@posthog/agent 2.3.304 → 2.3.305
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 +10 -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 +10 -1
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +10 -1
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/codex/codex-agent.test.ts +42 -0
- package/src/adapters/codex/codex-agent.ts +14 -0
package/package.json
CHANGED
|
@@ -107,6 +107,48 @@ describe("CodexAcpAgent", () => {
|
|
|
107
107
|
).toBe("read-only");
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
it("propagates taskRunId and fires SDK_SESSION when loading a cloud session", async () => {
|
|
111
|
+
const { agent, client } = createAgent();
|
|
112
|
+
mockCodexConnection.loadSession.mockResolvedValue({
|
|
113
|
+
modes: { currentModeId: "auto", availableModes: [] },
|
|
114
|
+
configOptions: [],
|
|
115
|
+
} satisfies Partial<LoadSessionResponse>);
|
|
116
|
+
|
|
117
|
+
await agent.loadSession({
|
|
118
|
+
sessionId: "session-1",
|
|
119
|
+
cwd: process.cwd(),
|
|
120
|
+
_meta: { taskRunId: "run-1", taskId: "task-1" },
|
|
121
|
+
} as never);
|
|
122
|
+
|
|
123
|
+
expect(
|
|
124
|
+
(agent as unknown as { sessionState: { taskRunId?: string } })
|
|
125
|
+
.sessionState.taskRunId,
|
|
126
|
+
).toBe("run-1");
|
|
127
|
+
expect(client.extNotification).toHaveBeenCalledWith(
|
|
128
|
+
"_posthog/sdk_session",
|
|
129
|
+
{
|
|
130
|
+
taskRunId: "run-1",
|
|
131
|
+
sessionId: "session-1",
|
|
132
|
+
adapter: "codex",
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("does not emit SDK_SESSION on loadSession when taskRunId is absent", async () => {
|
|
138
|
+
const { agent, client } = createAgent();
|
|
139
|
+
mockCodexConnection.loadSession.mockResolvedValue({
|
|
140
|
+
modes: { currentModeId: "auto", availableModes: [] },
|
|
141
|
+
configOptions: [],
|
|
142
|
+
} satisfies Partial<LoadSessionResponse>);
|
|
143
|
+
|
|
144
|
+
await agent.loadSession({
|
|
145
|
+
sessionId: "session-1",
|
|
146
|
+
cwd: process.cwd(),
|
|
147
|
+
} as never);
|
|
148
|
+
|
|
149
|
+
expect(client.extNotification).not.toHaveBeenCalled();
|
|
150
|
+
});
|
|
151
|
+
|
|
110
152
|
it("preserves the live session mode when loading an existing session", async () => {
|
|
111
153
|
const { agent } = createAgent();
|
|
112
154
|
mockCodexConnection.loadSession.mockResolvedValue({
|
|
@@ -267,13 +267,27 @@ export class CodexAcpAgent extends BaseAcpAgent {
|
|
|
267
267
|
meta?.permissionMode,
|
|
268
268
|
);
|
|
269
269
|
|
|
270
|
+
// Carry taskRunId/taskId across load so prompt() still emits cloud
|
|
271
|
+
// notifications (TURN_COMPLETE, USAGE_UPDATE) after a reload. newSession
|
|
272
|
+
// and unstable_resumeSession both do this; loadSession historically did
|
|
273
|
+
// not, which silently broke task-completion tracking on re-attach.
|
|
270
274
|
this.sessionState = createSessionState(params.sessionId, params.cwd, {
|
|
275
|
+
taskRunId: meta?.taskRunId,
|
|
276
|
+
taskId: meta?.taskId ?? meta?.persistence?.taskId,
|
|
271
277
|
modeId: response.modes?.currentModeId ?? "auto",
|
|
272
278
|
permissionMode: currentPermissionMode,
|
|
273
279
|
});
|
|
274
280
|
this.sessionId = params.sessionId;
|
|
275
281
|
this.sessionState.configOptions = response.configOptions ?? [];
|
|
276
282
|
|
|
283
|
+
if (meta?.taskRunId) {
|
|
284
|
+
await this.client.extNotification(POSTHOG_NOTIFICATIONS.SDK_SESSION, {
|
|
285
|
+
taskRunId: meta.taskRunId,
|
|
286
|
+
sessionId: params.sessionId,
|
|
287
|
+
adapter: "codex",
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
277
291
|
return response;
|
|
278
292
|
}
|
|
279
293
|
|