@posthog/agent 1.21.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CLAUDE.md +3 -3
  2. package/README.md +3 -3
  3. package/dist/claude-cli/cli.js +1396 -1347
  4. package/dist/index.d.ts +11 -11
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -3
  7. package/dist/src/adapters/claude/claude-adapter.d.ts +3 -3
  8. package/dist/src/adapters/claude/claude-adapter.d.ts.map +1 -1
  9. package/dist/src/adapters/claude/claude-adapter.js +156 -111
  10. package/dist/src/adapters/claude/claude-adapter.js.map +1 -1
  11. package/dist/src/adapters/claude/tool-mapper.d.ts +1 -1
  12. package/dist/src/adapters/claude/tool-mapper.d.ts.map +1 -1
  13. package/dist/src/adapters/claude/tool-mapper.js.map +1 -1
  14. package/dist/src/adapters/types.d.ts +1 -1
  15. package/dist/src/adapters/types.d.ts.map +1 -1
  16. package/dist/src/agent.d.ts +7 -7
  17. package/dist/src/agent.d.ts.map +1 -1
  18. package/dist/src/agent.js +143 -85
  19. package/dist/src/agent.js.map +1 -1
  20. package/dist/src/agents/execution.js.map +1 -1
  21. package/dist/src/agents/planning.js.map +1 -1
  22. package/dist/src/agents/research.js.map +1 -1
  23. package/dist/src/file-manager.d.ts +4 -4
  24. package/dist/src/file-manager.d.ts.map +1 -1
  25. package/dist/src/file-manager.js +59 -58
  26. package/dist/src/file-manager.js.map +1 -1
  27. package/dist/src/git-manager.d.ts +2 -1
  28. package/dist/src/git-manager.d.ts.map +1 -1
  29. package/dist/src/git-manager.js +99 -68
  30. package/dist/src/git-manager.js.map +1 -1
  31. package/dist/src/posthog-api.d.ts +2 -3
  32. package/dist/src/posthog-api.d.ts.map +1 -1
  33. package/dist/src/posthog-api.js +22 -22
  34. package/dist/src/posthog-api.js.map +1 -1
  35. package/dist/src/prompt-builder.d.ts +3 -3
  36. package/dist/src/prompt-builder.d.ts.map +1 -1
  37. package/dist/src/prompt-builder.js +123 -93
  38. package/dist/src/prompt-builder.js.map +1 -1
  39. package/dist/src/task-manager.d.ts +4 -4
  40. package/dist/src/task-manager.d.ts.map +1 -1
  41. package/dist/src/task-manager.js +19 -18
  42. package/dist/src/task-manager.js.map +1 -1
  43. package/dist/src/task-progress-reporter.d.ts +3 -4
  44. package/dist/src/task-progress-reporter.d.ts.map +1 -1
  45. package/dist/src/task-progress-reporter.js +69 -53
  46. package/dist/src/task-progress-reporter.js.map +1 -1
  47. package/dist/src/template-manager.d.ts +1 -1
  48. package/dist/src/template-manager.d.ts.map +1 -1
  49. package/dist/src/template-manager.js +30 -28
  50. package/dist/src/template-manager.js.map +1 -1
  51. package/dist/src/todo-manager.d.ts +3 -3
  52. package/dist/src/todo-manager.d.ts.map +1 -1
  53. package/dist/src/todo-manager.js +29 -24
  54. package/dist/src/todo-manager.js.map +1 -1
  55. package/dist/src/tools/registry.d.ts +1 -1
  56. package/dist/src/tools/registry.js +60 -60
  57. package/dist/src/tools/registry.js.map +1 -1
  58. package/dist/src/tools/types.d.ts +31 -31
  59. package/dist/src/types.d.ts +33 -33
  60. package/dist/src/types.d.ts.map +1 -1
  61. package/dist/src/types.js.map +1 -1
  62. package/dist/src/utils/logger.d.ts +4 -4
  63. package/dist/src/utils/logger.d.ts.map +1 -1
  64. package/dist/src/utils/logger.js +8 -8
  65. package/dist/src/utils/logger.js.map +1 -1
  66. package/dist/src/workflow/config.d.ts +1 -1
  67. package/dist/src/workflow/config.d.ts.map +1 -1
  68. package/dist/src/workflow/config.js +18 -18
  69. package/dist/src/workflow/config.js.map +1 -1
  70. package/dist/src/workflow/steps/build.d.ts +1 -1
  71. package/dist/src/workflow/steps/build.d.ts.map +1 -1
  72. package/dist/src/workflow/steps/build.js +46 -38
  73. package/dist/src/workflow/steps/build.js.map +1 -1
  74. package/dist/src/workflow/steps/finalize.d.ts +1 -1
  75. package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
  76. package/dist/src/workflow/steps/finalize.js +62 -47
  77. package/dist/src/workflow/steps/finalize.js.map +1 -1
  78. package/dist/src/workflow/steps/plan.d.ts +1 -1
  79. package/dist/src/workflow/steps/plan.d.ts.map +1 -1
  80. package/dist/src/workflow/steps/plan.js +58 -46
  81. package/dist/src/workflow/steps/plan.js.map +1 -1
  82. package/dist/src/workflow/steps/research.d.ts +1 -1
  83. package/dist/src/workflow/steps/research.d.ts.map +1 -1
  84. package/dist/src/workflow/steps/research.js +68 -56
  85. package/dist/src/workflow/steps/research.js.map +1 -1
  86. package/dist/src/workflow/types.d.ts +12 -12
  87. package/dist/src/workflow/types.d.ts.map +1 -1
  88. package/dist/src/workflow/utils.d.ts +1 -1
  89. package/dist/src/workflow/utils.d.ts.map +1 -1
  90. package/dist/src/workflow/utils.js +7 -4
  91. package/dist/src/workflow/utils.js.map +1 -1
  92. package/package.json +9 -9
  93. package/src/adapters/claude/claude-adapter.ts +220 -168
  94. package/src/adapters/claude/tool-mapper.ts +2 -2
  95. package/src/adapters/types.ts +1 -1
  96. package/src/agent.ts +579 -444
  97. package/src/agents/execution.ts +1 -1
  98. package/src/agents/planning.ts +1 -1
  99. package/src/agents/research.ts +0 -1
  100. package/src/file-manager.ts +64 -63
  101. package/src/git-manager.ts +159 -86
  102. package/src/posthog-api.ts +122 -82
  103. package/src/prompt-builder.ts +180 -135
  104. package/src/task-manager.ts +38 -30
  105. package/src/task-progress-reporter.ts +80 -58
  106. package/src/template-manager.ts +98 -45
  107. package/src/todo-manager.ts +35 -30
  108. package/src/tools/registry.ts +62 -62
  109. package/src/tools/types.ts +36 -36
  110. package/src/types.ts +93 -71
  111. package/src/utils/logger.ts +62 -56
  112. package/src/workflow/config.ts +48 -48
  113. package/src/workflow/steps/build.ts +122 -113
  114. package/src/workflow/steps/finalize.ts +218 -177
  115. package/src/workflow/steps/plan.ts +151 -131
  116. package/src/workflow/steps/research.ts +205 -186
  117. package/src/workflow/types.ts +38 -36
  118. package/src/workflow/utils.ts +37 -34
  119. package/LICENSE +0 -33
