@agentclientprotocol/claude-agent-acp 0.54.1 → 0.56.0

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.
@@ -384,9 +384,25 @@ export declare class ClaudeAcpAgent {
384
384
  * `canUseTool` since that is where the SDK routes the tool's permission check.
385
385
  */
386
386
  private handleAskUserQuestion;
387
+ /**
388
+ * Handle `request_user_dialog` control requests — blocking dialogs the CLI
389
+ * asks the host to render. Only kinds declared in `supportedDialogKinds`
390
+ * are ever emitted; everything unexpected is answered `cancelled` (the
391
+ * required answer for unrecognized kinds), which applies the dialog's
392
+ * default behavior CLI-side. Today the only declared kind is the
393
+ * refusal-fallback consent prompt, rendered as an ACP form elicitation.
394
+ */
395
+ private handleUserDialog;
387
396
  private sendAvailableCommandsUpdate;
388
397
  private updateConfigOption;
389
398
  private applyConfigOptionValue;
399
+ /** Reconcile adapter model state after the SDK persistently swapped the
400
+ * session's model out from under us (refusal fallback). The SDK already
401
+ * made the switch, so this must NOT call `query.setModel` — it only
402
+ * updates our bookkeeping (currentModelId, context window, mode clamping,
403
+ * effort/Fast-mode options) via the same `applyConfigOptionValue` path a
404
+ * user-driven model change takes, then notifies the client. */
405
+ private syncModelAfterRefusalFallback;
390
406
  /** Replace the Fast mode option in `session.configOptions` so it reflects
391
407
  * `enabled` (and the client's current boolean-capability). A no-op when the
392
408
  * option isn't present, so callers must confirm the current model surfaces
@@ -1 +1 @@
1
- {"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EAGb,iBAAiB,EACjB,kBAAkB,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E;IACR,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,mBAAmB,EAAE,CAoDvB;AAED;;;;;;;;;;;oEAWoE;AACpE,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,EAC3D,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAgB,MAAM;;;EAqCrB"}
package/dist/acp-agent.js CHANGED
@@ -7,7 +7,7 @@ import * as os from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { promisify } from "node:util";
9
9
  import packageJson from "../package.json" with { type: "json" };
10
- import { applyAskElicitationResponse, askUserQuestionsToCreateRequest, createElicitationResponseToElicitResult, extractAskUserQuestions, mcpElicitationToCreateRequest, } from "./elicitation.js";
10
+ import { applyAskElicitationResponse, askUserQuestionsToCreateRequest, createElicitationResponseToElicitResult, extractAskUserQuestions, extractRefusalFallbackPrompt, mcpElicitationToCreateRequest, REFUSAL_FALLBACK_DIALOG_KIND, refusalFallbackResultFromResponse, refusalFallbackToCreateRequest, } from "./elicitation.js";
11
11
  import { SettingsManager } from "./settings.js";
12
12
  import { applyTaskCreate, applyTaskUpdate, createPostToolUseHook, createTaskHook, parseTaskCreateOutput, planEntries, registerHookCallback, taskStateToPlanEntries, toolInfoFromToolUse, toolUpdateFromDiffToolResponse, toolUpdateFromToolResult, } from "./tools.js";
13
13
  import { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
@@ -42,6 +42,12 @@ const DEFAULT_CONTEXT_WINDOW = 200000;
42
42
  * "obviously stuck" ceiling, not a guess at interrupt latency, so it can't
43
43
  * pre-empt a slow-but-healthy interrupt. */
44
44
  const DEFAULT_FORCE_CANCEL_GRACE_MS = 30_000;
45
+ /** Error surfaced when the SDK declares a turn over (`session_state_changed:
46
+ * idle`, its authoritative turn-over signal) without ever emitting the turn's
47
+ * `result` — a model stream that dropped mid-turn, or an async agent that
48
+ * completed/stalled without the host turn resolving (issue #825). */
49
+ const TURN_NO_RESULT_MESSAGE = "The turn ended without a result: the agent went idle while this prompt was still in flight " +
50
+ "(e.g. the model stream dropped mid-turn). Any partial output may be incomplete; please retry.";
45
51
  /** Compute a stable fingerprint of the session-defining params so we can
46
52
  * detect when a loadSession/resumeSession call requires tearing down and
47
53
  * recreating the underlying Query process. MCP servers are sorted by name
@@ -185,6 +191,9 @@ export function isLocalCommandMetadata(content) {
185
191
  const PERMISSION_MODE_ALIASES = {
186
192
  auto: "auto",
187
193
  default: "default",
194
+ // Claude Code 2.1.200 renamed the "default" mode to "Manual" and accepts
195
+ // `"defaultMode": "manual"` in settings.json; honor the same alias here.
196
+ manual: "default",
188
197
  acceptedits: "acceptEdits",
189
198
  dontask: "dontAsk",
190
199
  plan: "plan",
@@ -660,6 +669,20 @@ export class ClaudeAcpAgent {
660
669
  // Stop reason accumulated for the active turn (result subtype, refusal,
661
670
  // max_tokens, …). Reset per turn; read when the turn settles at idle.
662
671
  let stopReason = "end_turn";
672
+ // How many trailing `session_state_changed: idle` messages are already
673
+ // accounted for: every user-turn result that terminates a turn (settle,
674
+ // reject, or orphan skip) is followed by one, as is a cancelled turn
675
+ // settled by the next turn's echo hand-off. The idle handler absorbs owed
676
+ // idles; an idle that arrives when NONE is owed while the active turn is
677
+ // still unsettled means the SDK ended the turn without ever emitting its
678
+ // result, so the turn will never settle on its own (issue #825).
679
+ // Stream-level debt, deliberately NOT reset per turn: a lagged idle can
680
+ // arrive after the next turn has already activated (issue #773), and the
681
+ // debt is what attributes it to the turn that owed it. Over-counting (an
682
+ // idle the SDK never emits, e.g. CLI binaries without session-state
683
+ // events — issue #497) is benign: the counter just absorbs one future
684
+ // idle, and detection degrades to the status quo rather than misfiring.
685
+ let owedTrailingIdles = 0;
663
686
  const resetTurnScratch = () => {
664
687
  lastAssistantTotalUsage = null;
665
688
  lastAssistantUsage = null;
@@ -780,9 +803,19 @@ export class ClaudeAcpAgent {
780
803
  // settle "cancelled" even when query.next() is wedged (issue #680). Re-armed
781
804
  // after each fire so the consumer keeps serving later turns.
782
805
  let cancelController = session.cancelController;
806
+ // The in-flight query.next(), kept across abort wake-ups that don't
807
+ // consume a message, so no yielded message is ever dropped — async
808
+ // generators serialize next() calls, so racing a SECOND next() while one
809
+ // is pending would make the abandoned one swallow a message (e.g. a
810
+ // force-cancelled turn's late result, whose orphan accounting below
811
+ // depends on actually seeing it).
812
+ let pendingNext = null;
783
813
  try {
784
814
  while (true) {
785
- const nextMessage = session.query.next();
815
+ pendingNext ??= session.query
816
+ .next()
817
+ .then((result) => ({ kind: "message", result }));
818
+ const nextMessage = pendingNext;
786
819
  // Fresh abort listener per iteration, removed when next() wins, so a
787
820
  // long-lived session doesn't accumulate listeners on one signal.
788
821
  let onAbort;
@@ -790,25 +823,36 @@ export class ClaudeAcpAgent {
790
823
  onAbort = () => resolve("abort");
791
824
  cancelController.signal.addEventListener("abort", onAbort, { once: true });
792
825
  });
793
- const raced = await Promise.race([
794
- nextMessage.then((result) => ({ kind: "message", result })),
795
- abortRace,
796
- ]);
826
+ const raced = await Promise.race([nextMessage, abortRace]);
797
827
  cancelController.signal.removeEventListener("abort", onAbort);
798
828
  if (raced === "abort") {
799
- // cancel()/teardown woke us. Abandon the in-flight next() (swallowing
800
- // any later rejection so it can't surface as unhandled) and settle the
801
- // active turn "cancelled" per the ACP contract. If the session is
802
- // being torn down, stop; otherwise re-arm and keep consuming.
803
- void nextMessage.catch(() => { });
829
+ // cancel()/teardown woke us: settle the active turn "cancelled" per
830
+ // the ACP contract. The SDK never acknowledged this turn (that's why
831
+ // the force-cancel backstop fired), so if it later recovers from the
832
+ // wedge it will still emit the turn's result — with no live turn to
833
+ // match — followed by its trailing idle. Pre-count it as an orphan
834
+ // so that late result is skipped (not promoted onto the next queued
835
+ // prompt) and its trailer is recorded as owed, not read as the next
836
+ // turn being abandoned. Stale counts self-heal: activation resets
837
+ // them (see activateTurn).
838
+ if (session.activeTurn && !session.activeTurn.settled) {
839
+ session.pendingOrphanResults = (session.pendingOrphanResults ?? 0) + 1;
840
+ }
804
841
  settleActive({ stopReason: "cancelled" });
842
+ // If the session is being torn down, abandon the in-flight next()
843
+ // (swallowing any later rejection so it can't surface as unhandled)
844
+ // and stop; otherwise re-arm and keep consuming — `pendingNext`
845
+ // stays in flight so its eventual message is processed, not dropped.
805
846
  if (!this.sessions[params.sessionId]) {
847
+ void nextMessage.catch(() => { });
806
848
  return;
807
849
  }
808
850
  cancelController = new AbortController();
809
851
  session.cancelController = cancelController;
810
852
  continue;
811
853
  }
854
+ // A message arrived: this next() is consumed; arm a fresh one next pass.
855
+ pendingNext = null;
812
856
  const { value: message, done } = raced.result;
813
857
  if (done || !message) {
814
858
  // The stream ended. Settle the in-flight turns FIRST, then release the
@@ -941,20 +985,55 @@ export class ClaudeAcpAgent {
941
985
  }
942
986
  case "session_state_changed": {
943
987
  if (message.state === "idle") {
944
- // A non-cancelled turn already settled at its terminal
945
- // `result` (issue #773), so this trailing `idle` is just
946
- // absorbed. We must NOT settle `activeTurn` here in that case:
947
- // `idle` carries no turn identity, and it can lag (the SDK
948
- // flushes held-back results / drains background agents first),
949
- // so by the time it arrives the SDK may have echoed the NEXT
950
- // turn and activated it — settling now would resolve that new
951
- // turn prematurely with end_turn and ~zero usage, dropping its
952
- // real result. Only a cancelled turn relies on `idle`: its
953
- // `result` is dropped at the `session.cancelled` guard, so it
954
- // never settles at a result and must settle here.
955
- if (session.cancelled) {
988
+ // A non-cancelled turn normally settled at its terminal
989
+ // `result` already (issue #773), and that result recorded an
990
+ // owed trailing idle — absorbed here via the decrement. We
991
+ // must NOT settle `activeTurn` on an owed idle: `idle`
992
+ // carries no turn identity, and it can lag (the SDK flushes
993
+ // held-back results / drains background agents first), so by
994
+ // the time it arrives the SDK may have echoed the NEXT turn
995
+ // and activated it — settling now would resolve that new
996
+ // turn prematurely with end_turn and ~zero usage, dropping
997
+ // its real result. A cancelled turn relies on `idle`: its
998
+ // `result` is dropped at the `session.cancelled` guard, so
999
+ // it never settles at a result and must settle here.
1000
+ //
1001
+ // An idle that is NOT owed while the active turn is still
1002
+ // unsettled is the issue #825 signature: `idle` is the SDK's
1003
+ // authoritative turn-over signal (it fires after held-back
1004
+ // results flush and background agents drain), so a turn that
1005
+ // reaches it without a result will never get one — the model
1006
+ // stream dropped mid-turn, or an async agent
1007
+ // completed/stalled without the host turn resolving. Fail
1008
+ // the turn NOW so its session/prompt gets a terminal
1009
+ // response, instead of leaving it hanging until the next
1010
+ // prompt drains the wreckage.
1011
+ if (session.cancelled && session.activeTurn && !session.activeTurn.settled) {
956
1012
  settleActive({ stopReason: "cancelled" });
957
1013
  }
1014
+ else if (owedTrailingIdles > 0) {
1015
+ // Absorb a settled turn's trailing idle. Also covers a
1016
+ // cancel that landed between a turn's counted result and
1017
+ // this lagged idle (no active turn to settle): the idle
1018
+ // still belongs to that settled turn, and skipping the
1019
+ // decrement would leak the debt permanently.
1020
+ owedTrailingIdles--;
1021
+ }
1022
+ else if (!session.cancelled &&
1023
+ session.activeTurn &&
1024
+ !session.activeTurn.settled) {
1025
+ // Deliberately only the ACTIVE turn: a queued turn that
1026
+ // was never echoed is NOT failed here, because an idle
1027
+ // can legitimately precede the SDK picking up freshly
1028
+ // pushed input (the idle was emitted before the SDK read
1029
+ // it) — failing the queue head on that race would reject
1030
+ // a prompt the SDK is about to run. A turn abandoned
1031
+ // before its echo therefore still hangs until cancel or
1032
+ // the next prompt; only a timer could tell those apart.
1033
+ this.logger.error(`Session ${params.sessionId}: SDK went idle without emitting a result ` +
1034
+ `for the active turn; failing the in-flight prompt (issue #825)`);
1035
+ failActive(RequestError.internalError(errorKindData("no_result"), TURN_NO_RESULT_MESSAGE));
1036
+ }
958
1037
  // The SDK generates the session title in a background task and
959
1038
  // persists it to the session file; `idle` is the turn-over
960
1039
  // signal, so it's the point at which a new title may have
@@ -1109,10 +1188,65 @@ export class ClaudeAcpAgent {
1109
1188
  case "notification":
1110
1189
  case "api_retry":
1111
1190
  case "thinking_tokens":
1112
- case "model_refusal_fallback":
1113
- case "model_refusal_no_fallback":
1114
1191
  // Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
1115
1192
  break;
1193
+ case "model_refusal_fallback": {
1194
+ // The SDK retried a refused turn on the fallback model and made
1195
+ // the swap persistent for the session. Without a notice the
1196
+ // user just sees regenerated output; without the state sync the
1197
+ // client's model picker (and the model-dependent options
1198
+ // rebuilt from it) keeps advertising a model the session is no
1199
+ // longer running.
1200
+ //
1201
+ // Current CLIs only emit direction "retry" (persistent swap).
1202
+ // "revert"/"sticky" are retained in the SDK enum for older
1203
+ // CLIs, where "revert" marked a turn-only fallback — for that
1204
+ // direction the session stays on the original model, so skip
1205
+ // the persistent-swap claim and the state sync.
1206
+ const persistent = message.direction !== "revert";
1207
+ const category = message.api_refusal_category
1208
+ ? ` (${message.api_refusal_category})`
1209
+ : "";
1210
+ const explanation = message.api_refusal_explanation
1211
+ ? `\n\n${message.api_refusal_explanation}`
1212
+ : "";
1213
+ const outcome = persistent
1214
+ ? `The session will continue on ${message.fallback_model}.`
1215
+ : `The session stays on ${message.original_model}.`;
1216
+ await this.client.sessionUpdate({
1217
+ sessionId: message.session_id,
1218
+ update: {
1219
+ sessionUpdate: "agent_message_chunk",
1220
+ content: {
1221
+ type: "text",
1222
+ text: `**Model fallback:** ${message.original_model} declined this request${category}; retried with ${message.fallback_model}. ${outcome}${explanation}`,
1223
+ },
1224
+ },
1225
+ });
1226
+ if (persistent) {
1227
+ await this.syncModelAfterRefusalFallback(params.sessionId, session, message.fallback_model);
1228
+ }
1229
+ break;
1230
+ }
1231
+ case "model_refusal_no_fallback":
1232
+ // The refusal ends the turn as an error; the terminal `result`
1233
+ // handler settles it with ACP's `refusal` stop reason and
1234
+ // streams `lastRefusalExplanation`. The assistant frame's
1235
+ // stop_details is the primary source for that explanation —
1236
+ // this structured banner is the backup source when the frame
1237
+ // carried none (older CLIs, gateways that drop stop_details).
1238
+ //
1239
+ // `refused_user_message_uuid` is explicitly null when the
1240
+ // refused turn was not human-authored (a background
1241
+ // task-notification followup or auto-continuation) — don't
1242
+ // let those pollute the user turn's explanation. `undefined`
1243
+ // (older CLIs that omit the field) can't be attributed either
1244
+ // way, so keep seeding — the same exposure the assistant-frame
1245
+ // capture already has.
1246
+ if (!lastRefusalExplanation && message.refused_user_message_uuid !== null) {
1247
+ lastRefusalExplanation = message.api_refusal_explanation ?? message.content;
1248
+ }
1249
+ break;
1116
1250
  default:
1117
1251
  unreachable(message, this.logger);
1118
1252
  break;
@@ -1139,6 +1273,23 @@ export class ClaudeAcpAgent {
1139
1273
  if (!isTaskNotification) {
1140
1274
  ensureActiveTurn();
1141
1275
  }
1276
+ // Every user-turn result terminates a turn (settle, reject, or
1277
+ // orphan skip) and the SDK follows it with a trailing
1278
+ // `session_state_changed: idle` — record the debt so the idle
1279
+ // handler absorbs that idle rather than reading it as a turn the
1280
+ // SDK abandoned (issue #825). One exclusion: the cancelled ACTIVE
1281
+ // turn's own result. It is dropped at the `session.cancelled`
1282
+ // guard, and either the idle itself settles the turn (consuming
1283
+ // the trailer) or the next echo's hand-off does (which records
1284
+ // the debt there instead) — counting here too would double it.
1285
+ // Results skipped while cancelled with NO active turn — orphaned
1286
+ // queued turns the SDK still ran, or a force-cancelled turn's
1287
+ // late result after the backstop settled it — get no such settle,
1288
+ // so their trailers must be counted here or they'd later be read
1289
+ // as the next healthy turn being abandoned and false-fail it.
1290
+ if (!isTaskNotification && (!session.cancelled || !session.activeTurn)) {
1291
+ owedTrailingIdles++;
1292
+ }
1142
1293
  // Accumulate usage into the user turn's tally. Skip task-notification
1143
1294
  // followups: their cost is real but is reported separately via the
1144
1295
  // usage_update below, and `session.accumulatedUsage` is only reset on
@@ -1415,9 +1566,18 @@ export class ClaudeAcpAgent {
1415
1566
  // "cancelled" per the ACP contract rather than "end_turn" —
1416
1567
  // otherwise a cancel followed quickly by the next prompt
1417
1568
  // would report the cancelled turn as a normal completion.
1418
- settleActive(session.cancelled
1419
- ? { stopReason: "cancelled" }
1420
- : { stopReason: "end_turn", usage: sessionUsage(session) });
1569
+ if (session.cancelled) {
1570
+ // The cancelled turn settles here, but the trailing idle
1571
+ // its interrupt produces is still in flight — record the
1572
+ // debt so that lagged idle is absorbed rather than read
1573
+ // as the freshly-activated turn ending without a result
1574
+ // (which would false-fail a healthy turn — issue #825).
1575
+ owedTrailingIdles++;
1576
+ settleActive({ stopReason: "cancelled" });
1577
+ }
1578
+ else {
1579
+ settleActive({ stopReason: "end_turn", usage: sessionUsage(session) });
1580
+ }
1421
1581
  }
1422
1582
  activateTurn(queued);
1423
1583
  }
@@ -1445,7 +1605,13 @@ export class ClaudeAcpAgent {
1445
1605
  lastAssistantError = message.error;
1446
1606
  }
1447
1607
  if (message.message.stop_reason === "refusal") {
1448
- lastRefusalExplanation = message.message.stop_details?.explanation ?? null;
1608
+ // Keep any explanation already seeded by a
1609
+ // `model_refusal_no_fallback` banner — the banner/frame
1610
+ // ordering is CLI-dependent, and a frame whose stop_details
1611
+ // was dropped (the case the banner backup exists for) must
1612
+ // not clobber the seed back to null.
1613
+ lastRefusalExplanation =
1614
+ message.message.stop_details?.explanation ?? lastRefusalExplanation;
1449
1615
  }
1450
1616
  }
1451
1617
  // Strip <command-*>/<local-command-stdout> markers and render any
@@ -1613,9 +1779,16 @@ export class ClaudeAcpAgent {
1613
1779
  }
1614
1780
  break;
1615
1781
  }
1782
+ // `conversation_reset` (from `/clear`, plan-mode exit, fresh-session
1783
+ // flows) is safe to drop: turn lifecycle here is driven by
1784
+ // results/idle, and the client owns its own transcript view.
1785
+ // `control_request_progress` only reports on side_question control
1786
+ // requests, which this adapter never issues.
1616
1787
  case "tool_use_summary":
1617
1788
  case "auth_status":
1618
1789
  case "prompt_suggestion":
1790
+ case "conversation_reset":
1791
+ case "control_request_progress":
1619
1792
  break;
1620
1793
  default:
1621
1794
  unreachable(message);
@@ -2210,6 +2383,44 @@ export class ClaudeAcpAgent {
2210
2383
  }
2211
2384
  return { behavior: "allow", updatedInput: outcome.updatedInput };
2212
2385
  }
2386
+ /**
2387
+ * Handle `request_user_dialog` control requests — blocking dialogs the CLI
2388
+ * asks the host to render. Only kinds declared in `supportedDialogKinds`
2389
+ * are ever emitted; everything unexpected is answered `cancelled` (the
2390
+ * required answer for unrecognized kinds), which applies the dialog's
2391
+ * default behavior CLI-side. Today the only declared kind is the
2392
+ * refusal-fallback consent prompt, rendered as an ACP form elicitation.
2393
+ */
2394
+ handleUserDialog(sessionId) {
2395
+ return async (request, { signal }) => {
2396
+ if (request.dialogKind !== REFUSAL_FALLBACK_DIALOG_KIND) {
2397
+ return { behavior: "cancelled" };
2398
+ }
2399
+ const prompt = extractRefusalFallbackPrompt(request.payload);
2400
+ if (!prompt) {
2401
+ this.logger.error(`refusal_fallback_prompt payload had an unexpected shape; cancelling the dialog: ${JSON.stringify(request.payload)}`);
2402
+ return { behavior: "cancelled" };
2403
+ }
2404
+ let response;
2405
+ try {
2406
+ response = await this.client.unstable_createElicitation(refusalFallbackToCreateRequest(prompt, sessionId), signal);
2407
+ }
2408
+ catch (error) {
2409
+ // A cancellation we requested (signal aborted) is expected teardown;
2410
+ // anything else is a client failure. Either way the safe answer is
2411
+ // `cancelled` — the CLI applies the dialog's default (keep the
2412
+ // refusal) rather than switching models without consent.
2413
+ if (!signal.aborted) {
2414
+ this.logger.error(`Failed to present refusal fallback elicitation: ${error}`);
2415
+ }
2416
+ return { behavior: "cancelled" };
2417
+ }
2418
+ if (signal.aborted) {
2419
+ return { behavior: "cancelled" };
2420
+ }
2421
+ return { behavior: "completed", result: refusalFallbackResultFromResponse(response) };
2422
+ };
2423
+ }
2213
2424
  async sendAvailableCommandsUpdate(sessionId) {
2214
2425
  const session = this.sessions[sessionId];
2215
2426
  if (!session)
@@ -2257,8 +2468,16 @@ export class ClaudeAcpAgent {
2257
2468
  }
2258
2469
  session.models = { ...session.models, currentModelId: value };
2259
2470
  // Recompute availableModes for the new model and clamp the current
2260
- // mode if the SDK no longer offers it (today: "auto" on Haiku).
2261
- const newAvailableModes = buildAvailableModes(newModelInfo);
2471
+ // mode if the SDK no longer offers it (today: "auto" on Haiku). An
2472
+ // unknown model (an SDK-initiated refusal fallback to a model outside
2473
+ // the user's `availableModels` allowlist — user-driven switches are
2474
+ // validated against the options first) tells us nothing about its
2475
+ // capabilities, so keep the current modes rather than spuriously
2476
+ // downgrading (e.g. kicking the user out of "auto" for a model that
2477
+ // does support it).
2478
+ const newAvailableModes = newModelInfo
2479
+ ? buildAvailableModes(newModelInfo)
2480
+ : session.modes.availableModes;
2262
2481
  // Capture BEFORE mutating session.modes so the log message reflects
2263
2482
  // the invalidated mode rather than "default".
2264
2483
  const previousModeId = session.modes.currentModeId;
@@ -2339,6 +2558,36 @@ export class ClaudeAcpAgent {
2339
2558
  }
2340
2559
  }
2341
2560
  }
