forked from TrafficGuard/typedai
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcodeTaskAgentRunner.ts
More file actions
32 lines (29 loc) · 1.43 KB
/
codeTaskAgentRunner.ts
File metadata and controls
32 lines (29 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { startWorkflowAgent } from '#agent/workflow/workflowAgentRunner';
import { logger } from '#o11y/logger';
import type { CodeTask } from '#shared/codeTask/codeTask.model';
import type { CodeTaskRepository } from './codeTaskRepository';
export async function runCodeTaskWorkflowAgent(codeTask: CodeTask, subtype: string, codeTaskRepo: CodeTaskRepository, workflow: () => any): Promise<any> {
// Prepare agent config, ensuring codeTaskId is included
const execution = await startWorkflowAgent(
{
agentName: `code-task-${codeTask.id}-${subtype}`,
functions: [], // TODO: Add necessary functions (e.g., SCM, FileSystem)
initialPrompt: codeTask.instructions, // Or specific prompt for the step
codeTaskId: codeTask.id,
subtype,
// Assuming user is fetched earlier or passed in codeTask object if needed
// user: codeTask.user,
// Assuming fileSystemPath is derived correctly for the codeTask
// fileSystemPath: join(process.cwd(), 'codeTask-workspaces', codeTask.userId, codeTask.id),
},
workflow,
);
// Update CodeTask state immediately after starting the agent
const agentId = execution.agentId;
await codeTaskRepo.updateCodeTask(codeTask.userId, codeTask.id, {
agentHistory: [...(codeTask.agentHistory || []), agentId], // Append to history
lastAgentActivity: Date.now(),
});
logger.info({ codeTask: codeTask.id, agentId, subtype }, 'CodeTask updated with current agent and history.');
await execution.execution;
}