@tormentalabs/claude-code-wire-compat 0.7.0 → 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 (97) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +31 -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 +208 -24
  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/limits.d.ts +29 -2
  33. package/dist/limits.d.ts.map +1 -1
  34. package/dist/limits.js +29 -2
  35. package/dist/limits.js.map +1 -1
  36. package/dist/model-capabilities.d.ts +8 -4
  37. package/dist/model-capabilities.d.ts.map +1 -1
  38. package/dist/model-capabilities.js +14 -7
  39. package/dist/model-capabilities.js.map +1 -1
  40. package/dist/model-identity.d.ts +15 -2
  41. package/dist/model-identity.d.ts.map +1 -1
  42. package/dist/model-identity.js +44 -1
  43. package/dist/model-identity.js.map +1 -1
  44. package/dist/model-queries.d.ts +11 -1
  45. package/dist/model-queries.d.ts.map +1 -1
  46. package/dist/model-queries.js +51 -7
  47. package/dist/model-queries.js.map +1 -1
  48. package/dist/models.d.ts.map +1 -1
  49. package/dist/models.js +2 -2
  50. package/dist/models.js.map +1 -1
  51. package/dist/profile-behaviors.d.ts +72 -0
  52. package/dist/profile-behaviors.d.ts.map +1 -1
  53. package/dist/profile-behaviors.js +66 -15
  54. package/dist/profile-behaviors.js.map +1 -1
  55. package/dist/profiles/beta-registry-2.1.329.d.ts +229 -0
  56. package/dist/profiles/beta-registry-2.1.329.d.ts.map +1 -0
  57. package/dist/profiles/beta-registry-2.1.329.js +281 -0
  58. package/dist/profiles/beta-registry-2.1.329.js.map +1 -0
  59. package/dist/profiles/claude-code-2.1.329.d.ts +3 -0
  60. package/dist/profiles/claude-code-2.1.329.d.ts.map +1 -0
  61. package/dist/profiles/claude-code-2.1.329.js +466 -0
  62. package/dist/profiles/claude-code-2.1.329.js.map +1 -0
  63. package/dist/redaction.d.ts.map +1 -1
  64. package/dist/redaction.js +7 -3
  65. package/dist/redaction.js.map +1 -1
  66. package/dist/request-body.d.ts +27 -1
  67. package/dist/request-body.d.ts.map +1 -1
  68. package/dist/request-body.js +192 -23
  69. package/dist/request-body.js.map +1 -1
  70. package/dist/system-prompt.d.ts.map +1 -1
  71. package/dist/system-prompt.js +6 -4
  72. package/dist/system-prompt.js.map +1 -1
  73. package/dist/tools-used.d.ts +52 -0
  74. package/dist/tools-used.d.ts.map +1 -0
  75. package/dist/tools-used.js +116 -0
  76. package/dist/tools-used.js.map +1 -0
  77. package/package.json +5 -1
  78. package/src/account-features.ts +114 -0
  79. package/src/anti-verbosity.ts +8 -3
  80. package/src/betas.ts +252 -22
  81. package/src/build-request.ts +251 -26
  82. package/src/contracts.ts +185 -3
  83. package/src/fingerprint.ts +84 -7
  84. package/src/headers.ts +221 -21
  85. package/src/index.ts +10 -0
  86. package/src/limits.ts +31 -2
  87. package/src/model-capabilities.ts +16 -7
  88. package/src/model-identity.ts +62 -2
  89. package/src/model-queries.ts +71 -8
  90. package/src/models.ts +2 -1
  91. package/src/profile-behaviors.ts +150 -16
  92. package/src/profiles/beta-registry-2.1.329.ts +298 -0
  93. package/src/profiles/claude-code-2.1.329.ts +471 -0
  94. package/src/redaction.ts +7 -3
  95. package/src/request-body.ts +253 -22
  96. package/src/system-prompt.ts +6 -2
  97. package/src/tools-used.ts +134 -0
@@ -1,6 +1,10 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
 
3
- import type { ClaudeCodeModelFamily } from "./contracts.js";
3
+ import type {
4
+ ClaudeCodeModelFamily,
5
+ ClaudeCodeProtocolProfile,
6
+ } from "./contracts.js";
7
+ import { profileBehaviors } from "./profile-behaviors.js";
4
8
 
5
9
  /** Ports upstream `dp` (binary offset 226644497). */