@@ -1,9 +1,9 @@
1
- import { randomBytes } from 'crypto';
1
+ import { randomBytes } from "node:crypto";
2
2
 
3
3
  export interface TaskExecutionState {
4
4
  taskId: string;
5
- status: 'running' | 'completed' | 'failed' | 'canceled' | 'timeout';
6
- mode: 'plan_only' | 'plan_and_build' | 'build_only';
5
+ status: "running" | "completed" | "failed" | "canceled" | "timeout";
6
+ mode: "plan_only" | "plan_and_build" | "build_only";
7
7
  result?: any;
8
8
  startedAt: number;
9
9
  completedAt?: number;
@@ -11,21 +11,21 @@ export interface TaskExecutionState {
11
11
  }
12
12
 
13
13
  export class TaskManager {
14
- private executionStates = new Map<string, TaskExecutionState>();
14
+ public executionStates = new Map<string, TaskExecutionState>();
15
15
  private defaultTimeout = 10 * 60 * 1000; // 10 minutes
16
16
 
17
17
  generateExecutionId(): string {
18
- return randomBytes(16).toString('hex');
18
+ return randomBytes(16).toString("hex");
19
19
  }
20
20
 
21
21
  startExecution(
22
- taskId: string,
23
- mode: 'plan_only' | 'plan_and_build' | 'build_only',
24
- executionId: string = this.generateExecutionId()
22
+ taskId: string,
23
+ mode: "plan_only" | "plan_and_build" | "build_only",
24
+ executionId: string = this.generateExecutionId(),
25
25
  ): TaskExecutionState {
26
26
  const executionState: TaskExecutionState = {
27
27
  taskId,
28
- status: 'running',
28
+ status: "running",
29
29
  mode,
30
30
  startedAt: Date.now(),
31
31
  abortController: new AbortController(),
@@ -33,7 +33,7 @@ export class TaskManager {
33
33
 
34
34
  this.executionStates.set(executionId, executionState);
35
35
  this.scheduleTimeout(executionId);
36
-
36
+
37
37
  return executionState;
38
38
  }
39
39
 
@@ -43,7 +43,7 @@ export class TaskManager {
43
43
  throw new Error(`Execution ${executionId} not found`);
44
44
  }
45
45
 
46
- if (execution.result && execution.status === 'completed') {
46
+ if (execution.result && execution.status === "completed") {
47
47
  return execution.result;
48
48
  }
49
49
 
@@ -56,16 +56,21 @@ export class TaskManager {
56
56
  return;
57
57
  }
58
58
 
59
- if (currentExecution.status === 'completed' && currentExecution.result) {
59
+ if (
60
+ currentExecution.status === "completed" &&
61
+ currentExecution.result
62
+ ) {
60
63
  clearInterval(checkInterval);
61
64
  resolve(currentExecution.result);
62
65
  } else if (
63
- currentExecution.status === 'failed' ||
64
- currentExecution.status === 'canceled' ||
65
- currentExecution.status === 'timeout'
66
+ currentExecution.status === "failed" ||
67
+ currentExecution.status === "canceled" ||
68
+ currentExecution.status === "timeout"
66
69
  ) {
67
70
  clearInterval(checkInterval);
68
- reject(new Error(`Execution ${executionId} ${currentExecution.status}`));
71
+ reject(
72
+ new Error(`Execution ${executionId} ${currentExecution.status}`),
73
+ );
69
74
  }
70
75
  }, 100);
71
76
  });
@@ -77,7 +82,7 @@ export class TaskManager {
77
82
  throw new Error(`Execution ${executionId} not found`);
78
83
  }
79
84
 
80
- execution.status = 'completed';
85
+ execution.status = "completed";
81
86
  execution.result = result;
82
87
  execution.completedAt = Date.now();
83
88
  }
@@ -88,11 +93,11 @@ export class TaskManager {
88
93
  throw new Error(`Execution ${executionId} not found`);
89
94
  }
90
95
 
91
- execution.status = 'failed';
96
+ execution.status = "failed";
92
97
  execution.completedAt = Date.now();
93
98
  execution.result = {
94
99
  error: error.message,
95
- status: 'failed',
100
+ status: "failed",
96
101
  };
97
102
  }
