@posthog/agent 2.3.418 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "2.3.418",
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/enricher": "1.0.0",
107
- "@posthog/git": "1.0.0"
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 {
@@ -37,12 +37,12 @@ describe("agentsh runtime detection", () => {
37
37
  {
38
38
  name: "returns the agentsh session id and version",
39
39
  getVersion: async () => ({
40
- stdout: "agentsh version 0.16.7\n",
40
+ stdout: "agentsh version 0.18.3\n",
41
41
  stderr: "",
42
42
  }),
43
43
  expected: {
44
44
  sessionId: "session-123",
45
- version: "agentsh version 0.16.7",
45
+ version: "agentsh version 0.18.3",
46
46
  },
47
47
  },
48
48
  {
@@ -71,7 +71,7 @@ describe("agentsh runtime detection", () => {
71
71
  await logAgentshRuntimeInfo(logger, {
72
72
  readSessionId: async () => "session-123\n",
73
73
  getVersion: async () => ({
74
- stdout: "agentsh version 0.16.7\n",
74
+ stdout: "agentsh version 0.18.3\n",
75
75
  stderr: "",
76
76
  }),
77
77
  });
@@ -80,7 +80,7 @@ describe("agentsh runtime detection", () => {
80
80
  "Agentsh session ID: session-123",
81
81
  );
82
82
  expect(logger.debug).toHaveBeenCalledWith(
83
- "Agentsh hardening version: agentsh version 0.16.7",
83
+ "Agentsh hardening version: agentsh version 0.18.3",
84
84
  );
85
85
  });
86
86