@posthog/agent 2.3.425 → 2.3.443
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 +1 -1
- 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 +14 -9
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +14 -9
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/server/agent-server.test.ts +38 -0
- package/src/server/agent-server.ts +15 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/agent",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.443",
|
|
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": {
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
"typescript": "^5.5.0",
|
|
104
104
|
"vitest": "^2.1.8",
|
|
105
105
|
"@posthog/shared": "1.0.0",
|
|
106
|
-
"@posthog/
|
|
107
|
-
"@posthog/
|
|
106
|
+
"@posthog/git": "1.0.0",
|
|
107
|
+
"@posthog/enricher": "1.0.0"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
110
|
"@agentclientprotocol/sdk": "0.19.0",
|
|
@@ -202,6 +202,44 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
202
202
|
}, 30000);
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
+
describe("turn completion", () => {
|
|
206
|
+
it("persists structured turn completion notifications", () => {
|
|
207
|
+
const appendRawLine = vi.fn();
|
|
208
|
+
const testServer = new AgentServer({
|
|
209
|
+
port,
|
|
210
|
+
jwtPublicKey: TEST_PUBLIC_KEY,
|
|
211
|
+
repositoryPath: repo.path,
|
|
212
|
+
apiUrl: "http://localhost:8000",
|
|
213
|
+
apiKey: "test-api-key",
|
|
214
|
+
projectId: 1,
|
|
215
|
+
mode: "interactive",
|
|
216
|
+
taskId: "test-task-id",
|
|
217
|
+
runId: "test-run-id",
|
|
218
|
+
}) as unknown as {
|
|
219
|
+
session: unknown;
|
|
220
|
+
broadcastTurnComplete(stopReason: string): void;
|
|
221
|
+
};
|
|
222
|
+
testServer.session = {
|
|
223
|
+
acpSessionId: "session-1",
|
|
224
|
+
payload: { run_id: "run-1" },
|
|
225
|
+
logWriter: { appendRawLine },
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
testServer.broadcastTurnComplete("end_turn");
|
|
229
|
+
|
|
230
|
+
expect(appendRawLine).toHaveBeenCalledTimes(1);
|
|
231
|
+
expect(appendRawLine.mock.calls[0][0]).toBe("run-1");
|
|
232
|
+
expect(JSON.parse(appendRawLine.mock.calls[0][1])).toEqual({
|
|
233
|
+
jsonrpc: "2.0",
|
|
234
|
+
method: "_posthog/turn_complete",
|
|
235
|
+
params: {
|
|
236
|
+
sessionId: "session-1",
|
|
237
|
+
stopReason: "end_turn",
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
205
243
|
describe("GET /events", () => {
|
|
206
244
|
it("returns 401 without authorization header", async () => {
|
|
207
245
|
await createServer().start();
|
|
@@ -2226,18 +2226,25 @@ ${attributionInstructions}
|
|
|
2226
2226
|
|
|
2227
2227
|
private broadcastTurnComplete(stopReason: string): void {
|
|
2228
2228
|
if (!this.session) return;
|
|
2229
|
+
const notification = {
|
|
2230
|
+
jsonrpc: "2.0",
|
|
2231
|
+
method: POSTHOG_NOTIFICATIONS.TURN_COMPLETE,
|
|
2232
|
+
params: {
|
|
2233
|
+
sessionId: this.session.acpSessionId,
|
|
2234
|
+
stopReason,
|
|
2235
|
+
},
|
|
2236
|
+
};
|
|
2237
|
+
|
|
2229
2238
|
this.broadcastEvent({
|
|
2230
2239
|
type: "notification",
|
|
2231
2240
|
timestamp: new Date().toISOString(),
|
|
2232
|
-
notification
|
|
2233
|
-
jsonrpc: "2.0",
|
|
2234
|
-
method: POSTHOG_NOTIFICATIONS.TURN_COMPLETE,
|
|
2235
|
-
params: {
|
|
2236
|
-
sessionId: this.session.acpSessionId,
|
|
2237
|
-
stopReason,
|
|
2238
|
-
},
|
|
2239
|
-
},
|
|
2241
|
+
notification,
|
|
2240
2242
|
});
|
|
2243
|
+
|
|
2244
|
+
this.session.logWriter.appendRawLine(
|
|
2245
|
+
this.session.payload.run_id,
|
|
2246
|
+
JSON.stringify(notification),
|
|
2247
|
+
);
|
|
2241
2248
|
}
|
|
2242
2249
|
|
|
2243
2250
|
private broadcastEvent(event: Record<string, unknown>): void {
|