@tormentalabs/claude-code-wire-compat 0.7.1 → 0.8.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +27 -4
  3. package/dist/account-features.d.ts +11 -0
  4. package/dist/account-features.d.ts.map +1 -0
  5. package/dist/account-features.js +98 -0
  6. package/dist/account-features.js.map +1 -0
  7. package/dist/anti-verbosity.d.ts.map +1 -1
  8. package/dist/anti-verbosity.js +3 -3
  9. package/dist/anti-verbosity.js.map +1 -1
  10. package/dist/betas.d.ts +74 -2
  11. package/dist/betas.d.ts.map +1 -1
  12. package/dist/betas.js +158 -18
  13. package/dist/betas.js.map +1 -1
  14. package/dist/build-request.d.ts.map +1 -1
  15. package/dist/build-request.js +201 -19
  16. package/dist/build-request.js.map +1 -1
  17. package/dist/contracts.d.ts +181 -2
  18. package/dist/contracts.d.ts.map +1 -1
  19. package/dist/contracts.js.map +1 -1
  20. package/dist/fingerprint.d.ts +28 -5
  21. package/dist/fingerprint.d.ts.map +1 -1
  22. package/dist/fingerprint.js +63 -5
  23. package/dist/fingerprint.js.map +1 -1
  24. package/dist/headers.d.ts +60 -1
  25. package/dist/headers.d.ts.map +1 -1
  26. package/dist/headers.js +176 -23
  27. package/dist/headers.js.map +1 -1
  28. package/dist/index.d.ts +4 -2
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/model-capabilities.d.ts +8 -4
  33. package/dist/model-capabilities.d.ts.map +1 -1
  34. package/dist/model-capabilities.js +14 -7
  35. package/dist/model-capabilities.js.map +1 -1
  36. package/dist/model-identity.d.ts +15 -2
  37. package/dist/model-identity.d.ts.map +1 -1
  38. package/dist/model-identity.js +44 -1
  39. package/dist/model-identity.js.map +1 -1
  40. package/dist/model-queries.d.ts +11 -1
  41. package/dist/model-queries.d.ts.map +1 -1
  42. package/dist/model-queries.js +51 -7
  43. package/dist/model-queries.js.map +1 -1
  44. package/dist/models.d.ts.map +1 -1
  45. package/dist/models.js +2 -2
  46. package/dist/models.js.map +1 -1
  47. package/dist/profile-behaviors.d.ts +72 -0
  48. package/dist/profile-behaviors.d.ts.map +1 -1
  49. package/dist/profile-behaviors.js +66 -15
  50. package/dist/profile-behaviors.js.map +1 -1
  51. package/dist/profiles/beta-registry-2.1.329.d.ts +229 -0
  52. package/dist/profiles/beta-registry-2.1.329.d.ts.map +1 -0
  53. package/dist/profiles/beta-registry-2.1.329.js +281 -0
  54. package/dist/profiles/beta-registry-2.1.329.js.map +1 -0
  55. package/dist/profiles/claude-code-2.1.329.d.ts +3 -0
  56. package/dist/profiles/claude-code-2.1.329.d.ts.map +1 -0
  57. package/dist/profiles/claude-code-2.1.329.js +466 -0
  58. package/dist/profiles/claude-code-2.1.329.js.map +1 -0
  59. package/dist/redaction.d.ts.map +1 -1
  60. package/dist/redaction.js +1 -0
  61. package/dist/redaction.js.map +1 -1
  62. package/dist/request-body.d.ts +27 -1
  63. package/dist/request-body.d.ts.map +1 -1
  64. package/dist/request-body.js +184 -16
  65. package/dist/request-body.js.map +1 -1
  66. package/dist/tools-used.d.ts +52 -0
  67. package/dist/tools-used.d.ts.map +1 -0
  68. package/dist/tools-used.js +116 -0
  69. package/dist/tools-used.js.map +1 -0
  70. package/package.json +5 -1
  71. package/src/account-features.ts +114 -0
  72. package/src/anti-verbosity.ts +8 -3
  73. package/src/betas.ts +252 -22
  74. package/src/build-request.ts +245 -22
  75. package/src/contracts.ts +185 -3
  76. package/src/fingerprint.ts +84 -7
  77. package/src/headers.ts +221 -21
  78. package/src/index.ts +10 -0
  79. package/src/model-capabilities.ts +16 -7
  80. package/src/model-identity.ts +62 -2
  81. package/src/model-queries.ts +71 -8
  82. package/src/models.ts +2 -1
  83. package/src/profile-behaviors.ts +150 -16
  84. package/src/profiles/beta-registry-2.1.329.ts +298 -0
  85. package/src/profiles/claude-code-2.1.329.ts +471 -0
  86. package/src/redaction.ts +1 -0
  87. package/src/request-body.ts +242 -17
  88. package/src/tools-used.ts +134 -0