2561
+ /** Reconcile adapter model state after the SDK persistently swapped the
2562
+ * session's model out from under us (refusal fallback). The SDK already
2563
+ * made the switch, so this must NOT call `query.setModel` — it only
2564
+ * updates our bookkeeping (currentModelId, context window, mode clamping,
2565
+ * effort/Fast-mode options) via the same `applyConfigOptionValue` path a
2566
+ * user-driven model change takes, then notifies the client. */
2567
+ async syncModelAfterRefusalFallback(sessionId, session, fallbackModel) {
2568
+ // Map the SDK-reported model onto one of the session's model options
2569
+ // (handles display names and `resolvedModel` ids). The fallback model may
2570
+ // not be among the options — e.g. excluded by the user's
2571
+ // `availableModels` allowlist — in which case we track the raw id: the
2572
+ // picker shows no selection, but the model-dependent bookkeeping and any
2573
+ // later `setModel` round-trip stay truthful to what the SDK is running.
2574
+ const resolved = resolveModelPreference(session.modelInfos, fallbackModel);
2575
+ const value = resolved?.value ?? fallbackModel;
2576
+ if (session.models.currentModelId === value)
2577
+ return;
2578
+ try {
2579
+ await this.updateConfigOption(sessionId, MODEL_CONFIG_ID, value);
2580
+ }
2581
+ catch (err) {
2582
+ // This runs on the consumer loop: a throw here tears down the query
2583
+ // stream (failAllTurns + closeQueryStream) and bricks the session —
2584
+ // far worse than stale bookkeeping. The user-driven RPC path lets the
2585
+ // same errors propagate to fail just that request; here we log and
2586
+ // move on, matching the setPermissionMode containment inside
2587
+ // applyConfigOptionValue.
2588
+ this.logger.error(`Failed to reconcile model state after refusal fallback to "${fallbackModel}":`, err);
2589
+ }
2590
+ }
2342
2591
  /** Replace the Fast mode option in `session.configOptions` so it reflects
2343
2592
  * `enabled` (and the client's current boolean-capability). A no-op when the
2344
2593
  * option isn't present, so callers must confirm the current model surfaces
@@ -2586,6 +2835,18 @@ export class ClaudeAcpAgent {
2586
2835
  ...(elicitationSupport.form || elicitationSupport.url
2587
2836
  ? { onElicitation: this.handleMcpElicitation(sessionId, elicitationSupport) }
2588
2837
  : {}),
2838
+ // Render the CLI's refusal-fallback consent prompt ("<model> declined —
2839
+ // retry with <fallback>?") as an ACP form elicitation. Declaring the
2840
+ // kind is the opt-in: the CLI never emits an undeclared dialog, and the
2841
+ // flow instead degrades to the classic refusal error ending the turn.
2842
+ // Gated on form elicitation since that's the only ACP surface that can
2843
+ // present a choice outside a tool call.
2844
+ ...(elicitationSupport.form
2845
+ ? {
2846
+ onUserDialog: this.handleUserDialog(sessionId),
2847
+ supportedDialogKinds: [REFUSAL_FALLBACK_DIALOG_KIND],
2848
+ }
2849
+ : {}),
2589
2850
  pathToClaudeCodeExecutable: process.env.CLAUDE_CODE_EXECUTABLE ?? (await claudeCliPath()),
2590
2851
  extraArgs: {
2591
2852
  ...userProvidedOptions?.extraArgs,
@@ -2840,9 +3101,9 @@ function totalTokens(usage) {
2840
3101
  }
2841
3102
  /**
2842
3103
  * Build the `data` payload attached to a `RequestError.internalError` when we
2843
- * have a categorical error from the Claude SDK. Returns `undefined` when no
2844
- * categorical error is available, matching the previous behavior of passing
2845
- * `undefined` to `RequestError.internalError`.
3104
+ * have a categorical error — from the Claude SDK, or one of the adapter's own
3105
+ * kinds. Returns `undefined` when no categorical error is available, matching
3106
+ * the previous behavior of passing `undefined` to `RequestError.internalError`.
2846
3107
  *
2847
3108
  * The `errorKind` field is a convention for ACP clients to dispatch on
2848
3109
  * without having to pattern-match the human-readable message text. Clients
@@ -2905,8 +3166,10 @@ function buildAvailableModes(modelInfo) {
2905
3166
  });
2906
3167
  }
2907
3168
  modes.push({
3169
+ // Claude Code 2.1.200 renamed this mode to "Manual" across its surfaces;
3170
+ // the wire id stays "default" ("manual" is only an accepted input alias).
2908
3171
  id: "default",
2909
- name: "Default",
3172
+ name: "Manual",
2910
3173
  description: "Standard behavior, prompts for dangerous operations",
2911
3174
  }, {
2912
3175
  id: "acceptEdits",
@@ -79,4 +79,49 @@ export type AskUserQuestionOutcome = {
79
79
  * rather than the turn aborting); cancel aborts the tool call.
80
80
  */
