@posthog/agent 2.3.547 → 2.3.556
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/dist/agent.js +42 -2
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +42 -2
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +42 -2
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/session/options.ts +8 -0
- package/src/server/agent-server.test.ts +34 -4
package/package.json
CHANGED
|
@@ -102,6 +102,12 @@ function buildMcpServers(
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
function buildEnvironment(): Record<string, string> {
|
|
105
|
+
const bedrockFallbackHeader = "x-posthog-use-bedrock-fallback: true";
|
|
106
|
+
const existingCustomHeaders = process.env.ANTHROPIC_CUSTOM_HEADERS;
|
|
107
|
+
const customHeaders = existingCustomHeaders
|
|
108
|
+
? `${existingCustomHeaders}\n${bedrockFallbackHeader}`
|
|
109
|
+
: bedrockFallbackHeader;
|
|
110
|
+
|
|
105
111
|
return {
|
|
106
112
|
...process.env,
|
|
107
113
|
ELECTRON_RUN_AS_NODE: "1",
|
|
@@ -110,6 +116,8 @@ function buildEnvironment(): Record<string, string> {
|
|
|
110
116
|
ENABLE_TOOL_SEARCH: "auto:0",
|
|
111
117
|
// Enable idle state as end-of-turn signal (required for SDK 0.2.114+)
|
|
112
118
|
CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1",
|
|
119
|
+
// Route to AWS Bedrock as a fallback when Anthropic returns 5xx
|
|
120
|
+
ANTHROPIC_CUSTOM_HEADERS: customHeaders,
|
|
113
121
|
};
|
|
114
122
|
}
|
|
115
123
|
|
|
@@ -303,12 +303,41 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
303
303
|
|
|
304
304
|
let reader: ReadableStreamDefaultReader<Uint8Array> | null = null;
|
|
305
305
|
try {
|
|
306
|
-
|
|
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(
|
|
310
|
-
|
|
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);
|