@nyssance/codex-acp-v2 0.7.1 → 0.7.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2 — 2026-09-29
4
+
5
+ ### Added
6
+
7
+ - Turn correlation v2 (`capabilities._meta.alwith.turns = {version: 2}`): `session/prompt`
8
+ accepts a host-named receipt in `_meta.alwith.messageId`, and every `state_update` of a
9
+ prompted turn carries `_meta.alwith.messageId`. A stale `idle` of an older turn is dropped
10
+ once a newer prompt owns the session.
11
+
3
12
  ## 0.7.1 — 2026-09-29
4
13
 
5
14
  ### Changed
package/dist/index.js CHANGED
@@ -21844,7 +21844,7 @@ var package_default = {
21844
21844
  publishConfig: {
21845
21845
  access: "public"
21846
21846
  },
21847
- version: "0.7.1",
21847
+ version: "0.7.2",
21848
21848
  description: "Native ACP v2 agent for the OpenAI Codex app-server",
21849
21849
  packageManager: "bun@1.4.0",
21850
21850
  engines: {
@@ -25963,6 +25963,7 @@ class ClientSession {
25963
25963
  disposed = false;
25964
25964
  output = new AbortController;
25965
25965
  terminalAttempted = false;
25966
+ messageId;
25966
25967
  get signal() {
25967
25968
  return this.output.signal;
25968
25969
  }
@@ -26006,26 +26007,36 @@ class ClientSession {
26006
26007
  return;
26007
26008
  await abortable(this.link.notify(methods.client.elicitation.complete, { elicitationId }), this.output.signal);
26008
26009
  }
26009
- reportRunning() {
26010
+ reportRunning(messageId) {
26011
+ this.messageId = messageId;
26010
26012
  this.terminalAttempted = false;
26011
26013
  this.turnGeneration += 1;
26012
26014
  this.turnActive = true;
26013
26015
  this.waiting = 0;
26014
26016
  this.state({ sessionUpdate: "state_update", state: "running" });
26015
26017
  }
26016
- async reportIdle(stopReason, extra) {
26018
+ async reportIdle(stopReason, extra, messageId = this.messageId) {
26019
+ if (messageId !== this.messageId)
26020
+ return;
26017
26021
  if (this.terminalAttempted)
26018
26022
  return;
26019
26023
  this.terminalAttempted = true;
26020
26024
  this.turnActive = false;
26021
26025
  this.waiting = 0;
26022
- await this.update({
26026
+ await this.update(this.correlated({
26023
26027
  sessionUpdate: "state_update",
26024
26028
  state: "idle",
26025
26029
  stopReason,
26026
26030
  ...extra?.usage === undefined ? {} : { usage: extra.usage },
26027
26031
  ...extra?._meta === undefined ? {} : { _meta: extra._meta }
26028
- });
26032
+ }));
26033
+ }
26034
+ correlated(update) {
26035
+ if (this.messageId === undefined)
26036
+ return update;
26037
+ const meta = update._meta;
26038
+ const alwith = meta?.["alwith"];
26039
+ return { ...update, _meta: { ...meta, alwith: { ...alwith, messageId: this.messageId } } };
26029
26040
  }
26030
26041
  async waitingOnClient(operation, signal) {
26031
26042
  if (this.disposed)
@@ -26046,7 +26057,7 @@ class ClientSession {
26046
26057
  }
26047
26058
  async state(update) {
26048
26059
  try {
26049
- await this.update(update);
26060
+ await this.update(this.correlated(update));
26050
26061
  } catch (error40) {
26051
26062
  logger.error("Failed to publish session state", error40, { sessionId: this.sessionId });
26052
26063
  }
@@ -26776,7 +26787,7 @@ class CodexAgent {
26776
26787
  additionalDirectories: {}
26777
26788
  },
26778
26789
  providers: {},
26779
- _meta: { alwith: { tools: { version: 1 } }, codex: { archive: true, seedHistory: true, skills: true, plugins: true, providerCatalog: true, rename: true, account: true, fuzzyFileSearch: true } }
26790
+ _meta: { alwith: { tools: { version: 1 }, turns: { version: 2 } }, codex: { archive: true, seedHistory: true, skills: true, plugins: true, providerCatalog: true, rename: true, account: true, fuzzyFileSearch: true } }
26780
26791
  },
26781
26792
  authMethods: authMethods(this.capabilities, this.env)
26782
26793
  };
@@ -27533,7 +27544,7 @@ class CodexAgent {
27533
27544
  return runtime;
27534
27545
  }
27535
27546
  async prompt(params) {
27536
- return await this.promptInternal(params, false, crypto.randomUUID());
27547
+ return await this.promptInternal(params, false, requestedMessageId(params) ?? crypto.randomUUID());
27537
27548
  }
27538
27549
  async promptInternal(params, allowReentry, messageId) {
27539
27550
  this.assertRoutingAvailable();
@@ -27557,7 +27568,7 @@ class CodexAgent {
27557
27568
  }
27558
27569
  const turn = createActiveTurn(session.id, messageId);
27559
27570
  session.activeTurn = turn;
27560
- runtime.client.reportRunning();
27571
+ runtime.client.reportRunning(messageId);
27561
27572
  this.runPrompt(runtime, turn, params);
27562
27573
  return { messageId };
27563
27574
  }
@@ -27781,7 +27792,7 @@ class CodexAgent {
27781
27792
  await runtime.bridge.finishOpenToolCalls(reason === "cancelled" ? "cancelled" : reason === "end_turn" ? "completed" : "failed");
27782
27793
  if (runtime.session.activeTurn === turn)
27783
27794
  runtime.session.activeTurn = null;
27784
- await runtime.client.reportIdle(reason, extra);
27795
+ await runtime.client.reportIdle(reason, extra, turn.clientUserMessageId ?? undefined);
27785
27796
  }
27786
27797
  async reportTurnFailure(runtime, turn, error40) {
27787
27798
  const { stopReason, ...classification } = classifyTurnError(error40.codexErrorInfo);
@@ -27966,6 +27977,15 @@ ${stderr}` : ""}`);
27966
27977
  function mcpServerNames(servers) {
27967
27978
  return servers.flatMap((server) => typeof server.name === "string" ? [sanitizeMcpServerName(server.name)] : []);
27968
27979
  }
27980
+ function requestedMessageId(params) {
27981
+ const alwith = params._meta?.["alwith"];
27982
+ if (alwith?.messageId === undefined)
27983
+ return;
27984
+ if (typeof alwith.messageId !== "string" || alwith.messageId.length === 0) {
27985
+ throw RequestError.invalidParams(undefined, "_meta.alwith.messageId must be a non-empty string");
27986
+ }
27987
+ return alwith.messageId;
27988
+ }
27969
27989
  function agentMessage(messageId, text2) {
27970
27990
  return { sessionUpdate: "agent_message_chunk", messageId, content: { type: "text", text: text2 } };
27971
27991
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.7.1",
6
+ "version": "0.7.2",
7
7
  "description": "Native ACP v2 agent for the OpenAI Codex app-server",
8
8
  "packageManager": "bun@1.4.0",
9
9
  "engines": {