@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
@@ -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
+ );