6
10
  export function stripModelMarkers(model: string): string {
@@ -21,6 +25,40 @@ function dottedToDashedVersion(model: string): string {
21
25
  return model.replace(/(\d)\.(\d)/g, "$1-$2");
22
26
  }
23
27
 
28
+ /** Which normalizer rungs apply; see `normalizeModelId`. */
29
+ export type ModelIdLadder = "base" | "extended";
30
+
31
+ /**
32
+ * Resolves the ladder a profile's own normalizer follows, from the behaviour
33
+ * flag rather than from the profile id.
34
+ */
35
+ export function modelIdLadder(
36
+ profile: ClaudeCodeProtocolProfile,
37
+ ): ModelIdLadder {
38
+ return profileBehaviors(profile).extendedModelIdLadder ? "extended" : "base";
39
+ }
40
+
41
+ /**
42
+ * Ports upstream `V2e` (2.1.329 bundle, view line 101880, byte offset
43
+ * 5753662): whether `needle` occurs in `haystack` as an undated id. When the
44
+ * needle ends in a `-`/`_` plus a digit, an occurrence directly followed by
45
+ * three more digits is a date suffix on the shorter id (`claude-fable-5-` +
46
+ * `20260101`) and does not count.
47
+ */
48
+ function matchesUndated(haystack: string, needle: string): boolean {
49
+ const endsInDigit = /[-_]\d$/.test(needle);
50
+ for (
51
+ let at = haystack.indexOf(needle);
52
+ at !== -1;
53
+ at = haystack.indexOf(needle, at + 1)
54
+ ) {
55
+ if (!endsInDigit || !/^\d{3}/.test(haystack.slice(at + needle.length))) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+
24
62
  /**
25
63
  * Ports upstream `$_` (binary offset 226639025); in the 2.1.280 bundle the
26
64
  * function is `GF` at byte offset 7413751. The two offsets are in different
@@ -29,11 +67,27 @@ function dottedToDashedVersion(model: string): string {
29
67
  *
30
68
  * Rung order is load-bearing: each test is a substring test, so a longer id
31
69
  * must precede the shorter id it contains or the shorter rung swallows it.
70
+ *
71
+ * Two ladders. `"base"` is the ladder every profile through 2.1.280 follows.
72
+ * `"extended"` adds four rungs transcribed from the 2.1.329 bundle (`NK`, view
73
+ * lines 113702-113708): `claude-fable-5-2`, `claude-mythos-5-2`,
74
+ * `claude-sonnet-5-5` and `claude-haiku-5-5`, each placed before the shorter id
75
+ * it contains. Which ladder a profile follows is decided by `modelIdLadder`.
32
76
  */
33
- export function normalizeModelId(model: string): string {
77
+ export function normalizeModelId(
78
+ model: string,
79
+ ladder: ModelIdLadder = "base",
80
+ ): string {
34
81
  model = dottedToDashedVersion(model.toLowerCase());
82
+ const extended = ladder === "extended";
83
+ if (extended && matchesUndated(model, "claude-fable-5-2")) {
84
+ return "claude-fable-5-2";
85
+ }
35
86
  if (model.includes("claude-fable-5-1")) return "claude-fable-5-1";
36
87
  if (model.includes("claude-fable-5")) return "claude-fable-5";
88
+ if (extended && matchesUndated(model, "claude-mythos-5-2")) {
89
+ return "claude-mythos-5-2";
90
+ }
37
91
  if (model.includes("claude-mythos-5-1")) return "claude-mythos-5-1";
38
92
  if (model.includes("claude-mythos-5")) return "claude-mythos-5";
39
93
  if (model.includes("claude-opus-5-5")) return "claude-opus-5-5";
@@ -44,10 +98,16 @@ export function normalizeModelId(model: string): string {
44
98
  if (model.includes("claude-opus-4-5")) return "claude-opus-4-5";
45
99
  if (model.includes("claude-opus-4-1")) return "claude-opus-4-1";
46
100
  if (/claude-opus-4(?!-\d(?!\d))/.test(model)) return "claude-opus-4-0";
101
+ if (extended && model.includes("claude-sonnet-5-5")) {
102
+ return "claude-sonnet-5-5";
103
+ }
47
104
  if (model.includes("claude-sonnet-5")) return "claude-sonnet-5";
48
105
  if (model.includes("claude-sonnet-4-6")) return "claude-sonnet-4-6";
49
106
  if (model.includes("claude-sonnet-4-5")) return "claude-sonnet-4-5";
50
107
  if (/claude-sonnet-4(?!-\d(?!\d))/.test(model)) return "claude-sonnet-4-0";
108
+ if (extended && model.includes("claude-haiku-5-5")) {
109
+ return "claude-haiku-5-5";
110
+ }
51
111
  if (model.includes("claude-haiku-4-5")) return "claude-haiku-4-5";
52
112
  if (model.includes("claude-3-7-sonnet")) return "claude-3-7-sonnet";
53
113
  if (model.includes("claude-3-5-sonnet")) return "claude-3-5-sonnet";
@@ -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
  }