@posthog/agent 2.3.466 → 2.3.478
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 -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 +21 -1
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +21 -1
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/session/instructions.ts +2 -0
- package/src/server/agent-server.test.ts +29 -0
- package/src/server/agent-server.ts +23 -0
package/package.json
CHANGED
|
@@ -2,6 +2,8 @@ const BRANCH_NAMING = `
|
|
|
2
2
|
# Branch Naming
|
|
3
3
|
|
|
4
4
|
When working in a detached HEAD state, create a descriptive branch name based on the work being done before committing. Do this automatically without asking the user.
|
|
5
|
+
|
|
6
|
+
When creating a new branch, prefix it with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`).
|
|
5
7
|
`;
|
|
6
8
|
|
|
7
9
|
const PLAN_MODE = `
|
|
@@ -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, {
|