@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
package/src/betas.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { BETA_REGISTRY } from "./beta-registry.js";
4
4
  import type {
5
+ ClaudeCodeAccountFeatures,
5
6
  ClaudeCodeCapabilities,
6
7
  ClaudeCodeProtocolProfile,
7
8
  } from "./contracts.js";
@@ -10,11 +11,14 @@ import {
10
11
  supportsMidConversationSystem,
11
12
  supportsStructuredOutputs,
12
13
  } from "./model-capabilities.js";
14
+ import { profileBehaviors } from "./profile-behaviors.js";
13
15
  import { BETA_REGISTRY_2_1_233 } from "./profiles/beta-registry-2.1.233.js";
14
16
  import { BETA_REGISTRY_2_1_280 } from "./profiles/beta-registry-2.1.280.js";
17
+ import { BETA_REGISTRY_2_1_329 } from "./profiles/beta-registry-2.1.329.js";
15
18
  import { CLAUDE_CODE_2_1_195_PROFILE } from "./profiles/claude-code-2.1.195.js";
16
19
  import { CLAUDE_CODE_2_1_233_PROFILE } from "./profiles/claude-code-2.1.233.js";
17
20
  import { CLAUDE_CODE_2_1_280_PROFILE } from "./profiles/claude-code-2.1.280.js";
21
+ import { CLAUDE_CODE_2_1_329_PROFILE } from "./profiles/claude-code-2.1.329.js";
18
22
 
19
23
  /*
20
24
  * Provenance. The emitted order is a port of the genuine client's base beta set
@@ -59,6 +63,21 @@ interface BetaRegistryEntry {
59
63
  * registry absence does not keep its site inert there; what does is the
60
64
  * catalogue, because no 2.1.233 model declares the backing capability. The two
61
65
  * mechanisms are not interchangeable and both are load-bearing.
66
+ *
67
+ * The account-served members (`INLINE_TOOLS`, `TOOL_PROVENANCE`,
68
+ * `ADVISOR_TOOL`, `CLAUDE_CODE_SIDE_QUERY`, `MESSAGE_THREADS`) are a third
69
+ * case: several older registries DO declare them, so registry presence cannot
70
+ * keep their sites inert. Their sites additionally require the profile's
71
+ * `accountServedInputs` behaviour, which only 2.1.329 sets, and a caller input
72
+ * that states the feature explicitly.
73
+ *
74
+ * `MID_CONVERSATION_SYSTEM` is the one key that went from required to optional.
75
+ * Registries up to 2.1.280 carry it with a header. A later registry may carry
76
+ * it header-less upstream (the slot exists but no identifier is sent), in which
77
+ * case it is simply omitted from that registry. The push site then emits no
78
+ * header, while the two sites that read "the mid-conversation-system site is
79
+ * active" (11b and 11c) keep keying on the activity outcome and not on the
80
+ * registry entry, exactly as upstream keys on the composed state.
62
81
  */
63
82
  export interface ComposableBetaRegistry {
64
83
  readonly CLAUDE_CODE: BetaRegistryEntry;
@@ -70,10 +89,15 @@ export interface ComposableBetaRegistry {
70
89
  readonly CONTEXT_MANAGEMENT: BetaRegistryEntry;
71
90
  readonly STRUCTURED_OUTPUTS: BetaRegistryEntry;
72
91
  readonly PROMPT_CACHING_SCOPE: BetaRegistryEntry;
73
- readonly MID_CONVERSATION_SYSTEM: BetaRegistryEntry;
92
+ readonly MID_CONVERSATION_SYSTEM?: BetaRegistryEntry;
74
93
  readonly PER_MESSAGE_EFFORT?: BetaRegistryEntry;
75
94
  readonly MID_CONV_TOOL_CHANGE?: BetaRegistryEntry;
95
+ readonly INLINE_TOOLS?: BetaRegistryEntry;
96
+ readonly TOOL_PROVENANCE?: BetaRegistryEntry;
97
+ readonly ADVISOR_TOOL?: BetaRegistryEntry;
76
98
  readonly MID_CONVERSATION_SYSTEM_CLEAR_AT?: BetaRegistryEntry;
99
+ readonly CLAUDE_CODE_SIDE_QUERY?: BetaRegistryEntry;
100
+ readonly MESSAGE_THREADS?: BetaRegistryEntry;
77
101
  readonly EFFORT: BetaRegistryEntry;
78
102
  readonly THINKING_BINDING_CONTROLS?: BetaRegistryEntry;
79
103
  readonly THINKING_DISPLAY_UPDATES?: BetaRegistryEntry;
@@ -90,6 +114,7 @@ const PROFILE_BETA_REGISTRIES: ReadonlyMap<string, ComposableBetaRegistry> =
90
114
  [CLAUDE_CODE_2_1_195_PROFILE.id, BETA_REGISTRY],
91
115
  [CLAUDE_CODE_2_1_233_PROFILE.id, BETA_REGISTRY_2_1_233],
92
116
  [CLAUDE_CODE_2_1_280_PROFILE.id, BETA_REGISTRY_2_1_280],
117
+ [CLAUDE_CODE_2_1_329_PROFILE.id, BETA_REGISTRY_2_1_329],
93
118
  ]);