@@ -1,8 +1,16 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
 
3
- import type { ClaudeCodeProtocolProfile } from "./contracts.js";
3
+ import type {
4
+ ClaudeCodeCatalogueEntry,
5
+ ClaudeCodeProtocolProfile,
6
+ } from "./contracts.js";
4
7
  import { supportsStructuredOutputs as portedStructuredOutputs } from "./model-capabilities.js";
5
- import { modelFamilyOf, normalizeModelId } from "./model-identity.js";
8
+ import type { ModelIdLadder } from "./model-identity.js";
9
+ import {
10
+ modelFamilyOf,
11
+ modelIdLadder,
12
+ normalizeModelId,
13
+ } from "./model-identity.js";
6
14
  import { CLAUDE_CODE_2_1_195_PROFILE } from "./profiles/claude-code-2.1.195.js";
7
15
 
8
16
  /*
@@ -42,12 +50,23 @@ import { CLAUDE_CODE_2_1_195_PROFILE } from "./profiles/claude-code-2.1.195.js";
42
50
  * RUNTIME NEUTRALITY. No builtins, no clock, no randomness, no I/O.
43
51
  */
44
52
 
45
- /** Lowercased + dotted-to-dashed id, or `null` for input no predicate can answer for. */
46
- function normalizedOrNull(model: string): string | null {
53
+ /**
54
+ * Lowercased + dotted-to-dashed id, or `null` for input no predicate can answer
55
+ * for.
56
+ *
57
+ * Profile-less identity predicates use the extended ladder (the widest the
58
+ * package knows), so `isSonnet5Model("claude-sonnet-5-5")` is false: the 5.5
59
+ * ids are their own models. Queries that take a profile pass that profile's
60
+ * own ladder instead, so 2.1.280 keeps its folding.
61
+ */
62
+ function normalizedOrNull(
63
+ model: string,
64
+ ladder: ModelIdLadder = "extended",
65
+ ): string | null {
47
66
  if (typeof model !== "string" || model.length === 0) {
48
67
  return null;
49
68
  }
50
- return normalizeModelId(model);
69
+ return normalizeModelId(model, ladder);
51
70
  }
52
71
 
53
72
  /**
@@ -90,7 +109,7 @@ export function modelCapability(
90
109
  capability: string,
91
110
  profile: ClaudeCodeProtocolProfile = CLAUDE_CODE_2_1_195_PROFILE,
92
111
  ): boolean {
93
- const id = normalizedOrNull(model);
112
+ const id = normalizedOrNull(model, modelIdLadder(profile));
94
113
  if (
95
114
  id === null ||
96
115
  typeof capability !== "string" ||
@@ -105,6 +124,26 @@ export function modelCapability(
105
124
  return entry.capabilities.includes(capability);
106
125
  }
107
126
 
127
+ /**
128
+ * The catalogue entry the profile's own normalizer resolves `model` to, or
129
+ * `undefined` when the model is not a string, is empty, or the profile does not
130
+ * catalogue the resolved id.
131
+ *
132
+ * Folding-consistent: under a profile that follows the base ladder,
133
+ * `claude-sonnet-5-5` resolves to the `claude-sonnet-5` entry, exactly as the
134
+ * request builder resolves it for that profile.
135
+ */
136
+ export function modelCatalogueEntry(
137
+ model: string,
138
+ profile: ClaudeCodeProtocolProfile = CLAUDE_CODE_2_1_195_PROFILE,
139
+ ): ClaudeCodeCatalogueEntry | undefined {
140
+ const id = normalizedOrNull(model, modelIdLadder(profile));
141
+ if (id === null || !Object.hasOwn(profile.supportedModels, id)) {
142
+ return undefined;
143
+ }
144
+ return profile.supportedModels[id];
145
+ }
146
+
108
147
  /** Whether `model` normalizes to `claude-opus-4-6`. */
109
148
  export function isOpus46Model(model: string): boolean {
110
149
  return normalizedOrNull(model) === "claude-opus-4-6";
@@ -140,6 +179,26 @@ export function isSonnet5Model(model: string): boolean {
140
179
  return normalizedOrNull(model) === "claude-sonnet-5";
141
180
  }
142
181
 
182
+ /** Whether `model` normalizes to `claude-sonnet-5-5` (internal). */
183
+ function isSonnet55Model(model: string): boolean {
184
+ return normalizedOrNull(model) === "claude-sonnet-5-5";
185
+ }
186
+
187
+ /** Whether `model` normalizes to `claude-haiku-5-5` (internal). */
188
+ function isHaiku55Model(model: string): boolean {
189
+ return normalizedOrNull(model) === "claude-haiku-5-5";
190
+ }
191
+
192
+ /** Whether `model` normalizes to `claude-fable-5-2` (internal). */
193
+ function isFable52Model(model: string): boolean {
194
+ return normalizedOrNull(model) === "claude-fable-5-2";
195
+ }
196
+
197
+ /** Whether `model` normalizes to `claude-mythos-5-2` (internal). */
198
+ function isMythos52Model(model: string): boolean {
199
+ return normalizedOrNull(model) === "claude-mythos-5-2";
200
+ }
201
+
143
202
  /** Whether `model` normalizes to `claude-fable-5`. */
144
203
  export function isFable5Model(model: string): boolean {
145
204
  return normalizedOrNull(model) === "claude-fable-5";
@@ -194,7 +253,7 @@ export function isEligibleFor1MContext(
194
253
  model: string,
195
254
  profile: ClaudeCodeProtocolProfile = CLAUDE_CODE_2_1_195_PROFILE,
196
255
  ): boolean {
197
- const id = normalizedOrNull(model);
256
+ const id = normalizedOrNull(model, modelIdLadder(profile));
198
257
  if (id === null) {
199
258
  return false;
200
259
  }
@@ -265,9 +324,13 @@ export function isAdaptiveThinkingModel(model: string): boolean {
265
324
  isOpus55Model(model) ||
266
325
  isSonnet46Model(model) ||
267
326
  isSonnet5Model(model) ||
327
+ isSonnet55Model(model) ||
328
+ isHaiku55Model(model) ||
268
329
  isFable5Model(model) ||
269
330
  isFable51Model(model) ||
331
+ isFable52Model(model) ||
270
332
  isMythos5Model(model) ||
271
- isMythos51Model(model)
333
+ isMythos51Model(model) ||
334
+ isMythos52Model(model)
272
335
  );
273
336
  }
package/src/models.ts CHANGED
@@ -9,6 +9,7 @@ import { ClaudeCodeWireError } from "./contracts.js";
9
9
  import { deriveCapabilities } from "./model-capabilities.js";
10
10
  import {
11
11
  modelFamilyOf,
12
+ modelIdLadder,
12
13
  normalizeModelId,
13
14
  stripModelMarkers,
14
15
  } from "./model-identity.js";
@@ -30,7 +31,7 @@ export function resolveModel(
30
31
  }
31
32
 
32
33
  const wireId = stripModelMarkers(model);
33
- const id = normalizeModelId(model);
34
+ const id = normalizeModelId(model, modelIdLadder(profile));
34
35
  const entry = Object.hasOwn(profile.supportedModels, id)
35
36
  ? profile.supportedModels[id]
36
37
  : undefined;
@@ -2,6 +2,7 @@
2
2
 
3
3
  import type { ClaudeCodeProtocolProfile } from "./contracts.js";
4
4
  import { CLAUDE_CODE_2_1_195_PROFILE } from "./profiles/claude-code-2.1.195.js";
5
+ import { CLAUDE_CODE_2_1_329_PROFILE } from "./profiles/claude-code-2.1.329.js";
5
6
 
6
7
  /**
7
8
  * Per-profile behaviour dispatch.
@@ -56,6 +57,89 @@ export interface ClaudeCodeProfileBehaviors {
56
57
  * predicate is wire-authoritative for that profile alone.
57
58
  */
58
59
  readonly opus45EffortException: boolean;
60
+
61
+ /**
62
+ * Whether `messages` may carry `role: "system"` control messages with an
63
+ * `output_config` (the per-turn effort and timing statements).
64
+ *
65
+ * Consumed by the message canonicaliser in `request-body.ts`. False means
66
+ * such a message is refused with `INVALID_INPUT`, which is what every
67
+ * profile did before the shape was transcribed.
68
+ */
69
+ readonly perTurnControlMessages: boolean;
70
+
71
+ /**
72
+ * Whether `supportsMidConversationSystem` reads the profile's catalogue
73
+ * (`mid_conv_system` capability string) before falling back to the
74
+ * predicate. False means the predicate alone decides, which is what a client
75
+ * that retired the catalogue string does.
76
+ *
77
+ * Consumed by `supportsMidConversationSystem` in `model-capabilities.ts`.
78
+ */
79
+ readonly midConversationSystemFromCatalogue: boolean;
80
+
81
+ /**
82
+ * Whether the thinking-token-count beta is pushed after the per-request
83
+ * sites (site 6′) instead of at its historical position (site 6).
84
+ *
85
+ * Consumed by `composeBetasWithAudit` in `betas.ts`.
86
+ */
87
+ readonly thinkingTokenCountAfterRequestTable: boolean;
88
+
89
+ /**
90
+ * Whether the 1M-context beta is withheld for a model whose catalogue entry
91
+ * already declares a native 1M window.
92
+ *
93
+ * Consumed by site 3 of `composeBetasWithAudit` in `betas.ts`.
94
+ */
95
+ readonly longContextExcludesNative1m: boolean;
96
+
97
+ /**
98
+ * Whether the model-id normalizer uses the extended ladder (the 5.5 and 5.2
99
+ * rungs). Declared ahead of its reader; inert until the normalizer reads it.
100
+ */
101
+ readonly extendedModelIdLadder: boolean;
102
+
103
+ /**
104
+ * Whether headers use the genuine client's layout (names, casing, ordering
105
+ * and the request-class set). Declared ahead of its reader; inert until the
106
+ * header builder reads it.
107
+ */
108
+ readonly genuineHeaderLayout: boolean;
109
+
110
+ /**
111
+ * Whether the billing block carries the turn-origin and turn-position
112
+ * segments. Declared ahead of its reader; inert until the fingerprint
113
+ * module reads it.
114
+ */
115
+ readonly billingTurnSegments: boolean;
116
+
117
+ /**
118
+ * Whether the request body carries a generated `context_management` when
119
+ * the beta fires. Consumed by `buildCanonicalBody` in `request-body.ts`.
120
+ */
121
+ readonly generatedContextManagement: boolean;
122
+
123
+ /**
124
+ * Whether the request body carries `diagnostics` alongside the cache
125
+ * diagnosis beta. Consumed by `buildCanonicalBody` in `request-body.ts`.
126
+ */
127
+ readonly cacheDiagnosisBody: boolean;
128
+
129
+ /**
130
+ * Whether body keys are emitted in the genuine client's order. Consumed by
131
+ * `buildCanonicalBody` in `request-body.ts`.
132
+ */
133
+ readonly genuineBodyKeyOrder: boolean;
134
+
135
+ /**
136
+ * Whether caller-supplied account-served inputs (dispatch id, inline tools,
137
+ * threads, side-query and agentic-query markers) are honoured. The dispatch
138
+ * id is read by the header builder in `headers.ts`; the others by the beta
139
+ * composer in `betas.ts` and, for the thread body, the body builder in
140
+ * `request-body.ts`.
141
+ */
142
+ readonly accountServedInputs: boolean;
59
143
  }
60
144
 
61
145
  /**
@@ -67,17 +151,63 @@ const LEGACY_BEHAVIORS: ClaudeCodeProfileBehaviors = Object.freeze({
67
151
  requestDerivedTokenCeiling: false,
68
152
  billingChainSegments: false,
69
153
  opus45EffortException: true,
154
+ perTurnControlMessages: false,
155
+ midConversationSystemFromCatalogue: true,
156
+ thinkingTokenCountAfterRequestTable: false,
157
+ longContextExcludesNative1m: false,
158
+ extendedModelIdLadder: false,
159
+ genuineHeaderLayout: false,
160
+ billingTurnSegments: false,
161
+ generatedContextManagement: false,
162
+ cacheDiagnosisBody: false,
163
+ genuineBodyKeyOrder: false,
164
+ accountServedInputs: false,
70
165
  });
71
166
 
72
167
  /**
73
- * Upstream 2.1.222 and later: derivation is catalogue-first, so the
168
+ * Upstream 2.1.222 through 2.1.280: derivation is catalogue-first, so the
74
169
  * `claude-opus-4-5` exception does not apply, and both of the newer request
75
- * behaviours are present.
170
+ * behaviours are present. This is also where a profile with an unrecognised id
171
+ * lands.
172
+ */
173
+ const CATALOGUE_ERA_BEHAVIORS: ClaudeCodeProfileBehaviors = Object.freeze({
174
+ requestDerivedTokenCeiling: true,
175
+ billingChainSegments: true,
176
+ opus45EffortException: false,
177
+ perTurnControlMessages: false,
178
+ midConversationSystemFromCatalogue: true,
179
+ thinkingTokenCountAfterRequestTable: false,
180
+ longContextExcludesNative1m: false,
181
+ extendedModelIdLadder: false,
182
+ genuineHeaderLayout: false,
183
+ billingTurnSegments: false,
184
+ generatedContextManagement: false,
185
+ cacheDiagnosisBody: false,
186
+ genuineBodyKeyOrder: false,
187
+ accountServedInputs: false,
188
+ });
189
+
190
+ /**
191
+ * Upstream 2.1.329: the catalogue-era set with the wire-level differences the
192
+ * 2.1.329 analysis records. Every flag that is true here and false in the other
193
+ * two sets is a behaviour the older clients do not have; the flags declared
194
+ * ahead of their readers are inert until a later change reads them.
76
195
  */
77
- const MODERN_BEHAVIORS: ClaudeCodeProfileBehaviors = Object.freeze({
196
+ const WIRE_FAITHFUL_BEHAVIORS: ClaudeCodeProfileBehaviors = Object.freeze({
78
197
  requestDerivedTokenCeiling: true,
79
198
  billingChainSegments: true,
80
199
  opus45EffortException: false,
200
+ perTurnControlMessages: true,
201
+ midConversationSystemFromCatalogue: false,
202
+ thinkingTokenCountAfterRequestTable: true,
203
+ longContextExcludesNative1m: true,
204
+ extendedModelIdLadder: true,
205
+ genuineHeaderLayout: true,
206
+ billingTurnSegments: true,
207
+ generatedContextManagement: true,
208
+ cacheDiagnosisBody: true,
209
+ genuineBodyKeyOrder: true,
210
+ accountServedInputs: true,
81
211
  });
82
212
 
83
213
  /**
@@ -92,23 +222,27 @@ export function profileBehaviors(
92
222
  /*
93
223
  * ---- Demarcated: the ONLY per-version identity comparison in `src/`. ----
94
224
  *
95
- * The split is 2.1.195 versus 2.1.222+, and it is structural rather than a
96
- * capability flag: these are differences in what the upstream builder is
97
- * written to do, not values it reads from a catalogue. 2.1.195 is the one
98
- * profile ported from the older builder, so it is the one named here.
225
+ * Three sets, two named identities. 2.1.195 is the one profile ported from
226
+ * the older builder; 2.1.329 is the one profile whose wire behaviour was
227
+ * transcribed from a client that no longer reads the catalogue for
228
+ * everything the earlier ones did. Both are named here because each differs
229
+ * in what the upstream builder is written to do, not in values it reads
230
+ * from a catalogue.
99
231
  *
100
- * The default is deliberately the MODERN side. A profile ported from a
101
- * client newer than 2.1.233 inherits the current behaviour and needs no edit
102
- * here; only a profile ported from a client OLDER than 2.1.222 would, and
103
- * adding one is a decision that should require touching this module. Written
104
- * the other way round — naming the modern profiles and defaulting to legacy
105
- * — every new profile would silently regress to 2.1.195 semantics.
232
+ * The fallthrough is deliberately the CATALOGUE-ERA side, and it stays
233
+ * pre-329: a profile whose id is unrecognised (an overridden id, a synthetic
234
+ * profile) keeps the bytes it had before 2.1.329 existed. Adopting the
235
+ * wire-faithful set is something a profile must opt into by being named
236
+ * here, never something it can inherit by accident. Written the other way
237
+ * round — defaulting to legacy — every new profile would silently regress to
238
+ * 2.1.195 semantics.
106
239
  *
107
240
  * `test/governance/version-dispatch.test.ts` asserts this comparison is
108
241
  * here, and that it is nowhere else.
109
242
  */
110
- if (profile.id === CLAUDE_CODE_2_1_195_PROFILE.id) {
111
- return LEGACY_BEHAVIORS;
243
+ if (profile.id === CLAUDE_CODE_2_1_195_PROFILE.id) return LEGACY_BEHAVIORS;
244
+ if (profile.id === CLAUDE_CODE_2_1_329_PROFILE.id) {
245
+ return WIRE_FAITHFUL_BEHAVIORS;
112
246
  }
113
- return MODERN_BEHAVIORS;
247
+ return CATALOGUE_ERA_BEHAVIORS;
114
248
  }
@@ -0,0 +1,298 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+ interface BetaRegistryEntry {
4
+ readonly featureKey: string;
5
+ readonly header: string;
6
+ }
7
+
8
+ /*
9
+ * `deepFreeze` is duplicated from `src/beta-registry.ts` rather than imported,
10
+ * for the same reason the 2.1.233 and 2.1.280 registries duplicate it: a shared
11
+ * helper module would make every registry import-coupled for four lines of
12
+ * code, and keeping each registry a leaf keeps a version bump from rippling.
13
+ */
14
+ function deepFreeze<T>(value: T): T {
15
+ if (value !== null && typeof value === "object") {
16
+ for (const key of Reflect.ownKeys(value)) {
17
+ deepFreeze(Reflect.get(value, key));
18
+ }
19
+ Object.freeze(value);
20
+ }
21
+ return value;
22
+ }
23
+
24
+ /**
25
+ * Genuine-client beta registry as of 2.1.329, upstream factory chain at byte
26
+ * offset 7881648 (view line 109432) and ordered array `a1i` immediately after
27
+ * it.
28
+ *
29
+ * KEY ORDER IS LOAD-BEARING. The array is the raw slot order and is NOT
30
+ * append-only: six entries are new since 2.1.280 and none of them sits at the
31
+ * end. See `docs/protocol/versions/claude-code-2.1.329-analysis.md` section 5.1.
32
+ *
33
+ * The upstream array carries 48 slots. Two are explicit `null` (indices 39 and
34
+ * 43, `yBn` and `ml`) and one is a header-less member (index 30, `fS`, declared
35
+ * as `pl("mid_conversation_system")`), leaving the forty-five entries below.
36
+ * Both nulls are null IN THIS BUILD, which is all the bytes establish; neither
37
+ * is transcribed, because a null is not an entry.
38
+ *
39
+ * `mid_conversation_system` is deliberately ABSENT. The 2.1.280 registry
40
+ * carried it with the header `mid-conversation-system-2026-04-07`. In 2.1.329
41
+ * the slot is declared as `pl("mid_conversation_system")`, a call that passes a
42
+ * name and no header, and the old identifier survives only as a bare string
43
+ * constant (`Zkt`) that no registry member points at. The beta therefore graduated: the client no longer
44
+ * advertises it, while the behaviour it gated stays on. That is why
45
+ * `ComposableBetaRegistry.MID_CONVERSATION_SYSTEM` is optional. The slot sits
46
+ * between `TOOL_PROVENANCE` and `PER_MESSAGE_EFFORT` and is recorded here
47
+ * rather than silently closed up, because a later build may give it a header.
48
+ *
49
+ * `NARRATION_SUMMARIES` stays absent exactly as in the two previous registries.
50
+ *
51
+ * Further registry members are deliberately absent:
52
+ * `tool_provenance_server_url_latch` (new at 2.1.329),
53
+ * `mid_conv_cache_promotion_latch` and `mid_conv_cache_promotion_ok_latch`.
54
+ * Upstream declares them through the same factory but excludes them from the
55
+ * ordered array, and their "header" values are internal `x-cc-*` names, not
56
+ * beta identifiers. Transcribing them would corrupt the registry. Likewise
57
+ * `thinking_display` (`i1i`, declared through `pl()`) is outside the array.
58
+ *
59
+ * `oauth_auth` is the one entry whose header is NOT a string literal upstream:
60
+ * the declaration reads `hWe=k("oauth_auth",Yu)`, and `Yu` resolves to
61
+ * `"oauth-2025-04-20"`.
62
+ *
63
+ * `tool_search` is reused by two entries (`ADVANCED_TOOL_USE` and
64
+ * `TOOL_SEARCH`) as in 2.1.280; the two headers differ and only the second is
65
+ * a member of the third-party set.
66
+ */
67
+ export const BETA_REGISTRY_2_1_329 = deepFreeze({
68
+ CLAUDE_CODE: { featureKey: "claude_code", header: "claude-code-20250219" },
69
+ OAUTH_AUTH: { featureKey: "oauth_auth", header: "oauth-2025-04-20" },
70
+ INTERLEAVED_THINKING: {
71
+ featureKey: "interleaved_thinking",
72
+ header: "interleaved-thinking-2025-05-14",
73
+ },
74
+ LONG_CONTEXT: { featureKey: "long_context", header: "context-1m-2025-08-07" },
75
+ CONTEXT_MANAGEMENT: {
76
+ featureKey: "context_management",
77
+ header: "context-management-2025-06-27",
78
+ },
79
+ STRUCTURED_OUTPUTS: {
80
+ featureKey: "structured_outputs",
81
+ header: "structured-outputs-2025-12-15",
82
+ },
83
+ WEB_SEARCH: { featureKey: "web_search", header: "web-search-2025-03-05" },
84
+ // New at 2.1.329.
85
+ WEB_SEARCH_RESULTS_ONLY: {
86
+ featureKey: "web_search_results_only",
87
+ header: "web-search-results-only-2026-11-15",
88
+ },
89
+ ADVANCED_TOOL_USE: {
90
+ featureKey: "tool_search",
91
+ header: "advanced-tool-use-2025-11-20",
92
+ },
93
+ TOOL_SEARCH: {
94
+ featureKey: "tool_search",
95
+ header: "tool-search-tool-2025-10-19",
96
+ },
97
+ EFFORT: { featureKey: "effort", header: "effort-2025-11-24" },
98
+ TASK_BUDGETS: {
99
+ featureKey: "task_budgets",
100
+ header: "task-budgets-2026-03-13",
101
+ },
102
+ PROMPT_CACHING_SCOPE: {
103
+ featureKey: "prompt_caching_scope",
104
+ header: "prompt-caching-scope-2026-01-05",
105
+ },
106
+ PROMPT_CACHING_EVICT: {
107
+ featureKey: "prompt_caching_evict",
108
+ header: "prompt-caching-evict-2026-05-12",
109
+ },
110
+ // New at 2.1.329.
111
+ CACHE_KEEPALIVE: {
112
+ featureKey: "cache_keepalive",
113
+ header: "cache-keepalive-2026-09-03",
114
+ },
115
+ EXTENDED_CACHE_TTL: {
116
+ featureKey: "extended_cache_ttl",
117
+ header: "extended-cache-ttl-2025-04-11",
118
+ },
119
+ SPEED: { featureKey: "speed", header: "fast-mode-2026-02-01" },
120
+ REDACT_THINKING: {
121
+ featureKey: "redact_thinking",
122
+ header: "redact-thinking-2026-02-12",
123
+ },
124
+ THINKING_RESUMPTION: {
125
+ featureKey: "thinking_resumption",
126
+ header: "thinking-resumption-2026-07-17",
127
+ },
128
+ // New at 2.1.329, and inserted rather than appended: it sits directly after
129
+ // `THINKING_RESUMPTION`, ahead of entries that already existed.
130
+ RESUMPTION: {
131
+ featureKey: "resumption",
132
+ header: "resumption-2026-10-08",
133
+ },
134
+ THINKING_TOKEN_COUNT: {
135
+ featureKey: "thinking_token_count",
136
+ header: "thinking-token-count-2026-05-13",
137
+ },
138
+ AFK_MODE: { featureKey: "afk_mode", header: "afk-mode-2026-01-31" },
139
+ ADVISOR_TOOL: {
140
+ featureKey: "advisor_tool",
141
+ header: "advisor-tool-2026-03-01",
142
+ },
143
+ CACHE_DIAGNOSIS: {
144
+ featureKey: "cache_diagnosis",
145
+ header: "cache-diagnosis-2026-04-07",
146
+ },
147
+ CONTEXT_HINT: {
148
+ featureKey: "context_hint",
149
+ header: "context-hint-2026-04-09",
150
+ },
151
+ MCP_SERVERS: { featureKey: "mcp_servers", header: "mcp-servers-2025-12-04" },
152
+ FILES_API: { featureKey: "files_api", header: "files-api-2025-04-14" },
153
+ ENVIRONMENTS: {
154
+ featureKey: "environments",
155
+ header: "environments-2025-11-01",
156
+ },
157
+ CCR_BYOC: { featureKey: "ccr_byoc", header: "ccr-byoc-2025-07-29" },
158
+ // New at 2.1.329. The feature key is `ccr_tool_provenance`.
159
+ TOOL_PROVENANCE: {
160
+ featureKey: "ccr_tool_provenance",
161
+ header: "tool-provenance-2026-10-26",
162
+ },
163
+ // Slot 30 (`mid_conversation_system`, header-less) belongs here and is not
164
+ // transcribed; see the header comment above.
165
+ PER_MESSAGE_EFFORT: {
166
+ featureKey: "per_message_effort",
167
+ header: "per-turn-control-2026-07-01",
168
+ },
169
+ PER_TURN_TIMING: {
170
+ featureKey: "per_turn_timing",
171
+ header: "timing-2026-09-09",
172
+ },
173
+ MID_CONV_TOOL_CHANGE: {
174
+ featureKey: "mid_conv_tool_change",
175
+ header: "mid-conversation-tool-changes-2026-07-01",
176
+ },
177
+ INLINE_TOOLS: {
178
+ featureKey: "inline_tools",
179
+ header: "inline-tools-2026-09-15",
180
+ },
181
+ SERVER_SIDE_FALLBACK: {
182
+ featureKey: "server_side_fallback",
183
+ header: "server-side-fallback-2026-06-01",
184
+ },
185
+ // New at 2.1.329.
186
+ PROGRAM_USE_CASE_IDS: {
187
+ featureKey: "program_use_case_ids",
188
+ header: "program-use-case-ids-2026-09-17",
189
+ },
190
+ SERVER_SIDE_FALLBACK_CATEGORY: {
191
+ featureKey: "server_side_fallback_category",
192
+ header: "server-side-fallback-2026-07-01",
193
+ },
194
+ FALLBACK_CREDIT: {
195
+ featureKey: "fallback_credit",
196
+ header: "fallback-credit-2026-06-01",
197
+ },
198
+ // The first null slot (`yBn`, upstream index 39) belongs here. As at 2.1.280,
199
+ // nothing ties it to a header string by evidence.
200
+ AUTO_MODE_CLASSIFIER: {
201
+ featureKey: "auto_mode_classifier",
202
+ header: "auto-mode-classifier-2026-07-16",
203
+ },
204
+ // New at 2.1.329. Pushed by upstream before the effort beta on the
205
+ // per-attempt path (analysis document section 5.4).
206
+ CLAUDE_CODE_SIDE_QUERY: {
207
+ featureKey: "claude_code_side_query",
208
+ header: "claude-code-side-query-2026-09-29",
209
+ },
210
+ DANGEROUS_TOOL_USE: {
211
+ featureKey: "dangerous_tool_use",
212
+ header: "dangerous-tool-use-2026-09-03",
213
+ },
214
+ // The second null slot (`ml`, upstream index 43) belongs here.
215
+ THINKING_DISPLAY_UPDATES: {
216
+ featureKey: "thinking_display_updates",
217
+ header: "thinking-display-updates-2026-08-18",
218
+ },
219
+ MESSAGE_THREADS: {
220
+ featureKey: "message_threads",
221
+ header: "message-threads-2026-08-12",
222
+ },
223
+ MID_CONVERSATION_SYSTEM_CLEAR_AT: {
224
+ featureKey: "mid_conversation_system_clear_at",
225
+ header: "mid-conversation-system-clear-at-2026-08-21",
226
+ },
227
+ /*
228
+ * LAST in the array, though upstream DECLARES it before `message_threads`
229
+ * and `mid_conversation_system_clear_at`. Declaration order and array order
230
+ * differ here and the array is what this transcription follows.
231
+ */
232
+ THINKING_BINDING_CONTROLS: {
233
+ featureKey: "thinking_binding_controls",
234
+ header: "thinking-binding-controls-2026-08-01",
235
+ },
236
+ } satisfies Record<string, BetaRegistryEntry>);
237
+
238
+ /*
239
+ * Third-party filtering as of 2.1.329, upstream `cw` at byte 9419770 (view line
240
+ * 113823), consumed by `Pyo(e) { if (tAe()) return e; return e.filter(r =>
241
+ * cw.has(r)) }` in the same run.
242
+ *
243
+ * Upstream's literal lists fifteen members. One of them, `fS`, is the
244
+ * header-less `mid_conversation_system` slot and contributes no identifier, so
245
+ * the set has fourteen. Delta against the 2.1.280 set: `mid-conversation-system`
246
+ * left (it has no header any more) and `thinking_display_updates` was ADDED.
247
+ * Order below follows upstream's literal.
248
+ */
249
+ export const THIRD_PARTY_ALLOWED_BETAS_2_1_329: ReadonlySet<string> =
250
+ Object.freeze(
251
+ new Set([
252
+ BETA_REGISTRY_2_1_329.CLAUDE_CODE.header,
253
+ BETA_REGISTRY_2_1_329.INTERLEAVED_THINKING.header,
254
+ BETA_REGISTRY_2_1_329.LONG_CONTEXT.header,
255
+ BETA_REGISTRY_2_1_329.CONTEXT_MANAGEMENT.header,
256
+ BETA_REGISTRY_2_1_329.STRUCTURED_OUTPUTS.header,
257
+ BETA_REGISTRY_2_1_329.WEB_SEARCH.header,
258
+ BETA_REGISTRY_2_1_329.EFFORT.header,
259
+ BETA_REGISTRY_2_1_329.TOOL_SEARCH.header,
260
+ BETA_REGISTRY_2_1_329.AFK_MODE.header,
261
+ BETA_REGISTRY_2_1_329.DANGEROUS_TOOL_USE.header,
262
+ BETA_REGISTRY_2_1_329.FALLBACK_CREDIT.header,
263
+ BETA_REGISTRY_2_1_329.THINKING_TOKEN_COUNT.header,
264
+ BETA_REGISTRY_2_1_329.THINKING_BINDING_CONTROLS.header,
265
+ BETA_REGISTRY_2_1_329.THINKING_DISPLAY_UPDATES.header,
266
+ ]),
267
+ );
268
+
269
+ /*
270
+ * Provider filtering as of 2.1.329 (`Bkr` in the analysis document): the
271
+ * interleaved-thinking, 1M-context and tool-search-tool betas. Unchanged from
272
+ * 2.1.280.
273
+ *
274
+ * Static reference data with no call site in `src/`, exactly like its
275
+ * predecessors. See `test/governance/provider-scope.test.ts`.
276
+ */
277
+ export const BEDROCK_UNSUPPORTED_BETAS_2_1_329: ReadonlySet<string> =
278
+ Object.freeze(
279
+ new Set([
280
+ BETA_REGISTRY_2_1_329.INTERLEAVED_THINKING.header,
281
+ BETA_REGISTRY_2_1_329.LONG_CONTEXT.header,
282
+ BETA_REGISTRY_2_1_329.TOOL_SEARCH.header,
283
+ ]),
284
+ );
285
+
286
+ /*
287
+ * Count-tokens selection as of 2.1.329 (`bBn` in the analysis document):
288
+ * claude-code, interleaved-thinking, context-management and oauth. Unchanged
289
+ * from 2.1.280.
290
+ */
291
+ export const COUNT_TOKENS_BETAS_2_1_329: ReadonlySet<string> = Object.freeze(
292
+ new Set([
293
+ BETA_REGISTRY_2_1_329.CLAUDE_CODE.header,
294
+ BETA_REGISTRY_2_1_329.INTERLEAVED_THINKING.header,
295
+ BETA_REGISTRY_2_1_329.CONTEXT_MANAGEMENT.header,
296
+ BETA_REGISTRY_2_1_329.OAUTH_AUTH.header,
297
+ ]),
298
+ );