@nathapp/nax-agent-acp 0.92.5 → 0.92.6

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
@@ -3,6 +3,10 @@
3
3
  All notable changes to `@nathapp/nax-agent-acp` are recorded here. Versions move in
4
4
  step with `@nathapp/nax-agent`.
5
5
 
6
+ ## [0.92.6] - 2026-11-16
7
+
8
+ - No changes in this package. Released in lockstep with the other nax packages.
9
+
6
10
  ## [0.92.5] - 2026-11-15
7
11
 
8
12
  - No changes in this package. Released in lockstep with the other nax packages.
@@ -37,6 +37,7 @@ import { shellSandboxPlan } from "#src/client/shell-sandbox";
37
37
  import { createToolCalls } from "#src/client/tool-calls";
38
38
  import { createToolHost, newToolHostServerName, newToolHostToken } from "#src/client/tool-host";
39
39
  import { runPromptTurn } from "#src/client/turn";
40
+ import { TurnEndAbort } from "#src/client/turn-end-abort";
40
41
  import { createCostMeter } from "#src/client/usage";
41
42
  /** Test seam: the process launcher, the tool host factory and its server name. Production always uses launchAgent, createToolHost and newToolHostServerName. */
42
43
  export const _acpBackendDeps = {
@@ -140,7 +141,7 @@ async function connect(base, ctx, restore, retiredTokens, serverName) {
140
141
  const status = { disconnected: false };
141
142
  void acp.launched.exited.then(() => {
142
143
  status.disconnected = true;
143
- gone.abort();
144
+ gone.abort(new TurnEndAbort("the agent process exited"));
144
145
  });
145
146
  const state = {
146
147
  link: acp.link,
@@ -1,6 +1,7 @@
1
1
  import { getLogger } from "@nathapp/nax-agent";
2
2
  import { isDenial, rejectLocally } from "#src/client/permissions";
3
3
  import { isRecord } from "#src/client/text";
4
+ import { TurnEndAbort } from "#src/client/turn-end-abort";
4
5
  /** Concurrent permission requests and elicitations one turn may hold; further ones are answered locally. */
5
6
  export const MAX_PENDING_DECISIONS = 16;
6
7
  const LOG_MESSAGES = {
@@ -105,7 +106,7 @@ export function createInboundRouter(decide, elicit = cancelElicitation, ownTools
105
106
  return async () => {
106
107
  if (active === binding)
107
108
  active = undefined;
108
- scope.abort();
109
+ scope.abort(new TurnEndAbort("the ACP prompt turn ended"));
109
110
  await Promise.allSettled([...binding.pending]);
110
111
  };
111
112
  },
@@ -1,5 +1,6 @@
1
1
  import { ASK_CANCELLED_REASON, ASK_DENIED_REASON, ASK_NO_CHANNEL_REASON, ASK_PROFILE_REASON, ASK_TIMEOUT_REASON, ASK_UNSHOWABLE_REASON, capStrings, redactSecrets, } from "@nathapp/nax-agent";
2
2
  import { capBytes, scrubSecrets, stripControl, stripInvisible } from "#src/client/text";
3
+ import { abandonedText } from "#src/client/turn-end-abort";
3
4
  export const MAX_CONCURRENT_TOOL_CALLS = 8;
4
5
  /** Byte cap of an approval summary (native: EMBEDDER_SUMMARY_BYTES). */
5
6
  export const TOOL_SUMMARY_BYTES = 1024;
@@ -53,8 +54,8 @@ export function toolSummary(tool, input, secrets) {
53
54
  const visible = scrubSecrets(stripInvisible(stripControl(describeInput(tool, input))), secrets);
54
55
  return capBytes(visible.replace(/[\n\t]+/g, " ").trim(), TOOL_SUMMARY_BYTES);
55
56
  }
56
- function abandoned(name) {
57
- return textResult(`Tool "${name}" was abandoned: the turn ended.`, true);
57
+ function abandoned(name, signal) {
58
+ return textResult(abandonedText(name, signal), true);
58
59
  }
59
60
  function runSafely(tool, input, ctx) {
60
61
  return Promise.resolve()
@@ -66,10 +67,10 @@ function runSafely(tool, input, ctx) {
66
67
  /** Answers at once when the signal aborts: a run that ignores its signal is abandoned and its late result ignored. */
67
68
  async function invoke(tool, input, ctx) {
68
69
  if (ctx.signal.aborted)
69
- return abandoned(tool.name);
70
+ return abandoned(tool.name, ctx.signal);
70
71
  let onAbort = () => { };
71
72
  const aborted = new Promise((resolve) => {
72
- onAbort = () => resolve(abandoned(tool.name));
73
+ onAbort = () => resolve(abandoned(tool.name, ctx.signal));
73
74
  ctx.signal.addEventListener("abort", onAbort, { once: true });
74
75
  });
75
76
  try {
@@ -107,7 +108,7 @@ export function createToolCalls(deps) {
107
108
  const input = args ?? {};
108
109
  const ctx = { sessionId: deps.sessionId, toolCallId: `mcp-${accepted}`, signal };
109
110
  if (signal.aborted)
110
- return abandoned(tool.name);
111
+ return abandoned(tool.name, signal);
111
112
  const denied = await approve(deps, tool, input, ctx);
112
113
  return denied ?? invoke(tool, input, ctx);
113
114
  };
@@ -18,6 +18,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprot
18
18
  import { NaxError } from "@nathapp/nax-agent";
19
19
  import { TOOL_HOST_SERVER_NAME } from "#src/client/pre-approval";
20
20
  import { race } from "#src/client/race";
21
+ import { TurnEndAbort } from "#src/client/turn-end-abort";
21
22
  export const TOOL_HOST_PATH = "/mcp";
22
23
  export const MAX_BODY_BYTES = 1024 * 1024;
23
24
  /** Past this many body bytes the 413 is sent at once and the connection closed. */
@@ -104,7 +105,7 @@ async function serveMcp(state, req, res, body) {
104
105
  server.setRequestHandler(CallToolRequestSchema, (request) => state.calls.call(request.params.name, request.params.arguments, signal));
105
106
  const transport = new StreamableHTTPServerTransport({ enableJsonResponse: true });
106
107
  res.on("close", () => {
107
- gone.abort();
108
+ gone.abort(new TurnEndAbort("the agent closed the tool request"));
108
109
  void transport.close().catch(() => undefined);
109
110
  void server.close().catch(() => undefined);
110
111
  });
@@ -190,7 +191,7 @@ export function createToolHost(calls, token = newToolHostToken(), opts = {}) {
190
191
  },
191
192
  drain: () => calls.drain(),
192
193
  stop() {
193
- state.stopped.abort();
194
+ state.stopped.abort(new TurnEndAbort("the tool host stopped"));
194
195
  stopping ??= close(http);
195
196
  return stopping;
196
197
  },
@@ -0,0 +1,31 @@
1
+ /**
2
+ * US-004: the reasons this package gives for its own turn ends, and the
3
+ * abandoned-tool text they produce.
4
+ *
5
+ * nax-agent keeps the same pair (`session/turn-end-abort.ts`,
6
+ * `abandonedToolMessage`), but neither is exported from its public entry, so
7
+ * this package carries its own copies. `TurnEndAbort` keeps the AbortError
8
+ * contract (a NAME, as nax-agent's does): a bare `abort()` already produces a
9
+ * runtime `DOMException` with that name, so a distinguishable reason cannot be
10
+ * a different name — it is a nax-owned class whose name keeps the contract and
11
+ * whose message says WHY the turn ended.
12
+ */
13
+ /** A turn end this package caused: name kept, message names the reason. */
14
+ export declare class TurnEndAbort extends Error {
15
+ readonly name = "AbortError";
16
+ }
17
+ /**
18
+ * The text the agent receives for an abandoned embedder tool call.
19
+ *
20
+ * The reason is only observable once the signal has aborted, so this is
21
+ * evaluated at abandonment time, never before the race. `AbortSignal.any` keeps
22
+ * the reason of the source that aborted first, so a caller's own cancel or
23
+ * timeout reason wins over this package's turn-end reason when it fires first.
24
+ *
25
+ * - a `NaxError` reason names its code and message (a session cancel, the turn
26
+ * deadline, a stalled consumer);
27
+ * - this package's `TurnEndAbort` names its message alone (no error code);
28
+ * - anything else — a bare `abort()`, a runtime `DOMException`, an unrelated
29
+ * error — keeps the text that says only that the turn ended.
30
+ */
31
+ export declare function abandonedText(name: string, signal: AbortSignal): string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * US-004: the reasons this package gives for its own turn ends, and the
3
+ * abandoned-tool text they produce.
4
+ *
5
+ * nax-agent keeps the same pair (`session/turn-end-abort.ts`,
6
+ * `abandonedToolMessage`), but neither is exported from its public entry, so
7
+ * this package carries its own copies. `TurnEndAbort` keeps the AbortError
8
+ * contract (a NAME, as nax-agent's does): a bare `abort()` already produces a
9
+ * runtime `DOMException` with that name, so a distinguishable reason cannot be
10
+ * a different name — it is a nax-owned class whose name keeps the contract and
11
+ * whose message says WHY the turn ended.
12
+ */
13
+ import { NaxError } from "@nathapp/nax-agent";
14
+ /** A turn end this package caused: name kept, message names the reason. */
15
+ export class TurnEndAbort extends Error {
16
+ name = "AbortError";
17
+ }
18
+ /**
19
+ * The text the agent receives for an abandoned embedder tool call.
20
+ *
21
+ * The reason is only observable once the signal has aborted, so this is
22
+ * evaluated at abandonment time, never before the race. `AbortSignal.any` keeps
23
+ * the reason of the source that aborted first, so a caller's own cancel or
24
+ * timeout reason wins over this package's turn-end reason when it fires first.
25
+ *
26
+ * - a `NaxError` reason names its code and message (a session cancel, the turn
27
+ * deadline, a stalled consumer);
28
+ * - this package's `TurnEndAbort` names its message alone (no error code);
29
+ * - anything else — a bare `abort()`, a runtime `DOMException`, an unrelated
30
+ * error — keeps the text that says only that the turn ended.
31
+ */
32
+ export function abandonedText(name, signal) {
33
+ const base = `Tool "${name}" was abandoned: the turn ended`;
34
+ const reason = signal.reason;
35
+ if (reason instanceof NaxError)
36
+ return `${base} (${reason.code}: ${reason.message}).`;
37
+ if (reason instanceof TurnEndAbort)
38
+ return `${base} (${reason.message}).`;
39
+ return `${base}.`;
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nax-agent-acp",
3
- "version": "0.92.5",
3
+ "version": "0.92.6",
4
4
  "description": "ACP (Agent Client Protocol) backend for @nathapp/nax-agent sessions: drive Claude Code and other ACP agents through the nax-agent session API.",
5
5
  "license": "MIT",
6
6
  "author": "William Khoo",
@@ -49,7 +49,7 @@
49
49
  "zod": "^4.6.6"
50
50
  },
51
51
  "peerDependencies": {
52
- "@nathapp/nax-agent": "^0.92.5"
52
+ "@nathapp/nax-agent": "^0.92.6"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public",