94
119
 
95
120
  /**
@@ -155,6 +180,29 @@ export interface ComposeBetasInput {
155
180
  * `[1m]` model marker. See `docs/source-trace.md`, governance ledger L10.
156
181
  */
157
182
  readonly use1MContextOverride?: boolean;
183
+ /**
184
+ * Validated caller opt-ins for features the genuine client enables per
185
+ * account. Read only under the profile's `accountServedInputs` behaviour.
186
+ */
187
+ readonly accountFeatures?: ClaudeCodeAccountFeatures;
188
+ /**
189
+ * Whether the request's tools include the advisor tool
190
+ * (`type: "advisor_20260301"`). Compute it at the call site from the caller's
191
+ * tool list; read only under `accountServedInputs`.
192
+ */
193
+ readonly hasAdvisorTool?: boolean;
194
+ /**
195
+ * Marks a side query (the plugin uses it for session-title requests), which
196
+ * adds the claude-code-side-query beta. Read only under
197
+ * `accountServedInputs`.
198
+ */
199
+ readonly sideQuery?: boolean;
200
+ /**
201
+ * Marks an agentic query, which restores the claude-code beta for a model
202
+ * the per-model table excludes it from (haiku). Read only under
203
+ * `accountServedInputs`.
204
+ */
205
+ readonly agenticQuery?: boolean;
158
206
  }
159
207
 
160
208
  /**
@@ -179,8 +227,35 @@ export interface ComposedBetas {
179
227
  * `output_config.effort` in the body.
180
228
  */
181
229
  readonly thinkingDisplayOverride?: "updates";
230
+ /**
231
+ * Whether the context-management site (push site 7) fired, i.e. the
232
+ * experimental gate held and the model declares the capability. Body-side
233
+ * half of a beta/body pair, like `thinkingDisplayOverride`: the body builder
234
+ * generates `context_management` from it under
235
+ * `generatedContextManagement`. Not touched by `suppressBetas`: suppressing
236
+ * the identifier removes the HEADER only (MEMORY #4).
237
+ */
238
+ readonly contextManagementComposed: boolean;
239
+ /**
240
+ * Whether the cache-diagnosis site fired (the profile policy enables it).
241
+ * Body-side half of the pair: the body builder emits `diagnostics` from it
242
+ * under `cacheDiagnosisBody`. Not touched by `suppressBetas`.
243
+ */
244
+ readonly cacheDiagnosisComposed: boolean;
245
+ /**
246
+ * The thread the body should carry, present only when the message-threads
247
+ * site fired AND the identifier survived `suppressBetas`. Unlike the other
248
+ * body-side halves, a caller who suppresses this beta also loses the body
249
+ * field: sending `thread` without its beta is a request the server rejects.
250
+ */
251
+ readonly thread?: ClaudeCodeThreadBody;
182
252
  }
183
253
 
