@posthog/agent 1.1.0 → 1.3.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/CLAUDE.md +68 -35
- package/README.md +55 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/src/agent.d.ts +5 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +65 -11
- package/dist/src/agent.js.map +1 -1
- package/dist/src/event-transformer.d.ts +2 -0
- package/dist/src/event-transformer.d.ts.map +1 -1
- package/dist/src/event-transformer.js +53 -5
- package/dist/src/event-transformer.js.map +1 -1
- package/dist/src/posthog-api.d.ts +34 -0
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +38 -0
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/stage-executor.d.ts +5 -2
- package/dist/src/stage-executor.d.ts.map +1 -1
- package/dist/src/stage-executor.js +20 -12
- package/dist/src/stage-executor.js.map +1 -1
- package/dist/src/task-progress-reporter.d.ts +44 -0
- package/dist/src/task-progress-reporter.d.ts.map +1 -0
- package/dist/src/task-progress-reporter.js +234 -0
- package/dist/src/task-progress-reporter.js.map +1 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -1
- package/src/agent.ts +77 -11
- package/src/event-transformer.ts +61 -7
- package/src/posthog-api.ts +79 -0
- package/src/stage-executor.ts +29 -15
- package/src/task-progress-reporter.ts +287 -0
- package/src/types.ts +30 -2
- package/dist/src/utils/mcp.d.ts +0 -10
- package/dist/src/utils/mcp.d.ts.map +0 -1
- package/dist/src/utils/mcp.js +0 -18
- package/dist/src/utils/mcp.js.map +0 -1
- package/src/utils/mcp.ts +0 -15
|
@@ -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 { Task } 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';\nimport { POSTHOG_MCP } from './utils/mcp.js';\n\nexport class StageExecutor {\n private registry: AgentRegistry;\n private logger: Logger;\n private eventTransformer: EventTransformer;\n private promptBuilder: PromptBuilder;\n\n constructor(registry: AgentRegistry, logger: Logger, promptBuilder?: PromptBuilder) {\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 }\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: {\n ...POSTHOG_MCP\n }\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 && transformed.type !== 'token') {\n this.logger.debug('Planning event', { type: transformed.type });\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: {\n ...POSTHOG_MCP\n }\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 && transformed.type !== 'token') {\n this.logger.debug('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,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;AACzB,YAAA,UAAU,EAAE;AACV,gBAAA,GAAG;AACJ;SACF;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,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;AAC/C,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;YAClE;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 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,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,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AACzF,YAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;QACxB;QAEA,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAA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,OAAO,CAAC;QACvB;QACA,OAAO,EAAE,OAAO,EAAE;IACpB;AACD;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Logger } from './utils/logger.js';
|
|
2
|
+
import type { PostHogAPIClient } from './posthog-api.js';
|
|
3
|
+
import type { AgentEvent } from './types.js';
|
|
4
|
+
interface ProgressMetadata {
|
|
5
|
+
workflowId?: string;
|
|
6
|
+
workflowRunId?: string;
|
|
7
|
+
activityId?: string;
|
|
8
|
+
totalSteps?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Persists task execution progress to PostHog so clients can poll for updates.
|
|
12
|
+
*
|
|
13
|
+
* The reporter is intentionally best-effort – failures are logged but never
|
|
14
|
+
* allowed to break the agent execution flow.
|
|
15
|
+
*/
|
|
16
|
+
export declare class TaskProgressReporter {
|
|
17
|
+
private posthogAPI?;
|
|
18
|
+
private logger;
|
|
19
|
+
private progressRecord?;
|
|
20
|
+
private taskId?;
|
|
21
|
+
private outputLog;
|
|
22
|
+
private totalSteps?;
|
|
23
|
+
private lastLogEntry?;
|
|
24
|
+
constructor(posthogAPI: PostHogAPIClient | undefined, logger: Logger);
|
|
25
|
+
get progressId(): string | undefined;
|
|
26
|
+
start(taskId: string, metadata?: ProgressMetadata): Promise<void>;
|
|
27
|
+
stageStarted(stageKey: string, stageIndex: number): Promise<void>;
|
|
28
|
+
stageCompleted(stageKey: string, completedStages: number): Promise<void>;
|
|
29
|
+
branchCreated(stageKey: string, branchName: string): Promise<void>;
|
|
30
|
+
commitMade(stageKey: string, kind: 'plan' | 'implementation'): Promise<void>;
|
|
31
|
+
pullRequestCreated(stageKey: string, prUrl: string): Promise<void>;
|
|
32
|
+
noNextStage(stageKey?: string): Promise<void>;
|
|
33
|
+
complete(): Promise<void>;
|
|
34
|
+
fail(error: Error | string): Promise<void>;
|
|
35
|
+
appendLog(line: string): Promise<void>;
|
|
36
|
+
recordEvent(event: AgentEvent): Promise<void>;
|
|
37
|
+
private update;
|
|
38
|
+
private summarizeUserMessage;
|
|
39
|
+
private formatFileWriteEvent;
|
|
40
|
+
private formatDiffEvent;
|
|
41
|
+
private truncateMultiline;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=task-progress-reporter.d.ts.map
|
|
@@ -0,0 +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,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAmB;IACtC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,cAAc,CAAC,CAAqB;IAC5C,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,UAAU,EAAE,gBAAgB,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM;IAKpE,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAEK,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BrE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjE,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,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;YA8DrC,MAAM;IA6BpB,OAAO,CAAC,oBAAoB;IAiE5B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persists task execution progress to PostHog so clients can poll for updates.
|
|
3
|
+
*
|
|
4
|
+
* The reporter is intentionally best-effort – failures are logged but never
|
|
5
|
+
* allowed to break the agent execution flow.
|
|
6
|
+
*/
|
|
7
|
+
class TaskProgressReporter {
|
|
8
|
+
posthogAPI;
|
|
9
|
+
logger;
|
|
10
|
+
progressRecord;
|
|
11
|
+
taskId;
|
|
12
|
+
outputLog = [];
|
|
13
|
+
totalSteps;
|
|
14
|
+
lastLogEntry;
|
|
15
|
+
constructor(posthogAPI, logger) {
|
|
16
|
+
this.posthogAPI = posthogAPI;
|
|
17
|
+
this.logger = logger.child('TaskProgressReporter');
|
|
18
|
+
}
|
|
19
|
+
get progressId() {
|
|
20
|
+
return this.progressRecord?.id;
|
|
21
|
+
}
|
|
22
|
+
async start(taskId, metadata = {}) {
|
|
23
|
+
if (!this.posthogAPI) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.taskId = taskId;
|
|
27
|
+
this.totalSteps = metadata.totalSteps;
|
|
28
|
+
try {
|
|
29
|
+
const record = await this.posthogAPI.createTaskProgress(taskId, {
|
|
30
|
+
status: 'started',
|
|
31
|
+
current_step: 'initializing',
|
|
32
|
+
total_steps: metadata.totalSteps ?? 0,
|
|
33
|
+
completed_steps: 0,
|
|
34
|
+
workflow_id: metadata.workflowId,
|
|
35
|
+
workflow_run_id: metadata.workflowRunId,
|
|
36
|
+
activity_id: metadata.activityId,
|
|
37
|
+
output_log: '',
|
|
38
|
+
});
|
|
39
|
+
this.progressRecord = record;
|
|
40
|
+
this.outputLog = record.output_log ? record.output_log.split('\n') : [];
|
|
41
|
+
this.logger.debug('Created task progress record', { taskId, progressId: record.id });
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.logger.warn('Failed to create task progress record', { taskId, error: error.message });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async stageStarted(stageKey, stageIndex) {
|
|
48
|
+
await this.update({
|
|
49
|
+
status: 'in_progress',
|
|
50
|
+
current_step: stageKey,
|
|
51
|
+
completed_steps: Math.min(stageIndex, this.totalSteps ?? stageIndex),
|
|
52
|
+
}, `Stage started: ${stageKey}`);
|
|
53
|
+
}
|
|
54
|
+
async stageCompleted(stageKey, completedStages) {
|
|
55
|
+
await this.update({
|
|
56
|
+
status: 'in_progress',
|
|
57
|
+
current_step: stageKey,
|
|
58
|
+
completed_steps: Math.min(completedStages, this.totalSteps ?? completedStages),
|
|
59
|
+
}, `Stage completed: ${stageKey}`);
|
|
60
|
+
}
|
|
61
|
+
async branchCreated(stageKey, branchName) {
|
|
62
|
+
await this.appendLog(`Branch created (${stageKey}): ${branchName}`);
|
|
63
|
+
}
|
|
64
|
+
async commitMade(stageKey, kind) {
|
|
65
|
+
await this.appendLog(`Commit made (${stageKey}, ${kind})`);
|
|
66
|
+
}
|
|
67
|
+
async pullRequestCreated(stageKey, prUrl) {
|
|
68
|
+
await this.appendLog(`Pull request created (${stageKey}): ${prUrl}`);
|
|
69
|
+
}
|
|
70
|
+
async noNextStage(stageKey) {
|
|
71
|
+
await this.appendLog(stageKey
|
|
72
|
+
? `No next stage available after '${stageKey}'. Execution halted.`
|
|
73
|
+
: 'No next stage available. Execution halted.');
|
|
74
|
+
}
|
|
75
|
+
async complete() {
|
|
76
|
+
await this.update({ status: 'completed', completed_steps: this.totalSteps }, 'Workflow execution completed');
|
|
77
|
+
}
|
|
78
|
+
async fail(error) {
|
|
79
|
+
const message = typeof error === 'string' ? error : error.message;
|
|
80
|
+
await this.update({ status: 'failed', error_message: message }, `Workflow execution failed: ${message}`);
|
|
81
|
+
}
|
|
82
|
+
async appendLog(line) {
|
|
83
|
+
await this.update({}, line);
|
|
84
|
+
}
|
|
85
|
+
async recordEvent(event) {
|
|
86
|
+
if (!this.posthogAPI || !this.progressId || !this.taskId) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
switch (event.type) {
|
|
90
|
+
case 'token':
|
|
91
|
+
case 'message_delta':
|
|
92
|
+
case 'content_block_start':
|
|
93
|
+
case 'content_block_stop':
|
|
94
|
+
case 'compact_boundary':
|
|
95
|
+
case 'tool_call':
|
|
96
|
+
case 'tool_result':
|
|
97
|
+
case 'message_start':
|
|
98
|
+
case 'message_stop':
|
|
99
|
+
case 'metric':
|
|
100
|
+
case 'artifact':
|
|
101
|
+
// Skip verbose streaming artifacts from persistence
|
|
102
|
+
return;
|
|
103
|
+
case 'file_write':
|
|
104
|
+
await this.appendLog(this.formatFileWriteEvent(event));
|
|
105
|
+
return;
|
|
106
|
+
case 'diff':
|
|
107
|
+
await this.appendLog(this.formatDiffEvent(event));
|
|
108
|
+
return;
|
|
109
|
+
case 'status':
|
|
110
|
+
// Status events are covered by dedicated progress updates
|
|
111
|
+
return;
|
|
112
|
+
case 'error':
|
|
113
|
+
await this.appendLog(`[error] ${event.message}`);
|
|
114
|
+
return;
|
|
115
|
+
case 'done': {
|
|
116
|
+
const cost = event.totalCostUsd !== undefined ? ` cost=$${event.totalCostUsd.toFixed(2)}` : '';
|
|
117
|
+
await this.appendLog(`[done] duration=${event.durationMs ?? 'unknown'}ms turns=${event.numTurns ?? 'unknown'}${cost}`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
case 'init':
|
|
121
|
+
// Omit verbose init messages from persisted log
|
|
122
|
+
return;
|
|
123
|
+
case 'user_message': {
|
|
124
|
+
const summary = this.summarizeUserMessage(event.content);
|
|
125
|
+
if (summary) {
|
|
126
|
+
await this.appendLog(summary);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
default:
|
|
131
|
+
// For any unfamiliar event types, avoid spamming the log.
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async update(update, logLine) {
|
|
136
|
+
if (!this.posthogAPI || !this.progressId || !this.taskId) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (logLine) {
|
|
140
|
+
if (logLine !== this.lastLogEntry) {
|
|
141
|
+
this.outputLog.push(logLine);
|
|
142
|
+
this.lastLogEntry = logLine;
|
|
143
|
+
}
|
|
144
|
+
update.output_log = this.outputLog.join('\n');
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const record = await this.posthogAPI.updateTaskProgress(this.taskId, this.progressId, update);
|
|
148
|
+
// Sync local cache with server response to avoid drift if server modifies values
|
|
149
|
+
this.progressRecord = record;
|
|
150
|
+
if (record.output_log !== undefined && record.output_log !== null) {
|
|
151
|
+
this.outputLog = record.output_log ? record.output_log.split('\n') : [];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
this.logger.warn('Failed to update task progress record', {
|
|
156
|
+
taskId: this.taskId,
|
|
157
|
+
progressId: this.progressId,
|
|
158
|
+
error: error.message,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
summarizeUserMessage(content) {
|
|
163
|
+
if (!content) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const trimmed = content.trim();
|
|
167
|
+
if (!trimmed) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const fileUpdateMatch = trimmed.match(/The file\s+([^\s]+)\s+has been updated/i);
|
|
171
|
+
if (fileUpdateMatch) {
|
|
172
|
+
return `[user] file updated: ${fileUpdateMatch[1]}`;
|
|
173
|
+
}
|
|
174
|
+
if (/Todos have been modified/i.test(trimmed)) {
|
|
175
|
+
return '[todo] list updated';
|
|
176
|
+
}
|
|
177
|
+
const diffMatch = trimmed.match(/diff --git a\/([^\s]+) b\/([^\s]+)/);
|
|
178
|
+
if (diffMatch) {
|
|
179
|
+
return `[diff] ${diffMatch[2] ?? diffMatch[1]}`;
|
|
180
|
+
}
|
|
181
|
+
const gitStatusMatch = trimmed.match(/^On branch ([^\n]+)/);
|
|
182
|
+
if (gitStatusMatch) {
|
|
183
|
+
return `[git] status ${gitStatusMatch[1]}`;
|
|
184
|
+
}
|
|
185
|
+
if (/This Bash command contains multiple operations/i.test(trimmed)) {
|
|
186
|
+
return '[approval] multi-step command pending';
|
|
187
|
+
}
|
|
188
|
+
if (/This command requires approval/i.test(trimmed)) {
|
|
189
|
+
return '[approval] command awaiting approval';
|
|
190
|
+
}
|
|
191
|
+
if (/^Exit plan mode\?/i.test(trimmed)) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
if (trimmed.includes('node_modules')) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
if (trimmed.includes('total ') && trimmed.includes('drwx')) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
if (trimmed.includes('→')) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
if (trimmed.split('\n').length > 2) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const normalized = trimmed.replace(/\s+/g, ' ');
|
|
207
|
+
const maxLen = 120;
|
|
208
|
+
if (!normalized) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const preview = normalized.length > maxLen ? `${normalized.slice(0, maxLen)}…` : normalized;
|
|
212
|
+
return `[user] ${preview}`;
|
|
213
|
+
}
|
|
214
|
+
formatFileWriteEvent(event) {
|
|
215
|
+
const size = event.bytes !== undefined ? ` (${event.bytes} bytes)` : '';
|
|
216
|
+
return `[file] wrote ${event.path}${size}`;
|
|
217
|
+
}
|
|
218
|
+
formatDiffEvent(event) {
|
|
219
|
+
const summary = event.summary
|
|
220
|
+
? event.summary.trim()
|
|
221
|
+
: this.truncateMultiline(event.patch ?? '', 160);
|
|
222
|
+
return `[diff] ${event.file}${summary ? ` | ${summary}` : ''}`;
|
|
223
|
+
}
|
|
224
|
+
truncateMultiline(text, max = 160) {
|
|
225
|
+
if (!text) {
|
|
226
|
+
return '';
|
|
227
|
+
}
|
|
228
|
+
const compact = text.replace(/\s+/g, ' ').trim();
|
|
229
|
+
return compact.length > max ? `${compact.slice(0, max)}…` : compact;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { TaskProgressReporter };
|
|
234
|
+
//# sourceMappingURL=task-progress-reporter.js.map
|
|
@@ -0,0 +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,CAAC,UAAU,EAAE;YACpB;QACF;AAEA,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU;AAErC,QAAA,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CA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AAE,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;;;;"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -148,11 +148,31 @@ export interface TaskExecutionResult {
|
|
|
148
148
|
plan?: string;
|
|
149
149
|
executionResult?: ExecutionResult;
|
|
150
150
|
}
|
|
151
|
+
export type McpServerConfig = {
|
|
152
|
+
type?: 'stdio';
|
|
153
|
+
command: string;
|
|
154
|
+
args?: string[];
|
|
155
|
+
env?: Record<string, string>;
|
|
156
|
+
} | {
|
|
157
|
+
type: 'sse';
|
|
158
|
+
url: string;
|
|
159
|
+
headers?: Record<string, string>;
|
|
160
|
+
} | {
|
|
161
|
+
type: 'http';
|
|
162
|
+
url: string;
|
|
163
|
+
headers?: Record<string, string>;
|
|
164
|
+
} | {
|
|
165
|
+
type: 'sdk';
|
|
166
|
+
name: string;
|
|
167
|
+
instance?: any;
|
|
168
|
+
};
|
|
151
169
|
export interface AgentConfig {
|
|
152
170
|
workingDirectory?: string;
|
|
153
171
|
onEvent?: (event: AgentEvent) => void;
|
|
154
172
|
posthogApiUrl?: string;
|
|
155
173
|
posthogApiKey?: string;
|
|
174
|
+
posthogMcpUrl?: string;
|
|
175
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
156
176
|
debug?: boolean;
|
|
157
177
|
}
|
|
158
178
|
export interface PostHogAPIConfig {
|
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,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,YAAY,gBAAgB;IAC5B,MAAM,sBAAsB;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IAC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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GAAG;IACF,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;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\nexport interface AgentConfig {\n workingDirectory?: string;\n onEvent?: (event: AgentEvent) => void;\n
|
|
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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based workflow for PostHog tasks",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
11
12
|
"types": "./dist/index.d.ts"
|
|
12
13
|
}
|
|
13
14
|
},
|