@agentclientprotocol/claude-agent-acp 0.106.0 → 0.106.1-preview.10

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.
Files changed (68) hide show
  1. package/README.md +1 -76
  2. package/dist/async-tasks.d.ts +1 -1
  3. package/dist/async-tasks.js +1 -1
  4. package/dist/context-window.d.ts +11 -9
  5. package/dist/context-window.d.ts.map +1 -1
  6. package/dist/context-window.js +12 -13
  7. package/dist/managed-policy.d.ts +9 -0
  8. package/dist/managed-policy.d.ts.map +1 -1
  9. package/dist/managed-policy.js +25 -0
  10. package/dist/native-subagents.d.ts +72 -9
  11. package/dist/native-subagents.d.ts.map +1 -1
  12. package/dist/native-subagents.js +130 -12
  13. package/dist/session-failure-extension.d.ts +15 -1
  14. package/dist/session-failure-extension.d.ts.map +1 -1
  15. package/dist/session-failure-extension.js +63 -0
  16. package/dist/session-fast-mode.d.ts +16 -10
  17. package/dist/session-fast-mode.d.ts.map +1 -1
  18. package/dist/session-fast-mode.js +36 -25
  19. package/dist/session-index/transcript-scan.d.ts +4 -2
  20. package/dist/session-index/transcript-scan.d.ts.map +1 -1
  21. package/dist/session-index/transcript-scan.js +67 -12
  22. package/dist/session-model.d.ts +22 -16
  23. package/dist/session-model.d.ts.map +1 -1
  24. package/dist/session-model.js +66 -38
  25. package/dist/session-usage.d.ts +8 -17
  26. package/dist/session-usage.d.ts.map +1 -1
  27. package/dist/session-usage.js +8 -21
  28. package/dist/settings.d.ts +2 -0
  29. package/dist/settings.d.ts.map +1 -1
  30. package/dist/settings.js +12 -0
  31. package/dist/subagent-replay.d.ts +16 -1
  32. package/dist/subagent-replay.d.ts.map +1 -1
  33. package/dist/subagent-replay.js +28 -1
  34. package/dist/tool-calls/renderer.d.ts +26 -0
  35. package/dist/tool-calls/renderer.d.ts.map +1 -1
  36. package/dist/tool-calls/renderer.js +30 -0
  37. package/dist/v1/acp-agent.d.ts +31 -68
  38. package/dist/v1/acp-agent.d.ts.map +1 -1
  39. package/dist/v1/acp-agent.js +71 -271
  40. package/dist/v1/async-task-stop.d.ts +11 -0
  41. package/dist/v1/async-task-stop.d.ts.map +1 -0
  42. package/dist/v1/async-task-stop.js +18 -0
  43. package/dist/v1/session-fingerprint.d.ts +16 -0
  44. package/dist/v1/session-fingerprint.d.ts.map +1 -0
  45. package/dist/v1/session-fingerprint.js +129 -0
  46. package/dist/v1/steering.d.ts +48 -0
  47. package/dist/v1/steering.d.ts.map +1 -0
  48. package/dist/v1/steering.js +41 -0
  49. package/dist/v2/agent.js +10 -4
  50. package/dist/v2/outcome.d.ts +3 -2
  51. package/dist/v2/outcome.d.ts.map +1 -1
  52. package/dist/v2/outcome.js +8 -3
  53. package/dist/v2/reports.d.ts +2 -2
  54. package/dist/v2/reports.d.ts.map +1 -1
  55. package/dist/v2/reports.js +3 -6
  56. package/dist/v2/session.d.ts +11 -4
  57. package/dist/v2/session.d.ts.map +1 -1
  58. package/dist/v2/session.js +18 -4
  59. package/dist/v2/setup.js +1 -1
  60. package/dist/v2/stream.d.ts +2 -4
  61. package/dist/v2/stream.d.ts.map +1 -1
  62. package/dist/v2/stream.js +5 -9
  63. package/dist/v2/subagent-replay.js +2 -2
  64. package/dist/v2/tasks.d.ts +29 -11
  65. package/dist/v2/tasks.d.ts.map +1 -1
  66. package/dist/v2/tasks.js +69 -19
  67. package/dist/v2/tool-call.js +3 -0
  68. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import type { SessionConfigOption } from "@agentclientprotocol/sdk/unstable";
2
- import type { ModelInfo, Query, Settings } from "@anthropic-ai/claude-agent-sdk";
2
+ import { type ModelInfo, type Query, type Settings } from "@anthropic-ai/claude-agent-sdk";
3
3
  export declare const MODEL_CONFIG_ID = "model";
