@posthog/agent 1.9.0 → 1.10.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/README.md CHANGED
@@ -15,7 +15,7 @@ bun run example
15
15
  - **PostHog Integration**: Fetches existing tasks from PostHog API
16
16
  - **Configurable Workflows**: Execute tasks via PostHog-defined or local workflows
17
17
  - **Branch Management**: Automatic branch creation for planning and implementation
18
- - **Progress Tracking**: Execution status stored in PostHog `TaskProgress` records for easy polling
18
+ - **Progress Tracking**: Execution status stored in PostHog `TaskRun` records for easy polling
19
19
 
20
20
  ## Usage
21
21
 
@@ -96,7 +96,7 @@ your-repo/
96
96
 
97
97
  ## Progress Updates
98
98
 
99
- Progress for each task execution is persisted to PostHog's `TaskProgress` model, so UIs can poll for updates without relying on streaming hooks:
99
+ Progress for each task execution is persisted to PostHog's `TaskRun` model, so UIs can poll for updates without relying on streaming hooks:
100
100
 
101
101
  ```typescript
102
102
  const agent = new Agent({
@@ -106,9 +106,12 @@ const agent = new Agent({
106
106
  });
107
107
 
108
108
  const poller = setInterval(async () => {
109
- const progress = await agent.getPostHogClient()?.getTaskProgress(taskId);
110
- if (progress?.has_progress) {
111
- renderProgress(progress.status, progress.current_step, progress.completed_steps, progress.total_steps);
109
+ const runs = await agent.getPostHogClient()?.listTaskRuns(taskId);
110
+ const latestRun = runs?.sort((a, b) =>
111
+ new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
112
+ )[0];
113
+ if (latestRun) {
114
+ renderProgress(latestRun.status, latestRun.log, latestRun.current_stage);
112
115
  }
113
116
  }, 3000);
114
117
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Agent, } from './src/agent.js';
2
2
  export { PermissionMode, } from './src/types.js';
3
- export type { Task, SupportingFile, ExecutionResult, AgentConfig, McpServerConfig, AgentEvent } from './src/types.js';
3
+ export type { Task, TaskRun, SupportingFile, ExecutionResult, AgentConfig, McpServerConfig, AgentEvent } from './src/types.js';
4
4
  export type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions, AgentDefinition } from './src/workflow-types.js';
5
5
  export { Logger, LogLevel, } from './src/utils/logger.js';
6
6
  export type { LoggerConfig } from './src/utils/logger.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,GACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,cAAc,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,IAAI,EACJ,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACb,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACH,MAAM,EACN,QAAQ,GACX,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACR,YAAY,EACf,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAGxE,YAAY,EACR,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,GACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,cAAc,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,IAAI,EACJ,OAAO,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I,CAAC;IAoB1F,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
@@ -130,24 +130,29 @@ class Agent {
130
130
  await this.posthogAPI.updateTask(task.id, { workflow: workflowId });
131
131
  task.workflow = workflowId;
132
132
  }
133
- if (!task.current_stage && workflow.stages.length > 0) {
134
- const firstStage = [...workflow.stages].sort((a, b) => a.position - b.position)[0];
135
- await this.posthogAPI.updateTaskStage(task.id, firstStage.id);
136
- task.current_stage = firstStage.id;
137
- }
138
133
  }
139
134
  catch (e) {
140
- this.logger.warn('Failed to sync task workflow/stage before execution', { error: e.message });
135
+ this.logger.warn('Failed to sync task workflow before execution', { error: e.message });
141
136
  }
142
137
  }
143
138
  const executionId = this.taskManager.generateExecutionId();
144
139
  this.logger.info('Starting workflow execution', { taskId: task.id, workflowId, executionId });
145
140
  this.taskManager.startExecution(task.id, 'plan_and_build', executionId);
146
141
  await this.progressReporter.start(task.id, {
147
- workflowId,
148
- workflowRunId: executionId,
149
142
  totalSteps: orderedStages.length,
150
143
  });
144
+ // Set initial stage on the newly created run
145
+ const firstStage = orderedStages[0];
146
+ if (this.posthogAPI && this.progressReporter.runId && firstStage) {
147
+ try {
148
+ await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {
149
+ current_stage: firstStage.id
150
+ });
151
+ }
152
+ catch (e) {
153
+ this.logger.warn('Failed to set initial stage on run', { error: e.message });
154
+ }
155
+ }
151
156
  try {
152
157
  let startIndex = 0;
153
158
  const currentStageId = task.current_stage;
@@ -169,15 +174,18 @@ class Agent {
169
174
  if (idx >= 0)
170
175
  startIndex = idx;
171
176
  }
172
- // Align server-side stage when restarting from the beginning
173
- if (this.posthogAPI) {
177
+ // Align server-side stage when restarting from a different stage
178
+ if (this.posthogAPI && this.progressReporter.runId) {
174
179
  const targetStage = orderedStages[startIndex];
175
180
  if (targetStage && targetStage.id !== currentStageId) {
176
181
  try {
177
- await this.posthogAPI.updateTaskStage(task.id, targetStage.id);
178
- task.current_stage = targetStage.id;
182
+ await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {
183
+ current_stage: targetStage.id
184
+ });
185
+ }
186
+ catch (e) {
187
+ this.logger.warn('Failed to update run stage', { error: e.message });
179
188
  }
180
- catch { }
181
189
  }
182
190
  }
183
191
  for (let i = startIndex; i < orderedStages.length; i++) {
@@ -285,15 +293,17 @@ class Agent {
285
293
  this.emitEvent(this.adapter.createStatusEvent('stage_complete', { stage: stage.key }));
286
294
  }
287
295
  async progressToNextStage(taskId, currentStageKey) {
288
- if (!this.posthogAPI)
289
- throw new Error('PostHog API not configured. Cannot progress stage.');
296
+ if (!this.posthogAPI || !this.progressReporter.runId) {
297
+ throw new Error('PostHog API not configured or no active run. Cannot progress stage.');
298
+ }
290
299
  try {
291
- await this.posthogAPI.progressTask(taskId, { auto: true });
300
+ await this.posthogAPI.progressTaskRun(taskId, this.progressReporter.runId);
292
301
  }
293
302
  catch (error) {
294
303
  if (error instanceof Error && error.message.includes('No next stage available')) {
295
- this.logger.warn('No next stage available when attempting to progress task', {
304
+ this.logger.warn('No next stage available when attempting to progress run', {
296
305
  taskId,
306
+ runId: this.progressReporter.runId,
297
307
  stage: currentStageKey,
298
308
  error: error.message,
299
309
  });
@@ -417,24 +427,30 @@ Generated by PostHog Agent`;
417
427
  return prUrl;
