@posthog/agent 1.16.2 → 1.16.4

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 CHANGED
@@ -106,7 +106,8 @@ Note: No test, lint, or build scripts are currently defined in package.json.
106
106
  const agent = new Agent({
107
107
  workingDirectory: "/path/to/repo",
108
108
  posthogApiUrl: "https://app.posthog.com",
109
- posthogApiKey: process.env.POSTHOG_API_KEY
109
+ posthogApiKey: process.env.POSTHOG_API_KEY,
110
+ posthogProjectId: 1
110
111
  });
111
112
 
112
113
  // Fetch existing PostHog task
@@ -227,7 +228,8 @@ Each task execution creates specific Git branches:
227
228
  const agent = new Agent({
228
229
  workingDirectory: "/path/to/repo",
229
230
  posthogApiUrl: "https://app.posthog.com",
230
- posthogApiKey: process.env.POSTHOG_API_KEY
231
+ posthogApiKey: process.env.POSTHOG_API_KEY,
232
+ posthogProjectId: 1
231
233
  });
232
234
 
233
235
  // 2. Fetch existing task from PostHog
package/README.md CHANGED
@@ -27,6 +27,7 @@ const agent = new Agent({
27
27
  workingDirectory: "/path/to/repo",
28
28
  posthogApiUrl: "https://app.posthog.com",
29
29
  posthogApiKey: process.env.POSTHOG_API_KEY, // Used for both API and MCP
30
+ posthogProjectId: 1,
30
31
  onEvent: (event) => {
31
32
  // Streamed updates for responsive UIs
32
33
  if (event.type !== 'token') {
@@ -88,6 +89,7 @@ const agent = new Agent({
88
89
  workingDirectory: repoPath,
89
90
  posthogApiUrl: "https://app.posthog.com",
90
91
  posthogApiKey: process.env.POSTHOG_KEY,
92
+ posthogProjectId: 1,
91
93
  });
92
94
 
93
95
  const poller = setInterval(async () => {
@@ -165,6 +167,7 @@ const agent = new Agent({
165
167
  workingDirectory: "/path/to/repo",
166
168
  posthogApiUrl: "https://app.posthog.com",
167
169
  posthogApiKey: process.env.POSTHOG_API_KEY,
170
+ posthogProjectId: 1,
168
171
  canUseTool: async (toolName, input, { signal, suggestions }) => {
169
172
  // Block destructive commands
170
173
  if (toolName === 'Bash' && input.command?.includes('rm -rf')) {
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AASpD,OAAO,EAA4C,KAAK,iBAAiB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAIhJ,qBAAa,KAAK;IACd,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAAC,CAAmB;IACtC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAC,CAAsB;IACxC,OAAO,CAAC,UAAU,CAAC,CAAsB;IACzC,OAAO,CAAC,UAAU,CAAC,CAAa;IACzB,KAAK,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,WAAW;IA+D/B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO;IAKzB;;OAEG;YACW,oBAAoB;IA0B5B,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,EAAE,OAAO,GAAE,OAAO,YAAY,EAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDxG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,YAAY,E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AE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBlH,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;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;YAUvC,iBAAiB;IAmB/B,OAAO,CAAC,sBAAsB;YAiBhB,iBAAiB;IAsC/B,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"}
package/dist/src/agent.js CHANGED
@@ -69,6 +69,7 @@ class Agent {
69
69
  this.posthogAPI = new PostHogAPIClient({
70
70
  apiUrl: config.posthogApiUrl,
71
71
  apiKey: config.posthogApiKey,
72
+ projectId: config.posthogProjectId,
72
73
  });
73
74
  }
74
75
  this.promptBuilder = new PromptBuilder({
@@ -78,7 +79,7 @@ class Agent {
78
79
  logger: this.logger.child('PromptBuilder')
79
80
  });
80
81
  this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);
81
- this.extractor = new AISDKExtractor({ apiKey: config.posthogApiKey, baseURL: config.posthogApiUrl, logger: this.logger.child('AISDKExtractor') });
82
+ this.extractor = new AISDKExtractor({ apiKey: config.posthogApiKey, gatewayUrl: this.posthogAPI?.getLlmGatewayUrl() ?? '', logger: this.logger.child('AISDKExtractor') });
82
83
  }
83
84
  /**
84
85
  * Enable or disable debug logging
@@ -94,12 +95,8 @@ class Agent {
94
95
  if (!this.posthogAPI) {
95
96
  return;
96
97
  }
97
- if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {
98
- this.ensureOpenAIGatewayEnv();
99
- return;
100
- }
101
98
  try {
102
- const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();
99
+ const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
103
100
  const apiKey = this.posthogAPI.getApiKey();
104
101
  process.env.ANTHROPIC_BASE_URL = gatewayUrl;
105
102
  process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
@@ -352,17 +349,17 @@ Generated by PostHog Agent`;
352
349
  await this.gitManager.switchToBranch(existingBranch);
353
350
  }
354
351
  }
355
- ensureOpenAIGatewayEnv(baseUrl, token) {
356
- const resolvedBaseUrl = baseUrl || process.env.ANTHROPIC_BASE_URL;
352
+ ensureOpenAIGatewayEnv(gatewayUrl, token) {
353
+ const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;
357
354
  const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;
358
- if (resolvedBaseUrl) {
359
- process.env.OPENAI_BASE_URL = resolvedBaseUrl;
355
+ if (resolvedGatewayUrl) {
356
+ process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
360
357
  }
361
358
  if (resolvedToken) {
362
359
  process.env.OPENAI_API_KEY = resolvedToken;
363
360
  }
364
361
  if (!this.extractor) {
365
- this.extractor = new AISDKExtractor({ apiKey: resolvedToken || '', baseURL: resolvedBaseUrl || '', logger: this.logger.child('AISDKExtractor') });
362
+ this.extractor = new AISDKExtractor({ apiKey: resolvedToken || '', gatewayUrl: resolvedGatewayUrl || '', logger: this.logger.child('AISDKExtractor') });
366
363
  }
367
364
  }
368
365
  async ensurePullRequest(task, stepResults) {
@@ -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, AgentConfig, CanUseTool } from './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 { Logger } from './utils/logger.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\nimport { AISDKExtractor, type StructuredExtractor, type ExtractedQuestion, type ExtractedQuestionWithAnswer } from './structured-extraction.js';\nimport { TASK_WORKFLOW } from './workflow/config.js';\nimport type { WorkflowRuntime } from './workflow/types.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 progressReporter: TaskProgressReporter;\n private promptBuilder: PromptBuilder;\n private extractor?: StructuredExtractor;\n private mcpServers?: Record<string, any>;\n private canUseTool?: CanUseTool;\n public debug: boolean;\n\n constructor(config: AgentConfig) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.canUseTool = config.canUseTool;\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\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n });\n }\n\n this.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.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n this.extractor = new AISDKExtractor({apiKey: config.posthogApiKey, baseURL: config.posthogApiUrl, logger: this.logger.child('AISDKExtractor')});\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 this.ensureOpenAIGatewayEnv();\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 this.ensureOpenAIGatewayEnv(gatewayUrl, 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 // Adaptive task execution orchestrated via workflow steps\n async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });\n\n // Initialize progress reporter for task run tracking (needed for PR attachment)\n await this.progressReporter.start(task.id, { totalSteps: TASK_WORKFLOW.length });\n this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));\n\n await this.prepareTaskBranch(taskSlug, isCloudMode);\n\n const workflowContext: WorkflowRuntime = {\n task,\n taskSlug,\n cwd,\n isCloudMode,\n options,\n logger: this.logger,\n fileManager: this.fileManager,\n gitManager: this.gitManager,\n promptBuilder: this.promptBuilder,\n progressReporter: this.progressReporter,\n adapter: this.adapter,\n mcpServers: this.mcpServers,\n posthogAPI: this.posthogAPI,\n extractor: this.extractor,\n emitEvent: (event: any) => this.emitEvent(event),\n stepResults: {},\n };\n\n for (const step of TASK_WORKFLOW) {\n const result = await step.run({ step, context: workflowContext });\n if (result.halt) {\n return;\n }\n }\n\n const shouldCreatePR = options.createPR ?? isCloudMode;\n if (shouldCreatePR) {\n await this.ensurePullRequest(task, workflowContext.stepResults);\n }\n\n await this.progressReporter.complete();\n this.logger.info('Task execution complete', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));\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>; canUseTool?: CanUseTool } = {}): 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 // Add canUseTool hook if provided (options take precedence over instance config)\n const canUseTool = options.canUseTool || this.canUseTool;\n if (canUseTool) {\n baseOptions.canUseTool = canUseTool;\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 }): 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 async extractQuestionsFromResearch(taskId: string, includeAnswers: boolean = false): Promise<ExtractedQuestion[] | ExtractedQuestionWithAnswer[]> {\n this.logger.info('Extracting questions from research.md', { taskId, includeAnswers });\n \n if (!this.extractor) {\n throw new Error('OpenAI extractor not initialized. Ensure the LLM gateway is configured.');\n }\n\n const researchContent = await this.fileManager.readResearch(taskId);\n if (!researchContent) {\n throw new Error('research.md not found for task ' + taskId);\n }\n\n if (includeAnswers) {\n return await this.extractor.extractQuestionsWithAnswers(researchContent);\n } else {\n return await this.extractor.extractQuestions(researchContent);\n }\n }\n\n // Git operations for task execution\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 async prepareTaskBranch(taskSlug: string, isCloudMode: boolean): Promise<void> {\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n const branchName = await this.gitManager.createTaskBranch(taskSlug);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));\n\n await this.fileManager.ensureGitignore();\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });\n } else {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n } else {\n this.logger.info('Switching to existing task branch', { branch: existingBranch });\n await this.gitManager.switchToBranch(existingBranch);\n }\n }\n\n private ensureOpenAIGatewayEnv(baseUrl?: string, token?: string): void {\n const resolvedBaseUrl = baseUrl || process.env.ANTHROPIC_BASE_URL;\n const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;\n\n if (resolvedBaseUrl) {\n process.env.OPENAI_BASE_URL = resolvedBaseUrl;\n }\n\n if (resolvedToken) {\n process.env.OPENAI_API_KEY = resolvedToken;\n }\n\n if (!this.extractor) {\n this.extractor = new AISDKExtractor({apiKey: resolvedToken || '', baseURL: resolvedBaseUrl || '', logger: this.logger.child('AISDKExtractor')});\n }\n }\n\n private async ensurePullRequest(task: Task, stepResults: Record<string, any>): Promise<void> {\n const latestRun = task.latest_run;\n const existingPr =\n latestRun?.output && typeof latestRun.output === 'object'\n ? (latestRun.output as any).pr_url\n : null;\n\n if (existingPr) {\n this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });\n return;\n }\n\n const buildResult = stepResults['build'];\n if (!buildResult?.commitCreated) {\n this.logger.warn('Build step did not produce a commit; skipping PR creation', { taskId: task.id });\n return;\n }\n\n const branchName = await this.gitManager.getCurrentBranch();\n const prUrl = await this.createPullRequest(\n task.id,\n branchName,\n task.title,\n task.description ?? ''\n );\n\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));\n\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });\n } catch (error) {\n this.logger.warn('Could not attach PR to task', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\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';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MAgBa,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,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,SAAS;AACT,IAAA,UAAU;AACV,IAAA,UAAU;AACX,IAAA,KAAK;AAEZ,IAAA,WAAA,CAAY,MAAmB,EAAA;QAC3B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;AAChE,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAC7B,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK;;AAGlC,QAAA,MAAM,aAAa,GAAG,MAAM,CAAC;eACtB,OAAO,CAAC,GAAG,CAAC;AACZ,eAAA,6BAA6B;;QAGpC,MAAM,OAAO,GAA2B,EAAE;AAC1C,QAAA,IAAI,MAAM,CAAC,aAA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M,CAAC,KAAK,CAAC;AAChE,aAAA,CAAC;QACN;IACJ;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, AgentConfig, CanUseTool } from './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 { Logger } from './utils/logger.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\nimport { AISDKExtractor, type StructuredExtractor, type ExtractedQuestion, type ExtractedQuestionWithAnswer } from './structured-extraction.js';\nimport { TASK_WORKFLOW } from './workflow/config.js';\nimport type { WorkflowRuntime } from './workflow/types.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 progressReporter: TaskProgressReporter;\n private promptBuilder: PromptBuilder;\n private extractor?: StructuredExtractor;\n private mcpServers?: Record<string, any>;\n private canUseTool?: CanUseTool;\n public debug: boolean;\n\n constructor(config: AgentConfig) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.canUseTool = config.canUseTool;\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\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n projectId: config.posthogProjectId,\n });\n }\n\n this.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.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n this.extractor = new AISDKExtractor({apiKey: config.posthogApiKey, gatewayUrl: this.posthogAPI?.getLlmGatewayUrl() ?? '', logger: this.logger.child('AISDKExtractor')});\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 try {\n const gatewayUrl = 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 this.ensureOpenAIGatewayEnv(gatewayUrl, 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 // Adaptive task execution orchestrated via workflow steps\n async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });\n\n // Initialize progress reporter for task run tracking (needed for PR attachment)\n await this.progressReporter.start(task.id, { totalSteps: TASK_WORKFLOW.length });\n this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));\n\n await this.prepareTaskBranch(taskSlug, isCloudMode);\n\n const workflowContext: WorkflowRuntime = {\n task,\n taskSlug,\n cwd,\n isCloudMode,\n options,\n logger: this.logger,\n fileManager: this.fileManager,\n gitManager: this.gitManager,\n promptBuilder: this.promptBuilder,\n progressReporter: this.progressReporter,\n adapter: this.adapter,\n mcpServers: this.mcpServers,\n posthogAPI: this.posthogAPI,\n extractor: this.extractor,\n emitEvent: (event: any) => this.emitEvent(event),\n stepResults: {},\n };\n\n for (const step of TASK_WORKFLOW) {\n const result = await step.run({ step, context: workflowContext });\n if (result.halt) {\n return;\n }\n }\n\n const shouldCreatePR = options.createPR ?? isCloudMode;\n if (shouldCreatePR) {\n await this.ensurePullRequest(task, workflowContext.stepResults);\n }\n\n await this.progressReporter.complete();\n this.logger.info('Task execution complete', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));\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>; canUseTool?: CanUseTool } = {}): 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 // Add canUseTool hook if provided (options take precedence over instance config)\n const canUseTool = options.canUseTool || this.canUseTool;\n if (canUseTool) {\n baseOptions.canUseTool = canUseTool;\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 }): 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 async extractQuestionsFromResearch(taskId: string, includeAnswers: boolean = false): Promise<ExtractedQuestion[] | ExtractedQuestionWithAnswer[]> {\n this.logger.info('Extracting questions from research.md', { taskId, includeAnswers });\n \n if (!this.extractor) {\n throw new Error('OpenAI extractor not initialized. Ensure the LLM gateway is configured.');\n }\n\n const researchContent = await this.fileManager.readResearch(taskId);\n if (!researchContent) {\n throw new Error('research.md not found for task ' + taskId);\n }\n\n if (includeAnswers) {\n return await this.extractor.extractQuestionsWithAnswers(researchContent);\n } else {\n return await this.extractor.extractQuestions(researchContent);\n }\n }\n\n // Git operations for task execution\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 async prepareTaskBranch(taskSlug: string, isCloudMode: boolean): Promise<void> {\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n const branchName = await this.gitManager.createTaskBranch(taskSlug);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));\n\n await this.fileManager.ensureGitignore();\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });\n } else {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n } else {\n this.logger.info('Switching to existing task branch', { branch: existingBranch });\n await this.gitManager.switchToBranch(existingBranch);\n }\n }\n\n private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {\n const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;\n const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;\n\n if (resolvedGatewayUrl) {\n process.env.OPENAI_BASE_URL = resolvedGatewayUrl;\n }\n\n if (resolvedToken) {\n process.env.OPENAI_API_KEY = resolvedToken;\n }\n\n if (!this.extractor) {\n this.extractor = new AISDKExtractor({apiKey: resolvedToken || '', gatewayUrl: resolvedGatewayUrl || '', logger: this.logger.child('AISDKExtractor')});\n }\n }\n\n private async ensurePullRequest(task: Task, stepResults: Record<string, any>): Promise<void> {\n const latestRun = task.latest_run;\n const existingPr =\n latestRun?.output && typeof latestRun.output === 'object'\n ? (latestRun.output as any).pr_url\n : null;\n\n if (existingPr) {\n this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });\n return;\n }\n\n const buildResult = stepResults['build'];\n if (!buildResult?.commitCreated) {\n this.logger.warn('Build step did not produce a commit; skipping PR creation', { taskId: task.id });\n return;\n }\n\n const branchName = await this.gitManager.getCurrentBranch();\n const prUrl = await this.createPullRequest(\n task.id,\n branchName,\n task.title,\n task.description ?? ''\n );\n\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));\n\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });\n } catch (error) {\n this.logger.warn('Could not attach PR to task', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\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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K,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CACjF;QACL;AACA,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB;AACH;;;;"}
@@ -15,10 +15,10 @@ export declare class PostHogAPIClient {
15
15
  private get baseUrl();
16
16
  private get headers();
17
17
  private apiRequest;
18
- getTeamId(): Promise<number>;
18
+ getTeamId(): number;
19
19
  getBaseUrl(): string;
20
20
  getApiKey(): string;
21
- getLlmGatewayUrl(): Promise<string>;
21
+ getLlmGatewayUrl(): string;
22
22
  fetchTask(taskId: string): Promise<Task>;
23
23
  listTasks(filters?: {
24
24
  repository?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAkB,gBAAgB,EAAE,eAAe,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;AASvI,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,OAAO,CAAuB;gBAE1B,MAAM,EAAE,gBAAgB;IAIpC,OAAO,KAAK,OAAO,GAKlB;IAED,OAAO,KAAK,OAAO,GAKlB;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EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IAmC1E;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAkC3B"}
@@ -38,18 +38,8 @@ class PostHogAPIClient {
38
38
  }
39
39
  return response.json();
40
40
  }
41
- async getTeamId() {
42
- if (this._teamId !== null) {
43
- return this._teamId;
44
- }
45
- // Fetch user info to get team ID (following Array's pattern)
46
- const userResponse = await this.apiRequest('/api/users/@me/');
47
- if (!userResponse.team?.id) {
48
- throw new Error('No team found for user');
49
- }
50
- const teamId = Number(userResponse.team.id);
51
- this._teamId = teamId;
52
- return teamId;
41
+ getTeamId() {
42
+ return this.config.projectId;
53
43
  }
54
44
  getBaseUrl() {
55
45
  return this.baseUrl;
@@ -57,16 +47,16 @@ class PostHogAPIClient {
57
47
  getApiKey() {
58
48
  return this.config.apiKey;
59
49
  }
60
- async getLlmGatewayUrl() {
61
- const teamId = await this.getTeamId();
50
+ getLlmGatewayUrl() {
51
+ const teamId = this.getTeamId();
62
52
  return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;
63
53
  }
64
54
  async fetchTask(taskId) {
65
- const teamId = await this.getTeamId();
55
+ const teamId = this.getTeamId();
66
56
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/`);
67
57
  }
68
58
  async listTasks(filters) {
69
- const teamId = await this.getTeamId();
59
+ const teamId = this.getTeamId();
70
60
  const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);
71
61
  if (filters) {
72
62
  Object.entries(filters).forEach(([key, value]) => {
@@ -78,7 +68,7 @@ class PostHogAPIClient {
78
68
  return response.results || [];
79
69
  }
80
70
  async updateTask(taskId, updates) {
81
- const teamId = await this.getTeamId();
71
+ const teamId = this.getTeamId();
82
72
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/`, {
83
73
  method: 'PATCH',
84
74
  body: JSON.stringify(updates),
@@ -86,37 +76,37 @@ class PostHogAPIClient {
86
76
  }
87
77
  // TaskRun methods
88
78
  async listTaskRuns(taskId) {
89
- const teamId = await this.getTeamId();
79
+ const teamId = this.getTeamId();
90
80
  const response = await this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/`);
91
81
  return response.results || [];
92
82
  }
93
83
  async getTaskRun(taskId, runId) {
94
- const teamId = await this.getTeamId();
84
+ const teamId = this.getTeamId();
95
85
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);
96
86
  }
97
87
  async createTaskRun(taskId, payload) {
98
- const teamId = await this.getTeamId();
88
+ const teamId = this.getTeamId();
99
89
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {
100
90
  method: "POST",
101
91
  body: JSON.stringify(payload || {}),
102
92
  });
103
93
  }
104
94
  async updateTaskRun(taskId, runId, payload) {
105
- const teamId = await this.getTeamId();
95
+ const teamId = this.getTeamId();
106
96
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {
107
97
  method: "PATCH",
108
98
  body: JSON.stringify(payload),
109
99
  });
110
100
  }
111
101
  async setTaskRunOutput(taskId, runId, output) {
112
- const teamId = await this.getTeamId();
102
+ const teamId = this.getTeamId();
113
103
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
114
104
  method: 'PATCH',
115
105
  body: JSON.stringify({ output }),
116
106
  });
117
107
  }
118
108
  async appendTaskRunLog(taskId, runId, entries) {
119
- const teamId = await this.getTeamId();
109
+ const teamId = this.getTeamId();
120
110
  return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {
121
111
  method: 'POST',
122
112
  body: JSON.stringify({ entries }),
@@ -126,7 +116,7 @@ class PostHogAPIClient {
126
116
  * Fetch error details from PostHog error tracking
127
117
  */
128
118
  async fetchErrorDetails(errorId, projectId) {
129
- const teamId = projectId ? parseInt(projectId) : await this.getTeamId();
119
+ const teamId = projectId ? parseInt(projectId) : this.getTeamId();
130
120
  try {
131
121
  const errorData = await this.apiRequest(`/api/projects/${teamId}/error_tracking/${errorId}/`);
132
122
  // Format error details for agent consumption
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type { Task, TaskRun, LogEntry, SupportingFile, PostHogAPIConfig, PostHogResource, ResourceType, UrlMention } from './types.js';\n\ninterface PostHogApiResponse<T> {\n results?: T[];\n count?: number;\n next?: string | null;\n previous?: string | null;\n}\n\nexport interface TaskRunUpdate {\n status?: TaskRun[\"status\"];\n branch?: string | null;\n current_stage?: string | null;\n log?: LogEntry[];\n error_message?: string | null;\n output?: Record<string, unknown> | null;\n state?: Record<string, unknown>;\n}\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n private _teamId: number | null = null;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\") \n ? this.config.apiUrl.slice(0, -1) \n : this.config.apiUrl;\n return host;\n }\n\n private get headers(): Record<string, string> {\n return {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n private async apiRequest<T>(\n endpoint: string, \n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n \n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.headers,\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n async getTeamId(): Promise<number> {\n if (this._teamId !== null) {\n return this._teamId;\n }\n\n // Fetch user info to get team ID (following Array's pattern)\n const userResponse = await this.apiRequest<any>('/api/users/@me/');\n\n if (!userResponse.team?.id) {\n throw new Error('No team found for user');\n }\n\n const teamId = Number(userResponse.team.id);\n this._teamId = teamId;\n return teamId;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.config.apiKey;\n }\n\n async getLlmGatewayUrl(): Promise<string> {\n const teamId = await this.getTeamId();\n return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;\n }\n\n async fetchTask(taskId: string): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n }): Promise<Task[]> {\n const teamId = await this.getTeamId();\n const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);\n \n if (filters) {\n Object.entries(filters).forEach(([key, value]) => {\n if (value) url.searchParams.append(key, value);\n });\n }\n\n const response = await this.apiRequest<PostHogApiResponse<Task>>(\n url.pathname + url.search\n );\n \n return response.results || [];\n }\n\n async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // TaskRun methods\n async listTaskRuns(taskId: string): Promise<TaskRun[]> {\n const teamId = await this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<TaskRun>>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/`\n );\n return response.results || [];\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);\n }\n\n async createTaskRun(\n taskId: string,\n payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {\n method: \"POST\",\n body: JSON.stringify(payload || {}),\n });\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n });\n }\n\n async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {\n method: 'PATCH',\n body: JSON.stringify({ output }),\n });\n }\n\n async appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {\n method: 'POST',\n body: JSON.stringify({ entries }),\n });\n }\n\n /**\n * Fetch error details from PostHog error tracking\n */\n async fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource> {\n const teamId = projectId ? parseInt(projectId) : await this.getTeamId();\n \n try {\n const errorData = await this.apiRequest<any>(`/api/projects/${teamId}/error_tracking/${errorId}/`);\n \n // Format error details for agent consumption\n const content = this.formatErrorContent(errorData);\n \n return {\n type: 'error',\n id: errorId,\n url: `${this.baseUrl}/project/${teamId}/error_tracking/${errorId}`,\n title: errorData.exception_type || 'Unknown Error',\n content,\n metadata: {\n exception_type: errorData.exception_type,\n first_seen: errorData.first_seen,\n last_seen: errorData.last_seen,\n volume: errorData.volume,\n users_affected: errorData.users_affected,\n },\n };\n } catch (error) {\n throw new Error(`Failed to fetch error details for ${errorId}: ${error}`);\n }\n }\n\n /**\n * Generic resource fetcher by URL or ID\n */\n async fetchResourceByUrl(urlMention: UrlMention): Promise<PostHogResource> {\n switch (urlMention.type) {\n case 'error':\n if (!urlMention.id) {\n throw new Error('Error ID is required for error resources');\n }\n // Extract project ID from URL if available, otherwise use default team\n let projectId: string | undefined;\n if (urlMention.url) {\n const projectIdMatch = urlMention.url.match(/\\/project\\/(\\d+)\\//);\n projectId = projectIdMatch ? projectIdMatch[1] : undefined;\n }\n return this.fetchErrorDetails(urlMention.id, projectId);\n \n case 'experiment':\n case 'insight':\n case 'feature_flag':\n throw new Error(`Resource type '${urlMention.type}' not yet implemented`);\n \n case 'generic':\n // Return a minimal resource for generic URLs\n return {\n type: 'generic',\n id: '',\n url: urlMention.url,\n title: 'Generic Resource',\n content: `Generic resource: ${urlMention.url}`,\n metadata: {},\n };\n \n default:\n throw new Error(`Unknown resource type: ${urlMention.type}`);\n }\n }\n\n /**\n * Format error data for agent consumption\n */\n private formatErrorContent(errorData: any): string {\n const sections = [];\n \n if (errorData.exception_type) {\n sections.push(`**Error Type**: ${errorData.exception_type}`);\n }\n \n if (errorData.exception_message) {\n sections.push(`**Message**: ${errorData.exception_message}`);\n }\n \n if (errorData.stack_trace) {\n sections.push(`**Stack Trace**:\\n\\`\\`\\`\\n${errorData.stack_trace}\\n\\`\\`\\``);\n }\n \n if (errorData.volume) {\n sections.push(`**Volume**: ${errorData.volume} occurrences`);\n }\n \n if (errorData.users_affected) {\n sections.push(`**Users Affected**: ${errorData.users_affected}`);\n }\n \n if (errorData.first_seen && errorData.last_seen) {\n sections.push(`**First Seen**: ${errorData.first_seen}`);\n sections.push(`**Last Seen**: ${errorData.last_seen}`);\n }\n \n if (errorData.properties && Object.keys(errorData.properties).length > 0) {\n sections.push(`**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`);\n }\n \n return sections.join('\\n\\n');\n }\n}\n"],"names":[],"mappings":"MAmBa,gBAAgB,CAAA;AACnB,IAAA,MAAM;IACN,OAAO,GAAkB,IAAI;AAErC,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;AAC1C,cAAE,IAAI,CAAC,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ourcesContent":["import type { Task, TaskRun, LogEntry, SupportingFile, PostHogAPIConfig, PostHogResource, ResourceType, UrlMention } from './types.js';\n\ninterface PostHogApiResponse<T> {\n results?: T[];\n count?: number;\n next?: string | null;\n previous?: string | null;\n}\n\nexport interface TaskRunUpdate {\n status?: TaskRun[\"status\"];\n branch?: string | null;\n current_stage?: string | null;\n log?: LogEntry[];\n error_message?: string | null;\n output?: Record<string, unknown> | null;\n state?: Record<string, unknown>;\n}\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n private _teamId: number | null = null;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\") \n ? this.config.apiUrl.slice(0, -1) \n : this.config.apiUrl;\n return host;\n }\n\n private get headers(): Record<string, string> {\n return {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n private async apiRequest<T>(\n endpoint: string, \n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n \n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.headers,\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n getTeamId(): number {\n return this.config.projectId;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.config.apiKey;\n }\n\n getLlmGatewayUrl(): string {\n const teamId = this.getTeamId();\n return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;\n }\n\n async fetchTask(taskId: string): Promise<Task> {\n const teamId = this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n }): Promise<Task[]> {\n const teamId = this.getTeamId();\n const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);\n \n if (filters) {\n Object.entries(filters).forEach(([key, value]) => {\n if (value) url.searchParams.append(key, value);\n });\n }\n\n const response = await this.apiRequest<PostHogApiResponse<Task>>(\n url.pathname + url.search\n );\n \n return response.results || [];\n }\n\n async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {\n const teamId = this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // TaskRun methods\n async listTaskRuns(taskId: string): Promise<TaskRun[]> {\n const teamId = this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<TaskRun>>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/`\n );\n return response.results || [];\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);\n }\n\n async createTaskRun(\n taskId: string,\n payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {\n method: \"POST\",\n body: JSON.stringify(payload || {}),\n });\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n });\n }\n\n async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {\n method: 'PATCH',\n body: JSON.stringify({ output }),\n });\n }\n\n async appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {\n method: 'POST',\n body: JSON.stringify({ entries }),\n });\n }\n\n /**\n * Fetch error details from PostHog error tracking\n */\n async fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource> {\n const teamId = projectId ? parseInt(projectId) : this.getTeamId();\n \n try {\n const errorData = await this.apiRequest<any>(`/api/projects/${teamId}/error_tracking/${errorId}/`);\n \n // Format error details for agent consumption\n const content = this.formatErrorContent(errorData);\n \n return {\n type: 'error',\n id: errorId,\n url: `${this.baseUrl}/project/${teamId}/error_tracking/${errorId}`,\n title: errorData.exception_type || 'Unknown Error',\n content,\n metadata: {\n exception_type: errorData.exception_type,\n first_seen: errorData.first_seen,\n last_seen: errorData.last_seen,\n volume: errorData.volume,\n users_affected: errorData.users_affected,\n },\n };\n } catch (error) {\n throw new Error(`Failed to fetch error details for ${errorId}: ${error}`);\n }\n }\n\n /**\n * Generic resource fetcher by URL or ID\n */\n async fetchResourceByUrl(urlMention: UrlMention): Promise<PostHogResource> {\n switch (urlMention.type) {\n case 'error':\n if (!urlMention.id) {\n throw new Error('Error ID is required for error resources');\n }\n // Extract project ID from URL if available, otherwise use default team\n let projectId: string | undefined;\n if (urlMention.url) {\n const projectIdMatch = urlMention.url.match(/\\/project\\/(\\d+)\\//);\n projectId = projectIdMatch ? projectIdMatch[1] : undefined;\n }\n return this.fetchErrorDetails(urlMention.id, projectId);\n \n case 'experiment':\n case 'insight':\n case 'feature_flag':\n throw new Error(`Resource type '${urlMention.type}' not yet implemented`);\n \n case 'generic':\n // Return a minimal resource for generic URLs\n return {\n type: 'generic',\n id: '',\n url: urlMention.url,\n title: 'Generic Resource',\n content: `Generic resource: ${urlMention.url}`,\n metadata: {},\n };\n \n default:\n throw new Error(`Unknown resource type: ${urlMention.type}`);\n }\n }\n\n /**\n * Format error data for agent consumption\n */\n private formatErrorContent(errorData: any): string {\n const sections = [];\n \n if (errorData.exception_type) {\n sections.push(`**Error Type**: ${errorData.exception_type}`);\n }\n \n if (errorData.exception_message) {\n sections.push(`**Message**: ${errorData.exception_message}`);\n }\n \n if (errorData.stack_trace) {\n sections.push(`**Stack Trace**:\\n\\`\\`\\`\\n${errorData.stack_trace}\\n\\`\\`\\``);\n }\n \n if (errorData.volume) {\n sections.push(`**Volume**: ${errorData.volume} occurrences`);\n }\n \n if (errorData.users_affected) {\n sections.push(`**Users Affected**: ${errorData.users_affected}`);\n }\n \n if (errorData.first_seen && errorData.last_seen) {\n sections.push(`**First Seen**: ${errorData.first_seen}`);\n sections.push(`**Last Seen**: ${errorData.last_seen}`);\n }\n \n if (errorData.properties && Object.keys(errorData.properties).length > 0) {\n sections.push(`**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`);\n }\n \n return sections.join('\\n\\n');\n }\n}\n"],"names":[],"mappings":"MAmBa,gBAAgB,CAAA;AACnB,IAAA,MAAM;IACN,OAAO,GAAkB,IAAI;AAErC,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;AAC1C,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE;AAChC,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM;AACtB,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,OAAO;AACL,YAAA,eAAe,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,CAAE;AAC/C,YAAA,cAAc,EAAE,kBAAkB;SACnC;IACH;AAEQ,IAAA,MAAM,UAAU,C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C,IAAI,CAAC,CAAA,eAAA,EAAkB,SAAS,CAAC,SAAS,CAAA,CAAE,CAAC;QACxD;AAEA,QAAA,IAAI,SAAS,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;AACxE,YAAA,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,CAAE,CAAC;QACnF;AAEA,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B;AACD;;;;"}
@@ -14,7 +14,7 @@ export interface StructuredExtractor {
14
14
  }
15
15
  export type StructuredExtractorConfig = {
16
16
  apiKey: string;
17
- baseURL: string;
17
+ gatewayUrl: string;
18
18
  modelName?: string;
19
19
  logger?: Logger;
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"structured-extraction.d.ts","sourceRoot":"","sources":["../../src/structured-extraction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAwBD,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxE,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC;CAC9F;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,M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AAM,EAAE,yBAAyB;IAmBvC,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAqBvE,2BAA2B,CAC/B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,2BAA2B,EAAE,CAAC;CAoB1C"}
@@ -29,12 +29,12 @@ class AISDKExtractor {
29
29
  }
30
30
  this.model = getAnthropicModel({
31
31
  apiKey: config.apiKey,
32
- baseURL: config.baseURL,
32
+ gatewayUrl: config.gatewayUrl,
33
33
  modelName: config.modelName || 'claude-haiku-4-5',
34
34
  });
35
35
  this.logger.debug('Using PostHog LLM gateway for structured extraction', {
36
36
  modelName: config.modelName || 'claude-haiku-4-5',
37
- baseURL: config.baseURL
37
+ gatewayUrl: config.gatewayUrl
38
38
  });
39
39
  }
40
40
  async extractQuestions(researchContent) {
@@ -1 +1 @@
1
- {"version":3,"file":"structured-extraction.js","sources":["../../src/structured-extraction.ts"],"sourcesContent":["import { generateObject } from 'ai';\nimport { z } from 'zod';\nimport { Logger } from './utils/logger.js';\nimport { getAnthropicModel } from './utils/ai-sdk.js';\n\nexport interface ExtractedQuestion {\n id: string;\n question: string;\n options: string[];\n}\n\nexport interface ExtractedQuestionWithAnswer extends ExtractedQuestion {\n recommendedAnswer: string;\n justification: string;\n}\n\nconst questionsOnlySchema = z.object({\n questions: z.array(\n z.object({\n id: z.string(),\n question: z.string(),\n options: z.array(z.string()),\n })\n ),\n});\n\nconst questionsWithAnswersSchema = z.object({\n questions: z.array(\n z.object({\n id: z.string(),\n question: z.string(),\n options: z.array(z.string()),\n recommendedAnswer: z.string().describe('The letter of the recommended option (e.g., \"a\", \"b\", \"c\")'),\n justification: z.string().describe('Brief explanation for the recommended answer'),\n })\n ),\n});\n\nexport interface StructuredExtractor {\n extractQuestions(researchContent: string): Promise<ExtractedQuestion[]>;\n extractQuestionsWithAnswers(researchContent: string): Promise<ExtractedQuestionWithAnswer[]>;\n}\n\nexport type StructuredExtractorConfig = {\n apiKey: string;\n baseURL: string;\n modelName?: string;\n logger?: Logger;\n}\n\nexport class AISDKExtractor implements StructuredExtractor {\n private logger: Logger;\n private model: any;\n\n constructor(config: StructuredExtractorConfig) {\n this.logger = config.logger || new Logger({ debug: false, prefix: '[AISDKExtractor]' });\n\n if (!config.apiKey) {\n throw new Error('Missing API key for structured extraction. Ensure the LLM gateway is configured.');\n }\n\n this.model = getAnthropicModel({\n apiKey: config.apiKey,\n baseURL: config.baseURL,\n modelName: config.modelName || 'claude-haiku-4-5',\n });\n\n this.logger.debug('Using PostHog LLM gateway for structured extraction', {\n modelName: config.modelName || 'claude-haiku-4-5',\n baseURL: config.baseURL\n });\n }\n\n async extractQuestions(researchContent: string): Promise<ExtractedQuestion[]> {\n this.logger.debug('Extracting questions from research content', {\n contentLength: researchContent.length,\n });\n\n const { object } = await generateObject({\n model: this.model,\n schema: questionsOnlySchema,\n schemaName: 'ResearchQuestions',\n schemaDescription: 'Research questions extracted from markdown content',\n system: 'Extract the research questions from the provided markdown. Return a JSON object matching the schema.',\n prompt: researchContent,\n });\n\n this.logger.info('Successfully extracted questions', {\n questionCount: object.questions.length,\n });\n\n return object.questions;\n }\n\n async extractQuestionsWithAnswers(\n researchContent: string,\n ): Promise<ExtractedQuestionWithAnswer[]> {\n this.logger.debug('Extracting questions with recommended answers', {\n contentLength: researchContent.length,\n });\n\n const { object } = await generateObject({\n model: this.model,\n schema: questionsWithAnswersSchema,\n schemaName: 'ResearchQuestionsWithAnswers',\n schemaDescription: 'Research questions with recommended answers extracted from markdown',\n system: 'Extract the research questions from the markdown and provide recommended answers based on the analysis. For each question, include a recommendedAnswer (the letter: a, b, c, etc.) and a brief justification. Return a JSON object matching the schema.',\n prompt: researchContent,\n });\n\n this.logger.info('Successfully extracted questions with answers', {\n questionCount: object.questions.length,\n });\n\n return object.questions;\n }\n}\n"],"names":[],"mappings":";;;;;AAgBA,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,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eAAe;AACxB,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE;AAChE,YAAA,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM;AACvC,SAAA,CAAC;QAEF,OAAO,MAAM,CAAC,SAAS;IACzB;AACD;;;;"}
1
+ {"version":3,"file":"structured-extraction.js","sources":["../../src/structured-extraction.ts"],"sourcesContent":["import { generateObject } from 'ai';\nimport { z } from 'zod';\nimport { Logger } from './utils/logger.js';\nimport { getAnthropicModel } from './utils/ai-sdk.js';\n\nexport interface ExtractedQuestion {\n id: string;\n question: string;\n options: string[];\n}\n\nexport interface ExtractedQuestionWithAnswer extends ExtractedQuestion {\n recommendedAnswer: string;\n justification: string;\n}\n\nconst questionsOnlySchema = z.object({\n questions: z.array(\n z.object({\n id: z.string(),\n question: z.string(),\n options: z.array(z.string()),\n })\n ),\n});\n\nconst questionsWithAnswersSchema = z.object({\n questions: z.array(\n z.object({\n id: z.string(),\n question: z.string(),\n options: z.array(z.string()),\n recommendedAnswer: z.string().describe('The letter of the recommended option (e.g., \"a\", \"b\", \"c\")'),\n justification: z.string().describe('Brief explanation for the recommended answer'),\n })\n ),\n});\n\nexport interface StructuredExtractor {\n extractQuestions(researchContent: string): Promise<ExtractedQuestion[]>;\n extractQuestionsWithAnswers(researchContent: string): Promise<ExtractedQuestionWithAnswer[]>;\n}\n\nexport type StructuredExtractorConfig = {\n apiKey: string;\n gatewayUrl: string;\n modelName?: string;\n logger?: Logger;\n}\n\nexport class AISDKExtractor implements StructuredExtractor {\n private logger: Logger;\n private model: any;\n\n constructor(config: StructuredExtractorConfig) {\n this.logger = config.logger || new Logger({ debug: false, prefix: '[AISDKExtractor]' });\n\n if (!config.apiKey) {\n throw new Error('Missing API key for structured extraction. Ensure the LLM gateway is configured.');\n }\n\n this.model = getAnthropicModel({\n apiKey: config.apiKey,\n gatewayUrl: config.gatewayUrl,\n modelName: config.modelName || 'claude-haiku-4-5',\n });\n\n this.logger.debug('Using PostHog LLM gateway for structured extraction', {\n modelName: config.modelName || 'claude-haiku-4-5',\n gatewayUrl: config.gatewayUrl\n });\n }\n\n async extractQuestions(researchContent: string): Promise<ExtractedQuestion[]> {\n this.logger.debug('Extracting questions from research content', {\n contentLength: researchContent.length,\n });\n\n const { object } = await generateObject({\n model: this.model,\n schema: questionsOnlySchema,\n schemaName: 'ResearchQuestions',\n schemaDescription: 'Research questions extracted from markdown content',\n system: 'Extract the research questions from the provided markdown. Return a JSON object matching the schema.',\n prompt: researchContent,\n });\n\n this.logger.info('Successfully extracted questions', {\n questionCount: object.questions.length,\n });\n\n return object.questions;\n }\n\n async extractQuestionsWithAnswers(\n researchContent: string,\n ): Promise<ExtractedQuestionWithAnswer[]> {\n this.logger.debug('Extracting questions with recommended answers', {\n contentLength: researchContent.length,\n });\n\n const { object } = await generateObject({\n model: this.model,\n schema: questionsWithAnswersSchema,\n schemaName: 'ResearchQuestionsWithAnswers',\n schemaDescription: 'Research questions with recommended answers extracted from markdown',\n system: 'Extract the research questions from the markdown and provide recommended answers based on the analysis. For each question, include a recommendedAnswer (the letter: a, b, c, etc.) and a brief justification. Return a JSON object matching the schema.',\n prompt: researchContent,\n });\n\n this.logger.info('Successfully extracted questions with answers', {\n questionCount: object.questions.length,\n });\n\n return object.questions;\n }\n}\n"],"names":[],"mappings":";;;;;AAgBA,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,CAAC,CAAC,KAAK,CAChB,CAAC,CAAC,MAAM,CAAC;AACP,QAAA,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;AACd,QAAA,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AAC7B,KAAA,CAAC,CACH;AACF,CAAA,CAAC;AAEF,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,S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posthogProjectId: number;
237
238
  posthogMcpUrl?: string;
238
239
  mcpServers?: Record<string, McpServerConfig>;
239
240
  debug?: boolean;
@@ -242,6 +243,7 @@ export interface AgentConfig {
242
243
  export interface PostHogAPIConfig {
243
244
  apiUrl: string;
244
245
  apiKey: string;
246
+ projectId: number;
245
247
  }
246
248
  export type ResourceType = 'error' | 'experiment' | 'insight' | 'feature_flag' | 'generic';
247
249
  export interface PostHogResource {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC/F,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;AAG7C,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,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IAInB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAGD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,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OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["\n// import and export to keep a single type file\nimport type { CanUseTool, PermissionResult } from '@anthropic-ai/claude-agent-sdk/sdkTypes.js';\nexport type { CanUseTool, PermissionResult };\n\n// 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 github_integration?: number | null;\n repository_config?: unknown; // JSONField\n repository_list: string;\n primary_repository: string;\n created_at: string;\n updated_at: string;\n\n // DEPRECATED: These fields have been moved to TaskRun\n // Use task.latest_run instead\n current_stage?: string | null;\n github_branch?: string | null;\n github_pr_url?: string | null;\n latest_run?: TaskRun;\n}\n\n// Log entry structure for TaskRun.log\nexport interface LogEntry {\n type: string; // e.g., \"info\", \"warning\", \"error\", \"success\", \"debug\"\n message: string;\n [key: string]: unknown; // Allow additional fields\n}\n\n// TaskRun model - represents individual execution runs of tasks\nexport interface TaskRun {\n id: string;\n task: string; // Task ID\n team: number;\n branch: string | null;\n status: 'started' | 'in_progress' | 'completed' | 'failed';\n log: LogEntry[]; // Array of log entry objects\n error_message: string | null;\n output: Record<string, unknown> | null; // Structured output (PR URL, commit SHA, etc.)\n state: Record<string, unknown>; // Intermediate run state (defaults to {}, never null)\n created_at: string;\n updated_at: string;\n completed_at: string | null;\n}\n\nexport interface SupportingFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output';\n created_at: string;\n}\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\nexport interface TaskExecutionOptions {\n repositoryPath?: string;\n permissionMode?: PermissionMode;\n isCloudMode?: boolean; // Determines local vs cloud behavior (local pauses after each phase)\n createPR?: boolean; // Whether to create PR after build (defaults to false if local. This setting has no effect if isCloudMode is true.)\n autoProgress?: boolean;\n queryOverrides?: Record<string, any>;\n // Fine-grained permission control (only applied to build phase)\n // See: https://docs.claude.com/en/api/agent-sdk/permissions\n canUseTool?: CanUseTool;\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 parentToolUseId?: string | null; // For nested tool calls (subagents)\n // Tool metadata (enriched by adapter for UI consumption)\n tool?: import('./tools/types.js').Tool;\n category?: import('./tools/types.js').ToolCategory;\n}\n\nexport interface ToolResultEvent extends BaseEvent {\n type: 'tool_result';\n toolName: string;\n callId: string;\n result: any;\n isError?: boolean; // Whether the tool execution failed\n parentToolUseId?: string | null; // For nested tool calls (subagents)\n // Tool metadata (enriched by adapter for UI consumption)\n tool?: import('./tools/types.js').Tool;\n category?: import('./tools/types.js').ToolCategory;\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 // Common optional fields (varies by phase):\n kind?: string; // Kind of status (plan, implementation)\n branch?: string; // Git branch name\n prUrl?: string; // Pull request URL\n taskId?: string; // Task identifier\n messageId?: string; // Claude message ID\n model?: string; // Model name\n [key: string]: any; // Allow additional fields\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 agents?: string[];\n slashCommands?: string[];\n outputStyle?: string;\n mcpServers?: Array<{ name: string; status: 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 result?: string; // Final summary text from Claude\n durationMs?: number;\n durationApiMs?: number; // API-only duration (excluding local processing)\n numTurns?: number;\n totalCostUsd?: number;\n usage?: any;\n modelUsage?: { // Per-model usage breakdown\n [modelName: string]: {\n inputTokens: number;\n outputTokens: number;\n cacheReadInputTokens: number;\n cacheCreationInputTokens: number;\n webSearchRequests: number;\n costUSD: number;\n contextWindow: number;\n };\n };\n permissionDenials?: Array<{ // Tools that were denied by permissions\n tool_name: string;\n tool_use_id: string;\n tool_input: Record<string, unknown>;\n }>;\n}\n\nexport interface ErrorEvent extends BaseEvent {\n type: 'error';\n message: string;\n error?: any;\n errorType?: string;\n context?: Record<string, any>; // Partial error context for debugging\n sdkError?: any; // Original SDK error object\n}\n\n// Metric and artifact events (general purpose, not tool-specific)\nexport interface MetricEvent extends BaseEvent {\n type: 'metric';\n key: string;\n value: number;\n unit?: string;\n}\n\nexport interface ArtifactEvent extends BaseEvent {\n type: 'artifact';\n kind: string;\n content: any;\n}\n\nexport interface RawSDKEvent extends BaseEvent {\n type: 'raw_sdk_event';\n sdkMessage: any; // Full SDK message for debugging\n}\n\nexport type AgentEvent =\n | TokenEvent\n | ContentBlockStartEvent\n | ContentBlockStopEvent\n | ToolCallEvent\n | ToolResultEvent\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | UserMessageEvent\n | StatusEvent\n | InitEvent\n | CompactBoundaryEvent\n | DoneEvent\n | ErrorEvent\n | MetricEvent\n | ArtifactEvent\n | RawSDKEvent;\n\nexport interface ExecutionResult {\n results: any[];\n}\n\nexport interface PlanResult {\n plan: string;\n}\n\nexport interface TaskExecutionResult {\n task: Task;\n plan?: string;\n executionResult?: ExecutionResult;\n}\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 // Fine-grained permission control for direct run() calls\n // See: https://docs.claude.com/en/api/agent-sdk/permissions\n canUseTool?: CanUseTool;\n}\n\nexport interface PostHogAPIConfig {\n apiUrl: string;\n apiKey: string;\n}\n\n// URL mention types\nexport type ResourceType = 'error' | 'experiment' | 'insight' | 'feature_flag' | 'generic';\n\nexport interface PostHogResource {\n type: ResourceType;\n id: string;\n url: string;\n title?: string;\n content: string;\n metadata?: Record<string, any>;\n}\n\nexport interface UrlMention {\n url: string;\n type: ResourceType;\n id?: string;\n label?: string;\n}"],"names":[],"mappings":"IAyDY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,aAA4B;AAC5B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,mBAA4B;AAC9B,CAAC,EALW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["\n// import and export to keep a single type file\nimport type { CanUseTool, PermissionResult } from '@anthropic-ai/claude-agent-sdk/sdkTypes.js';\nexport type { CanUseTool, PermissionResult };\n\n// 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 github_integration?: number | null;\n repository_config?: unknown; // JSONField\n repository_list: string;\n primary_repository: string;\n created_at: string;\n updated_at: string;\n\n // DEPRECATED: These fields have been moved to TaskRun\n // Use task.latest_run instead\n current_stage?: string | null;\n github_branch?: string | null;\n github_pr_url?: string | null;\n latest_run?: TaskRun;\n}\n\n// Log entry structure for TaskRun.log\nexport interface LogEntry {\n type: string; // e.g., \"info\", \"warning\", \"error\", \"success\", \"debug\"\n message: string;\n [key: string]: unknown; // Allow additional fields\n}\n\n// TaskRun model - represents individual execution runs of tasks\nexport interface TaskRun {\n id: string;\n task: string; // Task ID\n team: number;\n branch: string | null;\n status: 'started' | 'in_progress' | 'completed' | 'failed';\n log: LogEntry[]; // Array of log entry objects\n error_message: string | null;\n output: Record<string, unknown> | null; // Structured output (PR URL, commit SHA, etc.)\n state: Record<string, unknown>; // Intermediate run state (defaults to {}, never null)\n created_at: string;\n updated_at: string;\n completed_at: string | null;\n}\n\nexport interface SupportingFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output';\n created_at: string;\n}\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\nexport interface TaskExecutionOptions {\n repositoryPath?: string;\n permissionMode?: PermissionMode;\n isCloudMode?: boolean; // Determines local vs cloud behavior (local pauses after each phase)\n createPR?: boolean; // Whether to create PR after build (defaults to false if local. This setting has no effect if isCloudMode is true.)\n autoProgress?: boolean;\n queryOverrides?: Record<string, any>;\n // Fine-grained permission control (only applied to build phase)\n // See: https://docs.claude.com/en/api/agent-sdk/permissions\n canUseTool?: CanUseTool;\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 parentToolUseId?: string | null; // For nested tool calls (subagents)\n // Tool metadata (enriched by adapter for UI consumption)\n tool?: import('./tools/types.js').Tool;\n category?: import('./tools/types.js').ToolCategory;\n}\n\nexport interface ToolResultEvent extends BaseEvent {\n type: 'tool_result';\n toolName: string;\n callId: string;\n result: any;\n isError?: boolean; // Whether the tool execution failed\n parentToolUseId?: string | null; // For nested tool calls (subagents)\n // Tool metadata (enriched by adapter for UI consumption)\n tool?: import('./tools/types.js').Tool;\n category?: import('./tools/types.js').ToolCategory;\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 // Common optional fields (varies by phase):\n kind?: string; // Kind of status (plan, implementation)\n branch?: string; // Git branch name\n prUrl?: string; // Pull request URL\n taskId?: string; // Task identifier\n messageId?: string; // Claude message ID\n model?: string; // Model name\n [key: string]: any; // Allow additional fields\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 agents?: string[];\n slashCommands?: string[];\n outputStyle?: string;\n mcpServers?: Array<{ name: string; status: 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 result?: string; // Final summary text from Claude\n durationMs?: number;\n durationApiMs?: number; // API-only duration (excluding local processing)\n numTurns?: number;\n totalCostUsd?: number;\n usage?: any;\n modelUsage?: { // Per-model usage breakdown\n [modelName: string]: {\n inputTokens: number;\n outputTokens: number;\n cacheReadInputTokens: number;\n cacheCreationInputTokens: number;\n webSearchRequests: number;\n costUSD: number;\n contextWindow: number;\n };\n };\n permissionDenials?: Array<{ // Tools that were denied by permissions\n tool_name: string;\n tool_use_id: string;\n tool_input: Record<string, unknown>;\n }>;\n}\n\nexport interface ErrorEvent extends BaseEvent {\n type: 'error';\n message: string;\n error?: any;\n errorType?: string;\n context?: Record<string, any>; // Partial error context for debugging\n sdkError?: any; // Original SDK error object\n}\n\n// Metric and artifact events (general purpose, not tool-specific)\nexport interface MetricEvent extends BaseEvent {\n type: 'metric';\n key: string;\n value: number;\n unit?: string;\n}\n\nexport interface ArtifactEvent extends BaseEvent {\n type: 'artifact';\n kind: string;\n content: any;\n}\n\nexport interface RawSDKEvent extends BaseEvent {\n type: 'raw_sdk_event';\n sdkMessage: any; // Full SDK message for debugging\n}\n\nexport type AgentEvent =\n | TokenEvent\n | ContentBlockStartEvent\n | ContentBlockStopEvent\n | ToolCallEvent\n | ToolResultEvent\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | UserMessageEvent\n | StatusEvent\n | InitEvent\n | CompactBoundaryEvent\n | DoneEvent\n | ErrorEvent\n | MetricEvent\n | ArtifactEvent\n | RawSDKEvent;\n\nexport interface ExecutionResult {\n results: any[];\n}\n\nexport interface PlanResult {\n plan: string;\n}\n\nexport interface TaskExecutionResult {\n task: Task;\n plan?: string;\n executionResult?: ExecutionResult;\n}\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 posthogProjectId: number;\n\n // PostHog MCP configuration\n posthogMcpUrl?: string;\n\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 // Fine-grained permission control for direct run() calls\n // See: https://docs.claude.com/en/api/agent-sdk/permissions\n canUseTool?: CanUseTool;\n}\n\nexport interface PostHogAPIConfig {\n apiUrl: string;\n apiKey: string;\n projectId: number;\n}\n\n// URL mention types\nexport type ResourceType = 'error' | 'experiment' | 'insight' | 'feature_flag' | 'generic';\n\nexport interface PostHogResource {\n type: ResourceType;\n id: string;\n url: string;\n title?: string;\n content: string;\n metadata?: Record<string, any>;\n}\n\nexport interface UrlMention {\n url: string;\n type: ResourceType;\n id?: string;\n label?: string;\n}"],"names":[],"mappings":"IAyDY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,aAA4B;AAC5B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,mBAA4B;AAC9B,CAAC,EALW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1,6 +1,6 @@
1
1
  export interface PostHogGatewayConfig {
2
2
  apiKey: string;
3
- baseURL: string;
3
+ gatewayUrl: string;
4
4
  modelName?: string;
5
5
  }
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../../src/utils/ai-sdk.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,gCA+B7D"}
1
+ {"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../../src/utils/ai-sdk.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,gCA+B7D"}
@@ -11,7 +11,7 @@ function getAnthropicModel(config) {
11
11
  const modelName = config.modelName || 'claude-haiku-4-5';
12
12
  // PostHog gateway expects /v1/messages, but AI SDK appends /messages
13
13
  // So we need to append /v1 to the baseURL
14
- const baseURL = config.baseURL ? `${config.baseURL}/v1` : undefined;
14
+ const baseURL = config.gatewayUrl ? `${config.gatewayUrl}/v1` : undefined;
15
15
  // Custom fetch to convert x-api-key header to Authorization Bearer
16
16
  // PostHog gateway expects Bearer token, but Anthropic SDK sends x-api-key
17
17
  const customFetch = async (url, init) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-sdk.js","sources":["../../../src/utils/ai-sdk.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\n\nexport interface PostHogGatewayConfig {\n apiKey: string;\n baseURL: string;\n modelName?: string;\n}\n\n/**\n * Creates an Anthropic model configured for PostHog LLM gateway.\n * \n * Handles two key differences between AI SDK and PostHog gateway:\n * 1. Appends /v1 to baseURL (gateway expects /v1/messages, SDK appends /messages)\n * 2. Converts x-api-key header to Authorization Bearer token\n */\nexport function getAnthropicModel(config: PostHogGatewayConfig) {\n const modelName = config.modelName || 'claude-haiku-4-5';\n \n // PostHog gateway expects /v1/messages, but AI SDK appends /messages\n // So we need to append /v1 to the baseURL\n const baseURL = config.baseURL ? `${config.baseURL}/v1` : undefined;\n\n // Custom fetch to convert x-api-key header to Authorization Bearer\n // PostHog gateway expects Bearer token, but Anthropic SDK sends x-api-key\n const customFetch = async (url: RequestInfo, init?: RequestInit): Promise<Response> => {\n const headers = new Headers(init?.headers);\n\n if (headers.has('x-api-key')) {\n headers.delete('x-api-key');\n headers.set('Authorization', `Bearer ${config.apiKey}`);\n }\n\n return fetch(url, {\n ...init,\n headers,\n });\n };\n\n const anthropic = createAnthropic({\n apiKey: config.apiKey,\n baseURL,\n //@ts-ignore\n fetch: customFetch,\n });\n\n return anthropic(modelName);\n}\n"],"names":[],"mappings":";;AAQA;;;;;;AAMG;AACG,SAAU,iBAAiB,CAAC,MAA4B,EAAA;AAC5D,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,kBAAkB;;;AAIxD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,GAAG,CAAA,EAAG,MAAM,CAAC,OAAO,CAAA,GAAA,CAAK,GAAG,SAAS;;;IAInE,MAAM,WAAW,GAAG,OAAO,GAAgB,EAAE,IAAkB,KAAuB;QACpF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AAE1C,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;AAC5B,YAAA,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA,OAAA,EAAU,MAAM,CAAC,MAAM,CAAA,CAAE,CAAC;QACzD;QAEA,OAAO,KAAK,CAAC,GAAG,EAAE;AAChB,YAAA,GAAG,IAAI;YACP,OAAO;AACR,SAAA,CAAC;AACJ,IAAA,CAAC;IAED,MAAM,SAAS,GAAG,eAAe,CAAC;QAChC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO;;AAEP,QAAA,KAAK,EAAE,WAAW;AACnB,KAAA,CAAC;AAEF,IAAA,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B;;;;"}
1
+ {"version":3,"file":"ai-sdk.js","sources":["../../../src/utils/ai-sdk.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\n\nexport interface PostHogGatewayConfig {\n apiKey: string;\n gatewayUrl: string;\n modelName?: string;\n}\n\n/**\n * Creates an Anthropic model configured for PostHog LLM gateway.\n * \n * Handles two key differences between AI SDK and PostHog gateway:\n * 1. Appends /v1 to baseURL (gateway expects /v1/messages, SDK appends /messages)\n * 2. Converts x-api-key header to Authorization Bearer token\n */\nexport function getAnthropicModel(config: PostHogGatewayConfig) {\n const modelName = config.modelName || 'claude-haiku-4-5';\n \n // PostHog gateway expects /v1/messages, but AI SDK appends /messages\n // So we need to append /v1 to the baseURL\n const baseURL = config.gatewayUrl ? `${config.gatewayUrl}/v1` : undefined;\n\n // Custom fetch to convert x-api-key header to Authorization Bearer\n // PostHog gateway expects Bearer token, but Anthropic SDK sends x-api-key\n const customFetch = async (url: RequestInfo, init?: RequestInit): Promise<Response> => {\n const headers = new Headers(init?.headers);\n\n if (headers.has('x-api-key')) {\n headers.delete('x-api-key');\n headers.set('Authorization', `Bearer ${config.apiKey}`);\n }\n\n return fetch(url, {\n ...init,\n headers,\n });\n };\n\n const anthropic = createAnthropic({\n apiKey: config.apiKey,\n baseURL,\n //@ts-ignore\n fetch: customFetch,\n });\n\n return anthropic(modelName);\n}\n"],"names":[],"mappings":";;AAQA;;;;;;AAMG;AACG,SAAU,iBAAiB,CAAC,MAA4B,EAAA;AAC5D,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,kBAAkB;;;AAIxD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,GAAG,CAAA,EAAG,MAAM,CAAC,UAAU,CAAA,GAAA,CAAK,GAAG,SAAS;;;IAIzE,MAAM,WAAW,GAAG,OAAO,GAAgB,EAAE,IAAkB,KAAuB;QACpF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AAE1C,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;AAC5B,YAAA,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA,OAAA,EAAU,MAAM,CAAC,MAAM,CAAA,CAAE,CAAC;QACzD;QAEA,OAAO,KAAK,CAAC,GAAG,EAAE;AAChB,YAAA,GAAG,IAAI;YACP,OAAO;AACR,SAAA,CAAC;AACJ,IAAA,CAAC;IAED,MAAM,SAAS,GAAG,eAAe,CAAC;QAChC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO;;AAEP,QAAA,KAAK,EAAE,WAAW;AACnB,KAAA,CAAC;AAEF,IAAA,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
package/src/agent.ts CHANGED
@@ -81,6 +81,7 @@ export class Agent {
81
81
  this.posthogAPI = new PostHogAPIClient({
82
82
  apiUrl: config.posthogApiUrl,
83
83
  apiKey: config.posthogApiKey,
84
+ projectId: config.posthogProjectId,
84
85
  });
85
86
  }
86
87
 
@@ -91,7 +92,7 @@ export class Agent {
91
92
  logger: this.logger.child('PromptBuilder')
92
93
  });
93
94
  this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);
94
- this.extractor = new AISDKExtractor({apiKey: config.posthogApiKey, baseURL: config.posthogApiUrl, logger: this.logger.child('AISDKExtractor')});
95
+ this.extractor = new AISDKExtractor({apiKey: config.posthogApiKey, gatewayUrl: this.posthogAPI?.getLlmGatewayUrl() ?? '', logger: this.logger.child('AISDKExtractor')});
95
96
  }
96
97
 
97
98
  /**
@@ -110,13 +111,8 @@ export class Agent {
110
111
  return;
111
112
  }
112
113
 
113
- if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {
114
- this.ensureOpenAIGatewayEnv();
115
- return;
116
- }
117
-
118
114
  try {
119
- const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();
115
+ const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
120
116
  const apiKey = this.posthogAPI.getApiKey();
121
117
 
122
118
  process.env.ANTHROPIC_BASE_URL = gatewayUrl;
@@ -421,12 +417,12 @@ Generated by PostHog Agent`;
421
417
  }
422
418
  }
423
419
 
424
- private ensureOpenAIGatewayEnv(baseUrl?: string, token?: string): void {
425
- const resolvedBaseUrl = baseUrl || process.env.ANTHROPIC_BASE_URL;
420
+ private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {
421
+ const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;
426
422
  const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;
427
423
 
428
- if (resolvedBaseUrl) {
429
- process.env.OPENAI_BASE_URL = resolvedBaseUrl;
424
+ if (resolvedGatewayUrl) {
425
+ process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
430
426
  }
431
427
 
432
428
  if (resolvedToken) {
@@ -434,7 +430,7 @@ Generated by PostHog Agent`;
434
430
  }
435
431
 
436
432
  if (!this.extractor) {
437
- this.extractor = new AISDKExtractor({apiKey: resolvedToken || '', baseURL: resolvedBaseUrl || '', logger: this.logger.child('AISDKExtractor')});
433
+ this.extractor = new AISDKExtractor({apiKey: resolvedToken || '', gatewayUrl: resolvedGatewayUrl || '', logger: this.logger.child('AISDKExtractor')});
438
434
  }
439
435
  }
440
436
 
@@ -67,21 +67,8 @@ export class PostHogAPIClient {
67
67
  return response.json();
68
68
  }
69
69
 
70
- async getTeamId(): Promise<number> {
71
- if (this._teamId !== null) {
72
- return this._teamId;
73
- }
74
-
75
- // Fetch user info to get team ID (following Array's pattern)
76
- const userResponse = await this.apiRequest<any>('/api/users/@me/');
77
-
78
- if (!userResponse.team?.id) {
79
- throw new Error('No team found for user');
80
- }
81
-
82
- const teamId = Number(userResponse.team.id);
83
- this._teamId = teamId;
84
- return teamId;
70
+ getTeamId(): number {
71
+ return this.config.projectId;
85
72
  }
86
73
 
87
74
  getBaseUrl(): string {
@@ -92,13 +79,13 @@ export class PostHogAPIClient {
92
79
  return this.config.apiKey;
93
80
  }
94
81
 
95
- async getLlmGatewayUrl(): Promise<string> {
96
- const teamId = await this.getTeamId();
82
+ getLlmGatewayUrl(): string {
83
+ const teamId = this.getTeamId();
97
84
  return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;
98
85
  }
99
86
 
100
87
  async fetchTask(taskId: string): Promise<Task> {
101
- const teamId = await this.getTeamId();
88
+ const teamId = this.getTeamId();
102
89
  return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);
103
90
  }
104
91
 
@@ -107,7 +94,7 @@ export class PostHogAPIClient {
107
94
  organization?: string;
108
95
  origin_product?: string;
109
96
  }): Promise<Task[]> {
110
- const teamId = await this.getTeamId();
97
+ const teamId = this.getTeamId();
111
98
  const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);
112
99
 
113
100
  if (filters) {
@@ -124,7 +111,7 @@ export class PostHogAPIClient {
124
111
  }
125
112
 
126
113
  async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {
127
- const teamId = await this.getTeamId();
114
+ const teamId = this.getTeamId();
128
115
  return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {
129
116
  method: 'PATCH',
130
117
  body: JSON.stringify(updates),
@@ -133,7 +120,7 @@ export class PostHogAPIClient {
133
120
 
134
121
  // TaskRun methods
135
122
  async listTaskRuns(taskId: string): Promise<TaskRun[]> {
136
- const teamId = await this.getTeamId();
123
+ const teamId = this.getTeamId();
137
124
  const response = await this.apiRequest<PostHogApiResponse<TaskRun>>(
138
125
  `/api/projects/${teamId}/tasks/${taskId}/runs/`
139
126
  );
@@ -141,7 +128,7 @@ export class PostHogAPIClient {
141
128
  }
142
129
 
143
130
  async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {
144
- const teamId = await this.getTeamId();
131
+ const teamId = this.getTeamId();
145
132
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);
146
133
  }
147
134
 
@@ -149,7 +136,7 @@ export class PostHogAPIClient {
149
136
  taskId: string,
150
137
  payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>
151
138
  ): Promise<TaskRun> {
152
- const teamId = await this.getTeamId();
139
+ const teamId = this.getTeamId();
153
140
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {
154
141
  method: "POST",
155
142
  body: JSON.stringify(payload || {}),
@@ -161,7 +148,7 @@ export class PostHogAPIClient {
161
148
  runId: string,
162
149
  payload: TaskRunUpdate
163
150
  ): Promise<TaskRun> {
164
- const teamId = await this.getTeamId();
151
+ const teamId = this.getTeamId();
165
152
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {
166
153
  method: "PATCH",
167
154
  body: JSON.stringify(payload),
@@ -169,7 +156,7 @@ export class PostHogAPIClient {
169
156
  }
170
157
 
171
158
  async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {
172
- const teamId = await this.getTeamId();
159
+ const teamId = this.getTeamId();
173
160
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
174
161
  method: 'PATCH',
175
162
  body: JSON.stringify({ output }),
@@ -177,7 +164,7 @@ export class PostHogAPIClient {
177
164
  }
178
165
 
179
166
  async appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun> {
180
- const teamId = await this.getTeamId();
167
+ const teamId = this.getTeamId();
181
168
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {
182
169
  method: 'POST',
183
170
  body: JSON.stringify({ entries }),
@@ -188,7 +175,7 @@ export class PostHogAPIClient {
188
175
  * Fetch error details from PostHog error tracking
189
176
  */
190
177
  async fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource> {
191
- const teamId = projectId ? parseInt(projectId) : await this.getTeamId();
178
+ const teamId = projectId ? parseInt(projectId) : this.getTeamId();
192
179
 
193
180
  try {
194
181
  const errorData = await this.apiRequest<any>(`/api/projects/${teamId}/error_tracking/${errorId}/`);
@@ -43,7 +43,7 @@ export interface StructuredExtractor {
43
43
 
44
44
  export type StructuredExtractorConfig = {
45
45
  apiKey: string;
46
- baseURL: string;
46
+ gatewayUrl: string;
47
47
  modelName?: string;
48
48
  logger?: Logger;
49
49
  }
@@ -61,13 +61,13 @@ export class AISDKExtractor implements StructuredExtractor {
61
61
 
62
62
  this.model = getAnthropicModel({
63
63
  apiKey: config.apiKey,
64
- baseURL: config.baseURL,
64
+ gatewayUrl: config.gatewayUrl,
65
65
  modelName: config.modelName || 'claude-haiku-4-5',
66
66
  });
67
67
 
68
68
  this.logger.debug('Using PostHog LLM gateway for structured extraction', {
69
69
  modelName: config.modelName || 'claude-haiku-4-5',
70
- baseURL: config.baseURL
70
+ gatewayUrl: config.gatewayUrl
71
71
  });
72
72
  }
73
73
 
package/src/types.ts CHANGED
@@ -303,10 +303,12 @@ export interface AgentConfig {
303
303
  // PostHog API configuration
304
304
  posthogApiUrl: string;
305
305
  posthogApiKey: string;
306
+ posthogProjectId: number;
306
307
 
307
308
  // PostHog MCP configuration
308
309
  posthogMcpUrl?: string;
309
310
 
311
+
310
312
  // MCP Server configuration
311
313
  // Additional MCP servers (PostHog MCP is always included by default)
312
314
  // You can override the PostHog MCP config by providing mcpServers.posthog
@@ -323,6 +325,7 @@ export interface AgentConfig {
323
325
  export interface PostHogAPIConfig {
324
326
  apiUrl: string;
325
327
  apiKey: string;
328
+ projectId: number;
326
329
  }
327
330
 
328
331
  // URL mention types
@@ -2,7 +2,7 @@ import { createAnthropic } from '@ai-sdk/anthropic';
2
2
 
3
3
  export interface PostHogGatewayConfig {
4
4
  apiKey: string;
5
- baseURL: string;
5
+ gatewayUrl: string;
6
6
  modelName?: string;
7
7
  }
8
8
 
@@ -18,7 +18,7 @@ export function getAnthropicModel(config: PostHogGatewayConfig) {
18
18
 
19
19
  // PostHog gateway expects /v1/messages, but AI SDK appends /messages
20
20
  // So we need to append /v1 to the baseURL
21
- const baseURL = config.baseURL ? `${config.baseURL}/v1` : undefined;
21
+ const baseURL = config.gatewayUrl ? `${config.gatewayUrl}/v1` : undefined;
22
22
 
23
23
  // Custom fetch to convert x-api-key header to Authorization Bearer
24
24
  // PostHog gateway expects Bearer token, but Anthropic SDK sends x-api-key