81
81
  export declare function applyAskElicitationResponse(response: CreateElicitationResponse, toolInput: Record<string, unknown>, questions: AskUserQuestion[]): AskUserQuestionOutcome;
82
+ /**
83
+ * The `request_user_dialog` kind the CLI emits when a model refusal has a
84
+ * fallback available but needs user consent before retrying (e.g. Claude Fable
85
+ * declining a request with Opus available as the fallback). Declaring this
86
+ * kind in `supportedDialogKinds` is the opt-in: the CLI fails closed and never
87
+ * emits an undeclared kind — the flow degrades to the classic refusal error
88
+ * ending the turn.
89
+ */
90
+ export declare const REFUSAL_FALLBACK_DIALOG_KIND = "refusal_fallback_prompt";
91
+ /**
92
+ * Payload of the `refusal_fallback_prompt` dialog. The dialog protocol
93
+ * transports payloads opaquely, so this shape is recovered from the CLI's own
94
+ * schema (v2.1.177): `originalModel`/`fallbackModel` are required strings;
95
+ * `apiRefusalCategory` (nullable), `guidanceText`, and
96
+ * `retractedMessageUuids` are optional. We ignore `retractedMessageUuids` —
97
+ * ACP has no way to retract already-streamed chunks.
98
+ */
99
+ export type RefusalFallbackPrompt = {
100
+ originalModel: string;
101
+ fallbackModel: string;
102
+ apiRefusalCategory: string | null;
103
+ guidanceText?: string;
104
+ };
105
+ /**
106
+ * Validate the opaque dialog payload into a {@link RefusalFallbackPrompt}.
107
+ * Returns `null` when the required fields are missing or mistyped (a newer CLI
108
+ * may reshape the payload), so the caller can cancel the dialog and let the
109
+ * CLI apply its default behavior instead of rendering something misleading.
110
+ */
111
+ export declare function extractRefusalFallbackPrompt(payload: Record<string, unknown>): RefusalFallbackPrompt | null;
112
+ /**
113
+ * Render the refusal-fallback consent prompt as an ACP form elicitation: a
114
+ * single-select between retrying on the fallback model and keeping the
115
+ * refusal. The enum `const`s are the dialog's wire result values, so the
116
+ * response maps back without a translation table.
117
+ */
118
+ export declare function refusalFallbackToCreateRequest(prompt: RefusalFallbackPrompt, sessionId: string): CreateElicitationRequest;
119
+ /**
120
+ * Map the elicitation response back to the dialog's result enum. Only an
121
+ * explicit accept-with-retry resolves to `retry_fallback`; decline, cancel, a
122
+ * skipped field, or an unrecognized value all keep the refusal — the dialog's
123
+ * own default — so a dismissed or half-filled form can never trigger a model
124
+ * switch the user didn't ask for.
125
+ */
126
+ export declare function refusalFallbackResultFromResponse(response: CreateElicitationResponse): string;
82
127
  //# sourceMappingURL=elicitation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAI1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd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AAC;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,qBAAqB,GAAG,IAAI,CAW9B;AAYD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,qBAAqB,EAC7B,SAAS,EAAE,MAAM,GAChB,wBAAwB,CAuB1B;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,yBAAyB,GAAG,MAAM,CAM7F"}
