@posthog/agent 2.3.304 → 2.3.306
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 +28 -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 +28 -1
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +28 -1
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/codex/codex-agent.test.ts +128 -0
- package/src/adapters/codex/codex-agent.ts +32 -0
package/dist/agent.js
CHANGED
|
@@ -245,7 +245,7 @@ import { v7 as uuidv7 } from "uuid";
|
|
|
245
245
|
// package.json
|
|
246
246
|
var package_default = {
|
|
247
247
|
name: "@posthog/agent",
|
|
248
|
-
version: "2.3.
|
|
248
|
+
version: "2.3.306",
|
|
249
249
|
repository: "https://github.com/PostHog/code",
|
|
250
250
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
251
251
|
exports: {
|
|
@@ -4706,6 +4706,17 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
4706
4706
|
codexProcess;
|
|
4707
4707
|
codexConnection;
|
|
4708
4708
|
sessionState;
|
|
4709
|
+
/**
|
|
4710
|
+
* FIFO serializer for prompt() calls. codex-acp and codex-rs themselves
|
|
4711
|
+
* serialize submissions at the conversation level, but our adapter
|
|
4712
|
+
* accumulates per-turn usage into sessionState.accumulatedUsage via the
|
|
4713
|
+
* codex-client sessionUpdate handler. If two prompts ran concurrently on
|
|
4714
|
+
* the JS side, the second's resetUsage() would wipe out the first's
|
|
4715
|
+
* in-flight counters and both TURN_COMPLETE notifications would report
|
|
4716
|
+
* garbled totals. Serializing on the JS side keeps the accumulator
|
|
4717
|
+
* single-owner.
|
|
4718
|
+
*/
|
|
4719
|
+
promptMutex = Promise.resolve();
|
|
4709
4720
|
constructor(client, options) {
|
|
4710
4721
|
super(client);
|
|
4711
4722
|
this.logger = new Logger({ debug: true, prefix: "[CodexAcpAgent]" });
|
|
@@ -4797,11 +4808,20 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
4797
4808
|
meta?.permissionMode
|
|
4798
4809
|
);
|
|
4799
4810
|
this.sessionState = createSessionState(params.sessionId, params.cwd, {
|
|
4811
|
+
taskRunId: meta?.taskRunId,
|
|
4812
|
+
taskId: meta?.taskId ?? meta?.persistence?.taskId,
|
|
4800
4813
|
modeId: response.modes?.currentModeId ?? "auto",
|
|
4801
4814
|
permissionMode: currentPermissionMode
|
|
4802
4815
|
});
|
|
4803
4816
|
this.sessionId = params.sessionId;
|
|
4804
4817
|
this.sessionState.configOptions = response.configOptions ?? [];
|
|
4818
|
+
if (meta?.taskRunId) {
|
|
4819
|
+
await this.client.extNotification(POSTHOG_NOTIFICATIONS.SDK_SESSION, {
|
|
4820
|
+
taskRunId: meta.taskRunId,
|
|
4821
|
+
sessionId: params.sessionId,
|
|
4822
|
+
adapter: "codex"
|
|
4823
|
+
});
|
|
4824
|
+
}
|
|
4805
4825
|
return response;
|
|
4806
4826
|
}
|
|
4807
4827
|
async unstable_resumeSession(params) {
|
|
@@ -4883,6 +4903,13 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
4883
4903
|
return this.listSessions(params);
|
|
4884
4904
|
}
|
|
4885
4905
|
async prompt(params) {
|
|
4906
|
+
const previous = this.promptMutex;
|
|
4907
|
+
const next = previous.catch(() => {
|
|
4908
|
+
}).then(() => this.runPrompt(params));
|
|
4909
|
+
this.promptMutex = next;
|
|
4910
|
+
return next;
|
|
4911
|
+
}
|
|
4912
|
+
async runPrompt(params) {
|
|
4886
4913
|
this.session.cancelled = false;
|
|
4887
4914
|
this.session.interruptReason = void 0;
|
|
4888
4915
|
resetUsage(this.sessionState);
|