@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/src/tools/types.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Makes it easier for UIs to filter and display tools by function.
|
|
4
4
|
*/
|
|
5
5
|
export type ToolCategory =
|
|
6
|
-
|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
6
|
+
| 'filesystem' // File operations: Read, Write, Edit, Glob, NotebookEdit
|
|
7
|
+
| 'shell' // Shell operations: Bash, BashOutput, KillShell
|
|
8
|
+
| 'web' // Web operations: WebFetch, WebSearch
|
|
9
|
+
| 'assistant' // Assistant operations: Task, TodoWrite, ExitPlanMode
|
|
10
|
+
| 'search' // Search operations: Grep
|
|
11
|
+
| 'unknown'; // Unknown or unrecognized tools
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Base tool interface representing a tool that can be called by the agent.
|
|
@@ -23,86 +23,86 @@ export interface Tool {
|
|
|
23
23
|
// Filesystem tools
|
|
24
24
|
|
|
25
25
|
export interface ReadTool extends Tool {
|
|
26
|
-
name:
|
|
27
|
-
category:
|
|
26
|
+
name: 'Read';
|
|
27
|
+
category: 'filesystem';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface WriteTool extends Tool {
|
|
31
|
-
name:
|
|
32
|
-
category:
|
|
31
|
+
name: 'Write';
|
|
32
|
+
category: 'filesystem';
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface EditTool extends Tool {
|
|
36
|
-
name:
|
|
37
|
-
category:
|
|
36
|
+
name: 'Edit';
|
|
37
|
+
category: 'filesystem';
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export interface GlobTool extends Tool {
|
|
41
|
-
name:
|
|
42
|
-
category:
|
|
41
|
+
name: 'Glob';
|
|
42
|
+
category: 'filesystem';
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface NotebookEditTool extends Tool {
|
|
46
|
-
name:
|
|
47
|
-
category:
|
|
46
|
+
name: 'NotebookEdit';
|
|
47
|
+
category: 'filesystem';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Shell tools
|
|
51
51
|
|
|
52
52
|
export interface BashTool extends Tool {
|
|
53
|
-
name:
|
|
54
|
-
category:
|
|
53
|
+
name: 'Bash';
|
|
54
|
+
category: 'shell';
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export interface BashOutputTool extends Tool {
|
|
58
|
-
name:
|
|
59
|
-
category:
|
|
58
|
+
name: 'BashOutput';
|
|
59
|
+
category: 'shell';
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export interface KillShellTool extends Tool {
|
|
63
|
-
name:
|
|
64
|
-
category:
|
|
63
|
+
name: 'KillShell';
|
|
64
|
+
category: 'shell';
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// Web tools
|
|
68
68
|
|
|
69
69
|
export interface WebFetchTool extends Tool {
|
|
70
|
-
name:
|
|
71
|
-
category:
|
|
70
|
+
name: 'WebFetch';
|
|
71
|
+
category: 'web';
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface WebSearchTool extends Tool {
|
|
75
|
-
name:
|
|
76
|
-
category:
|
|
75
|
+
name: 'WebSearch';
|
|
76
|
+
category: 'web';
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// Search tools
|
|
80
80
|
|
|
81
81
|
export interface GrepTool extends Tool {
|
|
82
|
-
name:
|
|
83
|
-
category:
|
|
82
|
+
name: 'Grep';
|
|
83
|
+
category: 'search';
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// Assistant tools
|
|
87
87
|
|
|
88
88
|
export interface TaskTool extends Tool {
|
|
89
|
-
name:
|
|
90
|
-
category:
|
|
89
|
+
name: 'Task';
|
|
90
|
+
category: 'assistant';
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export interface TodoWriteTool extends Tool {
|
|
94
|
-
name:
|
|
95
|
-
category:
|
|
94
|
+
name: 'TodoWrite';
|
|
95
|
+
category: 'assistant';
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export interface ExitPlanModeTool extends Tool {
|
|
99
|
-
name:
|
|
100
|
-
category:
|
|
99
|
+
name: 'ExitPlanMode';
|
|
100
|
+
category: 'assistant';
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export interface SlashCommandTool extends Tool {
|
|
104
|
-
name:
|
|
105
|
-
category:
|
|
104
|
+
name: 'SlashCommand';
|
|
105
|
+
category: 'assistant';
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
|
|
1
2
|
// import and export to keep a single type file
|
|
2
|
-
import type {
|
|
3
|
-
CanUseTool,
|
|
4
|
-
PermissionResult,
|
|
5
|
-
} from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import type { CanUseTool, PermissionResult } from '@anthropic-ai/claude-agent-sdk';
|
|
6
4
|
export type { CanUseTool, PermissionResult };
|
|
7
5
|
|
|
8
6
|
// PostHog Task model (matches Array's OpenAPI schema)
|
|
@@ -10,12 +8,7 @@ export interface Task {
|
|
|
10
8
|
id: string;
|
|
11
9
|
title: string;
|
|
12
10
|
description: string;
|
|
13
|
-
origin_product:
|
|
14
|
-
| "error_tracking"
|
|
15
|
-
| "eval_clusters"
|
|
16
|
-
| "user_created"
|
|
17
|
-
| "support_queue"
|
|
18
|
-
| "session_summaries";
|
|
11
|
+
origin_product: 'error_tracking' | 'eval_clusters' | 'user_created' | 'support_queue' | 'session_summaries';
|
|
19
12
|
position?: number;
|
|
20
13
|
github_integration?: number | null;
|
|
21
14
|
repository_config?: unknown; // JSONField
|
|
@@ -39,12 +32,7 @@ export interface LogEntry {
|
|
|
39
32
|
[key: string]: unknown; // Allow additional fields
|
|
40
33
|
}
|
|
41
34
|
|
|
42
|
-
export type ArtifactType =
|
|
43
|
-
| "plan"
|
|
44
|
-
| "context"
|
|
45
|
-
| "reference"
|
|
46
|
-
| "output"
|
|
47
|
-
| "artifact";
|
|
35
|
+
export type ArtifactType = 'plan' | 'context' | 'reference' | 'output' | 'artifact';
|
|
48
36
|
|
|
49
37
|
export interface TaskRunArtifact {
|
|
50
38
|
name: string;
|
|
@@ -61,7 +49,7 @@ export interface TaskRun {
|
|
|
61
49
|
task: string; // Task ID
|
|
62
50
|
team: number;
|
|
63
51
|
branch: string | null;
|
|
64
|
-
status:
|
|
52
|
+
status: 'started' | 'in_progress' | 'completed' | 'failed';
|
|
65
53
|
log_url?: string; // Presigned S3 URL for log access (valid for 1 hour)
|
|
66
54
|
error_message: string | null;
|
|
67
55
|
output: Record<string, unknown> | null; // Structured output (PR URL, commit SHA, etc.)
|
|
@@ -90,7 +78,7 @@ export enum PermissionMode {
|
|
|
90
78
|
PLAN = "plan",
|
|
91
79
|
DEFAULT = "default",
|
|
92
80
|
ACCEPT_EDITS = "acceptEdits",
|
|
93
|
-
BYPASS = "bypassPermissions"
|
|
81
|
+
BYPASS = "bypassPermissions"
|
|
94
82
|
}
|
|
95
83
|
|
|
96
84
|
export interface ExecutionOptions {
|
|
@@ -117,57 +105,57 @@ interface BaseEvent {
|
|
|
117
105
|
|
|
118
106
|
// Streaming content events
|
|
119
107
|
export interface TokenEvent extends BaseEvent {
|
|
120
|
-
type:
|
|
108
|
+
type: 'token';
|
|
121
109
|
content: string;
|
|
122
|
-
contentType?:
|
|
110
|
+
contentType?: 'text' | 'thinking' | 'tool_input';
|
|
123
111
|
}
|
|
124
112
|
|
|
125
113
|
export interface ContentBlockStartEvent extends BaseEvent {
|
|
126
|
-
type:
|
|
114
|
+
type: 'content_block_start';
|
|
127
115
|
index: number;
|
|
128
|
-
contentType:
|
|
116
|
+
contentType: 'text' | 'tool_use' | 'thinking';
|
|
129
117
|
toolName?: string;
|
|
130
118
|
toolId?: string;
|
|
131
119
|
}
|
|
132
120
|
|
|
133
121
|
export interface ContentBlockStopEvent extends BaseEvent {
|
|
134
|
-
type:
|
|
122
|
+
type: 'content_block_stop';
|
|
135
123
|
index: number;
|
|
136
124
|
}
|
|
137
125
|
|
|
138
126
|
// Tool events
|
|
139
127
|
export interface ToolCallEvent extends BaseEvent {
|
|
140
|
-
type:
|
|
128
|
+
type: 'tool_call';
|
|
141
129
|
toolName: string;
|
|
142
130
|
callId: string;
|
|
143
131
|
args: Record<string, any>;
|
|
144
|
-
parentToolUseId?: string | null;
|
|
132
|
+
parentToolUseId?: string | null; // For nested tool calls (subagents)
|
|
145
133
|
// Tool metadata (enriched by adapter for UI consumption)
|
|
146
|
-
tool?: import(
|
|
147
|
-
category?: import(
|
|
134
|
+
tool?: import('./tools/types.js').Tool;
|
|
135
|
+
category?: import('./tools/types.js').ToolCategory;
|
|
148
136
|
}
|
|
149
137
|
|
|
150
138
|
export interface ToolResultEvent extends BaseEvent {
|
|
151
|
-
type:
|
|
139
|
+
type: 'tool_result';
|
|
152
140
|
toolName: string;
|
|
153
141
|
callId: string;
|
|
154
142
|
result: any;
|
|
155
|
-
isError?: boolean;
|
|
156
|
-
parentToolUseId?: string | null;
|
|
143
|
+
isError?: boolean; // Whether the tool execution failed
|
|
144
|
+
parentToolUseId?: string | null; // For nested tool calls (subagents)
|
|
157
145
|
// Tool metadata (enriched by adapter for UI consumption)
|
|
158
|
-
tool?: import(
|
|
159
|
-
category?: import(
|
|
146
|
+
tool?: import('./tools/types.js').Tool;
|
|
147
|
+
category?: import('./tools/types.js').ToolCategory;
|
|
160
148
|
}
|
|
161
149
|
|
|
162
150
|
// Message lifecycle events
|
|
163
151
|
export interface MessageStartEvent extends BaseEvent {
|
|
164
|
-
type:
|
|
152
|
+
type: 'message_start';
|
|
165
153
|
messageId?: string;
|
|
166
154
|
model?: string;
|
|
167
155
|
}
|
|
168
156
|
|
|
169
157
|
export interface MessageDeltaEvent extends BaseEvent {
|
|
170
|
-
type:
|
|
158
|
+
type: 'message_delta';
|
|
171
159
|
stopReason?: string;
|
|
172
160
|
stopSequence?: string;
|
|
173
161
|
usage?: {
|
|
@@ -176,32 +164,32 @@ export interface MessageDeltaEvent extends BaseEvent {
|
|
|
176
164
|
}
|
|
177
165
|
|
|
178
166
|
export interface MessageStopEvent extends BaseEvent {
|
|
179
|
-
type:
|
|
167
|
+
type: 'message_stop';
|
|
180
168
|
}
|
|
181
169
|
|
|
182
170
|
// User message events
|
|
183
171
|
export interface UserMessageEvent extends BaseEvent {
|
|
184
|
-
type:
|
|
172
|
+
type: 'user_message';
|
|
185
173
|
content: string;
|
|
186
174
|
isSynthetic?: boolean;
|
|
187
175
|
}
|
|
188
176
|
|
|
189
177
|
// System events
|
|
190
178
|
export interface StatusEvent extends BaseEvent {
|
|
191
|
-
type:
|
|
179
|
+
type: 'status';
|
|
192
180
|
phase: string;
|
|
193
181
|
// Common optional fields (varies by phase):
|
|
194
|
-
kind?: string;
|
|
195
|
-
branch?: string;
|
|
196
|
-
prUrl?: string;
|
|
197
|
-
taskId?: string;
|
|
198
|
-
messageId?: string;
|
|
199
|
-
model?: string;
|
|
200
|
-
[key: string]: any;
|
|
182
|
+
kind?: string; // Kind of status (plan, implementation)
|
|
183
|
+
branch?: string; // Git branch name
|
|
184
|
+
prUrl?: string; // Pull request URL
|
|
185
|
+
taskId?: string; // Task identifier
|
|
186
|
+
messageId?: string; // Claude message ID
|
|
187
|
+
model?: string; // Model name
|
|
188
|
+
[key: string]: any; // Allow additional fields
|
|
201
189
|
}
|
|
202
190
|
|
|
203
191
|
export interface InitEvent extends BaseEvent {
|
|
204
|
-
type:
|
|
192
|
+
type: 'init';
|
|
205
193
|
model: string;
|
|
206
194
|
tools: string[];
|
|
207
195
|
permissionMode: string;
|
|
@@ -214,22 +202,21 @@ export interface InitEvent extends BaseEvent {
|
|
|
214
202
|
}
|
|
215
203
|
|
|
216
204
|
export interface CompactBoundaryEvent extends BaseEvent {
|
|
217
|
-
type:
|
|
218
|
-
trigger:
|
|
205
|
+
type: 'compact_boundary';
|
|
206
|
+
trigger: 'manual' | 'auto';
|
|
219
207
|
preTokens: number;
|
|
220
208
|
}
|
|
221
209
|
|
|
222
210
|
// Result events
|
|
223
211
|
export interface DoneEvent extends BaseEvent {
|
|
224
|
-
type:
|
|
225
|
-
result?: string;
|
|
212
|
+
type: 'done';
|
|
213
|
+
result?: string; // Final summary text from Claude
|
|
226
214
|
durationMs?: number;
|
|
227
|
-
durationApiMs?: number;
|
|
215
|
+
durationApiMs?: number; // API-only duration (excluding local processing)
|
|
228
216
|
numTurns?: number;
|
|
229
217
|
totalCostUsd?: number;
|
|
230
218
|
usage?: any;
|
|
231
|
-
modelUsage?: {
|
|
232
|
-
// Per-model usage breakdown
|
|
219
|
+
modelUsage?: { // Per-model usage breakdown
|
|
233
220
|
[modelName: string]: {
|
|
234
221
|
inputTokens: number;
|
|
235
222
|
outputTokens: number;
|
|
@@ -240,8 +227,7 @@ export interface DoneEvent extends BaseEvent {
|
|
|
240
227
|
contextWindow: number;
|
|
241
228
|
};
|
|
242
229
|
};
|
|
243
|
-
permissionDenials?: Array<{
|
|
244
|
-
// Tools that were denied by permissions
|
|
230
|
+
permissionDenials?: Array<{ // Tools that were denied by permissions
|
|
245
231
|
tool_name: string;
|
|
246
232
|
tool_use_id: string;
|
|
247
233
|
tool_input: Record<string, unknown>;
|
|
@@ -249,7 +235,7 @@ export interface DoneEvent extends BaseEvent {
|
|
|
249
235
|
}
|
|
250
236
|
|
|
251
237
|
export interface ErrorEvent extends BaseEvent {
|
|
252
|
-
type:
|
|
238
|
+
type: 'error';
|
|
253
239
|
message: string;
|
|
254
240
|
error?: any;
|
|
255
241
|
errorType?: string;
|
|
@@ -259,20 +245,20 @@ export interface ErrorEvent extends BaseEvent {
|
|
|
259
245
|
|
|
260
246
|
// Metric and artifact events (general purpose, not tool-specific)
|
|
261
247
|
export interface MetricEvent extends BaseEvent {
|
|
262
|
-
type:
|
|
248
|
+
type: 'metric';
|
|
263
249
|
key: string;
|
|
264
250
|
value: number;
|
|
265
251
|
unit?: string;
|
|
266
252
|
}
|
|
267
253
|
|
|
268
254
|
export interface ArtifactEvent extends BaseEvent {
|
|
269
|
-
type:
|
|
255
|
+
type: 'artifact';
|
|
270
256
|
kind: string;
|
|
271
257
|
content: any;
|
|
272
258
|
}
|
|
273
259
|
|
|
274
260
|
export interface RawSDKEvent extends BaseEvent {
|
|
275
|
-
type:
|
|
261
|
+
type: 'raw_sdk_event';
|
|
276
262
|
sdkMessage: any; // Full SDK message for debugging
|
|
277
263
|
}
|
|
278
264
|
|
|
@@ -310,28 +296,24 @@ export interface TaskExecutionResult {
|
|
|
310
296
|
}
|
|
311
297
|
|
|
312
298
|
// MCP Server configuration types (re-exported from Claude SDK for convenience)
|
|
313
|
-
export type McpServerConfig =
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type: "sdk";
|
|
332
|
-
name: string;
|
|
333
|
-
instance?: any; // McpServer instance
|
|
334
|
-
};
|
|
299
|
+
export type McpServerConfig = {
|
|
300
|
+
type?: 'stdio';
|
|
301
|
+
command: string;
|
|
302
|
+
args?: string[];
|
|
303
|
+
env?: Record<string, string>;
|
|
304
|
+
} | {
|
|
305
|
+
type: 'sse';
|
|
306
|
+
url: string;
|
|
307
|
+
headers?: Record<string, string>;
|
|
308
|
+
} | {
|
|
309
|
+
type: 'http';
|
|
310
|
+
url: string;
|
|
311
|
+
headers?: Record<string, string>;
|
|
312
|
+
} | {
|
|
313
|
+
type: 'sdk';
|
|
314
|
+
name: string;
|
|
315
|
+
instance?: any; // McpServer instance
|
|
316
|
+
};
|
|
335
317
|
|
|
336
318
|
export interface AgentConfig {
|
|
337
319
|
workingDirectory?: string;
|
|
@@ -345,6 +327,7 @@ export interface AgentConfig {
|
|
|
345
327
|
// PostHog MCP configuration
|
|
346
328
|
posthogMcpUrl?: string;
|
|
347
329
|
|
|
330
|
+
|
|
348
331
|
// MCP Server configuration
|
|
349
332
|
// Additional MCP servers (PostHog MCP is always included by default)
|
|
350
333
|
// You can override the PostHog MCP config by providing mcpServers.posthog
|
|
@@ -365,12 +348,7 @@ export interface PostHogAPIConfig {
|
|
|
365
348
|
}
|
|
366
349
|
|
|
367
350
|
// URL mention types
|
|
368
|
-
export type ResourceType =
|
|
369
|
-
| "error"
|
|
370
|
-
| "experiment"
|
|
371
|
-
| "insight"
|
|
372
|
-
| "feature_flag"
|
|
373
|
-
| "generic";
|
|
351
|
+
export type ResourceType = 'error' | 'experiment' | 'insight' | 'feature_flag' | 'generic';
|
|
374
352
|
|
|
375
353
|
export interface PostHogResource {
|
|
376
354
|
type: ResourceType;
|
|
@@ -402,11 +380,11 @@ export interface ResearchAnswer {
|
|
|
402
380
|
}
|
|
403
381
|
|
|
404
382
|
export interface ResearchEvaluation {
|
|
405
|
-
actionabilityScore: number;
|
|
406
|
-
context: string;
|
|
407
|
-
keyFiles: string[];
|
|
408
|
-
blockers?: string[];
|
|
383
|
+
actionabilityScore: number; // 0-1 confidence score
|
|
384
|
+
context: string; // brief summary for planning
|
|
385
|
+
keyFiles: string[]; // files needing modification
|
|
386
|
+
blockers?: string[]; // what's preventing full confidence
|
|
409
387
|
questions?: ResearchQuestion[]; // only if score < 0.7
|
|
410
|
-
answered?: boolean;
|
|
411
|
-
answers?: ResearchAnswer[];
|
|
412
|
-
}
|
|
388
|
+
answered?: boolean; // whether questions have been answered
|
|
389
|
+
answers?: ResearchAnswer[]; // user's answers to questions
|
|
390
|
+
}
|
package/src/utils/logger.ts
CHANGED
|
@@ -2,84 +2,78 @@
|
|
|
2
2
|
* Simple logger utility with configurable debug mode
|
|
3
3
|
*/
|
|
4
4
|
export enum LogLevel {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
ERROR = 0,
|
|
6
|
+
WARN = 1,
|
|
7
|
+
INFO = 2,
|
|
8
|
+
DEBUG = 3
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface LoggerConfig {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
prefix?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class Logger {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
private debugEnabled: boolean;
|
|
18
|
+
private prefix: string;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setDebug(enabled: boolean) {
|
|
26
|
-
this.debugEnabled = enabled;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private formatMessage(
|
|
30
|
-
level: string,
|
|
31
|
-
message: string,
|
|
32
|
-
data?: unknown,
|
|
33
|
-
): string {
|
|
34
|
-
const timestamp = new Date().toISOString();
|
|
35
|
-
const base = `${timestamp} ${this.prefix} ${level} ${message}`;
|
|
20
|
+
constructor(config: LoggerConfig = {}) {
|
|
21
|
+
this.debugEnabled = config.debug ?? false;
|
|
22
|
+
this.prefix = config.prefix ?? '[PostHog Agent]';
|
|
23
|
+
}
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
setDebug(enabled: boolean) {
|
|
26
|
+
this.debugEnabled = enabled;
|
|
39
27
|
}
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
private formatMessage(level: string, message: string, data?: any): string {
|
|
30
|
+
const timestamp = new Date().toISOString();
|
|
31
|
+
const base = `${timestamp} ${this.prefix} ${level} ${message}`;
|
|
32
|
+
|
|
33
|
+
if (data !== undefined) {
|
|
34
|
+
return `${base} ${JSON.stringify(data, null, 2)}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return base;
|
|
38
|
+
}
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.error(this.formatMessage("[ERROR]", message, error));
|
|
40
|
+
error(message: string, error?: Error | any) {
|
|
41
|
+
// Always log errors
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
console.error(this.formatMessage('[ERROR]', message, {
|
|
44
|
+
message: error.message,
|
|
45
|
+
stack: error.stack
|
|
46
|
+
}));
|
|
47
|
+
} else {
|
|
48
|
+
console.error(this.formatMessage('[ERROR]', message, error));
|
|
49
|
+
}
|
|
55
50
|
}
|
|
56
|
-
}
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
warn(message: string, data?: any) {
|
|
53
|
+
if (this.debugEnabled) {
|
|
54
|
+
console.warn(this.formatMessage('[WARN]', message, data));
|
|
55
|
+
}
|
|
61
56
|
}
|
|
62
|
-
}
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
info(message: string, data?: any) {
|
|
59
|
+
if (this.debugEnabled) {
|
|
60
|
+
console.log(this.formatMessage('[INFO]', message, data));
|
|
61
|
+
}
|
|
67
62
|
}
|
|
68
|
-
}
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
debug(message: string, data?: any) {
|
|
65
|
+
if (this.debugEnabled) {
|
|
66
|
+
console.log(this.formatMessage('[DEBUG]', message, data));
|
|
67
|
+
}
|
|
73
68
|
}
|
|
74
|
-
}
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a child logger with additional prefix
|
|
72
|
+
*/
|
|
73
|
+
child(childPrefix: string): Logger {
|
|
74
|
+
return new Logger({
|
|
75
|
+
debug: this.debugEnabled,
|
|
76
|
+
prefix: `${this.prefix} [${childPrefix}]`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|