4
4
  export type SessionModelState = {
5
5
  availableModels: Array<{
@@ -52,15 +52,20 @@ export declare function buildModelConfigOption(models: SessionModelState, modelI
52
52
  */
53
53
  export declare function aliasResumedModelRow(models: ModelInfo[], resumedModel: string | undefined): ModelInfo[];
54
54
  /**
55
- * Whether managed `deniedModels` blocks a model id, following the CLI's rules
56
- * closely enough for the picker: a family alias blocks the whole family, and a
57
- * model id blocks that version in every spelling plus the later minor versions
58
- * it prefixes (`claude-opus-5` also blocks `claude-opus-5-5`). Entries share
59
- * `normalizeModelId`, so `claude-opus-4.5` or `anthropic/claude-opus-4.5` also
60
- * blocks `claude-opus-4-5`, which the CLI may still allow. The CLI stays the
61
- * enforcer; this only keeps the picker from offering a refused row.
55
+ * Which of `ids` a managed `deniedModels` list blocks, by the CLI's own entry
56
+ * rules: the SDK's `matchDeniedModels`, asked about each of the
57
+ * {@link deniedModelSpellings} of an id.
58
+ * - A family alias (`opus`) blocks the family.
59
+ * - A model id blocks that version in every spelling, and the later minor
60
+ * versions when it names none (`claude-opus-5` also blocks `claude-opus-5-5`).
61
+ * - Any other entry (`claude-opus-4.5`, `my-model`) blocks only that name,
62
+ * alone or as the last path segment (`gateway/my-model`).
63
+ * - `default`, `best` and `opusplan` block nothing.
64
+ *
65
+ * The CLI stays the enforcer; this only keeps the picker from offering a row
66
+ * that `setModel` would refuse.
62
67
  */
63
- export declare function isDeniedModel(modelId: string, deniedModels: readonly string[]): boolean;
68
+ export declare function deniedModelIds(ids: readonly string[], deniedModels: readonly string[]): Promise<Set<string>>;
64
69
  /**
65
70
  * Restrict the SDK's model list to the user's `availableModels` allowlist
66
71
  * (already merged-and-deduped across settings sources by `SettingsManager`).
@@ -76,10 +81,11 @@ export declare function isDeniedModel(modelId: string, deniedModels: readonly st
76
81
  * - `undefined` is handled by the caller (no allowlist applied).
77
82
  * - The Default option is unaffected by `availableModels` — it always remains
78
83
  * available, even when the allowlist is `[]`.
79
- * - Managed `deniedModels` wins over the allowlist, so a denied entry is
80
- * dropped even though the CLI would otherwise leave it unmatched.
84
+ * - Managed `deniedModels` wins over the allowlist: an entry is dropped when
85
+ * the list blocks its name, its `modelOverrides` target, or the model of the
86
+ * row it resolves to (see {@link deniedModelIds}).
81
87
  */
82
- export declare function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], allowlist: string[], settingsModelOverrides?: Record<string, string>, deniedModels?: readonly string[]): ModelInfo[];
88
+ export declare function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], allowlist: string[], settingsModelOverrides?: Record<string, string>, deniedModels?: readonly string[]): Promise<ModelInfo[]>;
83
89
  /**
84
90
  * Keep the SDK models the `providers/set` gateway listed (`listGatewayModels`,
85
91
  * `listBedrockModels`). A row matches when its `resolvedModel` (or
@@ -119,10 +125,10 @@ export declare function narrowToGatewayModels(models: ModelInfo[], listedModelId
119
125
  * capability flag (current and future); the identity fields are overridden
120
126
  * because the fuzzy-matched sibling's resolvedModel/displayName/description
121
127
  * can describe a different context lane and would poison later resolvedModel
122
- * matching (a model switch that the adapter did not make) and context-window
123
- * inference if they traveled under this id. `allowlistedModelInfo` is the
124
- * allowlisted entry alone, the only one whose identity strings are a
125
- * trustworthy window signal.
128
+ * matching (a model switch that the adapter did not make) and the lookup of
129
+ * the learned context window (`immediateContextWindow`) if they traveled under
130
+ * this id. `allowlistedModelInfo` is the allowlisted entry alone, the only one
131
+ * whose `resolvedModel` that lookup may use.
126
132
  */
