claude-code-acp-ts 0.59.0 → 0.60.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.
@@ -222,11 +222,32 @@ type Session = {
222
222
  emitRawSDKMessages: boolean | SDKMessageFilter[];
223
223
  /** Context window size of the session's current model, carried across
224
224
  * prompts so mid-stream usage_update notifications report a correct `size`
225
- * before the turn's first result message arrives. Seeded from the SDK's
226
- * getContextUsage report at session creation (DEFAULT_CONTEXT_WINDOW when
227
- * that and the text heuristic both fail), refreshed the same way on model
228
- * switches, and confirmed by each result's modelUsage. */
225
+ * before the turn's first result message arrives. Seeded synchronously at
226
+ * session creation and on model switches from the per-model cache or the
227
+ * text heuristic (DEFAULT_CONTEXT_WINDOW when both miss; on session/load the
228
+ * resumed session's own `getContextUsage` report wins, see
229
+ * `readResumedLiveModel`), then confirmed — and the cache populated — by each
230
+ * result's modelUsage. No extra `getContextUsage` IPC is on these paths: on a
231
+ * fresh session it stalls until the first turn runs (see the seeding call
232
+ * sites and `contextWindowCache`). */
229
233
  contextWindowSize: number;
234
+ /** Whether `contextWindowSize` came from an authoritative source (the
235
+ * cross-session cache, a resumed session's `getContextUsage` report, or a
236
+ * `result.modelUsage`) rather than the text heuristic / default. Guards the
237
+ * mid-stream `message_start` heuristic upgrade: an authoritative window that
238
+ * happens to equal DEFAULT_CONTEXT_WINDOW must not be mistaken for "unseeded"
239
+ * and clobbered by a "1m" text match. */
240
+ contextWindowAuthoritative: boolean;
241
+ /** Stable identifier of the LLM backend this session's query was created
242
+ * against, derived from the routing-relevant vars of the exact `env` handed
243
+ * to the SDK at query creation (see {@link providerCacheKeyFor}). The context
244
+ * window is a property of (model id, backend) — the same resolved model id
245
+ * can name different windows behind different base URLs, routing headers, or
246
+ * credentials — so this scopes the module-global `contextWindowCache` per
247
+ * backend. Captured from the query's own env (not re-resolved later) because
248
+ * the process-wide provider config can change while a session is being
249
+ * created, while the query stays baked to the env it was created with. */
250
+ providerCacheKey: string;
230
251
  /** Accumulated task list for the session, keyed by task ID. Task IDs are
231
252
  * per-session, so this state must not be shared across sessions. */
232
253
  taskState: TaskState;
@@ -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,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EAGb,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EACb,cAAc,EAEd,mBAAmB,EACnB,oBAAoB,EAEpB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,UAAU,EAEV,aAAa,EAKb,SAAS,EAIT,OAAO,EACP,cAAc,EAEd,gBAAgB,EAChB,KAAK,EAKL,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EAGf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAqBlG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EASL,SA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tB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;CAC7C,GACA,mBAAmB,EAAE,CAgIvB;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;;;EAwCrB"}
package/dist/acp-agent.js CHANGED
@@ -788,6 +788,12 @@ export class ClaudeAcpAgent {
788
788
  // those paths.
789
789
  this.gatewayAuthRequest = undefined;
790
790
  this.providerConfig = undefined;
791
+ // Learned context windows are per-account state too: 1M-context
792
+ // entitlement is gated per org/tier, and an OAuth re-login is invisible to
793
+ // the env-derived provider cache key, so windows learned under the old
794
+ // login must not seed sessions under the next. Worst case of clearing is
795
+ // re-learning on each model's next turn.
796
+ contextWindowCache.clear();
791
797
  // For the Claude/Console login methods the credentials live in the native
792
798
  // CLI's store (keychain or config dir), which only the binary can clear.
793
799
  // `claude auth logout` is non-interactive and idempotent.
@@ -2045,12 +2051,35 @@ export class ClaudeAcpAgent {
2045
2051
  const matchingModelUsage = lastAssistantModel
2046
2052
  ? getMatchingModelUsage(message.modelUsage, lastAssistantModel)
2047
2053
  : null;
2048
- // Only overwrite when we have an authoritative value — a miss
2049
- // (e.g. a turn with no top-level assistant message) would
2050
- // otherwise discard the window learned on a prior turn and
2051
- // leave the next prompt's mid-stream updates reporting 200k.
2052
- if (matchingModelUsage) {
2053
- session.contextWindowSize = matchingModelUsage.contextWindow;
2054
+ // Only overwrite when we have an authoritative, sane value. A miss
2055
+ // (e.g. a turn with no top-level assistant message), or a
2056
+ // nonsensical non-positive/NaN window (observed from third-party
2057
+ // backends), would otherwise discard the window learned on a prior
2058
+ // turn and leave the next prompt's mid-stream updates reporting a
2059
+ // wrong size. `cacheContextWindow` applies the same `> 0` guard, so
2060
+ // a bad value never reaches the cross-session cache either.
2061
+ if (matchingModelUsage &&
2062
+ typeof matchingModelUsage.usage.contextWindow === "number" &&
2063
+ matchingModelUsage.usage.contextWindow > 0) {
2064
+ session.contextWindowSize = matchingModelUsage.usage.contextWindow;
2065
+ session.contextWindowAuthoritative = true;
2066
+ // Authoritative: fold it into the cross-session cache keyed on
2067
+ // (this session's provider, the resolved model id —
2068
+ // matchingModelUsage.key, e.g. "claude-sonnet-5[1m]") so a later
2069
+ // session/new or switch on the same provider that resolves to
2070
+ // this model seeds the correct window synchronously, with no
2071
+ // getContextUsage IPC.
2072
+ cacheContextWindow(contextWindowCacheKey(session.providerCacheKey, matchingModelUsage.key), matchingModelUsage.usage.contextWindow);
2073
+ // Also cache under the assistant message's own (bare) spelling.
2074
+ // Seed-time reads fall back to a picker value / verbatim live id
2075
+ // when a row carries no resolvedModel (the synthesized
2076
+ // out-of-allowlist resume row sets it undefined on purpose), and
2077
+ // those spellings match `.model` from the assistant message, not
2078
+ // the decorated modelUsage key — without this entry such rows
2079
+ // could never hit the cache.
2080
+ if (lastAssistantModel && lastAssistantModel !== matchingModelUsage.key) {
2081
+ cacheContextWindow(contextWindowCacheKey(session.providerCacheKey, lastAssistantModel), matchingModelUsage.usage.contextWindow);
2082
+ }
2054
2083
  }
2055
2084
  // Send usage_update notification
2056
2085
  if (lastAssistantTotalUsage !== null) {
@@ -2293,11 +2322,16 @@ export class ClaudeAcpAgent {
2293
2322
  const model = message.event.message.model;
2294
2323
  if (model && model !== "<synthetic>") {
2295
2324
  lastAssistantModel = model;
2296
- // Only upgrade from the default — once the SDK has given us
2297
- // an authoritative window (seeded at session creation,
2298
- // refreshed on model switches in `applyConfigOptionValue`,
2299
- // confirmed by each `result`), trust it over the heuristic.
2300
- if (session.contextWindowSize === DEFAULT_CONTEXT_WINDOW) {
2325
+ // Only upgrade from the heuristic default — once we have an
2326
+ // authoritative window (cache-seeded at session creation or
2327
+ // on a model switch, read from the resumed session on
2328
+ // session/load, confirmed by each `result`), trust it over
2329
+ // the heuristic. The flag, not the value, is the sentinel: an
2330
+ // authoritative window can legitimately equal
2331
+ // DEFAULT_CONTEXT_WINDOW (e.g. a backend serving a 200k lane
2332
+ // under a "[1m]"-spelled id) and must not be clobbered.
2333
+ if (!session.contextWindowAuthoritative &&
2334
+ session.contextWindowSize === DEFAULT_CONTEXT_WINDOW) {
2301
2335
  const inferred = inferContextWindowFromModel(model);
2302
2336
  if (inferred !== null) {
2303
2337
  session.contextWindowSize = inferred;
@@ -2592,7 +2626,20 @@ export class ClaudeAcpAgent {
2592
2626
  _meta: {
2593
2627
  claudeCode: {
2594
2628
  toolName: message.tool_name,
2595
- toolResponse: { elapsedTimeSeconds: message.elapsed_time_seconds },
2629
+ toolResponse: {
2630
+ elapsedTimeSeconds: message.elapsed_time_seconds,
2631
+ // For Agent/Task calls: the subagent's type, and — when
2632
+ // the subagent is waiting out an API rate-limit retry —
2633
+ // the SDK's retry counters (attempt, max_retries,
2634
+ // retry_delay_ms, …), forwarded verbatim so clients can
2635
+ // show why a spawn looks stalled.
2636
+ ...(message.subagent_type !== undefined && {
2637
+ subagentType: message.subagent_type,
2638
+ }),
2639
+ ...(message.subagent_retry !== undefined && {
2640
+ subagentRetry: message.subagent_retry,
2641
+ }),
2642
+ },
2596
2643
  },
2597
2644
  },
2598
2645
  },
@@ -3192,7 +3239,7 @@ export class ClaudeAcpAgent {
3192
3239
  await this.client.sessionUpdate({ sessionId, update });
3193
3240
  }
3194
3241
  canUseTool(sessionId) {
3195
- return async (toolName, toolInput, { signal, suggestions, toolUseID, agentID }) => {
3242
+ return async (toolName, toolInput, { signal, suggestions, toolUseID, agentID, matchedAskRule }) => {
3196
3243
  const alwaysAllowLabel = describeAlwaysAllow(suggestions, toolName);
3197
3244
  const supportsTerminalOutput = this.clientCapabilities?._meta?.["terminal_output"] === true;
3198
3245
  const session = this.sessions[sessionId];
@@ -3300,7 +3347,14 @@ export class ClaudeAcpAgent {
3300
3347
  };
3301
3348
  }
3302
3349
  }
3303
- if (session.modes.currentModeId === "bypassPermissions") {
3350
+ // In bypass mode the CLI skips permission checks itself; the asks that
3351
+ // still reach canUseTool are the ones it insists on prompting for even
3352
+ // under --dangerously-skip-permissions. Keep auto-allowing those —
3353
+ // bypass means bypass — EXCEPT rule-forced asks (`matchedAskRule`): the
3354
+ // user explicitly configured a permissions.ask rule for this tool, and
3355
+ // the SDK's guidance is that hosts running auto-approval must treat such
3356
+ // asks as a human prompt. Fall through to the normal request below.
3357
+ if (session.modes.currentModeId === "bypassPermissions" && !matchedAskRule) {
3304
3358
  return {
3305
3359
  behavior: "allow",
3306
3360
  updatedInput: toolInput,
@@ -3506,17 +3560,21 @@ export class ClaudeAcpAgent {
3506
3560
  // carries no "1m" token.
3507
3561
  const newModelInfo = session.modelInfos.find((m) => m.value === value);
3508
3562
  if (session.models.currentModelId !== value) {
3509
- // The cached context window was learned for the previous model. The
3510
- // SDK is already running the new model here (user-driven switches call
3511
- // `query.setModel` before this, and the refusal-fallback sync only
3512
- // reconciles a switch the SDK already made), so ask it for the new
3513
- // window; fall back to the text heuristic so mid-stream updates
3514
- // between now and the next `result` reflect the user's selection
3515
- // instead of the old model's window.
3516
- session.contextWindowSize =
3517
- (await fetchContextWindowSize(session.query, this.logger)) ??
3518
- inferContextWindowFromModel(value, newModelInfo?.resolvedModel, newModelInfo?.displayName, newModelInfo?.description) ??
3519
- DEFAULT_CONTEXT_WINDOW;
3563
+ // Seed the new model's context window WITHOUT any IPC on the switch
3564
+ // path: cached authoritative value if we've already learned it (from a
3565
+ // prior turn's `result.modelUsage`), else the text heuristic, else the
3566
+ // default. We deliberately do NOT call `getContextUsage` here — before
3567
+ // a fresh session's first prompt turn that control request is not
3568
+ // serviced (~15s stall, issues #886/#880), and (because SDK control
3569
+ // requests are serialized over one channel) it would drag the awaited
3570
+ // `setModel` down with it. The authoritative window arrives on the
3571
+ // first `result.modelUsage` for the model and is cached from there;
3572
+ // until then a switched-to alias that has never run a turn shows the
3573
+ // heuristic/default window, which self-corrects on its first response
3574
+ // (matches pre-0.59.0 behavior).
3575
+ const seeded = immediateContextWindow(session.providerCacheKey, value, newModelInfo);
3576
+ session.contextWindowSize = seeded.size;
3577
+ session.contextWindowAuthoritative = seeded.authoritative;
3520
3578
  }
3521
3579
  session.models = { ...session.models, currentModelId: value };
3522
3580
  // Recompute availableModes for the new model and clamp the current
@@ -3845,6 +3903,28 @@ export class ClaudeAcpAgent {
3845
3903
  // below) so the TaskCreated/TaskCompleted hook callbacks can close over
3846
3904
  // the same Map that the streaming message handler will read from.
3847
3905
  const taskState = new Map();
3906
+ // The exact env the query will be created with. Built (and the provider
3907
+ // cache key derived from it, below) in one place so the key always
3908
+ // describes the backend this query actually talks to: `providers/set`,
3909
+ // `providers/disable`, and `logout` mutate the process-wide provider
3910
+ // config concurrently, so re-resolving it after any of the awaits between
3911
+ // here and the session registration could disagree with the env baked
3912
+ // into the query.
3913
+ const env = {
3914
+ ...process.env,
3915
+ ...userProvidedOptions?.env,
3916
+ // Client-managed LLM routing: `providers/set` config wins, else the
3917
+ // legacy gateway auth request. Baked into the query at creation, so it
3918
+ // only affects sessions started after the change (matching the RFD).
3919
+ ...createEnvForProvider(this.resolveProviderConfig()),
3920
+ // Opt-in to session state events like when the agent is idle
3921
+ CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1",
3922
+ };
3923
+ // Scopes the context-window cache to this query's backend (see
3924
+ // `contextWindowCache`). Derived from the same `env` object handed to the
3925
+ // SDK, so per-session `_meta` env routing and ambient process-env routing
3926
+ // are distinguished exactly as the CLI will see them.
3927
+ const providerCacheKey = providerCacheKeyFor(env);
3848
3928
  const options = {
3849
3929
  systemPrompt,
3850
3930
  settingSources: ["user", "project", "local"],
@@ -3861,16 +3941,7 @@ export class ClaudeAcpAgent {
3861
3941
  ...(modelConfig.availableModels && { availableModels: modelConfig.availableModels }),
3862
3942
  },
3863
3943
  }),
3864
- env: {
3865
- ...process.env,
3866
- ...userProvidedOptions?.env,
3867
- // Client-managed LLM routing: `providers/set` config wins, else the
3868
- // legacy gateway auth request. Baked into the query at creation, so it
3869
- // only affects sessions started after the change (matching the RFD).
3870
- ...createEnvForProvider(this.resolveProviderConfig()),
3871
- // Opt-in to session state events like when the agent is idle
3872
- CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1",
3873
- },
3944
+ env,
3874
3945
  // Override certain fields that must be controlled by ACP
3875
3946
  cwd: params.cwd,
3876
3947
  includePartialMessages: true,
@@ -3912,7 +3983,7 @@ export class ClaudeAcpAgent {
3912
3983
  ...(userProvidedOptions?.hooks?.PostToolUse || []),
3913
3984
  {
3914
3985
  hooks: [
3915
- createPostToolUseHook(this.logger, {
3986
+ createPostToolUseHook({
3916
3987
  onEnterPlanMode: async () => {
3917
3988
  await this.client.sessionUpdate({
3918
3989
  sessionId,
@@ -4018,7 +4089,7 @@ export class ClaudeAcpAgent {
4018
4089
  const allowedModels = Array.isArray(settingsAvailableModels)
4019
4090
  ? applyAvailableModelsAllowlist(initializationResult.models, settingsAvailableModels, settingsModelOverrides)
4020
4091
  : initializationResult.models;
4021
- const models = await getAvailableModels(q, allowedModels, initializationResult.models, settingsManager, this.logger, creationOpts.resume !== undefined);
4092
+ const { modelState: models, resumedContextWindow } = await getAvailableModels(q, allowedModels, initializationResult.models, settingsManager, this.logger, creationOpts.resume !== undefined);
4022
4093
  // Gate `auto` (and future model-specific modes) on the resolved model's
4023
4094
  // `ModelInfo`. See `buildAvailableModes` for the canonical SDK signal.
4024
4095
  // A resumed session can be running a model outside the `availableModels`
@@ -4114,25 +4185,39 @@ export class ClaudeAcpAgent {
4114
4185
  typeof initialEffort.currentValue === "string" &&
4115
4186
  initialEffort.currentValue !== "default") {
4116
4187
  await q.applyFlagSettings({
4117
- effortLevel: initialEffort.currentValue,
4188
+ effortLevel: toSdkEffortLevel(initialEffort.currentValue),
4118
4189
  });
4119
4190
  }
4120
- // Seed the context window from the SDK's authoritative report. Text
4121
- // inference alone misses aliases that resolve to extended-context models
4122
- // with no "1m" token anywhere in their id or description (e.g. `sonnet` →
4123
- // claude-sonnet-5, natively ~1M): those streamed `usage_update.size:
4124
- // 200000` until the first result's modelUsage corrected it — again on
4125
- // every process restart or session re-creation, since the learned window
4126
- // lives only on the Session (issue #596).
4191
+ // Seed the context window WITHOUT any extra IPC on the session/new path.
4192
+ // On session/load, the resumed session's own `getContextUsage` report — a
4193
+ // response `getAvailableModels` already awaited to learn the live model
4194
+ // (resumed sessions ARE serviced pre-turn, unlike fresh ones) — is
4195
+ // authoritative and wins. Otherwise: the cached authoritative window if a
4196
+ // prior turn has learned it for this model (`result.modelUsage`,
4197
+ // cross-session), else the text heuristic, else the default. We
4198
+ // deliberately do NOT issue a getContextUsage call here: on a fresh
4199
+ // session that control request is not serviced until the first prompt
4200
+ // turn runs, so awaiting it — as 0.59.0 did — made session/new take ~15s
4201
+ // (issues #886/#880). The authoritative window arrives on the first
4202
+ // `result.modelUsage` and is cached from there.
4203
+ //
4204
+ // Text inference alone misses aliases that resolve to extended-context
4205
+ // models with no "1m" token anywhere in their id or description (e.g.
4206
+ // `sonnet` → claude-sonnet-5, natively ~1M): those stream
4207
+ // `usage_update.size: 200000` until the first result's modelUsage corrects
4208
+ // it — but the cache means only the FIRST session to ever run a turn on such
4209
+ // a model eats that window, not every fresh session after a process
4210
+ // restart (issue #596; a post-restart session/load is covered by the
4211
+ // resumed report above).
4127
4212
  //
4128
4213
  // The inference fallback is deliberately keyed to the allowlisted entry: a
4129
4214
  // fallback-resolved sibling's resolvedModel/displayName/description can
4130
4215
  // describe a different context lane than the verbatim live id (e.g. an
4131
4216
  // "opus[1m]" row matched for a bare 200k id), so on the fallback path only
4132
4217
  // the id itself is a trustworthy window signal.
4133
- const contextWindowSize = (await fetchContextWindowSize(q, this.logger)) ??
4134
- inferContextWindowFromModel(models.currentModelId, allowlistedModelInfo?.resolvedModel, allowlistedModelInfo?.displayName, allowlistedModelInfo?.description) ??
4135
- DEFAULT_CONTEXT_WINDOW;
4218
+ const seededWindow = resumedContextWindow !== null
4219
+ ? { size: resumedContextWindow, authoritative: true }
4220
+ : immediateContextWindow(providerCacheKey, models.currentModelId, allowlistedModelInfo);
4136
4221
  this.sessions[sessionId] = {
4137
4222
  query: q,
4138
4223
  input: input,
@@ -4155,7 +4240,9 @@ export class ClaudeAcpAgent {
4155
4240
  fastModeEnabled,
4156
4241
  abortController,
4157
4242
  emitRawSDKMessages: sessionMeta?.claudeCode?.emitRawSDKMessages ?? false,
4158
- contextWindowSize,
4243
+ contextWindowSize: seededWindow.size,
4244
+ contextWindowAuthoritative: seededWindow.authoritative,
4245
+ providerCacheKey,
4159
4246
  taskState,
4160
4247
  toolUseCache: {},
4161
4248
  emittedToolCalls: new Set(),
@@ -4350,7 +4437,10 @@ function buildAvailableModes(modelInfo) {
4350
4437
  // and only clears a key when an explicit `null` is sent — see
4351
4438
  // `applyFlagSettings` in @anthropic-ai/claude-agent-sdk. Mapping both the
4352
4439
  // `"default"` sentinel and `undefined` (effort option absent for the model) to
4353
- // `null` ensures any previously-applied flag is actually cleared.
4440
+ // `null` ensures any previously-applied flag is actually cleared. Typed as
4441
+ // `EffortLevel` (not `Settings["effortLevel"]`): the picker offers whatever
4442
+ // `supportedEffortLevels` reports, which includes the session-scoped `"max"`
4443
+ // that the persisted Settings shape deliberately excludes.
4354
4444
  function toSdkEffortLevel(value) {
4355
4445
  return value === undefined || value === "default" ? null : value;
4356
4446
  }
@@ -4802,23 +4892,37 @@ export function applyAvailableModelsAllowlist(sdkModels, allowlist, settingsMode
4802
4892
  }
4803
4893
  /** Read the model a resumed session is actually running (via the
4804
4894
  * `getContextUsage` control request — the same source `/context` prints) and
4805
- * map it onto the picker. Best-effort: a control-request failure is logged
4806
- * and returns null so callers keep their current choice; failing the whole
4807
- * session/load over an unreadable report would be worse. */
4895
+ * map it onto the picker, along with the report's authoritative context
4896
+ * window (`rawMaxTokens`). Resumed sessions get this request serviced before
4897
+ * any turn runs in the new process — unlike fresh sessions, where it stalls
4898
+ * until the first prompt turn (issues #886/#880) — so the same response that
4899
+ * restores the live model (issue #845) also seeds the window for free,
4900
+ * covering post-restart reloads of models the text heuristic misses (issue
4901
+ * #596). Best-effort: a control-request failure is logged and returns nulls
4902
+ * so callers keep their current choice; failing the whole session/load over
4903
+ * an unreadable report would be worse. */
4808
4904
  async function readResumedLiveModel(query, models, logger) {
4809
4905
  try {
4810
- const liveModel = (await query.getContextUsage()).model;
4811
- return liveModel ? matchResumedModel(models, liveModel) : null;
4906
+ const usage = await query.getContextUsage();
4907
+ return {
4908
+ model: usage.model ? matchResumedModel(models, usage.model) : null,
4909
+ contextWindow: usage.rawMaxTokens > 0 ? usage.rawMaxTokens : null,
4910
+ };
4812
4911
  }
4813
4912
  catch (error) {
4814
4913
  logger.error("Failed to read the resumed session's live model:", error);
4815
- return null;
4914
+ return { model: null, contextWindow: null };
4816
4915
  }
4817
4916
  }
4818
4917
  async function getAvailableModels(query, models, sdkModels, settingsManager, logger, isResumedSession) {
4819
4918
  const settings = settingsManager.getSettings();
4820
4919
  let currentModel = models[0];
4821
4920
  let resolvedFromInput;
4921
+ // The context window reported alongside a resumed session's live model.
4922
+ // Only ever non-null on the paths where `currentModel` IS the live model
4923
+ // (no override, or a failed override re-assert), so the window always
4924
+ // describes the model the session actually runs.
4925
+ let resumedContextWindow = null;
4822
4926
  // Model priority (highest to lowest):
4823
4927
  // 1. ANTHROPIC_MODEL environment variable
4824
4928
  // 2. settings.model (user configuration)
@@ -4846,7 +4950,9 @@ async function getAvailableModels(query, models, sdkModels, settingsManager, log
4846
4950
  // the SDK is already running this model, and pushing a picker alias back
4847
4951
  // (e.g. "opus[1m]") could change the live model rather than describe it.
4848
4952
  if (resolvedFromInput === undefined && isResumedSession) {
4849
- currentModel = (await readResumedLiveModel(query, models, logger)) ?? currentModel;
4953
+ const live = await readResumedLiveModel(query, models, logger);
4954
+ currentModel = live.model ?? currentModel;
4955
+ resumedContextWindow = live.contextWindow;
4850
4956
  }
4851
4957
  // Skip the setModel round-trip when we can prove the SDK has already landed
4852
4958
  // on the same model. Two cases qualify:
@@ -4879,16 +4985,21 @@ async function getAvailableModels(query, models, sdkModels, settingsManager, log
4879
4985
  if (!isResumedSession)
4880
4986
  throw error;
4881
4987
  logger.error(`Failed to re-assert model "${currentModel.value}" on resume:`, error);
4882
- currentModel = (await readResumedLiveModel(query, models, logger)) ?? currentModel;
4988
+ const live = await readResumedLiveModel(query, models, logger);
4989
+ currentModel = live.model ?? currentModel;
4990
+ resumedContextWindow = live.contextWindow;
4883
4991
  }
4884
4992
  }
4885
4993
  return {
4886
- availableModels: models.map((model) => ({
4887
- modelId: model.value,
4888
- name: model.displayName,
4889
- description: model.description,
4890
- })),
4891
- currentModelId: currentModel.value,
4994
+ modelState: {
4995
+ availableModels: models.map((model) => ({
4996
+ modelId: model.value,
4997
+ name: model.displayName,
4998
+ description: model.description,
4999
+ })),
5000
+ currentModelId: currentModel.value,
5001
+ },
5002
+ resumedContextWindow,
4892
5003
  };
4893
5004
  }
4894
5005
  function getAvailableSlashCommands(commands) {
@@ -5015,6 +5126,12 @@ export function promptToClaude(prompt) {
5015
5126
  },
5016
5127
  session_id: prompt.sessionId,
5017
5128
  parent_tool_use_id: null,
5129
+ // ACP prompts are the user's own input relayed by the client. Stamp the
5130
+ // provenance explicitly: per the SDK, a host wrapping keyboard input must
5131
+ // send `{kind: "human"}` — an absent `origin` is treated as unattributed
5132
+ // and fails closed at the CLI's strict isHuman() trust gates (e.g. the
5133
+ // ultracode keyword opt-in honors only human-originated turns).
5134
+ origin: { kind: "human" },
5018
5135
  };
5019
5136
  }
5020
5137
  /**
@@ -5631,9 +5748,9 @@ function commonPrefixLength(a, b) {
5631
5748
  }
5632
5749
  return i;
5633
5750
  }
5634
- /** Best-effort first guess of a model's context window, used only as a
5635
- * fallback when the SDK's authoritative `getContextUsage` is unavailable (and
5636
- * until a `result` message arrives with the `modelUsage` value).
5751
+ /** Best-effort first guess of a model's context window, used to seed the
5752
+ * window synchronously (via `immediateContextWindow`) until a `result` message
5753
+ * arrives with the authoritative `modelUsage` value.
5637
5754
  *
5638
5755
  * Anthropic 1M-context variants encode "1m" as a distinct token in the SDK
5639
5756
  * model ID (e.g., "claude-opus-4-6-1m"), which `\b1m\b` catches without also
@@ -5643,9 +5760,12 @@ function commonPrefixLength(a, b) {
5643
5760
  * "claude-opus-4-8[1m]", "Opus 4.7 (1M context)"), so callers pass those too.
5644
5761
  * This text scan can't catch every model — some resolve to extended-context
5645
5762
  * models with no "1m" anywhere (e.g. `sonnet` → claude-sonnet-5, natively
5646
- * ~1M) — which is why `fetchContextWindowSize` is preferred wherever a live
5647
- * query is available. A miss falls back to the default window and is
5648
- * corrected by `result.modelUsage` within one turn. */
5763
+ * ~1M). Such a miss falls back to the default window and is corrected by
5764
+ * `result.modelUsage` (and cached) within one turn. We do NOT consult the
5765
+ * SDK's `getContextUsage` to close that gap: on a fresh session it is not
5766
+ * serviced before the first prompt turn (issues #886/#880, see
5767
+ * `contextWindowCache`; resumed sessions do get it, via
5768
+ * `readResumedLiveModel`). */
5649
5769
  function inferContextWindowFromModel(...texts) {
5650
5770
  if (texts.some((text) => text != null && /\b1m\b/i.test(text)))
5651
5771
  return 1_000_000;
@@ -5666,28 +5786,95 @@ async function fetchContextUsedTokens(query, logger) {
5666
5786
  return null;
5667
5787
  }
5668
5788
  }
5669
- /** Fetch the current model's full context window (`rawMaxTokens`) via the
5670
- * `getContextUsage` control request — the same source `/context` prints.
5671
- * This is the only pre-`result` signal that covers semantic aliases whose
5672
- * text carries no "1m" token (e.g. `sonnet` → claude-sonnet-5, natively
5673
- * ~1M), so it's the primary window source at session creation and on model
5674
- * switches; `inferContextWindowFromModel` remains the fallback. A returned
5675
- * window is still superseded by each `result.modelUsage.contextWindow`.
5789
+ /** Cross-session cache of authoritative context windows, keyed by
5790
+ * `${providerCacheKey}\0${modelId}` (see {@link contextWindowCacheKey}).
5791
+ * The window is a property of (model id, backend): the same resolved model id
5792
+ * (e.g. "claude-sonnet-5[1m]", the spelling of the `result.modelUsage` keys)
5793
+ * can name different context lanes behind different base URLs, routing
5794
+ * headers, or credentials, so the key carries both. Caching it module-level
5795
+ * lets a later session/new or switch that resolves to the same (backend,
5796
+ * model) — in this session or any other, within the adapter's lifetime — seed
5797
+ * the correct window synchronously with no IPC. Keying on the resolved id
5798
+ * (rather than the picker value) means aliases that resolve to the same
5799
+ * concrete model share one entry; the result handler additionally writes the
5800
+ * bare assistant-message spelling so seed-time reads that fall back to a
5801
+ * verbatim live id (rows without `resolvedModel`) can hit too.
5676
5802
  *
5677
- * (Older CLIs under-reported extended 1M windows here — commit 20ef663
5678
- * dropped the field for that reason — but the CLI vendored by the pinned
5679
- * SDK reports them correctly again.) Returns `null` on any control-request
5680
- * failure or a nonsensical (non-positive) window. */
5681
- async function fetchContextWindowSize(query, logger) {
5682
- try {
5683
- const usage = await query.getContextUsage();
5684
- return usage.rawMaxTokens > 0 ? usage.rawMaxTokens : null;
5685
- }
5686
- catch (error) {
5687
- logger.error("Failed to fetch context window size from SDK:", error);
5688
- return null;
5803
+ * Populated authoritatively by each `result.modelUsage` a turn confirms (see
5804
+ * the consumer's result handler). We deliberately never populate it from a
5805
+ * fresh session's `getContextUsage`: before that session's first prompt turn
5806
+ * has run the control request is not serviced (it stalls ~15s, and serializes
5807
+ * ahead of an awaited `setModel` — issues #886/#880, regressed in 0.59.0), so
5808
+ * it can neither beat the first `result` nor be issued cheaply before one.
5809
+ * Resumed sessions are the exception — their report IS serviced pre-turn, and
5810
+ * the session/load path seeds (but does not cache) the window from the same
5811
+ * response that restores the live model, see `readResumedLiveModel`.
5812
+ * Cleared on `logout`: 1M-context entitlement can differ per account/tier, so
5813
+ * windows learned under one login must not seed sessions under the next. */
5814
+ const contextWindowCache = new Map();
5815
+ /** The env vars that determine which LLM backend — and which context lane on
5816
+ * it — a query's API traffic reaches: endpoint selection (base URLs and the
5817
+ * Bedrock/Vertex switches with their project/region), routing/beta headers
5818
+ * (an `anthropic-beta: context-1m-…` header flips the same model id at the
5819
+ * same endpoint between context lanes), and credential identity (extended
5820
+ * context is entitlement-gated per account). Used to derive the
5821
+ * provider-cache key from the exact env a query is created with, so
5822
+ * `providers/set` config, per-session `_meta` env overrides, and ambient
5823
+ * process env are all distinguished exactly as the CLI will see them. */
5824
+ const PROVIDER_ROUTING_ENV_VARS = [
5825
+ "ANTHROPIC_BASE_URL",
5826
+ "ANTHROPIC_BEDROCK_BASE_URL",
5827
+ "ANTHROPIC_VERTEX_BASE_URL",
5828
+ "CLAUDE_CODE_USE_BEDROCK",
5829
+ "CLAUDE_CODE_USE_VERTEX",
5830
+ "ANTHROPIC_VERTEX_PROJECT_ID",
5831
+ "CLOUD_ML_REGION",
5832
+ "AWS_REGION",
5833
+ "ANTHROPIC_CUSTOM_HEADERS",
5834
+ "ANTHROPIC_API_KEY",
5835
+ "ANTHROPIC_AUTH_TOKEN",
5836
+ ];
5837
+ /** Stable identifier for the LLM backend a session's query is created against,
5838
+ * used to scope {@link contextWindowCache} per backend. Positional `\0`-join
5839
+ * of {@link PROVIDER_ROUTING_ENV_VARS} values, so no segment can masquerade
5840
+ * as another and unset vars everywhere yield one stable "default" bucket.
5841
+ * Header/credential values can be secrets; the key only ever lives as an
5842
+ * in-memory Map key and is never logged or surfaced. Over-keying is the safe
5843
+ * side: a var change that didn't really change the backend costs one cache
5844
+ * miss (heuristic seed until the next result), while under-keying would serve
5845
+ * one backend's window for another's. */
5846
+ function providerCacheKeyFor(env) {
5847
+ return PROVIDER_ROUTING_ENV_VARS.map((name) => env[name] ?? "").join("\0");
5848
+ }
5849
+ /** Compose the `contextWindowCache` key from a session's provider key and a
5850
+ * model id. `\0`-joined so the model segment can't collide with a provider
5851
+ * segment. */
5852
+ function contextWindowCacheKey(providerCacheKey, modelId) {
5853
+ return `${providerCacheKey}\0${modelId}`;
5854
+ }
5855
+ function cacheContextWindow(modelKey, window) {
5856
+ if (window > 0) {
5857
+ contextWindowCache.set(modelKey, window);
5689
5858
  }
5690
5859
  }
5860
+ /** The context window to report *right now* for a model, with NO IPC on the
5861
+ * critical path: the cached authoritative value if we've learned it (from a
5862
+ * prior turn's `result.modelUsage`, this or any session on the same backend),
5863
+ * else the text heuristic over the model row's identity strings, else the
5864
+ * default. Derives the cache key itself — `modelInfo?.resolvedModel ?? modelId`,
5865
+ * the same rule at every seed site — so read keys can't drift from the write
5866
+ * site's spelling. `authoritative` reports whether the value came from the
5867
+ * cache: an authoritative window can legitimately equal
5868
+ * DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the caller. */
5869
+ function immediateContextWindow(providerCacheKey, modelId, modelInfo) {
5870
+ const cached = contextWindowCache.get(contextWindowCacheKey(providerCacheKey, modelInfo?.resolvedModel ?? modelId));
5871
+ if (cached !== undefined)
5872
+ return { size: cached, authoritative: true };
5873
+ return {
5874
+ size: inferContextWindowFromModel(modelId, modelInfo?.resolvedModel, modelInfo?.displayName, modelInfo?.description) ?? DEFAULT_CONTEXT_WINDOW,
5875
+ authoritative: false,
5876
+ };
5877
+ }
5691
5878
  /** Translate the legacy `MAX_THINKING_TOKENS` env var into the SDK's `thinking`
5692
5879
  * option. The `maxThinkingTokens` option it used to feed is deprecated and
5693
5880
  * reduced to on/off on current models, so map the value to explicit thinking
@@ -5729,6 +5916,12 @@ function getMatchingModelUsage(modelUsage, currentModel) {
5729
5916
  }
5730
5917
  }
5731
5918
  if (bestKey) {
5732
- return modelUsage[bestKey];
5919
+ // `bestKey` is the SDK's resolved model id (e.g. "claude-sonnet-5[1m]"),
5920
+ // the same spelling as ModelInfo.resolvedModel — the primary key the
5921
+ // window is cached under. `currentModel` (the assistant message's
5922
+ // `.model`) can be the bare form (e.g. "claude-sonnet-5"); the result
5923
+ // handler caches under that spelling too, for seed-time reads that fall
5924
+ // back to a bare id (rows without `resolvedModel`).
5925
+ return { key: bestKey, usage: modelUsage[bestKey] };
5733
5926
  }
5734
5927
  }
package/dist/tools.d.ts CHANGED
@@ -3,7 +3,6 @@ import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
3
3
  import { TaskCreateInput, TaskCreateOutput, TaskUpdateInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
4
4
  import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
5
5
  import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
6
- import { Logger } from "./acp-agent.js";
7
6
  interface ToolInfo {
8
7
  title: string;
9
8
  kind: ToolKind;
@@ -82,7 +81,7 @@ export declare function toolUpdateFromDiffToolResponse(toolResponse: unknown): {
82
81
  export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHook, }: {
83
82
  onPostToolUseHook?: (toolUseID: string, toolInput: unknown, toolResponse: unknown) => Promise<void>;
84
83
  }) => void;
85
- export declare const createPostToolUseHook: (logger?: Logger, options?: {
84
+ export declare const createPostToolUseHook: (options?: {
86
85
  onEnterPlanMode?: () => Promise<void>;
87
86
  }) => HookCallback;
88
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAKhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAA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AAC,CAAC;CACpB,SAKF,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAC/B,UAAU;IAAE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAiBtD,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACxB,SAAS;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAsBpE,CAAC"}
package/dist/tools.js CHANGED
@@ -362,9 +362,38 @@ function structuredResult(toolUseResult) {
362
362
  * matching rather than mangle the report.
363
363
  */
364
364
  function stripAgentTrailer(text) {
365
- return text
366
- .replace(/\n?<usage>[\s\S]*?<\/usage>\s*$/, "")
367
- .replace(/\n?agentId: [\w-]+ \([^)]*\)\s*$/, "");
365
+ return stripAgentIdLine(stripUsageBlock(text));
366
+ }
367
+ const USAGE_OPEN = "<usage>";
368
+ const USAGE_CLOSE = "</usage>";
369
+ /** Remove a trailing `<usage>…</usage>` block, plus trailing whitespace and
370
+ * one preceding newline. Matches from the *last* `<usage>` so a report that
371
+ * merely mentions the marker earlier isn't truncated at the mention. */
372
+ function stripUsageBlock(text) {
373
+ const body = text.trimEnd();
374
+ if (!body.endsWith(USAGE_CLOSE)) {
375
+ return text;
376
+ }
377
+ const open = body.lastIndexOf(USAGE_OPEN, body.length - USAGE_CLOSE.length - USAGE_OPEN.length);
378
+ if (open === -1) {
379
+ return text;
380
+ }
381
+ return body.slice(0, open > 0 && body[open - 1] === "\n" ? open - 1 : open);
382
+ }
383
+ /** The continuation line, anchored to a whole line so the regex has a single
384
+ * start position and no ambiguous repetition (`[\w-]+` can't consume the
385
+ * following space, `[^)]*` can't consume the closing paren) — it runs in
386
+ * linear time on any input. */
387
+ const AGENT_ID_LINE = /^agentId: [\w-]+ \([^)]*\)$/;
388
+ /** Remove a final `agentId: <id> (…)` line, plus trailing whitespace and the
389
+ * newline that preceded the line. */
390
+ function stripAgentIdLine(text) {
391
+ const body = text.trimEnd();
392
+ const lineStart = body.lastIndexOf("\n") + 1;
393
+ if (!AGENT_ID_LINE.test(body.slice(lineStart))) {
394
+ return text;
395
+ }
396
+ return body.slice(0, Math.max(lineStart - 1, 0));
368
397
  }
369
398
  /** Apply {@link stripAgentTrailer} across a raw tool_result `content` (plain
370
399
  * string or block array), leaving non-text blocks untouched. */
@@ -898,7 +927,7 @@ export const registerHookCallback = (toolUseID, { onPostToolUseHook, }) => {
898
927
  };
899
928
  };
900
929
  /* A callback for Claude Code that is called when receiving a PostToolUse hook */
901
- export const createPostToolUseHook = (logger = console, options) => async (input, toolUseID) => {
930
+ export const createPostToolUseHook = (options) => async (input, toolUseID) => {
902
931
  if (input.hook_event_name === "PostToolUse") {
903
932
  // Handle EnterPlanMode tool - notify client of mode change after successful execution
904
933
  if (input.tool_name === "EnterPlanMode" && options?.onEnterPlanMode) {
@@ -908,12 +937,8 @@ export const createPostToolUseHook = (logger = console, options) => async (input
908
937
  const onPostToolUseHook = toolUseCallbacks[toolUseID]?.onPostToolUseHook;
909
938
  if (onPostToolUseHook) {
910
939
  await onPostToolUseHook(toolUseID, input.tool_input, input.tool_response);
911
- delete toolUseCallbacks[toolUseID]; // Cleanup after execution
912
- }
913
- else {
914
- logger.error(`No onPostToolUseHook found for tool use ID: ${toolUseID}`);
915
- delete toolUseCallbacks[toolUseID];
916
940
  }
941
+ delete toolUseCallbacks[toolUseID]; // Cleanup after execution
917
942
  }
918
943
  }
919
944
  return { continue: true };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.59.0",
6
+ "version": "0.60.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,16 +64,16 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@agentclientprotocol/sdk": "1.2.1",
67
- "@anthropic-ai/claude-agent-sdk": "0.3.207",
67
+ "@anthropic-ai/claude-agent-sdk": "0.3.215",
68
68
  "zod": "^3.25.0 || ^4.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@anthropic-ai/sdk": "0.111.0",
71
+ "@anthropic-ai/sdk": "0.112.3",
72
72
  "@eslint/js": "10.0.1",
73
73
  "@tsconfig/node22": "22.0.5",
74
74
  "@types/node": "26.1.1",
75
- "@typescript-eslint/eslint-plugin": "8.63.0",
76
- "@typescript-eslint/parser": "8.63.0",
75
+ "@typescript-eslint/eslint-plugin": "8.64.0",
76
+ "@typescript-eslint/parser": "8.64.0",
77
77
  "eslint": "10.7.0",
78
78
  "eslint-config-prettier": "10.1.8",
79
79
  "globals": "17.7.0",