@posthog/agent 1.24.0 → 1.24.2
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/LICENSE +33 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/src/adapters/claude/claude-adapter.d.ts +3 -3
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +1 -1
- package/dist/src/adapters/claude/claude-adapter.js +111 -156
- package/dist/src/adapters/claude/claude-adapter.js.map +1 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts +1 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts.map +1 -1
- package/dist/src/adapters/claude/tool-mapper.js.map +1 -1
- package/dist/src/adapters/types.d.ts +1 -1
- package/dist/src/adapters/types.d.ts.map +1 -1
- package/dist/src/agent.d.ts +7 -7
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +85 -143
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/file-manager.d.ts +4 -4
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +58 -59
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +1 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +70 -87
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +3 -2
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +22 -22
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +3 -3
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +93 -123
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/task-manager.d.ts +4 -4
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js +18 -19
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/task-progress-reporter.d.ts +4 -3
- package/dist/src/task-progress-reporter.d.ts.map +1 -1
- package/dist/src/task-progress-reporter.js +54 -59
- package/dist/src/task-progress-reporter.js.map +1 -1
- package/dist/src/template-manager.d.ts +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +28 -30
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +3 -3
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +24 -29
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.js +60 -60
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/types.d.ts +31 -31
- package/dist/src/types.d.ts +33 -33
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.d.ts +4 -4
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +8 -8
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/workflow/config.d.ts +1 -1
- package/dist/src/workflow/config.d.ts.map +1 -1
- package/dist/src/workflow/config.js +18 -18
- package/dist/src/workflow/config.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +38 -46
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +48 -54
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +46 -58
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +56 -68
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +12 -12
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/workflow/utils.d.ts +1 -1
- package/dist/src/workflow/utils.d.ts.map +1 -1
- package/dist/src/workflow/utils.js +4 -7
- package/dist/src/workflow/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/claude/claude-adapter.ts +168 -220
- package/src/adapters/claude/tool-mapper.ts +2 -2
- package/src/adapters/types.ts +1 -1
- package/src/agent.ts +444 -579
- package/src/agents/execution.ts +1 -1
- package/src/agents/planning.ts +1 -1
- package/src/agents/research.ts +1 -0
- package/src/file-manager.ts +63 -64
- package/src/git-manager.ts +88 -144
- package/src/posthog-api.ts +82 -122
- package/src/prompt-builder.ts +135 -180
- package/src/task-manager.ts +30 -38
- package/src/task-progress-reporter.ts +59 -70
- package/src/template-manager.ts +45 -98
- package/src/todo-manager.ts +30 -35
- package/src/tools/registry.ts +62 -62
- package/src/tools/types.ts +36 -36
- package/src/types.ts +71 -93
- package/src/utils/logger.ts +56 -62
- package/src/workflow/config.ts +48 -48
- package/src/workflow/steps/build.ts +113 -122
- package/src/workflow/steps/finalize.ts +182 -214
- package/src/workflow/steps/plan.ts +131 -151
- package/src/workflow/steps/research.ts +186 -205
- package/src/workflow/types.ts +36 -38
- package/src/workflow/utils.ts +34 -37
package/dist/src/posthog-api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
class PostHogAPIClient {
|
|
2
2
|
config;
|
|
3
|
+
_teamId = null;
|
|
3
4
|
constructor(config) {
|
|
4
5
|
this.config = config;
|
|
5
6
|
}
|
|
@@ -11,8 +12,8 @@ class PostHogAPIClient {
|
|
|
11
12
|
}
|
|
12
13
|
get headers() {
|
|
13
14
|
return {
|
|
14
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
15
|
-
|
|
15
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
16
|
+
'Content-Type': 'application/json',
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
async apiRequest(endpoint, options = {}) {
|
|
@@ -69,7 +70,7 @@ class PostHogAPIClient {
|
|
|
69
70
|
async updateTask(taskId, updates) {
|
|
70
71
|
const teamId = this.getTeamId();
|
|
71
72
|
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/`, {
|
|
72
|
-
method:
|
|
73
|
+
method: 'PATCH',
|
|
73
74
|
body: JSON.stringify(updates),
|
|
74
75
|
});
|
|
75
76
|
}
|
|
@@ -100,14 +101,14 @@ class PostHogAPIClient {
|
|
|
100
101
|
async setTaskRunOutput(taskId, runId, output) {
|
|
101
102
|
const teamId = this.getTeamId();
|
|
102
103
|
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
|
|
103
|
-
method:
|
|
104
|
+
method: 'PATCH',
|
|
104
105
|
body: JSON.stringify({ output }),
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
async appendTaskRunLog(taskId, runId, entries) {
|
|
108
109
|
const teamId = this.getTeamId();
|
|
109
110
|
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {
|
|
110
|
-
method:
|
|
111
|
+
method: 'POST',
|
|
111
112
|
body: JSON.stringify({ entries }),
|
|
112
113
|
});
|
|
113
114
|
}
|
|
@@ -117,7 +118,7 @@ class PostHogAPIClient {
|
|
|
117
118
|
}
|
|
118
119
|
const teamId = this.getTeamId();
|
|
119
120
|
const response = await this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/`, {
|
|
120
|
-
method:
|
|
121
|
+
method: 'POST',
|
|
121
122
|
body: JSON.stringify({ artifacts }),
|
|
122
123
|
});
|
|
123
124
|
return response.artifacts ?? [];
|
|
@@ -143,8 +144,8 @@ class PostHogAPIClient {
|
|
|
143
144
|
// Parse newline-delimited JSON
|
|
144
145
|
return content
|
|
145
146
|
.trim()
|
|
146
|
-
.split(
|
|
147
|
-
.map(
|
|
147
|
+
.split('\n')
|
|
148
|
+
.map(line => JSON.parse(line));
|
|
148
149
|
}
|
|
149
150
|
catch (error) {
|
|
150
151
|
throw new Error(`Failed to fetch task run logs: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -154,16 +155,16 @@ class PostHogAPIClient {
|
|
|
154
155
|
* Fetch error details from PostHog error tracking
|
|
155
156
|
*/
|
|
156
157
|
async fetchErrorDetails(errorId, projectId) {
|
|
157
|
-
const teamId = projectId ? parseInt(projectId
|
|
158
|
+
const teamId = projectId ? parseInt(projectId) : this.getTeamId();
|
|
158
159
|
try {
|
|
159
160
|
const errorData = await this.apiRequest(`/api/projects/${teamId}/error_tracking/${errorId}/`);
|
|
160
161
|
// Format error details for agent consumption
|
|
161
162
|
const content = this.formatErrorContent(errorData);
|
|
162
163
|
return {
|
|
163
|
-
type:
|
|
164
|
+
type: 'error',
|
|
164
165
|
id: errorId,
|
|
165
166
|
url: `${this.baseUrl}/project/${teamId}/error_tracking/${errorId}`,
|
|
166
|
-
title: errorData.exception_type ||
|
|
167
|
+
title: errorData.exception_type || 'Unknown Error',
|
|
167
168
|
content,
|
|
168
169
|
metadata: {
|
|
169
170
|
exception_type: errorData.exception_type,
|
|
@@ -183,9 +184,9 @@ class PostHogAPIClient {
|
|
|
183
184
|
*/
|
|
184
185
|
async fetchResourceByUrl(urlMention) {
|
|
185
186
|
switch (urlMention.type) {
|
|
186
|
-
case
|
|
187
|
+
case 'error':
|
|
187
188
|
if (!urlMention.id) {
|
|
188
|
-
throw new Error(
|
|
189
|
+
throw new Error('Error ID is required for error resources');
|
|
189
190
|
}
|
|
190
191
|
// Extract project ID from URL if available, otherwise use default team
|
|
191
192
|
let projectId;
|
|
@@ -194,18 +195,17 @@ class PostHogAPIClient {
|
|
|
194
195
|
projectId = projectIdMatch ? projectIdMatch[1] : undefined;
|
|
195
196
|
}
|
|
196
197
|
return this.fetchErrorDetails(urlMention.id, projectId);
|
|
197
|
-
|
|
198
|
-
case
|
|
199
|
-
case
|
|
200
|
-
case "feature_flag":
|
|
198
|
+
case 'experiment':
|
|
199
|
+
case 'insight':
|
|
200
|
+
case 'feature_flag':
|
|
201
201
|
throw new Error(`Resource type '${urlMention.type}' not yet implemented`);
|
|
202
|
-
case
|
|
202
|
+
case 'generic':
|
|
203
203
|
// Return a minimal resource for generic URLs
|
|
204
204
|
return {
|
|
205
|
-
type:
|
|
206
|
-
id:
|
|
205
|
+
type: 'generic',
|
|
206
|
+
id: '',
|
|
207
207
|
url: urlMention.url,
|
|
208
|
-
title:
|
|
208
|
+
title: 'Generic Resource',
|
|
209
209
|
content: `Generic resource: ${urlMention.url}`,
|
|
210
210
|
metadata: {},
|
|
211
211
|
};
|
|
@@ -240,7 +240,7 @@ class PostHogAPIClient {
|
|
|
240
240
|
if (errorData.properties && Object.keys(errorData.properties).length > 0) {
|
|
241
241
|
sections.push(`**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`);
|
|
242
242
|
}
|
|
243
|
-
return sections.join(
|
|
243
|
+
return sections.join('\n\n');
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type {\n LogEntry,\n PostHogAPIConfig,\n PostHogResource,\n Task,\n TaskArtifactUploadPayload,\n TaskRun,\n TaskRunArtifact,\n UrlMention,\n} 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 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\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>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n );\n }\n\n async createTaskRun(\n taskId: string,\n payload?: Partial<\n Omit<\n TaskRun,\n \"id\" | \"task\" | \"team\" | \"created_at\" | \"updated_at\" | \"completed_at\"\n >\n >,\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/`,\n {\n method: \"POST\",\n body: JSON.stringify(payload || {}),\n },\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>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n },\n );\n }\n\n async setTaskRunOutput(\n taskId: string,\n runId: string,\n output: Record<string, unknown>,\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`,\n {\n method: \"PATCH\",\n body: JSON.stringify({ output }),\n },\n );\n }\n\n async appendTaskRunLog(\n taskId: string,\n runId: string,\n entries: LogEntry[],\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`,\n {\n method: \"POST\",\n body: JSON.stringify({ entries }),\n },\n );\n }\n\n async uploadTaskArtifacts(\n taskId: string,\n runId: string,\n artifacts: TaskArtifactUploadPayload[],\n ): Promise<TaskRunArtifact[]> {\n if (!artifacts.length) {\n return [];\n }\n\n const teamId = this.getTeamId();\n const response = await this.apiRequest<{ artifacts: TaskRunArtifact[] }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/`,\n {\n method: \"POST\",\n body: JSON.stringify({ artifacts }),\n },\n );\n\n return response.artifacts ?? [];\n }\n\n /**\n * Fetch logs from S3 using presigned URL from TaskRun\n * @param taskRun - The task run containing the log_url\n * @returns Array of log entries, or empty array if no logs available\n */\n async fetchTaskRunLogs(taskRun: TaskRun): Promise<LogEntry[]> {\n if (!taskRun.log_url) {\n return [];\n }\n\n try {\n const response = await fetch(taskRun.log_url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch logs: ${response.status} ${response.statusText}`,\n );\n }\n\n const content = await response.text();\n\n if (!content.trim()) {\n return [];\n }\n\n // Parse newline-delimited JSON\n return content\n .trim()\n .split(\"\\n\")\n .map((line) => JSON.parse(line) as LogEntry);\n } catch (error) {\n throw new Error(\n `Failed to fetch task run logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /**\n * Fetch error details from PostHog error tracking\n */\n async fetchErrorDetails(\n errorId: string,\n projectId?: string,\n ): Promise<PostHogResource> {\n const teamId = projectId ? parseInt(projectId, 10) : this.getTeamId();\n\n try {\n const errorData = await this.apiRequest<any>(\n `/api/projects/${teamId}/error_tracking/${errorId}/`,\n );\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\n case \"experiment\":\n case \"insight\":\n case \"feature_flag\":\n throw new Error(\n `Resource type '${urlMention.type}' not yet implemented`,\n );\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(\n `**Stack Trace**:\\n\\`\\`\\`\\n${errorData.stack_trace}\\n\\`\\`\\``,\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(\n `**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`,\n );\n }\n\n return sections.join(\"\\n\\n\");\n }\n}\n"],"names":[],"mappings":"MA2Ba,gBAAgB,CAAA;AACnB,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAA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A,CAAE,CAAC;QAC9D;AAEA,QAAA,IAAI,SAAS,CAAC,WAAW,EAAE;YACzB,QAAQ,CAAC,IAAI,CACX,CAAA,0BAAA,EAA6B,SAAS,CAAC,WAAW,CAAA,QAAA,CAAU,CAC7D;QACH;AAEA,QAAA,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,QAAQ,CAAC,IAAI,CAAC,CAAA,YAAA,EAAe,SAAS,CAAC,MAAM,CAAA,YAAA,CAAc,CAAC;QAC9D;AAEA,QAAA,IAAI,SAAS,CAAC,cAAc,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,CAAA,oBAAA,EAAuB,SAAS,CAAC,cAAc,CAAA,CAAE,CAAC;QAClE;QAEA,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,SAAS,EAAE;YAC/C,QAAQ,CAAC,IAAI,CAAC,CAAA,gBAAA,EAAmB,SAAS,CAAC,UAAU,CAAA,CAAE,CAAC;YACxD,QAAQ,CAAC,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,CACX,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,CAAE,CACnE;QACH;AAEA,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type {\n Task,\n TaskRun,\n LogEntry,\n SupportingFile,\n PostHogAPIConfig,\n PostHogResource,\n ResourceType,\n UrlMention,\n TaskRunArtifact,\n TaskArtifactUploadPayload,\n} 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 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 async uploadTaskArtifacts(\n taskId: string,\n runId: string,\n artifacts: TaskArtifactUploadPayload[]\n ): Promise<TaskRunArtifact[]> {\n if (!artifacts.length) {\n return [];\n }\n\n const teamId = this.getTeamId();\n const response = await this.apiRequest<{ artifacts: TaskRunArtifact[] }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/`,\n {\n method: 'POST',\n body: JSON.stringify({ artifacts }),\n }\n );\n\n return response.artifacts ?? [];\n }\n\n /**\n * Fetch logs from S3 using presigned URL from TaskRun\n * @param taskRun - The task run containing the log_url\n * @returns Array of log entries, or empty array if no logs available\n */\n async fetchTaskRunLogs(taskRun: TaskRun): Promise<LogEntry[]> {\n if (!taskRun.log_url) {\n return [];\n }\n\n try {\n const response = await fetch(taskRun.log_url);\n \n if (!response.ok) {\n throw new Error(`Failed to fetch logs: ${response.status} ${response.statusText}`);\n }\n\n const content = await response.text();\n \n if (!content.trim()) {\n return [];\n }\n\n // Parse newline-delimited JSON\n return content\n .trim()\n .split('\\n')\n .map(line => JSON.parse(line) as LogEntry);\n } catch (error) {\n throw new Error(`Failed to fetch task run logs: ${error instanceof Error ? error.message : String(error)}`);\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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
2
|
-
import type {
|
|
3
|
-
import { Logger } from
|
|
1
|
+
import type { Task, UrlMention, PostHogResource } from './types.js';
|
|
2
|
+
import type { TemplateVariables } from './template-manager.js';
|
|
3
|
+
import { Logger } from './utils/logger.js';
|
|
4
4
|
export interface PromptBuilderDeps {
|
|
5
5
|
getTaskFiles: (taskId: string) => Promise<any[]>;
|
|
6
6
|
generatePlanTemplate: (vars: TemplateVariables) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/prompt-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,oBAAoB,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE;QAAE,kBAAkB,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;KAAE,CAAC;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,oBAAoB,CAA4C;IACxE,OAAO,CAAC,aAAa,CAAC,CAAqC;IAC3D,OAAO,CAAC,MAAM,CAAS;gBAEX,IAAI,EAAE,iBAAiB;IAOnC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAY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