omnigateway 0.4.12 → 0.5.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/README.md +138 -239
- package/bin/omni.js +1111 -516
- package/gateway.js +2009 -474
- package/package.json +1 -1
- package/public/assets/{CopyValue-By5BAgv7.js → CopyValue-dQWAaTxf.js} +3 -3
- package/public/assets/{Field-B79Yxdit.js → Field-DTQ2LPzA.js} +1 -1
- package/public/assets/{Match-BWa6L0L1.js → Match-C85GObiU.js} +1 -1
- package/public/assets/{Panel-CoulMx6R.js → Panel-CQVz9yeR.js} +2 -2
- package/public/assets/Rack-V32CHmN6.js +316 -0
- package/public/assets/{Readout-D1XEfywe.js → Readout-DJR1qKja.js} +1 -1
- package/public/assets/States-CauIsA0N.js +54 -0
- package/public/assets/{Toggle-ClEeOh0F.js → Toggle-BQI8jz09.js} +1 -1
- package/public/assets/{TokenBreakdown-D70VeZ2N.js → TokenBreakdown-B2_gfuqt.js} +1 -1
- package/public/assets/_app-DzzXdoyU.js +1 -0
- package/public/assets/_app.accounts-owsnxlbn.js +64 -0
- package/public/assets/_app.console-bzKNP_8Y.js +44 -0
- package/public/assets/_app.database-CsJbkedE.js +24 -0
- package/public/assets/_app.index-D4ydl2mY.js +62 -0
- package/public/assets/_app.keys-DKX0smty.js +82 -0
- package/public/assets/_app.logs-CFFsj2zR.js +68 -0
- package/public/assets/_app.models-B0ZxWGHV.js +148 -0
- package/public/assets/{_app.plugins._pluginId-B-ZDQNPU.js → _app.plugins._pluginId-C5X4B1cE.js} +3 -3
- package/public/assets/{_app.settings-DTnFwTeA.js → _app.settings-Yg_6az-L.js} +4 -4
- package/public/assets/_app.usage-BRIz_GCn.js +83 -0
- package/public/assets/index-DiCU8bLB.js +178 -0
- package/public/assets/{login-DjfMomJJ.js → login-B4LoiALI.js} +3 -3
- package/public/assets/plus-xu9reaJp.js +1 -0
- package/public/assets/queries-DuSqKybM.js +145 -0
- package/public/assets/{shared-Cct_4xwp.js → shared-DYkFSPbd.js} +4 -4
- package/public/assets/stream-Dz5HjHBh.js +1 -0
- package/public/assets/{trash-2-U2ViYZum.js → trash-2-DbutVvFY.js} +1 -1
- package/public/index.html +3 -3
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/assets/Rack-fDZClWZL.js +0 -314
- package/public/assets/States-DtkkMzEu.js +0 -54
- package/public/assets/_app-CDPKnQ72.js +0 -1
- package/public/assets/_app.accounts-Dz0ox4Br.js +0 -64
- package/public/assets/_app.console-hPUmmYjp.js +0 -44
- package/public/assets/_app.database-DGtP4NdG.js +0 -24
- package/public/assets/_app.index-COcCAmbH.js +0 -62
- package/public/assets/_app.keys-yTXTbKTA.js +0 -76
- package/public/assets/_app.logs-BhMvO_Fx.js +0 -68
- package/public/assets/_app.models-0S3rurIl.js +0 -148
- package/public/assets/_app.usage-C2-VLiq9.js +0 -83
- package/public/assets/index-COwhxKU7.js +0 -178
- package/public/assets/plus-UDQ_BTEr.js +0 -1
- package/public/assets/queries-CX9mStps.js +0 -145
package/bin/omni.js
CHANGED
|
@@ -405,7 +405,6 @@ function loadConfig(env) {
|
|
|
405
405
|
const baseUrl = optionalText(env.OMNI_BASE_URL, derivedBaseUrl).replace(/\/+$/, "") || derivedBaseUrl;
|
|
406
406
|
const staticDir = env.OMNI_STATIC_DIR?.trim();
|
|
407
407
|
const logFile = env.OMNI_LOG_FILE?.trim();
|
|
408
|
-
const exposeClaudeCodeAliases = TRUTHY.has((env.OMNI_EXPOSE_CLAUDE_CODE_ALIASES ?? "").trim().toLowerCase());
|
|
409
408
|
const bodyLoggingAllowed = TRUTHY.has((env.OMNI_BODY_LOGGING_ALLOWED ?? "").trim().toLowerCase());
|
|
410
409
|
const rawLogLevel = env.OMNI_LOG_LEVEL?.trim();
|
|
411
410
|
const logLevel = parseLogLevel(rawLogLevel);
|
|
@@ -418,7 +417,6 @@ function loadConfig(env) {
|
|
|
418
417
|
encryptionKey,
|
|
419
418
|
baseUrl,
|
|
420
419
|
staticDir: staticDir === undefined || staticDir.length === 0 ? null : staticDir,
|
|
421
|
-
exposeClaudeCodeAliases,
|
|
422
420
|
bodyLoggingAllowed,
|
|
423
421
|
logFile: logFile === undefined || logFile.length === 0 ? null : logFile
|
|
424
422
|
};
|
|
@@ -2140,13 +2138,31 @@ var anthropicAdapter = {
|
|
|
2140
2138
|
};
|
|
2141
2139
|
}
|
|
2142
2140
|
};
|
|
2143
|
-
// packages/providers/src/
|
|
2144
|
-
var
|
|
2141
|
+
// packages/providers/src/custom/decode.ts
|
|
2142
|
+
var CHAT_FINISH = {
|
|
2145
2143
|
stop: "endTurn",
|
|
2146
2144
|
length: "maxTokens",
|
|
2147
2145
|
tool_calls: "toolUse",
|
|
2148
2146
|
content_filter: "contentFilter"
|
|
2149
2147
|
};
|
|
2148
|
+
function reasoningText(delta) {
|
|
2149
|
+
if (typeof delta.reasoning === "string" && delta.reasoning.length > 0)
|
|
2150
|
+
return delta.reasoning;
|
|
2151
|
+
if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
|
|
2152
|
+
return delta.reasoning_content;
|
|
2153
|
+
}
|
|
2154
|
+
if (!Array.isArray(delta.reasoning_details))
|
|
2155
|
+
return "";
|
|
2156
|
+
return delta.reasoning_details.flatMap((entry) => {
|
|
2157
|
+
if (entry === null || typeof entry !== "object")
|
|
2158
|
+
return [];
|
|
2159
|
+
if (typeof entry.text === "string" && entry.text.length > 0)
|
|
2160
|
+
return [entry.text];
|
|
2161
|
+
if (typeof entry.summary === "string" && entry.summary.length > 0)
|
|
2162
|
+
return [entry.summary];
|
|
2163
|
+
return [];
|
|
2164
|
+
}).join("");
|
|
2165
|
+
}
|
|
2150
2166
|
function json2(data) {
|
|
2151
2167
|
try {
|
|
2152
2168
|
const v = JSON.parse(data);
|
|
@@ -2155,7 +2171,7 @@ function json2(data) {
|
|
|
2155
2171
|
return null;
|
|
2156
2172
|
}
|
|
2157
2173
|
}
|
|
2158
|
-
async function*
|
|
2174
|
+
async function* decodeCustomChat(messages) {
|
|
2159
2175
|
let started = false;
|
|
2160
2176
|
let done = false;
|
|
2161
2177
|
let stopReason = "endTurn";
|
|
@@ -2184,6 +2200,21 @@ async function* decodeChat(messages) {
|
|
|
2184
2200
|
if (!choice)
|
|
2185
2201
|
continue;
|
|
2186
2202
|
const delta = choice.delta ?? {};
|
|
2203
|
+
const reasoning = reasoningText(delta);
|
|
2204
|
+
if (reasoning.length > 0) {
|
|
2205
|
+
if (openKind !== "thinking") {
|
|
2206
|
+
if (openKind !== undefined)
|
|
2207
|
+
yield { type: "blockEnd", index: openIndex };
|
|
2208
|
+
openKind = "thinking";
|
|
2209
|
+
openIndex = nextIndex++;
|
|
2210
|
+
yield { type: "blockStart", index: openIndex, block: { type: "thinking" } };
|
|
2211
|
+
}
|
|
2212
|
+
yield {
|
|
2213
|
+
type: "blockDelta",
|
|
2214
|
+
index: openIndex,
|
|
2215
|
+
delta: { type: "thinking", text: reasoning }
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2187
2218
|
if (typeof delta.content === "string" && delta.content.length > 0) {
|
|
2188
2219
|
if (openKind !== "text") {
|
|
2189
2220
|
if (openKind !== undefined)
|
|
@@ -2224,7 +2255,7 @@ async function* decodeChat(messages) {
|
|
|
2224
2255
|
}
|
|
2225
2256
|
}
|
|
2226
2257
|
if (typeof choice.finish_reason === "string") {
|
|
2227
|
-
stopReason =
|
|
2258
|
+
stopReason = CHAT_FINISH[choice.finish_reason] ?? "endTurn";
|
|
2228
2259
|
}
|
|
2229
2260
|
}
|
|
2230
2261
|
if (done) {
|
|
@@ -2240,110 +2271,7 @@ async function* decodeChat(messages) {
|
|
|
2240
2271
|
};
|
|
2241
2272
|
}
|
|
2242
2273
|
}
|
|
2243
|
-
|
|
2244
|
-
// packages/providers/src/kimi/wire.ts
|
|
2245
|
-
function encodeToolChoice2(c) {
|
|
2246
|
-
switch (c.type) {
|
|
2247
|
-
case "auto":
|
|
2248
|
-
return "auto";
|
|
2249
|
-
case "any":
|
|
2250
|
-
return "required";
|
|
2251
|
-
case "none":
|
|
2252
|
-
return "none";
|
|
2253
|
-
case "tool":
|
|
2254
|
-
return { type: "function", function: { name: c.name } };
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
function toChatWire(req, model, vendor = "kimi") {
|
|
2258
|
-
const degradations = [];
|
|
2259
|
-
const note2 = (d) => {
|
|
2260
|
-
if (!degradations.includes(d))
|
|
2261
|
-
degradations.push(d);
|
|
2262
|
-
};
|
|
2263
|
-
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
2264
|
-
note2("kimi:context-1m-dropped");
|
|
2265
|
-
const messages = [];
|
|
2266
|
-
const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
|
|
2267
|
-
|
|
2268
|
-
`);
|
|
2269
|
-
if (system !== undefined && system.length > 0)
|
|
2270
|
-
messages.push({ role: "system", content: system });
|
|
2271
|
-
for (const message of req.messages) {
|
|
2272
|
-
const text = [];
|
|
2273
|
-
const toolCalls = [];
|
|
2274
|
-
for (const block of message.content) {
|
|
2275
|
-
switch (block.type) {
|
|
2276
|
-
case "text":
|
|
2277
|
-
text.push(block.text);
|
|
2278
|
-
break;
|
|
2279
|
-
case "image":
|
|
2280
|
-
note2("kimi:images-dropped");
|
|
2281
|
-
break;
|
|
2282
|
-
case "thinking":
|
|
2283
|
-
note2("kimi:thinking-dropped");
|
|
2284
|
-
break;
|
|
2285
|
-
case "toolUse":
|
|
2286
|
-
toolCalls.push({
|
|
2287
|
-
id: block.id,
|
|
2288
|
-
type: "function",
|
|
2289
|
-
function: { name: block.name, arguments: JSON.stringify(block.input) }
|
|
2290
|
-
});
|
|
2291
|
-
break;
|
|
2292
|
-
case "toolResult":
|
|
2293
|
-
messages.push({
|
|
2294
|
-
role: "tool",
|
|
2295
|
-
tool_call_id: block.toolUseId,
|
|
2296
|
-
content: block.content
|
|
2297
|
-
});
|
|
2298
|
-
break;
|
|
2299
|
-
case "anthropicNative":
|
|
2300
|
-
note2("kimi:anthropic-native-block-dropped");
|
|
2301
|
-
break;
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
if (toolCalls.length > 0) {
|
|
2305
|
-
messages.push({
|
|
2306
|
-
role: message.role,
|
|
2307
|
-
content: text.length > 0 ? text.join(`
|
|
2308
|
-
`) : null,
|
|
2309
|
-
tool_calls: toolCalls
|
|
2310
|
-
});
|
|
2311
|
-
} else if (text.length > 0) {
|
|
2312
|
-
messages.push({ role: message.role, content: text.join(`
|
|
2313
|
-
`) });
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
const body = {
|
|
2317
|
-
model,
|
|
2318
|
-
messages,
|
|
2319
|
-
stream: req.stream,
|
|
2320
|
-
stream_options: { include_usage: true }
|
|
2321
|
-
};
|
|
2322
|
-
if (req.maxTokens !== undefined)
|
|
2323
|
-
body.max_tokens = req.maxTokens;
|
|
2324
|
-
if (req.temperature !== undefined)
|
|
2325
|
-
body.temperature = req.temperature;
|
|
2326
|
-
if (req.stopSequences !== undefined)
|
|
2327
|
-
body.stop = req.stopSequences;
|
|
2328
|
-
if (req.tools !== undefined) {
|
|
2329
|
-
const custom = req.tools.filter((t) => t.provider === "custom");
|
|
2330
|
-
if (custom.length !== req.tools.length)
|
|
2331
|
-
note2("kimi:anthropic-tool-dropped");
|
|
2332
|
-
body.tools = custom.map((t) => ({
|
|
2333
|
-
type: "function",
|
|
2334
|
-
function: { name: t.name, description: t.description, parameters: t.inputSchema }
|
|
2335
|
-
}));
|
|
2336
|
-
}
|
|
2337
|
-
if (req.toolChoice !== undefined)
|
|
2338
|
-
body.tool_choice = encodeToolChoice2(req.toolChoice);
|
|
2339
|
-
if (req.reasoning !== undefined)
|
|
2340
|
-
note2("kimi:reasoning-dropped");
|
|
2341
|
-
Object.assign(body, req.vendor?.[vendor] ?? {});
|
|
2342
|
-
return { body, degradations };
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
// packages/providers/src/openai/decode.ts
|
|
2346
|
-
var ERROR_CODE = {
|
|
2274
|
+
var RESPONSES_ERROR_CODE = {
|
|
2347
2275
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
2348
2276
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
2349
2277
|
invalid_api_key: "AUTH",
|
|
@@ -2351,15 +2279,7 @@ var ERROR_CODE = {
|
|
|
2351
2279
|
context_length_exceeded: "BAD_REQUEST",
|
|
2352
2280
|
content_policy_violation: "CONTENT_FILTER"
|
|
2353
2281
|
};
|
|
2354
|
-
function
|
|
2355
|
-
try {
|
|
2356
|
-
const v = JSON.parse(data);
|
|
2357
|
-
return typeof v === "object" && v !== null ? v : null;
|
|
2358
|
-
} catch {
|
|
2359
|
-
return null;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
async function* decodeResponses(messages) {
|
|
2282
|
+
async function* decodeCustomResponses(messages) {
|
|
2363
2283
|
const indices = new Map;
|
|
2364
2284
|
let next = 0;
|
|
2365
2285
|
const irIndex = (outputIndex, contentIndex = 0) => {
|
|
@@ -2375,7 +2295,7 @@ async function* decodeResponses(messages) {
|
|
|
2375
2295
|
let terminal = false;
|
|
2376
2296
|
const ownsBlock = new Set;
|
|
2377
2297
|
for await (const msg of messages) {
|
|
2378
|
-
const d =
|
|
2298
|
+
const d = json2(msg.data);
|
|
2379
2299
|
if (d === null)
|
|
2380
2300
|
continue;
|
|
2381
2301
|
switch (msg.event) {
|
|
@@ -2467,7 +2387,7 @@ async function* decodeResponses(messages) {
|
|
|
2467
2387
|
case "error": {
|
|
2468
2388
|
terminal = true;
|
|
2469
2389
|
const err = d.response?.error ?? d.error ?? {};
|
|
2470
|
-
const code =
|
|
2390
|
+
const code = RESPONSES_ERROR_CODE[String(err.code ?? err.type)] ?? "UPSTREAM";
|
|
2471
2391
|
yield {
|
|
2472
2392
|
type: "error",
|
|
2473
2393
|
code,
|
|
@@ -2490,8 +2410,20 @@ async function* decodeResponses(messages) {
|
|
|
2490
2410
|
}
|
|
2491
2411
|
}
|
|
2492
2412
|
|
|
2493
|
-
// packages/providers/src/
|
|
2494
|
-
function
|
|
2413
|
+
// packages/providers/src/custom/wire.ts
|
|
2414
|
+
function encodeChatToolChoice(c) {
|
|
2415
|
+
switch (c.type) {
|
|
2416
|
+
case "auto":
|
|
2417
|
+
return "auto";
|
|
2418
|
+
case "any":
|
|
2419
|
+
return "required";
|
|
2420
|
+
case "none":
|
|
2421
|
+
return "none";
|
|
2422
|
+
case "tool":
|
|
2423
|
+
return { type: "function", function: { name: c.name } };
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
function encodeResponsesToolChoice(c) {
|
|
2495
2427
|
switch (c.type) {
|
|
2496
2428
|
case "auto":
|
|
2497
2429
|
return "auto";
|
|
@@ -2503,20 +2435,115 @@ function encodeToolChoice3(c) {
|
|
|
2503
2435
|
return { type: "function", name: c.name };
|
|
2504
2436
|
}
|
|
2505
2437
|
}
|
|
2506
|
-
function
|
|
2438
|
+
function customEffort(reasoning) {
|
|
2439
|
+
if (reasoning === undefined || reasoning.mode !== "adaptive")
|
|
2440
|
+
return;
|
|
2441
|
+
return reasoning.effort ?? "medium";
|
|
2442
|
+
}
|
|
2443
|
+
function toCustomChatWire(req, model) {
|
|
2507
2444
|
const degradations = [];
|
|
2508
|
-
const input = [];
|
|
2509
2445
|
const note2 = (d) => {
|
|
2510
2446
|
if (!degradations.includes(d))
|
|
2511
2447
|
degradations.push(d);
|
|
2512
2448
|
};
|
|
2513
2449
|
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
2514
|
-
note2("
|
|
2450
|
+
note2("custom:context-1m-dropped");
|
|
2451
|
+
const messages = [];
|
|
2452
|
+
const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
|
|
2453
|
+
|
|
2454
|
+
`);
|
|
2455
|
+
if (system !== undefined && system.length > 0)
|
|
2456
|
+
messages.push({ role: "system", content: system });
|
|
2457
|
+
for (const message of req.messages) {
|
|
2458
|
+
const text = [];
|
|
2459
|
+
const toolCalls = [];
|
|
2460
|
+
for (const block of message.content) {
|
|
2461
|
+
switch (block.type) {
|
|
2462
|
+
case "text":
|
|
2463
|
+
text.push(block.text);
|
|
2464
|
+
break;
|
|
2465
|
+
case "image":
|
|
2466
|
+
note2("custom:images-dropped");
|
|
2467
|
+
break;
|
|
2468
|
+
case "thinking":
|
|
2469
|
+
note2("custom:thinking-dropped");
|
|
2470
|
+
break;
|
|
2471
|
+
case "toolUse":
|
|
2472
|
+
toolCalls.push({
|
|
2473
|
+
id: block.id,
|
|
2474
|
+
type: "function",
|
|
2475
|
+
function: { name: block.name, arguments: JSON.stringify(block.input) }
|
|
2476
|
+
});
|
|
2477
|
+
break;
|
|
2478
|
+
case "toolResult":
|
|
2479
|
+
messages.push({
|
|
2480
|
+
role: "tool",
|
|
2481
|
+
tool_call_id: block.toolUseId,
|
|
2482
|
+
content: block.content
|
|
2483
|
+
});
|
|
2484
|
+
break;
|
|
2485
|
+
case "anthropicNative":
|
|
2486
|
+
note2("custom:anthropic-native-block-dropped");
|
|
2487
|
+
break;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
if (toolCalls.length > 0) {
|
|
2491
|
+
messages.push({
|
|
2492
|
+
role: message.role,
|
|
2493
|
+
content: text.length > 0 ? text.join(`
|
|
2494
|
+
`) : null,
|
|
2495
|
+
tool_calls: toolCalls
|
|
2496
|
+
});
|
|
2497
|
+
} else if (text.length > 0) {
|
|
2498
|
+
messages.push({ role: message.role, content: text.join(`
|
|
2499
|
+
`) });
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
const body = {
|
|
2503
|
+
model,
|
|
2504
|
+
messages,
|
|
2505
|
+
stream: req.stream,
|
|
2506
|
+
stream_options: { include_usage: true }
|
|
2507
|
+
};
|
|
2508
|
+
if (req.maxTokens !== undefined)
|
|
2509
|
+
body.max_tokens = req.maxTokens;
|
|
2510
|
+
if (req.temperature !== undefined)
|
|
2511
|
+
body.temperature = req.temperature;
|
|
2512
|
+
if (req.stopSequences !== undefined)
|
|
2513
|
+
body.stop = req.stopSequences;
|
|
2514
|
+
if (req.tools !== undefined) {
|
|
2515
|
+
const portable = req.tools.filter((t) => t.provider === "custom");
|
|
2516
|
+
if (portable.length !== req.tools.length)
|
|
2517
|
+
note2("custom:anthropic-tool-dropped");
|
|
2518
|
+
body.tools = portable.map((t) => ({
|
|
2519
|
+
type: "function",
|
|
2520
|
+
function: { name: t.name, description: t.description, parameters: t.inputSchema }
|
|
2521
|
+
}));
|
|
2522
|
+
}
|
|
2523
|
+
if (req.toolChoice !== undefined)
|
|
2524
|
+
body.tool_choice = encodeChatToolChoice(req.toolChoice);
|
|
2525
|
+
const effort = customEffort(req.reasoning);
|
|
2526
|
+
if (effort !== undefined)
|
|
2527
|
+
body.reasoning_effort = effort;
|
|
2528
|
+
else if (req.reasoning?.mode === "budget")
|
|
2529
|
+
note2("custom:reasoning-budget-dropped");
|
|
2530
|
+
Object.assign(body, req.vendor?.openai ?? {});
|
|
2531
|
+
return { body, degradations };
|
|
2532
|
+
}
|
|
2533
|
+
function toCustomResponsesWire(req, model) {
|
|
2534
|
+
const degradations = [];
|
|
2535
|
+
const note2 = (d) => {
|
|
2536
|
+
if (!degradations.includes(d))
|
|
2537
|
+
degradations.push(d);
|
|
2538
|
+
};
|
|
2539
|
+
const input = [];
|
|
2540
|
+
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
2541
|
+
note2("custom:context-1m-dropped");
|
|
2515
2542
|
for (const message of req.messages) {
|
|
2516
2543
|
const parts = [];
|
|
2517
2544
|
const inlined = message.role === "system";
|
|
2518
2545
|
if (inlined)
|
|
2519
|
-
note2("
|
|
2546
|
+
note2("custom:system-turn-inlined");
|
|
2520
2547
|
const role = inlined ? "user" : message.role;
|
|
2521
2548
|
const flush = () => {
|
|
2522
2549
|
if (parts.length === 0)
|
|
@@ -2541,9 +2568,7 @@ ${block.text}
|
|
|
2541
2568
|
});
|
|
2542
2569
|
break;
|
|
2543
2570
|
case "thinking":
|
|
2544
|
-
|
|
2545
|
-
note2("openai:thinking-dropped");
|
|
2546
|
-
}
|
|
2571
|
+
note2("custom:thinking-dropped");
|
|
2547
2572
|
break;
|
|
2548
2573
|
case "toolUse":
|
|
2549
2574
|
flush();
|
|
@@ -2563,7 +2588,7 @@ ${block.text}
|
|
|
2563
2588
|
});
|
|
2564
2589
|
break;
|
|
2565
2590
|
case "anthropicNative":
|
|
2566
|
-
note2("
|
|
2591
|
+
note2("custom:anthropic-native-block-dropped");
|
|
2567
2592
|
break;
|
|
2568
2593
|
}
|
|
2569
2594
|
}
|
|
@@ -2575,23 +2600,15 @@ ${block.text}
|
|
|
2575
2600
|
`);
|
|
2576
2601
|
if (instructions !== undefined && instructions.length > 0)
|
|
2577
2602
|
body.instructions = instructions;
|
|
2578
|
-
if (req.maxTokens !== undefined)
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
body.max_output_tokens = req.maxTokens;
|
|
2583
|
-
}
|
|
2584
|
-
if (req.temperature !== undefined) {
|
|
2585
|
-
if (opts.oauth)
|
|
2586
|
-
note2("openai:temperature-dropped");
|
|
2587
|
-
else
|
|
2588
|
-
body.temperature = req.temperature;
|
|
2589
|
-
}
|
|
2603
|
+
if (req.maxTokens !== undefined)
|
|
2604
|
+
body.max_output_tokens = req.maxTokens;
|
|
2605
|
+
if (req.temperature !== undefined)
|
|
2606
|
+
body.temperature = req.temperature;
|
|
2590
2607
|
if (req.tools !== undefined) {
|
|
2591
|
-
const
|
|
2592
|
-
if (
|
|
2593
|
-
note2("
|
|
2594
|
-
body.tools =
|
|
2608
|
+
const portable = req.tools.filter((t) => t.provider === "custom");
|
|
2609
|
+
if (portable.length !== req.tools.length)
|
|
2610
|
+
note2("custom:anthropic-tool-dropped");
|
|
2611
|
+
body.tools = portable.map((t) => ({
|
|
2595
2612
|
type: "function",
|
|
2596
2613
|
name: t.name,
|
|
2597
2614
|
description: t.description,
|
|
@@ -2599,20 +2616,12 @@ ${block.text}
|
|
|
2599
2616
|
}));
|
|
2600
2617
|
}
|
|
2601
2618
|
if (req.toolChoice !== undefined)
|
|
2602
|
-
body.tool_choice =
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
body.reasoning = {
|
|
2609
|
-
effort: effort === "xhigh" || effort === "max" ? "high" : effort,
|
|
2610
|
-
summary: "auto"
|
|
2611
|
-
};
|
|
2612
|
-
if (req.reasoning.mode === "budget") {
|
|
2613
|
-
degradations.push("openai:reasoning-budget-dropped");
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2619
|
+
body.tool_choice = encodeResponsesToolChoice(req.toolChoice);
|
|
2620
|
+
const effort = customEffort(req.reasoning);
|
|
2621
|
+
if (effort !== undefined)
|
|
2622
|
+
body.reasoning = { effort, summary: "auto" };
|
|
2623
|
+
else if (req.reasoning?.mode === "budget")
|
|
2624
|
+
note2("custom:reasoning-budget-dropped");
|
|
2616
2625
|
Object.assign(body, req.vendor?.openai ?? {});
|
|
2617
2626
|
return { body, degradations };
|
|
2618
2627
|
}
|
|
@@ -2623,7 +2632,13 @@ function metadata(data) {
|
|
|
2623
2632
|
if (typeof origin !== "string" || protocol !== "chat_completions" && protocol !== "responses") {
|
|
2624
2633
|
throw new GatewayError("BAD_REQUEST", "custom credential has invalid endpoint metadata");
|
|
2625
2634
|
}
|
|
2626
|
-
|
|
2635
|
+
const basePath = typeof data.basePath === "string" ? data.basePath : "";
|
|
2636
|
+
return { origin, basePath, protocol };
|
|
2637
|
+
}
|
|
2638
|
+
function endpointUrl(origin, basePath, protocol) {
|
|
2639
|
+
const suffix = protocol === "chat_completions" ? "chat/completions" : "responses";
|
|
2640
|
+
const base = `${origin}${basePath}`.replace(/\/+$/, "");
|
|
2641
|
+
return base.endsWith("/v1") ? `${base}/${suffix}` : `${base}/v1/${suffix}`;
|
|
2627
2642
|
}
|
|
2628
2643
|
var customAdapter = {
|
|
2629
2644
|
id: "custom",
|
|
@@ -2633,15 +2648,15 @@ var customAdapter = {
|
|
|
2633
2648
|
if (apiKey === null) {
|
|
2634
2649
|
throw new GatewayError("AUTH", "custom credential has no API key", { provider: "custom" });
|
|
2635
2650
|
}
|
|
2636
|
-
const { origin, protocol } = metadata(req.credentials.providerData);
|
|
2637
|
-
const encoded = protocol === "chat_completions" ?
|
|
2651
|
+
const { origin, basePath, protocol } = metadata(req.credentials.providerData);
|
|
2652
|
+
const encoded = protocol === "chat_completions" ? toCustomChatWire(req.request, req.model) : toCustomResponsesWire(req.request, req.model);
|
|
2638
2653
|
const headers = [
|
|
2639
2654
|
["Content-Type", "application/json"],
|
|
2640
2655
|
["Authorization", `Bearer ${apiKey}`]
|
|
2641
2656
|
];
|
|
2642
2657
|
const res = await req.http({
|
|
2643
2658
|
provider: "custom",
|
|
2644
|
-
url:
|
|
2659
|
+
url: endpointUrl(origin, basePath, protocol),
|
|
2645
2660
|
method: "POST",
|
|
2646
2661
|
headers,
|
|
2647
2662
|
body: JSON.stringify({ ...encoded.body, stream: true }),
|
|
@@ -2653,8 +2668,8 @@ var customAdapter = {
|
|
|
2653
2668
|
throw new GatewayError("UPSTREAM", "empty response body", { provider: "custom" });
|
|
2654
2669
|
}
|
|
2655
2670
|
return {
|
|
2656
|
-
events: protocol === "chat_completions" ?
|
|
2657
|
-
degradations: encoded.degradations
|
|
2671
|
+
events: protocol === "chat_completions" ? decodeCustomChat(parseSse(res.body)) : decodeCustomResponses(parseSse(res.body)),
|
|
2672
|
+
degradations: encoded.degradations
|
|
2658
2673
|
};
|
|
2659
2674
|
}
|
|
2660
2675
|
};
|
|
@@ -2673,7 +2688,7 @@ function grokDeviceHeaders(providerData) {
|
|
|
2673
2688
|
import { createHash as createHash2 } from "crypto";
|
|
2674
2689
|
|
|
2675
2690
|
// packages/providers/src/grok/decode.ts
|
|
2676
|
-
var
|
|
2691
|
+
var ERROR_CODE = {
|
|
2677
2692
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
2678
2693
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
2679
2694
|
invalid_api_key: "AUTH",
|
|
@@ -2707,7 +2722,7 @@ var KNOWN_EVENTS2 = new Set([
|
|
|
2707
2722
|
"response.failed",
|
|
2708
2723
|
"error"
|
|
2709
2724
|
]);
|
|
2710
|
-
function
|
|
2725
|
+
function json3(data) {
|
|
2711
2726
|
try {
|
|
2712
2727
|
const v = JSON.parse(data);
|
|
2713
2728
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -2742,7 +2757,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
2742
2757
|
};
|
|
2743
2758
|
return;
|
|
2744
2759
|
}
|
|
2745
|
-
const d =
|
|
2760
|
+
const d = json3(msg.data);
|
|
2746
2761
|
if (d === null)
|
|
2747
2762
|
continue;
|
|
2748
2763
|
switch (msg.event) {
|
|
@@ -2835,7 +2850,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
2835
2850
|
case "error": {
|
|
2836
2851
|
terminal = true;
|
|
2837
2852
|
const err = d.response?.error ?? d.error ?? {};
|
|
2838
|
-
const code =
|
|
2853
|
+
const code = ERROR_CODE[String(err.code ?? err.type)] ?? "UPSTREAM";
|
|
2839
2854
|
yield {
|
|
2840
2855
|
type: "error",
|
|
2841
2856
|
code,
|
|
@@ -2861,7 +2876,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
2861
2876
|
// packages/providers/src/grok/wire.ts
|
|
2862
2877
|
import { createHash } from "crypto";
|
|
2863
2878
|
var MAX_TOOLS = 200;
|
|
2864
|
-
function
|
|
2879
|
+
function encodeToolChoice2(c) {
|
|
2865
2880
|
switch (c.type) {
|
|
2866
2881
|
case "auto":
|
|
2867
2882
|
return "auto";
|
|
@@ -2972,12 +2987,14 @@ ${block.text}
|
|
|
2972
2987
|
}));
|
|
2973
2988
|
}
|
|
2974
2989
|
if (req.toolChoice !== undefined)
|
|
2975
|
-
body.tool_choice =
|
|
2990
|
+
body.tool_choice = encodeToolChoice2(req.toolChoice);
|
|
2976
2991
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
2977
|
-
|
|
2978
|
-
body.reasoning = { effort, summary: "concise" };
|
|
2979
|
-
if (req.reasoning.mode === "budget")
|
|
2992
|
+
if (req.reasoning.mode === "budget") {
|
|
2980
2993
|
note2("grok:reasoning-budget-dropped");
|
|
2994
|
+
} else {
|
|
2995
|
+
const effort = req.reasoning.effort ?? "medium";
|
|
2996
|
+
body.reasoning = { effort, summary: "concise" };
|
|
2997
|
+
}
|
|
2981
2998
|
}
|
|
2982
2999
|
Object.assign(body, req.vendor?.grok ?? {});
|
|
2983
3000
|
return { body, degradations };
|
|
@@ -3135,13 +3152,13 @@ function hasHeader(req, lowerName) {
|
|
|
3135
3152
|
return req.headers.some(([name]) => name.toLowerCase() === lowerName);
|
|
3136
3153
|
}
|
|
3137
3154
|
// packages/providers/src/kilo/decode.ts
|
|
3138
|
-
var
|
|
3155
|
+
var FINISH = {
|
|
3139
3156
|
stop: "endTurn",
|
|
3140
3157
|
length: "maxTokens",
|
|
3141
3158
|
tool_calls: "toolUse",
|
|
3142
3159
|
content_filter: "contentFilter"
|
|
3143
3160
|
};
|
|
3144
|
-
function
|
|
3161
|
+
function reasoningText2(delta) {
|
|
3145
3162
|
if (typeof delta.reasoning === "string" && delta.reasoning.length > 0)
|
|
3146
3163
|
return delta.reasoning;
|
|
3147
3164
|
if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
|
|
@@ -3159,7 +3176,7 @@ function reasoningText(delta) {
|
|
|
3159
3176
|
return [];
|
|
3160
3177
|
}).join("");
|
|
3161
3178
|
}
|
|
3162
|
-
function
|
|
3179
|
+
function json4(data) {
|
|
3163
3180
|
try {
|
|
3164
3181
|
const v = JSON.parse(data);
|
|
3165
3182
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -3181,7 +3198,7 @@ async function* decodeKiloChat(messages) {
|
|
|
3181
3198
|
done = true;
|
|
3182
3199
|
break;
|
|
3183
3200
|
}
|
|
3184
|
-
const d =
|
|
3201
|
+
const d = json4(msg.data);
|
|
3185
3202
|
if (d === null)
|
|
3186
3203
|
continue;
|
|
3187
3204
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -3196,7 +3213,7 @@ async function* decodeKiloChat(messages) {
|
|
|
3196
3213
|
if (!choice)
|
|
3197
3214
|
continue;
|
|
3198
3215
|
const delta = choice.delta ?? {};
|
|
3199
|
-
const reasoning =
|
|
3216
|
+
const reasoning = reasoningText2(delta);
|
|
3200
3217
|
if (reasoning.length > 0) {
|
|
3201
3218
|
if (openKind !== "thinking") {
|
|
3202
3219
|
if (openKind !== undefined)
|
|
@@ -3252,7 +3269,7 @@ async function* decodeKiloChat(messages) {
|
|
|
3252
3269
|
}
|
|
3253
3270
|
}
|
|
3254
3271
|
if (typeof choice.finish_reason === "string") {
|
|
3255
|
-
stopReason =
|
|
3272
|
+
stopReason = FINISH[choice.finish_reason] ?? "endTurn";
|
|
3256
3273
|
}
|
|
3257
3274
|
}
|
|
3258
3275
|
if (done) {
|
|
@@ -3270,7 +3287,7 @@ async function* decodeKiloChat(messages) {
|
|
|
3270
3287
|
}
|
|
3271
3288
|
|
|
3272
3289
|
// packages/providers/src/kilo/wire.ts
|
|
3273
|
-
function
|
|
3290
|
+
function encodeToolChoice3(c) {
|
|
3274
3291
|
switch (c.type) {
|
|
3275
3292
|
case "auto":
|
|
3276
3293
|
return "auto";
|
|
@@ -3376,125 +3393,594 @@ function toKiloWire(req, model) {
|
|
|
3376
3393
|
if (req.tools !== undefined) {
|
|
3377
3394
|
const custom = req.tools.filter((t) => t.provider === "custom");
|
|
3378
3395
|
if (custom.length !== req.tools.length)
|
|
3379
|
-
note2("kilo:anthropic-tool-dropped");
|
|
3396
|
+
note2("kilo:anthropic-tool-dropped");
|
|
3397
|
+
body.tools = custom.map((t) => ({
|
|
3398
|
+
type: "function",
|
|
3399
|
+
function: { name: t.name, description: t.description, parameters: t.inputSchema }
|
|
3400
|
+
}));
|
|
3401
|
+
}
|
|
3402
|
+
if (req.toolChoice !== undefined)
|
|
3403
|
+
body.tool_choice = encodeToolChoice3(req.toolChoice);
|
|
3404
|
+
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
3405
|
+
if (req.reasoning.mode === "budget") {
|
|
3406
|
+
body.reasoning = { max_tokens: req.reasoning.budgetTokens };
|
|
3407
|
+
} else {
|
|
3408
|
+
body.reasoning = { effort: req.reasoning.effort ?? "medium" };
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
Object.assign(body, req.vendor?.kilo ?? {});
|
|
3412
|
+
return { body, degradations };
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
// packages/providers/src/kilo/index.ts
|
|
3416
|
+
var OAUTH_URL = "https://api.kilo.ai/api/openrouter/chat/completions";
|
|
3417
|
+
var API_URL2 = "https://api.kilo.ai/api/gateway/chat/completions";
|
|
3418
|
+
function organizationHeaders(providerData) {
|
|
3419
|
+
const orgId = providerData.orgId;
|
|
3420
|
+
if (typeof orgId !== "string" || orgId.length === 0)
|
|
3421
|
+
return [];
|
|
3422
|
+
return [["X-Kilocode-OrganizationID", orgId]];
|
|
3423
|
+
}
|
|
3424
|
+
var kiloAdapter = {
|
|
3425
|
+
id: "kilo",
|
|
3426
|
+
capabilities: PROVIDER_CAPABILITIES.kilo,
|
|
3427
|
+
async send(req) {
|
|
3428
|
+
const oauth = req.credentials.accessToken !== null;
|
|
3429
|
+
const token = req.credentials.accessToken ?? req.credentials.apiKey;
|
|
3430
|
+
if (token === null) {
|
|
3431
|
+
throw new GatewayError("AUTH", "kilo credential has no token", { provider: "kilo" });
|
|
3432
|
+
}
|
|
3433
|
+
const { body, degradations } = toKiloWire(req.request, req.model);
|
|
3434
|
+
const protocol = [
|
|
3435
|
+
["Content-Type", "application/json"],
|
|
3436
|
+
["Authorization", `Bearer ${token}`],
|
|
3437
|
+
...organizationHeaders(req.credentials.providerData)
|
|
3438
|
+
];
|
|
3439
|
+
const profile = PROFILES.kilo;
|
|
3440
|
+
const headers = orderHeaders(mergeHeaders(profile.headers, protocol), profile.order);
|
|
3441
|
+
const res = await req.http({
|
|
3442
|
+
provider: "kilo",
|
|
3443
|
+
url: oauth ? OAUTH_URL : API_URL2,
|
|
3444
|
+
method: "POST",
|
|
3445
|
+
headers,
|
|
3446
|
+
body: JSON.stringify(orderFields({ ...body, stream: true }, BODY_ORDER.kilo)),
|
|
3447
|
+
signal: req.signal
|
|
3448
|
+
});
|
|
3449
|
+
if (res.status < 200 || res.status >= 300)
|
|
3450
|
+
throw await httpError(res, "kilo");
|
|
3451
|
+
if (res.body === null)
|
|
3452
|
+
throw new GatewayError("UPSTREAM", "empty response body", { provider: "kilo" });
|
|
3453
|
+
return { events: decodeKiloChat(parseSse(res.body)), degradations };
|
|
3454
|
+
}
|
|
3455
|
+
};
|
|
3456
|
+
// packages/providers/src/kimi/device.ts
|
|
3457
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
3458
|
+
function mintKimiDevice() {
|
|
3459
|
+
return {
|
|
3460
|
+
deviceId: randomUUID2(),
|
|
3461
|
+
deviceName: "MacBook-Pro",
|
|
3462
|
+
deviceModel: "MacBookPro18,3",
|
|
3463
|
+
osVersion: "15.3.1"
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
function kimiDeviceHeaders(providerData) {
|
|
3467
|
+
const deviceId = providerData.deviceId;
|
|
3468
|
+
if (typeof deviceId !== "string" || deviceId.length === 0)
|
|
3469
|
+
return [];
|
|
3470
|
+
const str = (v) => typeof v === "string" && v.length > 0 ? v : "unknown";
|
|
3471
|
+
return [
|
|
3472
|
+
["X-Msh-Device-Id", deviceId],
|
|
3473
|
+
["X-Msh-Device-Name", str(providerData.deviceName)],
|
|
3474
|
+
["X-Msh-Device-Model", str(providerData.deviceModel)],
|
|
3475
|
+
["X-Msh-Os-Version", str(providerData.osVersion)]
|
|
3476
|
+
];
|
|
3477
|
+
}
|
|
3478
|
+
// packages/providers/src/kimi/decode.ts
|
|
3479
|
+
var FINISH2 = {
|
|
3480
|
+
stop: "endTurn",
|
|
3481
|
+
length: "maxTokens",
|
|
3482
|
+
tool_calls: "toolUse",
|
|
3483
|
+
content_filter: "contentFilter"
|
|
3484
|
+
};
|
|
3485
|
+
function json5(data) {
|
|
3486
|
+
try {
|
|
3487
|
+
const v = JSON.parse(data);
|
|
3488
|
+
return typeof v === "object" && v !== null ? v : null;
|
|
3489
|
+
} catch {
|
|
3490
|
+
return null;
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
async function* decodeChat(messages) {
|
|
3494
|
+
let started = false;
|
|
3495
|
+
let done = false;
|
|
3496
|
+
let stopReason = "endTurn";
|
|
3497
|
+
let usage = { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 };
|
|
3498
|
+
const toolIndex = new Map;
|
|
3499
|
+
let nextIndex = 0;
|
|
3500
|
+
let openKind;
|
|
3501
|
+
let openIndex = 0;
|
|
3502
|
+
for await (const msg of messages) {
|
|
3503
|
+
if (msg.data === "[DONE]") {
|
|
3504
|
+
done = true;
|
|
3505
|
+
break;
|
|
3506
|
+
}
|
|
3507
|
+
const d = json5(msg.data);
|
|
3508
|
+
if (d === null)
|
|
3509
|
+
continue;
|
|
3510
|
+
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
3511
|
+
started = true;
|
|
3512
|
+
yield { type: "start", id: String(d.id ?? ""), model: String(d.model ?? "") };
|
|
3513
|
+
}
|
|
3514
|
+
if (d.usage) {
|
|
3515
|
+
const details = d.usage.prompt_tokens_details;
|
|
3516
|
+
usage = usageFromPromptTotal(d.usage.prompt_tokens ?? 0, d.usage.completion_tokens ?? 0, details?.cached_tokens ?? d.usage.prompt_cache_hit_tokens ?? 0, details?.cache_creation_tokens ?? details?.cache_write_tokens ?? 0);
|
|
3517
|
+
}
|
|
3518
|
+
const choice = d.choices?.[0];
|
|
3519
|
+
if (!choice)
|
|
3520
|
+
continue;
|
|
3521
|
+
const delta = choice.delta ?? {};
|
|
3522
|
+
if (typeof delta.content === "string" && delta.content.length > 0) {
|
|
3523
|
+
if (openKind !== "text") {
|
|
3524
|
+
if (openKind !== undefined)
|
|
3525
|
+
yield { type: "blockEnd", index: openIndex };
|
|
3526
|
+
openKind = "text";
|
|
3527
|
+
openIndex = nextIndex++;
|
|
3528
|
+
yield { type: "blockStart", index: openIndex, block: { type: "text" } };
|
|
3529
|
+
}
|
|
3530
|
+
yield {
|
|
3531
|
+
type: "blockDelta",
|
|
3532
|
+
index: openIndex,
|
|
3533
|
+
delta: { type: "text", text: delta.content }
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3536
|
+
for (const call of delta.tool_calls ?? []) {
|
|
3537
|
+
const wireIndex = call.index ?? 0;
|
|
3538
|
+
let index = toolIndex.get(wireIndex);
|
|
3539
|
+
if (index === undefined) {
|
|
3540
|
+
if (openKind !== undefined)
|
|
3541
|
+
yield { type: "blockEnd", index: openIndex };
|
|
3542
|
+
index = nextIndex++;
|
|
3543
|
+
toolIndex.set(wireIndex, index);
|
|
3544
|
+
openKind = "tool";
|
|
3545
|
+
openIndex = index;
|
|
3546
|
+
yield {
|
|
3547
|
+
type: "blockStart",
|
|
3548
|
+
index,
|
|
3549
|
+
block: {
|
|
3550
|
+
type: "toolUse",
|
|
3551
|
+
id: String(call.id ?? `call_${wireIndex}`),
|
|
3552
|
+
name: String(call.function?.name ?? "")
|
|
3553
|
+
}
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3556
|
+
const args = call.function?.arguments;
|
|
3557
|
+
if (typeof args === "string" && args.length > 0) {
|
|
3558
|
+
yield { type: "blockDelta", index, delta: { type: "toolJson", partial: args } };
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
if (typeof choice.finish_reason === "string") {
|
|
3562
|
+
stopReason = FINISH2[choice.finish_reason] ?? "endTurn";
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
if (done) {
|
|
3566
|
+
if (openKind !== undefined)
|
|
3567
|
+
yield { type: "blockEnd", index: openIndex };
|
|
3568
|
+
yield { type: "end", stopReason, usage };
|
|
3569
|
+
} else {
|
|
3570
|
+
yield {
|
|
3571
|
+
type: "error",
|
|
3572
|
+
code: "UPSTREAM",
|
|
3573
|
+
message: "upstream stream ended before [DONE]",
|
|
3574
|
+
retryable: RETRYABLE.UPSTREAM
|
|
3575
|
+
};
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
// packages/providers/src/kimi/wire.ts
|
|
3580
|
+
function encodeToolChoice4(c) {
|
|
3581
|
+
switch (c.type) {
|
|
3582
|
+
case "auto":
|
|
3583
|
+
return "auto";
|
|
3584
|
+
case "any":
|
|
3585
|
+
return "required";
|
|
3586
|
+
case "none":
|
|
3587
|
+
return "none";
|
|
3588
|
+
case "tool":
|
|
3589
|
+
return { type: "function", function: { name: c.name } };
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
function toChatWire(req, model, vendor = "kimi") {
|
|
3593
|
+
const degradations = [];
|
|
3594
|
+
const note2 = (d) => {
|
|
3595
|
+
if (!degradations.includes(d))
|
|
3596
|
+
degradations.push(d);
|
|
3597
|
+
};
|
|
3598
|
+
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
3599
|
+
note2("kimi:context-1m-dropped");
|
|
3600
|
+
const messages = [];
|
|
3601
|
+
const system = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
|
|
3602
|
+
|
|
3603
|
+
`);
|
|
3604
|
+
if (system !== undefined && system.length > 0)
|
|
3605
|
+
messages.push({ role: "system", content: system });
|
|
3606
|
+
for (const message of req.messages) {
|
|
3607
|
+
const text = [];
|
|
3608
|
+
const toolCalls = [];
|
|
3609
|
+
for (const block of message.content) {
|
|
3610
|
+
switch (block.type) {
|
|
3611
|
+
case "text":
|
|
3612
|
+
text.push(block.text);
|
|
3613
|
+
break;
|
|
3614
|
+
case "image":
|
|
3615
|
+
note2("kimi:images-dropped");
|
|
3616
|
+
break;
|
|
3617
|
+
case "thinking":
|
|
3618
|
+
note2("kimi:thinking-dropped");
|
|
3619
|
+
break;
|
|
3620
|
+
case "toolUse":
|
|
3621
|
+
toolCalls.push({
|
|
3622
|
+
id: block.id,
|
|
3623
|
+
type: "function",
|
|
3624
|
+
function: { name: block.name, arguments: JSON.stringify(block.input) }
|
|
3625
|
+
});
|
|
3626
|
+
break;
|
|
3627
|
+
case "toolResult":
|
|
3628
|
+
messages.push({
|
|
3629
|
+
role: "tool",
|
|
3630
|
+
tool_call_id: block.toolUseId,
|
|
3631
|
+
content: block.content
|
|
3632
|
+
});
|
|
3633
|
+
break;
|
|
3634
|
+
case "anthropicNative":
|
|
3635
|
+
note2("kimi:anthropic-native-block-dropped");
|
|
3636
|
+
break;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
if (toolCalls.length > 0) {
|
|
3640
|
+
messages.push({
|
|
3641
|
+
role: message.role,
|
|
3642
|
+
content: text.length > 0 ? text.join(`
|
|
3643
|
+
`) : null,
|
|
3644
|
+
tool_calls: toolCalls
|
|
3645
|
+
});
|
|
3646
|
+
} else if (text.length > 0) {
|
|
3647
|
+
messages.push({ role: message.role, content: text.join(`
|
|
3648
|
+
`) });
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
const body = {
|
|
3652
|
+
model,
|
|
3653
|
+
messages,
|
|
3654
|
+
stream: req.stream,
|
|
3655
|
+
stream_options: { include_usage: true }
|
|
3656
|
+
};
|
|
3657
|
+
if (req.maxTokens !== undefined)
|
|
3658
|
+
body.max_tokens = req.maxTokens;
|
|
3659
|
+
if (req.temperature !== undefined)
|
|
3660
|
+
body.temperature = req.temperature;
|
|
3661
|
+
if (req.stopSequences !== undefined)
|
|
3662
|
+
body.stop = req.stopSequences;
|
|
3663
|
+
if (req.tools !== undefined) {
|
|
3664
|
+
const custom = req.tools.filter((t) => t.provider === "custom");
|
|
3665
|
+
if (custom.length !== req.tools.length)
|
|
3666
|
+
note2("kimi:anthropic-tool-dropped");
|
|
3667
|
+
body.tools = custom.map((t) => ({
|
|
3668
|
+
type: "function",
|
|
3669
|
+
function: { name: t.name, description: t.description, parameters: t.inputSchema }
|
|
3670
|
+
}));
|
|
3671
|
+
}
|
|
3672
|
+
if (req.toolChoice !== undefined)
|
|
3673
|
+
body.tool_choice = encodeToolChoice4(req.toolChoice);
|
|
3674
|
+
if (req.reasoning !== undefined)
|
|
3675
|
+
note2("kimi:reasoning-dropped");
|
|
3676
|
+
Object.assign(body, req.vendor?.[vendor] ?? {});
|
|
3677
|
+
return { body, degradations };
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
// packages/providers/src/kimi/index.ts
|
|
3681
|
+
var BASE_URL2 = "https://api.kimi.com/coding/v1/chat/completions";
|
|
3682
|
+
var kimiAdapter = {
|
|
3683
|
+
id: "kimi",
|
|
3684
|
+
capabilities: PROVIDER_CAPABILITIES.kimi,
|
|
3685
|
+
async send(req) {
|
|
3686
|
+
const { body, degradations } = toChatWire(req.request, req.model);
|
|
3687
|
+
const token = req.credentials.accessToken ?? req.credentials.apiKey;
|
|
3688
|
+
if (token === null) {
|
|
3689
|
+
throw new GatewayError("AUTH", "kimi credential has no token", { provider: "kimi" });
|
|
3690
|
+
}
|
|
3691
|
+
const protocol = [
|
|
3692
|
+
["Content-Type", "application/json"],
|
|
3693
|
+
["Accept", "text/event-stream"],
|
|
3694
|
+
["Authorization", `Bearer ${token}`],
|
|
3695
|
+
...kimiDeviceHeaders(req.credentials.providerData)
|
|
3696
|
+
];
|
|
3697
|
+
const profile = PROFILES.kimi;
|
|
3698
|
+
const headers = orderHeaders(mergeHeaders(profile.headers, protocol), profile.order);
|
|
3699
|
+
const res = await req.http({
|
|
3700
|
+
provider: "kimi",
|
|
3701
|
+
url: BASE_URL2,
|
|
3702
|
+
method: "POST",
|
|
3703
|
+
headers,
|
|
3704
|
+
body: JSON.stringify(orderFields({ ...body, stream: true }, BODY_ORDER.kimi)),
|
|
3705
|
+
signal: req.signal
|
|
3706
|
+
});
|
|
3707
|
+
if (res.status < 200 || res.status >= 300)
|
|
3708
|
+
throw await httpError(res, "kimi");
|
|
3709
|
+
if (res.body === null)
|
|
3710
|
+
throw new GatewayError("UPSTREAM", "empty response body", { provider: "kimi" });
|
|
3711
|
+
return { events: decodeChat(parseSse(res.body)), degradations };
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
// packages/providers/src/openai/decode.ts
|
|
3715
|
+
var ERROR_CODE2 = {
|
|
3716
|
+
rate_limit_exceeded: "RATE_LIMIT",
|
|
3717
|
+
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
3718
|
+
invalid_api_key: "AUTH",
|
|
3719
|
+
server_error: "UPSTREAM",
|
|
3720
|
+
context_length_exceeded: "BAD_REQUEST",
|
|
3721
|
+
content_policy_violation: "CONTENT_FILTER"
|
|
3722
|
+
};
|
|
3723
|
+
function json6(data) {
|
|
3724
|
+
try {
|
|
3725
|
+
const v = JSON.parse(data);
|
|
3726
|
+
return typeof v === "object" && v !== null ? v : null;
|
|
3727
|
+
} catch {
|
|
3728
|
+
return null;
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
async function* decodeResponses(messages) {
|
|
3732
|
+
const indices = new Map;
|
|
3733
|
+
let next = 0;
|
|
3734
|
+
const irIndex = (outputIndex, contentIndex = 0) => {
|
|
3735
|
+
const key = `${outputIndex}:${contentIndex}`;
|
|
3736
|
+
const existing = indices.get(key);
|
|
3737
|
+
if (existing !== undefined)
|
|
3738
|
+
return existing;
|
|
3739
|
+
const assigned = next++;
|
|
3740
|
+
indices.set(key, assigned);
|
|
3741
|
+
return assigned;
|
|
3742
|
+
};
|
|
3743
|
+
let sawToolCall = false;
|
|
3744
|
+
let terminal = false;
|
|
3745
|
+
const ownsBlock = new Set;
|
|
3746
|
+
for await (const msg of messages) {
|
|
3747
|
+
const d = json6(msg.data);
|
|
3748
|
+
if (d === null)
|
|
3749
|
+
continue;
|
|
3750
|
+
switch (msg.event) {
|
|
3751
|
+
case "response.created":
|
|
3752
|
+
yield {
|
|
3753
|
+
type: "start",
|
|
3754
|
+
id: String(d.response?.id ?? ""),
|
|
3755
|
+
model: String(d.response?.model ?? "")
|
|
3756
|
+
};
|
|
3757
|
+
break;
|
|
3758
|
+
case "response.output_item.added": {
|
|
3759
|
+
const item = d.item ?? {};
|
|
3760
|
+
if (item.type === "reasoning") {
|
|
3761
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
3762
|
+
yield {
|
|
3763
|
+
type: "blockStart",
|
|
3764
|
+
index: irIndex(d.output_index ?? 0),
|
|
3765
|
+
block: { type: "thinking" }
|
|
3766
|
+
};
|
|
3767
|
+
} else if (item.type === "function_call") {
|
|
3768
|
+
sawToolCall = true;
|
|
3769
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
3770
|
+
yield {
|
|
3771
|
+
type: "blockStart",
|
|
3772
|
+
index: irIndex(d.output_index ?? 0),
|
|
3773
|
+
block: { type: "toolUse", id: String(item.call_id), name: String(item.name) }
|
|
3774
|
+
};
|
|
3775
|
+
}
|
|
3776
|
+
break;
|
|
3777
|
+
}
|
|
3778
|
+
case "response.content_part.added":
|
|
3779
|
+
if (d.part?.type === "output_text") {
|
|
3780
|
+
yield {
|
|
3781
|
+
type: "blockStart",
|
|
3782
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
3783
|
+
block: { type: "text" }
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
3786
|
+
break;
|
|
3787
|
+
case "response.output_text.delta":
|
|
3788
|
+
yield {
|
|
3789
|
+
type: "blockDelta",
|
|
3790
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
3791
|
+
delta: { type: "text", text: String(d.delta ?? "") }
|
|
3792
|
+
};
|
|
3793
|
+
break;
|
|
3794
|
+
case "response.reasoning_summary_text.delta":
|
|
3795
|
+
yield {
|
|
3796
|
+
type: "blockDelta",
|
|
3797
|
+
index: irIndex(d.output_index ?? 0),
|
|
3798
|
+
delta: { type: "thinking", text: String(d.delta ?? "") }
|
|
3799
|
+
};
|
|
3800
|
+
break;
|
|
3801
|
+
case "response.function_call_arguments.delta":
|
|
3802
|
+
yield {
|
|
3803
|
+
type: "blockDelta",
|
|
3804
|
+
index: irIndex(d.output_index ?? 0),
|
|
3805
|
+
delta: { type: "toolJson", partial: String(d.delta ?? "") }
|
|
3806
|
+
};
|
|
3807
|
+
break;
|
|
3808
|
+
case "response.content_part.done":
|
|
3809
|
+
yield { type: "blockEnd", index: irIndex(d.output_index ?? 0, d.content_index ?? 0) };
|
|
3810
|
+
break;
|
|
3811
|
+
case "response.output_item.done": {
|
|
3812
|
+
const outputIndex = d.output_index ?? 0;
|
|
3813
|
+
if (ownsBlock.delete(outputIndex)) {
|
|
3814
|
+
yield { type: "blockEnd", index: irIndex(outputIndex) };
|
|
3815
|
+
}
|
|
3816
|
+
break;
|
|
3817
|
+
}
|
|
3818
|
+
case "response.completed":
|
|
3819
|
+
case "response.incomplete": {
|
|
3820
|
+
terminal = true;
|
|
3821
|
+
const r = d.response ?? {};
|
|
3822
|
+
const reason = r.incomplete_details?.reason;
|
|
3823
|
+
let stopReason = sawToolCall ? "toolUse" : "endTurn";
|
|
3824
|
+
if (reason === "max_output_tokens")
|
|
3825
|
+
stopReason = "maxTokens";
|
|
3826
|
+
else if (reason === "content_filter")
|
|
3827
|
+
stopReason = "contentFilter";
|
|
3828
|
+
yield {
|
|
3829
|
+
type: "end",
|
|
3830
|
+
stopReason,
|
|
3831
|
+
usage: usageFromPromptTotal(r.usage?.input_tokens ?? 0, r.usage?.output_tokens ?? 0, r.usage?.input_tokens_details?.cached_tokens ?? r.usage?.prompt_tokens_details?.cached_tokens ?? 0)
|
|
3832
|
+
};
|
|
3833
|
+
break;
|
|
3834
|
+
}
|
|
3835
|
+
case "response.failed":
|
|
3836
|
+
case "error": {
|
|
3837
|
+
terminal = true;
|
|
3838
|
+
const err = d.response?.error ?? d.error ?? {};
|
|
3839
|
+
const code = ERROR_CODE2[String(err.code ?? err.type)] ?? "UPSTREAM";
|
|
3840
|
+
yield {
|
|
3841
|
+
type: "error",
|
|
3842
|
+
code,
|
|
3843
|
+
message: String(err.message ?? "upstream error"),
|
|
3844
|
+
retryable: RETRYABLE[code]
|
|
3845
|
+
};
|
|
3846
|
+
break;
|
|
3847
|
+
}
|
|
3848
|
+
default:
|
|
3849
|
+
break;
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
if (!terminal) {
|
|
3853
|
+
yield {
|
|
3854
|
+
type: "error",
|
|
3855
|
+
code: "UPSTREAM",
|
|
3856
|
+
message: "upstream stream ended before response completion",
|
|
3857
|
+
retryable: RETRYABLE.UPSTREAM
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
// packages/providers/src/openai/wire.ts
|
|
3863
|
+
function encodeToolChoice5(c) {
|
|
3864
|
+
switch (c.type) {
|
|
3865
|
+
case "auto":
|
|
3866
|
+
return "auto";
|
|
3867
|
+
case "any":
|
|
3868
|
+
return "required";
|
|
3869
|
+
case "none":
|
|
3870
|
+
return "none";
|
|
3871
|
+
case "tool":
|
|
3872
|
+
return { type: "function", name: c.name };
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
3876
|
+
const degradations = [];
|
|
3877
|
+
const input = [];
|
|
3878
|
+
const note2 = (d) => {
|
|
3879
|
+
if (!degradations.includes(d))
|
|
3880
|
+
degradations.push(d);
|
|
3881
|
+
};
|
|
3882
|
+
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
3883
|
+
note2("openai:context-1m-dropped");
|
|
3884
|
+
for (const message of req.messages) {
|
|
3885
|
+
const parts = [];
|
|
3886
|
+
const inlined = message.role === "system";
|
|
3887
|
+
if (inlined)
|
|
3888
|
+
note2("openai:system-turn-inlined");
|
|
3889
|
+
const role = inlined ? "user" : message.role;
|
|
3890
|
+
const flush = () => {
|
|
3891
|
+
if (parts.length === 0)
|
|
3892
|
+
return;
|
|
3893
|
+
input.push({ type: "message", role, content: [...parts] });
|
|
3894
|
+
parts.length = 0;
|
|
3895
|
+
};
|
|
3896
|
+
for (const block of message.content) {
|
|
3897
|
+
switch (block.type) {
|
|
3898
|
+
case "text":
|
|
3899
|
+
parts.push({
|
|
3900
|
+
type: role === "assistant" ? "output_text" : "input_text",
|
|
3901
|
+
text: inlined ? `<system-reminder>
|
|
3902
|
+
${block.text}
|
|
3903
|
+
</system-reminder>` : block.text
|
|
3904
|
+
});
|
|
3905
|
+
break;
|
|
3906
|
+
case "image":
|
|
3907
|
+
parts.push({
|
|
3908
|
+
type: "input_image",
|
|
3909
|
+
image_url: `data:${block.mediaType};base64,${block.data}`
|
|
3910
|
+
});
|
|
3911
|
+
break;
|
|
3912
|
+
case "thinking":
|
|
3913
|
+
if (!degradations.includes("openai:thinking-dropped")) {
|
|
3914
|
+
note2("openai:thinking-dropped");
|
|
3915
|
+
}
|
|
3916
|
+
break;
|
|
3917
|
+
case "toolUse":
|
|
3918
|
+
flush();
|
|
3919
|
+
input.push({
|
|
3920
|
+
type: "function_call",
|
|
3921
|
+
call_id: block.id,
|
|
3922
|
+
name: block.name,
|
|
3923
|
+
arguments: JSON.stringify(block.input)
|
|
3924
|
+
});
|
|
3925
|
+
break;
|
|
3926
|
+
case "toolResult":
|
|
3927
|
+
flush();
|
|
3928
|
+
input.push({
|
|
3929
|
+
type: "function_call_output",
|
|
3930
|
+
call_id: block.toolUseId,
|
|
3931
|
+
output: block.content
|
|
3932
|
+
});
|
|
3933
|
+
break;
|
|
3934
|
+
case "anthropicNative":
|
|
3935
|
+
note2("openai:anthropic-native-block-dropped");
|
|
3936
|
+
break;
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
flush();
|
|
3940
|
+
}
|
|
3941
|
+
const body = { model, input, stream: req.stream, store: false };
|
|
3942
|
+
const instructions = req.system?.flatMap((b) => b.type === "text" ? [b.text] : []).join(`
|
|
3943
|
+
|
|
3944
|
+
`);
|
|
3945
|
+
if (instructions !== undefined && instructions.length > 0)
|
|
3946
|
+
body.instructions = instructions;
|
|
3947
|
+
if (req.maxTokens !== undefined) {
|
|
3948
|
+
if (opts.oauth)
|
|
3949
|
+
note2("openai:max-tokens-dropped");
|
|
3950
|
+
else
|
|
3951
|
+
body.max_output_tokens = req.maxTokens;
|
|
3952
|
+
}
|
|
3953
|
+
if (req.temperature !== undefined) {
|
|
3954
|
+
if (opts.oauth)
|
|
3955
|
+
note2("openai:temperature-dropped");
|
|
3956
|
+
else
|
|
3957
|
+
body.temperature = req.temperature;
|
|
3958
|
+
}
|
|
3959
|
+
if (req.tools !== undefined) {
|
|
3960
|
+
const custom = req.tools.filter((t) => t.provider === "custom");
|
|
3961
|
+
if (custom.length !== req.tools.length)
|
|
3962
|
+
note2("openai:anthropic-tool-dropped");
|
|
3380
3963
|
body.tools = custom.map((t) => ({
|
|
3381
3964
|
type: "function",
|
|
3382
|
-
|
|
3965
|
+
name: t.name,
|
|
3966
|
+
description: t.description,
|
|
3967
|
+
parameters: t.inputSchema
|
|
3383
3968
|
}));
|
|
3384
3969
|
}
|
|
3385
3970
|
if (req.toolChoice !== undefined)
|
|
3386
3971
|
body.tool_choice = encodeToolChoice5(req.toolChoice);
|
|
3387
3972
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
3388
3973
|
if (req.reasoning.mode === "budget") {
|
|
3389
|
-
|
|
3974
|
+
degradations.push("openai:reasoning-budget-dropped");
|
|
3390
3975
|
} else {
|
|
3391
3976
|
const effort = req.reasoning.effort ?? "medium";
|
|
3392
|
-
|
|
3393
|
-
note2("kilo:reasoning-effort-clamped");
|
|
3394
|
-
body.reasoning = { effort: effort === "xhigh" || effort === "max" ? "high" : effort };
|
|
3977
|
+
body.reasoning = { effort, summary: "auto" };
|
|
3395
3978
|
}
|
|
3396
3979
|
}
|
|
3397
|
-
Object.assign(body, req.vendor?.
|
|
3980
|
+
Object.assign(body, req.vendor?.openai ?? {});
|
|
3398
3981
|
return { body, degradations };
|
|
3399
3982
|
}
|
|
3400
3983
|
|
|
3401
|
-
// packages/providers/src/kilo/index.ts
|
|
3402
|
-
var OAUTH_URL = "https://api.kilo.ai/api/openrouter/chat/completions";
|
|
3403
|
-
var API_URL2 = "https://api.kilo.ai/api/gateway/chat/completions";
|
|
3404
|
-
function organizationHeaders(providerData) {
|
|
3405
|
-
const orgId = providerData.orgId;
|
|
3406
|
-
if (typeof orgId !== "string" || orgId.length === 0)
|
|
3407
|
-
return [];
|
|
3408
|
-
return [["X-Kilocode-OrganizationID", orgId]];
|
|
3409
|
-
}
|
|
3410
|
-
var kiloAdapter = {
|
|
3411
|
-
id: "kilo",
|
|
3412
|
-
capabilities: PROVIDER_CAPABILITIES.kilo,
|
|
3413
|
-
async send(req) {
|
|
3414
|
-
const oauth = req.credentials.accessToken !== null;
|
|
3415
|
-
const token = req.credentials.accessToken ?? req.credentials.apiKey;
|
|
3416
|
-
if (token === null) {
|
|
3417
|
-
throw new GatewayError("AUTH", "kilo credential has no token", { provider: "kilo" });
|
|
3418
|
-
}
|
|
3419
|
-
const { body, degradations } = toKiloWire(req.request, req.model);
|
|
3420
|
-
const protocol = [
|
|
3421
|
-
["Content-Type", "application/json"],
|
|
3422
|
-
["Authorization", `Bearer ${token}`],
|
|
3423
|
-
...organizationHeaders(req.credentials.providerData)
|
|
3424
|
-
];
|
|
3425
|
-
const profile = PROFILES.kilo;
|
|
3426
|
-
const headers = orderHeaders(mergeHeaders(profile.headers, protocol), profile.order);
|
|
3427
|
-
const res = await req.http({
|
|
3428
|
-
provider: "kilo",
|
|
3429
|
-
url: oauth ? OAUTH_URL : API_URL2,
|
|
3430
|
-
method: "POST",
|
|
3431
|
-
headers,
|
|
3432
|
-
body: JSON.stringify(orderFields({ ...body, stream: true }, BODY_ORDER.kilo)),
|
|
3433
|
-
signal: req.signal
|
|
3434
|
-
});
|
|
3435
|
-
if (res.status < 200 || res.status >= 300)
|
|
3436
|
-
throw await httpError(res, "kilo");
|
|
3437
|
-
if (res.body === null)
|
|
3438
|
-
throw new GatewayError("UPSTREAM", "empty response body", { provider: "kilo" });
|
|
3439
|
-
return { events: decodeKiloChat(parseSse(res.body)), degradations };
|
|
3440
|
-
}
|
|
3441
|
-
};
|
|
3442
|
-
// packages/providers/src/kimi/device.ts
|
|
3443
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
3444
|
-
function mintKimiDevice() {
|
|
3445
|
-
return {
|
|
3446
|
-
deviceId: randomUUID2(),
|
|
3447
|
-
deviceName: "MacBook-Pro",
|
|
3448
|
-
deviceModel: "MacBookPro18,3",
|
|
3449
|
-
osVersion: "15.3.1"
|
|
3450
|
-
};
|
|
3451
|
-
}
|
|
3452
|
-
function kimiDeviceHeaders(providerData) {
|
|
3453
|
-
const deviceId = providerData.deviceId;
|
|
3454
|
-
if (typeof deviceId !== "string" || deviceId.length === 0)
|
|
3455
|
-
return [];
|
|
3456
|
-
const str = (v) => typeof v === "string" && v.length > 0 ? v : "unknown";
|
|
3457
|
-
return [
|
|
3458
|
-
["X-Msh-Device-Id", deviceId],
|
|
3459
|
-
["X-Msh-Device-Name", str(providerData.deviceName)],
|
|
3460
|
-
["X-Msh-Device-Model", str(providerData.deviceModel)],
|
|
3461
|
-
["X-Msh-Os-Version", str(providerData.osVersion)]
|
|
3462
|
-
];
|
|
3463
|
-
}
|
|
3464
|
-
// packages/providers/src/kimi/index.ts
|
|
3465
|
-
var BASE_URL2 = "https://api.kimi.com/coding/v1/chat/completions";
|
|
3466
|
-
var kimiAdapter = {
|
|
3467
|
-
id: "kimi",
|
|
3468
|
-
capabilities: PROVIDER_CAPABILITIES.kimi,
|
|
3469
|
-
async send(req) {
|
|
3470
|
-
const { body, degradations } = toChatWire(req.request, req.model);
|
|
3471
|
-
const token = req.credentials.accessToken ?? req.credentials.apiKey;
|
|
3472
|
-
if (token === null) {
|
|
3473
|
-
throw new GatewayError("AUTH", "kimi credential has no token", { provider: "kimi" });
|
|
3474
|
-
}
|
|
3475
|
-
const protocol = [
|
|
3476
|
-
["Content-Type", "application/json"],
|
|
3477
|
-
["Accept", "text/event-stream"],
|
|
3478
|
-
["Authorization", `Bearer ${token}`],
|
|
3479
|
-
...kimiDeviceHeaders(req.credentials.providerData)
|
|
3480
|
-
];
|
|
3481
|
-
const profile = PROFILES.kimi;
|
|
3482
|
-
const headers = orderHeaders(mergeHeaders(profile.headers, protocol), profile.order);
|
|
3483
|
-
const res = await req.http({
|
|
3484
|
-
provider: "kimi",
|
|
3485
|
-
url: BASE_URL2,
|
|
3486
|
-
method: "POST",
|
|
3487
|
-
headers,
|
|
3488
|
-
body: JSON.stringify(orderFields({ ...body, stream: true }, BODY_ORDER.kimi)),
|
|
3489
|
-
signal: req.signal
|
|
3490
|
-
});
|
|
3491
|
-
if (res.status < 200 || res.status >= 300)
|
|
3492
|
-
throw await httpError(res, "kimi");
|
|
3493
|
-
if (res.body === null)
|
|
3494
|
-
throw new GatewayError("UPSTREAM", "empty response body", { provider: "kimi" });
|
|
3495
|
-
return { events: decodeChat(parseSse(res.body)), degradations };
|
|
3496
|
-
}
|
|
3497
|
-
};
|
|
3498
3984
|
// packages/providers/src/openai/index.ts
|
|
3499
3985
|
var OAUTH_URL2 = "https://chatgpt.com/backend-api/codex/responses";
|
|
3500
3986
|
var API_URL3 = "https://api.openai.com/v1/responses";
|
|
@@ -3897,7 +4383,7 @@ __export(exports_external, {
|
|
|
3897
4383
|
ipv4: () => ipv42,
|
|
3898
4384
|
ipv6: () => ipv62,
|
|
3899
4385
|
iso: () => exports_iso,
|
|
3900
|
-
json: () =>
|
|
4386
|
+
json: () => json7,
|
|
3901
4387
|
jwt: () => jwt,
|
|
3902
4388
|
keyof: () => keyof,
|
|
3903
4389
|
ksuid: () => ksuid2,
|
|
@@ -15338,29 +15824,29 @@ var formatMap = {
|
|
|
15338
15824
|
regex: ""
|
|
15339
15825
|
};
|
|
15340
15826
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
15341
|
-
const
|
|
15342
|
-
|
|
15827
|
+
const json7 = _json;
|
|
15828
|
+
json7.type = "string";
|
|
15343
15829
|
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
15344
15830
|
if (typeof minimum === "number")
|
|
15345
|
-
|
|
15831
|
+
json7.minLength = minimum;
|
|
15346
15832
|
if (typeof maximum === "number")
|
|
15347
|
-
|
|
15833
|
+
json7.maxLength = maximum;
|
|
15348
15834
|
if (format) {
|
|
15349
|
-
|
|
15350
|
-
if (
|
|
15351
|
-
delete
|
|
15835
|
+
json7.format = formatMap[format] ?? format;
|
|
15836
|
+
if (json7.format === "")
|
|
15837
|
+
delete json7.format;
|
|
15352
15838
|
if (format === "time") {
|
|
15353
|
-
delete
|
|
15839
|
+
delete json7.format;
|
|
15354
15840
|
}
|
|
15355
15841
|
}
|
|
15356
15842
|
if (contentEncoding)
|
|
15357
|
-
|
|
15843
|
+
json7.contentEncoding = contentEncoding;
|
|
15358
15844
|
if (patterns && patterns.size > 0) {
|
|
15359
15845
|
const regexes = [...patterns];
|
|
15360
15846
|
if (regexes.length === 1)
|
|
15361
|
-
|
|
15847
|
+
json7.pattern = regexes[0].source;
|
|
15362
15848
|
else if (regexes.length > 1) {
|
|
15363
|
-
|
|
15849
|
+
json7.allOf = [
|
|
15364
15850
|
...regexes.map((regex) => ({
|
|
15365
15851
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
15366
15852
|
pattern: regex.source
|
|
@@ -15370,40 +15856,40 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
15370
15856
|
}
|
|
15371
15857
|
};
|
|
15372
15858
|
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
15373
|
-
const
|
|
15859
|
+
const json7 = _json;
|
|
15374
15860
|
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
15375
15861
|
if (typeof format === "string" && format.includes("int"))
|
|
15376
|
-
|
|
15862
|
+
json7.type = "integer";
|
|
15377
15863
|
else
|
|
15378
|
-
|
|
15864
|
+
json7.type = "number";
|
|
15379
15865
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
15380
15866
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
15381
15867
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
15382
15868
|
if (exMin) {
|
|
15383
15869
|
if (legacy) {
|
|
15384
|
-
|
|
15385
|
-
|
|
15870
|
+
json7.minimum = exclusiveMinimum;
|
|
15871
|
+
json7.exclusiveMinimum = true;
|
|
15386
15872
|
} else {
|
|
15387
|
-
|
|
15873
|
+
json7.exclusiveMinimum = exclusiveMinimum;
|
|
15388
15874
|
}
|
|
15389
15875
|
} else if (typeof minimum === "number") {
|
|
15390
|
-
|
|
15876
|
+
json7.minimum = minimum;
|
|
15391
15877
|
}
|
|
15392
15878
|
if (exMax) {
|
|
15393
15879
|
if (legacy) {
|
|
15394
|
-
|
|
15395
|
-
|
|
15880
|
+
json7.maximum = exclusiveMaximum;
|
|
15881
|
+
json7.exclusiveMaximum = true;
|
|
15396
15882
|
} else {
|
|
15397
|
-
|
|
15883
|
+
json7.exclusiveMaximum = exclusiveMaximum;
|
|
15398
15884
|
}
|
|
15399
15885
|
} else if (typeof maximum === "number") {
|
|
15400
|
-
|
|
15886
|
+
json7.maximum = maximum;
|
|
15401
15887
|
}
|
|
15402
15888
|
if (typeof multipleOf === "number")
|
|
15403
|
-
|
|
15889
|
+
json7.multipleOf = multipleOf;
|
|
15404
15890
|
};
|
|
15405
|
-
var booleanProcessor = (_schema, _ctx,
|
|
15406
|
-
|
|
15891
|
+
var booleanProcessor = (_schema, _ctx, json7, _params) => {
|
|
15892
|
+
json7.type = "boolean";
|
|
15407
15893
|
};
|
|
15408
15894
|
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
15409
15895
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -15415,13 +15901,13 @@ var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
|
15415
15901
|
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
15416
15902
|
}
|
|
15417
15903
|
};
|
|
15418
|
-
var nullProcessor = (_schema, ctx,
|
|
15904
|
+
var nullProcessor = (_schema, ctx, json7, _params) => {
|
|
15419
15905
|
if (ctx.target === "openapi-3.0") {
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15906
|
+
json7.type = "string";
|
|
15907
|
+
json7.nullable = true;
|
|
15908
|
+
json7.enum = [null];
|
|
15423
15909
|
} else {
|
|
15424
|
-
|
|
15910
|
+
json7.type = "null";
|
|
15425
15911
|
}
|
|
15426
15912
|
};
|
|
15427
15913
|
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -15434,8 +15920,8 @@ var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
|
15434
15920
|
throw new Error("Void cannot be represented in JSON Schema");
|
|
15435
15921
|
}
|
|
15436
15922
|
};
|
|
15437
|
-
var neverProcessor = (_schema, _ctx,
|
|
15438
|
-
|
|
15923
|
+
var neverProcessor = (_schema, _ctx, json7, _params) => {
|
|
15924
|
+
json7.not = {};
|
|
15439
15925
|
};
|
|
15440
15926
|
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
15441
15927
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
@@ -15444,16 +15930,16 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
15444
15930
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
15445
15931
|
}
|
|
15446
15932
|
};
|
|
15447
|
-
var enumProcessor = (schema, _ctx,
|
|
15933
|
+
var enumProcessor = (schema, _ctx, json7, _params) => {
|
|
15448
15934
|
const def = schema._zod.def;
|
|
15449
15935
|
const values = getEnumValues(def.entries);
|
|
15450
15936
|
if (values.every((v) => typeof v === "number"))
|
|
15451
|
-
|
|
15937
|
+
json7.type = "number";
|
|
15452
15938
|
if (values.every((v) => typeof v === "string"))
|
|
15453
|
-
|
|
15454
|
-
|
|
15939
|
+
json7.type = "string";
|
|
15940
|
+
json7.enum = values;
|
|
15455
15941
|
};
|
|
15456
|
-
var literalProcessor = (schema, ctx,
|
|
15942
|
+
var literalProcessor = (schema, ctx, json7, _params) => {
|
|
15457
15943
|
const def = schema._zod.def;
|
|
15458
15944
|
const vals = [];
|
|
15459
15945
|
for (const val of def.values) {
|
|
@@ -15473,22 +15959,22 @@ var literalProcessor = (schema, ctx, json6, _params) => {
|
|
|
15473
15959
|
}
|
|
15474
15960
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
15475
15961
|
const val = vals[0];
|
|
15476
|
-
|
|
15962
|
+
json7.type = val === null ? "null" : typeof val;
|
|
15477
15963
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
15478
|
-
|
|
15964
|
+
json7.enum = [val];
|
|
15479
15965
|
} else {
|
|
15480
|
-
|
|
15966
|
+
json7.const = val;
|
|
15481
15967
|
}
|
|
15482
15968
|
} else {
|
|
15483
15969
|
if (vals.every((v) => typeof v === "number"))
|
|
15484
|
-
|
|
15970
|
+
json7.type = "number";
|
|
15485
15971
|
if (vals.every((v) => typeof v === "string"))
|
|
15486
|
-
|
|
15972
|
+
json7.type = "string";
|
|
15487
15973
|
if (vals.every((v) => typeof v === "boolean"))
|
|
15488
|
-
|
|
15974
|
+
json7.type = "boolean";
|
|
15489
15975
|
if (vals.every((v) => v === null))
|
|
15490
|
-
|
|
15491
|
-
|
|
15976
|
+
json7.type = "null";
|
|
15977
|
+
json7.enum = vals;
|
|
15492
15978
|
}
|
|
15493
15979
|
};
|
|
15494
15980
|
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -15496,16 +15982,16 @@ var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
|
15496
15982
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
15497
15983
|
}
|
|
15498
15984
|
};
|
|
15499
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
15500
|
-
const _json =
|
|
15985
|
+
var templateLiteralProcessor = (schema, _ctx, json7, _params) => {
|
|
15986
|
+
const _json = json7;
|
|
15501
15987
|
const pattern = schema._zod.pattern;
|
|
15502
15988
|
if (!pattern)
|
|
15503
15989
|
throw new Error("Pattern not found in template literal");
|
|
15504
15990
|
_json.type = "string";
|
|
15505
15991
|
_json.pattern = pattern.source;
|
|
15506
15992
|
};
|
|
15507
|
-
var fileProcessor = (schema, _ctx,
|
|
15508
|
-
const _json =
|
|
15993
|
+
var fileProcessor = (schema, _ctx, json7, _params) => {
|
|
15994
|
+
const _json = json7;
|
|
15509
15995
|
const file = {
|
|
15510
15996
|
type: "string",
|
|
15511
15997
|
format: "binary",
|
|
@@ -15528,8 +16014,8 @@ var fileProcessor = (schema, _ctx, json6, _params) => {
|
|
|
15528
16014
|
Object.assign(_json, file);
|
|
15529
16015
|
}
|
|
15530
16016
|
};
|
|
15531
|
-
var successProcessor = (_schema, _ctx,
|
|
15532
|
-
|
|
16017
|
+
var successProcessor = (_schema, _ctx, json7, _params) => {
|
|
16018
|
+
json7.type = "boolean";
|
|
15533
16019
|
};
|
|
15534
16020
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
15535
16021
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -15557,27 +16043,27 @@ var setProcessor = (_schema, ctx, _json, _params) => {
|
|
|
15557
16043
|
}
|
|
15558
16044
|
};
|
|
15559
16045
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
15560
|
-
const
|
|
16046
|
+
const json7 = _json;
|
|
15561
16047
|
const def = schema._zod.def;
|
|
15562
16048
|
const { minimum, maximum } = schema._zod.bag;
|
|
15563
16049
|
if (typeof minimum === "number")
|
|
15564
|
-
|
|
16050
|
+
json7.minItems = minimum;
|
|
15565
16051
|
if (typeof maximum === "number")
|
|
15566
|
-
|
|
15567
|
-
|
|
15568
|
-
|
|
16052
|
+
json7.maxItems = maximum;
|
|
16053
|
+
json7.type = "array";
|
|
16054
|
+
json7.items = process2(def.element, ctx, {
|
|
15569
16055
|
...params,
|
|
15570
16056
|
path: [...params.path, "items"]
|
|
15571
16057
|
});
|
|
15572
16058
|
};
|
|
15573
16059
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
15574
|
-
const
|
|
16060
|
+
const json7 = _json;
|
|
15575
16061
|
const def = schema._zod.def;
|
|
15576
|
-
|
|
15577
|
-
|
|
16062
|
+
json7.type = "object";
|
|
16063
|
+
json7.properties = {};
|
|
15578
16064
|
const shape = def.shape;
|
|
15579
16065
|
for (const key in shape) {
|
|
15580
|
-
|
|
16066
|
+
json7.properties[key] = process2(shape[key], ctx, {
|
|
15581
16067
|
...params,
|
|
15582
16068
|
path: [...params.path, "properties", key]
|
|
15583
16069
|
});
|
|
@@ -15592,21 +16078,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
15592
16078
|
}
|
|
15593
16079
|
}));
|
|
15594
16080
|
if (requiredKeys.size > 0) {
|
|
15595
|
-
|
|
16081
|
+
json7.required = Array.from(requiredKeys);
|
|
15596
16082
|
}
|
|
15597
16083
|
if (def.catchall?._zod.def.type === "never") {
|
|
15598
|
-
|
|
16084
|
+
json7.additionalProperties = false;
|
|
15599
16085
|
} else if (!def.catchall) {
|
|
15600
16086
|
if (ctx.io === "output")
|
|
15601
|
-
|
|
16087
|
+
json7.additionalProperties = false;
|
|
15602
16088
|
} else if (def.catchall) {
|
|
15603
|
-
|
|
16089
|
+
json7.additionalProperties = process2(def.catchall, ctx, {
|
|
15604
16090
|
...params,
|
|
15605
16091
|
path: [...params.path, "additionalProperties"]
|
|
15606
16092
|
});
|
|
15607
16093
|
}
|
|
15608
16094
|
};
|
|
15609
|
-
var unionProcessor = (schema, ctx,
|
|
16095
|
+
var unionProcessor = (schema, ctx, json7, params) => {
|
|
15610
16096
|
const def = schema._zod.def;
|
|
15611
16097
|
const isExclusive = def.inclusive === false;
|
|
15612
16098
|
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
@@ -15614,12 +16100,12 @@ var unionProcessor = (schema, ctx, json6, params) => {
|
|
|
15614
16100
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
15615
16101
|
}));
|
|
15616
16102
|
if (isExclusive) {
|
|
15617
|
-
|
|
16103
|
+
json7.oneOf = options;
|
|
15618
16104
|
} else {
|
|
15619
|
-
|
|
16105
|
+
json7.anyOf = options;
|
|
15620
16106
|
}
|
|
15621
16107
|
};
|
|
15622
|
-
var intersectionProcessor = (schema, ctx,
|
|
16108
|
+
var intersectionProcessor = (schema, ctx, json7, params) => {
|
|
15623
16109
|
const def = schema._zod.def;
|
|
15624
16110
|
const a = process2(def.left, ctx, {
|
|
15625
16111
|
...params,
|
|
@@ -15634,12 +16120,12 @@ var intersectionProcessor = (schema, ctx, json6, params) => {
|
|
|
15634
16120
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
15635
16121
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
15636
16122
|
];
|
|
15637
|
-
|
|
16123
|
+
json7.allOf = allOf;
|
|
15638
16124
|
};
|
|
15639
16125
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
15640
|
-
const
|
|
16126
|
+
const json7 = _json;
|
|
15641
16127
|
const def = schema._zod.def;
|
|
15642
|
-
|
|
16128
|
+
json7.type = "array";
|
|
15643
16129
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
15644
16130
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
15645
16131
|
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
@@ -15651,37 +16137,37 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
15651
16137
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
15652
16138
|
}) : null;
|
|
15653
16139
|
if (ctx.target === "draft-2020-12") {
|
|
15654
|
-
|
|
16140
|
+
json7.prefixItems = prefixItems;
|
|
15655
16141
|
if (rest) {
|
|
15656
|
-
|
|
16142
|
+
json7.items = rest;
|
|
15657
16143
|
}
|
|
15658
16144
|
} else if (ctx.target === "openapi-3.0") {
|
|
15659
|
-
|
|
16145
|
+
json7.items = {
|
|
15660
16146
|
anyOf: prefixItems
|
|
15661
16147
|
};
|
|
15662
16148
|
if (rest) {
|
|
15663
|
-
|
|
16149
|
+
json7.items.anyOf.push(rest);
|
|
15664
16150
|
}
|
|
15665
|
-
|
|
16151
|
+
json7.minItems = prefixItems.length;
|
|
15666
16152
|
if (!rest) {
|
|
15667
|
-
|
|
16153
|
+
json7.maxItems = prefixItems.length;
|
|
15668
16154
|
}
|
|
15669
16155
|
} else {
|
|
15670
|
-
|
|
16156
|
+
json7.items = prefixItems;
|
|
15671
16157
|
if (rest) {
|
|
15672
|
-
|
|
16158
|
+
json7.additionalItems = rest;
|
|
15673
16159
|
}
|
|
15674
16160
|
}
|
|
15675
16161
|
const { minimum, maximum } = schema._zod.bag;
|
|
15676
16162
|
if (typeof minimum === "number")
|
|
15677
|
-
|
|
16163
|
+
json7.minItems = minimum;
|
|
15678
16164
|
if (typeof maximum === "number")
|
|
15679
|
-
|
|
16165
|
+
json7.maxItems = maximum;
|
|
15680
16166
|
};
|
|
15681
16167
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
15682
|
-
const
|
|
16168
|
+
const json7 = _json;
|
|
15683
16169
|
const def = schema._zod.def;
|
|
15684
|
-
|
|
16170
|
+
json7.type = "object";
|
|
15685
16171
|
const keyType = def.keyType;
|
|
15686
16172
|
const keyBag = keyType._zod.bag;
|
|
15687
16173
|
const patterns = keyBag?.patterns;
|
|
@@ -15690,18 +16176,18 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
15690
16176
|
...params,
|
|
15691
16177
|
path: [...params.path, "patternProperties", "*"]
|
|
15692
16178
|
});
|
|
15693
|
-
|
|
16179
|
+
json7.patternProperties = {};
|
|
15694
16180
|
for (const pattern of patterns) {
|
|
15695
|
-
|
|
16181
|
+
json7.patternProperties[pattern.source] = valueSchema;
|
|
15696
16182
|
}
|
|
15697
16183
|
} else {
|
|
15698
16184
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
15699
|
-
|
|
16185
|
+
json7.propertyNames = process2(def.keyType, ctx, {
|
|
15700
16186
|
...params,
|
|
15701
16187
|
path: [...params.path, "propertyNames"]
|
|
15702
16188
|
});
|
|
15703
16189
|
}
|
|
15704
|
-
|
|
16190
|
+
json7.additionalProperties = process2(def.valueType, ctx, {
|
|
15705
16191
|
...params,
|
|
15706
16192
|
path: [...params.path, "additionalProperties"]
|
|
15707
16193
|
});
|
|
@@ -15710,19 +16196,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
15710
16196
|
if (keyValues) {
|
|
15711
16197
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
15712
16198
|
if (validKeyValues.length > 0) {
|
|
15713
|
-
|
|
16199
|
+
json7.required = validKeyValues;
|
|
15714
16200
|
}
|
|
15715
16201
|
}
|
|
15716
16202
|
};
|
|
15717
|
-
var nullableProcessor = (schema, ctx,
|
|
16203
|
+
var nullableProcessor = (schema, ctx, json7, params) => {
|
|
15718
16204
|
const def = schema._zod.def;
|
|
15719
16205
|
const inner = process2(def.innerType, ctx, params);
|
|
15720
16206
|
const seen = ctx.seen.get(schema);
|
|
15721
16207
|
if (ctx.target === "openapi-3.0") {
|
|
15722
16208
|
seen.ref = def.innerType;
|
|
15723
|
-
|
|
16209
|
+
json7.nullable = true;
|
|
15724
16210
|
} else {
|
|
15725
|
-
|
|
16211
|
+
json7.anyOf = [inner, { type: "null" }];
|
|
15726
16212
|
}
|
|
15727
16213
|
};
|
|
15728
16214
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -15731,22 +16217,22 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
15731
16217
|
const seen = ctx.seen.get(schema);
|
|
15732
16218
|
seen.ref = def.innerType;
|
|
15733
16219
|
};
|
|
15734
|
-
var defaultProcessor = (schema, ctx,
|
|
16220
|
+
var defaultProcessor = (schema, ctx, json7, params) => {
|
|
15735
16221
|
const def = schema._zod.def;
|
|
15736
16222
|
process2(def.innerType, ctx, params);
|
|
15737
16223
|
const seen = ctx.seen.get(schema);
|
|
15738
16224
|
seen.ref = def.innerType;
|
|
15739
|
-
|
|
16225
|
+
json7.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
15740
16226
|
};
|
|
15741
|
-
var prefaultProcessor = (schema, ctx,
|
|
16227
|
+
var prefaultProcessor = (schema, ctx, json7, params) => {
|
|
15742
16228
|
const def = schema._zod.def;
|
|
15743
16229
|
process2(def.innerType, ctx, params);
|
|
15744
16230
|
const seen = ctx.seen.get(schema);
|
|
15745
16231
|
seen.ref = def.innerType;
|
|
15746
16232
|
if (ctx.io === "input")
|
|
15747
|
-
|
|
16233
|
+
json7._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
15748
16234
|
};
|
|
15749
|
-
var catchProcessor = (schema, ctx,
|
|
16235
|
+
var catchProcessor = (schema, ctx, json7, params) => {
|
|
15750
16236
|
const def = schema._zod.def;
|
|
15751
16237
|
process2(def.innerType, ctx, params);
|
|
15752
16238
|
const seen = ctx.seen.get(schema);
|
|
@@ -15757,7 +16243,7 @@ var catchProcessor = (schema, ctx, json6, params) => {
|
|
|
15757
16243
|
} catch {
|
|
15758
16244
|
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
15759
16245
|
}
|
|
15760
|
-
|
|
16246
|
+
json7.default = catchValue;
|
|
15761
16247
|
};
|
|
15762
16248
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
15763
16249
|
const def = schema._zod.def;
|
|
@@ -15767,12 +16253,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
15767
16253
|
const seen = ctx.seen.get(schema);
|
|
15768
16254
|
seen.ref = innerType;
|
|
15769
16255
|
};
|
|
15770
|
-
var readonlyProcessor = (schema, ctx,
|
|
16256
|
+
var readonlyProcessor = (schema, ctx, json7, params) => {
|
|
15771
16257
|
const def = schema._zod.def;
|
|
15772
16258
|
process2(def.innerType, ctx, params);
|
|
15773
16259
|
const seen = ctx.seen.get(schema);
|
|
15774
16260
|
seen.ref = def.innerType;
|
|
15775
|
-
|
|
16261
|
+
json7.readOnly = true;
|
|
15776
16262
|
};
|
|
15777
16263
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
15778
16264
|
const def = schema._zod.def;
|
|
@@ -16042,7 +16528,7 @@ __export(exports_schemas2, {
|
|
|
16042
16528
|
invertCodec: () => invertCodec,
|
|
16043
16529
|
ipv4: () => ipv42,
|
|
16044
16530
|
ipv6: () => ipv62,
|
|
16045
|
-
json: () =>
|
|
16531
|
+
json: () => json7,
|
|
16046
16532
|
jwt: () => jwt,
|
|
16047
16533
|
keyof: () => keyof,
|
|
16048
16534
|
ksuid: () => ksuid2,
|
|
@@ -16393,7 +16879,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
16393
16879
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
16394
16880
|
$ZodString.init(inst, def);
|
|
16395
16881
|
ZodType.init(inst, def);
|
|
16396
|
-
inst._zod.processJSONSchema = (ctx,
|
|
16882
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => stringProcessor(inst, ctx, json7, params);
|
|
16397
16883
|
const bag = inst._zod.bag;
|
|
16398
16884
|
inst.format = bag.format ?? null;
|
|
16399
16885
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -16664,7 +17150,7 @@ function hash2(alg, params) {
|
|
|
16664
17150
|
var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
16665
17151
|
$ZodNumber.init(inst, def);
|
|
16666
17152
|
ZodType.init(inst, def);
|
|
16667
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17153
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => numberProcessor(inst, ctx, json7, params);
|
|
16668
17154
|
_installLazyMethods(inst, "ZodNumber", {
|
|
16669
17155
|
gt(value, params) {
|
|
16670
17156
|
return this.check(_gt(value, params));
|
|
@@ -16744,7 +17230,7 @@ function uint32(params) {
|
|
|
16744
17230
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
16745
17231
|
$ZodBoolean.init(inst, def);
|
|
16746
17232
|
ZodType.init(inst, def);
|
|
16747
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17233
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => booleanProcessor(inst, ctx, json7, params);
|
|
16748
17234
|
});
|
|
16749
17235
|
function boolean2(params) {
|
|
16750
17236
|
return _boolean(ZodBoolean, params);
|
|
@@ -16752,7 +17238,7 @@ function boolean2(params) {
|
|
|
16752
17238
|
var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
|
|
16753
17239
|
$ZodBigInt.init(inst, def);
|
|
16754
17240
|
ZodType.init(inst, def);
|
|
16755
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17241
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => bigintProcessor(inst, ctx, json7, params);
|
|
16756
17242
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
16757
17243
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
16758
17244
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
@@ -16787,7 +17273,7 @@ function uint64(params) {
|
|
|
16787
17273
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
16788
17274
|
$ZodSymbol.init(inst, def);
|
|
16789
17275
|
ZodType.init(inst, def);
|
|
16790
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17276
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => symbolProcessor(inst, ctx, json7, params);
|
|
16791
17277
|
});
|
|
16792
17278
|
function symbol(params) {
|
|
16793
17279
|
return _symbol(ZodSymbol, params);
|
|
@@ -16795,7 +17281,7 @@ function symbol(params) {
|
|
|
16795
17281
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
16796
17282
|
$ZodUndefined.init(inst, def);
|
|
16797
17283
|
ZodType.init(inst, def);
|
|
16798
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17284
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => undefinedProcessor(inst, ctx, json7, params);
|
|
16799
17285
|
});
|
|
16800
17286
|
function _undefined3(params) {
|
|
16801
17287
|
return _undefined2(ZodUndefined, params);
|
|
@@ -16803,7 +17289,7 @@ function _undefined3(params) {
|
|
|
16803
17289
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
16804
17290
|
$ZodNull.init(inst, def);
|
|
16805
17291
|
ZodType.init(inst, def);
|
|
16806
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17292
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => nullProcessor(inst, ctx, json7, params);
|
|
16807
17293
|
});
|
|
16808
17294
|
function _null3(params) {
|
|
16809
17295
|
return _null2(ZodNull, params);
|
|
@@ -16811,7 +17297,7 @@ function _null3(params) {
|
|
|
16811
17297
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
16812
17298
|
$ZodAny.init(inst, def);
|
|
16813
17299
|
ZodType.init(inst, def);
|
|
16814
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17300
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => anyProcessor(inst, ctx, json7, params);
|
|
16815
17301
|
});
|
|
16816
17302
|
function any() {
|
|
16817
17303
|
return _any(ZodAny);
|
|
@@ -16819,7 +17305,7 @@ function any() {
|
|
|
16819
17305
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
16820
17306
|
$ZodUnknown.init(inst, def);
|
|
16821
17307
|
ZodType.init(inst, def);
|
|
16822
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17308
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => unknownProcessor(inst, ctx, json7, params);
|
|
16823
17309
|
});
|
|
16824
17310
|
function unknown() {
|
|
16825
17311
|
return _unknown(ZodUnknown);
|
|
@@ -16827,7 +17313,7 @@ function unknown() {
|
|
|
16827
17313
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
16828
17314
|
$ZodNever.init(inst, def);
|
|
16829
17315
|
ZodType.init(inst, def);
|
|
16830
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17316
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => neverProcessor(inst, ctx, json7, params);
|
|
16831
17317
|
});
|
|
16832
17318
|
function never(params) {
|
|
16833
17319
|
return _never(ZodNever, params);
|
|
@@ -16835,7 +17321,7 @@ function never(params) {
|
|
|
16835
17321
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
16836
17322
|
$ZodVoid.init(inst, def);
|
|
16837
17323
|
ZodType.init(inst, def);
|
|
16838
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17324
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => voidProcessor(inst, ctx, json7, params);
|
|
16839
17325
|
});
|
|
16840
17326
|
function _void2(params) {
|
|
16841
17327
|
return _void(ZodVoid, params);
|
|
@@ -16843,7 +17329,7 @@ function _void2(params) {
|
|
|
16843
17329
|
var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
16844
17330
|
$ZodDate.init(inst, def);
|
|
16845
17331
|
ZodType.init(inst, def);
|
|
16846
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17332
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => dateProcessor(inst, ctx, json7, params);
|
|
16847
17333
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
16848
17334
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
16849
17335
|
const c = inst._zod.bag;
|
|
@@ -16856,7 +17342,7 @@ function date3(params) {
|
|
|
16856
17342
|
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
16857
17343
|
$ZodArray.init(inst, def);
|
|
16858
17344
|
ZodType.init(inst, def);
|
|
16859
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17345
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => arrayProcessor(inst, ctx, json7, params);
|
|
16860
17346
|
inst.element = def.element;
|
|
16861
17347
|
_installLazyMethods(inst, "ZodArray", {
|
|
16862
17348
|
min(n, params) {
|
|
@@ -16886,7 +17372,7 @@ function keyof(schema) {
|
|
|
16886
17372
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
16887
17373
|
$ZodObjectJIT.init(inst, def);
|
|
16888
17374
|
ZodType.init(inst, def);
|
|
16889
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17375
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => objectProcessor(inst, ctx, json7, params);
|
|
16890
17376
|
exports_util.defineLazy(inst, "shape", () => {
|
|
16891
17377
|
return def.shape;
|
|
16892
17378
|
});
|
|
@@ -16959,7 +17445,7 @@ function looseObject(shape, params) {
|
|
|
16959
17445
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
16960
17446
|
$ZodUnion.init(inst, def);
|
|
16961
17447
|
ZodType.init(inst, def);
|
|
16962
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17448
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => unionProcessor(inst, ctx, json7, params);
|
|
16963
17449
|
inst.options = def.options;
|
|
16964
17450
|
});
|
|
16965
17451
|
function union(options, params) {
|
|
@@ -16972,7 +17458,7 @@ function union(options, params) {
|
|
|
16972
17458
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
16973
17459
|
ZodUnion.init(inst, def);
|
|
16974
17460
|
$ZodXor.init(inst, def);
|
|
16975
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17461
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => unionProcessor(inst, ctx, json7, params);
|
|
16976
17462
|
inst.options = def.options;
|
|
16977
17463
|
});
|
|
16978
17464
|
function xor(options, params) {
|
|
@@ -16998,7 +17484,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
16998
17484
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
16999
17485
|
$ZodIntersection.init(inst, def);
|
|
17000
17486
|
ZodType.init(inst, def);
|
|
17001
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17487
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => intersectionProcessor(inst, ctx, json7, params);
|
|
17002
17488
|
});
|
|
17003
17489
|
function intersection(left, right) {
|
|
17004
17490
|
return new ZodIntersection({
|
|
@@ -17010,7 +17496,7 @@ function intersection(left, right) {
|
|
|
17010
17496
|
var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
17011
17497
|
$ZodTuple.init(inst, def);
|
|
17012
17498
|
ZodType.init(inst, def);
|
|
17013
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17499
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => tupleProcessor(inst, ctx, json7, params);
|
|
17014
17500
|
inst.rest = (rest) => inst.clone({
|
|
17015
17501
|
...inst._zod.def,
|
|
17016
17502
|
rest
|
|
@@ -17030,7 +17516,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
17030
17516
|
var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
17031
17517
|
$ZodRecord.init(inst, def);
|
|
17032
17518
|
ZodType.init(inst, def);
|
|
17033
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17519
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => recordProcessor(inst, ctx, json7, params);
|
|
17034
17520
|
inst.keyType = def.keyType;
|
|
17035
17521
|
inst.valueType = def.valueType;
|
|
17036
17522
|
});
|
|
@@ -17072,7 +17558,7 @@ function looseRecord(keyType, valueType, params) {
|
|
|
17072
17558
|
var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
17073
17559
|
$ZodMap.init(inst, def);
|
|
17074
17560
|
ZodType.init(inst, def);
|
|
17075
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17561
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => mapProcessor(inst, ctx, json7, params);
|
|
17076
17562
|
inst.keyType = def.keyType;
|
|
17077
17563
|
inst.valueType = def.valueType;
|
|
17078
17564
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -17091,7 +17577,7 @@ function map(keyType, valueType, params) {
|
|
|
17091
17577
|
var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
17092
17578
|
$ZodSet.init(inst, def);
|
|
17093
17579
|
ZodType.init(inst, def);
|
|
17094
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17580
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => setProcessor(inst, ctx, json7, params);
|
|
17095
17581
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
17096
17582
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
17097
17583
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -17107,7 +17593,7 @@ function set(valueType, params) {
|
|
|
17107
17593
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
17108
17594
|
$ZodEnum.init(inst, def);
|
|
17109
17595
|
ZodType.init(inst, def);
|
|
17110
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17596
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => enumProcessor(inst, ctx, json7, params);
|
|
17111
17597
|
inst.enum = def.entries;
|
|
17112
17598
|
inst.options = Object.values(def.entries);
|
|
17113
17599
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -17160,7 +17646,7 @@ function nativeEnum(entries, params) {
|
|
|
17160
17646
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
17161
17647
|
$ZodLiteral.init(inst, def);
|
|
17162
17648
|
ZodType.init(inst, def);
|
|
17163
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17649
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => literalProcessor(inst, ctx, json7, params);
|
|
17164
17650
|
inst.values = new Set(def.values);
|
|
17165
17651
|
Object.defineProperty(inst, "value", {
|
|
17166
17652
|
get() {
|
|
@@ -17181,7 +17667,7 @@ function literal(value, params) {
|
|
|
17181
17667
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
17182
17668
|
$ZodFile.init(inst, def);
|
|
17183
17669
|
ZodType.init(inst, def);
|
|
17184
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17670
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => fileProcessor(inst, ctx, json7, params);
|
|
17185
17671
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
17186
17672
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
17187
17673
|
inst.mime = (types2, params) => inst.check(_mime(Array.isArray(types2) ? types2 : [types2], params));
|
|
@@ -17192,7 +17678,7 @@ function file(params) {
|
|
|
17192
17678
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
17193
17679
|
$ZodTransform.init(inst, def);
|
|
17194
17680
|
ZodType.init(inst, def);
|
|
17195
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17681
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => transformProcessor(inst, ctx, json7, params);
|
|
17196
17682
|
inst._zod.parse = (payload, _ctx) => {
|
|
17197
17683
|
if (_ctx.direction === "backward") {
|
|
17198
17684
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -17232,7 +17718,7 @@ function transform(fn) {
|
|
|
17232
17718
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
17233
17719
|
$ZodOptional.init(inst, def);
|
|
17234
17720
|
ZodType.init(inst, def);
|
|
17235
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17721
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => optionalProcessor(inst, ctx, json7, params);
|
|
17236
17722
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17237
17723
|
});
|
|
17238
17724
|
function optional(innerType) {
|
|
@@ -17244,7 +17730,7 @@ function optional(innerType) {
|
|
|
17244
17730
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
17245
17731
|
$ZodExactOptional.init(inst, def);
|
|
17246
17732
|
ZodType.init(inst, def);
|
|
17247
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17733
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => optionalProcessor(inst, ctx, json7, params);
|
|
17248
17734
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17249
17735
|
});
|
|
17250
17736
|
function exactOptional(innerType) {
|
|
@@ -17256,7 +17742,7 @@ function exactOptional(innerType) {
|
|
|
17256
17742
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
17257
17743
|
$ZodNullable.init(inst, def);
|
|
17258
17744
|
ZodType.init(inst, def);
|
|
17259
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17745
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => nullableProcessor(inst, ctx, json7, params);
|
|
17260
17746
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17261
17747
|
});
|
|
17262
17748
|
function nullable(innerType) {
|
|
@@ -17271,7 +17757,7 @@ function nullish2(innerType) {
|
|
|
17271
17757
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
17272
17758
|
$ZodDefault.init(inst, def);
|
|
17273
17759
|
ZodType.init(inst, def);
|
|
17274
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17760
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => defaultProcessor(inst, ctx, json7, params);
|
|
17275
17761
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17276
17762
|
inst.removeDefault = inst.unwrap;
|
|
17277
17763
|
});
|
|
@@ -17287,7 +17773,7 @@ function _default2(innerType, defaultValue) {
|
|
|
17287
17773
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
17288
17774
|
$ZodPrefault.init(inst, def);
|
|
17289
17775
|
ZodType.init(inst, def);
|
|
17290
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17776
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => prefaultProcessor(inst, ctx, json7, params);
|
|
17291
17777
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17292
17778
|
});
|
|
17293
17779
|
function prefault(innerType, defaultValue) {
|
|
@@ -17302,7 +17788,7 @@ function prefault(innerType, defaultValue) {
|
|
|
17302
17788
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
17303
17789
|
$ZodNonOptional.init(inst, def);
|
|
17304
17790
|
ZodType.init(inst, def);
|
|
17305
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17791
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => nonoptionalProcessor(inst, ctx, json7, params);
|
|
17306
17792
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17307
17793
|
});
|
|
17308
17794
|
function nonoptional(innerType, params) {
|
|
@@ -17315,7 +17801,7 @@ function nonoptional(innerType, params) {
|
|
|
17315
17801
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
17316
17802
|
$ZodSuccess.init(inst, def);
|
|
17317
17803
|
ZodType.init(inst, def);
|
|
17318
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17804
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => successProcessor(inst, ctx, json7, params);
|
|
17319
17805
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17320
17806
|
});
|
|
17321
17807
|
function success(innerType) {
|
|
@@ -17327,7 +17813,7 @@ function success(innerType) {
|
|
|
17327
17813
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
17328
17814
|
$ZodCatch.init(inst, def);
|
|
17329
17815
|
ZodType.init(inst, def);
|
|
17330
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17816
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => catchProcessor(inst, ctx, json7, params);
|
|
17331
17817
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17332
17818
|
inst.removeCatch = inst.unwrap;
|
|
17333
17819
|
});
|
|
@@ -17341,7 +17827,7 @@ function _catch2(innerType, catchValue) {
|
|
|
17341
17827
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
17342
17828
|
$ZodNaN.init(inst, def);
|
|
17343
17829
|
ZodType.init(inst, def);
|
|
17344
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17830
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => nanProcessor(inst, ctx, json7, params);
|
|
17345
17831
|
});
|
|
17346
17832
|
function nan(params) {
|
|
17347
17833
|
return _nan(ZodNaN, params);
|
|
@@ -17349,7 +17835,7 @@ function nan(params) {
|
|
|
17349
17835
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
17350
17836
|
$ZodPipe.init(inst, def);
|
|
17351
17837
|
ZodType.init(inst, def);
|
|
17352
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17838
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => pipeProcessor(inst, ctx, json7, params);
|
|
17353
17839
|
inst.in = def.in;
|
|
17354
17840
|
inst.out = def.out;
|
|
17355
17841
|
});
|
|
@@ -17390,7 +17876,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
17390
17876
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
17391
17877
|
$ZodReadonly.init(inst, def);
|
|
17392
17878
|
ZodType.init(inst, def);
|
|
17393
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17879
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => readonlyProcessor(inst, ctx, json7, params);
|
|
17394
17880
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17395
17881
|
});
|
|
17396
17882
|
function readonly(innerType) {
|
|
@@ -17402,7 +17888,7 @@ function readonly(innerType) {
|
|
|
17402
17888
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
17403
17889
|
$ZodTemplateLiteral.init(inst, def);
|
|
17404
17890
|
ZodType.init(inst, def);
|
|
17405
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17891
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => templateLiteralProcessor(inst, ctx, json7, params);
|
|
17406
17892
|
});
|
|
17407
17893
|
function templateLiteral(parts, params) {
|
|
17408
17894
|
return new ZodTemplateLiteral({
|
|
@@ -17414,7 +17900,7 @@ function templateLiteral(parts, params) {
|
|
|
17414
17900
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
17415
17901
|
$ZodLazy.init(inst, def);
|
|
17416
17902
|
ZodType.init(inst, def);
|
|
17417
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17903
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => lazyProcessor(inst, ctx, json7, params);
|
|
17418
17904
|
inst.unwrap = () => inst._zod.def.getter();
|
|
17419
17905
|
});
|
|
17420
17906
|
function lazy(getter) {
|
|
@@ -17426,7 +17912,7 @@ function lazy(getter) {
|
|
|
17426
17912
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
17427
17913
|
$ZodPromise.init(inst, def);
|
|
17428
17914
|
ZodType.init(inst, def);
|
|
17429
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17915
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => promiseProcessor(inst, ctx, json7, params);
|
|
17430
17916
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
17431
17917
|
});
|
|
17432
17918
|
function promise(innerType) {
|
|
@@ -17438,7 +17924,7 @@ function promise(innerType) {
|
|
|
17438
17924
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
17439
17925
|
$ZodFunction.init(inst, def);
|
|
17440
17926
|
ZodType.init(inst, def);
|
|
17441
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17927
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => functionProcessor(inst, ctx, json7, params);
|
|
17442
17928
|
});
|
|
17443
17929
|
function _function(params) {
|
|
17444
17930
|
return new ZodFunction({
|
|
@@ -17450,7 +17936,7 @@ function _function(params) {
|
|
|
17450
17936
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
17451
17937
|
$ZodCustom.init(inst, def);
|
|
17452
17938
|
ZodType.init(inst, def);
|
|
17453
|
-
inst._zod.processJSONSchema = (ctx,
|
|
17939
|
+
inst._zod.processJSONSchema = (ctx, json7, params) => customProcessor(inst, ctx, json7, params);
|
|
17454
17940
|
});
|
|
17455
17941
|
function check(fn) {
|
|
17456
17942
|
const ch = new $ZodCheck({
|
|
@@ -17497,7 +17983,7 @@ var stringbool = (...args) => _stringbool({
|
|
|
17497
17983
|
Boolean: ZodBoolean,
|
|
17498
17984
|
String: ZodString
|
|
17499
17985
|
}, ...args);
|
|
17500
|
-
function
|
|
17986
|
+
function json7(params) {
|
|
17501
17987
|
const jsonSchema = lazy(() => {
|
|
17502
17988
|
return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
|
|
17503
17989
|
});
|
|
@@ -18105,6 +18591,7 @@ var targetSchema = exports_external.discriminatedUnion("provider", [
|
|
|
18105
18591
|
}),
|
|
18106
18592
|
contextWindow: exports_external.number().int().positive().optional(),
|
|
18107
18593
|
maxOutputTokens: exports_external.number().int().positive().optional(),
|
|
18594
|
+
credentialId: exports_external.string().trim().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/, "credentialId must be an account id").optional(),
|
|
18108
18595
|
capabilities: exports_external.object({
|
|
18109
18596
|
tools: exports_external.boolean(),
|
|
18110
18597
|
images: exports_external.boolean(),
|
|
@@ -18126,6 +18613,7 @@ var targetSchema = exports_external.discriminatedUnion("provider", [
|
|
|
18126
18613
|
}),
|
|
18127
18614
|
contextWindow: exports_external.number().int().positive().optional(),
|
|
18128
18615
|
maxOutputTokens: exports_external.number().int().positive().optional(),
|
|
18616
|
+
credentialId: exports_external.string().trim().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/, "credentialId must be an account id").optional(),
|
|
18129
18617
|
capabilities: exports_external.object({
|
|
18130
18618
|
tools: exports_external.boolean(),
|
|
18131
18619
|
images: exports_external.boolean(),
|
|
@@ -18134,9 +18622,7 @@ var targetSchema = exports_external.discriminatedUnion("provider", [
|
|
|
18134
18622
|
}).strict()
|
|
18135
18623
|
]);
|
|
18136
18624
|
var modelSchema = exports_external.object({
|
|
18137
|
-
id: exports_external.string().min(1)
|
|
18138
|
-
message: 'model id must not start with "claude/": that prefix is reserved for discovery mirrors'
|
|
18139
|
-
}),
|
|
18625
|
+
id: exports_external.string().min(1),
|
|
18140
18626
|
strategy: exports_external.enum(["score", "priority", "roundRobin", "weighted"]),
|
|
18141
18627
|
isAlias: exports_external.boolean(),
|
|
18142
18628
|
targets: exports_external.array(targetSchema).min(1, "a virtual model needs at least one target")
|
|
@@ -18148,6 +18634,9 @@ var keyCreateSchema = exports_external.object({
|
|
|
18148
18634
|
bodyLoggingOptOut: exports_external.boolean().default(false)
|
|
18149
18635
|
}).strict();
|
|
18150
18636
|
var keyLimitsSchema = exports_external.object({ limits: limitConfigSchema }).strict();
|
|
18637
|
+
var keyModelsSchema = exports_external.object({
|
|
18638
|
+
modelAllowlist: exports_external.array(exports_external.string().min(1)).nullable()
|
|
18639
|
+
}).strict();
|
|
18151
18640
|
var retentionSchema = exports_external.object({
|
|
18152
18641
|
keepLatest: exports_external.number().int().min(1).max(100),
|
|
18153
18642
|
maxAgeDays: exports_external.number().int().min(1).max(3650)
|
|
@@ -18245,13 +18734,76 @@ async function readSource(deps, source, lines) {
|
|
|
18245
18734
|
]);
|
|
18246
18735
|
return result.code === 0 ? result.stdout : "";
|
|
18247
18736
|
}
|
|
18737
|
+
function parseConsoleLines(text, query) {
|
|
18738
|
+
const lines = consoleLimit(query.lines);
|
|
18739
|
+
return text.split(`
|
|
18740
|
+
`).filter((raw) => raw.trim().length > 0).map(parseLine).filter((line) => keep(line, query)).slice(-lines);
|
|
18741
|
+
}
|
|
18248
18742
|
async function readConsole(deps, source, query) {
|
|
18249
18743
|
const limited = { ...query, lines: consoleLimit(query.lines) };
|
|
18250
18744
|
const text = await readSource(deps, source, scanWidth(limited));
|
|
18251
|
-
const lines = text
|
|
18252
|
-
`).filter((raw) => raw.trim().length > 0).map(parseLine).filter((line) => keep(line, limited)).slice(-limited.lines);
|
|
18745
|
+
const lines = parseConsoleLines(text, limited);
|
|
18253
18746
|
return source.kind === "file" ? { source: "file", path: source.path, lines } : { source: source.kind, lines };
|
|
18254
18747
|
}
|
|
18748
|
+
// packages/store/src/types.ts
|
|
18749
|
+
var WINDOW_DURATION_MS = {
|
|
18750
|
+
fiveHour: 5 * 60 * 60 * 1000,
|
|
18751
|
+
daily: 24 * 60 * 60 * 1000,
|
|
18752
|
+
weekly: 7 * 24 * 60 * 60 * 1000
|
|
18753
|
+
};
|
|
18754
|
+
function durationFor(windowType, windowMs) {
|
|
18755
|
+
return windowMs !== null && windowMs > 0 ? windowMs : WINDOW_DURATION_MS[windowType];
|
|
18756
|
+
}
|
|
18757
|
+
var SAME_WINDOW_TOLERANCE_MS = 60000;
|
|
18758
|
+
function sameWindow(a, b) {
|
|
18759
|
+
if (a === null || b === null)
|
|
18760
|
+
return a === b;
|
|
18761
|
+
return Math.abs(a - b) <= SAME_WINDOW_TOLERANCE_MS;
|
|
18762
|
+
}
|
|
18763
|
+
function quotaVerdict(window, estimate) {
|
|
18764
|
+
if (estimate === undefined)
|
|
18765
|
+
return "unknown";
|
|
18766
|
+
if (window.observedAt > 0 && estimate.stale)
|
|
18767
|
+
return "stale";
|
|
18768
|
+
if (estimate.ratePerHour === null || window.limit === null)
|
|
18769
|
+
return "unknown";
|
|
18770
|
+
if (estimate.survives === false && estimate.exhaustsAt !== null)
|
|
18771
|
+
return "empty";
|
|
18772
|
+
return estimate.survives === true ? "ok" : "unknown";
|
|
18773
|
+
}
|
|
18774
|
+
var READ_OVER_INPUT = 0.1;
|
|
18775
|
+
function cacheReadRate(prices) {
|
|
18776
|
+
return prices.cacheRead ?? prices.input * READ_OVER_INPUT;
|
|
18777
|
+
}
|
|
18778
|
+
function servesTarget(target, account) {
|
|
18779
|
+
if (account.provider !== target.provider)
|
|
18780
|
+
return false;
|
|
18781
|
+
if (target.provider === "custom" && account.providerData.endpointId !== target.endpointId) {
|
|
18782
|
+
return false;
|
|
18783
|
+
}
|
|
18784
|
+
return target.credentialId === undefined || account.id === target.credentialId;
|
|
18785
|
+
}
|
|
18786
|
+
function resolvePin(target, accounts) {
|
|
18787
|
+
if (target.credentialId === undefined)
|
|
18788
|
+
return;
|
|
18789
|
+
return accounts.find((account) => servesTarget(target, account));
|
|
18790
|
+
}
|
|
18791
|
+
var DEFAULT_SETTINGS = {
|
|
18792
|
+
weights: { tier: 10, health: 3, quota: 2, load: 2, cost: 1, latency: 1 },
|
|
18793
|
+
maxAttempts: 3,
|
|
18794
|
+
requestDeadlineMs: 120000,
|
|
18795
|
+
breakerThreshold: 3,
|
|
18796
|
+
breakerCooldownMs: 30000,
|
|
18797
|
+
logRetentionDays: 30,
|
|
18798
|
+
quotaPollIntervalMs: 300000,
|
|
18799
|
+
rtkEnabled: false,
|
|
18800
|
+
autoCacheEnabled: true,
|
|
18801
|
+
bodyLoggingEnabled: false,
|
|
18802
|
+
bodyLoggingCaptureStreamChunks: false,
|
|
18803
|
+
snapshotKeepLatest: 5,
|
|
18804
|
+
snapshotMaxAgeDays: 30
|
|
18805
|
+
};
|
|
18806
|
+
|
|
18255
18807
|
// packages/router/src/snapshot.ts
|
|
18256
18808
|
var HEALTH_KEY_SEP = "::";
|
|
18257
18809
|
function healthKey(credentialId, model) {
|
|
@@ -18311,12 +18863,11 @@ function eligible(input) {
|
|
|
18311
18863
|
const excluded = [];
|
|
18312
18864
|
for (const target of model.targets) {
|
|
18313
18865
|
const missing = needNative && !ANTHROPIC_NATIVE_TOOLS[target.provider] ? "anthropicTools" : ["tools", "images", "reasoning"].find((cap) => need[cap] && !target.capabilities[cap]);
|
|
18866
|
+
let pinSeen = false;
|
|
18314
18867
|
for (const credential of snapshot.credentials) {
|
|
18315
|
-
if (credential
|
|
18316
|
-
continue;
|
|
18317
|
-
if (target.provider === "custom" && credential.providerData.endpointId !== target.endpointId) {
|
|
18868
|
+
if (!servesTarget(target, credential))
|
|
18318
18869
|
continue;
|
|
18319
|
-
|
|
18870
|
+
pinSeen = target.credentialId !== undefined;
|
|
18320
18871
|
const drop = (reason) => {
|
|
18321
18872
|
excluded.push({ credentialId: credential.id, model: target.model, reason });
|
|
18322
18873
|
};
|
|
@@ -18353,56 +18904,17 @@ function eligible(input) {
|
|
|
18353
18904
|
}
|
|
18354
18905
|
pairs.push({ credential, target });
|
|
18355
18906
|
}
|
|
18907
|
+
if (target.credentialId !== undefined && !pinSeen) {
|
|
18908
|
+
excluded.push({
|
|
18909
|
+
credentialId: target.credentialId,
|
|
18910
|
+
model: target.model,
|
|
18911
|
+
reason: "pin:missing"
|
|
18912
|
+
});
|
|
18913
|
+
}
|
|
18356
18914
|
}
|
|
18357
18915
|
return { pairs, excluded };
|
|
18358
18916
|
}
|
|
18359
18917
|
|
|
18360
|
-
// packages/store/src/types.ts
|
|
18361
|
-
var WINDOW_DURATION_MS = {
|
|
18362
|
-
fiveHour: 5 * 60 * 60 * 1000,
|
|
18363
|
-
daily: 24 * 60 * 60 * 1000,
|
|
18364
|
-
weekly: 7 * 24 * 60 * 60 * 1000
|
|
18365
|
-
};
|
|
18366
|
-
function durationFor(windowType, windowMs) {
|
|
18367
|
-
return windowMs !== null && windowMs > 0 ? windowMs : WINDOW_DURATION_MS[windowType];
|
|
18368
|
-
}
|
|
18369
|
-
var SAME_WINDOW_TOLERANCE_MS = 60000;
|
|
18370
|
-
function sameWindow(a, b) {
|
|
18371
|
-
if (a === null || b === null)
|
|
18372
|
-
return a === b;
|
|
18373
|
-
return Math.abs(a - b) <= SAME_WINDOW_TOLERANCE_MS;
|
|
18374
|
-
}
|
|
18375
|
-
function quotaVerdict(window, estimate) {
|
|
18376
|
-
if (estimate === undefined)
|
|
18377
|
-
return "unknown";
|
|
18378
|
-
if (window.observedAt > 0 && estimate.stale)
|
|
18379
|
-
return "stale";
|
|
18380
|
-
if (estimate.ratePerHour === null || window.limit === null)
|
|
18381
|
-
return "unknown";
|
|
18382
|
-
if (estimate.survives === false && estimate.exhaustsAt !== null)
|
|
18383
|
-
return "empty";
|
|
18384
|
-
return estimate.survives === true ? "ok" : "unknown";
|
|
18385
|
-
}
|
|
18386
|
-
var READ_OVER_INPUT = 0.1;
|
|
18387
|
-
function cacheReadRate(prices) {
|
|
18388
|
-
return prices.cacheRead ?? prices.input * READ_OVER_INPUT;
|
|
18389
|
-
}
|
|
18390
|
-
var DEFAULT_SETTINGS = {
|
|
18391
|
-
weights: { tier: 10, health: 3, quota: 2, load: 2, cost: 1, latency: 1 },
|
|
18392
|
-
maxAttempts: 3,
|
|
18393
|
-
requestDeadlineMs: 120000,
|
|
18394
|
-
breakerThreshold: 3,
|
|
18395
|
-
breakerCooldownMs: 30000,
|
|
18396
|
-
logRetentionDays: 30,
|
|
18397
|
-
quotaPollIntervalMs: 300000,
|
|
18398
|
-
rtkEnabled: false,
|
|
18399
|
-
autoCacheEnabled: true,
|
|
18400
|
-
bodyLoggingEnabled: false,
|
|
18401
|
-
bodyLoggingCaptureStreamChunks: false,
|
|
18402
|
-
snapshotKeepLatest: 5,
|
|
18403
|
-
snapshotMaxAgeDays: 30
|
|
18404
|
-
};
|
|
18405
|
-
|
|
18406
18918
|
// packages/router/src/quota.ts
|
|
18407
18919
|
var UNKNOWN_QUOTA = 0.5;
|
|
18408
18920
|
var QUOTA_FLOOR = 0.1;
|
|
@@ -18749,10 +19261,10 @@ function prepareArtifact(input) {
|
|
|
18749
19261
|
attempts,
|
|
18750
19262
|
error: error51.value
|
|
18751
19263
|
};
|
|
18752
|
-
const
|
|
18753
|
-
const size = encoder2.encode(
|
|
19264
|
+
const json8 = JSON.stringify(bounded);
|
|
19265
|
+
const size = encoder2.encode(json8).length;
|
|
18754
19266
|
if (size <= MAX_ARTIFACT_BYTES)
|
|
18755
|
-
return { artifact: bounded, json:
|
|
19267
|
+
return { artifact: bounded, json: json8 };
|
|
18756
19268
|
const marker = omission(size);
|
|
18757
19269
|
const omitted = omitBodies(bounded, marker);
|
|
18758
19270
|
const omittedJson = JSON.stringify(omitted);
|
|
@@ -18762,8 +19274,8 @@ function prepareArtifact(input) {
|
|
|
18762
19274
|
const stripped = { ...omitted, error: marker };
|
|
18763
19275
|
return { artifact: stripped, json: JSON.stringify(stripped) };
|
|
18764
19276
|
}
|
|
18765
|
-
async function sealArtifact(key,
|
|
18766
|
-
const bytes = encoder2.encode(await encrypt(key,
|
|
19277
|
+
async function sealArtifact(key, json8) {
|
|
19278
|
+
const bytes = encoder2.encode(await encrypt(key, json8));
|
|
18767
19279
|
return { bytes, sha256: await sha256Hex(bytes) };
|
|
18768
19280
|
}
|
|
18769
19281
|
async function readArtifact(key, dir, relPath, expectedSha256) {
|
|
@@ -20082,6 +20594,12 @@ function createKeyRepo(db, logger2 = noopLogger) {
|
|
|
20082
20594
|
id
|
|
20083
20595
|
]);
|
|
20084
20596
|
},
|
|
20597
|
+
async setModelAllowlist(id, modelAllowlist) {
|
|
20598
|
+
db.run("UPDATE api_keys SET model_allowlist = ? WHERE id = ?", [
|
|
20599
|
+
modelAllowlist === null ? null : JSON.stringify(modelAllowlist),
|
|
20600
|
+
id
|
|
20601
|
+
]);
|
|
20602
|
+
},
|
|
20085
20603
|
async revoke(id) {
|
|
20086
20604
|
db.run("UPDATE api_keys SET revoked_at = ? WHERE id = ?", [Date.now(), id]);
|
|
20087
20605
|
}
|
|
@@ -20710,6 +21228,7 @@ async function createStore(opts) {
|
|
|
20710
21228
|
findByHash: (hash3) => handle.keys.findByHash(hash3),
|
|
20711
21229
|
create: (input) => handle.keys.create(input),
|
|
20712
21230
|
setLimits: (id, limits) => handle.keys.setLimits(id, limits),
|
|
21231
|
+
setModelAllowlist: (id, modelAllowlist) => handle.keys.setModelAllowlist(id, modelAllowlist),
|
|
20713
21232
|
revoke: (id) => handle.keys.revoke(id)
|
|
20714
21233
|
},
|
|
20715
21234
|
usage: {
|
|
@@ -20859,13 +21378,15 @@ function customProviderData(input) {
|
|
|
20859
21378
|
} catch {
|
|
20860
21379
|
throw new GatewayError("BAD_REQUEST", "origin: must be a valid URL");
|
|
20861
21380
|
}
|
|
20862
|
-
if (url2.protocol !== "http:" && url2.protocol !== "https:" || url2.hostname.length === 0 || url2.username.length > 0 || url2.password.length > 0 || url2.
|
|
21381
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:" || url2.hostname.length === 0 || url2.username.length > 0 || url2.password.length > 0 || url2.search.length > 0 || url2.hash.length > 0) {
|
|
20863
21382
|
throw new GatewayError("BAD_REQUEST", "origin: must be an HTTP(S) server origin");
|
|
20864
21383
|
}
|
|
20865
|
-
|
|
21384
|
+
const basePath = url2.pathname.replace(/\/+$/, "");
|
|
21385
|
+
return { endpointId, endpointLabel, origin: url2.origin, basePath, protocol: input.protocol };
|
|
20866
21386
|
}
|
|
20867
21387
|
function sameCustomEndpoint(a, b) {
|
|
20868
|
-
|
|
21388
|
+
const basePath = typeof a.basePath === "string" ? a.basePath : "";
|
|
21389
|
+
return a.endpointId === b.endpointId && a.endpointLabel === b.endpointLabel && a.origin === b.origin && basePath === b.basePath && a.protocol === b.protocol;
|
|
20869
21390
|
}
|
|
20870
21391
|
async function createApiKeyCredential(store, input, logger2 = noopLogger) {
|
|
20871
21392
|
const provider = parseOrThrow(providerIdSchema, input.provider);
|
|
@@ -21341,6 +21862,14 @@ async function setKeyLimits(store, id, input, now = Date.now()) {
|
|
|
21341
21862
|
await store.keys.setLimits(id, body2.limits);
|
|
21342
21863
|
return toSummary(store, { ...key, limits: body2.limits }, now);
|
|
21343
21864
|
}
|
|
21865
|
+
async function setKeyModels(store, id, input, now = Date.now()) {
|
|
21866
|
+
const body2 = parseOrThrow(keyModelsSchema, input);
|
|
21867
|
+
const key = (await store.keys.list()).find((entry) => entry.id === id);
|
|
21868
|
+
if (key === undefined)
|
|
21869
|
+
throw new GatewayError("BAD_REQUEST", "no such api key");
|
|
21870
|
+
await store.keys.setModelAllowlist(id, body2.modelAllowlist);
|
|
21871
|
+
return toSummary(store, { ...key, modelAllowlist: body2.modelAllowlist }, now);
|
|
21872
|
+
}
|
|
21344
21873
|
async function revokeKey(store, id) {
|
|
21345
21874
|
await store.keys.revoke(id);
|
|
21346
21875
|
}
|
|
@@ -21353,8 +21882,8 @@ function narrower(a, b) {
|
|
|
21353
21882
|
...output.length === 0 ? {} : { maxOutputTokens: Math.min(...output) }
|
|
21354
21883
|
};
|
|
21355
21884
|
}
|
|
21356
|
-
function targetLimits(target, auths) {
|
|
21357
|
-
const ways = auths.size === 0 ? ["apiKey"] : [...auths];
|
|
21885
|
+
function targetLimits(target, auths, pinned) {
|
|
21886
|
+
const ways = pinned !== undefined ? [pinned.authType] : auths.size === 0 ? ["apiKey"] : [...auths];
|
|
21358
21887
|
let listed = {};
|
|
21359
21888
|
for (const auth of ways) {
|
|
21360
21889
|
const entry = catalogLimits(target.provider, target.model, auth);
|
|
@@ -21374,20 +21903,22 @@ function targetLimits(target, auths) {
|
|
|
21374
21903
|
}
|
|
21375
21904
|
function servingAuths(credentials) {
|
|
21376
21905
|
const byProvider = new Map;
|
|
21906
|
+
const routable = [];
|
|
21377
21907
|
for (const credential of credentials) {
|
|
21378
21908
|
if (!credential.enabled)
|
|
21379
21909
|
continue;
|
|
21380
21910
|
const ways = byProvider.get(credential.provider) ?? new Set;
|
|
21381
21911
|
ways.add(credential.authType);
|
|
21382
21912
|
byProvider.set(credential.provider, ways);
|
|
21913
|
+
routable.push(credential);
|
|
21383
21914
|
}
|
|
21384
|
-
return byProvider;
|
|
21915
|
+
return { byProvider, routable };
|
|
21385
21916
|
}
|
|
21386
21917
|
function resolveModelLimits(model, credentials) {
|
|
21387
|
-
const
|
|
21918
|
+
const { byProvider, routable } = servingAuths(credentials);
|
|
21388
21919
|
let limits = {};
|
|
21389
21920
|
for (const target of model.targets) {
|
|
21390
|
-
limits = narrower(limits, targetLimits(target,
|
|
21921
|
+
limits = narrower(limits, targetLimits(target, byProvider.get(target.provider) ?? new Set, resolvePin(target, routable)));
|
|
21391
21922
|
}
|
|
21392
21923
|
return limits;
|
|
21393
21924
|
}
|
|
@@ -21431,15 +21962,18 @@ function unreachable(model, credentials, stored) {
|
|
|
21431
21962
|
const held = heldAuths(credentials);
|
|
21432
21963
|
const grandfathered = new Set((stored?.targets ?? []).map(pairOf));
|
|
21433
21964
|
for (const target of model.targets) {
|
|
21434
|
-
|
|
21965
|
+
const pinned = resolvePin(target, credentials);
|
|
21966
|
+
if (pinned === undefined && grandfathered.has(pairOf(target)))
|
|
21435
21967
|
continue;
|
|
21436
|
-
const have = held.get(target.provider);
|
|
21968
|
+
const have = pinned === undefined ? held.get(target.provider) : new Set([pinned.authType]);
|
|
21437
21969
|
if (have === undefined)
|
|
21438
21970
|
continue;
|
|
21439
21971
|
const reach = catalogModelAuths(target.provider, target.model);
|
|
21440
21972
|
if (reach.some((auth) => have.has(auth)))
|
|
21441
21973
|
continue;
|
|
21442
|
-
|
|
21974
|
+
const holds = pinned === undefined ? `every ${target.provider} credential here is ${phrase([...have])}` : `this target is pinned to "${pinned.label}", which is ${phrase([...have])}`;
|
|
21975
|
+
const fix = pinned === undefined ? "connect the other kind, or pick a model this one can reach" : "pin it to the other kind, or pick a model this account can reach";
|
|
21976
|
+
return new GatewayError("BAD_REQUEST", `${target.provider} serves "${target.model}" to ${phrase(reach)} credentials only, ` + `and ${holds} \u2014 ${fix}`);
|
|
21443
21977
|
}
|
|
21444
21978
|
return null;
|
|
21445
21979
|
}
|
|
@@ -21483,14 +22017,15 @@ import { basename as basename2, join as join3, resolve as resolve2, sep as sep2
|
|
|
21483
22017
|
|
|
21484
22018
|
// packages/plugin-api/src/version.ts
|
|
21485
22019
|
var PLUGIN_API_VERSION = 1;
|
|
21486
|
-
var DASHBOARD_SDK_VERSION = "0.1.
|
|
22020
|
+
var DASHBOARD_SDK_VERSION = "0.1.2";
|
|
21487
22021
|
// packages/plugin-api/src/manifest.ts
|
|
21488
22022
|
var CAPABILITIES = [
|
|
21489
22023
|
"storage",
|
|
21490
22024
|
"files",
|
|
21491
22025
|
"net:outbound",
|
|
21492
22026
|
"events:request",
|
|
21493
|
-
"events:limit"
|
|
22027
|
+
"events:limit",
|
|
22028
|
+
"channels"
|
|
21494
22029
|
];
|
|
21495
22030
|
var ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
21496
22031
|
var idSchema = exports_external.string().regex(ID_PATTERN, "id must match /^[a-z][a-z0-9-]{0,31}$/");
|
|
@@ -22506,10 +23041,10 @@ function emailFromIdToken(idToken) {
|
|
|
22506
23041
|
if (parts.length !== 3 || payload === undefined || payload.length === 0)
|
|
22507
23042
|
return null;
|
|
22508
23043
|
try {
|
|
22509
|
-
const
|
|
22510
|
-
if (!isRecord2(
|
|
23044
|
+
const json8 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
23045
|
+
if (!isRecord2(json8))
|
|
22511
23046
|
return null;
|
|
22512
|
-
return typeof
|
|
23047
|
+
return typeof json8.email === "string" && json8.email.trim().length > 0 ? json8.email : null;
|
|
22513
23048
|
} catch {
|
|
22514
23049
|
return null;
|
|
22515
23050
|
}
|
|
@@ -22912,12 +23447,12 @@ function decodeClaims(idToken) {
|
|
|
22912
23447
|
return { email: null, accountId: null };
|
|
22913
23448
|
}
|
|
22914
23449
|
try {
|
|
22915
|
-
const
|
|
22916
|
-
if (!isRecord5(
|
|
23450
|
+
const json8 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
23451
|
+
if (!isRecord5(json8))
|
|
22917
23452
|
return { email: null, accountId: null };
|
|
22918
|
-
const auth =
|
|
23453
|
+
const auth = json8["https://api.openai.com/auth"];
|
|
22919
23454
|
return {
|
|
22920
|
-
email: typeof
|
|
23455
|
+
email: typeof json8.email === "string" ? json8.email : null,
|
|
22921
23456
|
accountId: isRecord5(auth) ? nonBlankStringOrNull(auth.chatgpt_account_id) : null
|
|
22922
23457
|
};
|
|
22923
23458
|
} catch {
|
|
@@ -23188,9 +23723,11 @@ var KEY_PLACEHOLDER = "<your OmniGateway key>";
|
|
|
23188
23723
|
async function describeModelsForSetup(store) {
|
|
23189
23724
|
const models = await listModels(store);
|
|
23190
23725
|
const credentials = (await listCredentials(store)).map((credential) => ({
|
|
23726
|
+
id: credential.id,
|
|
23191
23727
|
provider: credential.provider,
|
|
23192
23728
|
authType: credential.authType,
|
|
23193
|
-
enabled: credential.enabled
|
|
23729
|
+
enabled: credential.enabled,
|
|
23730
|
+
providerData: credential.providerData
|
|
23194
23731
|
}));
|
|
23195
23732
|
return models.map((model) => ({
|
|
23196
23733
|
model,
|
|
@@ -23226,8 +23763,7 @@ function claudeSettings(described, input, mapping, existing) {
|
|
|
23226
23763
|
const visibleId = (slot, id) => {
|
|
23227
23764
|
if (!ids.has(id))
|
|
23228
23765
|
throw new Error(`${slot} names unknown virtual model "${id}"`);
|
|
23229
|
-
|
|
23230
|
-
return useMirror ? `claude/${id}` : id;
|
|
23766
|
+
return id;
|
|
23231
23767
|
};
|
|
23232
23768
|
const settings = settingsObject(existing);
|
|
23233
23769
|
const currentEnv = settings.env;
|
|
@@ -24113,7 +24649,8 @@ var credentialsRemove = {
|
|
|
24113
24649
|
async run(args, { ctx, writer, prompt }) {
|
|
24114
24650
|
const id = requirePositional(args, 0, "credential id");
|
|
24115
24651
|
const credential = await findCredential(ctx, id);
|
|
24116
|
-
const
|
|
24652
|
+
const pinned = (await listModels(await ctx.store())).filter((model) => model.targets.some((target) => target.credentialId === id)).map((model) => model.id);
|
|
24653
|
+
const confirmed = await prompt.confirm(`delete ${credential.provider} credential "${credential.label}" (${id})?` + (pinned.length === 0 ? "" : ` ${pinned.length === 1 ? "model" : "models"} ${pinned.join(", ")} ` + `${pinned.length === 1 ? "pins a target" : "pin targets"} to it, and ` + `${pinned.length === 1 ? "that target" : "those targets"} will fail rather than ` + "fall back to another account."));
|
|
24117
24654
|
if (!confirmed)
|
|
24118
24655
|
throw new CliError("cancelled");
|
|
24119
24656
|
await removeCredential(await ctx.store(), id);
|
|
@@ -24161,13 +24698,14 @@ var credentialsAddKey = {
|
|
|
24161
24698
|
const store = await ctx.store();
|
|
24162
24699
|
const endpointId = stringFlag(args.values, "endpoint-id");
|
|
24163
24700
|
const existingEndpoint = providerId === "custom" && endpointId !== undefined ? (await listCredentials(store)).find((credential) => credential.provider === "custom" && credential.providerData.endpointId === endpointId.trim()) : undefined;
|
|
24701
|
+
const existingOrigin = existingEndpoint === undefined ? undefined : `${String(existingEndpoint.providerData.origin)}${typeof existingEndpoint.providerData.basePath === "string" ? existingEndpoint.providerData.basePath : ""}`;
|
|
24164
24702
|
const created = await createApiKeyCredential(store, {
|
|
24165
24703
|
provider: providerId,
|
|
24166
24704
|
apiKey: key,
|
|
24167
24705
|
label: stringFlag(args.values, "label"),
|
|
24168
24706
|
endpointId,
|
|
24169
24707
|
endpointLabel: stringFlag(args.values, "endpoint-label") ?? existingEndpoint?.providerData.endpointLabel,
|
|
24170
|
-
origin: stringFlag(args.values, "origin") ??
|
|
24708
|
+
origin: stringFlag(args.values, "origin") ?? existingOrigin,
|
|
24171
24709
|
protocol: protocol ?? existingEndpoint?.providerData.protocol
|
|
24172
24710
|
});
|
|
24173
24711
|
emit(ctx, writer, { id: created.id, provider: created.provider }, () => `stored ${created.provider} api key as ${created.id}`);
|
|
@@ -24579,6 +25117,43 @@ var keysRevoke = {
|
|
|
24579
25117
|
emit(ctx, writer, { id, revoked: true }, () => `${id} revoked`);
|
|
24580
25118
|
}
|
|
24581
25119
|
};
|
|
25120
|
+
var keysModels = {
|
|
25121
|
+
usage: "keys models <id> [--allow <model> ...] [--all] [--none]",
|
|
25122
|
+
summary: "Show or replace one key's allowed models",
|
|
25123
|
+
options: {
|
|
25124
|
+
allow: { type: "string", multiple: true },
|
|
25125
|
+
all: { type: "boolean" },
|
|
25126
|
+
none: { type: "boolean" }
|
|
25127
|
+
},
|
|
25128
|
+
async run(args, { ctx, writer }) {
|
|
25129
|
+
const id = requirePositional(args, 0, "key id");
|
|
25130
|
+
const allow = listFlag(args.values, "allow");
|
|
25131
|
+
const all = boolFlag(args.values, "all");
|
|
25132
|
+
const none = boolFlag(args.values, "none");
|
|
25133
|
+
const store = await ctx.store();
|
|
25134
|
+
const existing = (await listKeys(store)).find((entry) => entry.id === id);
|
|
25135
|
+
if (existing === undefined)
|
|
25136
|
+
throw new CliError(`no api key "${id}"`);
|
|
25137
|
+
let key = existing;
|
|
25138
|
+
if (all || none || allow !== undefined) {
|
|
25139
|
+
if ([all, none, allow !== undefined].filter(Boolean).length > 1) {
|
|
25140
|
+
throw new UsageError("--all, --none, and --allow cannot be combined");
|
|
25141
|
+
}
|
|
25142
|
+
const next = all ? null : none ? [] : allow ?? [];
|
|
25143
|
+
key = await setKeyModels(store, id, { modelAllowlist: next });
|
|
25144
|
+
}
|
|
25145
|
+
emit(ctx, writer, key, () => {
|
|
25146
|
+
const head = fields([
|
|
25147
|
+
["id", key.id],
|
|
25148
|
+
["label", key.label],
|
|
25149
|
+
["prefix", `${key.prefix}\u2026`]
|
|
25150
|
+
]);
|
|
25151
|
+
const models = key.modelAllowlist === null ? "every model" : key.modelAllowlist.length === 0 ? "no models; every request this key makes is refused" : key.modelAllowlist.join(", ");
|
|
25152
|
+
return `${head}
|
|
25153
|
+
models: ${models}`;
|
|
25154
|
+
});
|
|
25155
|
+
}
|
|
25156
|
+
};
|
|
24582
25157
|
|
|
24583
25158
|
// apps/cli/src/commands/models.ts
|
|
24584
25159
|
var modelsList = {
|
|
@@ -24611,6 +25186,7 @@ var modelsShow = {
|
|
|
24611
25186
|
async run(args, { ctx, writer }) {
|
|
24612
25187
|
const id = requirePositional(args, 0, "model id");
|
|
24613
25188
|
const model = await getModel(await ctx.store(), id);
|
|
25189
|
+
const pinned = model.targets.some((target) => target.credentialId !== undefined);
|
|
24614
25190
|
emit(ctx, writer, { model }, () => [
|
|
24615
25191
|
fields([
|
|
24616
25192
|
["id", model.id],
|
|
@@ -24621,6 +25197,7 @@ var modelsShow = {
|
|
|
24621
25197
|
table([
|
|
24622
25198
|
{ header: "PROVIDER" },
|
|
24623
25199
|
{ header: "MODEL" },
|
|
25200
|
+
...pinned ? [{ header: "ACCOUNT" }] : [],
|
|
24624
25201
|
{ header: "TIER", align: "right" },
|
|
24625
25202
|
{ header: "WEIGHT", align: "right" },
|
|
24626
25203
|
{ header: "IN $/MTOK", align: "right" },
|
|
@@ -24634,6 +25211,7 @@ var modelsShow = {
|
|
|
24634
25211
|
], model.targets.map((target) => [
|
|
24635
25212
|
provider(ctx, target.provider),
|
|
24636
25213
|
target.model,
|
|
25214
|
+
...pinned ? [target.credentialId ?? "any"] : [],
|
|
24637
25215
|
String(target.tier),
|
|
24638
25216
|
String(target.weight),
|
|
24639
25217
|
target.costPerMTok.input.toFixed(2),
|
|
@@ -25297,6 +25875,17 @@ async function orphanTables(ctx) {
|
|
|
25297
25875
|
return null;
|
|
25298
25876
|
}
|
|
25299
25877
|
}
|
|
25878
|
+
async function danglingPins(ctx) {
|
|
25879
|
+
if (ctx.configError !== null || !existsSync5(ctx.databasePath))
|
|
25880
|
+
return null;
|
|
25881
|
+
try {
|
|
25882
|
+
const store = await ctx.store();
|
|
25883
|
+
const accounts = await store.credentials.list();
|
|
25884
|
+
return (await store.config.listModels()).flatMap((model) => model.targets.filter((target) => target.credentialId !== undefined && resolvePin(target, accounts) === undefined).map((target) => `${model.id}/${target.model} \u2192 ${target.credentialId}`));
|
|
25885
|
+
} catch {
|
|
25886
|
+
return null;
|
|
25887
|
+
}
|
|
25888
|
+
}
|
|
25300
25889
|
var doctor = {
|
|
25301
25890
|
usage: "doctor",
|
|
25302
25891
|
summary: "Check what this CLI resolved, and whether it can do anything with it",
|
|
@@ -25309,6 +25898,7 @@ var doctor = {
|
|
|
25309
25898
|
const usageRollup = await rollupState(ctx);
|
|
25310
25899
|
const plugins = listPlugins(doctorPluginDeps(), deps.root);
|
|
25311
25900
|
const orphans = await orphanTables(ctx);
|
|
25901
|
+
const pins = await danglingPins(ctx);
|
|
25312
25902
|
const checks3 = {
|
|
25313
25903
|
root: deps.root,
|
|
25314
25904
|
rootSource: ctx.root.source,
|
|
@@ -25326,6 +25916,7 @@ var doctor = {
|
|
|
25326
25916
|
pluginsDir: pluginsDir(deps.root),
|
|
25327
25917
|
plugins,
|
|
25328
25918
|
orphanPluginTables: orphans,
|
|
25919
|
+
danglingPins: pins,
|
|
25329
25920
|
warnings: ctx.warnings
|
|
25330
25921
|
};
|
|
25331
25922
|
emit(ctx, writer, checks3, () => {
|
|
@@ -25352,6 +25943,10 @@ var doctor = {
|
|
|
25352
25943
|
"orphan plugin tables",
|
|
25353
25944
|
orphans === null ? paint(ctx, "dim", "not checked") : orphans.length === 0 ? ok(true, "none") : paint(ctx, "yellow", `${orphans.length}: ${orphans.join(", ")}`)
|
|
25354
25945
|
],
|
|
25946
|
+
[
|
|
25947
|
+
"dangling pins",
|
|
25948
|
+
pins === null ? paint(ctx, "dim", "not checked") : pins.length === 0 ? ok(true, "none") : paint(ctx, "yellow", `${pins.length}: ${pins.join(", ")}`)
|
|
25949
|
+
],
|
|
25355
25950
|
...checks3.warnings.map((warning) => ["ignored", paint(ctx, "yellow", warning)])
|
|
25356
25951
|
]);
|
|
25357
25952
|
});
|
|
@@ -25505,7 +26100,6 @@ var setupClaude = {
|
|
|
25505
26100
|
const path = join8(dir, "settings.json");
|
|
25506
26101
|
const file2 = claudeSettings(models, {
|
|
25507
26102
|
baseUrl: baseUrl(ctx),
|
|
25508
|
-
discoveryMirrors: ctx.config().exposeClaudeCodeAliases,
|
|
25509
26103
|
...key === undefined ? {} : { apiKey: key }
|
|
25510
26104
|
}, mapping, setupFs.read(path) ?? undefined);
|
|
25511
26105
|
finish(ctx, writer, [at(dir, file2)], dryRun2, key, setupFs.write);
|
|
@@ -25756,6 +26350,7 @@ var COMMANDS = {
|
|
|
25756
26350
|
"keys list": keysList,
|
|
25757
26351
|
"keys create": keysCreate,
|
|
25758
26352
|
"keys limits": keysLimits,
|
|
26353
|
+
"keys models": keysModels,
|
|
25759
26354
|
"keys revoke": keysRevoke,
|
|
25760
26355
|
"plugin list": pluginList,
|
|
25761
26356
|
"plugin verify": pluginVerify,
|