@posthog/agent 2.3.547 → 2.3.548

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.547",
3
+ "version": "2.3.548",
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": {
@@ -303,12 +303,41 @@ describe("AgentServer HTTP Mode", () => {
303
303
 
304
304
  let reader: ReadableStreamDefaultReader<Uint8Array> | null = null;
305
305
  try {
306
- await createServer().start();
306
+ const testServer = createServer() as unknown as {
307
+ app: {
308
+ fetch: (request: Request) => Promise<Response> | Response;
309
+ };
310
+ session: unknown;
311
+ };
312
+ testServer.session = {
313
+ payload: {
314
+ run_id: "test-run-id",
315
+ task_id: "test-task-id",
316
+ team_id: 1,
317
+ user_id: 1,
318
+ distinct_id: "test-distinct-id",
319
+ mode: "interactive",
320
+ },
321
+ acpSessionId: "session-1",
322
+ acpConnection: { cleanup: vi.fn().mockResolvedValue(undefined) },
323
+ clientConnection: {},
324
+ sseController: null,
325
+ deviceInfo: { type: "cloud" },
326
+ logWriter: {
327
+ appendRawLine: vi.fn(),
328
+ flush: vi.fn().mockResolvedValue(undefined),
329
+ },
330
+ permissionMode: "default",
331
+ hasDesktopConnected: false,
332
+ };
333
+
307
334
  const token = createToken();
308
335
 
309
- const response = await fetch(`http://localhost:${port}/events`, {
310
- headers: { Authorization: `Bearer ${token}` },
311
- });
336
+ const response = await testServer.app.fetch(
337
+ new Request(`http://localhost:${port}/events`, {
338
+ headers: { Authorization: `Bearer ${token}` },
339
+ }),
340
+ );
312
341
 
313
342
  expect(response.status).toBe(200);
314
343
  expect(response.body).not.toBeNull();
@@ -341,6 +370,7 @@ describe("AgentServer HTTP Mode", () => {
341
370
  expect(streamText).not.toContain('"type":"keepalive"');
342
371
  } finally {
343
372
  await reader?.cancel();
373
+ server = undefined;
344
374
  setIntervalSpy.mockRestore();
345
375
  }
346
376
  }, 30000);