@tormentalabs/claude-code-wire-compat 0.1.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +312 -0
  2. package/LICENSE +674 -0
  3. package/NOTICE +16 -0
  4. package/README.md +39 -0
  5. package/dist/anti-verbosity.d.ts +58 -0
  6. package/dist/anti-verbosity.d.ts.map +1 -0
  7. package/dist/anti-verbosity.js +174 -0
  8. package/dist/anti-verbosity.js.map +1 -0
  9. package/dist/beta-registry.d.ts +119 -0
  10. package/dist/beta-registry.d.ts.map +1 -0
  11. package/dist/beta-registry.js +125 -0
  12. package/dist/beta-registry.js.map +1 -0
  13. package/dist/betas.d.ts +11 -0
  14. package/dist/betas.d.ts.map +1 -0
  15. package/dist/betas.js +68 -0
  16. package/dist/betas.js.map +1 -0
  17. package/dist/build-request.d.ts +24 -0
  18. package/dist/build-request.d.ts.map +1 -0
  19. package/dist/build-request.js +1008 -0
  20. package/dist/build-request.js.map +1 -0
  21. package/dist/contracts.d.ts +717 -0
  22. package/dist/contracts.d.ts.map +1 -0
  23. package/dist/contracts.js +36 -0
  24. package/dist/contracts.js.map +1 -0
  25. package/dist/count-tokens.d.ts +42 -0
  26. package/dist/count-tokens.d.ts.map +1 -0
  27. package/dist/count-tokens.js +61 -0
  28. package/dist/count-tokens.js.map +1 -0
  29. package/dist/fingerprint.d.ts +4 -0
  30. package/dist/fingerprint.d.ts.map +1 -0
  31. package/dist/fingerprint.js +59 -0
  32. package/dist/fingerprint.js.map +1 -0
  33. package/dist/headers.d.ts +4 -0
  34. package/dist/headers.d.ts.map +1 -0
  35. package/dist/headers.js +255 -0
  36. package/dist/headers.js.map +1 -0
  37. package/dist/index.d.ts +17 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +6 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/metadata.d.ts +4 -0
  42. package/dist/metadata.d.ts.map +1 -0
  43. package/dist/metadata.js +192 -0
  44. package/dist/metadata.js.map +1 -0
  45. package/dist/model-capabilities.d.ts +103 -0
  46. package/dist/model-capabilities.d.ts.map +1 -0
  47. package/dist/model-capabilities.js +263 -0
  48. package/dist/model-capabilities.js.map +1 -0
  49. package/dist/model-identity.d.ts +11 -0
  50. package/dist/model-identity.d.ts.map +1 -0
  51. package/dist/model-identity.js +64 -0
  52. package/dist/model-identity.js.map +1 -0
  53. package/dist/models.d.ts +9 -0
  54. package/dist/models.d.ts.map +1 -0
  55. package/dist/models.js +25 -0
  56. package/dist/models.js.map +1 -0
  57. package/dist/profiles/claude-code-2.1.195.d.ts +3 -0
  58. package/dist/profiles/claude-code-2.1.195.d.ts.map +1 -0
  59. package/dist/profiles/claude-code-2.1.195.js +150 -0
  60. package/dist/profiles/claude-code-2.1.195.js.map +1 -0
  61. package/dist/redaction.d.ts +16 -0
  62. package/dist/redaction.d.ts.map +1 -0
  63. package/dist/redaction.js +364 -0
  64. package/dist/redaction.js.map +1 -0
  65. package/dist/request-body.d.ts +19 -0
  66. package/dist/request-body.d.ts.map +1 -0
  67. package/dist/request-body.js +1658 -0
  68. package/dist/request-body.js.map +1 -0
  69. package/dist/sha256.d.ts +9 -0
  70. package/dist/sha256.d.ts.map +1 -0
  71. package/dist/sha256.js +104 -0
  72. package/dist/sha256.js.map +1 -0
  73. package/dist/system-prompt.d.ts +4 -0
  74. package/dist/system-prompt.d.ts.map +1 -0
  75. package/dist/system-prompt.js +157 -0
  76. package/dist/system-prompt.js.map +1 -0
  77. package/dist/thinking.d.ts +91 -0
  78. package/dist/thinking.d.ts.map +1 -0
  79. package/dist/thinking.js +132 -0
  80. package/dist/thinking.js.map +1 -0
  81. package/dist/unicode.d.ts +10 -0
  82. package/dist/unicode.d.ts.map +1 -0
  83. package/dist/unicode.js +19 -0
  84. package/dist/unicode.js.map +1 -0
  85. package/package.json +72 -0