@@ -209,3 +209,81 @@ function normalizeElicitationSchema(schema) {
209
209
  }
210
210
  return { ...schema, type: "object" };
211
211
  }
212
+ /**
213
+ * The `request_user_dialog` kind the CLI emits when a model refusal has a
214
+ * fallback available but needs user consent before retrying (e.g. Claude Fable
215
+ * declining a request with Opus available as the fallback). Declaring this
216
+ * kind in `supportedDialogKinds` is the opt-in: the CLI fails closed and never
217
+ * emits an undeclared kind — the flow degrades to the classic refusal error
218
+ * ending the turn.
219
+ */
220
+ export const REFUSAL_FALLBACK_DIALOG_KIND = "refusal_fallback_prompt";
221
+ /**
222
+ * Validate the opaque dialog payload into a {@link RefusalFallbackPrompt}.
223
+ * Returns `null` when the required fields are missing or mistyped (a newer CLI
224
+ * may reshape the payload), so the caller can cancel the dialog and let the
225
+ * CLI apply its default behavior instead of rendering something misleading.
226
+ */
227
+ export function extractRefusalFallbackPrompt(payload) {
228
+ const { originalModel, fallbackModel, apiRefusalCategory, guidanceText } = payload;
229
+ if (typeof originalModel !== "string" || typeof fallbackModel !== "string") {
230
+ return null;
231
+ }
232
+ return {
233
+ originalModel,
234
+ fallbackModel,
235
+ apiRefusalCategory: typeof apiRefusalCategory === "string" ? apiRefusalCategory : null,
236
+ ...(typeof guidanceText === "string" && guidanceText ? { guidanceText } : {}),
237
+ };
238
+ }
239
+ /** Form-field key carrying the user's choice in the refusal-fallback form. */
240
+ const REFUSAL_FALLBACK_CHOICE_KEY = "choice";
241
+ /** Wire values of the dialog's result enum (CLI schema). `edit_prompt` is
242
+ * deliberately not offered: in the CLI it prefills the composer with the
243
+ * refused prompt for edit-and-retry, and ACP has no composer-prefill surface
244
+ * — the user can simply edit and resend on their own. */
245
+ const RETRY_FALLBACK_RESULT = "retry_fallback";
246
+ const KEEP_REFUSAL_RESULT = "cancelled";
247
+ /**
248
+ * Render the refusal-fallback consent prompt as an ACP form elicitation: a
249
+ * single-select between retrying on the fallback model and keeping the
250
+ * refusal. The enum `const`s are the dialog's wire result values, so the
251
+ * response maps back without a translation table.
252
+ */
253
+ export function refusalFallbackToCreateRequest(prompt, sessionId) {
254
+ const category = prompt.apiRefusalCategory ? ` (${prompt.apiRefusalCategory})` : "";
255
+ const guidance = prompt.guidanceText ? `\n\n${prompt.guidanceText}` : "";
256
+ return {
257
+ mode: "form",
258
+ sessionId,
259
+ message: `${prompt.originalModel} declined this request${category}. ` +
260
+ `Retry with ${prompt.fallbackModel}? The session would continue on ${prompt.fallbackModel}.` +
261
+ guidance,
262
+ requestedSchema: {
263
+ type: "object",
264
+ properties: {
265
+ [REFUSAL_FALLBACK_CHOICE_KEY]: {
266
+ type: "string",
267
+ oneOf: [
268
+ { const: RETRY_FALLBACK_RESULT, title: `Retry with ${prompt.fallbackModel}` },
269
+ { const: KEEP_REFUSAL_RESULT, title: "Keep the refusal" },
270
+ ],
271
+ },
272
+ },
273
+ },
274
+ };
275
+ }
276
+ /**
277
+ * Map the elicitation response back to the dialog's result enum. Only an
278
+ * explicit accept-with-retry resolves to `retry_fallback`; decline, cancel, a
279
+ * skipped field, or an unrecognized value all keep the refusal — the dialog's
280
+ * own default — so a dismissed or half-filled form can never trigger a model
281
+ * switch the user didn't ask for.
282
+ */
283
+ export function refusalFallbackResultFromResponse(response) {
284
+ if (response.action !== "accept") {
285
+ return KEEP_REFUSAL_RESULT;
286
+ }
287
+ const choice = response.content?.[REFUSAL_FALLBACK_CHOICE_KEY];
288
+ return choice === RETRY_FALLBACK_RESULT ? RETRY_FALLBACK_RESULT : KEEP_REFUSAL_RESULT;
289
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.54.1",
6
+ "version": "0.56.0",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -64,14 +64,14 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@agentclientprotocol/sdk": "1.1.0",
67
- "@anthropic-ai/claude-agent-sdk": "0.3.197",
67
+ "@anthropic-ai/claude-agent-sdk": "0.3.201",
68
68
  "zod": "^3.25.0 || ^4.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@anthropic-ai/sdk": "0.108.0",
71
+ "@anthropic-ai/sdk": "0.110.0",
72
72
  "@eslint/js": "10.0.1",
73
73
  "@tsconfig/node22": "22.0.5",
74
- "@types/node": "26.0.1",
74
+ "@types/node": "26.1.0",
75
75
  "@typescript-eslint/eslint-plugin": "8.62.1",
76
76
  "@typescript-eslint/parser": "8.62.1",
77
77
  "eslint": "10.6.0",
@@ -80,6 +80,6 @@
80
80
  "prettier": "3.9.4",
81
81
  "ts-node": "10.9.2",
82
82
  "typescript": "6.0.3",
83
- "vitest": "4.1.9"
83
+ "vitest": "4.1.10"
84
84
  }
85
85
  }