condukt 0.25.0 → 0.27.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/dist/runtimes/claude/bridge-cache.d.ts +58 -0
- package/dist/runtimes/claude/bridge-cache.d.ts.map +1 -0
- package/dist/runtimes/claude/bridge-cache.js +257 -0
- package/dist/runtimes/claude/bridge-cache.js.map +1 -0
- package/dist/runtimes/claude/claude-runtime.d.ts +30 -0
- package/dist/runtimes/claude/claude-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-runtime.js +88 -0
- package/dist/runtimes/claude/claude-runtime.js.map +1 -0
- package/dist/runtimes/claude/claude-session.d.ts +154 -0
- package/dist/runtimes/claude/claude-session.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-session.js +851 -0
- package/dist/runtimes/claude/claude-session.js.map +1 -0
- package/dist/runtimes/claude/config-mapper.d.ts +69 -0
- package/dist/runtimes/claude/config-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/config-mapper.js +458 -0
- package/dist/runtimes/claude/config-mapper.js.map +1 -0
- package/dist/runtimes/claude/epoch-store.d.ts +28 -0
- package/dist/runtimes/claude/epoch-store.d.ts.map +1 -0
- package/dist/runtimes/claude/epoch-store.js +199 -0
- package/dist/runtimes/claude/epoch-store.js.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts +14 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.js +64 -0
- package/dist/runtimes/claude/fallback-runtime.js.map +1 -0
- package/dist/runtimes/claude/index.d.ts +24 -0
- package/dist/runtimes/claude/index.d.ts.map +1 -0
- package/dist/runtimes/claude/index.js +61 -0
- package/dist/runtimes/claude/index.js.map +1 -0
- package/dist/runtimes/claude/message-mapper.d.ts +135 -0
- package/dist/runtimes/claude/message-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/message-mapper.js +504 -0
- package/dist/runtimes/claude/message-mapper.js.map +1 -0
- package/dist/runtimes/claude/one-shot.d.ts +48 -0
- package/dist/runtimes/claude/one-shot.d.ts.map +1 -0
- package/dist/runtimes/claude/one-shot.js +186 -0
- package/dist/runtimes/claude/one-shot.js.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts +138 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.js +1170 -0
- package/dist/runtimes/claude/protocol-bridge.js.map +1 -0
- package/dist/runtimes/claude/protocol-router.d.ts +113 -0
- package/dist/runtimes/claude/protocol-router.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-router.js +514 -0
- package/dist/runtimes/claude/protocol-router.js.map +1 -0
- package/dist/runtimes/claude/session-epoch.d.ts +156 -0
- package/dist/runtimes/claude/session-epoch.d.ts.map +1 -0
- package/dist/runtimes/claude/session-epoch.js +365 -0
- package/dist/runtimes/claude/session-epoch.js.map +1 -0
- package/dist/runtimes/claude/session-recovery.d.ts +78 -0
- package/dist/runtimes/claude/session-recovery.d.ts.map +1 -0
- package/dist/runtimes/claude/session-recovery.js +259 -0
- package/dist/runtimes/claude/session-recovery.js.map +1 -0
- package/dist/runtimes/claude/sse.d.ts +16 -0
- package/dist/runtimes/claude/sse.d.ts.map +1 -0
- package/dist/runtimes/claude/sse.js +46 -0
- package/dist/runtimes/claude/sse.js.map +1 -0
- package/dist/runtimes/claude/translate-chat.d.ts +106 -0
- package/dist/runtimes/claude/translate-chat.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-chat.js +857 -0
- package/dist/runtimes/claude/translate-chat.js.map +1 -0
- package/dist/runtimes/claude/translate-responses.d.ts +76 -0
- package/dist/runtimes/claude/translate-responses.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-responses.js +625 -0
- package/dist/runtimes/claude/translate-responses.js.map +1 -0
- package/dist/runtimes/claude/usage-ledger.d.ts +108 -0
- package/dist/runtimes/claude/usage-ledger.d.ts.map +1 -0
- package/dist/runtimes/claude/usage-ledger.js +189 -0
- package/dist/runtimes/claude/usage-ledger.js.map +1 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts +8 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.js +314 -135
- package/dist/runtimes/copilot/sdk-backend.js.map +1 -1
- package/dist/runtimes/mcp-env.d.ts +24 -0
- package/dist/runtimes/mcp-env.d.ts.map +1 -0
- package/dist/runtimes/mcp-env.js +81 -0
- package/dist/runtimes/mcp-env.js.map +1 -0
- package/dist/runtimes/mock/mock-runtime.d.ts +2 -2
- package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -1
- package/dist/runtimes/mock/mock-runtime.js +38 -1
- package/dist/runtimes/mock/mock-runtime.js.map +1 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +171 -3
- package/dist/src/agent.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/session-recovery-policy.d.ts +19 -0
- package/dist/src/session-recovery-policy.d.ts.map +1 -0
- package/dist/src/session-recovery-policy.js +43 -0
- package/dist/src/session-recovery-policy.js.map +1 -0
- package/dist/src/types.d.ts +118 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +11 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +20 -4
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Protocol routing for the in-process bridge (OpenCode Go / Zen parity).
|
|
4
|
+
*
|
|
5
|
+
* OpenCode serves models over three wire protocols:
|
|
6
|
+
* - Anthropic messages (…/anthropic/v1/messages)
|
|
7
|
+
* - OpenAI chat/completions (…/openai/v1/chat/completions)
|
|
8
|
+
* - OpenAI Responses (…/openai/v1/responses)
|
|
9
|
+
*
|
|
10
|
+
* This module decides, per model id, which upstream protocol to speak and
|
|
11
|
+
* which endpoint to use, and exposes the per-family capability tables the
|
|
12
|
+
* converters validate against. Pure functions (plus the session-id minting
|
|
13
|
+
* helper, which uses the system RNG); no network or filesystem I/O.
|
|
14
|
+
*
|
|
15
|
+
* Sources: opencode.ai Go docs endpoint table; zen gap-fill families;
|
|
16
|
+
* family fallbacks mirror the reference proxy's protocols.py classification.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.ZEN_ONLY = exports.EXACT_PROTOCOLS = exports.PROTOCOL_IDS = void 0;
|
|
20
|
+
exports.familyOf = familyOf;
|
|
21
|
+
exports.recognizeBase = recognizeBase;
|
|
22
|
+
exports.blockedReason = blockedReason;
|
|
23
|
+
exports.resolveBase = resolveBase;
|
|
24
|
+
exports.deriveZenBase = deriveZenBase;
|
|
25
|
+
exports.resolveProtocol = resolveProtocol;
|
|
26
|
+
exports.deriveEndpoints = deriveEndpoints;
|
|
27
|
+
exports.familyCaps = familyCaps;
|
|
28
|
+
exports.supportsToolChoice = supportsToolChoice;
|
|
29
|
+
exports.mapResponsesEffort = mapResponsesEffort;
|
|
30
|
+
exports.chatFamilyOf = chatFamilyOf;
|
|
31
|
+
exports.chatReasoningCaps = chatReasoningCaps;
|
|
32
|
+
exports.mapChatEffort = mapChatEffort;
|
|
33
|
+
exports.mapChatThinking = mapChatThinking;
|
|
34
|
+
exports.extractEffort = extractEffort;
|
|
35
|
+
exports.extractThinkingType = extractThinkingType;
|
|
36
|
+
exports.thinkingEnabled = thinkingEnabled;
|
|
37
|
+
exports.sanitizeSessionValue = sanitizeSessionValue;
|
|
38
|
+
exports.isOpencodeSessionId = isOpencodeSessionId;
|
|
39
|
+
exports.mintOpencodeSessionId = mintOpencodeSessionId;
|
|
40
|
+
const node_crypto_1 = require("node:crypto");
|
|
41
|
+
exports.PROTOCOL_IDS = ['anthropic', 'openai', 'responses'];
|
|
42
|
+
// ── Docs tables (OpenCode Go) ────────────────────────────────────────
|
|
43
|
+
// Exact model ids and the protocol their endpoint speaks. Go is the
|
|
44
|
+
// primary catalog; familia fallbacks below cover drift ids.
|
|
45
|
+
const GO_RESPONSES = [
|
|
46
|
+
'grok-4.7',
|
|
47
|
+
'grok-4.6',
|
|
48
|
+
'gpt-6-luna',
|
|
49
|
+
'gpt-5.6-luna',
|
|
50
|
+
'muse-spark-1.3-contributor',
|
|
51
|
+
'muse-spark-1.2-contributor',
|
|
52
|
+
];
|
|
53
|
+
const GO_ANTHROPIC = [
|
|
54
|
+
'claude-haiku-5-5',
|
|
55
|
+
'minimax-m3',
|
|
56
|
+
'qwen3.8-max',
|
|
57
|
+
'qwen3.8-flash',
|
|
58
|
+
'qwen3.7-max',
|
|
59
|
+
'qwen3.7-plus',
|
|
60
|
+
'qwen3.6-plus',
|
|
61
|
+
];
|
|
62
|
+
const GO_OPENAI = [
|
|
63
|
+
'glm-5.3-flash',
|
|
64
|
+
'glm-5.3',
|
|
65
|
+
'glm-5.2',
|
|
66
|
+
'glm-5.1',
|
|
67
|
+
'kimi-k3',
|
|
68
|
+
'kimi-k2.7-code',
|
|
69
|
+
'kimi-k2.6',
|
|
70
|
+
'longcat-2.0',
|
|
71
|
+
'deepseek-v4.1-flash',
|
|
72
|
+
'deepseek-v4-pro',
|
|
73
|
+
'mimo-v2.6-flash',
|
|
74
|
+
'mimo-v2.6-pro',
|
|
75
|
+
'mimo-v2.5',
|
|
76
|
+
'mimo-v2.5-pro',
|
|
77
|
+
'hy4-preview',
|
|
78
|
+
'hy3',
|
|
79
|
+
'space-bunny',
|
|
80
|
+
'longcat-2.5-preview-free',
|
|
81
|
+
'step-5-preview',
|
|
82
|
+
'beam-free',
|
|
83
|
+
'minimax-m2.5',
|
|
84
|
+
'minimax-m2.7',
|
|
85
|
+
];
|
|
86
|
+
/** Explicit docs entries. OpenAI is also the default, but listing keeps the
|
|
87
|
+
* table self-documenting and lets tests assert the docs surface exactly. */
|
|
88
|
+
exports.EXACT_PROTOCOLS = (() => {
|
|
89
|
+
const m = new Map();
|
|
90
|
+
for (const id of GO_OPENAI)
|
|
91
|
+
m.set(id, 'openai');
|
|
92
|
+
for (const id of GO_ANTHROPIC)
|
|
93
|
+
m.set(id, 'anthropic');
|
|
94
|
+
for (const id of GO_RESPONSES)
|
|
95
|
+
m.set(id, 'responses');
|
|
96
|
+
return m;
|
|
97
|
+
})();
|
|
98
|
+
// ── Console (Zen) surface ────────────────────────────────────────────
|
|
99
|
+
// Model ids that exist on the Console surface but not on Go. Used for
|
|
100
|
+
// base resolution (Go vs Zen gap-fill) only; protocol resolution for
|
|
101
|
+
// these still uses family fallback + the default, matching the reference.
|
|
102
|
+
// Source: live console model list (opencode.ai/inference/v1/models).
|
|
103
|
+
const ZEN_ONLY_IDS = [
|
|
104
|
+
'big-pickle',
|
|
105
|
+
'space-bunny-free',
|
|
106
|
+
'glm-5.3-flash-free',
|
|
107
|
+
'deepseek-v4.1-flash-free',
|
|
108
|
+
'nemotron-3.5-lightning-free',
|
|
109
|
+
'nemotron-3.5-super-vl-free',
|
|
110
|
+
'mimo-v2.6-flash-free',
|
|
111
|
+
'mistral-large-4',
|
|
112
|
+
'muse-spark-1.3',
|
|
113
|
+
'claude-opus-5-5-backup',
|
|
114
|
+
'gpt-6-astra',
|
|
115
|
+
'gpt-6.1-sol',
|
|
116
|
+
'gpt-5.6-terra',
|
|
117
|
+
'gpt-5.5',
|
|
118
|
+
'gpt-5.5-pro',
|
|
119
|
+
'gpt-5.4-mini',
|
|
120
|
+
'gpt-5.4-nano',
|
|
121
|
+
'gpt-5.3-codex',
|
|
122
|
+
'gpt-5.3-codex-spark',
|
|
123
|
+
'grok-build-0.1',
|
|
124
|
+
'gemini-3.1-pro',
|
|
125
|
+
'gemini-3.5-flash-lite',
|
|
126
|
+
'gemini-3.8-flash',
|
|
127
|
+
'gemini-4-argon',
|
|
128
|
+
'jev-1.13',
|
|
129
|
+
'jev-1.13-free',
|
|
130
|
+
'test',
|
|
131
|
+
];
|
|
132
|
+
exports.ZEN_ONLY = new Set(ZEN_ONLY_IDS.map((s) => s.toLowerCase()));
|
|
133
|
+
const FAMILY_FALLBACK = [
|
|
134
|
+
['gpt-', 'responses'],
|
|
135
|
+
['grok-', 'responses'],
|
|
136
|
+
['muse-spark-', 'responses'],
|
|
137
|
+
['claude-', 'anthropic'],
|
|
138
|
+
];
|
|
139
|
+
function familyOf(modelId) {
|
|
140
|
+
const low = (modelId || '').toLowerCase();
|
|
141
|
+
for (const [prefix] of FAMILY_FALLBACK) {
|
|
142
|
+
if (low.startsWith(prefix))
|
|
143
|
+
return prefix.replace(/-$/, '');
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
/** Classify an upstream base URL so routing can prefer the right protocol. */
|
|
148
|
+
function recognizeBase(baseUrl) {
|
|
149
|
+
const low = (baseUrl || '').toLowerCase();
|
|
150
|
+
if (/(^|\.)opencode\.ai\//.test(low) || low.includes('/zen/') || low.includes('/inference'))
|
|
151
|
+
return 'opencode';
|
|
152
|
+
if (low.includes('anthropic'))
|
|
153
|
+
return 'anthropic';
|
|
154
|
+
if (low.includes('openai'))
|
|
155
|
+
return 'openai';
|
|
156
|
+
return 'other';
|
|
157
|
+
}
|
|
158
|
+
// ── Blocked models ────────────────────────────────────────────────────
|
|
159
|
+
// Ids the bridge cannot speak (google SDK shape, systemone shape, or
|
|
160
|
+
// unclassified catalog ids). Returns a human-readable reason or null.
|
|
161
|
+
function blockedReason(modelId) {
|
|
162
|
+
const low = (modelId || '').toLowerCase().trim();
|
|
163
|
+
if (!low)
|
|
164
|
+
return null;
|
|
165
|
+
if (low.startsWith('gemini-'))
|
|
166
|
+
return 'google-sdk-only (proxy serves OpenAI/Anthropic protocols)';
|
|
167
|
+
if (low.startsWith('jev-'))
|
|
168
|
+
return 'systemone API (different request shape)';
|
|
169
|
+
if (low === 'omen-alpha')
|
|
170
|
+
return 'unclassified catalog id, not servable by this proxy';
|
|
171
|
+
if (low === 'test')
|
|
172
|
+
return 'non-model catalog entry';
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
function resolveBase(modelId) {
|
|
176
|
+
const low = (modelId || '').toLowerCase().trim();
|
|
177
|
+
if (exports.EXACT_PROTOCOLS.has(low))
|
|
178
|
+
return 'go';
|
|
179
|
+
if (exports.ZEN_ONLY.has(low))
|
|
180
|
+
return 'zen';
|
|
181
|
+
return 'go';
|
|
182
|
+
}
|
|
183
|
+
/** Derive the Console (Zen) base URL from a Go base URL, or null when
|
|
184
|
+
* no sensible counterpart exists. */
|
|
185
|
+
function deriveZenBase(goBaseUrl) {
|
|
186
|
+
const base = (goBaseUrl || '').replace(/\/+$/, '');
|
|
187
|
+
if (!base)
|
|
188
|
+
return null;
|
|
189
|
+
let m = base.match(/^(.*\/inference)\/go(\/v1)?$/i);
|
|
190
|
+
if (m)
|
|
191
|
+
return `${m[1]}${m[2] ?? ''}`;
|
|
192
|
+
m = base.match(/^(.*\/zen)\/go(\/v1)?$/i);
|
|
193
|
+
if (m)
|
|
194
|
+
return `${m[1]}${m[2] ?? ''}`;
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Decide the upstream protocol for a model id.
|
|
199
|
+
*
|
|
200
|
+
* Precedence:
|
|
201
|
+
* 1. explicit `protocol` (config force)
|
|
202
|
+
* 2. explicit `protocolMap[model]`
|
|
203
|
+
* 3. docs table exact match (opencode ids)
|
|
204
|
+
* 4. family fallback when the base is an OpenCode base (drift ids)
|
|
205
|
+
* 5. anthropic host → anthropic when the id looks anthropic-native
|
|
206
|
+
* 6. openai (chat/completions) — the compatible default
|
|
207
|
+
*/
|
|
208
|
+
function resolveProtocol(modelId, opts = {}) {
|
|
209
|
+
const low = (modelId || '').toLowerCase().trim();
|
|
210
|
+
if (opts.protocol)
|
|
211
|
+
return opts.protocol;
|
|
212
|
+
const mapped = opts.protocolMap?.[modelId] ?? opts.protocolMap?.[low];
|
|
213
|
+
if (mapped)
|
|
214
|
+
return mapped;
|
|
215
|
+
const exact = exports.EXACT_PROTOCOLS.get(low);
|
|
216
|
+
if (exact)
|
|
217
|
+
return exact;
|
|
218
|
+
const kind = recognizeBase(opts.baseUrl ?? '');
|
|
219
|
+
if (kind === 'opencode') {
|
|
220
|
+
for (const [prefix, protocol] of FAMILY_FALLBACK) {
|
|
221
|
+
if (low.startsWith(prefix))
|
|
222
|
+
return protocol;
|
|
223
|
+
}
|
|
224
|
+
return 'openai';
|
|
225
|
+
}
|
|
226
|
+
if (kind === 'anthropic')
|
|
227
|
+
return 'anthropic';
|
|
228
|
+
// Generic OpenAI-compatible upstream (LM Studio, vLLM, gateways…):
|
|
229
|
+
// chat/completions is the safe default.
|
|
230
|
+
return 'openai';
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Derive the three protocol endpoints from one base URL.
|
|
234
|
+
*
|
|
235
|
+
* Recognized shapes:
|
|
236
|
+
* - `https://opencode.ai/inference/go` → /anthropic/v1/messages, /openai/v1/…
|
|
237
|
+
* - `https://opencode.ai/zen/go` → same as above
|
|
238
|
+
* - `https://opencode.ai/zen/go/v1` → /messages, /chat/completions, /responses
|
|
239
|
+
* - `http://host/v1` → /messages, /chat/completions, /responses
|
|
240
|
+
* - `https://api.example.com` → /v1/messages, /v1/chat/completions, …
|
|
241
|
+
*/
|
|
242
|
+
function deriveEndpoints(baseUrl) {
|
|
243
|
+
const base = (baseUrl || '').replace(/\/+$/, '');
|
|
244
|
+
if (!base) {
|
|
245
|
+
throw new Error('upstreamBaseUrl must be a non-empty URL');
|
|
246
|
+
}
|
|
247
|
+
// OpenCode inference family (Go + Console): docs shape {base}/{protocol}/v1/...
|
|
248
|
+
if (/\/(inference)(\/go)?$/i.test(base)) {
|
|
249
|
+
return {
|
|
250
|
+
anthropic: `${base}/anthropic/v1/messages`,
|
|
251
|
+
openai: `${base}/openai/v1/chat/completions`,
|
|
252
|
+
responses: `${base}/openai/v1/responses`,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// OpenCode zen family: conventional {base}/v1/...
|
|
256
|
+
if (/\/(zen)(\/go)?$/i.test(base)) {
|
|
257
|
+
const v1 = /\/v1$/i.test(base) ? base : `${base}/v1`;
|
|
258
|
+
return {
|
|
259
|
+
anthropic: `${v1}/messages`,
|
|
260
|
+
openai: `${v1}/chat/completions`,
|
|
261
|
+
responses: `${v1}/responses`,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (/\/v1$/i.test(base)) {
|
|
265
|
+
return {
|
|
266
|
+
anthropic: `${base}/messages`,
|
|
267
|
+
openai: `${base}/chat/completions`,
|
|
268
|
+
responses: `${base}/responses`,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
anthropic: `${base}/v1/messages`,
|
|
273
|
+
openai: `${base}/v1/chat/completions`,
|
|
274
|
+
responses: `${base}/v1/responses`,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
const FAMILY_CAPS = {
|
|
278
|
+
'muse-spark': {
|
|
279
|
+
toolChoice: new Set(['auto']),
|
|
280
|
+
reasoningEffort: new Set(['minimal', 'low', 'medium', 'high', 'xhigh']),
|
|
281
|
+
},
|
|
282
|
+
gpt: {
|
|
283
|
+
toolChoice: new Set(['auto', 'named']),
|
|
284
|
+
reasoningEffort: new Set(['minimal', 'low', 'medium', 'high', 'xhigh', 'max']),
|
|
285
|
+
},
|
|
286
|
+
grok: {
|
|
287
|
+
toolChoice: new Set(['auto', 'named']),
|
|
288
|
+
reasoningEffort: new Set(['minimal', 'low', 'medium', 'high', 'xhigh', 'max']),
|
|
289
|
+
},
|
|
290
|
+
claude: {
|
|
291
|
+
toolChoice: new Set(),
|
|
292
|
+
reasoningEffort: new Set(),
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Capabilities for a family nobody verified. Only `auto` is safe to forward:
|
|
297
|
+
* if the upstream rejects `tool_choice`, the failure would surface as an
|
|
298
|
+
* opaque 400 after the request is billed, while `auto` is accepted by every
|
|
299
|
+
* family seen so far. A new family that does take named choices gets a row in
|
|
300
|
+
* FAMILY_CAPS rather than an assumption here.
|
|
301
|
+
*/
|
|
302
|
+
const DEFAULT_CAPS = {
|
|
303
|
+
toolChoice: new Set(['auto']),
|
|
304
|
+
reasoningEffort: new Set(['low']),
|
|
305
|
+
};
|
|
306
|
+
const RESPONSES_NO_MINIMAL = new Set(['gpt-6.1-sol']);
|
|
307
|
+
const RESPONSES_NO_MAX = new Set(['muse-spark-1.3-contributor', 'muse-spark-1.3-contributor-free']);
|
|
308
|
+
function familyCaps(modelId) {
|
|
309
|
+
const fam = familyOf(modelId);
|
|
310
|
+
return (fam && FAMILY_CAPS[fam]) || DEFAULT_CAPS;
|
|
311
|
+
}
|
|
312
|
+
function supportsToolChoice(modelId, choice) {
|
|
313
|
+
const caps = familyCaps(modelId);
|
|
314
|
+
if (choice && typeof choice === 'object') {
|
|
315
|
+
const t = choice.type;
|
|
316
|
+
if (t === 'tool' || t === 'function')
|
|
317
|
+
return caps.toolChoice.has('named');
|
|
318
|
+
if (t === 'auto')
|
|
319
|
+
return caps.toolChoice.has('auto');
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if (choice === 'auto')
|
|
323
|
+
return caps.toolChoice.has('auto');
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Map a client effort to the Responses wire value.
|
|
328
|
+
* Verbatim where the family accepts it; contributor max→xhigh (explicit
|
|
329
|
+
* rewrite, callers may record source); throws loudly otherwise.
|
|
330
|
+
*/
|
|
331
|
+
function mapResponsesEffort(modelId, effort) {
|
|
332
|
+
if (effort === null || effort === undefined || effort === '' || effort === 'none')
|
|
333
|
+
return null;
|
|
334
|
+
const e = String(effort);
|
|
335
|
+
const low = (modelId || '').toLowerCase();
|
|
336
|
+
if (e === 'max' && RESPONSES_NO_MAX.has(low))
|
|
337
|
+
return 'xhigh';
|
|
338
|
+
const caps = familyCaps(modelId).reasoningEffort;
|
|
339
|
+
if (RESPONSES_NO_MINIMAL.has(low) && e === 'minimal') {
|
|
340
|
+
throw new Error(`model ${modelId} does not accept reasoning effort ${JSON.stringify(effort)} ` +
|
|
341
|
+
`(valid: ${JSON.stringify([...caps].filter((x) => x !== 'minimal').sort())})`);
|
|
342
|
+
}
|
|
343
|
+
if (caps.has(e))
|
|
344
|
+
return e;
|
|
345
|
+
throw new Error(`model ${modelId} does not accept reasoning effort ${JSON.stringify(effort)} ` +
|
|
346
|
+
`(valid: ${JSON.stringify([...caps].sort()) || 'none — reasoning n/a'})`);
|
|
347
|
+
}
|
|
348
|
+
const CHAT_REASONING_CAPS = {
|
|
349
|
+
deepseek: {
|
|
350
|
+
thinking: new Set(['enabled', 'disabled']),
|
|
351
|
+
reasoningEffort: new Set(['low', 'high', 'max']),
|
|
352
|
+
canDisable: true,
|
|
353
|
+
},
|
|
354
|
+
glm: {
|
|
355
|
+
thinking: new Set(['enabled']),
|
|
356
|
+
reasoningEffort: new Set(['low', 'high', 'max']),
|
|
357
|
+
canDisable: false,
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
const CHAT_FAMILY_PREFIXES = [
|
|
361
|
+
['deepseek-', 'deepseek'],
|
|
362
|
+
['glm-', 'glm'],
|
|
363
|
+
];
|
|
364
|
+
function chatFamilyOf(modelId) {
|
|
365
|
+
const low = (modelId || '').toLowerCase();
|
|
366
|
+
for (const [prefix, fam] of CHAT_FAMILY_PREFIXES) {
|
|
367
|
+
if (low.startsWith(prefix))
|
|
368
|
+
return fam;
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
function chatReasoningCaps(modelId) {
|
|
373
|
+
const fam = chatFamilyOf(modelId);
|
|
374
|
+
if (!fam) {
|
|
375
|
+
return { thinking: new Set(), reasoningEffort: new Set(), canDisable: false };
|
|
376
|
+
}
|
|
377
|
+
return CHAT_REASONING_CAPS[fam];
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Map a client effort to a chat wire value (demotion-only).
|
|
381
|
+
* Returns the wire string or null when the field must be omitted.
|
|
382
|
+
* Throws for values that have no valid mapping.
|
|
383
|
+
*/
|
|
384
|
+
function mapChatEffort(modelId, effort) {
|
|
385
|
+
if (effort === null || effort === undefined || effort === '' || effort === 'none')
|
|
386
|
+
return null;
|
|
387
|
+
// Extras are family-gated: non-family chat models never receive the
|
|
388
|
+
// field (silent drop, mirroring the reference's WARN-only handling).
|
|
389
|
+
if (!chatFamilyOf(modelId))
|
|
390
|
+
return null;
|
|
391
|
+
const e = String(effort);
|
|
392
|
+
const caps = chatReasoningCaps(modelId).reasoningEffort;
|
|
393
|
+
if (caps.has(e))
|
|
394
|
+
return e;
|
|
395
|
+
if (e === 'minimal') {
|
|
396
|
+
if (chatFamilyOf(modelId) === 'deepseek' && caps.has('low'))
|
|
397
|
+
return 'low';
|
|
398
|
+
throw new Error(`model ${modelId} does not accept reasoning effort ${JSON.stringify(effort)} ` +
|
|
399
|
+
`(valid: ${JSON.stringify([...caps].sort()) || 'none — reasoning n/a'})`);
|
|
400
|
+
}
|
|
401
|
+
if (e === 'medium' || e === 'xhigh') {
|
|
402
|
+
if (caps.has('high'))
|
|
403
|
+
return 'high';
|
|
404
|
+
throw new Error(`model ${modelId} does not accept reasoning effort ${JSON.stringify(effort)} ` +
|
|
405
|
+
`(valid: ${JSON.stringify([...caps].sort()) || 'none — reasoning n/a'})`);
|
|
406
|
+
}
|
|
407
|
+
throw new Error(`model ${modelId} does not accept reasoning effort ${JSON.stringify(effort)} ` +
|
|
408
|
+
`(valid: ${JSON.stringify([...caps].sort()) || 'none — reasoning n/a'})`);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Map a client thinking type to the chat wire toggle.
|
|
412
|
+
* Returns "enabled" | "disabled" | null (omit).
|
|
413
|
+
*/
|
|
414
|
+
function mapChatThinking(modelId, thinkingType) {
|
|
415
|
+
const fam = chatFamilyOf(modelId);
|
|
416
|
+
if (!fam)
|
|
417
|
+
return null;
|
|
418
|
+
const t = thinkingType === null || thinkingType === undefined ? 'none' : String(thinkingType);
|
|
419
|
+
if (fam === 'deepseek') {
|
|
420
|
+
if (t === 'enabled' || t === 'adaptive')
|
|
421
|
+
return 'enabled';
|
|
422
|
+
if (t === 'disabled')
|
|
423
|
+
return 'disabled';
|
|
424
|
+
if (t === 'none' || t === '')
|
|
425
|
+
return null;
|
|
426
|
+
return 'enabled';
|
|
427
|
+
}
|
|
428
|
+
// GLM: reasoning cannot be disabled; an explicit disable is a loud error.
|
|
429
|
+
if (t === 'disabled') {
|
|
430
|
+
throw new Error(`model ${modelId} cannot disable thinking (reasoning is always-on; omit instead)`);
|
|
431
|
+
}
|
|
432
|
+
return 'enabled';
|
|
433
|
+
}
|
|
434
|
+
// ── Request intent extraction (Claude/Anthropic body shapes) ─────────
|
|
435
|
+
/** Client effort from any of the accepted Anthropic-adjacent shapes. */
|
|
436
|
+
function extractEffort(body) {
|
|
437
|
+
const direct = body['effort'];
|
|
438
|
+
if (typeof direct === 'string' && direct)
|
|
439
|
+
return direct;
|
|
440
|
+
const oc = body['output_config'];
|
|
441
|
+
if (oc && typeof oc === 'object' && typeof oc['effort'] === 'string') {
|
|
442
|
+
return oc['effort'];
|
|
443
|
+
}
|
|
444
|
+
const th = body['thinking'];
|
|
445
|
+
if (th && typeof th === 'object' && typeof th['effort'] === 'string') {
|
|
446
|
+
return th['effort'];
|
|
447
|
+
}
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
function extractThinkingType(body) {
|
|
451
|
+
const th = body['thinking'];
|
|
452
|
+
if (th && typeof th === 'object' && typeof th['type'] === 'string') {
|
|
453
|
+
return th['type'];
|
|
454
|
+
}
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
function thinkingEnabled(body) {
|
|
458
|
+
const t = extractThinkingType(body);
|
|
459
|
+
return t === 'enabled' || t === 'adaptive';
|
|
460
|
+
}
|
|
461
|
+
// ── Session header handling ──────────────────────────────────────────
|
|
462
|
+
/**
|
|
463
|
+
* Sanitize a value for `x-opencode-session` (routing + prompt caching).
|
|
464
|
+
* Returns null when the value is empty or malformed (control bytes or
|
|
465
|
+
* overlong); callers then omit the header rather than send junk.
|
|
466
|
+
*/
|
|
467
|
+
function sanitizeSessionValue(value) {
|
|
468
|
+
const s = typeof value === 'string' ? value.trim() : '';
|
|
469
|
+
if (!s)
|
|
470
|
+
return null;
|
|
471
|
+
if (s.length > 200)
|
|
472
|
+
return null;
|
|
473
|
+
for (const ch of s) {
|
|
474
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
475
|
+
if (code < 32 || code === 127)
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
return s;
|
|
479
|
+
}
|
|
480
|
+
// ── OpenCode session ids ─────────────────────────────────────────────
|
|
481
|
+
/**
|
|
482
|
+
* The OpenCode 2.x client mints session ids as `ses_` + 12 lowercase hex
|
|
483
|
+
* (bit-inverted timestamp + counter, so ids sort descending) + 14 base62
|
|
484
|
+
* random chars (packages/schema/src/identifier.ts).
|
|
485
|
+
*
|
|
486
|
+
* The Console free tier rejects `x-opencode-session` values that are not in
|
|
487
|
+
* this shape (verified live: a freshly minted client-shaped id passes, while
|
|
488
|
+
* arbitrary `ses_`-prefixed ids get `403 FreeTierError`). The bridge mints
|
|
489
|
+
* client-shaped ids for its own sessions when talking to OpenCode hosts.
|
|
490
|
+
*/
|
|
491
|
+
const SESSION_ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
492
|
+
const OPENCODE_SESSION_RE = /^ses_[0-9a-f]{12}[0-9A-Za-z]{14}$/;
|
|
493
|
+
let lastSessionTimestamp = 0;
|
|
494
|
+
let sessionCounter = 0;
|
|
495
|
+
function isOpencodeSessionId(value) {
|
|
496
|
+
return OPENCODE_SESSION_RE.test(value);
|
|
497
|
+
}
|
|
498
|
+
/** Mint a client-shaped session id (`ses_` + descending time + random). */
|
|
499
|
+
function mintOpencodeSessionId(timestamp = Date.now()) {
|
|
500
|
+
if (timestamp !== lastSessionTimestamp) {
|
|
501
|
+
lastSessionTimestamp = timestamp;
|
|
502
|
+
sessionCounter = 0;
|
|
503
|
+
}
|
|
504
|
+
sessionCounter++;
|
|
505
|
+
const current = BigInt(timestamp) * 0x1000n + BigInt(sessionCounter);
|
|
506
|
+
const value = ~current;
|
|
507
|
+
const time = Array.from({ length: 6 }, (_, index) => Number((value >> BigInt(40 - 8 * index)) & 0xffn)
|
|
508
|
+
.toString(16)
|
|
509
|
+
.padStart(2, '0')).join('');
|
|
510
|
+
const bytes = (0, node_crypto_1.randomBytes)(14);
|
|
511
|
+
const random = Array.from(bytes, (byte) => SESSION_ALPHABET[byte % 62]).join('');
|
|
512
|
+
return `ses_${time}${random}`;
|
|
513
|
+
}
|
|
514
|
+
//# sourceMappingURL=protocol-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-router.js","sourceRoot":"","sources":["../../../runtimes/claude/protocol-router.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AA6GH,4BAMC;AAKD,sCAMC;AAKD,sCAQC;AAKD,kCAKC;AAID,sCAQC;AAsBD,0CAkBC;AAoBD,0CAkCC;AA2CD,gCAGC;AAED,gDAUC;AAOD,gDAiBC;AA8BD,oCAMC;AAED,8CAMC;AAOD,sCA0BC;AAMD,0CAeC;AAKD,sCAYC;AAED,kDAMC;AAED,0CAGC;AASD,oDASC;AAoBD,kDAEC;AAGD,sDAgBC;AA1gBD,6CAA0C;AAI7B,QAAA,YAAY,GAA0B,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAExF,wEAAwE;AACxE,oEAAoE;AACpE,4DAA4D;AAC5D,MAAM,YAAY,GAAG;IACnB,UAAU;IACV,UAAU;IACV,YAAY;IACZ,cAAc;IACd,4BAA4B;IAC5B,4BAA4B;CACpB,CAAC;AAEX,MAAM,YAAY,GAAG;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