@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/server/bin.cjs
CHANGED
|
@@ -5805,7 +5805,7 @@ var import_hono = require("hono");
|
|
|
5805
5805
|
// package.json
|
|
5806
5806
|
var package_default = {
|
|
5807
5807
|
name: "@posthog/agent",
|
|
5808
|
-
version: "2.3.
|
|
5808
|
+
version: "2.3.306",
|
|
5809
5809
|
repository: "https://github.com/PostHog/code",
|
|
5810
5810
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
5811
5811
|
exports: {
|
|
@@ -10370,6 +10370,17 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
10370
10370
|
codexProcess;
|
|
10371
10371
|
codexConnection;
|
|
10372
10372
|
sessionState;
|
|
10373
|
+
/**
|
|
10374
|
+
* FIFO serializer for prompt() calls. codex-acp and codex-rs themselves
|
|
10375
|
+
* serialize submissions at the conversation level, but our adapter
|
|
10376
|
+
* accumulates per-turn usage into sessionState.accumulatedUsage via the
|
|
10377
|
+
* codex-client sessionUpdate handler. If two prompts ran concurrently on
|
|
10378
|
+
* the JS side, the second's resetUsage() would wipe out the first's
|
|
10379
|
+
* in-flight counters and both TURN_COMPLETE notifications would report
|
|
10380
|
+
* garbled totals. Serializing on the JS side keeps the accumulator
|
|
10381
|
+
* single-owner.
|
|
10382
|
+
*/
|
|
10383
|
+
promptMutex = Promise.resolve();
|
|
10373
10384
|
constructor(client, options) {
|
|
10374
10385
|
super(client);
|
|
10375
10386
|
this.logger = new Logger({ debug: true, prefix: "[CodexAcpAgent]" });
|
|
@@ -10461,11 +10472,20 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
10461
10472
|
meta?.permissionMode
|
|
10462
10473
|
);
|
|
10463
10474
|
this.sessionState = createSessionState(params.sessionId, params.cwd, {
|
|
10475
|
+
taskRunId: meta?.taskRunId,
|
|
10476
|
+
taskId: meta?.taskId ?? meta?.persistence?.taskId,
|
|
10464
10477
|
modeId: response.modes?.currentModeId ?? "auto",
|
|
10465
10478
|
permissionMode: currentPermissionMode
|
|
10466
10479
|
});
|
|
10467
10480
|
this.sessionId = params.sessionId;
|
|
10468
10481
|
this.sessionState.configOptions = response.configOptions ?? [];
|
|
10482
|
+
if (meta?.taskRunId) {
|
|
10483
|
+
await this.client.extNotification(POSTHOG_NOTIFICATIONS.SDK_SESSION, {
|
|
10484
|
+
taskRunId: meta.taskRunId,
|
|
10485
|
+
sessionId: params.sessionId,
|
|
10486
|
+
adapter: "codex"
|
|
10487
|
+
});
|
|
10488
|
+
}
|
|
10469
10489
|
return response;
|
|
10470
10490
|
}
|
|
10471
10491
|
async unstable_resumeSession(params) {
|
|
@@ -10547,6 +10567,13 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
10547
10567
|
return this.listSessions(params);
|
|
10548
10568
|
}
|
|
10549
10569
|
async prompt(params) {
|
|
10570
|
+
const previous = this.promptMutex;
|
|
10571
|
+
const next = previous.catch(() => {
|
|
10572
|
+
}).then(() => this.runPrompt(params));
|
|
10573
|
+
this.promptMutex = next;
|
|
10574
|
+
return next;
|
|
10575
|
+
}
|
|
10576
|
+
async runPrompt(params) {
|
|
10550
10577
|
this.session.cancelled = false;
|
|
10551
10578
|
this.session.interruptReason = void 0;
|
|
10552
10579
|
resetUsage(this.sessionState);
|