127
133
  export declare function withCurrentModelInfo(allowedModels: ModelInfo[], sdkModels: ModelInfo[], currentModelId: string): {
128
134
  allowlistedModelInfo: ModelInfo | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"session-model.d.ts","sourceRoot":"","sources":["../src/session-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAIjF,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,C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,wBAAgB,aAAa,CAC3B,aAAa,EAAE,SAAS,mBAAmB,EAAE,EAC7C,UAAU,EAAE,SAAS,EAAE,EACvB,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAW7C"}
@@ -1,3 +1,5 @@
1
+ // matchDeniedModels is marked @alpha in the SDK; API may shift in a future release.
2
+ import { matchDeniedModels, } from "@anthropic-ai/claude-agent-sdk";
1
3
  import { AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY, withAirMeta } from "./air-extension.js";
2
4
  import { bedrockRegionPrefix } from "./gateway-models.js";
3
5
  export const MODEL_CONFIG_ID = "model";
@@ -85,7 +87,7 @@ function containsWords(haystack, needle) {
85
87
  return false;
86
88
  }
87
89
  /** `id` without the gateway spellings that `normalizeModelId` keeps for
88
- * `deniedModels` and gateway listings: path segments before `claude-`
90
+ * gateway listings: path segments before `claude-`
89
91
  * (`vertex_ai/`, `openrouter/anthropic/`, `publishers/anthropic/models/`)
90
92
  * and the Anthropic API's `-latest` suffix (`claude-3-5-haiku-latest`). */
91
93
  function withoutGatewaySpelling(id) {
@@ -308,8 +310,8 @@ export function aliasResumedModelRow(models, resumedModel) {
308
310
  }
309
311
  /** A model id without the spellings that name the same model: provider
310
312
  * prefixes, dates, version suffixes, `:variant` suffixes, dotted versions,
311
- * `-fast` and context hints. `deniedModels` and gateway listings both match on
312
- * it. OpenRouter lists `anthropic/claude-opus-5.5:batch[1m]`, which normalizes
313
+ * `-fast` and context hints. Gateway listings match on it. OpenRouter lists
314
+ * `anthropic/claude-opus-5.5:batch[1m]`, which normalizes
313
315
  * to `claude-opus-5-5`; `anthropic/openai/gpt-5` keeps its `openai/` prefix and
314
316
  * matches no Claude id. */
315
317
  function normalizeModelId(value) {
@@ -331,27 +333,49 @@ function normalizeModelId(value) {
331
333
  .replace(/-fast$/, "")
332
334
  .replace(/-\d{8}$/, ""));
333
335
  }
336
+ /** A path that no model id starts with. Nothing enforces that no
337
+ * `deniedModels` entry names it (see {@link deniedModelSpellings}). */
338
+ const VERSION_SPELLING_PATH = "version-of/";
334
339
  /**
335
- * Whether managed `deniedModels` blocks a model id, following the CLI's rules
336
- * closely enough for the picker: a family alias blocks the whole family, and a
337
- * model id blocks that version in every spelling plus the later minor versions
338
- * it prefixes (`claude-opus-5` also blocks `claude-opus-5-5`). Entries share
339
- * `normalizeModelId`, so `claude-opus-4.5` or `anthropic/claude-opus-4.5` also
340
- * blocks `claude-opus-4-5`, which the CLI may still allow. The CLI stays the
341
- * enforcer; this only keeps the picker from offering a refused row.
340
+ * The spellings of `id` to ask the SDK's `matchDeniedModels` about. That
341
+ * function compares an id with the entries alone. The CLI blocks more
342
+ * (`setModel` against CLI 2.1.323):
343
+ * - a last path segment that an exact-name entry names: `my-model` blocks
344
+ * `gateway/my-model`;
345
+ * - a version behind a `:variant` suffix or written with a dot:
346
+ * `claude-opus-5-5` blocks `claude-opus-5-5:free` and
347
+ * `anthropic/claude-opus-5.5`.
348
+ *
349
+ * An exact-name entry does not block a `:variant`: `my-model` leaves
350
+ * `my-model:free` allowed. So the version spelling goes behind a path, which
351
+ * the SDK ignores for a versioned id and which keeps the spelling from
352
+ * equalling an exact name.
342
353
  */
343
- export function isDeniedModel(modelId, deniedModels) {
344
- const id = normalizeModelId(modelId);
345
- if (!id)
346
- return false;
347
- return deniedModels.some((entry) => {
348
- const denied = normalizeModelId(entry);
349
- if (!denied)
350
- return false;
351
- if (MODEL_FAMILY_ALIASES.has(denied))
352
- return id === denied || id.includes(`-${denied}`);
353
- return id === denied || id.startsWith(`${denied}-`);
354
- });
354
+ function deniedModelSpellings(id) {
355
+ const lastSegment = id.slice(id.lastIndexOf("/") + 1);
356
+ const version = lastSegment.replace(/:.*$/, "").replace(/(?<=\d)\.(?=\d)/g, "-");
357
+ return [id, lastSegment, `${VERSION_SPELLING_PATH}${version}`];
358
+ }
359
+ /**
360
+ * Which of `ids` a managed `deniedModels` list blocks, by the CLI's own entry
361
+ * rules: the SDK's `matchDeniedModels`, asked about each of the
362
+ * {@link deniedModelSpellings} of an id.
363
+ * - A family alias (`opus`) blocks the family.
364
+ * - A model id blocks that version in every spelling, and the later minor
365
+ * versions when it names none (`claude-opus-5` also blocks `claude-opus-5-5`).
366
+ * - Any other entry (`claude-opus-4.5`, `my-model`) blocks only that name,
367
+ * alone or as the last path segment (`gateway/my-model`).
368
+ * - `default`, `best` and `opusplan` block nothing.
369
+ *
370
+ * The CLI stays the enforcer; this only keeps the picker from offering a row
371
+ * that `setModel` would refuse.
372
+ */
373
+ export async function deniedModelIds(ids, deniedModels) {
374
+ if (ids.length === 0 || deniedModels.length === 0)
375
+ return new Set();
376
+ const asked = ids.flatMap((id) => deniedModelSpellings(id).map((spelling) => ({ id, spelling })));
377
+ const { denied } = await matchDeniedModels(asked.map(({ spelling }) => spelling), deniedModels);
378
+ return new Set(asked.filter((_, index) => denied[index]).map(({ id }) => id));
355
379
  }
356
380
  /**
357
381
  * Restrict the SDK's model list to the user's `availableModels` allowlist
@@ -368,10 +392,11 @@ export function isDeniedModel(modelId, deniedModels) {
368
392
  * - `undefined` is handled by the caller (no allowlist applied).
369
393
  * - The Default option is unaffected by `availableModels` — it always remains
370
394
  * available, even when the allowlist is `[]`.
371
- * - Managed `deniedModels` wins over the allowlist, so a denied entry is
372
- * dropped even though the CLI would otherwise leave it unmatched.
395
+ * - Managed `deniedModels` wins over the allowlist: an entry is dropped when
396
+ * the list blocks its name, its `modelOverrides` target, or the model of the
397
+ * row it resolves to (see {@link deniedModelIds}).
373
398
  */
374
- export function applyAvailableModelsAllowlist(sdkModels, allowlist, settingsModelOverrides, deniedModels = []) {
399
+ export async function applyAvailableModelsAllowlist(sdkModels, allowlist, settingsModelOverrides, deniedModels = []) {
375
400
  // Default is always preserved per the docs. Synthesize one if the SDK
376
401
  // didn't surface it so downstream code (e.g. `getAvailableModels` picking
377
402
  // `models[0]` as a fallback) still has something to work with.
@@ -390,18 +415,21 @@ export function applyAvailableModelsAllowlist(sdkModels, allowlist, settingsMode
390
415
  // opaque provider IDs) often won't textually resemble anything in
391
416
  // `sdkModelsWithoutDefault`. Only the entry's surfaced `value` becomes the
392
417
  // override target, so it's what `setModel` ends up passing to the API.
393
- for (const entry of allowlist) {
418
+ const entries = allowlist.flatMap((entry) => {
394
419
  const trimmed = entry.trim();
395
- if (!trimmed || seen.has(trimmed))
396
- continue;
397
- const overridden = settingsModelOverrides?.[trimmed];
398
- const effective = overridden ?? trimmed;
399
- if (seen.has(effective))
400
- continue;
420
+ if (!trimmed)
421
+ return [];
422
+ const effective = settingsModelOverrides?.[trimmed] ?? trimmed;
401
423
  const sdkMatch = resolveModelPreference(sdkModelsWithoutDefault, trimmed);
402
- if ([trimmed, effective, sdkMatch?.resolvedModel].some((id) => id != null && isDeniedModel(id, deniedModels))) {
424
+ const ids = [trimmed, effective, ...(sdkMatch?.resolvedModel ? [sdkMatch.resolvedModel] : [])];
425
+ return [{ trimmed, effective, sdkMatch, ids }];
426
+ });
427
+ const denied = await deniedModelIds(entries.flatMap(({ ids }) => ids), deniedModels);
428
+ for (const { trimmed, effective, sdkMatch, ids } of entries) {
429
+ if (seen.has(trimmed) || seen.has(effective))
430
+ continue;
431
+ if (ids.some((id) => denied.has(id)))
403
432
  continue;
404
- }
405
433
  if (sdkMatch) {
406
434
  result.push({ ...sdkMatch, value: effective });
407
435
  }
@@ -485,10 +513,10 @@ export function narrowToGatewayModels(models, listedModelIds, regionPrefix) {
485
513
  * capability flag (current and future); the identity fields are overridden
486
514
  * because the fuzzy-matched sibling's resolvedModel/displayName/description
487
515
  * can describe a different context lane and would poison later resolvedModel
488
- * matching (a model switch that the adapter did not make) and context-window
489
- * inference if they traveled under this id. `allowlistedModelInfo` is the
490
- * allowlisted entry alone, the only one whose identity strings are a
491
- * trustworthy window signal.
516
+ * matching (a model switch that the adapter did not make) and the lookup of
517
+ * the learned context window (`immediateContextWindow`) if they traveled under
518
+ * this id. `allowlistedModelInfo` is the allowlisted entry alone, the only one
519
+ * whose `resolvedModel` that lookup may use.
492
520
  */
493
521
  export function withCurrentModelInfo(allowedModels, sdkModels, currentModelId) {
494
522
  const allowlistedModelInfo = allowedModels.find((m) => m.value === currentModelId);
@@ -25,7 +25,14 @@ export declare const ZERO_USAGE: Readonly<{
25
25
  cache_read_input_tokens: 0;
26
26
  cache_creation_input_tokens: 0;
27
27
  }>;
28
- export declare const DEFAULT_CONTEXT_WINDOW = 200000;
28
+ /**
29
+ * The context window reported for a model until Claude Code says what it is
30
+ * (see `context-window.ts`): 1M, the window Claude Code itself assumes for a
31
+ * model id it does not know (since 2.1.323). Claude Code reports 200K for an
32
+ * older model such as `claude-sonnet-4-5`, and for every model under
33
+ * `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`.
34
+ */
35
+ export declare const DEFAULT_CONTEXT_WINDOW = 1000000;
29
36
  /** `_meta.quota` for work that spent `usage` in its main agent loop and
30
37
  * `modelUsage` by model (see `turnQuotaMeta` in `v1/acp-agent.ts`). */
31
38
  export declare function quotaMeta(usage: AccumulatedUsage, modelUsage: ModelTokenTally | undefined): {
@@ -102,22 +109,6 @@ export declare function snapshotFromUsage(usage: {
102
109
  cache_read_input_tokens?: number | null;
103
110
  cache_creation_input_tokens?: number | null;
104
111
  }): UsageSnapshot;
105
- /** Best-effort first guess of a model's context window, used to seed the
106
- * window synchronously (via `immediateContextWindow`) until a `result` message
107
- * arrives with the authoritative `modelUsage` value.
108
- *
109
- * Anthropic 1M-context variants encode "1m" as a distinct token in the SDK
110
- * model ID (e.g., "claude-opus-4-6-1m"), which `\b1m\b` catches without also
111
- * matching things like "10m" or embedded substrings. Semantic aliases like
112
- * `default` carry no such token in the ID, but their `resolvedModel` and the
113
- * SDK's human-facing `displayName`/`description` can (e.g.
114
- * "claude-opus-4-8[1m]", "Opus 4.7 (1M context)"), so callers pass those too.
115
- * This text scan can't catch every model — some resolve to extended-context
116
- * models with no "1m" anywhere (e.g. `sonnet` → claude-sonnet-5, natively
117
- * ~1M). Such a miss falls back to the default window, is refined by the
118
- * background `getContextUsage` (`refreshContextWindowInBackground`), and is
119
- * corrected by `result.modelUsage` (and cached) within one turn. */
120
- export declare function inferContextWindowFromModel(...texts: Array<string | undefined>): number | null;
121
112
  export declare function getMatchingModelUsage(modelUsage: Record<string, ModelUsage>, currentModel: string): {
122
113
  key: string;
123
114
  usage: ModelUsage;
@@ -1 +1 @@
1
- {"version":3,"file":"session-usage.d.ts","sourceRoot":"","sources":["../src/session-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;yDACyD;AACzD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;EAKrB,CAAC;AAEH,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAE7C;wEACwE;AACxE,wBAAgB,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;EAUzF;AAmBD;8EAC8E;AAC9E,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAE1D;AAED;;;6DAG6D;AAC7D,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAA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AAC;IAC9B,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,2BAA2B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,EACD,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB,eAAe,CAWjB;AAED;6CAC6C;AAC7C,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAAG,eAAe,CAchG;AAED;;;+DAG+D;AAC/D,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAOxD;AAED;;;;;;;qEAOqE;AACrE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,2BAA2B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,GAAG,aAAa,CAOhB;AAUD,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,YAAY,EAAE,MAAM;;;cAsBrB"}
@@ -4,7 +4,14 @@ export const ZERO_USAGE = Object.freeze({
4
4
  cache_read_input_tokens: 0,
5
5
  cache_creation_input_tokens: 0,
6
6
  });
7
- export const DEFAULT_CONTEXT_WINDOW = 200000;
7
+ /**
8
+ * The context window reported for a model until Claude Code says what it is
9
+ * (see `context-window.ts`): 1M, the window Claude Code itself assumes for a
10
+ * model id it does not know (since 2.1.323). Claude Code reports 200K for an
11
+ * older model such as `claude-sonnet-4-5`, and for every model under
12
+ * `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`.
13
+ */
14
+ export const DEFAULT_CONTEXT_WINDOW = 1_000_000;
8
15
  /** `_meta.quota` for work that spent `usage` in its main agent loop and
9
16
  * `modelUsage` by model (see `turnQuotaMeta` in `v1/acp-agent.ts`). */
10
17
  export function quotaMeta(usage, modelUsage) {
@@ -154,26 +161,6 @@ function commonPrefixLength(a, b) {
154
161
  }
155
162
  return i;
156
163
  }
157
- /** Best-effort first guess of a model's context window, used to seed the
158
- * window synchronously (via `immediateContextWindow`) until a `result` message
159
- * arrives with the authoritative `modelUsage` value.
160
- *
161
- * Anthropic 1M-context variants encode "1m" as a distinct token in the SDK
162
- * model ID (e.g., "claude-opus-4-6-1m"), which `\b1m\b` catches without also
163
- * matching things like "10m" or embedded substrings. Semantic aliases like
164
- * `default` carry no such token in the ID, but their `resolvedModel` and the
165
- * SDK's human-facing `displayName`/`description` can (e.g.
166
- * "claude-opus-4-8[1m]", "Opus 4.7 (1M context)"), so callers pass those too.
167
- * This text scan can't catch every model — some resolve to extended-context
168
- * models with no "1m" anywhere (e.g. `sonnet` → claude-sonnet-5, natively
169
- * ~1M). Such a miss falls back to the default window, is refined by the
170
- * background `getContextUsage` (`refreshContextWindowInBackground`), and is
171
- * corrected by `result.modelUsage` (and cached) within one turn. */
172
- export function inferContextWindowFromModel(...texts) {
173
- if (texts.some((text) => text != null && /\b1m\b/i.test(text)))
174
- return 1_000_000;
175
- return null;
176
- }
177
164
  export function getMatchingModelUsage(modelUsage, currentModel) {
178
165
  let bestKey = null;
179
166
  let bestLen = 0;
@@ -29,6 +29,8 @@ export declare class SettingsManager {
29
29
  private managedModelSettings;
30
30
  private managedApiKeyHelper?;
31
31
  private managedCompactionSettings;
32
+ /** The policy sources last logged as not loaded (see {@link unloadedPolicySources}). */
33
+ private unloadedPolicy?;
32
34
  private watchers;
33
35
  private onChange?;
34
36
  private logger;
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAC;AA0BxC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE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ode are marked @alpha in the
4
4
  // SDK; API may shift in a future release.
5
5
  import { filterEscalatingDefaultMode, resolveSettings, } from "@anthropic-ai/claude-agent-sdk";
6
+ import { unloadedPolicySources } from "./managed-policy.js";
6
7
  import { claudeConfigDir } from "./paths.js";
7
8
  /**
8
9
  * Permission rule format examples:
@@ -41,6 +42,8 @@ export class SettingsManager {
41
42
  managedModelSettings = {};
42
43
  managedApiKeyHelper;
43
44
  managedCompactionSettings = {};
45
+ /** The policy sources last logged as not loaded (see {@link unloadedPolicySources}). */
46
+ unloadedPolicy;
44
47
  watchers = [];
45
48
  onChange;
46
49
  logger;
@@ -92,6 +95,15 @@ export class SettingsManager {
92
95
  async loadAllSettings() {
93
96
  try {
94
97
  const resolved = await resolveSettings({ cwd: this.cwd });
98
+ // Once per change: a reload after each settings file edit would repeat it.
99
+ const unloaded = unloadedPolicySources(resolved);
100
+ if (unloaded !== this.unloadedPolicy) {
101
+ this.unloadedPolicy = unloaded;
102
+ if (unloaded) {
103
+ this.logger.error(`Managed settings did not load from ${unloaded}: the session's settings ` +
104
+ "and model list do not reflect it. Claude Code reads the policy itself.");
105
+ }
106
+ }
95
107
  this.effective = filterEscalatingDefaultMode(resolved);
96
108
  // The CLI reads `deniedModels` from managed settings only.
97
109
  this.managedDeniedModels = resolved.sources
@@ -20,7 +20,10 @@
20
20
  * reached the call is that message too: the sender's outgoing view, at the
21
21
  * call, and the child's incoming one, in the child's history. A child's
22
22
  * history follows its launch, so a call to a child from its parent is always
23
- * delivered first. Any other SendMessage call stays a tool call.
23
+ * delivered first. Any other SendMessage call stays a tool call. As live, a
24
+ * TaskStop or SendMessage call that the client is shown and that names a
25
+ * replayed child by its agent id carries the RFD's `session` reference to it
26
+ * (`ReplayTranscript.withTarget`).
24
27
  *
25
28
  * Right after its announcement, each child gets its `model` option: the model
26
29
  * of its first response, in its transcript. A later response with another
@@ -99,7 +102,17 @@ export declare class ReplayTranscript<Child extends ReplayChild = ReplayChild> {
99
102
  readonly omitted: Set<string>;
100
103
  /** The SubagentHandback calls, by tool use id. */
101
104
  readonly handbacks: Map<string, ReplayHandback>;
105
+ /** The agent that each TaskStop or SendMessage call names (see `targetAgentId`), by tool use id. */
106
+ private readonly targets;
102
107
  constructor(history: SubagentHistory);
108
+ /**
109
+ * `notification`, a replayed tool call update that the client is shown on
110
+ * the session `shownOn`, with the RFD's `session` reference when the call
111
+ * names a child of another session by its agent id, as live
112
+ * (`NativeSubagentRuntime.withTarget`). Only a child that the replay
113
+ * announced before the update is referenced.
114
+ */
115
+ withTarget(notification: AcpSessionNotification, shownOn: string): AcpSessionNotification;
103
116
  /**
104
117
  * Registers the launches, the launch results, and the SendMessage calls in
105
118
  * `messages`, the transcript of the session `ownerSessionId`.
@@ -137,6 +150,8 @@ export declare class RfdSubagentReplay {
137
150
  */
138
151
  scan(messages: readonly SessionMessage[], ownerSessionId: string): void;
139
152
  /** The child that the tool use `toolUseId` launched, when the replay shows it. */
153
+ /** See {@link ReplayTranscript.withTarget}. */
154
+ withTarget(notification: AcpSessionNotification, shownOn: string): AcpSessionNotification;
140
155
  childOfLaunch(toolUseId: string): ReplayChild | undefined;
141
156
  /**
142
157
  * Announces `child` on its parent, as live: running, with the parent's
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-replay.d.ts","sourceRoot":"","sources":["../src/subagent-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAOL,KAAK,UAAU,EAMf,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CA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QAAQ,CAAC,EAAE;IAAE,aAAa,EAAE,QAAQ,CAAA;CAAE,CAAC,CASxE"}
@@ -1,5 +1,5 @@
1
1
  import { statSync } from "node:fs";
2
- import { childModelOption, HANDBACK_TOOL, handbackMessage, isNativeSubagentControlTool, launchReply, linkedSessionMessages, nativeSubagentState, responseModelEntry, rfdEndState, rfdLabels, sameDirectory, } from "./native-subagents.js";
2
+ import { childModelOption, HANDBACK_TOOL, handbackMessage, isNativeSubagentControlTool, launchReply, linkedSessionMessages, nativeSubagentState, responseModelEntry, rfdEndState, rfdLabels, sameDirectory, targetAgentId, withSessionReference, } from "./native-subagents.js";
3
3
  import { noticeUpdate } from "./session-notices.js";
4
4
  /**
5
5
  * What both replays read from the transcripts before they send anything: the
@@ -18,9 +18,29 @@ export class ReplayTranscript {
18
18
  omitted = new Set();
19
19
  /** The SubagentHandback calls, by tool use id. */
20
20
  handbacks = new Map();
21
+ /** The agent that each TaskStop or SendMessage call names (see `targetAgentId`), by tool use id. */
22
+ targets = new Map();
21
23
  constructor(history) {
22
24
  this.history = history;
23
25
  }
26
+ /**
27
+ * `notification`, a replayed tool call update that the client is shown on
28
+ * the session `shownOn`, with the RFD's `session` reference when the call
29
+ * names a child of another session by its agent id, as live
30
+ * (`NativeSubagentRuntime.withTarget`). Only a child that the replay
31
+ * announced before the update is referenced.
32
+ */
33
+ withTarget(notification, shownOn) {
34
+ const { update } = notification;
35
+ if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
36
+ return notification;
37
+ }
38
+ const agentId = this.targets.get(update.toolCallId);
39
+ const child = agentId !== undefined ? this.byAgentId.get(agentId) : undefined;
40
+ if (!child?.announced || child.sessionId === shownOn)
41
+ return notification;
42
+ return withSessionReference(notification, child.sessionId);
43
+ }
24
44
  /**
25
45
  * Registers the launches, the launch results, and the SendMessage calls in
26
46
  * `messages`, the transcript of the session `ownerSessionId`.
@@ -29,6 +49,9 @@ export class ReplayTranscript {
29
49
  for (const message of messages) {
30
50
  for (const block of contentBlocks(message)) {
31
51
  if (block.type === "tool_use" && typeof block.id === "string") {
52
+ const agentId = targetAgentId(block.name, block.input);
53
+ if (agentId !== undefined)
54
+ this.targets.set(block.id, agentId);
32
55
  if (isNativeSubagentControlTool(block.name)) {
33
56
  this.registerLaunch(block.id, inputOf(block), ownerSessionId);
34
57
  }
@@ -119,6 +142,10 @@ export class RfdSubagentReplay {
119
142
  this.transcript.scan(messages, ownerSessionId);
120
143
  }
121
144
  /** The child that the tool use `toolUseId` launched, when the replay shows it. */
145
+ /** See {@link ReplayTranscript.withTarget}. */
146
+ withTarget(notification, shownOn) {
147
+ return this.transcript.withTarget(notification, shownOn);
148
+ }
122
149
  childOfLaunch(toolUseId) {
123
150
  return this.transcript.children.get(toolUseId);
124
151
  }
@@ -12,6 +12,32 @@ export type ToolCallUpdate = SessionNotification["update"];
12
12
  export declare const V2_CANCELLED: ToolCallStatus;
13
13
  /** Whether `status` ends a tool call: `completed`, `failed`, or, on v2, `cancelled`. */
14
14
  export declare function isFinalToolCallStatus(status: ToolCallStatus | null | undefined): boolean;
15
+ /**
16
+ * The tool call that a `tool_progress` beat reports on, of the calls the
17
+ * client holds (`held`), or undefined for a beat to drop.
18
+ *
19
+ * Not every beat reports under the id of a call the client has seen: a tool's
20
+ * heartbeat derives `<tool_use_id>-heartbeat-<n>`, and the `agent_api_retry`
21
+ * beats behind `subagentRetry` report under `agent_<assistant_message_id>`.
22
+ * Forwarding those ids leaves the client resolving a call it was never told
23
+ * about (#851). The SDK stamps `parent_tool_use_id` with the id of the
24
+ * executing tool on them, so they go to that call. A beat under the id of a
25
+ * held call keeps it: a subagent's `bash_progress`, whose parent is the Agent
26
+ * call that spawned it.
27
+ *
28
+ * Dropped:
29
+ * - a beat for a call the client does not hold: never announced, or returned
30
+ * (an id leaves `held` at its tool result, so a late beat cannot reopen it);
31
+ * - the heartbeat of a hook that runs long (`hook-<event>-<id>-heartbeat-<n>`,
32
+ * since Claude Code 2.1.323). Its `tool_name` is the hook event and its
33
+ * elapsed time is the hook's. For a PreToolUse or PostToolUse hook its
34
+ * `parent_tool_use_id` is the tool call, which is not running then: sent on,
35
+ * it would name the call `PreToolUse` and restart its elapsed time.
36
+ */
37
+ export declare function progressToolCallId(beat: {
38
+ tool_use_id: string;
39
+ parent_tool_use_id: string | null;
40
+ }, held: ReadonlySet<string>): string | undefined;
15
41
  /** The `_meta` of a tool call report. */
16
42
  export type ToolUpdateMeta = {
17
43
  claudeCode?: {
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/tool-calls/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,IAAI,qBAAqB,EAC3C,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,mCAAmC,CAAC;AAS3C,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM5F,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAK3D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAA6B,cAAc,CAAC;AAErE,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAExF;AAED,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE;QAKX,QAAQ,CAAC,EAAE,MAAM,CAAC;QAKlB,YAAY,CAAC,EAAE,OAAO,CAAC;QAIvB,eAAe,CAAC,EAAE,MAAM,CAAC;QAMzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAG1B,YAAY,CAAC,EAAE,MAAM,CAAC;QAEtB,SAAS,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cancelled";
20
20
  export function isFinalToolCallStatus(status) {
21
21
  return status === "completed" || status === "failed" || status === V2_CANCELLED;
22
22
  }
23
+ /**
24
+ * The tool call that a `tool_progress` beat reports on, of the calls the
25
+ * client holds (`held`), or undefined for a beat to drop.
26
+ *
27
+ * Not every beat reports under the id of a call the client has seen: a tool's
28
+ * heartbeat derives `<tool_use_id>-heartbeat-<n>`, and the `agent_api_retry`
29
+ * beats behind `subagentRetry` report under `agent_<assistant_message_id>`.
30
+ * Forwarding those ids leaves the client resolving a call it was never told
31
+ * about (#851). The SDK stamps `parent_tool_use_id` with the id of the
32
+ * executing tool on them, so they go to that call. A beat under the id of a
33
+ * held call keeps it: a subagent's `bash_progress`, whose parent is the Agent
34
+ * call that spawned it.
35
+ *
36
+ * Dropped:
37
+ * - a beat for a call the client does not hold: never announced, or returned
38
+ * (an id leaves `held` at its tool result, so a late beat cannot reopen it);
39
+ * - the heartbeat of a hook that runs long (`hook-<event>-<id>-heartbeat-<n>`,
40
+ * since Claude Code 2.1.323). Its `tool_name` is the hook event and its
41
+ * elapsed time is the hook's. For a PreToolUse or PostToolUse hook its
42
+ * `parent_tool_use_id` is the tool call, which is not running then: sent on,
43
+ * it would name the call `PreToolUse` and restart its elapsed time.
44
+ */
45
+ export function progressToolCallId(beat, held) {
46
+ if (held.has(beat.tool_use_id))
47
+ return beat.tool_use_id;
48
+ if (beat.tool_use_id.startsWith("hook-"))
49
+ return undefined;
50
+ const parent = beat.parent_tool_use_id;
51
+ return parent !== null && held.has(parent) ? parent : undefined;
52
+ }
23
53
  /**
24
54
  * Turns tool facts into the fields of the standard ACP tool call report, as
25
55
  * `docs/air-extensions.md#tool-call-contract` defines: each fact goes in one field.