@tormentalabs/claude-code-wire-compat 0.1.0-rc.16 → 0.1.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.
- package/CHANGELOG.md +132 -1
- package/README.md +53 -1
- package/dist/build-request.d.ts.map +1 -1
- package/dist/build-request.js +164 -26
- package/dist/build-request.js.map +1 -1
- package/dist/contracts.d.ts +103 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/redaction.d.ts +11 -0
- package/dist/redaction.d.ts.map +1 -1
- package/dist/redaction.js +11 -0
- package/dist/redaction.js.map +1 -1
- package/dist/request-body.d.ts.map +1 -1
- package/dist/request-body.js +74 -19
- package/dist/request-body.js.map +1 -1
- package/dist/system-prompt.d.ts +12 -5
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +29 -13
- package/dist/system-prompt.js.map +1 -1
- package/package.json +2 -1
- package/src/anti-verbosity.ts +219 -0
- package/src/beta-registry.ts +140 -0
- package/src/betas.ts +219 -0
- package/src/build-request.ts +1655 -0
- package/src/contracts.ts +1233 -0
- package/src/count-tokens.ts +84 -0
- package/src/fingerprint.ts +85 -0
- package/src/headers.ts +442 -0
- package/src/index.ts +62 -0
- package/src/metadata.ts +331 -0
- package/src/model-capabilities.ts +295 -0
- package/src/model-identity.ts +45 -0
- package/src/models.ts +46 -0
- package/src/profiles/claude-code-2.1.195.ts +154 -0
- package/src/redaction.ts +521 -0
- package/src/request-body.ts +1924 -0
- package/src/sha256.ts +114 -0
- package/src/system-prompt.ts +222 -0
- package/src/thinking.ts +266 -0
- package/src/unicode.ts +24 -0
package/src/models.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ClaudeCodeCapabilities,
|
|
5
|
+
ClaudeCodeModelFamily,
|
|
6
|
+
ClaudeCodeProtocolProfile,
|
|
7
|
+
} from "./contracts.js";
|
|
8
|
+
import { ClaudeCodeWireError } from "./contracts.js";
|
|
9
|
+
import { deriveCapabilities } from "./model-capabilities.js";
|
|
10
|
+
import {
|
|
11
|
+
modelFamilyOf,
|
|
12
|
+
normalizeModelId,
|
|
13
|
+
stripModelMarkers,
|
|
14
|
+
} from "./model-identity.js";
|
|
15
|
+
import { CLAUDE_CODE_2_1_195_PROFILE } from "./profiles/claude-code-2.1.195.js";
|
|
16
|
+
|
|
17
|
+
export interface ResolvedClaudeCodeModel {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly wireId: string;
|
|
20
|
+
readonly family: ClaudeCodeModelFamily;
|
|
21
|
+
readonly capabilities: ClaudeCodeCapabilities;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveModel(
|
|
25
|
+
model: string,
|
|
26
|
+
profile: ClaudeCodeProtocolProfile = CLAUDE_CODE_2_1_195_PROFILE,
|
|
27
|
+
): ResolvedClaudeCodeModel {
|
|
28
|
+
if (typeof model !== "string" || model.length === 0) {
|
|
29
|
+
throw new ClaudeCodeWireError("INVALID_INPUT", { model });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const wireId = stripModelMarkers(model);
|
|
33
|
+
const id = normalizeModelId(model);
|
|
34
|
+
const entry = Object.hasOwn(profile.supportedModels, id)
|
|
35
|
+
? profile.supportedModels[id]
|
|
36
|
+
: undefined;
|
|
37
|
+
return Object.freeze({
|
|
38
|
+
id,
|
|
39
|
+
wireId,
|
|
40
|
+
// The catalogue supplies the family. It does NOT supply capabilities:
|
|
41
|
+
// on first party every capability is a pure function of the normalized
|
|
42
|
+
// id. See the header of `model-capabilities.ts` for why.
|
|
43
|
+
family: entry?.family ?? modelFamilyOf(id),
|
|
44
|
+
capabilities: deriveCapabilities(id),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
|
|
3
|
+
import type { ClaudeCodeProtocolProfile } from "../contracts.js";
|
|
4
|
+
import { COUNT_TOKENS_ENDPOINT } from "../count-tokens.js";
|
|
5
|
+
|
|
6
|
+
function deepFreeze<T>(value: T): T {
|
|
7
|
+
if (value !== null && typeof value === "object") {
|
|
8
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
9
|
+
deepFreeze(Reflect.get(value, key));
|
|
10
|
+
}
|
|
11
|
+
Object.freeze(value);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CLAUDE_CODE_2_1_195_PROFILE: ClaudeCodeProtocolProfile =
|
|
17
|
+
deepFreeze({
|
|
18
|
+
id: "claude-code-2.1.195-sdk-0.94.0",
|
|
19
|
+
cliVersion: "2.1.195",
|
|
20
|
+
sdkVersion: "0.94.0",
|
|
21
|
+
endpoint: "https://api.anthropic.com/v1/messages?beta=true",
|
|
22
|
+
countTokensEndpoint: COUNT_TOKENS_ENDPOINT,
|
|
23
|
+
entrypoint: "cli",
|
|
24
|
+
userAgent: "claude-cli/2.1.195 (external, cli)",
|
|
25
|
+
buildTime: "2026-06-26T01:00:56Z",
|
|
26
|
+
gitSha: "4603aa3f2ea164bd0974f82eb413ae7acc99a7ee",
|
|
27
|
+
attributionHeaderEnabled: true,
|
|
28
|
+
provider: "anthropic",
|
|
29
|
+
anthropicVersion: "2023-06-01",
|
|
30
|
+
contextHintEnabled: false,
|
|
31
|
+
betaPolicy: {
|
|
32
|
+
oauthAuthenticated: true,
|
|
33
|
+
experimentalBetasEnabled: true,
|
|
34
|
+
oneMillionContextEnabled: true,
|
|
35
|
+
interleavedThinkingEnabled: true,
|
|
36
|
+
interactive: true,
|
|
37
|
+
thinkingSummariesShown: false,
|
|
38
|
+
thinkingTokenCountEnabled: true,
|
|
39
|
+
narrationSummariesEnabled: false,
|
|
40
|
+
structuredOutputsEnabled: false,
|
|
41
|
+
afkModeEnabled: false,
|
|
42
|
+
cacheDiagnosisEnabled: false,
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Verbatim genuine-client catalogue at byte offset 226599191.
|
|
46
|
+
* `defaultEffort` is policy exposed as catalogue data; this package must
|
|
47
|
+
* never apply it to a request.
|
|
48
|
+
*/
|
|
49
|
+
supportedModels: {
|
|
50
|
+
"claude-3-5-haiku": {
|
|
51
|
+
family: "haiku",
|
|
52
|
+
capabilities: [],
|
|
53
|
+
},
|
|
54
|
+
"claude-haiku-4-5": {
|
|
55
|
+
family: "haiku",
|
|
56
|
+
capabilities: ["context_management"],
|
|
57
|
+
},
|
|
58
|
+
"claude-3-5-sonnet": {
|
|
59
|
+
family: "sonnet",
|
|
60
|
+
capabilities: [],
|
|
61
|
+
},
|
|
62
|
+
"claude-3-7-sonnet": {
|
|
63
|
+
family: "sonnet",
|
|
64
|
+
capabilities: [],
|
|
65
|
+
},
|
|
66
|
+
"claude-sonnet-4-0": {
|
|
67
|
+
family: "sonnet",
|
|
68
|
+
context: { window: 200000, supports1mBeta: true },
|
|
69
|
+
capabilities: ["context_management"],
|
|
70
|
+
},
|
|
71
|
+
"claude-sonnet-4-5": {
|
|
72
|
+
family: "sonnet",
|
|
73
|
+
context: { window: 200000, supports1mBeta: true },
|
|
74
|
+
capabilities: ["context_management"],
|
|
75
|
+
},
|
|
76
|
+
"claude-sonnet-4-6": {
|
|
77
|
+
family: "sonnet",
|
|
78
|
+
context: { window: 200000, supports1mBeta: true },
|
|
79
|
+
capabilities: [
|
|
80
|
+
"effort",
|
|
81
|
+
"max_effort",
|
|
82
|
+
"adaptive_thinking",
|
|
83
|
+
"context_management",
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
"claude-opus-4-0": {
|
|
87
|
+
family: "opus",
|
|
88
|
+
capabilities: ["context_management"],
|
|
89
|
+
},
|
|
90
|
+
"claude-opus-4-1": {
|
|
91
|
+
family: "opus",
|
|
92
|
+
capabilities: ["context_management"],
|
|
93
|
+
},
|
|
94
|
+
"claude-opus-4-5": {
|
|
95
|
+
family: "opus",
|
|
96
|
+
capabilities: ["context_management"],
|
|
97
|
+
},
|
|
98
|
+
"claude-opus-4-6": {
|
|
99
|
+
family: "opus",
|
|
100
|
+
context: { window: 200000, supports1mBeta: true },
|
|
101
|
+
capabilities: [
|
|
102
|
+
"effort",
|
|
103
|
+
"max_effort",
|
|
104
|
+
"adaptive_thinking",
|
|
105
|
+
"context_management",
|
|
106
|
+
"fast_mode",
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
"claude-opus-4-7": {
|
|
110
|
+
family: "opus",
|
|
111
|
+
context: { window: 1e6, native1m: true, supports1mBeta: true },
|
|
112
|
+
capabilities: [
|
|
113
|
+
"effort",
|
|
114
|
+
"max_effort",
|
|
115
|
+
"xhigh_effort",
|
|
116
|
+
"adaptive_thinking",
|
|
117
|
+
"context_management",
|
|
118
|
+
"fast_mode",
|
|
119
|
+
],
|
|
120
|
+
defaultEffort: "xhigh",
|
|
121
|
+
},
|
|
122
|
+
"claude-opus-4-8": {
|
|
123
|
+
family: "opus",
|
|
124
|
+
context: { window: 1e6, native1m: true, supports1mBeta: true },
|
|
125
|
+
capabilities: [
|
|
126
|
+
"effort",
|
|
127
|
+
"max_effort",
|
|
128
|
+
"xhigh_effort",
|
|
129
|
+
"adaptive_thinking",
|
|
130
|
+
"mid_conv_system",
|
|
131
|
+
"context_management",
|
|
132
|
+
"fast_mode",
|
|
133
|
+
"lean_prompt",
|
|
134
|
+
],
|
|
135
|
+
defaultEffort: "high",
|
|
136
|
+
},
|
|
137
|
+
"claude-fable-5": {
|
|
138
|
+
family: "fable",
|
|
139
|
+
context: { window: 1e6, native1m: true, supports1mBeta: true },
|
|
140
|
+
capabilities: [
|
|
141
|
+
"effort",
|
|
142
|
+
"max_effort",
|
|
143
|
+
"xhigh_effort",
|
|
144
|
+
"adaptive_thinking",
|
|
145
|
+
"rejects_disabled_thinking",
|
|
146
|
+
"mid_conv_system",
|
|
147
|
+
"context_management",
|
|
148
|
+
"lean_prompt",
|
|
149
|
+
"fable_5_mitigations",
|
|
150
|
+
],
|
|
151
|
+
defaultEffort: "high",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|