@posthog/agent 2.3.527 → 2.3.547

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "2.3.527",
3
+ "version": "2.3.547",
4
4
  "repository": "https://github.com/PostHog/code",
5
5
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
6
6
  "exports": {
@@ -107,8 +107,8 @@
107
107
  "typescript": "^5.5.0",
108
108
  "vitest": "^2.1.8",
109
109
  "@posthog/shared": "1.0.0",
110
- "@posthog/enricher": "1.0.0",
111
- "@posthog/git": "1.0.0"
110
+ "@posthog/git": "1.0.0",
111
+ "@posthog/enricher": "1.0.0"
112
112
  },
113
113
  "dependencies": {
114
114
  "@agentclientprotocol/sdk": "0.19.0",
@@ -237,6 +237,7 @@ describe("canUseTool MCP approval enforcement", () => {
237
237
  expect.objectContaining({
238
238
  toolCall: expect.objectContaining({
239
239
  title: "The agent wants to run `notebooks-destroy` on PostHog",
240
+ _meta: { claudeCode: { toolName: "mcp__posthog__exec" } },
240
241
  }),
241
242
  }),
242
243
  );
@@ -528,6 +528,7 @@ async function handlePostHogExecApprovalFlow(
528
528
  },
529
529
  ],
530
530
  rawInput: { ...(toolInput as Record<string, unknown>), toolName },
531
+ _meta: { claudeCode: { toolName } },
531
532
  },
532
533
  });
533
534
 
@@ -279,16 +279,27 @@ describe("AgentServer HTTP Mode", () => {
279
279
  const keepaliveCallback: { current: (() => void) | null } = {
280
280
  current: null,
281
281
  };
282
+ // Pass through to real setInterval for non-keepalive timers; otherwise
283
+ // unrelated internals (undici, http server, MSW) lose their periodic
284
+ // callbacks and can hang the test.
285
+ const realSetInterval = globalThis.setInterval;
282
286
  const setIntervalSpy = vi
283
287
  .spyOn(globalThis, "setInterval")
284
- .mockImplementation(
285
- (callback: (_: undefined) => void, timeout?: number) => {
286
- if (timeout === SSE_KEEPALIVE_INTERVAL_MS) {
287
- keepaliveCallback.current = () => callback(undefined);
288
- }
288
+ .mockImplementation(((
289
+ callback: (_: undefined) => void,
290
+ timeout?: number,
291
+ ...args: unknown[]
292
+ ) => {
293
+ if (timeout === SSE_KEEPALIVE_INTERVAL_MS) {
294
+ keepaliveCallback.current = () => callback(undefined);
289
295
  return setTimeout(() => undefined, 60_000);
290
- },
291
- );
296
+ }
297
+ return (realSetInterval as (...rest: unknown[]) => unknown)(
298
+ callback,
299
+ timeout,
300
+ ...args,
301
+ );
302
+ }) as unknown as typeof setInterval);
292
303
 
293
304
  let reader: ReadableStreamDefaultReader<Uint8Array> | null = null;
294
305
  try {
@@ -307,8 +318,9 @@ describe("AgentServer HTTP Mode", () => {
307
318
  throw new Error("Expected SSE response body reader");
308
319
  }
309
320
 
310
- await vi.waitFor(() =>
311
- expect(keepaliveCallback.current).not.toBeNull(),
321
+ await vi.waitFor(
322
+ () => expect(keepaliveCallback.current).not.toBeNull(),
323
+ { timeout: 10_000, interval: 50 },
312
324
  );
313
325
  const emitKeepalive = keepaliveCallback.current;
314
326
  if (!emitKeepalive) {
@@ -318,7 +330,7 @@ describe("AgentServer HTTP Mode", () => {
318
330
 
319
331
  const decoder = new TextDecoder();
320
332
  let streamText = "";
321
- for (let attempts = 0; attempts < 5; attempts++) {
333
+ for (let attempts = 0; attempts < 10; attempts++) {
322
334
  const { done, value } = await reader.read();
323
335
  if (done) break;
324
336
  streamText += decoder.decode(value, { stream: true });
@@ -331,7 +343,7 @@ describe("AgentServer HTTP Mode", () => {
331
343
  await reader?.cancel();
332
344
  setIntervalSpy.mockRestore();
333
345
  }
334
- }, 20000);
346
+ }, 30000);
335
347
  });
336
348
 
337
349
  describe("POST /command", () => {