@posthog/agent 2.3.474 → 2.3.502
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 +3 -3
- 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 +21 -3
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +21 -3
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/claude-agent.ts +2 -2
- package/src/server/agent-server.test.ts +29 -0
- package/src/server/agent-server.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/agent",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.502",
|
|
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": {
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
"tsx": "^4.20.6",
|
|
103
103
|
"typescript": "^5.5.0",
|
|
104
104
|
"vitest": "^2.1.8",
|
|
105
|
-
"@posthog/
|
|
105
|
+
"@posthog/shared": "1.0.0",
|
|
106
106
|
"@posthog/git": "1.0.0",
|
|
107
|
-
"@posthog/
|
|
107
|
+
"@posthog/enricher": "1.0.0"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
110
|
"@agentclientprotocol/sdk": "0.19.0",
|
|
@@ -1309,7 +1309,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
1309
1309
|
const configOptions = this.buildConfigOptions(
|
|
1310
1310
|
permissionMode,
|
|
1311
1311
|
modelOptions,
|
|
1312
|
-
effort ?? "
|
|
1312
|
+
effort ?? "medium",
|
|
1313
1313
|
);
|
|
1314
1314
|
session.configOptions = configOptions;
|
|
1315
1315
|
|
|
@@ -1406,7 +1406,7 @@ export class ClaudeAcpAgent extends BaseAcpAgent {
|
|
|
1406
1406
|
currentModelId: string;
|
|
1407
1407
|
options: SessionConfigSelectOption[];
|
|
1408
1408
|
},
|
|
1409
|
-
currentEffort: EffortLevel = "
|
|
1409
|
+
currentEffort: EffortLevel = "medium",
|
|
1410
1410
|
): SessionConfigOption[] {
|
|
1411
1411
|
const modeOptions = getAvailableModes().map((mode) => ({
|
|
1412
1412
|
value: mode.id,
|
|
@@ -382,6 +382,35 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
382
382
|
}, 20000);
|
|
383
383
|
});
|
|
384
384
|
|
|
385
|
+
describe("session lifecycle", () => {
|
|
386
|
+
it("emits _posthog/run_started after session initialization", async () => {
|
|
387
|
+
await createServer().start();
|
|
388
|
+
|
|
389
|
+
// The notification is persisted via `logWriter.appendRawLine` which the
|
|
390
|
+
// mock backend's append_log handler captures into `appendLogCalls`.
|
|
391
|
+
await vi.waitFor(
|
|
392
|
+
() => {
|
|
393
|
+
const allEntries = appendLogCalls.flat() as Array<{
|
|
394
|
+
type?: string;
|
|
395
|
+
notification?: {
|
|
396
|
+
method?: string;
|
|
397
|
+
params?: Record<string, unknown>;
|
|
398
|
+
};
|
|
399
|
+
}>;
|
|
400
|
+
const runStarted = allEntries.find(
|
|
401
|
+
(e) => e?.notification?.method === "_posthog/run_started",
|
|
402
|
+
);
|
|
403
|
+
expect(runStarted).toBeDefined();
|
|
404
|
+
expect(runStarted?.notification?.params).toMatchObject({
|
|
405
|
+
runId: "test-run-id",
|
|
406
|
+
taskId: "test-task-id",
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
{ timeout: 15000, interval: 100 },
|
|
410
|
+
);
|
|
411
|
+
}, 30000);
|
|
412
|
+
});
|
|
413
|
+
|
|
385
414
|
describe("getInitialPromptOverride", () => {
|
|
386
415
|
it("returns override string from run state", () => {
|
|
387
416
|
const s = createServer();
|
|
@@ -958,6 +958,29 @@ export class AgentServer {
|
|
|
958
958
|
await logAgentshRuntimeInfo(this.logger);
|
|
959
959
|
this.logger.debug(`Initial permission mode: ${initialPermissionMode}`);
|
|
960
960
|
|
|
961
|
+
// Lifecycle handshake: clients gate "agent is ready to accept user
|
|
962
|
+
// messages" on this notification. Persisted to the session log so
|
|
963
|
+
// warm reconnects (sandbox restart with snapshot resume) replay it
|
|
964
|
+
// and see the agent come online again.
|
|
965
|
+
const runStartedNotification = {
|
|
966
|
+
jsonrpc: "2.0" as const,
|
|
967
|
+
method: POSTHOG_NOTIFICATIONS.RUN_STARTED,
|
|
968
|
+
params: {
|
|
969
|
+
sessionId: acpSessionId,
|
|
970
|
+
runId: payload.run_id,
|
|
971
|
+
taskId: payload.task_id,
|
|
972
|
+
},
|
|
973
|
+
};
|
|
974
|
+
this.broadcastEvent({
|
|
975
|
+
type: "notification",
|
|
976
|
+
timestamp: new Date().toISOString(),
|
|
977
|
+
notification: runStartedNotification,
|
|
978
|
+
});
|
|
979
|
+
this.session.logWriter.appendRawLine(
|
|
980
|
+
payload.run_id,
|
|
981
|
+
JSON.stringify(runStartedNotification),
|
|
982
|
+
);
|
|
983
|
+
|
|
961
984
|
// Signal in_progress so the UI can start polling for updates
|
|
962
985
|
this.posthogAPI
|
|
963
986
|
.updateTaskRun(payload.task_id, payload.run_id, {
|