254
+ /** The wire shape of the body's `thread` object. */
255
+ export type ClaudeCodeThreadBody =
256
+ | { readonly type: "create" }
257
+ | { readonly type: "continue"; readonly previous_message_id: string };
258
+
184
259
  /**
185
260
  * Bounds a caller-supplied beta list (`additionalBetas` and `suppressBetas`
186
261
  * share these rules verbatim). The header is a comma-joined single
@@ -228,6 +303,11 @@ export function composeBetasWithAudit(
228
303
  const policy = profile.betaPolicy;
229
304
  const experimental = policy.experimentalBetasEnabled;
230
305
  const registry = resolveBetaRegistry(profile);
306
+ const behaviors = profileBehaviors(profile);
307
+ // Account-served and per-query caller inputs act only where the profile's
308
+ // behaviour set declares them; every other profile ignores them entirely.
309
+ const honoured = behaviors.accountServedInputs;
310
+ const accountFeatures = input.accountFeatures;
231
311
 
232
312
  if (!input.normalizedId.includes("haiku"))
233
313
  out.push(registry.CLAUDE_CODE.header);
@@ -237,7 +317,21 @@ export function composeBetasWithAudit(
237
317
  // enable a beta the pinned profile declares unavailable.
238
318
  const oneMillionRequested =
239
319
  input.use1MContextOverride ?? /\[1m\]/iu.test(input.rawModel);
240
- if (policy.oneMillionContextEnabled && oneMillionRequested) {
320
+ /*
321
+ * Under `longContextExcludesNative1m` a model whose catalogue entry declares
322
+ * a native 1M window never gets the beta: the window needs no opt-in, so the
323
+ * genuine client does not send one. Only the marker conjunct is replaced by
324
+ * `use1MContextOverride`; this exclusion still applies to an override of
325
+ * `true`, because the override cannot make a native window need the beta.
326
+ */
327
+ const nativeOneMillion =
328
+ Object.hasOwn(profile.supportedModels, input.normalizedId) &&
329
+ profile.supportedModels[input.normalizedId]?.context?.native1m === true;
330
+ if (
331
+ policy.oneMillionContextEnabled &&
332
+ oneMillionRequested &&
333
+ !(behaviors.longContextExcludesNative1m && nativeOneMillion)
334
+ ) {
241
335
  out.push(registry.LONG_CONTEXT.header);
242
336
  }