98
103
 
@@ -102,14 +107,14 @@ export class TaskManager {
102
107
  throw new Error(`Execution ${executionId} not found`);
103
108
  }
104
109
 
105
- execution.status = 'canceled';
110
+ execution.status = "canceled";
106
111
  execution.completedAt = Date.now();
107
112
  execution.abortController?.abort();
108
-
113
+
109
114
  if (!execution.result) {
110
115
  execution.result = {
111
- status: 'canceled',
112
- message: 'Execution was canceled',
116
+ status: "canceled",
117
+ message: "Execution was canceled",
113
118
  };
114
119
  }
115
120
  }
@@ -126,18 +131,21 @@ export class TaskManager {
126
131
  return this.executionStates.get(executionId)?.abortController;
127
132
  }
128
133
 
129
- private scheduleTimeout(executionId: string, timeout: number = this.defaultTimeout): void {
134
+ private scheduleTimeout(
135
+ executionId: string,
136
+ timeout: number = this.defaultTimeout,
137
+ ): void {
130
138
  setTimeout(() => {
131
139
  const execution = this.executionStates.get(executionId);
132
- if (execution && execution.status === 'running') {
133
- execution.status = 'timeout';
140
+ if (execution && execution.status === "running") {
141
+ execution.status = "timeout";
134
142
  execution.completedAt = Date.now();
135
143
  execution.abortController?.abort();
136
-
144
+
137
145
  if (!execution.result) {
138
146
  execution.result = {
139
- status: 'timeout',
140
- message: 'Execution timed out',
147
+ status: "timeout",
148
+ message: "Execution timed out",
141
149
  };
142
150
  }
143
151
  }
@@ -152,4 +160,4 @@ export class TaskManager {
152
160
  }
153
161
  }
154
162
  }
155
- }
163
+ }
@@ -1,6 +1,6 @@
1
- import type { Logger } from './utils/logger.js';
2
- import type { PostHogAPIClient, TaskRunUpdate } from './posthog-api.js';
3
- import type { AgentEvent, TaskRun, LogEntry } from './types.js';
1
+ import type { PostHogAPIClient, TaskRunUpdate } from "./posthog-api.js";
2
+ import type { AgentEvent, LogEntry, TaskRun } from "./types.js";
3
+ import type { Logger } from "./utils/logger.js";
4
4
 
5
5
  interface ProgressMetadata {
6
6
  totalSteps?: number;
@@ -17,10 +17,9 @@ export class TaskProgressReporter {
17
17
  private logger: Logger;
18
18
  private taskRun?: TaskRun;
19
19
  private taskId?: string;
20
- private outputLog: string[] = [];
21
20
  private totalSteps?: number;
22
21
  private lastLogEntry?: string;
23
- private tokenBuffer: string = '';
22
+ private tokenBuffer: string = "";
24
23
  private tokenCount: number = 0;
25
24
  private tokenFlushTimer?: NodeJS.Timeout;
26
25
  private readonly TOKEN_BATCH_SIZE = 100;
@@ -31,7 +30,7 @@ export class TaskProgressReporter {
31
30
 
32
31
  constructor(posthogAPI: PostHogAPIClient | undefined, logger: Logger) {
33
32
  this.posthogAPI = posthogAPI;
34
- this.logger = logger.child('TaskProgressReporter');
33
+ this.logger = logger.child("TaskProgressReporter");
35
34
  }
36
35
 
37
36
  get runId(): string | undefined {
@@ -48,28 +47,49 @@ export class TaskProgressReporter {
48
47
 
49
48
  try {
50
49
  const run = await this.posthogAPI.createTaskRun(taskId, {
51
- status: 'started',
50
+ status: "started",
52
51
  });
53
52
  this.taskRun = run;
54
- this.outputLog = [];
55
- this.logger.debug('Created task run', { taskId, runId: run.id });
53
+ this.logger.debug("Created task run", { taskId, runId: run.id });
56
54
  } catch (error) {
57
- this.logger.warn('Failed to create task run', { taskId, error: (error as Error).message });
55
+ this.logger.warn("Failed to create task run", {
56
+ taskId,
57
+ error: (error as Error).message,
58
+ });
58
59
  }
59
60
  }
60
61
 
61
62
  async complete(): Promise<void> {
62
63
  await this.flushTokens(); // Flush any remaining tokens before completion
64
+ try {
65
+ await this.logWriteQueue;
66
+ } catch (error) {
67
+ this.logger.debug("Pending logs failed to write during completion", {
68
+ error,
69
+ });
70
+ }
71
+
63
72
  if (this.tokenFlushTimer) {
64
73
  clearTimeout(this.tokenFlushTimer);
65
74
  this.tokenFlushTimer = undefined;
66
75
  }
67
- await this.update({ status: 'completed' }, 'Task execution completed');
76
+ await this.update({ status: "completed" }, "Task execution completed");
68
77
  }
69
78
 
70
79
  async fail(error: Error | string): Promise<void> {
71
- const message = typeof error === 'string' ? error : error.message;
72
- await this.update({ status: 'failed', error_message: message }, `Task execution failed: ${message}`);
80
+ try {
81
+ await this.logWriteQueue;
82
+ } catch (logError) {
83
+ this.logger.debug("Pending logs failed to write during fail", {
84
+ error: logError,
85
+ });
86
+ }
87
+
88
+ const message = typeof error === "string" ? error : error.message;
89
+ await this.update(
90
+ { status: "failed", error_message: message },
91
+ `Task execution failed: ${message}`,
92
+ );
73
93
  }
74
94
 
75
95
  async appendLog(line: string): Promise<void> {
@@ -82,11 +102,11 @@ export class TaskProgressReporter {
82
102
  }
83
103
 
84
104
  const buffer = this.tokenBuffer;
85
- this.tokenBuffer = '';
105
+ this.tokenBuffer = "";
86
106
  this.tokenCount = 0;
87
107
 
88
108
  await this.appendLogEntry({
89
- type: 'token',
109
+ type: "token",
90
110
  message: buffer,
91
111
  });
92
112
  }
@@ -99,7 +119,7 @@ export class TaskProgressReporter {
99
119
  this.tokenFlushTimer = setTimeout(() => {
100
120
  this.tokenFlushTimer = undefined;
101
121
  this.flushTokens().catch((err) => {
102
- this.logger.warn('Failed to flush tokens', { error: err });
122
+ this.logger.warn("Failed to flush tokens", { error: err });
103
123
  });
104
124
  }, this.TOKEN_FLUSH_INTERVAL_MS);
105
125
  }
@@ -114,8 +134,7 @@ export class TaskProgressReporter {
114
134
 
115
135
  this.logWriteQueue = this.logWriteQueue
116
136
  .catch((error) => {
117
- // Ensure previous failures don't block subsequent writes
118
- this.logger.debug('Previous log append failed', {
137
+ this.logger.debug("Previous log append failed", {
119
138
  taskId,
120
139
  runId,
121
140
  error: error instanceof Error ? error.message : String(error),
@@ -140,7 +159,7 @@ export class TaskProgressReporter {
140
159
  await this.posthogAPI.appendTaskRunLog(taskId, runId, [entry]);
141
160
  return;
142
161
  } catch (error) {
143
- this.logger.warn('Failed to append log entry', {
162
+ this.logger.warn("Failed to append log entry", {
144
163
  taskId,
145
164
  runId,
146
165
  attempt,
@@ -153,7 +172,7 @@ export class TaskProgressReporter {
153
172
  }
154
173
 
155
174
  const delayMs =
156
- this.LOG_APPEND_RETRY_BASE_DELAY_MS * Math.pow(2, attempt - 1);
175
+ this.LOG_APPEND_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1);
157
176
  await new Promise((resolve) => setTimeout(resolve, delayMs));
158
177
  }
159
178
  }
@@ -165,7 +184,7 @@ export class TaskProgressReporter {
165
184
  }
166
185
 
167
186
  switch (event.type) {
168
- case 'token': {
187
+ case "token": {
169
188
  // Batch tokens for efficiency
170
189
  this.tokenBuffer += event.content;
171
190
  this.tokenCount++;
@@ -182,9 +201,9 @@ export class TaskProgressReporter {
182
201
  return;
183
202
  }
184
203
 
185
- case 'content_block_start': {
204
+ case "content_block_start": {
186
205
  await this.appendLogEntry({
187
- type: 'content_block_start',
206
+ type: "content_block_start",
188
207
  message: JSON.stringify({
189
208
  index: event.index,
190
209
  contentType: event.contentType,
@@ -196,9 +215,9 @@ export class TaskProgressReporter {
196
215
  return;
197
216
  }
198
217
 
199
- case 'content_block_stop': {
218
+ case "content_block_stop": {
200
219
  await this.appendLogEntry({
201
- type: 'content_block_stop',
220
+ type: "content_block_stop",
202
221
  message: JSON.stringify({
203
222
  index: event.index,
204
223
  ts: event.ts,
@@ -207,9 +226,9 @@ export class TaskProgressReporter {
207
226
  return;
208
227
  }
209
228
 
210
- case 'message_start': {
229
+ case "message_start": {
211
230
  await this.appendLogEntry({
212
- type: 'message_start',
231
+ type: "message_start",
213
232
  message: JSON.stringify({
214
233
  messageId: event.messageId,
215
234
  model: event.model,
@@ -219,9 +238,9 @@ export class TaskProgressReporter {
219
238
  return;
220
239
  }
221
240
 
222
- case 'message_delta': {
241
+ case "message_delta": {
223
242
  await this.appendLogEntry({
224
- type: 'message_delta',
243
+ type: "message_delta",
225
244
  message: JSON.stringify({
226
245
  stopReason: event.stopReason,
227
246
  stopSequence: event.stopSequence,
@@ -232,17 +251,17 @@ export class TaskProgressReporter {
232
251
  return;
233
252
  }
234
253
 
235
- case 'message_stop': {
254
+ case "message_stop": {
236
255
  await this.appendLogEntry({
237
- type: 'message_stop',
256
+ type: "message_stop",
238
257
  message: JSON.stringify({ ts: event.ts }),
239
258
  });
240
259
  return;
241
260
  }
242
261
 
243
- case 'status': {
262
+ case "status": {
244
263
  await this.appendLogEntry({
245
- type: 'status',
264
+ type: "status",
246
265
  message: JSON.stringify({
247
266
  phase: event.phase,
248
267
  kind: event.kind,
@@ -257,9 +276,9 @@ export class TaskProgressReporter {
257
276
  return;
258
277
  }
259
278
 
260
- case 'artifact': {
279
+ case "artifact": {
261
280
  await this.appendLogEntry({
262
- type: 'artifact',
281
+ type: "artifact",
263
282
  message: JSON.stringify({
264
283
  kind: event.kind,
265
284
  content: event.content,
@@ -269,9 +288,9 @@ export class TaskProgressReporter {
269
288
  return;
270
289
  }
271
290
 
272
- case 'init': {
291
+ case "init": {
273
292
  await this.appendLogEntry({
274
- type: 'init',
293
+ type: "init",
275
294
  message: JSON.stringify({
276
295
  model: event.model,
277
296
  tools: event.tools,
@@ -284,9 +303,9 @@ export class TaskProgressReporter {
284
303
  return;
285
304
  }
286
305
 
287
- case 'metric': {
306
+ case "metric": {
288
307
  await this.appendLogEntry({
289
- type: 'metric',
308
+ type: "metric",
290
309
  message: JSON.stringify({
291
310
  key: event.key,
292
311
  value: event.value,
@@ -297,9 +316,9 @@ export class TaskProgressReporter {
297
316
  return;
298
317
  }
299
318
 
300
- case 'compact_boundary': {
319
+ case "compact_boundary": {
301
320
  await this.appendLogEntry({
302
- type: 'compact_boundary',
321
+ type: "compact_boundary",
303
322
  message: JSON.stringify({
304
323
  trigger: event.trigger,
305
324
  preTokens: event.preTokens,
@@ -309,9 +328,9 @@ export class TaskProgressReporter {
309
328
  return;
310
329
  }
311
330
 
312
- case 'tool_call': {
331
+ case "tool_call": {
313
332
  await this.appendLogEntry({
314
- type: 'tool_call',
333
+ type: "tool_call",
315
334
  message: JSON.stringify({
316
335
  toolName: event.toolName,
317
336
  callId: event.callId,
@@ -323,9 +342,9 @@ export class TaskProgressReporter {
323
342
  return;
324
343
  }
325
344
 
326
- case 'tool_result': {
345
+ case "tool_result": {
327
346
  await this.appendLogEntry({
328
- type: 'tool_result',
347
+ type: "tool_result",
329
348
  message: JSON.stringify({
330
349
  toolName: event.toolName,
331
350
  callId: event.callId,
@@ -338,9 +357,9 @@ export class TaskProgressReporter {
338
357
  return;
339
358
  }
340
359
 
341
- case 'error': {
360
+ case "error": {
342
361
  await this.appendLogEntry({
343
- type: 'error',
362
+ type: "error",
344
363
  message: JSON.stringify({
345
364
  message: event.message,
346
365
  errorType: event.errorType,
@@ -351,9 +370,9 @@ export class TaskProgressReporter {
351
370
  return;
352
371
  }
353
372
 
354
- case 'done': {
373
+ case "done": {
355
374
  await this.appendLogEntry({
356
- type: 'done',
375
+ type: "done",
357
376
  message: JSON.stringify({
358
377
  result: event.result,
359
378
  durationMs: event.durationMs,
@@ -369,9 +388,9 @@ export class TaskProgressReporter {
369
388
  return;
370
389
  }
371
390
 
372
- case 'user_message': {
391
+ case "user_message": {
373
392
  await this.appendLogEntry({
374
- type: 'user_message',
393
+ type: "user_message",
375
394
  message: JSON.stringify({
376
395
  content: event.content,
377
396
  isSynthetic: event.isSynthetic,
@@ -381,14 +400,14 @@ export class TaskProgressReporter {
381
400
  return;
382
401
  }
383
402
 
384
- case 'raw_sdk_event': {
403
+ case "raw_sdk_event": {
385
404
  // Skip raw SDK events - too verbose for persistence
386
405
  return;
387
406
  }
388
407
 
389
408
  default:
390
409
  // For any unfamiliar event types, log them as-is
391
- this.logger.debug('Unknown event type', { type: (event as any).type });
410
+ this.logger.debug("Unknown event type", { type: (event as any).type });
392
411
  return;
393
412
  }
394
413
  }
@@ -402,11 +421,11 @@ export class TaskProgressReporter {
402
421
  if (logLine && logLine !== this.lastLogEntry) {
403
422
  try {
404
423
  await this.posthogAPI.appendTaskRunLog(this.taskId, this.runId, [
405
- { type: 'info', message: logLine }
424
+ { type: "info", message: logLine },
406
425
  ]);
407
426
  this.lastLogEntry = logLine;
408
427
  } catch (error) {
409
- this.logger.warn('Failed to append log entry', {
428
+ this.logger.warn("Failed to append log entry", {
410
429
  taskId: this.taskId,
411
430
  runId: this.runId,
412
431
  error: (error as Error).message,
@@ -417,10 +436,14 @@ export class TaskProgressReporter {
417
436
  // Update other fields if provided
418
437
  if (Object.keys(update).length > 0) {
419
438
  try {
420
- const run = await this.posthogAPI.updateTaskRun(this.taskId, this.runId, update);
439
+ const run = await this.posthogAPI.updateTaskRun(
440
+ this.taskId,
441
+ this.runId,
442
+ update,
443
+ );
421
444
  this.taskRun = run;
422
445
  } catch (error) {
423
- this.logger.warn('Failed to update task run', {
446
+ this.logger.warn("Failed to update task run", {
424
447
  taskId: this.taskId,
425
448
  runId: this.runId,
426
449
  error: (error as Error).message,
@@ -428,5 +451,4 @@ export class TaskProgressReporter {
428
451
  }
429
452
  }
430
453
  }
431
-
432
454
  }