@posthog/agent 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +6 -1
- package/dist/src/agent.js.map +1 -1
- package/dist/src/event-transformer.d.ts +1 -0
- package/dist/src/event-transformer.d.ts.map +1 -1
- package/dist/src/event-transformer.js +53 -6
- package/dist/src/event-transformer.js.map +1 -1
- package/dist/src/stage-executor.d.ts.map +1 -1
- package/dist/src/stage-executor.js +6 -0
- package/dist/src/stage-executor.js.map +1 -1
- package/dist/src/task-progress-reporter.d.ts +2 -0
- package/dist/src/task-progress-reporter.d.ts.map +1 -1
- package/dist/src/task-progress-reporter.js +39 -2
- package/dist/src/task-progress-reporter.js.map +1 -1
- package/dist/src/types.d.ts +7 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +1 -1
- package/src/agent.ts +6 -1
- package/src/event-transformer.ts +58 -6
- package/src/stage-executor.ts +10 -0
- package/src/task-progress-reporter.ts +44 -2
- package/src/types.ts +9 -1
package/dist/src/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAcpD,qBAAa,KAAK;IACd,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAAC,CAAmB;IACtC,OAAO,CAAC,WAAW,CAAqB;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AS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO9D,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxF,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO9F,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBlH,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1F,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAUhC,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAUrD,OAAO,CAAC,SAAS;CAapB;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/src/agent.js
CHANGED
|
@@ -319,8 +319,13 @@ class Agent {
|
|
|
319
319
|
const results = [];
|
|
320
320
|
for await (const message of response) {
|
|
321
321
|
this.logger.debug('Received message in direct run', message);
|
|
322
|
+
// Emit raw SDK event
|
|
323
|
+
this.emitEvent(this.eventTransformer.createRawSDKEvent(message));
|
|
324
|
+
// Emit transformed event
|
|
322
325
|
const transformedEvent = this.eventTransformer.transform(message);
|
|
323
|
-
|
|
326
|
+
if (transformedEvent) {
|
|
327
|
+
this.emitEvent(transformedEvent);
|
|
328
|
+
}
|
|
324
329
|
results.push(message);
|
|
325
330
|
}
|
|
326
331
|
return { results };
|
package/dist/src/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Task, ExecutionResult, PlanResult, AgentConfig } from './types.js';\nimport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\nimport { TaskManager } from './task-manager.js';\nimport { PostHogAPIClient } from './posthog-api.js';\nimport { PostHogFileManager } from './file-manager.js';\nimport { GitManager } from './git-manager.js';\nimport { TemplateManager } from './template-manager.js';\nimport { EventTransformer } from './event-transformer.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { Logger } from './utils/logger.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport { WorkflowRegistry } from './workflow-registry.js';\nimport { StageExecutor } from './stage-executor.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\n\nexport class Agent {\n private workingDirectory: string;\n private onEvent?: (event: any) => void;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private eventTransformer: EventTransformer;\n private logger: Logger;\n private agentRegistry: AgentRegistry;\n private workflowRegistry: WorkflowRegistry;\n private stageExecutor: StageExecutor;\n private progressReporter: TaskProgressReporter;\n private mcpServers?: Record<string, any>;\n public debug: boolean;\n\n constructor(config: AgentConfig = {}) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl = config.posthogMcpUrl\n || process.env.POSTHOG_MCP_URL\n || 'https://mcp.posthog.com/mcp';\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers['Authorization'] = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: 'http' as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n }\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers\n };\n this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });\n this.taskManager = new TaskManager();\n this.eventTransformer = new EventTransformer();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child('FileManager')\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child('GitManager')\n // TODO: Add author config from environment or config\n });\n this.templateManager = new TemplateManager();\n this.agentRegistry = new AgentRegistry();\n\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n });\n }\n\n this.workflowRegistry = new WorkflowRegistry(this.posthogAPI);\n const promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n logger: this.logger.child('PromptBuilder')\n });\n this.stageExecutor = new StageExecutor(\n this.agentRegistry,\n this.logger,\n promptBuilder,\n undefined, // eventHandler set via setEventHandler below\n this.mcpServers\n );\n this.stageExecutor.setEventHandler((event) => this.emitEvent(event));\n this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {\n return;\n }\n\n try {\n const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n\n this.logger.debug('Configured LLM gateway', { gatewayUrl });\n } catch (error) {\n this.logger.error('Failed to configure LLM gateway', error);\n throw error;\n }\n }\n\n // Workflow-based execution\n async runWorkflow(taskOrId: Task | string, workflowId: string, options: WorkflowExecutionOptions = {}): Promise<{ task: Task; workflow: WorkflowDefinition }> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n await this.workflowRegistry.loadWorkflows();\n const workflow = this.workflowRegistry.getWorkflow(workflowId);\n if (!workflow) {\n throw new Error(`Workflow ${workflowId} not found`);\n }\n const orderedStages = [...workflow.stages].sort((a, b) => a.position - b.position);\n\n // Ensure task is assigned to workflow and positioned at first stage\n if (this.posthogAPI) {\n try {\n if ((task.workflow as any) !== workflowId) {\n await this.posthogAPI.updateTask(task.id, { workflow: workflowId } as any);\n (task as any).workflow = workflowId;\n }\n if (!(task as any).current_stage && workflow.stages.length > 0) {\n const firstStage = [...workflow.stages].sort((a, b) => a.position - b.position)[0];\n await this.posthogAPI.updateTaskStage(task.id, firstStage.id);\n (task as any).current_stage = firstStage.id;\n }\n } catch (e) {\n this.logger.warn('Failed to sync task workflow/stage before execution', { error: (e as Error).message });\n }\n }\n\n const executionId = this.taskManager.generateExecutionId();\n this.logger.info('Starting workflow execution', { taskId: task.id, workflowId, executionId });\n this.taskManager.startExecution(task.id, 'plan_and_build', executionId);\n await this.progressReporter.start(task.id, {\n workflowId,\n workflowRunId: executionId,\n totalSteps: orderedStages.length,\n });\n\n try {\n let startIndex = 0;\n const currentStageId = (task as any).current_stage as string | undefined;\n\n // If task is already at the last stage, fail gracefully without progressing\n if (currentStageId) {\n const currIdx = orderedStages.findIndex(s => s.id === currentStageId);\n const atLastStage = currIdx >= 0 && currIdx === orderedStages.length - 1;\n if (atLastStage) {\n const finalStageKey = orderedStages[currIdx]?.key;\n this.emitEvent(this.eventTransformer.createStatusEvent('no_next_stage', { stage: finalStageKey }));\n await this.progressReporter.noNextStage(finalStageKey);\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n }\n }\n\n if (options.resumeFromCurrentStage && currentStageId) {\n const idx = orderedStages.findIndex(s => s.id === currentStageId);\n if (idx >= 0) startIndex = idx;\n }\n\n // Align server-side stage when restarting from the beginning\n if (this.posthogAPI) {\n const targetStage = orderedStages[startIndex];\n if (targetStage && targetStage.id !== currentStageId) {\n try { await this.posthogAPI.updateTaskStage(task.id, targetStage.id); (task as any).current_stage = targetStage.id; } catch {}\n }\n }\n\n for (let i = startIndex; i < orderedStages.length; i++) {\n const stage = orderedStages[i];\n await this.progressReporter.stageStarted(stage.key, i);\n await this.executeStage(task, stage, options);\n await this.progressReporter.stageCompleted(stage.key, i + 1);\n if (options.autoProgress) {\n const hasNext = i < orderedStages.length - 1;\n if (hasNext) {\n await this.progressToNextStage(task.id, stage.key);\n }\n }\n }\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n } catch (error) {\n await this.progressReporter.fail(error as Error);\n this.taskManager.failExecution(executionId, error as Error);\n throw error;\n }\n }\n\n async executeStage(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions = {}): Promise<void> {\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_start', { stage: stage.key }));\n const overrides = options.stageOverrides?.[stage.key];\n const agentName = stage.agent_name || 'code_generation';\n const agentDef = this.agentRegistry.getAgent(agentName);\n const isManual = stage.is_manual_only === true;\n const stageKeyLower = (stage.key || '').toLowerCase().trim();\n const isPlanningByKey = stageKeyLower === 'plan' || stageKeyLower.includes('plan');\n const isPlanning = !isManual && ((agentDef?.agent_type === 'planning') || isPlanningByKey);\n const shouldCreatePlanningBranch = overrides?.createPlanningBranch !== false; // default true\n const shouldCreateImplBranch = overrides?.createImplementationBranch !== false; // default true\n\n if (isPlanning && shouldCreatePlanningBranch) {\n const planningBranch = await this.createPlanningBranch(task.id);\n await this.updateTaskBranch(task.id, planningBranch);\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: planningBranch }));\n await this.progressReporter.branchCreated(stage.key, planningBranch);\n } else if (!isPlanning && !isManual && shouldCreateImplBranch) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n\n const result = await this.stageExecutor.execute(task, stage, options);\n\n if (result.plan) {\n await this.writePlan(task.id, result.plan);\n await this.commitPlan(task.id, task.title);\n this.emitEvent(this.eventTransformer.createStatusEvent('commit_made', { stage: stage.key, kind: 'plan' }));\n await this.progressReporter.commitMade(stage.key, 'plan');\n }\n\n if (isManual) {\n const defaultOpenPR = true; // manual stages default to PR for review\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n // Ensure we're on an implementation branch for PRs\n let branchName = await this.gitManager.getCurrentBranch();\n const onTaskBranch = branchName.includes(`posthog/task-${task.id}`);\n if (!onTaskBranch && (overrides?.createImplementationBranch !== false)) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n branchName = implBranch;\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.eventTransformer.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n // Do not auto-progress on manual stages\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_complete', { stage: stage.key }));\n return;\n }\n\n if (result.results) {\n const existingPlan = await this.readPlan(task.id);\n const planSummary = existingPlan ? existingPlan.split('\\n')[0] : undefined;\n await this.commitImplementation(task.id, task.title, planSummary);\n this.emitEvent(this.eventTransformer.createStatusEvent('commit_made', { stage: stage.key, kind: 'implementation' }));\n await this.progressReporter.commitMade(stage.key, 'implementation');\n }\n\n // PR creation on complete stage (or if explicitly requested), regardless of whether edits occurred\n {\n const defaultOpenPR = stage.key.toLowerCase().includes('complete');\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n const branchName = await this.gitManager.getCurrentBranch();\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.eventTransformer.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n }\n\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_complete', { stage: stage.key }));\n }\n\n async progressToNextStage(taskId: string, currentStageKey?: string): Promise<void> {\n if (!this.posthogAPI) throw new Error('PostHog API not configured. Cannot progress stage.');\n try {\n await this.posthogAPI.progressTask(taskId, { auto: true });\n } catch (error) {\n if (error instanceof Error && error.message.includes('No next stage available')) {\n this.logger.warn('No next stage available when attempting to progress task', {\n taskId,\n stage: currentStageKey,\n error: error.message,\n });\n this.emitEvent(this.eventTransformer.createStatusEvent('no_next_stage', { stage: currentStageKey }));\n await this.progressReporter.noNextStage(currentStageKey);\n return;\n }\n throw error;\n }\n }\n\n // Direct prompt execution - still supported for low-level usage\n async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {\n await this._configureLlmGateway();\n const baseOptions: Record<string, any> = {\n model: \"claude-sonnet-4-5-20250929\",\n cwd: options.repositoryPath || this.workingDirectory,\n permissionMode: (options.permissionMode as any) || \"default\",\n settingSources: [\"local\"],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n const results = [];\n for await (const message of response) {\n this.logger.debug('Received message in direct run', message);\n const transformedEvent = this.eventTransformer.transform(message);\n this.onEvent?.(transformedEvent);\n results.push(message);\n }\n \n return { results };\n }\n \n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n this.logger.debug('Fetching task from PostHog', { taskId });\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n \n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n workflow?: string;\n current_stage?: string;\n }): Promise<Task[]> {\n if (!this.posthogAPI) {\n throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n }\n return this.posthogAPI.listTasks(filters);\n }\n \n // File system operations for task artifacts\n async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {\n this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });\n await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });\n }\n \n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n this.logger.debug('Reading task file', { taskId, fileName });\n return await this.fileManager.readTaskFile(taskId, fileName);\n }\n \n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug('Getting task files', { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug('Found task files', { taskId, fileCount: files.length });\n return files;\n }\n \n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.info('Writing plan', { taskId, planLength: plan.length });\n await this.fileManager.writePlan(taskId, plan);\n }\n \n async readPlan(taskId: string): Promise<string | null> {\n this.logger.debug('Reading plan', { taskId });\n return await this.fileManager.readPlan(taskId);\n }\n \n // Git operations for task workflow\n async createPlanningBranch(taskId: string): Promise<string> {\n this.logger.info('Creating planning branch', { taskId });\n const branchName = await this.gitManager.createTaskPlanningBranch(taskId);\n this.logger.debug('Planning branch created', { taskId, branchName });\n // Only create gitignore after we're on the new branch\n await this.fileManager.ensureGitignore();\n return branchName;\n }\n \n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n this.logger.info('Committing plan', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);\n this.logger.debug('Plan committed', { taskId, commitHash });\n return commitHash;\n }\n \n async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });\n const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);\n this.logger.debug('Implementation branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n this.logger.info('Committing implementation', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);\n this.logger.debug('Implementation committed', { taskId, commitHash });\n return commitHash;\n }\n\n async createPullRequest(taskId: string, branchName: string, taskTitle: string, taskDescription: string): Promise<string> {\n this.logger.info('Creating pull request', { taskId, branchName, taskTitle });\n\n // Build PR body\n const prBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody\n );\n\n this.logger.info('Pull request created', { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {\n this.logger.info('Attaching PR to task', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.attachTaskPullRequest(taskId, prUrl, branchName);\n this.logger.debug('PR attached to task', { taskId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task branch', { taskId, branchName });\n\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Cannot update task branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.setTaskBranch(taskId, branchName);\n this.logger.debug('Task branch updated', { taskId, branchName });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager['executionStates']) {\n if (execution.taskId === taskId && execution.status === 'running') {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager['executionStates'].values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private emitEvent(event: any): void {\n if (this.debug && event.type !== 'token') {\n // Log all events except tokens (too verbose)\n this.logger.debug('Emitting event', { type: event.type, ts: event.ts });\n }\n const persistPromise = this.progressReporter.recordEvent(event);\n if (persistPromise && typeof persistPromise.then === 'function') {\n persistPromise.catch((error: Error) =>\n this.logger.debug('Failed to persist agent event', { message: error.message })\n );\n }\n this.onEvent?.(event);\n }\n}\n\nexport { PermissionMode } from './types.js';\nexport type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';\nexport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAkBa,KAAK,CAAA;AACN,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,WAAW;AACX,IA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AI,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC;gBAC7C;YACJ;QACJ;IACJ;AAEA,IAAA,sBAAsB,CAAC,MAAc,EAAA;;AAEjC,QAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;AAClE,YAAA,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC7B,OAAO,SAAS,CAAC,MAAM;YAC3B;QACJ;AACA,QAAA,OAAO,IAAI;IACf;AAEQ,IAAA,SAAS,CAAC,KAAU,EAAA;QACxB,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;;YAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3E;QACA,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC;QAC/D,IAAI,cAAc,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,UAAU,EAAE;YAC7D,cAAc,CAAC,KAAK,CAAC,CAAC,KAAY,KAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CACjF;QACL;AACA,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Task, ExecutionResult, PlanResult, AgentConfig } from './types.js';\nimport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\nimport { TaskManager } from './task-manager.js';\nimport { PostHogAPIClient } from './posthog-api.js';\nimport { PostHogFileManager } from './file-manager.js';\nimport { GitManager } from './git-manager.js';\nimport { TemplateManager } from './template-manager.js';\nimport { EventTransformer } from './event-transformer.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { Logger } from './utils/logger.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport { WorkflowRegistry } from './workflow-registry.js';\nimport { StageExecutor } from './stage-executor.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\n\nexport class Agent {\n private workingDirectory: string;\n private onEvent?: (event: any) => void;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private eventTransformer: EventTransformer;\n private logger: Logger;\n private agentRegistry: AgentRegistry;\n private workflowRegistry: WorkflowRegistry;\n private stageExecutor: StageExecutor;\n private progressReporter: TaskProgressReporter;\n private mcpServers?: Record<string, any>;\n public debug: boolean;\n\n constructor(config: AgentConfig = {}) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl = config.posthogMcpUrl\n || process.env.POSTHOG_MCP_URL\n || 'https://mcp.posthog.com/mcp';\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers['Authorization'] = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: 'http' as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n }\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers\n };\n this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });\n this.taskManager = new TaskManager();\n this.eventTransformer = new EventTransformer();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child('FileManager')\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child('GitManager')\n // TODO: Add author config from environment or config\n });\n this.templateManager = new TemplateManager();\n this.agentRegistry = new AgentRegistry();\n\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n });\n }\n\n this.workflowRegistry = new WorkflowRegistry(this.posthogAPI);\n const promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n logger: this.logger.child('PromptBuilder')\n });\n this.stageExecutor = new StageExecutor(\n this.agentRegistry,\n this.logger,\n promptBuilder,\n undefined, // eventHandler set via setEventHandler below\n this.mcpServers\n );\n this.stageExecutor.setEventHandler((event) => this.emitEvent(event));\n this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {\n return;\n }\n\n try {\n const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n\n this.logger.debug('Configured LLM gateway', { gatewayUrl });\n } catch (error) {\n this.logger.error('Failed to configure LLM gateway', error);\n throw error;\n }\n }\n\n // Workflow-based execution\n async runWorkflow(taskOrId: Task | string, workflowId: string, options: WorkflowExecutionOptions = {}): Promise<{ task: Task; workflow: WorkflowDefinition }> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n await this.workflowRegistry.loadWorkflows();\n const workflow = this.workflowRegistry.getWorkflow(workflowId);\n if (!workflow) {\n throw new Error(`Workflow ${workflowId} not found`);\n }\n const orderedStages = [...workflow.stages].sort((a, b) => a.position - b.position);\n\n // Ensure task is assigned to workflow and positioned at first stage\n if (this.posthogAPI) {\n try {\n if ((task.workflow as any) !== workflowId) {\n await this.posthogAPI.updateTask(task.id, { workflow: workflowId } as any);\n (task as any).workflow = workflowId;\n }\n if (!(task as any).current_stage && workflow.stages.length > 0) {\n const firstStage = [...workflow.stages].sort((a, b) => a.position - b.position)[0];\n await this.posthogAPI.updateTaskStage(task.id, firstStage.id);\n (task as any).current_stage = firstStage.id;\n }\n } catch (e) {\n this.logger.warn('Failed to sync task workflow/stage before execution', { error: (e as Error).message });\n }\n }\n\n const executionId = this.taskManager.generateExecutionId();\n this.logger.info('Starting workflow execution', { taskId: task.id, workflowId, executionId });\n this.taskManager.startExecution(task.id, 'plan_and_build', executionId);\n await this.progressReporter.start(task.id, {\n workflowId,\n workflowRunId: executionId,\n totalSteps: orderedStages.length,\n });\n\n try {\n let startIndex = 0;\n const currentStageId = (task as any).current_stage as string | undefined;\n\n // If task is already at the last stage, fail gracefully without progressing\n if (currentStageId) {\n const currIdx = orderedStages.findIndex(s => s.id === currentStageId);\n const atLastStage = currIdx >= 0 && currIdx === orderedStages.length - 1;\n if (atLastStage) {\n const finalStageKey = orderedStages[currIdx]?.key;\n this.emitEvent(this.eventTransformer.createStatusEvent('no_next_stage', { stage: finalStageKey }));\n await this.progressReporter.noNextStage(finalStageKey);\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n }\n }\n\n if (options.resumeFromCurrentStage && currentStageId) {\n const idx = orderedStages.findIndex(s => s.id === currentStageId);\n if (idx >= 0) startIndex = idx;\n }\n\n // Align server-side stage when restarting from the beginning\n if (this.posthogAPI) {\n const targetStage = orderedStages[startIndex];\n if (targetStage && targetStage.id !== currentStageId) {\n try { await this.posthogAPI.updateTaskStage(task.id, targetStage.id); (task as any).current_stage = targetStage.id; } catch {}\n }\n }\n\n for (let i = startIndex; i < orderedStages.length; i++) {\n const stage = orderedStages[i];\n await this.progressReporter.stageStarted(stage.key, i);\n await this.executeStage(task, stage, options);\n await this.progressReporter.stageCompleted(stage.key, i + 1);\n if (options.autoProgress) {\n const hasNext = i < orderedStages.length - 1;\n if (hasNext) {\n await this.progressToNextStage(task.id, stage.key);\n }\n }\n }\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n } catch (error) {\n await this.progressReporter.fail(error as Error);\n this.taskManager.failExecution(executionId, error as Error);\n throw error;\n }\n }\n\n async executeStage(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions = {}): Promise<void> {\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_start', { stage: stage.key }));\n const overrides = options.stageOverrides?.[stage.key];\n const agentName = stage.agent_name || 'code_generation';\n const agentDef = this.agentRegistry.getAgent(agentName);\n const isManual = stage.is_manual_only === true;\n const stageKeyLower = (stage.key || '').toLowerCase().trim();\n const isPlanningByKey = stageKeyLower === 'plan' || stageKeyLower.includes('plan');\n const isPlanning = !isManual && ((agentDef?.agent_type === 'planning') || isPlanningByKey);\n const shouldCreatePlanningBranch = overrides?.createPlanningBranch !== false; // default true\n const shouldCreateImplBranch = overrides?.createImplementationBranch !== false; // default true\n\n if (isPlanning && shouldCreatePlanningBranch) {\n const planningBranch = await this.createPlanningBranch(task.id);\n await this.updateTaskBranch(task.id, planningBranch);\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: planningBranch }));\n await this.progressReporter.branchCreated(stage.key, planningBranch);\n } else if (!isPlanning && !isManual && shouldCreateImplBranch) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n\n const result = await this.stageExecutor.execute(task, stage, options);\n\n if (result.plan) {\n await this.writePlan(task.id, result.plan);\n await this.commitPlan(task.id, task.title);\n this.emitEvent(this.eventTransformer.createStatusEvent('commit_made', { stage: stage.key, kind: 'plan' }));\n await this.progressReporter.commitMade(stage.key, 'plan');\n }\n\n if (isManual) {\n const defaultOpenPR = true; // manual stages default to PR for review\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n // Ensure we're on an implementation branch for PRs\n let branchName = await this.gitManager.getCurrentBranch();\n const onTaskBranch = branchName.includes(`posthog/task-${task.id}`);\n if (!onTaskBranch && (overrides?.createImplementationBranch !== false)) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n branchName = implBranch;\n this.emitEvent(this.eventTransformer.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.eventTransformer.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n // Do not auto-progress on manual stages\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_complete', { stage: stage.key }));\n return;\n }\n\n if (result.results) {\n const existingPlan = await this.readPlan(task.id);\n const planSummary = existingPlan ? existingPlan.split('\\n')[0] : undefined;\n await this.commitImplementation(task.id, task.title, planSummary);\n this.emitEvent(this.eventTransformer.createStatusEvent('commit_made', { stage: stage.key, kind: 'implementation' }));\n await this.progressReporter.commitMade(stage.key, 'implementation');\n }\n\n // PR creation on complete stage (or if explicitly requested), regardless of whether edits occurred\n {\n const defaultOpenPR = stage.key.toLowerCase().includes('complete');\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n const branchName = await this.gitManager.getCurrentBranch();\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.eventTransformer.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n }\n\n this.emitEvent(this.eventTransformer.createStatusEvent('stage_complete', { stage: stage.key }));\n }\n\n async progressToNextStage(taskId: string, currentStageKey?: string): Promise<void> {\n if (!this.posthogAPI) throw new Error('PostHog API not configured. Cannot progress stage.');\n try {\n await this.posthogAPI.progressTask(taskId, { auto: true });\n } catch (error) {\n if (error instanceof Error && error.message.includes('No next stage available')) {\n this.logger.warn('No next stage available when attempting to progress task', {\n taskId,\n stage: currentStageKey,\n error: error.message,\n });\n this.emitEvent(this.eventTransformer.createStatusEvent('no_next_stage', { stage: currentStageKey }));\n await this.progressReporter.noNextStage(currentStageKey);\n return;\n }\n throw error;\n }\n }\n\n // Direct prompt execution - still supported for low-level usage\n async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {\n await this._configureLlmGateway();\n const baseOptions: Record<string, any> = {\n model: \"claude-sonnet-4-5-20250929\",\n cwd: options.repositoryPath || this.workingDirectory,\n permissionMode: (options.permissionMode as any) || \"default\",\n settingSources: [\"local\"],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n const results = [];\n for await (const message of response) {\n this.logger.debug('Received message in direct run', message);\n // Emit raw SDK event\n this.emitEvent(this.eventTransformer.createRawSDKEvent(message));\n // Emit transformed event\n const transformedEvent = this.eventTransformer.transform(message);\n if (transformedEvent) {\n this.emitEvent(transformedEvent);\n }\n results.push(message);\n }\n \n return { results };\n }\n \n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n this.logger.debug('Fetching task from PostHog', { taskId });\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n \n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n workflow?: string;\n current_stage?: string;\n }): Promise<Task[]> {\n if (!this.posthogAPI) {\n throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n }\n return this.posthogAPI.listTasks(filters);\n }\n \n // File system operations for task artifacts\n async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {\n this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });\n await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });\n }\n \n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n this.logger.debug('Reading task file', { taskId, fileName });\n return await this.fileManager.readTaskFile(taskId, fileName);\n }\n \n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug('Getting task files', { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug('Found task files', { taskId, fileCount: files.length });\n return files;\n }\n \n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.info('Writing plan', { taskId, planLength: plan.length });\n await this.fileManager.writePlan(taskId, plan);\n }\n \n async readPlan(taskId: string): Promise<string | null> {\n this.logger.debug('Reading plan', { taskId });\n return await this.fileManager.readPlan(taskId);\n }\n \n // Git operations for task workflow\n async createPlanningBranch(taskId: string): Promise<string> {\n this.logger.info('Creating planning branch', { taskId });\n const branchName = await this.gitManager.createTaskPlanningBranch(taskId);\n this.logger.debug('Planning branch created', { taskId, branchName });\n // Only create gitignore after we're on the new branch\n await this.fileManager.ensureGitignore();\n return branchName;\n }\n \n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n this.logger.info('Committing plan', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);\n this.logger.debug('Plan committed', { taskId, commitHash });\n return commitHash;\n }\n \n async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });\n const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);\n this.logger.debug('Implementation branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n this.logger.info('Committing implementation', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);\n this.logger.debug('Implementation committed', { taskId, commitHash });\n return commitHash;\n }\n\n async createPullRequest(taskId: string, branchName: string, taskTitle: string, taskDescription: string): Promise<string> {\n this.logger.info('Creating pull request', { taskId, branchName, taskTitle });\n\n // Build PR body\n const prBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody\n );\n\n this.logger.info('Pull request created', { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {\n this.logger.info('Attaching PR to task', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.attachTaskPullRequest(taskId, prUrl, branchName);\n this.logger.debug('PR attached to task', { taskId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task branch', { taskId, branchName });\n\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Cannot update task branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.setTaskBranch(taskId, branchName);\n this.logger.debug('Task branch updated', { taskId, branchName });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager['executionStates']) {\n if (execution.taskId === taskId && execution.status === 'running') {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager['executionStates'].values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private emitEvent(event: any): void {\n if (this.debug && event.type !== 'token') {\n // Log all events except tokens (too verbose)\n this.logger.debug('Emitting event', { type: event.type, ts: event.ts });\n }\n const persistPromise = this.progressReporter.recordEvent(event);\n if (persistPromise && typeof persistPromise.then === 'function') {\n persistPromise.catch((error: Error) =>\n this.logger.debug('Failed to persist agent event', { message: error.message })\n );\n }\n this.onEvent?.(event);\n }\n}\n\nexport { PermissionMode } from './types.js';\nexport type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';\nexport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAkBa,KAAK,CAAA;AACN,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,eAAe;AACf,IAAA,gBAAgB;AAChB,IAAA,MAAM;AACN,IAAA,aAAa;AACb,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,gBAAgB;AAChB,IAAA,UAAU;AACX,IAAA,KAAK;AAEZ,IAAA,WAAA,CAAY,SAAsB,EAAE,EAAA;QAChC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;AAChE,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;QAC7B,I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;gBAC7B,OAAO,SAAS,CAAC,MAAM;YAC3B;QACJ;AACA,QAAA,OAAO,IAAI;IACf;AAEQ,IAAA,SAAS,CAAC,KAAU,EAAA;QACxB,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;;YAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3E;QACA,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC;QAC/D,IAAI,cAAc,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,UAAU,EAAE;YAC7D,cAAc,CAAC,KAAK,CAAC,CAAC,KAAY,KAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CACjF;QACL;AACA,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB;AACH;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentEvent } from './types.js';
|
|
2
2
|
import type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
export declare class EventTransformer {
|
|
4
|
+
createRawSDKEvent(sdkMessage: any): AgentEvent;
|
|
4
5
|
transform(sdkMessage: SDKMessage): AgentEvent | null;
|
|
5
6
|
createStatusEvent(phase: string, additionalData?: any): AgentEvent;
|
|
6
7
|
private extractUserContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-transformer.d.ts","sourceRoot":"","sources":["../../src/event-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"event-transformer.d.ts","sourceRoot":"","sources":["../../src/event-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,qBAAa,gBAAgB;IAC3B,iBAAiB,CAAC,UAAU,EAAE,GAAG,GAAG,UAAU;IAQ9C,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IA2NpD,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,GAAG,GAAG,UAAU;IASlE,OAAO,CAAC,kBAAkB;IAkC1B,OAAO,CAAC,iBAAiB;CAoB1B"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
class EventTransformer {
|
|
2
|
+
createRawSDKEvent(sdkMessage) {
|
|
3
|
+
return {
|
|
4
|
+
type: 'raw_sdk_event',
|
|
5
|
+
ts: Date.now(),
|
|
6
|
+
sdkMessage
|
|
7
|
+
};
|
|
8
|
+
}
|
|
2
9
|
transform(sdkMessage) {
|
|
3
10
|
const baseEvent = { ts: Date.now() };
|
|
4
11
|
// Handle stream events
|
|
@@ -83,7 +90,12 @@ class EventTransformer {
|
|
|
83
90
|
type: 'error',
|
|
84
91
|
message: event.error?.message || 'Unknown error',
|
|
85
92
|
error: event.error,
|
|
86
|
-
errorType: event.error?.type
|
|
93
|
+
errorType: event.error?.type || 'stream_error',
|
|
94
|
+
context: event.error ? {
|
|
95
|
+
type: event.error.type,
|
|
96
|
+
code: event.error.code,
|
|
97
|
+
} : undefined,
|
|
98
|
+
sdkError: event.error
|
|
87
99
|
};
|
|
88
100
|
default:
|
|
89
101
|
return null;
|
|
@@ -91,10 +103,23 @@ class EventTransformer {
|
|
|
91
103
|
}
|
|
92
104
|
// Handle assistant messages (full message, not streaming)
|
|
93
105
|
if (sdkMessage.type === 'assistant') {
|
|
94
|
-
// Extract tool calls from assistant message
|
|
95
106
|
const message = sdkMessage.message;
|
|
96
|
-
//
|
|
97
|
-
|
|
107
|
+
// Extract tool calls from content blocks
|
|
108
|
+
if (message.content && Array.isArray(message.content)) {
|
|
109
|
+
for (const block of message.content) {
|
|
110
|
+
if (block.type === 'tool_use') {
|
|
111
|
+
// Return first tool_call event found
|
|
112
|
+
return {
|
|
113
|
+
...baseEvent,
|
|
114
|
+
type: 'tool_call',
|
|
115
|
+
toolName: block.name,
|
|
116
|
+
callId: block.id,
|
|
117
|
+
args: block.input || {}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// If no tool calls, emit status event
|
|
98
123
|
return {
|
|
99
124
|
...baseEvent,
|
|
100
125
|
type: 'status',
|
|
@@ -105,7 +130,23 @@ class EventTransformer {
|
|
|
105
130
|
}
|
|
106
131
|
// Handle user messages
|
|
107
132
|
if (sdkMessage.type === 'user') {
|
|
108
|
-
const
|
|
133
|
+
const message = sdkMessage.message;
|
|
134
|
+
// Check for tool results in content blocks
|
|
135
|
+
if (message?.content && Array.isArray(message.content)) {
|
|
136
|
+
for (const block of message.content) {
|
|
137
|
+
if (block.type === 'tool_result') {
|
|
138
|
+
return {
|
|
139
|
+
...baseEvent,
|
|
140
|
+
type: 'tool_result',
|
|
141
|
+
toolName: block.tool_name || 'unknown',
|
|
142
|
+
callId: block.tool_use_id || '',
|
|
143
|
+
result: block.content
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Otherwise extract text content
|
|
149
|
+
const textContent = this.extractUserContent(message?.content);
|
|
109
150
|
if (!textContent) {
|
|
110
151
|
return null;
|
|
111
152
|
}
|
|
@@ -134,7 +175,13 @@ class EventTransformer {
|
|
|
134
175
|
type: 'error',
|
|
135
176
|
message: `Execution failed: ${sdkMessage.subtype}`,
|
|
136
177
|
error: { subtype: sdkMessage.subtype },
|
|
137
|
-
errorType: sdkMessage.subtype
|
|
178
|
+
errorType: sdkMessage.subtype || 'result_error',
|
|
179
|
+
context: {
|
|
180
|
+
subtype: sdkMessage.subtype,
|
|
181
|
+
duration_ms: sdkMessage.duration_ms,
|
|
182
|
+
num_turns: sdkMessage.num_turns
|
|
183
|
+
},
|
|
184
|
+
sdkError: sdkMessage
|
|
138
185
|
};
|
|
139
186
|
}
|
|
140
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-transformer.js","sources":["../../src/event-transformer.ts"],"sourcesContent":["import type { AgentEvent } from './types.js';\nimport type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';\n\nexport class EventTransformer {\n transform(sdkMessage: SDKMessage): AgentEvent | null {\n const baseEvent = { ts: Date.now() };\n\n // Handle stream events\n if (sdkMessage.type === 'stream_event') {\n const event = sdkMessage.event;\n\n switch (event.type) {\n case 'message_start':\n return {\n ...baseEvent,\n type: 'message_start',\n messageId: event.message?.id,\n model: event.message?.model\n };\n\n case 'content_block_start':\n const contentBlock = event.content_block;\n if (!contentBlock) return null;\n\n return {\n ...baseEvent,\n type: 'content_block_start',\n index: event.index,\n contentType: contentBlock.type as 'text' | 'tool_use' | 'thinking',\n toolName: contentBlock.type === 'tool_use' ? contentBlock.name : undefined,\n toolId: contentBlock.type === 'tool_use' ? contentBlock.id : undefined\n };\n\n case 'content_block_delta':\n const delta = event.delta;\n if (!delta) return null;\n\n if (delta.type === 'text_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.text,\n contentType: 'text'\n };\n } else if (delta.type === 'input_json_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.partial_json,\n contentType: 'tool_input'\n };\n } else if (delta.type === 'thinking_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.thinking,\n contentType: 'thinking'\n };\n }\n return null;\n\n case 'content_block_stop':\n return {\n ...baseEvent,\n type: 'content_block_stop',\n index: event.index\n };\n\n case 'message_delta':\n return {\n ...baseEvent,\n type: 'message_delta',\n stopReason: event.delta?.stop_reason,\n stopSequence: event.delta?.stop_sequence,\n usage: event.usage ? {\n outputTokens: event.usage.output_tokens\n } : undefined\n };\n\n case 'message_stop':\n return {\n ...baseEvent,\n type: 'message_stop'\n };\n\n case 'ping':\n // Ignore ping events\n return null;\n\n case 'error':\n return {\n ...baseEvent,\n type: 'error',\n message: event.error?.message || 'Unknown error',\n error: event.error,\n errorType: event.error?.type\n };\n\n default:\n return null;\n }\n }\n\n // Handle assistant messages (full message, not streaming)\n if (sdkMessage.type === 'assistant') {\n // Extract tool calls from assistant message\n const message = sdkMessage.message;\n // We could emit individual tool_call events here if needed\n // For now, just emit a status event\n return {\n ...baseEvent,\n type: 'status',\n phase: 'assistant_message',\n messageId: message.id,\n model: message.model\n };\n }\n\n // Handle user messages\n if (sdkMessage.type === 'user') {\n const textContent = this.extractUserContent(sdkMessage.message?.content);\n if (!textContent) {\n return null;\n }\n return {\n ...baseEvent,\n type: 'user_message',\n content: textContent,\n isSynthetic: sdkMessage.isSynthetic\n };\n }\n\n // Handle result messages\n if (sdkMessage.type === 'result') {\n if (sdkMessage.subtype === 'success') {\n return {\n ...baseEvent,\n type: 'done',\n durationMs: sdkMessage.duration_ms,\n numTurns: sdkMessage.num_turns,\n totalCostUsd: sdkMessage.total_cost_usd,\n usage: sdkMessage.usage\n };\n } else {\n return {\n ...baseEvent,\n type: 'error',\n message: `Execution failed: ${sdkMessage.subtype}`,\n error: { subtype: sdkMessage.subtype },\n errorType: sdkMessage.subtype\n };\n }\n }\n\n // Handle system messages\n if (sdkMessage.type === 'system') {\n if (sdkMessage.subtype === 'init') {\n return {\n ...baseEvent,\n type: 'init',\n model: sdkMessage.model,\n tools: sdkMessage.tools,\n permissionMode: sdkMessage.permissionMode,\n cwd: sdkMessage.cwd,\n apiKeySource: sdkMessage.apiKeySource\n };\n } else if (sdkMessage.subtype === 'compact_boundary') {\n return {\n ...baseEvent,\n type: 'compact_boundary',\n trigger: sdkMessage.compact_metadata.trigger,\n preTokens: sdkMessage.compact_metadata.pre_tokens\n };\n }\n }\n\n return null;\n }\n \n createStatusEvent(phase: string, additionalData?: any): AgentEvent {\n return {\n type: 'status',\n ts: Date.now(),\n phase,\n ...additionalData\n };\n }\n\n private extractUserContent(content: unknown): string | null {\n if (!content) {\n return null;\n }\n\n if (typeof content === 'string') {\n const trimmed = content.trim();\n return trimmed.length > 0 ? trimmed : null;\n }\n\n if (Array.isArray(content)) {\n const parts: string[] = [];\n for (const block of content) {\n const extracted = this.extractUserContent(block);\n if (extracted) {\n parts.push(extracted);\n } else if (block && typeof block === 'object') {\n const candidate = this.extractFromObject(block as Record<string, unknown>);\n if (candidate) {\n parts.push(candidate);\n }\n }\n }\n const text = parts.join('\\n').trim();\n return text.length > 0 ? text : null;\n }\n\n if (typeof content === 'object') {\n return this.extractFromObject(content as Record<string, unknown>);\n }\n\n return null;\n }\n\n private extractFromObject(value: Record<string, unknown>): string | null {\n const preferredKeys = ['text', 'input_text', 'input', 'markdown', 'content', 'message'];\n for (const key of preferredKeys) {\n if (typeof value[key] === 'string') {\n const trimmed = (value[key] as string).trim();\n if (trimmed.length > 0) {\n return trimmed;\n }\n }\n }\n\n for (const entry of Object.values(value)) {\n const extracted = this.extractUserContent(entry);\n if (extracted) {\n return extracted;\n }\n }\n\n return null;\n }\n}\n"],"names":[],"mappings":"MAGa,gBAAgB,CAAA;AAC3B,IAAA,SAAS,CAAC,UAAsB,EAAA;QAC9B,MAAM,SAAS,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;;AAGpC,QAAA,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,EAAE;AACtC,YAAA,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK;AAE9B,YAAA,QAAQ,KAAK,CAAC,IAAI;AAChB,gBAAA,KAAK,eAAe;oBAClB,OAAO;AACL,wBAAA,GAAG,SAAS;AACZ,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Content":["import type { AgentEvent } from './types.js';\nimport type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';\n\nexport class EventTransformer {\n createRawSDKEvent(sdkMessage: any): AgentEvent {\n return {\n type: 'raw_sdk_event',\n ts: Date.now(),\n sdkMessage\n };\n }\n\n transform(sdkMessage: SDKMessage): AgentEvent | null {\n const baseEvent = { ts: Date.now() };\n\n // Handle stream events\n if (sdkMessage.type === 'stream_event') {\n const event = sdkMessage.event;\n\n switch (event.type) {\n case 'message_start':\n return {\n ...baseEvent,\n type: 'message_start',\n messageId: event.message?.id,\n model: event.message?.model\n };\n\n case 'content_block_start':\n const contentBlock = event.content_block;\n if (!contentBlock) return null;\n\n return {\n ...baseEvent,\n type: 'content_block_start',\n index: event.index,\n contentType: contentBlock.type as 'text' | 'tool_use' | 'thinking',\n toolName: contentBlock.type === 'tool_use' ? contentBlock.name : undefined,\n toolId: contentBlock.type === 'tool_use' ? contentBlock.id : undefined\n };\n\n case 'content_block_delta':\n const delta = event.delta;\n if (!delta) return null;\n\n if (delta.type === 'text_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.text,\n contentType: 'text'\n };\n } else if (delta.type === 'input_json_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.partial_json,\n contentType: 'tool_input'\n };\n } else if (delta.type === 'thinking_delta') {\n return {\n ...baseEvent,\n type: 'token',\n content: delta.thinking,\n contentType: 'thinking'\n };\n }\n return null;\n\n case 'content_block_stop':\n return {\n ...baseEvent,\n type: 'content_block_stop',\n index: event.index\n };\n\n case 'message_delta':\n return {\n ...baseEvent,\n type: 'message_delta',\n stopReason: event.delta?.stop_reason,\n stopSequence: event.delta?.stop_sequence,\n usage: event.usage ? {\n outputTokens: event.usage.output_tokens\n } : undefined\n };\n\n case 'message_stop':\n return {\n ...baseEvent,\n type: 'message_stop'\n };\n\n case 'ping':\n // Ignore ping events\n return null;\n\n case 'error':\n return {\n ...baseEvent,\n type: 'error',\n message: event.error?.message || 'Unknown error',\n error: event.error,\n errorType: event.error?.type || 'stream_error',\n context: event.error ? {\n type: event.error.type,\n code: event.error.code,\n } : undefined,\n sdkError: event.error\n };\n\n default:\n return null;\n }\n }\n\n // Handle assistant messages (full message, not streaming)\n if (sdkMessage.type === 'assistant') {\n const message = sdkMessage.message;\n \n // Extract tool calls from content blocks\n if (message.content && Array.isArray(message.content)) {\n for (const block of message.content) {\n if (block.type === 'tool_use') {\n // Return first tool_call event found\n return {\n ...baseEvent,\n type: 'tool_call',\n toolName: block.name,\n callId: block.id,\n args: block.input || {}\n };\n }\n }\n }\n \n // If no tool calls, emit status event\n return {\n ...baseEvent,\n type: 'status',\n phase: 'assistant_message',\n messageId: message.id,\n model: message.model\n };\n }\n\n // Handle user messages\n if (sdkMessage.type === 'user') {\n const message = sdkMessage.message;\n \n // Check for tool results in content blocks\n if (message?.content && Array.isArray(message.content)) {\n for (const block of message.content) {\n if (block.type === 'tool_result') {\n return {\n ...baseEvent,\n type: 'tool_result',\n toolName: block.tool_name || 'unknown',\n callId: block.tool_use_id || '',\n result: block.content\n };\n }\n }\n }\n \n // Otherwise extract text content\n const textContent = this.extractUserContent(message?.content);\n if (!textContent) {\n return null;\n }\n return {\n ...baseEvent,\n type: 'user_message',\n content: textContent,\n isSynthetic: sdkMessage.isSynthetic\n };\n }\n\n // Handle result messages\n if (sdkMessage.type === 'result') {\n if (sdkMessage.subtype === 'success') {\n return {\n ...baseEvent,\n type: 'done',\n durationMs: sdkMessage.duration_ms,\n numTurns: sdkMessage.num_turns,\n totalCostUsd: sdkMessage.total_cost_usd,\n usage: sdkMessage.usage\n };\n } else {\n return {\n ...baseEvent,\n type: 'error',\n message: `Execution failed: ${sdkMessage.subtype}`,\n error: { subtype: sdkMessage.subtype },\n errorType: sdkMessage.subtype || 'result_error',\n context: {\n subtype: sdkMessage.subtype,\n duration_ms: sdkMessage.duration_ms,\n num_turns: sdkMessage.num_turns\n },\n sdkError: sdkMessage\n };\n }\n }\n\n // Handle system messages\n if (sdkMessage.type === 'system') {\n if (sdkMessage.subtype === 'init') {\n return {\n ...baseEvent,\n type: 'init',\n model: sdkMessage.model,\n tools: sdkMessage.tools,\n permissionMode: sdkMessage.permissionMode,\n cwd: sdkMessage.cwd,\n apiKeySource: sdkMessage.apiKeySource\n };\n } else if (sdkMessage.subtype === 'compact_boundary') {\n return {\n ...baseEvent,\n type: 'compact_boundary',\n trigger: sdkMessage.compact_metadata.trigger,\n preTokens: sdkMessage.compact_metadata.pre_tokens\n };\n }\n }\n\n return null;\n }\n \n createStatusEvent(phase: string, additionalData?: any): AgentEvent {\n return {\n type: 'status',\n ts: Date.now(),\n phase,\n ...additionalData\n };\n }\n\n private extractUserContent(content: unknown): string | null {\n if (!content) {\n return null;\n }\n\n if (typeof content === 'string') {\n const trimmed = content.trim();\n return trimmed.length > 0 ? trimmed : null;\n }\n\n if (Array.isArray(content)) {\n const parts: string[] = [];\n for (const block of content) {\n const extracted = this.extractUserContent(block);\n if (extracted) {\n parts.push(extracted);\n } else if (block && typeof block === 'object') {\n const candidate = this.extractFromObject(block as Record<string, unknown>);\n if (candidate) {\n parts.push(candidate);\n }\n }\n }\n const text = parts.join('\\n').trim();\n return text.length > 0 ? text : null;\n }\n\n if (typeof content === 'object') {\n return this.extractFromObject(content as Record<string, unknown>);\n }\n\n return null;\n }\n\n private extractFromObject(value: Record<string, unknown>): string | null {\n const preferredKeys = ['text', 'input_text', 'input', 'markdown', 'content', 'message'];\n for (const key of preferredKeys) {\n if (typeof value[key] === 'string') {\n const trimmed = (value[key] as string).trim();\n if (trimmed.length > 0) {\n return trimmed;\n }\n }\n }\n\n for (const entry of Object.values(value)) {\n const extracted = this.extractUserContent(entry);\n if (extracted) {\n return extracted;\n }\n }\n\n return null;\n }\n}\n"],"names":[],"mappings":"MAGa,gBAAgB,CAAA;AAC3B,IAAA,iBAAiB,CAAC,UAAe,EAAA;QAC/B,OAAO;AACL,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,EAAE,EAAE,IAAI,CAAC,GA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OAAO,CAAC,4BAA4B,CAAC;YA+B3G,WAAW;YA+CX,YAAY;CAwC3B"}
|
|
@@ -75,6 +75,9 @@ class StageExecutor {
|
|
|
75
75
|
});
|
|
76
76
|
let plan = '';
|
|
77
77
|
for await (const message of response) {
|
|
78
|
+
// Emit raw SDK event first
|
|
79
|
+
this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));
|
|
80
|
+
// Then emit transformed event
|
|
78
81
|
const transformed = this.eventTransformer.transform(message);
|
|
79
82
|
if (transformed) {
|
|
80
83
|
if (transformed.type !== 'token') {
|
|
@@ -112,6 +115,9 @@ class StageExecutor {
|
|
|
112
115
|
});
|
|
113
116
|
const results = [];
|
|
114
117
|
for await (const message of response) {
|
|
118
|
+
// Emit raw SDK event first
|
|
119
|
+
this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));
|
|
120
|
+
// Then emit transformed event
|
|
115
121
|
const transformed = this.eventTransformer.transform(message);
|
|
116
122
|
if (transformed) {
|
|
117
123
|
if (transformed.type !== 'token') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage-executor.js","sources":["../../src/stage-executor.ts"],"sourcesContent":["import { query } from '@anthropic-ai/claude-agent-sdk';\nimport { Logger } from './utils/logger.js';\nimport { EventTransformer } from './event-transformer.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport type { AgentEvent, Task, McpServerConfig } from './types.js';\nimport type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { PromptBuilder } from './prompt-builder.js';\n\nexport class StageExecutor {\n private registry: AgentRegistry;\n private logger: Logger;\n private eventTransformer: EventTransformer;\n private promptBuilder: PromptBuilder;\n private eventHandler?: (event: AgentEvent) => void;\n private mcpServers?: Record<string, McpServerConfig>;\n\n constructor(\n registry: AgentRegistry,\n logger: Logger,\n promptBuilder?: PromptBuilder,\n eventHandler?: (event: AgentEvent) => void,\n mcpServers?: Record<string, McpServerConfig>,\n ) {\n this.registry = registry;\n this.logger = logger.child('StageExecutor');\n this.eventTransformer = new EventTransformer();\n this.promptBuilder = promptBuilder || new PromptBuilder({\n getTaskFiles: async () => [],\n generatePlanTemplate: async () => '',\n logger,\n });\n this.eventHandler = eventHandler;\n this.mcpServers = mcpServers;\n }\n\n setEventHandler(handler?: (event: AgentEvent) => void): void {\n this.eventHandler = handler;\n }\n\n async execute(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions): Promise<WorkflowStageExecutionResult> {\n const isManual = stage.is_manual_only === true;\n if (isManual) {\n this.logger.info('Manual stage detected; skipping agent execution', { stage: stage.key });\n return { results: [] };\n }\n\n const inferredAgent = stage.key.toLowerCase().includes('plan') ? 'planning_basic' : 'code_generation';\n const agentName = stage.agent_name || inferredAgent;\n const agent = this.registry.getAgent(agentName);\n if (!agent) {\n throw new Error(`Unknown agent '${agentName}' for stage '${stage.key}'`);\n }\n\n const permissionMode = (options.permissionMode as any) || 'acceptEdits';\n const cwd = options.repositoryPath || process.cwd();\n\n switch (agent.agent_type) {\n case 'planning':\n return this.runPlanning(task, cwd, options, stage.key);\n case 'execution':\n return this.runExecution(task, cwd, permissionMode, options, stage.key);\n case 'review': // TODO: Implement review\n case 'testing': // TODO: Implement testing\n default:\n // throw new Error(`Unsupported agent type: ${agent.agent_type}`);\n console.warn(`Unsupported agent type: ${agent.agent_type}`);\n return { results: [] };\n }\n }\n\n private async runPlanning(task: Task, cwd: string, options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildPlanningPrompt(task);\n let prompt = PLANNING_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey] || options.stageOverrides?.['plan'];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n\n let plan = '';\n for await (const message of response) {\n const transformed = this.eventTransformer.transform(message);\n if (transformed) {\n if (transformed.type !== 'token') {\n this.logger.debug('Planning event', { type: transformed.type });\n }\n this.eventHandler?.(transformed);\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) plan += c.text + '\\n';\n }\n }\n }\n\n return { plan: plan.trim() };\n }\n\n private async runExecution(task: Task, cwd: string, permissionMode: WorkflowExecutionOptions['permissionMode'], options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildExecutionPrompt(task);\n let prompt = EXECUTION_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode,\n settingSources: ['local'],\n mcpServers: this.mcpServers\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n const results: any[] = [];\n for await (const message of response) {\n const transformed = this.eventTransformer.transform(message);\n if (transformed) {\n if (transformed.type !== 'token') {\n this.logger.debug('Execution event', { type: transformed.type });\n }\n this.eventHandler?.(transformed);\n }\n results.push(message);\n }\n return { results };\n }\n}\n"],"names":[],"mappings":";;;;;;;MAUa,aAAa,CAAA;AAChB,IAAA,QAAQ;AACR,IAAA,MAAM;AACN,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,YAAY;AACZ,IAAA,UAAU;IAElB,WAAA,CACE,QAAuB,EACvB,MAAc,EACd,aAA6B,E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,MAAM,GAAG,aAAa;QAE7D,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,QAAQ,CAAC;AACzD,QAAA,MAAM,eAAe,GAAG;AACtB,YAAA,IAAI,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;AACjC,YAAA,IAAI,cAAc,EAAE,cAAc,IAAI,EAAE,CAAC;SACnB;AAExB,QAAA,MAAM,WAAW,GAAwB;AACvC,YAAA,KAAK,EAAE,4BAA4B;YACnC,GAAG;YACH,cAAc;YACd,cAAc,EAAE,CAAC,OAAO,CAAC;YACzB,UAAU,EAAE,IAAI,CAAC;SAClB;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC;YACrB,MAAM;AACN,YAAA,OAAO,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,eAAe,EAAE;AAChD,SAAA,CAAC;QACF,MAAM,OAAO,GAAU,EAAE;AACzB,QAAA,WAAW,MAAM,OAAO,IAAI,QAAQ,EAAE;YACpC,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5D,IAAI,WAAW,EAAE;AACf,gBAAA,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;AAChC,oBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;gBAClE;AACA,gBAAA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;YAClC;AACA,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACvB;QACA,OAAO,EAAE,OAAO,EAAE;IACpB;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"stage-executor.js","sources":["../../src/stage-executor.ts"],"sourcesContent":["import { query } from '@anthropic-ai/claude-agent-sdk';\nimport { Logger } from './utils/logger.js';\nimport { EventTransformer } from './event-transformer.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport type { AgentEvent, Task, McpServerConfig } from './types.js';\nimport type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { PromptBuilder } from './prompt-builder.js';\n\nexport class StageExecutor {\n private registry: AgentRegistry;\n private logger: Logger;\n private eventTransformer: EventTransformer;\n private promptBuilder: PromptBuilder;\n private eventHandler?: (event: AgentEvent) => void;\n private mcpServers?: Record<string, McpServerConfig>;\n\n constructor(\n registry: AgentRegistry,\n logger: Logger,\n promptBuilder?: PromptBuilder,\n eventHandler?: (event: AgentEvent) => void,\n mcpServers?: Record<string, McpServerConfig>,\n ) {\n this.registry = registry;\n this.logger = logger.child('StageExecutor');\n this.eventTransformer = new EventTransformer();\n this.promptBuilder = promptBuilder || new PromptBuilder({\n getTaskFiles: async () => [],\n generatePlanTemplate: async () => '',\n logger,\n });\n this.eventHandler = eventHandler;\n this.mcpServers = mcpServers;\n }\n\n setEventHandler(handler?: (event: AgentEvent) => void): void {\n this.eventHandler = handler;\n }\n\n async execute(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions): Promise<WorkflowStageExecutionResult> {\n const isManual = stage.is_manual_only === true;\n if (isManual) {\n this.logger.info('Manual stage detected; skipping agent execution', { stage: stage.key });\n return { results: [] };\n }\n\n const inferredAgent = stage.key.toLowerCase().includes('plan') ? 'planning_basic' : 'code_generation';\n const agentName = stage.agent_name || inferredAgent;\n const agent = this.registry.getAgent(agentName);\n if (!agent) {\n throw new Error(`Unknown agent '${agentName}' for stage '${stage.key}'`);\n }\n\n const permissionMode = (options.permissionMode as any) || 'acceptEdits';\n const cwd = options.repositoryPath || process.cwd();\n\n switch (agent.agent_type) {\n case 'planning':\n return this.runPlanning(task, cwd, options, stage.key);\n case 'execution':\n return this.runExecution(task, cwd, permissionMode, options, stage.key);\n case 'review': // TODO: Implement review\n case 'testing': // TODO: Implement testing\n default:\n // throw new Error(`Unsupported agent type: ${agent.agent_type}`);\n console.warn(`Unsupported agent type: ${agent.agent_type}`);\n return { results: [] };\n }\n }\n\n private async runPlanning(task: Task, cwd: string, options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildPlanningPrompt(task);\n let prompt = PLANNING_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey] || options.stageOverrides?.['plan'];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n\n let plan = '';\n for await (const message of response) {\n // Emit raw SDK event first\n this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));\n \n // Then emit transformed event\n const transformed = this.eventTransformer.transform(message);\n if (transformed) {\n if (transformed.type !== 'token') {\n this.logger.debug('Planning event', { type: transformed.type });\n }\n this.eventHandler?.(transformed);\n }\n \n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) plan += c.text + '\\n';\n }\n }\n }\n\n return { plan: plan.trim() };\n }\n\n private async runExecution(task: Task, cwd: string, permissionMode: WorkflowExecutionOptions['permissionMode'], options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildExecutionPrompt(task);\n let prompt = EXECUTION_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode,\n settingSources: ['local'],\n mcpServers: this.mcpServers\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n const results: any[] = [];\n for await (const message of response) {\n // Emit raw SDK event first\n this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));\n \n // Then emit transformed event\n const transformed = this.eventTransformer.transform(message);\n if (transformed) {\n if (transformed.type !== 'token') {\n this.logger.debug('Execution event', { type: transformed.type });\n }\n this.eventHandler?.(transformed);\n }\n \n results.push(message);\n }\n return { results };\n }\n}\n"],"names":[],"mappings":";;;;;;;MAUa,aAAa,CAAA;AAChB,IAAA,QAAQ;AACR,IAAA,MAAM;AACN,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,YAAY;AACZ,IAAA,UAAU;IAElB,WAAA,CACE,QAAuB,EACvB,MAAc,EACd,aAA6B,EAC7B,YAA0C,EAC1C,UAA4C,EAAA;AAE5C,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;AAC3C,QAAA,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,EAAE;AAC9C,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAI,aAAa,CAAC;AACtD,YAAA,YAAY,EAAE,YAAY,EAAE;AAC5B,YAAA,oBAAoB,EAAE,YAAY,EAAE;YACpC,MAAM;AACP,SAAA,CAAC;AACF,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;AAChC,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU;IAC9B;AAEA,IAAA,eAAe,CAAC,OAAqC,EAAA;AACnD,QAAA,IAAI,CAAC,YAAY,GAAG,OAAO;IAC7B;AAEA,IAAA,MAAM,OAAO,CAAC,IAAU,EAAE,KAAoB,EAAE,OAAiC,EAAA;AAC/E,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,KAAK,IAAI;QAC9C,IAAI,QAAQ,EAAE;AACZ,YA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YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;;YAGrE,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5D,IAAI,WAAW,EAAE;AACf,gBAAA,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;AAChC,oBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;gBAClE;AACA,gBAAA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;YAClC;AAEA,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACvB;QACA,OAAO,EAAE,OAAO,EAAE;IACpB;AACD;;;;"}
|
|
@@ -39,6 +39,8 @@ export declare class TaskProgressReporter {
|
|
|
39
39
|
private formatFileWriteEvent;
|
|
40
40
|
private formatDiffEvent;
|
|
41
41
|
private truncateMultiline;
|
|
42
|
+
private formatToolCallEvent;
|
|
43
|
+
private formatToolResultEvent;
|
|
42
44
|
}
|
|
43
45
|
export {};
|
|
44
46
|
//# sourceMappingURL=task-progress-reporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-progress-reporter.d.ts","sourceRoot":"","sources":["../../src/task-progress-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAA0C,MAAM,kBAAkB,CAAC;AACjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAA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AAO,CAAC,IAAI,CAAC;IAIlE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;YA6ErC,MAAM;IA6BpB,OAAO,CAAC,oBAAoB;IAiE5B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,qBAAqB;CAK9B"}
|
|
@@ -92,14 +92,27 @@ class TaskProgressReporter {
|
|
|
92
92
|
case 'content_block_start':
|
|
93
93
|
case 'content_block_stop':
|
|
94
94
|
case 'compact_boundary':
|
|
95
|
-
case 'tool_call':
|
|
96
|
-
case 'tool_result':
|
|
97
95
|
case 'message_start':
|
|
98
96
|
case 'message_stop':
|
|
99
97
|
case 'metric':
|
|
100
98
|
case 'artifact':
|
|
99
|
+
case 'raw_sdk_event':
|
|
101
100
|
// Skip verbose streaming artifacts from persistence
|
|
102
101
|
return;
|
|
102
|
+
case 'tool_call': {
|
|
103
|
+
const logLine = this.formatToolCallEvent(event);
|
|
104
|
+
if (logLine) {
|
|
105
|
+
await this.appendLog(logLine);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
case 'tool_result': {
|
|
110
|
+
const logLine = this.formatToolResultEvent(event);
|
|
111
|
+
if (logLine) {
|
|
112
|
+
await this.appendLog(logLine);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
103
116
|
case 'file_write':
|
|
104
117
|
await this.appendLog(this.formatFileWriteEvent(event));
|
|
105
118
|
return;
|
|
@@ -228,6 +241,30 @@ class TaskProgressReporter {
|
|
|
228
241
|
const compact = text.replace(/\s+/g, ' ').trim();
|
|
229
242
|
return compact.length > max ? `${compact.slice(0, max)}…` : compact;
|
|
230
243
|
}
|
|
244
|
+
formatToolCallEvent(event) {
|
|
245
|
+
// File operations to track
|
|
246
|
+
const fileOps = ['read_file', 'write', 'search_replace', 'delete_file', 'glob_file_search', 'file_search', 'list_dir', 'edit_notebook'];
|
|
247
|
+
// Terminal commands to track
|
|
248
|
+
const terminalOps = ['run_terminal_cmd', 'bash', 'shell'];
|
|
249
|
+
if (fileOps.includes(event.toolName)) {
|
|
250
|
+
// Extract file path from args
|
|
251
|
+
const path = event.args?.target_file || event.args?.file_path || event.args?.target_notebook || event.args?.target_directory || '';
|
|
252
|
+
return `[tool] ${event.toolName}${path ? `: ${path}` : ''}`;
|
|
253
|
+
}
|
|
254
|
+
else if (terminalOps.includes(event.toolName)) {
|
|
255
|
+
// Extract command from args
|
|
256
|
+
const cmd = event.args?.command || '';
|
|
257
|
+
const truncated = cmd.length > 80 ? `${cmd.slice(0, 80)}…` : cmd;
|
|
258
|
+
return `[cmd] ${truncated}`;
|
|
259
|
+
}
|
|
260
|
+
// Skip other tools from persistence
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
formatToolResultEvent(event) {
|
|
264
|
+
// We don't need to log tool results separately - tool calls are sufficient
|
|
265
|
+
// This keeps the log concise
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
231
268
|
}
|
|
232
269
|
|
|
233
270
|
export { TaskProgressReporter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-progress-reporter.js","sources":["../../src/task-progress-reporter.ts"],"sourcesContent":["import type { Logger } from './utils/logger.js';\nimport type { PostHogAPIClient, TaskProgressRecord, TaskProgressUpdate } from './posthog-api.js';\nimport type { AgentEvent } from './types.js';\n\ninterface ProgressMetadata {\n workflowId?: string;\n workflowRunId?: string;\n activityId?: string;\n totalSteps?: number;\n}\n\n/**\n * Persists task execution progress to PostHog so clients can poll for updates.\n *\n * The reporter is intentionally best-effort – failures are logged but never\n * allowed to break the agent execution flow.\n */\nexport class TaskProgressReporter {\n private posthogAPI?: PostHogAPIClient;\n private logger: Logger;\n private progressRecord?: TaskProgressRecord;\n private taskId?: string;\n private outputLog: string[] = [];\n private totalSteps?: number;\n private lastLogEntry?: string;\n\n constructor(posthogAPI: PostHogAPIClient | undefined, logger: Logger) {\n this.posthogAPI = posthogAPI;\n this.logger = logger.child('TaskProgressReporter');\n }\n\n get progressId(): string | undefined {\n return this.progressRecord?.id;\n }\n\n async start(taskId: string, metadata: ProgressMetadata = {}): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n this.taskId = taskId;\n this.totalSteps = metadata.totalSteps;\n\n try {\n const record = await this.posthogAPI.createTaskProgress(taskId, {\n status: 'started',\n current_step: 'initializing',\n total_steps: metadata.totalSteps ?? 0,\n completed_steps: 0,\n workflow_id: metadata.workflowId,\n workflow_run_id: metadata.workflowRunId,\n activity_id: metadata.activityId,\n output_log: '',\n });\n this.progressRecord = record;\n this.outputLog = record.output_log ? record.output_log.split('\\n') : [];\n this.logger.debug('Created task progress record', { taskId, progressId: record.id });\n } catch (error) {\n this.logger.warn('Failed to create task progress record', { taskId, error: (error as Error).message });\n }\n }\n\n async stageStarted(stageKey: string, stageIndex: number): Promise<void> {\n await this.update({\n status: 'in_progress',\n current_step: stageKey,\n completed_steps: Math.min(stageIndex, this.totalSteps ?? stageIndex),\n }, `Stage started: ${stageKey}`);\n }\n\n async stageCompleted(stageKey: string, completedStages: number): Promise<void> {\n await this.update({\n status: 'in_progress',\n current_step: stageKey,\n completed_steps: Math.min(completedStages, this.totalSteps ?? completedStages),\n }, `Stage completed: ${stageKey}`);\n }\n\n async branchCreated(stageKey: string, branchName: string): Promise<void> {\n await this.appendLog(`Branch created (${stageKey}): ${branchName}`);\n }\n\n async commitMade(stageKey: string, kind: 'plan' | 'implementation'): Promise<void> {\n await this.appendLog(`Commit made (${stageKey}, ${kind})`);\n }\n\n async pullRequestCreated(stageKey: string, prUrl: string): Promise<void> {\n await this.appendLog(`Pull request created (${stageKey}): ${prUrl}`);\n }\n\n async noNextStage(stageKey?: string): Promise<void> {\n await this.appendLog(\n stageKey\n ? `No next stage available after '${stageKey}'. Execution halted.`\n : 'No next stage available. Execution halted.'\n );\n }\n\n async complete(): Promise<void> {\n await this.update({ status: 'completed', completed_steps: this.totalSteps }, 'Workflow execution completed');\n }\n\n async fail(error: Error | string): Promise<void> {\n const message = typeof error === 'string' ? error : error.message;\n await this.update({ status: 'failed', error_message: message }, `Workflow execution failed: ${message}`);\n }\n\n async appendLog(line: string): Promise<void> {\n await this.update({}, line);\n }\n\n async recordEvent(event: AgentEvent): Promise<void> {\n if (!this.posthogAPI || !this.progressId || !this.taskId) {\n return;\n }\n\n switch (event.type) {\n case 'token':\n case 'message_delta':\n case 'content_block_start':\n case 'content_block_stop':\n case 'compact_boundary':\n case 'tool_call':\n case 'tool_result':\n case 'message_start':\n case 'message_stop':\n case 'metric':\n case 'artifact':\n // Skip verbose streaming artifacts from persistence\n return;\n\n case 'file_write':\n await this.appendLog(this.formatFileWriteEvent(event));\n return;\n\n case 'diff':\n await this.appendLog(this.formatDiffEvent(event));\n return;\n\n case 'status':\n // Status events are covered by dedicated progress updates\n return;\n\n case 'error':\n await this.appendLog(`[error] ${event.message}`);\n return;\n\n case 'done': {\n const cost = event.totalCostUsd !== undefined ? ` cost=$${event.totalCostUsd.toFixed(2)}` : '';\n await this.appendLog(\n `[done] duration=${event.durationMs ?? 'unknown'}ms turns=${event.numTurns ?? 'unknown'}${cost}`\n );\n return;\n }\n\n case 'init':\n // Omit verbose init messages from persisted log\n return;\n\n case 'user_message': {\n const summary = this.summarizeUserMessage(event.content);\n if (summary) {\n await this.appendLog(summary);\n }\n return;\n }\n\n default:\n // For any unfamiliar event types, avoid spamming the log.\n return;\n }\n }\n\n private async update(update: TaskProgressUpdate, logLine?: string): Promise<void> {\n if (!this.posthogAPI || !this.progressId || !this.taskId) {\n return;\n }\n\n if (logLine) {\n if (logLine !== this.lastLogEntry) {\n this.outputLog.push(logLine);\n this.lastLogEntry = logLine;\n }\n update.output_log = this.outputLog.join('\\n');\n }\n\n try {\n const record = await this.posthogAPI.updateTaskProgress(this.taskId, this.progressId, update);\n // Sync local cache with server response to avoid drift if server modifies values\n this.progressRecord = record;\n if (record.output_log !== undefined && record.output_log !== null) {\n this.outputLog = record.output_log ? record.output_log.split('\\n') : [];\n }\n } catch (error) {\n this.logger.warn('Failed to update task progress record', {\n taskId: this.taskId,\n progressId: this.progressId,\n error: (error as Error).message,\n });\n }\n }\n\n private summarizeUserMessage(content?: string): string | null {\n if (!content) {\n return null;\n }\n const trimmed = content.trim();\n if (!trimmed) {\n return null;\n }\n\n const fileUpdateMatch = trimmed.match(/The file\\s+([^\\s]+)\\s+has been updated/i);\n if (fileUpdateMatch) {\n return `[user] file updated: ${fileUpdateMatch[1]}`;\n }\n\n if (/Todos have been modified/i.test(trimmed)) {\n return '[todo] list updated';\n }\n\n const diffMatch = trimmed.match(/diff --git a\\/([^\\s]+) b\\/([^\\s]+)/);\n if (diffMatch) {\n return `[diff] ${diffMatch[2] ?? diffMatch[1]}`;\n }\n\n const gitStatusMatch = trimmed.match(/^On branch ([^\\n]+)/);\n if (gitStatusMatch) {\n return `[git] status ${gitStatusMatch[1]}`;\n }\n\n if (/This Bash command contains multiple operations/i.test(trimmed)) {\n return '[approval] multi-step command pending';\n }\n\n if (/This command requires approval/i.test(trimmed)) {\n return '[approval] command awaiting approval';\n }\n\n if (/^Exit plan mode\\?/i.test(trimmed)) {\n return null;\n }\n\n if (trimmed.includes('node_modules')) {\n return null;\n }\n\n if (trimmed.includes('total ') && trimmed.includes('drwx')) {\n return null;\n }\n\n if (trimmed.includes('→')) {\n return null;\n }\n\n if (trimmed.split('\\n').length > 2) {\n return null;\n }\n\n const normalized = trimmed.replace(/\\s+/g, ' ');\n const maxLen = 120;\n if (!normalized) {\n return null;\n }\n const preview = normalized.length > maxLen ? `${normalized.slice(0, maxLen)}…` : normalized;\n return `[user] ${preview}`;\n }\n\n private formatFileWriteEvent(event: Extract<AgentEvent, { type: 'file_write' }>): string {\n const size = event.bytes !== undefined ? ` (${event.bytes} bytes)` : '';\n return `[file] wrote ${event.path}${size}`;\n }\n\n private formatDiffEvent(event: Extract<AgentEvent, { type: 'diff' }>): string {\n const summary = event.summary\n ? event.summary.trim()\n : this.truncateMultiline(event.patch ?? '', 160);\n return `[diff] ${event.file}${summary ? ` | ${summary}` : ''}`;\n }\n\n private truncateMultiline(text: string, max = 160): string {\n if (!text) {\n return '';\n }\n const compact = text.replace(/\\s+/g, ' ').trim();\n return compact.length > max ? `${compact.slice(0, max)}…` : compact;\n }\n}\n"],"names":[],"mappings":"AAWA;;;;;AAKG;MACU,oBAAoB,CAAA;AACvB,IAAA,UAAU;AACV,IAAA,MAAM;AACN,IAAA,cAAc;AACd,IAAA,MAAM;IACN,SAAS,GAAa,EAAE;AACxB,IAAA,UAAU;AACV,IAAA,YAAY;IAEpB,WAAA,CAAY,UAAwC,EAAE,MAAc,EAAA;AAClE,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC;IACpD;AAEA,IAAA,IAAI,UAAU,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE;IAChC;AAEA,IAAA,MAAM,KAAK,CAAC,MAAc,EAAE,WAA6B,EAAE,EAAA;AACzD,QAAA,IAAI,CAAC,IAAI,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E;AACvE,QAAA,OAAO,gBAAgB,KAAK,CAAC,IAAI,CAAA,EAAG,IAAI,EAAE;IAC5C;AAEQ,IAAA,eAAe,CAAC,KAA4C,EAAA;AAClE,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC;AACpB,cAAE,KAAK,CAAC,OAAO,CAAC,IAAI;AACpB,cAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,GAAG,CAAC;AAClD,QAAA,OAAO,UAAU,KAAK,CAAC,IAAI,CAAA,EAAG,OAAO,GAAG,CAAA,GAAA,EAAM,OAAO,CAAA,CAAE,GAAG,EAAE,EAAE;IAChE;AAEQ,IAAA,iBAAiB,CAAC,IAAY,EAAE,GAAG,GAAG,GAAG,EAAA;QAC/C,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,OAAO,EAAE;QACX;AACA,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE;QAChD,OAAO,OAAO,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA,EAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,OAAO;IACrE;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"task-progress-reporter.js","sources":["../../src/task-progress-reporter.ts"],"sourcesContent":["import type { Logger } from './utils/logger.js';\nimport type { PostHogAPIClient, TaskProgressRecord, TaskProgressUpdate } from './posthog-api.js';\nimport type { AgentEvent } from './types.js';\n\ninterface ProgressMetadata {\n workflowId?: string;\n workflowRunId?: string;\n activityId?: string;\n totalSteps?: number;\n}\n\n/**\n * Persists task execution progress to PostHog so clients can poll for updates.\n *\n * The reporter is intentionally best-effort – failures are logged but never\n * allowed to break the agent execution flow.\n */\nexport class TaskProgressReporter {\n private posthogAPI?: PostHogAPIClient;\n private logger: Logger;\n private progressRecord?: TaskProgressRecord;\n private taskId?: string;\n private outputLog: string[] = [];\n private totalSteps?: number;\n private lastLogEntry?: string;\n\n constructor(posthogAPI: PostHogAPIClient | undefined, logger: Logger) {\n this.posthogAPI = posthogAPI;\n this.logger = logger.child('TaskProgressReporter');\n }\n\n get progressId(): string | undefined {\n return this.progressRecord?.id;\n }\n\n async start(taskId: string, metadata: ProgressMetadata = {}): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n this.taskId = taskId;\n this.totalSteps = metadata.totalSteps;\n\n try {\n const record = await this.posthogAPI.createTaskProgress(taskId, {\n status: 'started',\n current_step: 'initializing',\n total_steps: metadata.totalSteps ?? 0,\n completed_steps: 0,\n workflow_id: metadata.workflowId,\n workflow_run_id: metadata.workflowRunId,\n activity_id: metadata.activityId,\n output_log: '',\n });\n this.progressRecord = record;\n this.outputLog = record.output_log ? record.output_log.split('\\n') : [];\n this.logger.debug('Created task progress record', { taskId, progressId: record.id });\n } catch (error) {\n this.logger.warn('Failed to create task progress record', { taskId, error: (error as Error).message });\n }\n }\n\n async stageStarted(stageKey: string, stageIndex: number): Promise<void> {\n await this.update({\n status: 'in_progress',\n current_step: stageKey,\n completed_steps: Math.min(stageIndex, this.totalSteps ?? stageIndex),\n }, `Stage started: ${stageKey}`);\n }\n\n async stageCompleted(stageKey: string, completedStages: number): Promise<void> {\n await this.update({\n status: 'in_progress',\n current_step: stageKey,\n completed_steps: Math.min(completedStages, this.totalSteps ?? completedStages),\n }, `Stage completed: ${stageKey}`);\n }\n\n async branchCreated(stageKey: string, branchName: string): Promise<void> {\n await this.appendLog(`Branch created (${stageKey}): ${branchName}`);\n }\n\n async commitMade(stageKey: string, kind: 'plan' | 'implementation'): Promise<void> {\n await this.appendLog(`Commit made (${stageKey}, ${kind})`);\n }\n\n async pullRequestCreated(stageKey: string, prUrl: string): Promise<void> {\n await this.appendLog(`Pull request created (${stageKey}): ${prUrl}`);\n }\n\n async noNextStage(stageKey?: string): Promise<void> {\n await this.appendLog(\n stageKey\n ? `No next stage available after '${stageKey}'. Execution halted.`\n : 'No next stage available. Execution halted.'\n );\n }\n\n async complete(): Promise<void> {\n await this.update({ status: 'completed', completed_steps: this.totalSteps }, 'Workflow execution completed');\n }\n\n async fail(error: Error | string): Promise<void> {\n const message = typeof error === 'string' ? error : error.message;\n await this.update({ status: 'failed', error_message: message }, `Workflow execution failed: ${message}`);\n }\n\n async appendLog(line: string): Promise<void> {\n await this.update({}, line);\n }\n\n async recordEvent(event: AgentEvent): Promise<void> {\n if (!this.posthogAPI || !this.progressId || !this.taskId) {\n return;\n }\n\n switch (event.type) {\n case 'token':\n case 'message_delta':\n case 'content_block_start':\n case 'content_block_stop':\n case 'compact_boundary':\n case 'message_start':\n case 'message_stop':\n case 'metric':\n case 'artifact':\n case 'raw_sdk_event':\n // Skip verbose streaming artifacts from persistence\n return;\n\n case 'tool_call': {\n const logLine = this.formatToolCallEvent(event);\n if (logLine) {\n await this.appendLog(logLine);\n }\n return;\n }\n\n case 'tool_result': {\n const logLine = this.formatToolResultEvent(event);\n if (logLine) {\n await this.appendLog(logLine);\n }\n return;\n }\n\n case 'file_write':\n await this.appendLog(this.formatFileWriteEvent(event));\n return;\n\n case 'diff':\n await this.appendLog(this.formatDiffEvent(event));\n return;\n\n case 'status':\n // Status events are covered by dedicated progress updates\n return;\n\n case 'error':\n await this.appendLog(`[error] ${event.message}`);\n return;\n\n case 'done': {\n const cost = event.totalCostUsd !== undefined ? ` cost=$${event.totalCostUsd.toFixed(2)}` : '';\n await this.appendLog(\n `[done] duration=${event.durationMs ?? 'unknown'}ms turns=${event.numTurns ?? 'unknown'}${cost}`\n );\n return;\n }\n\n case 'init':\n // Omit verbose init messages from persisted log\n return;\n\n case 'user_message': {\n const summary = this.summarizeUserMessage(event.content);\n if (summary) {\n await this.appendLog(summary);\n }\n return;\n }\n\n default:\n // For any unfamiliar event types, avoid spamming the log.\n return;\n }\n }\n\n private async update(update: TaskProgressUpdate, logLine?: string): Promise<void> {\n if (!this.posthogAPI || !this.progressId || !this.taskId) {\n return;\n }\n\n if (logLine) {\n if (logLine !== this.lastLogEntry) {\n this.outputLog.push(logLine);\n this.lastLogEntry = logLine;\n }\n update.output_log = this.outputLog.join('\\n');\n }\n\n try {\n const record = await this.posthogAPI.updateTaskProgress(this.taskId, this.progressId, update);\n // Sync local cache with server response to avoid drift if server modifies values\n this.progressRecord = record;\n if (record.output_log !== undefined && record.output_log !== null) {\n this.outputLog = record.output_log ? record.output_log.split('\\n') : [];\n }\n } catch (error) {\n this.logger.warn('Failed to update task progress record', {\n taskId: this.taskId,\n progressId: this.progressId,\n error: (error as Error).message,\n });\n }\n }\n\n private summarizeUserMessage(content?: string): string | null {\n if (!content) {\n return null;\n }\n const trimmed = content.trim();\n if (!trimmed) {\n return null;\n }\n\n const fileUpdateMatch = trimmed.match(/The file\\s+([^\\s]+)\\s+has been updated/i);\n if (fileUpdateMatch) {\n return `[user] file updated: ${fileUpdateMatch[1]}`;\n }\n\n if (/Todos have been modified/i.test(trimmed)) {\n return '[todo] list updated';\n }\n\n const diffMatch = trimmed.match(/diff --git a\\/([^\\s]+) b\\/([^\\s]+)/);\n if (diffMatch) {\n return `[diff] ${diffMatch[2] ?? diffMatch[1]}`;\n }\n\n const gitStatusMatch = trimmed.match(/^On branch ([^\\n]+)/);\n if (gitStatusMatch) {\n return `[git] status ${gitStatusMatch[1]}`;\n }\n\n if (/This Bash command contains multiple operations/i.test(trimmed)) {\n return '[approval] multi-step command pending';\n }\n\n if (/This command requires approval/i.test(trimmed)) {\n return '[approval] command awaiting approval';\n }\n\n if (/^Exit plan mode\\?/i.test(trimmed)) {\n return null;\n }\n\n if (trimmed.includes('node_modules')) {\n return null;\n }\n\n if (trimmed.includes('total ') && trimmed.includes('drwx')) {\n return null;\n }\n\n if (trimmed.includes('→')) {\n return null;\n }\n\n if (trimmed.split('\\n').length > 2) {\n return null;\n }\n\n const normalized = trimmed.replace(/\\s+/g, ' ');\n const maxLen = 120;\n if (!normalized) {\n return null;\n }\n const preview = normalized.length > maxLen ? `${normalized.slice(0, maxLen)}…` : normalized;\n return `[user] ${preview}`;\n }\n\n private formatFileWriteEvent(event: Extract<AgentEvent, { type: 'file_write' }>): string {\n const size = event.bytes !== undefined ? ` (${event.bytes} bytes)` : '';\n return `[file] wrote ${event.path}${size}`;\n }\n\n private formatDiffEvent(event: Extract<AgentEvent, { type: 'diff' }>): string {\n const summary = event.summary\n ? event.summary.trim()\n : this.truncateMultiline(event.patch ?? '', 160);\n return `[diff] ${event.file}${summary ? ` | ${summary}` : ''}`;\n }\n\n private truncateMultiline(text: string, max = 160): string {\n if (!text) {\n return '';\n }\n const compact = text.replace(/\\s+/g, ' ').trim();\n return compact.length > max ? `${compact.slice(0, max)}…` : compact;\n }\n\n private formatToolCallEvent(event: Extract<AgentEvent, { type: 'tool_call' }>): string | null {\n // File operations to track\n const fileOps = ['read_file', 'write', 'search_replace', 'delete_file', 'glob_file_search', 'file_search', 'list_dir', 'edit_notebook'];\n // Terminal commands to track\n const terminalOps = ['run_terminal_cmd', 'bash', 'shell'];\n\n if (fileOps.includes(event.toolName)) {\n // Extract file path from args\n const path = event.args?.target_file || event.args?.file_path || event.args?.target_notebook || event.args?.target_directory || '';\n return `[tool] ${event.toolName}${path ? `: ${path}` : ''}`;\n } else if (terminalOps.includes(event.toolName)) {\n // Extract command from args\n const cmd = event.args?.command || '';\n const truncated = cmd.length > 80 ? `${cmd.slice(0, 80)}…` : cmd;\n return `[cmd] ${truncated}`;\n }\n\n // Skip other tools from persistence\n return null;\n }\n\n private formatToolResultEvent(event: Extract<AgentEvent, { type: 'tool_result' }>): string | null {\n // We don't need to log tool results separately - tool calls are sufficient\n // This keeps the log concise\n return null;\n }\n}\n"],"names":[],"mappings":"AAWA;;;;;AAKG;MACU,oBAAoB,CAAA;AACvB,IAAA,UAAU;AACV,IAAA,MAAM;AACN,IAAA,cAAc;AACd,IAAA,MAAM;IACN,SAAS,GAAa,EAAE;AACxB,IAAA,UAAU;AACV,IAAA,YAAY;IAEpB,WAAA,CAAY,UAAwC,EAAE,MAAc,EAA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AI;IACb;AACD;;;;"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -113,6 +113,8 @@ export interface ErrorEvent extends BaseEvent {
|
|
|
113
113
|
message: string;
|
|
114
114
|
error?: any;
|
|
115
115
|
errorType?: string;
|
|
116
|
+
context?: Record<string, any>;
|
|
117
|
+
sdkError?: any;
|
|
116
118
|
}
|
|
117
119
|
export interface DiffEvent extends BaseEvent {
|
|
118
120
|
type: 'diff';
|
|
@@ -136,7 +138,11 @@ export interface ArtifactEvent extends BaseEvent {
|
|
|
136
138
|
kind: string;
|
|
137
139
|
content: any;
|
|
138
140
|
}
|
|
139
|
-
export
|
|
141
|
+
export interface RawSDKEvent extends BaseEvent {
|
|
142
|
+
type: 'raw_sdk_event';
|
|
143
|
+
sdkMessage: any;
|
|
144
|
+
}
|
|
145
|
+
export type AgentEvent = TokenEvent | ContentBlockStartEvent | ContentBlockStopEvent | ToolCallEvent | ToolResultEvent | MessageStartEvent | MessageDeltaEvent | MessageStopEvent | UserMessageEvent | StatusEvent | InitEvent | CompactBoundaryEvent | DoneEvent | ErrorEvent | DiffEvent | FileWriteEvent | MetricEvent | ArtifactEvent | RawSDKEvent;
|
|
140
146
|
export interface ExecutionResult {
|
|
141
147
|
results: any[];
|
|
142
148
|
}
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,gBAAgB,GAAG,eAAe,GAAG,cAAc,GAAG,eAAe,GAAG,mBAAmB,CAAC;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAA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IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAGtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAKvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAG7C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["// PostHog Task model (matches Array's OpenAPI schema)\nexport interface Task {\n id: string;\n title: string;\n description: string;\n origin_product: 'error_tracking' | 'eval_clusters' | 'user_created' | 'support_queue' | 'session_summaries';\n position?: number;\n workflow?: string | null;\n current_stage?: string | null;\n github_integration?: number | null;\n repository_config?: unknown; // JSONField\n repository_list: string;\n primary_repository: string;\n github_branch: string | null;\n github_pr_url: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface SupportingFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output';\n created_at: string;\n}\n\n// Removed legacy ExecutionMode in favor of configurable workflows\n\nexport enum PermissionMode {\n PLAN = \"plan\",\n DEFAULT = \"default\",\n ACCEPT_EDITS = \"acceptEdits\",\n BYPASS = \"bypassPermissions\"\n}\n\nexport interface ExecutionOptions {\n repositoryPath?: string;\n permissionMode?: PermissionMode;\n}\n\n// Base event with timestamp\ninterface BaseEvent {\n ts: number;\n}\n\n// Streaming content events\nexport interface TokenEvent extends BaseEvent {\n type: 'token';\n content: string;\n contentType?: 'text' | 'thinking' | 'tool_input';\n}\n\nexport interface ContentBlockStartEvent extends BaseEvent {\n type: 'content_block_start';\n index: number;\n contentType: 'text' | 'tool_use' | 'thinking';\n toolName?: string;\n toolId?: string;\n}\n\nexport interface ContentBlockStopEvent extends BaseEvent {\n type: 'content_block_stop';\n index: number;\n}\n\n// Tool events\nexport interface ToolCallEvent extends BaseEvent {\n type: 'tool_call';\n toolName: string;\n callId: string;\n args: Record<string, any>;\n}\n\nexport interface ToolResultEvent extends BaseEvent {\n type: 'tool_result';\n toolName: string;\n callId: string;\n result: any;\n}\n\n// Message lifecycle events\nexport interface MessageStartEvent extends BaseEvent {\n type: 'message_start';\n messageId?: string;\n model?: string;\n}\n\nexport interface MessageDeltaEvent extends BaseEvent {\n type: 'message_delta';\n stopReason?: string;\n stopSequence?: string;\n usage?: {\n outputTokens: number;\n };\n}\n\nexport interface MessageStopEvent extends BaseEvent {\n type: 'message_stop';\n}\n\n// User message events\nexport interface UserMessageEvent extends BaseEvent {\n type: 'user_message';\n content: string;\n isSynthetic?: boolean;\n}\n\n// System events\nexport interface StatusEvent extends BaseEvent {\n type: 'status';\n phase: string;\n [key: string]: any;\n}\n\nexport interface InitEvent extends BaseEvent {\n type: 'init';\n model: string;\n tools: string[];\n permissionMode: string;\n cwd: string;\n apiKeySource: string;\n}\n\nexport interface CompactBoundaryEvent extends BaseEvent {\n type: 'compact_boundary';\n trigger: 'manual' | 'auto';\n preTokens: number;\n}\n\n// Result events\nexport interface DoneEvent extends BaseEvent {\n type: 'done';\n durationMs?: number;\n numTurns?: number;\n totalCostUsd?: number;\n usage?: any;\n}\n\nexport interface ErrorEvent extends BaseEvent {\n type: 'error';\n message: string;\n error?: any;\n errorType?: string;\n}\n\n// Legacy events (keeping for backwards compatibility)\nexport interface DiffEvent extends BaseEvent {\n type: 'diff';\n file: string;\n patch: string;\n summary?: string;\n}\n\nexport interface FileWriteEvent extends BaseEvent {\n type: 'file_write';\n path: string;\n bytes: number;\n}\n\nexport interface MetricEvent extends BaseEvent {\n type: 'metric';\n key: string;\n value: number;\n unit?: string;\n}\n\nexport interface ArtifactEvent extends BaseEvent {\n type: 'artifact';\n kind: string;\n content: any;\n}\n\nexport type AgentEvent =\n | TokenEvent\n | ContentBlockStartEvent\n | ContentBlockStopEvent\n | ToolCallEvent\n | ToolResultEvent\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | UserMessageEvent\n | StatusEvent\n | InitEvent\n | CompactBoundaryEvent\n | DoneEvent\n | ErrorEvent\n | DiffEvent\n | FileWriteEvent\n | MetricEvent\n | ArtifactEvent;\n\nexport interface ExecutionResult {\n results: any[];\n}\n\nexport interface PlanResult {\n plan: string;\n}\n\nexport interface TaskExecutionResult {\n task: Task;\n plan?: string;\n executionResult?: ExecutionResult;\n // Deprecated: mode removed in workflow-based execution\n}\n\n// MCP Server configuration types (re-exported from Claude SDK for convenience)\nexport type McpServerConfig = {\n type?: 'stdio';\n command: string;\n args?: string[];\n env?: Record<string, string>;\n} | {\n type: 'sse';\n url: string;\n headers?: Record<string, string>;\n} | {\n type: 'http';\n url: string;\n headers?: Record<string, string>;\n} | {\n type: 'sdk';\n name: string;\n instance?: any; // McpServer instance\n};\n\nexport interface AgentConfig {\n workingDirectory?: string;\n onEvent?: (event: AgentEvent) => void;\n\n // PostHog API configuration\n posthogApiUrl?: string;\n posthogApiKey?: string;\n\n // PostHog MCP configuration\n posthogMcpUrl?: string;\n\n // MCP Server configuration\n // Additional MCP servers (PostHog MCP is always included by default)\n // You can override the PostHog MCP config by providing mcpServers.posthog\n mcpServers?: Record<string, McpServerConfig>;\n\n // Logging configuration\n debug?: boolean;\n}\n\nexport interface PostHogAPIConfig {\n apiUrl: string;\n apiKey: string;\n}"],"names":[],"mappings":"AA0BA;IAEY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,aAA4B;AAC5B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,mBAA4B;AAC9B,CAAC,EALW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["// PostHog Task model (matches Array's OpenAPI schema)\nexport interface Task {\n id: string;\n title: string;\n description: string;\n origin_product: 'error_tracking' | 'eval_clusters' | 'user_created' | 'support_queue' | 'session_summaries';\n position?: number;\n workflow?: string | null;\n current_stage?: string | null;\n github_integration?: number | null;\n repository_config?: unknown; // JSONField\n repository_list: string;\n primary_repository: string;\n github_branch: string | null;\n github_pr_url: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface SupportingFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output';\n created_at: string;\n}\n\n// Removed legacy ExecutionMode in favor of configurable workflows\n\nexport enum PermissionMode {\n PLAN = \"plan\",\n DEFAULT = \"default\",\n ACCEPT_EDITS = \"acceptEdits\",\n BYPASS = \"bypassPermissions\"\n}\n\nexport interface ExecutionOptions {\n repositoryPath?: string;\n permissionMode?: PermissionMode;\n}\n\n// Base event with timestamp\ninterface BaseEvent {\n ts: number;\n}\n\n// Streaming content events\nexport interface TokenEvent extends BaseEvent {\n type: 'token';\n content: string;\n contentType?: 'text' | 'thinking' | 'tool_input';\n}\n\nexport interface ContentBlockStartEvent extends BaseEvent {\n type: 'content_block_start';\n index: number;\n contentType: 'text' | 'tool_use' | 'thinking';\n toolName?: string;\n toolId?: string;\n}\n\nexport interface ContentBlockStopEvent extends BaseEvent {\n type: 'content_block_stop';\n index: number;\n}\n\n// Tool events\nexport interface ToolCallEvent extends BaseEvent {\n type: 'tool_call';\n toolName: string;\n callId: string;\n args: Record<string, any>;\n}\n\nexport interface ToolResultEvent extends BaseEvent {\n type: 'tool_result';\n toolName: string;\n callId: string;\n result: any;\n}\n\n// Message lifecycle events\nexport interface MessageStartEvent extends BaseEvent {\n type: 'message_start';\n messageId?: string;\n model?: string;\n}\n\nexport interface MessageDeltaEvent extends BaseEvent {\n type: 'message_delta';\n stopReason?: string;\n stopSequence?: string;\n usage?: {\n outputTokens: number;\n };\n}\n\nexport interface MessageStopEvent extends BaseEvent {\n type: 'message_stop';\n}\n\n// User message events\nexport interface UserMessageEvent extends BaseEvent {\n type: 'user_message';\n content: string;\n isSynthetic?: boolean;\n}\n\n// System events\nexport interface StatusEvent extends BaseEvent {\n type: 'status';\n phase: string;\n [key: string]: any;\n}\n\nexport interface InitEvent extends BaseEvent {\n type: 'init';\n model: string;\n tools: string[];\n permissionMode: string;\n cwd: string;\n apiKeySource: string;\n}\n\nexport interface CompactBoundaryEvent extends BaseEvent {\n type: 'compact_boundary';\n trigger: 'manual' | 'auto';\n preTokens: number;\n}\n\n// Result events\nexport interface DoneEvent extends BaseEvent {\n type: 'done';\n durationMs?: number;\n numTurns?: number;\n totalCostUsd?: number;\n usage?: any;\n}\n\nexport interface ErrorEvent extends BaseEvent {\n type: 'error';\n message: string;\n error?: any;\n errorType?: string;\n context?: Record<string, any>; // Partial error context for debugging\n sdkError?: any; // Original SDK error object\n}\n\n// Legacy events (keeping for backwards compatibility)\nexport interface DiffEvent extends BaseEvent {\n type: 'diff';\n file: string;\n patch: string;\n summary?: string;\n}\n\nexport interface FileWriteEvent extends BaseEvent {\n type: 'file_write';\n path: string;\n bytes: number;\n}\n\nexport interface MetricEvent extends BaseEvent {\n type: 'metric';\n key: string;\n value: number;\n unit?: string;\n}\n\nexport interface ArtifactEvent extends BaseEvent {\n type: 'artifact';\n kind: string;\n content: any;\n}\n\nexport interface RawSDKEvent extends BaseEvent {\n type: 'raw_sdk_event';\n sdkMessage: any; // Full SDK message for debugging\n}\n\nexport type AgentEvent =\n | TokenEvent\n | ContentBlockStartEvent\n | ContentBlockStopEvent\n | ToolCallEvent\n | ToolResultEvent\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | UserMessageEvent\n | StatusEvent\n | InitEvent\n | CompactBoundaryEvent\n | DoneEvent\n | ErrorEvent\n | DiffEvent\n | FileWriteEvent\n | MetricEvent\n | ArtifactEvent\n | RawSDKEvent;\n\nexport interface ExecutionResult {\n results: any[];\n}\n\nexport interface PlanResult {\n plan: string;\n}\n\nexport interface TaskExecutionResult {\n task: Task;\n plan?: string;\n executionResult?: ExecutionResult;\n // Deprecated: mode removed in workflow-based execution\n}\n\n// MCP Server configuration types (re-exported from Claude SDK for convenience)\nexport type McpServerConfig = {\n type?: 'stdio';\n command: string;\n args?: string[];\n env?: Record<string, string>;\n} | {\n type: 'sse';\n url: string;\n headers?: Record<string, string>;\n} | {\n type: 'http';\n url: string;\n headers?: Record<string, string>;\n} | {\n type: 'sdk';\n name: string;\n instance?: any; // McpServer instance\n};\n\nexport interface AgentConfig {\n workingDirectory?: string;\n onEvent?: (event: AgentEvent) => void;\n\n // PostHog API configuration\n posthogApiUrl?: string;\n posthogApiKey?: string;\n\n // PostHog MCP configuration\n posthogMcpUrl?: string;\n\n // MCP Server configuration\n // Additional MCP servers (PostHog MCP is always included by default)\n // You can override the PostHog MCP config by providing mcpServers.posthog\n mcpServers?: Record<string, McpServerConfig>;\n\n // Logging configuration\n debug?: boolean;\n}\n\nexport interface PostHogAPIConfig {\n apiUrl: string;\n apiKey: string;\n}"],"names":[],"mappings":"AA0BA;IAEY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,aAA4B;AAC5B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,mBAA4B;AAC9B,CAAC,EALW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -352,8 +352,13 @@ export class Agent {
|
|
|
352
352
|
const results = [];
|
|
353
353
|
for await (const message of response) {
|
|
354
354
|
this.logger.debug('Received message in direct run', message);
|
|
355
|
+
// Emit raw SDK event
|
|
356
|
+
this.emitEvent(this.eventTransformer.createRawSDKEvent(message));
|
|
357
|
+
// Emit transformed event
|
|
355
358
|
const transformedEvent = this.eventTransformer.transform(message);
|
|
356
|
-
|
|
359
|
+
if (transformedEvent) {
|
|
360
|
+
this.emitEvent(transformedEvent);
|
|
361
|
+
}
|
|
357
362
|
results.push(message);
|
|
358
363
|
}
|
|
359
364
|
|
package/src/event-transformer.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type { AgentEvent } from './types.js';
|
|
|
2
2
|
import type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
|
|
4
4
|
export class EventTransformer {
|
|
5
|
+
createRawSDKEvent(sdkMessage: any): AgentEvent {
|
|
6
|
+
return {
|
|
7
|
+
type: 'raw_sdk_event',
|
|
8
|
+
ts: Date.now(),
|
|
9
|
+
sdkMessage
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
transform(sdkMessage: SDKMessage): AgentEvent | null {
|
|
6
14
|
const baseEvent = { ts: Date.now() };
|
|
7
15
|
|
|
@@ -93,7 +101,12 @@ export class EventTransformer {
|
|
|
93
101
|
type: 'error',
|
|
94
102
|
message: event.error?.message || 'Unknown error',
|
|
95
103
|
error: event.error,
|
|
96
|
-
errorType: event.error?.type
|
|
104
|
+
errorType: event.error?.type || 'stream_error',
|
|
105
|
+
context: event.error ? {
|
|
106
|
+
type: event.error.type,
|
|
107
|
+
code: event.error.code,
|
|
108
|
+
} : undefined,
|
|
109
|
+
sdkError: event.error
|
|
97
110
|
};
|
|
98
111
|
|
|
99
112
|
default:
|
|
@@ -103,10 +116,25 @@ export class EventTransformer {
|
|
|
103
116
|
|
|
104
117
|
// Handle assistant messages (full message, not streaming)
|
|
105
118
|
if (sdkMessage.type === 'assistant') {
|
|
106
|
-
// Extract tool calls from assistant message
|
|
107
119
|
const message = sdkMessage.message;
|
|
108
|
-
|
|
109
|
-
//
|
|
120
|
+
|
|
121
|
+
// Extract tool calls from content blocks
|
|
122
|
+
if (message.content && Array.isArray(message.content)) {
|
|
123
|
+
for (const block of message.content) {
|
|
124
|
+
if (block.type === 'tool_use') {
|
|
125
|
+
// Return first tool_call event found
|
|
126
|
+
return {
|
|
127
|
+
...baseEvent,
|
|
128
|
+
type: 'tool_call',
|
|
129
|
+
toolName: block.name,
|
|
130
|
+
callId: block.id,
|
|
131
|
+
args: block.input || {}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// If no tool calls, emit status event
|
|
110
138
|
return {
|
|
111
139
|
...baseEvent,
|
|
112
140
|
type: 'status',
|
|
@@ -118,7 +146,25 @@ export class EventTransformer {
|
|
|
118
146
|
|
|
119
147
|
// Handle user messages
|
|
120
148
|
if (sdkMessage.type === 'user') {
|
|
121
|
-
const
|
|
149
|
+
const message = sdkMessage.message;
|
|
150
|
+
|
|
151
|
+
// Check for tool results in content blocks
|
|
152
|
+
if (message?.content && Array.isArray(message.content)) {
|
|
153
|
+
for (const block of message.content) {
|
|
154
|
+
if (block.type === 'tool_result') {
|
|
155
|
+
return {
|
|
156
|
+
...baseEvent,
|
|
157
|
+
type: 'tool_result',
|
|
158
|
+
toolName: block.tool_name || 'unknown',
|
|
159
|
+
callId: block.tool_use_id || '',
|
|
160
|
+
result: block.content
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Otherwise extract text content
|
|
167
|
+
const textContent = this.extractUserContent(message?.content);
|
|
122
168
|
if (!textContent) {
|
|
123
169
|
return null;
|
|
124
170
|
}
|
|
@@ -147,7 +193,13 @@ export class EventTransformer {
|
|
|
147
193
|
type: 'error',
|
|
148
194
|
message: `Execution failed: ${sdkMessage.subtype}`,
|
|
149
195
|
error: { subtype: sdkMessage.subtype },
|
|
150
|
-
errorType: sdkMessage.subtype
|
|
196
|
+
errorType: sdkMessage.subtype || 'result_error',
|
|
197
|
+
context: {
|
|
198
|
+
subtype: sdkMessage.subtype,
|
|
199
|
+
duration_ms: sdkMessage.duration_ms,
|
|
200
|
+
num_turns: sdkMessage.num_turns
|
|
201
|
+
},
|
|
202
|
+
sdkError: sdkMessage
|
|
151
203
|
};
|
|
152
204
|
}
|
|
153
205
|
}
|
package/src/stage-executor.ts
CHANGED
|
@@ -95,6 +95,10 @@ export class StageExecutor {
|
|
|
95
95
|
|
|
96
96
|
let plan = '';
|
|
97
97
|
for await (const message of response) {
|
|
98
|
+
// Emit raw SDK event first
|
|
99
|
+
this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));
|
|
100
|
+
|
|
101
|
+
// Then emit transformed event
|
|
98
102
|
const transformed = this.eventTransformer.transform(message);
|
|
99
103
|
if (transformed) {
|
|
100
104
|
if (transformed.type !== 'token') {
|
|
@@ -102,6 +106,7 @@ export class StageExecutor {
|
|
|
102
106
|
}
|
|
103
107
|
this.eventHandler?.(transformed);
|
|
104
108
|
}
|
|
109
|
+
|
|
105
110
|
if (message.type === 'assistant' && message.message?.content) {
|
|
106
111
|
for (const c of message.message.content) {
|
|
107
112
|
if (c.type === 'text' && c.text) plan += c.text + '\n';
|
|
@@ -136,6 +141,10 @@ export class StageExecutor {
|
|
|
136
141
|
});
|
|
137
142
|
const results: any[] = [];
|
|
138
143
|
for await (const message of response) {
|
|
144
|
+
// Emit raw SDK event first
|
|
145
|
+
this.eventHandler?.(this.eventTransformer.createRawSDKEvent(message));
|
|
146
|
+
|
|
147
|
+
// Then emit transformed event
|
|
139
148
|
const transformed = this.eventTransformer.transform(message);
|
|
140
149
|
if (transformed) {
|
|
141
150
|
if (transformed.type !== 'token') {
|
|
@@ -143,6 +152,7 @@ export class StageExecutor {
|
|
|
143
152
|
}
|
|
144
153
|
this.eventHandler?.(transformed);
|
|
145
154
|
}
|
|
155
|
+
|
|
146
156
|
results.push(message);
|
|
147
157
|
}
|
|
148
158
|
return { results };
|
|
@@ -120,15 +120,30 @@ export class TaskProgressReporter {
|
|
|
120
120
|
case 'content_block_start':
|
|
121
121
|
case 'content_block_stop':
|
|
122
122
|
case 'compact_boundary':
|
|
123
|
-
case 'tool_call':
|
|
124
|
-
case 'tool_result':
|
|
125
123
|
case 'message_start':
|
|
126
124
|
case 'message_stop':
|
|
127
125
|
case 'metric':
|
|
128
126
|
case 'artifact':
|
|
127
|
+
case 'raw_sdk_event':
|
|
129
128
|
// Skip verbose streaming artifacts from persistence
|
|
130
129
|
return;
|
|
131
130
|
|
|
131
|
+
case 'tool_call': {
|
|
132
|
+
const logLine = this.formatToolCallEvent(event);
|
|
133
|
+
if (logLine) {
|
|
134
|
+
await this.appendLog(logLine);
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case 'tool_result': {
|
|
140
|
+
const logLine = this.formatToolResultEvent(event);
|
|
141
|
+
if (logLine) {
|
|
142
|
+
await this.appendLog(logLine);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
132
147
|
case 'file_write':
|
|
133
148
|
await this.appendLog(this.formatFileWriteEvent(event));
|
|
134
149
|
return;
|
|
@@ -284,4 +299,31 @@ export class TaskProgressReporter {
|
|
|
284
299
|
const compact = text.replace(/\s+/g, ' ').trim();
|
|
285
300
|
return compact.length > max ? `${compact.slice(0, max)}…` : compact;
|
|
286
301
|
}
|
|
302
|
+
|
|
303
|
+
private formatToolCallEvent(event: Extract<AgentEvent, { type: 'tool_call' }>): string | null {
|
|
304
|
+
// File operations to track
|
|
305
|
+
const fileOps = ['read_file', 'write', 'search_replace', 'delete_file', 'glob_file_search', 'file_search', 'list_dir', 'edit_notebook'];
|
|
306
|
+
// Terminal commands to track
|
|
307
|
+
const terminalOps = ['run_terminal_cmd', 'bash', 'shell'];
|
|
308
|
+
|
|
309
|
+
if (fileOps.includes(event.toolName)) {
|
|
310
|
+
// Extract file path from args
|
|
311
|
+
const path = event.args?.target_file || event.args?.file_path || event.args?.target_notebook || event.args?.target_directory || '';
|
|
312
|
+
return `[tool] ${event.toolName}${path ? `: ${path}` : ''}`;
|
|
313
|
+
} else if (terminalOps.includes(event.toolName)) {
|
|
314
|
+
// Extract command from args
|
|
315
|
+
const cmd = event.args?.command || '';
|
|
316
|
+
const truncated = cmd.length > 80 ? `${cmd.slice(0, 80)}…` : cmd;
|
|
317
|
+
return `[cmd] ${truncated}`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Skip other tools from persistence
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private formatToolResultEvent(event: Extract<AgentEvent, { type: 'tool_result' }>): string | null {
|
|
325
|
+
// We don't need to log tool results separately - tool calls are sufficient
|
|
326
|
+
// This keeps the log concise
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
287
329
|
}
|
package/src/types.ts
CHANGED
|
@@ -141,6 +141,8 @@ export interface ErrorEvent extends BaseEvent {
|
|
|
141
141
|
message: string;
|
|
142
142
|
error?: any;
|
|
143
143
|
errorType?: string;
|
|
144
|
+
context?: Record<string, any>; // Partial error context for debugging
|
|
145
|
+
sdkError?: any; // Original SDK error object
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
// Legacy events (keeping for backwards compatibility)
|
|
@@ -170,6 +172,11 @@ export interface ArtifactEvent extends BaseEvent {
|
|
|
170
172
|
content: any;
|
|
171
173
|
}
|
|
172
174
|
|
|
175
|
+
export interface RawSDKEvent extends BaseEvent {
|
|
176
|
+
type: 'raw_sdk_event';
|
|
177
|
+
sdkMessage: any; // Full SDK message for debugging
|
|
178
|
+
}
|
|
179
|
+
|
|
173
180
|
export type AgentEvent =
|
|
174
181
|
| TokenEvent
|
|
175
182
|
| ContentBlockStartEvent
|
|
@@ -188,7 +195,8 @@ export type AgentEvent =
|
|
|
188
195
|
| DiffEvent
|
|
189
196
|
| FileWriteEvent
|
|
190
197
|
| MetricEvent
|
|
191
|
-
| ArtifactEvent
|
|
198
|
+
| ArtifactEvent
|
|
199
|
+
| RawSDKEvent;
|
|
192
200
|
|
|
193
201
|
export interface ExecutionResult {
|
|
194
202
|
results: any[];
|