243
337
  if (
@@ -255,11 +349,18 @@ export function composeBetasWithAudit(
255
349
  ) {
256
350
  out.push(registry.REDACT_THINKING.header);
257
351
  }
258
- if (
352
+ /*
353
+ * Site 6. Under `thinkingTokenCountAfterRequestTable` the genuine client
354
+ * pushes this beta after the per-request sites instead; that push is site 6′
355
+ * below, with identical gates.
356
+ */
357
+ const thinkingTokenCountGates =
259
358
  policy.thinkingTokenCountEnabled &&
260
359
  experimental &&
261
- input.capabilities.interleavedThinking
262
- ) {
360
+ input.capabilities.interleavedThinking;
361
+ const tokenCountAfterRequestTable =
362
+ behaviors.thinkingTokenCountAfterRequestTable;
363
+ if (thinkingTokenCountGates && !tokenCountAfterRequestTable) {
263
364
  out.push(registry.THINKING_TOKEN_COUNT.header);
264
365
  }
265
366
  /*
@@ -278,8 +379,9 @@ export function composeBetasWithAudit(
278
379
  ) {
279
380
  out.push(narrationSummaries.header);
280
381
  }
281
- if (experimental && input.capabilities.contextManagement)
282
- out.push(registry.CONTEXT_MANAGEMENT.header);
382
+ const contextManagementComposed =
383
+ experimental && input.capabilities.contextManagement;
384
+ if (contextManagementComposed) out.push(registry.CONTEXT_MANAGEMENT.header);
283
385
  if (
284
386
  experimental &&
285
387
  supportsStructuredOutputs(input.normalizedId) &&
@@ -292,17 +394,36 @@ export function composeBetasWithAudit(
292
394
  if (experimental) out.push(registry.PROMPT_CACHING_SCOPE.header);
293
395
 
294
396
  /*
295
- * Upstream `jR`. The local boolean below records that this site PUSHED, which
296
- * is what sites 11b and 11c gate on -- upstream reads `Ee.includes(jR)`, the
297
- * composed array, not the registry. Asking the registry instead would fire
298
- * those two sites for a model this one skipped.
397
+ * Upstream `jR`. The local boolean below records that this site is ACTIVE for
398
+ * the model, which is what sites 11b and 11c gate on -- upstream reads
399
+ * `Ee.includes(jR)`, the composed state, not the registry. Asking the
400
+ * registry instead would fire those two sites for a model this one skipped.
401
+ * The header is pushed only when the registry carries one; a registry whose
402
+ * slot is header-less leaves the site active and the list unchanged.
299
403
  */
300
- const midConversationSystemFired = supportsMidConversationSystem(
404
+ const midConversationSystemActive = supportsMidConversationSystem(
301
405
  input.normalizedId,
302
406
  profile,
303
407
  );
304
- if (midConversationSystemFired) {
305
- out.push(registry.MID_CONVERSATION_SYSTEM.header);
408
+ const midConversationSystem = registry.MID_CONVERSATION_SYSTEM;
409
+ if (midConversationSystemActive && midConversationSystem !== undefined) {
410
+ out.push(midConversationSystem.header);
411
+ }
412
+
413
+ /*
414
+ * Agentic-query marker. Upstream `uwr(e, {isAgenticQuery})` appends the
415
+ * claude-code beta to the per-model table when the model's table excludes it
416
+ * (the haiku models): `if (r?.isAgenticQuery && !h.includes(qkt)) h.push(qkt)`.
417
+ * The push lands after the per-model entries -- the mid-conversation marker
418
+ * above is the table's last one -- and before every per-request site below.
419
+ */
420
+ if (
421
+ honoured &&
422
+ input.agenticQuery === true &&
423
+ input.normalizedId.includes("haiku") &&
424
+ !out.includes(registry.CLAUDE_CODE.header)
425
+ ) {
426
+ out.push(registry.CLAUDE_CODE.header);
306
427
  }
307
428
 
308
429
  /*
@@ -327,15 +448,70 @@ export function composeBetasWithAudit(
327
448
  * document's divergence record.
328
449
  */
329
450
  const midConvToolChange = registry.MID_CONV_TOOL_CHANGE;
330
- if (
451
+ const midConvToolChangeFired =
331
452
  experimental &&
332
- midConversationSystemFired &&
453
+ midConversationSystemActive &&
333
454
  input.capabilities.midConvToolChange &&
334
- midConvToolChange !== undefined
335
- ) {
455
+ midConvToolChange !== undefined;
456
+ if (midConvToolChangeFired) {
336
457
  out.push(midConvToolChange.header);
337
458
  }
338
459
 
460
+ /*
461
+ * Site 11d. The inline-tools beta, which the genuine client sends when the
462
+ * account is served the feature (server-served, so the caller states it) and
463
+ * the mid-conversation tool-change beta just fired: it keys on that composed
464
+ * outcome, which is why it sits directly after site 11b. The coupled body
465
+ * half (`role: "system"` messages carrying `tool_addition` blocks) is the
466
+ * caller's to supply; this site is header-only.
467
+ */
468
+ const inlineTools = registry.INLINE_TOOLS;
469
+ if (
470
+ honoured &&
471
+ accountFeatures?.inlineTools === true &&
472
+ experimental &&
473
+ midConvToolChangeFired &&
474
+ inlineTools !== undefined
475
+ ) {
476
+ out.push(inlineTools.header);
477
+ }
478
+
479
+ /*
480
+ * Site 11e. The tool-provenance beta. OPT-IN: both genuine OAuth captures
481
+ * omit it, so it is never composed by default. Upstream's own conjuncts are
482
+ * the experimental gate and OAuth authentication; the coupled
483
+ * `ownership_metadata` body field is recorded as not ported.
484
+ */
485
+ const toolProvenance = registry.TOOL_PROVENANCE;
486
+ if (
487
+ honoured &&
488
+ accountFeatures?.toolProvenance === true &&
489
+ experimental &&
490
+ policy.oauthAuthenticated &&
491
+ toolProvenance !== undefined
492
+ ) {
493
+ out.push(toolProvenance.header);
494
+ }
495
+
496
+ /*
497
+ * Site 11f. The advisor-tool beta, pushed when the request carries the
498
+ * advisor tool itself. No experimental gate: the tool's presence in the
499
+ * request is the whole condition.
500
+ */
501
+ const advisorTool = registry.ADVISOR_TOOL;
502
+ if (honoured && input.hasAdvisorTool === true && advisorTool !== undefined) {
503
+ out.push(advisorTool.header);
504
+ }
505
+
506
+ /*
507
+ * Site 6′. The thinking-token-count beta at the position the genuine client
508
+ * pushes it under `thinkingTokenCountAfterRequestTable`: after the
509
+ * per-request sites above and before clear-at (11c). Same gates as site 6.
510
+ */
511
+ if (thinkingTokenCountGates && tokenCountAfterRequestTable) {
512
+ out.push(registry.THINKING_TOKEN_COUNT.header);
513
+ }
514
+
339
515
  /*
340
516
  * Site 11c. Upstream `Mo`, which is the one site whose experimental gate is
341
517
  * invisible at the statement level -- `Mo` names no `Fg()` at all. The gate is
@@ -350,18 +526,32 @@ export function composeBetasWithAudit(
350
526
  * holds because `Vr` is a per-session latch, and a stateless package composes
351
527
  * every request as a first request. `Mee`'s other terms are fixed on the
352
528
  * first-party path. What is left is `Ee.includes(jR)`, which is precisely the
353
- * `midConversationSystemFired` outcome recorded at site 11.
529
+ * `midConversationSystemActive` outcome recorded at site 11.
354
530
  */
355
531
  const midConversationSystemClearAt =
356
532
  registry.MID_CONVERSATION_SYSTEM_CLEAR_AT;
357
533
  if (
358
534
  experimental &&
359
- midConversationSystemFired &&
535
+ midConversationSystemActive &&
360
536
  midConversationSystemClearAt !== undefined
361
537
  ) {
362
538
  out.push(midConversationSystemClearAt.header);
363
539
  }
364
540
 
541
+ /*
542
+ * Side-query marker. Upstream pushes the claude-code-side-query beta in the
543
+ * per-attempt group, before effort (`eUo`). The plugin sets the input on
544
+ * session-title requests only.
545
+ */
546
+ const claudeCodeSideQuery = registry.CLAUDE_CODE_SIDE_QUERY;
547
+ if (
548
+ honoured &&
549
+ input.sideQuery === true &&
550
+ claudeCodeSideQuery !== undefined
551
+ ) {
552
+ out.push(claudeCodeSideQuery.header);
553
+ }
554
+
365
555
  // Site 12.
366
556
  if (input.capabilities.effort) out.push(registry.EFFORT.header);
367
557
 
@@ -449,14 +639,40 @@ export function composeBetasWithAudit(
449
639
  out.push(registry.EXTENDED_CACHE_TTL.header);
450
640
  }
451
641
  if (profile.contextHintEnabled) out.push(registry.CONTEXT_HINT.header);
642
+ const cacheDiagnosisComposed = policy.cacheDiagnosisEnabled;
452
643
  if (
453
- policy.cacheDiagnosisEnabled &&
644
+ cacheDiagnosisComposed &&
454
645
  !out.includes(registry.CACHE_DIAGNOSIS.header)
455
646
  ) {
456
647
  out.push(registry.CACHE_DIAGNOSIS.header);
457
648
  }
458
649
 
459
- // No advisor-tool beta: upstream has no observed unconditional push site.
650
+ /*
651
+ * Site 18. The message-threads beta, after cache-diagnosis. Account-served,
652
+ * so the caller states the thread. Body-side half of a beta/body pair: the
653
+ * site also decides the body's `thread` object, which is dropped when the
654
+ * caller suppresses the identifier (see below).
655
+ */
656
+ const messageThreads = registry.MESSAGE_THREADS;
657
+ let threadBody: ClaudeCodeThreadBody | undefined;
658
+ if (
659
+ honoured &&
660
+ accountFeatures?.thread !== undefined &&
661
+ experimental &&
662
+ messageThreads !== undefined
663
+ ) {
664
+ out.push(messageThreads.header);
665
+ threadBody =
666
+ accountFeatures.thread.type === "create"
667
+ ? { type: "create" }
668
+ : {
669
+ type: "continue",
670
+ previous_message_id: accountFeatures.thread.previousMessageId,
671
+ };
672
+ }
673
+
674
+ // The advisor-tool beta is pushed at site 11f, under `accountServedInputs`;
675
+ // no profile composes it unconditionally.
460
676
 
461
677
  // Package extension. Canonical, upstream-derived identifiers always precede
462
678
  // caller-supplied ones, and a caller entry that duplicates an already-emitted
@@ -480,6 +696,9 @@ export function composeBetasWithAudit(
480
696
  ...(thinkingDisplayOverride === undefined
481
697
  ? {}
482
698
  : { thinkingDisplayOverride }),
699
+ contextManagementComposed,
700
+ cacheDiagnosisComposed,
701
+ ...(threadBody === undefined ? {} : { thread: threadBody }),
483
702
  });
484
703
  }
485
704
  const suppressed = new Set(validateAdditionalBetas(input.suppressBetas));
@@ -497,5 +716,16 @@ export function composeBetasWithAudit(
497
716
  ...(thinkingDisplayOverride === undefined
498
717
  ? {}
499
718
  : { thinkingDisplayOverride }),
719
+ // Same reasoning: the body-side halves of the context-management and
720
+ // cache-diagnosis pairs survive the suppression filter.
721
+ contextManagementComposed,
722
+ cacheDiagnosisComposed,
723
+ // The one body half the filter DOES reach: `thread` without its beta
724
+ // header is not a request the server accepts, so a suppressed
725
+ // message-threads identifier takes the body field with it.
726
+ ...(threadBody === undefined ||
727
+ (messageThreads !== undefined && suppressed.has(messageThreads.header))
728
+ ? {}
729
+ : { thread: threadBody }),
500
730
  });
501
731
  }