418
428
  }
419
429
  async attachPullRequestToTask(taskId, prUrl, branchName) {
420
- this.logger.info('Attaching PR to task', { taskId, prUrl, branchName });
421
- if (!this.posthogAPI) {
422
- const error = new Error('PostHog API not configured. Cannot attach PR to task.');
430
+ this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });
431
+ if (!this.posthogAPI || !this.progressReporter.runId) {
432
+ const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');
423
433
  this.logger.error('PostHog API not configured', error);
424
434
  throw error;
425
435
  }
426
- await this.posthogAPI.attachTaskPullRequest(taskId, prUrl, branchName);
427
- this.logger.debug('PR attached to task', { taskId, prUrl });
436
+ const updates = {
437
+ output: { pr_url: prUrl }
438
+ };
439
+ if (branchName) {
440
+ updates.branch = branchName;
441
+ }
442
+ await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);
443
+ this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });
428
444
  }
429
445
  async updateTaskBranch(taskId, branchName) {
430
- this.logger.info('Updating task branch', { taskId, branchName });
431
- if (!this.posthogAPI) {
432
- const error = new Error('PostHog API not configured. Cannot update task branch.');
446
+ this.logger.info('Updating task run branch', { taskId, branchName });
447
+ if (!this.posthogAPI || !this.progressReporter.runId) {
448
+ const error = new Error('PostHog API not configured or no active run. Cannot update branch.');
433
449
  this.logger.error('PostHog API not configured', error);
434
450
  throw error;
435
451
  }
436
- await this.posthogAPI.setTaskBranch(taskId, branchName);
437
- this.logger.debug('Task branch updated', { taskId, branchName });
452
+ await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });
453
+ this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });
438
454
  }
