mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 10:06:35 +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.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { prisma } from '@shumai/db'
|
|
import { workflowService } from '@shumai/workflow-core'
|
|
import { WorkflowTaskType, WorkflowTaskStatus } from '@shumai/db'
|
|
|
|
export async function executeAgentToolWorkflow(params: {
|
|
toolName: string
|
|
args: Record<string, unknown>
|
|
userId: string
|
|
assetId: string
|
|
}): Promise<unknown> {
|
|
const task = await prisma.workflowTask.create({
|
|
data: {
|
|
type: WorkflowTaskType.agent_tool_call,
|
|
status: WorkflowTaskStatus.pending,
|
|
assetId: params.assetId,
|
|
payload: {
|
|
projectId: 'none',
|
|
agentToolCall: {
|
|
toolName: params.toolName,
|
|
args: params.args,
|
|
userId: params.userId,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
const completedTask = await workflowService.executeWait(task)
|
|
if (completedTask.status === WorkflowTaskStatus.failed) {
|
|
const output = completedTask.output as Record<string, unknown> | null
|
|
const errorMsg = (output?.error as string) || 'Workflow task failed'
|
|
throw new Error(errorMsg)
|
|
}
|
|
|
|
return completedTask.output
|
|
}
|