mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 09:19:27 +00:00
Splits monolithic workflow workers into four decoupled workspaces under the Bun workspaces monorepo: - @shumai/workflow-core containing the core execution engine and utilities. - @shumai/agent containing agent-specific logic, workflows, and activities. - @shumai/transcode containing transcoding workflows, transcoder, and transcode activities. - @shumai/worker-db containing database activities. Introduces a dynamic workflow and activity registration pattern on LocalExecutor to eliminate circular dependencies. Updates worker bootstrapping and test suites to cleanly leverage generic workspace modules.
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { Type } from '@sinclair/typebox'
|
|
import { type AgentTool } from '@earendil-works/pi-agent-core'
|
|
import { executeAgentToolWorkflow } from './utils'
|
|
|
|
const listAssetsSchema = Type.Object({
|
|
parent: Type.String({
|
|
description: 'The parent folder ID to list assets from. This parameter is required.',
|
|
}),
|
|
page: Type.Optional(
|
|
Type.Number({
|
|
description: 'The page number to retrieve, default is 1.',
|
|
default: 1,
|
|
}),
|
|
),
|
|
pageSize: Type.Optional(
|
|
Type.Number({
|
|
description: 'The number of assets per page, default is 20.',
|
|
default: 20,
|
|
}),
|
|
),
|
|
type: Type.Optional(
|
|
Type.String({
|
|
description: "Filter assets by type: 'file', 'folder', or 'all'. Default is 'all'.",
|
|
enum: ['file', 'folder', 'all'],
|
|
default: 'all',
|
|
}),
|
|
),
|
|
})
|
|
|
|
export function createListAssetsTool(userId: string): AgentTool<typeof listAssetsSchema> {
|
|
return {
|
|
name: 'list_assets',
|
|
label: 'List Assets',
|
|
description: 'List the assets (files and folders) inside a parent folder with pagination.',
|
|
parameters: listAssetsSchema,
|
|
execute: async (_toolCallId, params) => {
|
|
try {
|
|
const result = await executeAgentToolWorkflow({
|
|
toolName: 'list_assets',
|
|
args: params,
|
|
userId,
|
|
assetId: params.parent,
|
|
})
|
|
return {
|
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
details: result,
|
|
}
|
|
} catch (error) {
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: `Error listing assets: ${error instanceof Error ? error.message : String(error)}`,
|
|
},
|
|
],
|
|
details: {},
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|