439
455
  // Execution management
440
456
  cancelTask(taskId) {
@@ -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 { ClaudeAdapter } from './adapters/claude/claude-adapter.js';\nimport type { ProviderAdapter } from './adapters/types.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 adapter: ProviderAdapter;\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 // Hardcode Claude adapter for now - extensible for other providers later\n this.adapter = new ClaudeAdapter();\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 posthogClient: this.posthogAPI,\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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n }\n\n this.emitEvent(this.adapter.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.adapter.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.adapter.createRawSDKEvent(message));\n // Emit transformed event\n const transformedEvent = this.adapter.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":";;;;;;;;;;;;;;;MAmBa,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,OAAO;AACP,IAAA,MAAM;AACN,IAAA,aAAa;AACb,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,gBAAgB;AAChB,IAAA,UAAU;AACX,IAAA,KAAK;AAEZ,IAAA,WAAA,CAA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AAC,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 { ClaudeAdapter } from './adapters/claude/claude-adapter.js';\nimport type { ProviderAdapter } from './adapters/types.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 adapter: ProviderAdapter;\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 // Hardcode Claude adapter for now - extensible for other providers later\n this.adapter = new ClaudeAdapter();\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 posthogClient: this.posthogAPI,\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 } catch (e) {\n this.logger.warn('Failed to sync task workflow 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 totalSteps: orderedStages.length,\n });\n\n // Set initial stage on the newly created run\n const firstStage = orderedStages[0];\n if (this.posthogAPI && this.progressReporter.runId && firstStage) {\n try {\n await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {\n current_stage: firstStage.id\n });\n } catch (e) {\n this.logger.warn('Failed to set initial stage on run', { error: (e as Error).message });\n }\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.adapter.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 a different stage\n if (this.posthogAPI && this.progressReporter.runId) {\n const targetStage = orderedStages[startIndex];\n if (targetStage && targetStage.id !== currentStageId) {\n try {\n await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {\n current_stage: targetStage.id\n });\n } catch (e) {\n this.logger.warn('Failed to update run stage', { error: (e as Error).message });\n }\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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.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.adapter.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n }\n\n this.emitEvent(this.adapter.createStatusEvent('stage_complete', { stage: stage.key }));\n }\n\n async progressToNextStage(taskId: string, currentStageKey?: string): Promise<void> {\n if (!this.posthogAPI || !this.progressReporter.runId) {\n throw new Error('PostHog API not configured or no active run. Cannot progress stage.');\n }\n try {\n await this.posthogAPI.progressTaskRun(taskId, this.progressReporter.runId);\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 run', {\n taskId,\n runId: this.progressReporter.runId,\n stage: currentStageKey,\n error: error.message,\n });\n this.emitEvent(this.adapter.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.adapter.createRawSDKEvent(message));\n // Emit transformed event\n const transformedEvent = this.adapter.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 run', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n const updates: any = {\n output: { pr_url: prUrl }\n };\n if (branchName) {\n updates.branch = branchName;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);\n this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task run branch', { taskId, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot update branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });\n this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, 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":";;;;;;;;;;;;;;;MAmBa,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,OAAO;AACP,IAAA,MAAM;AACN,IAAA,aAAa;AACb,IAAA,gBAAgB;AAChB,IAAA,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AAI,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,49 +1,13 @@
1
- import type { Task, PostHogAPIConfig, PostHogResource, UrlMention } from './types.js';
1
+ import type { Task, TaskRun, LogEntry, PostHogAPIConfig, PostHogResource, UrlMention } from './types.js';
2
2
  import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
3
- interface TaskProgressResponse {
4
- has_progress: boolean;
5
- id?: string;
6
- status?: "started" | "in_progress" | "completed" | "failed";
7
- current_step?: string;
8
- completed_steps?: number;
9
- total_steps?: number;
10
- progress_percentage?: number;
11
- output_log?: string;
12
- error_message?: string;
13
- created_at?: string;
14
- updated_at?: string;
15
- completed_at?: string;
16
- workflow_id?: string;
17
- workflow_run_id?: string;
18
- message?: string;
19
- }
20
- export interface TaskProgressRecord {
21
- id: string;
22
- task: string;
23
- status: "started" | "in_progress" | "completed" | "failed";
24
- current_step?: string | null;
25
- completed_steps?: number | null;
26
- total_steps?: number | null;
27
- progress_percentage?: number | null;
28
- output_log?: string | null;
29
- error_message?: string | null;
30
- workflow_id?: string | null;
31
- workflow_run_id?: string | null;
32
- activity_id?: string | null;
33
- created_at: string;
34
- updated_at: string;
35
- completed_at?: string | null;
36
- }
37
- export interface TaskProgressUpdate {
38
- status?: TaskProgressRecord["status"];
39
- current_step?: string | null;
40
- completed_steps?: number | null;
41
- total_steps?: number | null;
42
- output_log?: string | null;
3
+ export interface TaskRunUpdate {
4
+ status?: TaskRun["status"];
5
+ branch?: string | null;
6
+ current_stage?: string | null;
7
+ log?: LogEntry[];
43
8
  error_message?: string | null;
44
- workflow_id?: string | null;
45
- workflow_run_id?: string | null;
46
- activity_id?: string | null;
9
+ output?: Record<string, unknown> | null;
10
+ state?: Record<string, unknown>;
47
11
  }
48
12
  export declare class PostHogAPIClient {
49
13
  private config;
@@ -65,21 +29,17 @@ export declare class PostHogAPIClient {
65
29
  current_stage?: string;
66
30
  }): Promise<Task[]>;
67
31
  updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
68
- updateTaskStage(taskId: string, stageId: string): Promise<Task>;
69
- setTaskBranch(taskId: string, branch: string): Promise<Task>;
70
- attachTaskPullRequest(taskId: string, prUrl: string, branch?: string): Promise<Task>;
71
- getTaskProgress(taskId: string): Promise<TaskProgressResponse>;
72
- createTaskProgress(taskId: string, payload: TaskProgressUpdate & {
73
- status: TaskProgressRecord["status"];
74
- }): Promise<TaskProgressRecord>;
75
- updateTaskProgress(taskId: string, progressId: string, payload: TaskProgressUpdate): Promise<TaskProgressRecord>;
32
+ listTaskRuns(taskId: string): Promise<TaskRun[]>;
33
+ getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
34
+ createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>): Promise<TaskRun>;
35
+ updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
36
+ updateTaskRunStage(taskId: string, runId: string, stageId: string): Promise<TaskRun>;
37
+ progressTaskRun(taskId: string, runId: string, nextStageId?: string): Promise<TaskRun>;
38
+ setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun>;
39
+ appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun>;
76
40
  fetchWorkflow(workflowId: string): Promise<WorkflowDefinition>;
77
41
  listWorkflows(): Promise<WorkflowDefinition[]>;
78
42
  listAgents(): Promise<AgentDefinition[]>;
79
- progressTask(taskId: string, options?: {
80
- next_stage_id?: string;
81
- auto?: boolean;
82
- }): Promise<Task>;
83
43
  /**
84
44
  * Fetch error details from PostHog error tracking
85
45
  */
@@ -93,5 +53,4 @@ export declare class PostHogAPIClient {
93
53
  */
94
54
  private formatErrorContent;
95
55
  }
96
- export {};
97
56
  //# sourceMappingURL=posthog-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAkB,gBAAgB,EAAE,eAAe,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;AACpH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAS/E,UAAU,oBAAoB;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;I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