@@ -0,0 +1,192 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ import { ClaudeCodeWireError } from "./contracts.js";
3
+ import { inspectJsonInputs, validatedJson } from "./request-body.js";
4
+ import { classifySurrogateAt } from "./unicode.js";
5
+ const MAX_TEXT_LENGTH = 8_192;
6
+ const FORBIDDEN_KEYS = new Set(["__proto__", "prototype", "constructor"]);
7
+ const CORRELATION_KEYS = new Set([
8
+ "user_id",
9
+ "device_id",
10
+ "account_uuid",
11
+ "session_id",
12
+ ]);
13
+ function hasInvalidUtf16(value) {
14
+ for (let index = 0; index < value.length; index += 1) {
15
+ const classification = classifySurrogateAt(value, index);
16
+ if (classification === "loneSurrogate")
17
+ return true;
18
+ if (classification === "surrogatePair")
19
+ index += 1;
20
+ }
21
+ return false;
22
+ }
23
+ function hasControlCharacter(value) {
24
+ for (let index = 0; index < value.length; index += 1) {
25
+ const codeUnit = value.charCodeAt(index);
26
+ if (codeUnit <= 0x1f || codeUnit === 0x7f)
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ function ownDataValue(value, key) {
32
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
33
+ return descriptor === undefined || !("value" in descriptor)
34
+ ? undefined
35
+ : descriptor.value;
36
+ }
37
+ function validateIdentityText(value, field) {
38
+ if (typeof value !== "string") {
39
+ throw new ClaudeCodeWireError("INVALID_IDENTITY", { field });
40
+ }
41
+ if (hasInvalidUtf16(value)) {
42
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field });
43
+ }
44
+ if (value.length === 0 ||
45
+ value.length > MAX_TEXT_LENGTH ||
46
+ value.trim().length === 0 ||
47
+ hasControlCharacter(value)) {
48
+ throw new ClaudeCodeWireError("INVALID_IDENTITY", { field });
49
+ }
50
+ return value;
51
+ }
52
+ function validateIdentityObject(identity) {
53
+ if (typeof identity !== "object" ||
54
+ identity === null ||
55
+ Array.isArray(identity)) {
56
+ throw new ClaudeCodeWireError("INVALID_IDENTITY");
57
+ }
58
+ for (const key of Reflect.ownKeys(identity)) {
59
+ if (typeof key !== "string" || FORBIDDEN_KEYS.has(key)) {
60
+ throw new ClaudeCodeWireError("INVALID_IDENTITY");
61
+ }
62
+ }
63
+ return identity;
64
+ }
65
+ export function validateRuntimeIdentity(identity) {
66
+ const source = validateIdentityObject(identity);
67
+ const sessionId = validateIdentityText(ownDataValue(source, "sessionId"), "sessionId");
68
+ const deviceId = validateIdentityText(ownDataValue(source, "deviceId"), "deviceId");
69
+ const accountUuid = validateIdentityText(ownDataValue(source, "accountUuid"), "accountUuid");
70
+ const runtime = validateIdentityText(ownDataValue(source, "runtime"), "runtime");
71
+ const runtimeVersion = validateIdentityText(ownDataValue(source, "runtimeVersion"), "runtimeVersion");
72
+ const os = validateIdentityText(ownDataValue(source, "os"), "os");
73
+ const arch = validateIdentityText(ownDataValue(source, "arch"), "arch");
74
+ if (runtime !== "node" && runtime !== "bun" && runtime !== "workerd") {
75
+ throw new ClaudeCodeWireError("INVALID_IDENTITY", { field: "runtime" });
76
+ }
77
+ if (os !== "Windows" && os !== "Linux" && os !== "macOS") {
78
+ throw new ClaudeCodeWireError("INVALID_IDENTITY", { field: "os" });
79
+ }
80
+ return Object.freeze({
81
+ sessionId,
82
+ deviceId,
83
+ accountUuid,
84
+ runtime,
85
+ runtimeVersion,
86
+ os,
87
+ arch,
88
+ });
89
+ }
90
+ function validateMetadataKey(key) {
91
+ if (typeof key !== "string" || FORBIDDEN_KEYS.has(key)) {
92
+ throw new ClaudeCodeWireError("INVALID_INPUT");
93
+ }
94
+ if (hasInvalidUtf16(key)) {
95
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field: "metadataKey" });
96
+ }
97
+ if (key.length > MAX_TEXT_LENGTH) {
98
+ throw new ClaudeCodeWireError("INPUT_TOO_LARGE", {
99
+ field: "metadataKey",
100
+ });
101
+ }
102
+ if (key.length === 0 || hasControlCharacter(key)) {
103
+ throw new ClaudeCodeWireError("INVALID_INPUT", { field: "metadataKey" });
104
+ }
105
+ return key;
106
+ }
107
+ function validateMetadataValue(value, key) {
108
+ if (typeof value === "string") {
109
+ if (hasInvalidUtf16(value)) {
110
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field: key });
111
+ }
112
+ if (value.length > MAX_TEXT_LENGTH) {
113
+ throw new ClaudeCodeWireError("INPUT_TOO_LARGE", { field: key });
114
+ }
115
+ if (hasControlCharacter(value)) {
116
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field: key });
117
+ }
118
+ return value;
119
+ }
120
+ if (typeof value === "number") {
121
+ if (!Number.isFinite(value)) {
122
+ throw new ClaudeCodeWireError("INVALID_INPUT", { field: key });
123
+ }
124
+ return value;
125
+ }
126
+ if (typeof value === "boolean" || value === null)
127
+ return value;
128
+ if (typeof value !== "object") {
129
+ throw new ClaudeCodeWireError("INVALID_INPUT", { field: key });
130
+ }
131
+ inspectJsonInputs([value], (nestedString) => {
132
+ if (hasInvalidUtf16(nestedString)) {
133
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field: key });
134
+ }
135
+ if (nestedString.length > MAX_TEXT_LENGTH) {
136
+ throw new ClaudeCodeWireError("INPUT_TOO_LARGE", { field: key });
137
+ }
138
+ if (hasControlCharacter(nestedString)) {
139
+ throw new ClaudeCodeWireError("INVALID_UNICODE", { field: key });
140
+ }
141
+ });
142
+ return validatedJson(value);
143
+ }
144
+ function expectedCorrelationValue(key, identity, userId) {
145
+ switch (key) {
146
+ case "user_id":
147
+ return userId;
148
+ case "device_id":
149
+ return identity.deviceId;
150
+ case "account_uuid":
151
+ return identity.accountUuid;
152
+ case "session_id":
153
+ return identity.sessionId;
154
+ default:
155
+ return undefined;
156
+ }
157
+ }
158
+ function validateMetadataObject(metadata) {
159
+ if (typeof metadata !== "object" ||
160
+ metadata === null ||
161
+ Array.isArray(metadata)) {
162
+ throw new ClaudeCodeWireError("INVALID_INPUT", { field: "metadata" });
163
+ }
164
+ return metadata;
165
+ }
166
+ export function buildCorrelatedMetadata(identity, suppliedMetadata) {
167
+ const validatedIdentity = validateRuntimeIdentity(identity);
168
+ const userId = JSON.stringify({
169
+ device_id: validatedIdentity.deviceId,
170
+ account_uuid: validatedIdentity.accountUuid,
171
+ session_id: validatedIdentity.sessionId,
172
+ });
173
+ const entries = [["user_id", userId]];
174
+ if (suppliedMetadata === undefined)
175
+ return Object.freeze({ user_id: userId });
176
+ const metadataObject = validateMetadataObject(suppliedMetadata);
177
+ for (const rawKey of Reflect.ownKeys(metadataObject)) {
178
+ const key = validateMetadataKey(rawKey);
179
+ const value = validateMetadataValue(ownDataValue(metadataObject, key), key);
180
+ if (CORRELATION_KEYS.has(key)) {
181
+ const expected = expectedCorrelationValue(key, validatedIdentity, userId);
182
+ if (value !== expected) {
183
+ throw new ClaudeCodeWireError("INVALID_INPUT", { field: key });
184
+ }
185
+ if (key === "user_id")
186
+ continue;
187
+ }
188
+ entries.push([key, value]);
189
+ }
190
+ return Object.freeze(Object.fromEntries(entries));
191
+ }
192
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AAC1E,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,SAAS;IACT,WAAW;IACX,cAAc;IACd,YAAY;CACb,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,KAAa;IACpC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,cAAc,GAAG,mBA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CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,103 @@
1
+ import type { ClaudeCodeCapabilities } from "./contracts.js";
2
+ /**
3
+ * Upstream `Kw` at byte offset 227719902.
4
+ *
5
+ * Elided: the `W9` override, `CLAUDE_CODE_ALWAYS_ENABLE_EFFORT`, the
6
+ * `JB(id, "effort") || id === "claude-mythos-5"` test, and the `ZO` fallback.
7
+ */
8
+ export declare function supportsEffort(normalizedId: string): boolean;
9
+ /**
10
+ * Upstream `Hke` at byte offset 227720257.
11
+ *
12
+ * Its exclusion list is `Kw`'s plus `claude-opus-4-5`. Elided: the `W9`
13
+ * override, the `JB(id, "max_effort") || id === "claude-mythos-5"` test, and
14
+ * the `ZO` fallback.
15
+ */
16
+ export declare function supportsMaxEffort(normalizedId: string): boolean;
17
+ /**
18
+ * Upstream `Yte` at byte offset 227720583.
19
+ *
20
+ * Its exclusion list is `Hke`'s plus `claude-opus-4-6` and
21
+ * `claude-sonnet-4-6`. Elided: the `W9` override, the
22
+ * `JB(id, "xhigh_effort") || id === "claude-mythos-5"` test, and the `ZO`
23
+ * fallback.
24
+ */
25
+ export declare function supportsXhighEffort(normalizedId: string): boolean;
26
+ /**
27
+ * Upstream `Uot` at byte offset 227383245.
28
+ *
29
+ * Its exclusion list is `Kw`'s plus `claude-opus-4-5`, matching `Hke`'s today.
30
+ * The two are transcribed separately on purpose: they are independent upstream
31
+ * predicates that happen to agree at this client version. Elided: the `W9`
32
+ * override, the `JB(id, "adaptive_thinking") || id === "claude-mythos-5"`
33
+ * test, and the `ZO` fallback.
34
+ */
35
+ export declare function supportsAdaptiveThinking(normalizedId: string): boolean;
36
+ /**
37
+ * Upstream `D9r` at byte offset 227382784.
38
+ *
39
+ * Reduces to the same body as `supportsInterleavedThinking` and
40
+ * `supportsContextManagement` at this client version. Kept separate on
41
+ * purpose: three independent upstream predicates with different provenance
42
+ * that are versioned independently upstream. Do not merge them.
43
+ *
44
+ * Elided: the `W9` override.
45
+ */
46
+ export declare function supportsThinking(normalizedId: string): boolean;
47
+ /**
48
+ * Upstream `QOt` at byte offset 227384610.
49
+ *
50
+ * See the note on `supportsThinking` about the three identical bodies.
51
+ * Elided: the `W9` override, the unreachable `foundry` branch, and the
52
+ * non-`ZO` provider tail (`claude-haiku-4-5` is excluded only for providers
53
+ * outside `ZO`, which cannot occur here -- note this is why haiku 4.5 has
54
+ * interleaved thinking on first party but not on, say, vertex).
55
+ */
56
+ export declare function supportsInterleavedThinking(normalizedId: string): boolean;
57
+ /**
58
+ * Upstream `n0d` at byte offset 227385143.
59
+ *
60
+ * See the note on `supportsThinking` about the three identical bodies.
61
+ * Elided: the unreachable `foundry` branch and the non-`ZO` tail
62
+ * `JB(id, "context_management") || id === "claude-mythos-5"`. `n0d` has no
63
+ * `W9` override upstream.
64
+ */
65
+ export declare function supportsContextManagement(normalizedId: string): boolean;
66
+ /**
67
+ * Upstream `j4e` at byte offset 227385302.
68
+ *
69
+ * Elided: the unconditionally true `ZO` provider gate.
70
+ * This beta-only gate is intentionally absent from `ClaudeCodeCapabilities`.
71
+ */
72
+ export declare function supportsStructuredOutputs(normalizedId: string): boolean;
73
+ /**
74
+ * Upstream `RCn` at byte offset 227387413.
75
+ *
76
+ * Elided: host-state gates, the `W9` override, the unobservable `JB`/mythos
77
+ * clause, and the unconditionally true `ZO` fallback. This exclusion list
78
+ * differs from `rejectsDisabledThinking` by one member: that predicate also
79
+ * excludes `claude-opus-4-8`. Do not merge them.
80
+ * This beta-only gate is intentionally absent from `ClaudeCodeCapabilities`.
81
+ */
82
+ export declare function supportsMidConversationSystem(normalizedId: string): boolean;
83
+ /**
84
+ * Upstream `LCn` at byte offset 227385451.
85
+ *
86
+ * INVERTED POLARITY relative to every other predicate in this module: this
87
+ * list is an ALLOWLIST. Membership means temperature IS supported. Do not
88
+ * refactor it into the shared exclusion-list shape.
89
+ *
90
+ * Elided: the `W9` override.
91
+ */
92
+ export declare function supportsTemperature(normalizedId: string): boolean;
93
+ /**
94
+ * Upstream `U4e` at byte offset 227382881.
95
+ *
96
+ * Its exclusion list is the widest of the five: every catalogue model except
97
+ * `claude-fable-5`. It has no `W9` override and no `claude-mythos-5` clause
98
+ * upstream. Elided: the `JB(id, "rejects_disabled_thinking")` test and the
99
+ * `ZO` fallback.
100
+ */
101
+ export declare function rejectsDisabledThinking(normalizedId: string): boolean;
102
+ export declare function deriveCapabilities(normalizedId: string): ClaudeCodeCapabilities;
103
+ //# sourceMappingURL=model-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-capabilities.d.ts","sourceRoot":"","sources":["../src/model-capabilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AA4D7D;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAY5D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAa/D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAejE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAatE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAMvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAa3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAYjE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAiBrE;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,GACnB,sBAAsB,CAYxB"}
@@ -0,0 +1,263 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * Capability derivation, ported from the genuine client's nine capability
4
+ * predicates.
5
+ *
6
+ * THE LOAD-BEARING FACT, stated up front because it is surprising:
7
+ *
8
+ * On the first-party provider -- the only provider this package targets --
9
+ * every one of these nine predicates reduces to a pure function of the
10
+ * normalized model id. The catalogue's `capabilities` string array does not
11
+ * participate in capability derivation at all.
12
+ *
13
+ * Why. Upstream, each predicate has the shape
14
+ *
15
+ * let override = W9(model, cap); // env-var capability override
16
+ * if (override !== undefined) return override;
17
+ * let id = mo(model); // normalize
18
+ * if (<exclusion list>) return false;
19
+ * if (JB(id, cap) || id === "claude-mythos-5") return true;
20
+ * return ZO(l_(model)); // provider fallback
21
+ *
22
+ * and in this package:
23
+ *
24
+ * - `W9` opens with `if (td()) return;` and `td()` is true for first party,
25
+ * so the override always yields `undefined`. It also reads environment
26
+ * variables, which this package is designed never to do. Guard dropped.
27
+ * - `ZO(...)` is `provider is firstParty|anthropicAws|foundry|mantle`. The
28
+ * profile pins `provider: "anthropic"`, so `ZO(...)` is unconditionally
29
+ * true and `return ZO(l_(e))` becomes `return true`.
30
+ * - Therefore the `JB(id, cap)` catalogue-membership test and the
31
+ * `claude-mythos-5` special case can only return `true` from a position
32
+ * where the fallback already returns `true`. They are unobservable.
33
+ * - `l_(e) === "foundry"` branches are unreachable for the same reason.
34
+ * - `ut(CLAUDE_CODE_ALWAYS_ENABLE_EFFORT)` reads an environment variable;
35
+ * dropped by the same design rule as `W9`.
36
+ *
37
+ * Only the leading exclusion list is observable, so that is all these
38
+ * functions contain.
39
+ *
40
+ * WARNING TO FUTURE READERS. Two things follow that look like bugs and are not:
41
+ *
42
+ * 1. No membership test was lost. Do NOT "restore" a `JB`-equivalent check
43
+ * here. Adding one back cannot change any result, but it reintroduces
44
+ * dead branches that cannot be covered or mutation-killed.
45
+ * 2. The catalogue `capabilities` arrays are retained in the profile as
46
+ * faithful transcribed evidence AND are consumed elsewhere --
47
+ * `mid_conv_system`, `lean_prompt` and `fast_mode` are read by later
48
+ * work packages. Do NOT delete them because this module ignores them.
49
+ *
50
+ * `claude-mythos-5` has no catalogue entry by product decision D-1. Upstream
51
+ * special-cases it by name in `Kw`, `Hke`, `Yte` and `Uot`; this port subsumes
52
+ * those clauses into the first-party fallback, which yields an identical
53
+ * result. The explicit D-1 test asserting its full nine-boolean row is the
54
+ * guard for that equivalence.
55
+ *
56
+ * Model ids reaching these functions have already been normalized by
57
+ * `resolveModel` via `normalizeModelId`.
58
+ */
59
+ /**
60
+ * Upstream `Kw` at byte offset 227719902.
61
+ *
62
+ * Elided: the `W9` override, `CLAUDE_CODE_ALWAYS_ENABLE_EFFORT`, the
63
+ * `JB(id, "effort") || id === "claude-mythos-5"` test, and the `ZO` fallback.
64
+ */
65
+ export function supportsEffort(normalizedId) {
66
+ if (normalizedId.includes("claude-3-") ||
67
+ normalizedId === "claude-opus-4-0" ||
68
+ normalizedId === "claude-opus-4-1" ||
69
+ normalizedId === "claude-sonnet-4-0" ||
70
+ normalizedId === "claude-sonnet-4-5" ||
71
+ normalizedId === "claude-haiku-4-5") {
72
+ return false;
73
+ }
74
+ return true;
75
+ }
76
+ /**
77
+ * Upstream `Hke` at byte offset 227720257.
78
+ *
79
+ * Its exclusion list is `Kw`'s plus `claude-opus-4-5`. Elided: the `W9`
80
+ * override, the `JB(id, "max_effort") || id === "claude-mythos-5"` test, and
81
+ * the `ZO` fallback.
82
+ */
83
+ export function supportsMaxEffort(normalizedId) {
84
+ if (normalizedId.includes("claude-3-") ||
85
+ normalizedId === "claude-opus-4-0" ||
86
+ normalizedId === "claude-opus-4-1" ||
87
+ normalizedId === "claude-opus-4-5" ||
88
+ normalizedId === "claude-sonnet-4-0" ||
89
+ normalizedId === "claude-sonnet-4-5" ||
90
+ normalizedId === "claude-haiku-4-5") {
91
+ return false;
92
+ }
93
+ return true;
94
+ }
95
+ /**
96
+ * Upstream `Yte` at byte offset 227720583.
97
+ *
98
+ * Its exclusion list is `Hke`'s plus `claude-opus-4-6` and
99
+ * `claude-sonnet-4-6`. Elided: the `W9` override, the
100
+ * `JB(id, "xhigh_effort") || id === "claude-mythos-5"` test, and the `ZO`
101
+ * fallback.
102
+ */
103
+ export function supportsXhighEffort(normalizedId) {
104
+ if (normalizedId.includes("claude-3-") ||
105
+ normalizedId === "claude-opus-4-0" ||
106
+ normalizedId === "claude-opus-4-1" ||
107
+ normalizedId === "claude-opus-4-5" ||
108
+ normalizedId === "claude-opus-4-6" ||
109
+ normalizedId === "claude-sonnet-4-0" ||
110
+ normalizedId === "claude-sonnet-4-5" ||
111
+ normalizedId === "claude-sonnet-4-6" ||
112
+ normalizedId === "claude-haiku-4-5") {
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+ /**
118
+ * Upstream `Uot` at byte offset 227383245.
119
+ *
120
+ * Its exclusion list is `Kw`'s plus `claude-opus-4-5`, matching `Hke`'s today.
121
+ * The two are transcribed separately on purpose: they are independent upstream
122
+ * predicates that happen to agree at this client version. Elided: the `W9`
123
+ * override, the `JB(id, "adaptive_thinking") || id === "claude-mythos-5"`
124
+ * test, and the `ZO` fallback.
125
+ */
126
+ export function supportsAdaptiveThinking(normalizedId) {
127
+ if (normalizedId.includes("claude-3-") ||
128
+ normalizedId === "claude-opus-4-0" ||
129
+ normalizedId === "claude-opus-4-1" ||
130
+ normalizedId === "claude-opus-4-5" ||
131
+ normalizedId === "claude-sonnet-4-0" ||
132
+ normalizedId === "claude-sonnet-4-5" ||
133
+ normalizedId === "claude-haiku-4-5") {
134
+ return false;
135
+ }
136
+ return true;
137
+ }
138
+ /**
139
+ * Upstream `D9r` at byte offset 227382784.
140
+ *
141
+ * Reduces to the same body as `supportsInterleavedThinking` and
142
+ * `supportsContextManagement` at this client version. Kept separate on
143
+ * purpose: three independent upstream predicates with different provenance
144
+ * that are versioned independently upstream. Do not merge them.
145
+ *
146
+ * Elided: the `W9` override.
147
+ */
148
+ export function supportsThinking(normalizedId) {
149
+ return !normalizedId.includes("claude-3-");
150
+ }
151
+ /**
152
+ * Upstream `QOt` at byte offset 227384610.
153
+ *
154
+ * See the note on `supportsThinking` about the three identical bodies.
155
+ * Elided: the `W9` override, the unreachable `foundry` branch, and the
156
+ * non-`ZO` provider tail (`claude-haiku-4-5` is excluded only for providers
157
+ * outside `ZO`, which cannot occur here -- note this is why haiku 4.5 has
158
+ * interleaved thinking on first party but not on, say, vertex).
159
+ */
160
+ export function supportsInterleavedThinking(normalizedId) {
161
+ return !normalizedId.includes("claude-3-");
162
+ }
163
+ /**
164
+ * Upstream `n0d` at byte offset 227385143.
165
+ *
166
+ * See the note on `supportsThinking` about the three identical bodies.
167
+ * Elided: the unreachable `foundry` branch and the non-`ZO` tail
168
+ * `JB(id, "context_management") || id === "claude-mythos-5"`. `n0d` has no
169
+ * `W9` override upstream.
170
+ */
171
+ export function supportsContextManagement(normalizedId) {
172
+ return !normalizedId.includes("claude-3-");
173
+ }
174
+ /**
175
+ * Upstream `j4e` at byte offset 227385302.
176
+ *
177
+ * Elided: the unconditionally true `ZO` provider gate.
178
+ * This beta-only gate is intentionally absent from `ClaudeCodeCapabilities`.
179
+ */
180
+ export function supportsStructuredOutputs(normalizedId) {
181
+ return !(normalizedId.includes("claude-3-") ||
182
+ normalizedId === "claude-opus-4-0" ||
183
+ normalizedId === "claude-sonnet-4-0");
184
+ }
185
+ /**
186
+ * Upstream `RCn` at byte offset 227387413.
187
+ *
188
+ * Elided: host-state gates, the `W9` override, the unobservable `JB`/mythos
189
+ * clause, and the unconditionally true `ZO` fallback. This exclusion list
190
+ * differs from `rejectsDisabledThinking` by one member: that predicate also
191
+ * excludes `claude-opus-4-8`. Do not merge them.
192
+ * This beta-only gate is intentionally absent from `ClaudeCodeCapabilities`.
193
+ */
194
+ export function supportsMidConversationSystem(normalizedId) {
195
+ return !(normalizedId.includes("claude-3-") ||
196
+ normalizedId === "claude-opus-4-0" ||
197
+ normalizedId === "claude-opus-4-1" ||
198
+ normalizedId === "claude-opus-4-5" ||
199
+ normalizedId === "claude-opus-4-6" ||
200
+ normalizedId === "claude-opus-4-7" ||
201
+ normalizedId === "claude-sonnet-4-0" ||
202
+ normalizedId === "claude-sonnet-4-5" ||
203
+ normalizedId === "claude-sonnet-4-6" ||
204
+ normalizedId === "claude-haiku-4-5");
205
+ }
206
+ /**
207
+ * Upstream `LCn` at byte offset 227385451.
208
+ *
209
+ * INVERTED POLARITY relative to every other predicate in this module: this
210
+ * list is an ALLOWLIST. Membership means temperature IS supported. Do not
211
+ * refactor it into the shared exclusion-list shape.
212
+ *
213
+ * Elided: the `W9` override.
214
+ */
215
+ export function supportsTemperature(normalizedId) {
216
+ return (normalizedId.includes("claude-3-") ||
217
+ normalizedId === "claude-opus-4-0" ||
218
+ normalizedId === "claude-opus-4-1" ||
219
+ normalizedId === "claude-opus-4-5" ||
220
+ normalizedId === "claude-opus-4-6" ||
221
+ normalizedId === "claude-sonnet-4-0" ||
222
+ normalizedId === "claude-sonnet-4-5" ||
223
+ normalizedId === "claude-sonnet-4-6" ||
224
+ normalizedId === "claude-haiku-4-5");
225
+ }
226
+ /**
227
+ * Upstream `U4e` at byte offset 227382881.
228
+ *
229
+ * Its exclusion list is the widest of the five: every catalogue model except
230
+ * `claude-fable-5`. It has no `W9` override and no `claude-mythos-5` clause
231
+ * upstream. Elided: the `JB(id, "rejects_disabled_thinking")` test and the
232
+ * `ZO` fallback.
233
+ */
234
+ export function rejectsDisabledThinking(normalizedId) {
235
+ if (normalizedId.includes("claude-3-") ||
236
+ normalizedId === "claude-opus-4-0" ||
237
+ normalizedId === "claude-opus-4-1" ||
238
+ normalizedId === "claude-opus-4-5" ||
239
+ normalizedId === "claude-opus-4-6" ||
240
+ normalizedId === "claude-opus-4-7" ||
241
+ normalizedId === "claude-opus-4-8" ||
242
+ normalizedId === "claude-sonnet-4-0" ||
243
+ normalizedId === "claude-sonnet-4-5" ||
244
+ normalizedId === "claude-sonnet-4-6" ||
245
+ normalizedId === "claude-haiku-4-5") {
246
+ return false;
247
+ }
248
+ return true;
249
+ }
250
+ export function deriveCapabilities(normalizedId) {
251
+ return Object.freeze({
252
+ thinking: supportsThinking(normalizedId),
253
+ adaptiveThinking: supportsAdaptiveThinking(normalizedId),
254
+ interleavedThinking: supportsInterleavedThinking(normalizedId),
255
+ effort: supportsEffort(normalizedId),
256
+ maxEffort: supportsMaxEffort(normalizedId),
257
+ xhighEffort: supportsXhighEffort(normalizedId),
258
+ contextManagement: supportsContextManagement(normalizedId),
259
+ temperature: supportsTemperature(normalizedId),
260
+ rejectsDisabledThinking: rejectsDisabledThinking(normalizedId),
261
+ });
262
+ }
263
+ //# sourceMappingURL=model-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-capabilities.js","sourceRoot":"","sources":["../src/model-capabilities.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IACjD,IACE,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,mBAAmB;QACpC,YAAY,KAAK,mBAAmB;QACpC,YAAY,KAAK,kBAAkB,EACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC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,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,IACE,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,iBAAiB;QAClC,YAAY,KAAK,mBAAmB;QACpC,YAAY,KAAK,mBAAmB;QACpC,YAAY,KAAK,mBAAmB;QACpC,YAAY,KAAK,kBAAkB,EACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,YAAoB;IAEpB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC;QACxC,gBAAgB,EAAE,wBAAwB,CAAC,YAAY,CAAC;QACxD,mBAAmB,EAAE,2BAA2B,CAAC,YAAY,CAAC;QAC9D,MAAM,EAAE,cAAc,CAAC,YAAY,CAAC;QACpC,SAAS,EAAE,iBAAiB,CAAC,YAAY,CAAC;QAC1C,WAAW,EAAE,mBAAmB,CAAC,YAAY,CAAC;QAC9C,iBAAiB,EAAE,yBAAyB,CAAC,YAAY,CAAC;QAC1D,WAAW,EAAE,mBAAmB,CAAC,YAAY,CAAC;QAC9C,uBAAuB,EAAE,uBAAuB,CAAC,YAAY,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ClaudeCodeModelFamily } from "./contracts.js";
2
+ /** Ports upstream `dp` (binary offset 226644497). */
3
+ export declare function stripModelMarkers(model: string): string;
4
+ /** Ports upstream `$_` (binary offset 226639025). */
5
+ export declare function normalizeModelId(model: string): string;
6
+ /**
7
+ * Derives the package-local family classification used only by
8
+ * `RedactedRequestEvidence`; upstream has no corresponding family concept.
9
+ */
10
+ export declare function modelFamilyOf(normalizedId: string): ClaudeCodeModelFamily;
11
+ //# sourceMappingURL=model-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-identity.d.ts","sourceRoot":"","sources":["../src/model-identity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,qBAAqB,CAOzE"}
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /** Ports upstream `dp` (binary offset 226644497). */
3
+ export function stripModelMarkers(model) {
4
+ return model.replace(/\[(1|2)m\]/gi, "");
5
+ }
6
+ /** Ports upstream `$_` (binary offset 226639025). */
7
+ export function normalizeModelId(model) {
8
+ model = model.toLowerCase();
9
+ if (model.includes("claude-fable-5"))
10
+ return "claude-fable-5";
11
+ if (model.includes("claude-mythos-5"))
12
+ return "claude-mythos-5";
13
+ if (model.includes("claude-opus-4-8"))
14
+ return "claude-opus-4-8";
15
+ if (model.includes("claude-opus-4-7"))
16
+ return "claude-opus-4-7";
17
+ if (model.includes("claude-opus-4-6"))
18
+ return "claude-opus-4-6";
19
+ if (model.includes("claude-opus-4-5"))
20
+ return "claude-opus-4-5";
21
+ if (model.includes("claude-opus-4-1"))
22
+ return "claude-opus-4-1";
23
+ if (/claude-opus-4(?!-\d(?!\d))/.test(model))
24
+ return "claude-opus-4-0";
25
+ if (model.includes("claude-sonnet-4-6"))
26
+ return "claude-sonnet-4-6";
27
+ if (model.includes("claude-sonnet-4-5"))
28
+ return "claude-sonnet-4-5";
29
+ if (/claude-sonnet-4(?!-\d(?!\d))/.test(model))
30
+ return "claude-sonnet-4-0";
31
+ if (model.includes("claude-haiku-4-5"))
32
+ return "claude-haiku-4-5";
33
+ if (model.includes("claude-3-7-sonnet"))
34
+ return "claude-3-7-sonnet";
35
+ if (model.includes("claude-3-5-sonnet"))
36
+ return "claude-3-5-sonnet";
37
+ if (model.includes("claude-3-5-haiku"))
38
+ return "claude-3-5-haiku";
39
+ if (model.includes("claude-3-opus"))
40
+ return "claude-3-opus";
41
+ if (model.includes("claude-3-sonnet"))
42
+ return "claude-3-sonnet";
43
+ if (model.includes("claude-3-haiku"))
44
+ return "claude-3-haiku";
45
+ return model.replace(/-\d{8}$/, "");
46
+ }
47
+ /**
48
+ * Derives the package-local family classification used only by
49
+ * `RedactedRequestEvidence`; upstream has no corresponding family concept.
50
+ */
51
+ export function modelFamilyOf(normalizedId) {
52
+ if (normalizedId.includes("fable"))
53
+ return "fable";
54
+ if (normalizedId.includes("mythos"))
55
+ return "mythos";
56
+ if (normalizedId.includes("haiku"))
57
+ return "haiku";
58
+ if (normalizedId.includes("sonnet"))
59
+ return "sonnet";
60
+ if (normalizedId.includes("opus"))
61
+ return "opus";
62
+ return "unknown";
63
+ }
64
+ //# sourceMappingURL=model-identity.js.map