@bitkyc08/opencodex 2.100.4 → 2.100.5
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/gui/dist/assets/{App-DcpyI78f.js → App-BRExzhwL.js} +21 -21
- package/gui/dist/assets/{Tray-CzjPJprT.js → Tray-DHCWAn8V.js} +1 -1
- package/gui/dist/assets/{brand-mark-BTIi7e69.js → brand-mark-C70PuQ3j.js} +1 -1
- package/gui/dist/assets/index-Dy1jIGty.js +138 -0
- package/gui/dist/assets/{segment-thumb-features-Bn6Y-g3R.js → segment-thumb-features-Bquysdn5.js} +1 -1
- package/gui/dist/classic/assets/{App-eYJAyNHM.js → App-CaC-E6Vl.js} +20 -20
- package/gui/dist/classic/assets/{Tray-xHMYxLkV.js → Tray-BG253fiL.js} +1 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +138 -0
- package/gui/dist/classic/assets/{quota-summary-DyzHlkFl.js → quota-summary-B7KQPpEC.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +1 -1
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +1 -63
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +24 -0
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/provider.ts +3 -2
- package/src/client/connect.ts +10 -2
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/main-account.ts +7 -2
- package/src/codex/native-main-credentials.ts +11 -5
- package/src/combos/failover.ts +183 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/generated/compatibility-version.json +99 -83
- package/src/generated/model-metadata.ts +3 -3
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/upstream-retry.ts +1 -1
- package/src/messaging/remote-ports.ts +22 -10
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +25 -13
- package/src/oauth/index.ts +22 -14
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +43 -14
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/responses/citation-markers.ts +26 -23
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +21 -8
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-routes.ts +8 -8
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/request-log-conversation.ts +6 -2
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-dispatch.ts +8 -8
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +43 -19
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +6 -4
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/types/request.ts +4 -3
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/index-DVgU6S3y.js +0 -138
- package/gui/dist/classic/assets/index-DSaVRW4F.js +0 -138
|
@@ -963,6 +963,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
963
963
|
noVisionModels: ALIBABA_TOKEN_PLAN_NO_VISION,
|
|
964
964
|
// The gateway accepts prompt_cache_key on every Token Plan chat model (probed 260902).
|
|
965
965
|
promptCacheKey: true,
|
|
966
|
+
// DashScope compatible-mode answers `400 developer is not one of ['system','assistant','user','tool','function']`
|
|
967
|
+
// (#5664, #8864). The native /v1/chat/completions passthrough folds only on an explicit record.
|
|
968
|
+
foldDeveloperRoleToSystem: true,
|
|
966
969
|
},
|
|
967
970
|
{
|
|
968
971
|
id: "alibaba-token-plan-intl",
|
|
@@ -1010,6 +1013,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1010
1013
|
noReasoningModels: ["kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "glm-5.1", "glm-5", "MiniMax-M2.5"],
|
|
1011
1014
|
modelDefaultReasoningEfforts: { ...Object.fromEntries(QWEN38_FAMILY.map(id => [id, "xhigh"])), "deepseek-v4.1-flash-1017": "high" },
|
|
1012
1015
|
promptCacheKey: true,
|
|
1016
|
+
// DashScope compatible-mode answers `400 developer is not one of ['system','assistant','user','tool','function']`
|
|
1017
|
+
// (#5664, #8864). The native /v1/chat/completions passthrough folds only on an explicit record.
|
|
1018
|
+
foldDeveloperRoleToSystem: true,
|
|
1013
1019
|
},
|
|
1014
1020
|
// NEEDS_HUMAN 2026-07-10: kept for config compatibility, but this is a dashboard URL,
|
|
1015
1021
|
// no /models endpoint is documented, and tools are silently ignored upstream per docs.parallel.ai.
|
|
@@ -1304,10 +1310,11 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1304
1310
|
preserveCustomDestination: true,
|
|
1305
1311
|
defaultModel: "gpt-5.6-terra",
|
|
1306
1312
|
// 261027 preemptive: GPT-6.1 Terra (OpenAI API limits; TokenLab listing unverified).
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1313
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra, same basis.
|
|
1314
|
+
models: ["gpt-5.6-terra", "gpt-6.1-terra", "gpt-6.2-sol", "gpt-6.2-astra"],
|
|
1315
|
+
modelContextWindows: { "gpt-5.6-terra": 1_050_000, "gpt-6.1-terra": 1_050_000, "gpt-6.2-sol": 1_050_000, "gpt-6.2-astra": 1_050_000 },
|
|
1316
|
+
modelMaxOutputTokens: { "gpt-5.6-terra": 128_000, "gpt-6.1-terra": 128_000, "gpt-6.2-sol": 128_000, "gpt-6.2-astra": 128_000 },
|
|
1317
|
+
modelInputModalities: { "gpt-5.6-terra": ["text", "image"], "gpt-6.1-terra": ["text", "image"], "gpt-6.2-sol": ["text", "image"], "gpt-6.2-astra": ["text", "image"] },
|
|
1311
1318
|
// Per-model wires from `tokenlab.accepted_request_formats` (GET /v1/models/{id}, 2026-09-30).
|
|
1312
1319
|
// The provider stays on Chat, the released and end-to-end verified path, and every model
|
|
1313
1320
|
// accepts it. Models that also declare Responses use it for Codex (Responses inbound) only,
|
|
@@ -1316,8 +1323,8 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1316
1323
|
// gemini-3.8-flash declares Chat + Gemini native and stays on Chat. No delivery-policy
|
|
1317
1324
|
// header is sent: the API key's own policy stays authoritative.
|
|
1318
1325
|
modelWireDefaults: Object.fromEntries([
|
|
1319
|
-
// 261027 preemptive: GPT-6.1 Terra (mirrors TokenLab's GPT-6.1 Sol wire).
|
|
1320
|
-
"gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "grok-4.7",
|
|
1326
|
+
// 261027 preemptive: GPT-6.1 Terra (mirrors TokenLab's GPT-6.1 Sol wire); 261118: GPT-6.2 likewise.
|
|
1327
|
+
"gpt-6-astra", "gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "grok-4.7",
|
|
1321
1328
|
"deepseek-v4.1-flash", "deepseek-v4-pro", "kimi-k3", "glm-5.3",
|
|
1322
1329
|
].map(id => [id, { wire: "openai-responses", inbound: ["responses"] }])),
|
|
1323
1330
|
modelDiscovery: {
|
|
@@ -1349,8 +1356,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1349
1356
|
preserveCustomDestination: true,
|
|
1350
1357
|
defaultModel: "glm-5.3-flash",
|
|
1351
1358
|
// 261027 preemptive: GPT-6.1 Terra (mirrors Modelflare's GPT-6.1 Sol seed; provider listing unverified).
|
|
1352
|
-
|
|
1353
|
-
|
|
1359
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra, same basis.
|
|
1360
|
+
models: ["glm-5.3-flash", "claude-sonnet-5-5", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6.2-sol", "gpt-6.2-astra", "deepseek-v4-flash"],
|
|
1361
|
+
note: "OpenAI-compatible relay for Claude, GPT, GLM and DeepSeek chat models. The original four seeded models were verified with chat, streaming and tool calls; GPT-6.1 Terra, GPT-6.2 Sol and GPT-6.2 Astra are preemptive seeds pending provider verification. deepseek-v4.1-flash is listed upstream but currently answers 503 and is left out. An ordinary key only reaches its own routing group's models; a Smart key reaches the verified seeded models. Image and video models are not served through this Chat preset. Upstream latency varies widely (a few seconds to about 30 s) with occasional transient 503s.",
|
|
1354
1362
|
},
|
|
1355
1363
|
{
|
|
1356
1364
|
// AI Stupid Level Smart Router, operated by S.C. Studio Platforms S.R.L. Contract checked
|
|
@@ -1548,7 +1556,7 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1548
1556
|
featured: false,
|
|
1549
1557
|
dashboardUrl: "https://github.com/settings/copilot",
|
|
1550
1558
|
liveModels: true,
|
|
1551
|
-
models: ["gpt-4o", "gpt-4.1", "gpt-4.1-mini", "claude-sonnet-4", "gemini-2.5-pro", "gpt-5-mini", "gpt-5.3-codex", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"],
|
|
1559
|
+
models: ["gpt-4o", "gpt-4.1", "gpt-4.1-mini", "claude-sonnet-4", "gemini-2.5-pro", "gpt-5-mini", "gpt-5.3-codex", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"],
|
|
1552
1560
|
defaultModel: "gpt-4o",
|
|
1553
1561
|
// Copilot fronts a mixed-wire catalog: these models reject /chat/completions for
|
|
1554
1562
|
// real Codex-agent traffic (function tools + reasoning), so every inbound wire
|
|
@@ -1572,6 +1580,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1572
1580
|
"gpt-6.1-sol": "openai-responses",
|
|
1573
1581
|
// GPT-6.1 Terra: GA in Copilot 2026-10-26; rides Responses like GPT-6.1 Sol.
|
|
1574
1582
|
"gpt-6.1-terra": "openai-responses",
|
|
1583
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra ride Responses like GPT-6.1 Sol (Copilot listing unverified).
|
|
1584
|
+
"gpt-6.2-sol": "openai-responses",
|
|
1585
|
+
"gpt-6.2-astra": "openai-responses",
|
|
1575
1586
|
"grok-4.5": "openai-responses",
|
|
1576
1587
|
"grok-4.6": "openai-responses",
|
|
1577
1588
|
"mai-code-1.1-flash": "openai-responses",
|
|
@@ -226,7 +226,8 @@ export const OPENAI_API_GPT56_REASONING_EFFORTS = ["low", "medium", "high", "xhi
|
|
|
226
226
|
* (https://developers.openai.com/api/docs/models/gpt-6.1-sol, checked 2026-09-30).
|
|
227
227
|
*/
|
|
228
228
|
// GPT-6.1 Terra (2026-10-26): same API limits; its none..max ladder is set per model.
|
|
229
|
-
|
|
229
|
+
// GPT-6.2 Sol and Astra publish the same API limits and disallow none.
|
|
230
|
+
export const OPENAI_GPT6_MODELS = ["gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"];
|
|
230
231
|
/*
|
|
231
232
|
* Meta Model API (https://api.meta.ai/v1) — published ladder, deliberately NOT the
|
|
232
233
|
* house set. dev.meta.ai/docs/reasoning lists "none", "minimal", "low", "medium",
|
|
@@ -334,6 +335,8 @@ export const OPENROUTER_GPT56_CONTEXT_WINDOWS = {
|
|
|
334
335
|
"openai/gpt-6-luna": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
335
336
|
// Live /api/v1/models on 2026-09-30: context_length 1,050,000, max_completion_tokens 128,000.
|
|
336
337
|
"openai/gpt-6.1-sol": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
338
|
+
"openai/gpt-6.2-sol": 1_050_000,
|
|
339
|
+
"openai/gpt-6.2-astra": 1_050_000,
|
|
337
340
|
// OpenRouter listing checked 2026-10-27: context_length 1,050,000.
|
|
338
341
|
"openai/gpt-6.1-terra": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
339
342
|
};
|
|
@@ -43,6 +43,8 @@ export interface StaleContextWindowProjection {
|
|
|
43
43
|
* the degraded-mode figures, and live discovery supersedes them when it runs.
|
|
44
44
|
*/
|
|
45
45
|
export const STALE_CONTEXT_WINDOWS: readonly StaleContextWindow[] = [
|
|
46
|
+
// swe-2 shipped 262_000 (a stale vendor figure) before the measured 850_000 window.
|
|
47
|
+
{ provider: "devin", model: "swe-2", from: 262_000, to: 850_000 },
|
|
46
48
|
{ provider: "devin", model: "swe-1-7", from: 256_000, to: 262_000 },
|
|
47
49
|
{ provider: "devin", model: "swe-1-7-lightning", from: 256_000, to: 202_752 },
|
|
48
50
|
{ provider: "devin", model: "gpt-5-6-sol", from: 1_050_000, to: 1_000_000 },
|
|
@@ -215,8 +215,8 @@ export const passthroughMemoryCitationEscaper: MemoryCitationEscaper = {
|
|
|
215
215
|
*
|
|
216
216
|
* A tag can straddle delta boundaries, so a per-delta regex would miss the mention that matters
|
|
217
217
|
* most: the model writing the tag name one token at a time. The escaper buffers until it can tell
|
|
218
|
-
* a mention from a real block. A real block is emitted verbatim, tags included,
|
|
219
|
-
*
|
|
218
|
+
* a mention from a real block. A real block is emitted verbatim, tags included, once its closing
|
|
219
|
+
* tag and body prove it valid — the client keeps it, which is the whole point of the block.
|
|
220
220
|
* Everything else is a mention and gets `<`.
|
|
221
221
|
*/
|
|
222
222
|
export function createMemoryCitationEscaper(): MemoryCitationEscaper {
|
|
@@ -235,57 +235,60 @@ export function createMemoryCitationEscaper(): MemoryCitationEscaper {
|
|
|
235
235
|
held = "";
|
|
236
236
|
let out = "";
|
|
237
237
|
let i = 0;
|
|
238
|
+
// Ordinary text stays one input span, even when it contains many literal '<' characters.
|
|
239
|
+
// Flush that span only at a rewrite or hold boundary, rather than building one rope per '<'.
|
|
240
|
+
let literalStart = 0;
|
|
238
241
|
while (i < input.length) {
|
|
239
242
|
const next = input.indexOf("<", i);
|
|
240
|
-
if (next === -1)
|
|
241
|
-
out += input.slice(i);
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
out += input.slice(i, next);
|
|
245
|
-
// Look no further than one hold limit ahead: a real block never exceeds it, and slicing the
|
|
246
|
-
// whole remainder for every tag would make one large delta of many tags quadratic.
|
|
247
|
-
const tail = input.slice(next, next + MAX_MEMORY_CITATION_HOLD + 1);
|
|
243
|
+
if (next === -1) break;
|
|
248
244
|
const remaining = input.length - next;
|
|
249
|
-
if (
|
|
245
|
+
if (input.startsWith(MEMORY_CITATION_CLOSE, next)) {
|
|
250
246
|
// A close tag outside a claimed block is prose.
|
|
251
|
-
out += escapeClose;
|
|
247
|
+
out += input.slice(literalStart, next) + escapeClose;
|
|
252
248
|
i = next + MEMORY_CITATION_CLOSE.length;
|
|
249
|
+
literalStart = i;
|
|
253
250
|
continue;
|
|
254
251
|
}
|
|
255
|
-
if (!
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
if (!input.startsWith(MEMORY_CITATION_OPEN, next)) {
|
|
253
|
+
if (remaining < MEMORY_CITATION_CLOSE.length) {
|
|
254
|
+
const tail = input.slice(next);
|
|
255
|
+
if (MEMORY_CITATION_OPEN.startsWith(tail) || MEMORY_CITATION_CLOSE.startsWith(tail)) {
|
|
256
|
+
// A tag is still arriving.
|
|
257
|
+
held = tail;
|
|
258
|
+
return out + input.slice(literalStart, next);
|
|
259
|
+
}
|
|
260
260
|
}
|
|
261
|
-
out += "<";
|
|
262
261
|
i = next + 1;
|
|
263
262
|
continue;
|
|
264
263
|
}
|
|
264
|
+
// Only an opening-tag candidate needs a bounded body lookahead. Ordinary '<' characters
|
|
265
|
+
// above use offsets in the original string, without allocating a tail for every match.
|
|
266
|
+
const tail = input.slice(next, next + MAX_MEMORY_CITATION_HOLD + 1);
|
|
265
267
|
const afterOpen = tail.slice(MEMORY_CITATION_OPEN.length);
|
|
266
268
|
if (!bodyCouldBeReal(afterOpen)) {
|
|
267
|
-
out += escapeOpen;
|
|
269
|
+
out += input.slice(literalStart, next) + escapeOpen;
|
|
268
270
|
i = next + MEMORY_CITATION_OPEN.length;
|
|
271
|
+
literalStart = i;
|
|
269
272
|
continue;
|
|
270
273
|
}
|
|
271
274
|
const end = opensRealBlock(tail, 0);
|
|
272
275
|
if (end !== undefined) {
|
|
273
276
|
// A complete real block is released verbatim, both tags included, so the delta stream
|
|
274
277
|
// equals what `escapeMemoryCitationMentions` keeps in the final text.
|
|
275
|
-
out += tail.slice(0, end);
|
|
276
278
|
i = next + end;
|
|
277
279
|
continue;
|
|
278
280
|
}
|
|
279
281
|
if (!tail.includes(MEMORY_CITATION_CLOSE, MEMORY_CITATION_OPEN.length) && remaining <= MAX_MEMORY_CITATION_HOLD) {
|
|
280
282
|
// The block may still close; hold it whole.
|
|
281
283
|
held = tail;
|
|
282
|
-
return out;
|
|
284
|
+
return out + input.slice(literalStart, next);
|
|
283
285
|
}
|
|
284
286
|
// Closed without a valid body, or too large to keep holding: a mention.
|
|
285
|
-
out += escapeOpen;
|
|
287
|
+
out += input.slice(literalStart, next) + escapeOpen;
|
|
286
288
|
i = next + MEMORY_CITATION_OPEN.length;
|
|
289
|
+
literalStart = i;
|
|
287
290
|
}
|
|
288
|
-
return out;
|
|
291
|
+
return out + input.slice(literalStart);
|
|
289
292
|
},
|
|
290
293
|
pending(): string {
|
|
291
294
|
return held;
|
|
@@ -71,7 +71,7 @@ function isOutdatedVersion(parts: readonly number[]): boolean {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export async function probe(ctx: ManagementContext, state: LinkRouteState): Promise<Response> {
|
|
74
|
-
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null));
|
|
74
|
+
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null), ctx);
|
|
75
75
|
if ("error" in split) return split.error;
|
|
76
76
|
const keyRefusal = identityFileRefusal(split.route.explicitRoute);
|
|
77
77
|
if (keyRefusal) return keyRefusal;
|
|
@@ -151,7 +151,7 @@ export async function probe(ctx: ManagementContext, state: LinkRouteState): Prom
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export async function confirmHost(ctx: ManagementContext, state: LinkRouteState): Promise<Response> {
|
|
154
|
-
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null));
|
|
154
|
+
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null), ctx);
|
|
155
155
|
if ("error" in split) return split.error;
|
|
156
156
|
const keyRefusal = identityFileRefusal(split.route.explicitRoute);
|
|
157
157
|
if (keyRefusal) return keyRefusal;
|
|
@@ -255,7 +255,7 @@ function parsePort(stdout: string): number | null {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
export async function apply(ctx: ManagementContext, state: LinkRouteState): Promise<Response> {
|
|
258
|
-
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null));
|
|
258
|
+
const split = splitRouteRequest(await readManagementJsonBodyOr(ctx.req, null), ctx);
|
|
259
259
|
if ("error" in split) return split.error;
|
|
260
260
|
const value = split.body, wanted = split.route;
|
|
261
261
|
const body = isRecord(value) && Object.keys(value).every(key => APPLY_KEYS.has(key)) ? value : null;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* none), so a probe made by another caller with another route can never be confirmed or applied here.
|
|
6
6
|
*/
|
|
7
7
|
import { checkExplicitRoute, IDENTITY_FILE_GUIDANCE, identityFileProblem, sameExplicitRoute, type ExplicitRoute } from "../../link/explicit-route";
|
|
8
|
-
import {
|
|
8
|
+
import type { ManagementContext } from "./context";
|
|
9
|
+
import { adminLoopback, fail, isRecord, pairedSession } from "./link-route-state";
|
|
9
10
|
|
|
10
11
|
export interface RouteRequest {
|
|
11
12
|
explicitRoute: ExplicitRoute | null;
|
|
@@ -15,11 +16,12 @@ export interface RouteRequest {
|
|
|
15
16
|
export const NO_ROUTE_REQUEST: RouteRequest = { explicitRoute: null, exclusive: false };
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* The body without the route keys, and the route it asked for
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* The body without the route keys, and the route it asked for. Invalid forms receive a 400 before any SSH; a supplied
|
|
20
|
+
* command then requires owner-backed authority. The identity file itself is checked by
|
|
21
|
+
* identityFileRefusal where a request is about to run SSH, so an authorized repeat of a journalled apply replays its
|
|
22
|
+
* recorded outcome (or answers operation_mismatch) whatever its key file looks like now.
|
|
21
23
|
*/
|
|
22
|
-
export function splitRouteRequest(value: unknown): { body: unknown; route: RouteRequest } | { error: Response } {
|
|
24
|
+
export function splitRouteRequest(value: unknown, ctx: ManagementContext): { body: unknown; route: RouteRequest } | { error: Response } {
|
|
23
25
|
if (!isRecord(value) || (!("explicitRoute" in value) && !("exclusive" in value))) return { body: value, route: NO_ROUTE_REQUEST };
|
|
24
26
|
const { explicitRoute, exclusive, ...body } = value;
|
|
25
27
|
if (exclusive !== undefined && exclusive !== true) return { error: fail("invalid_body", "exclusive must be true when present.", 400) };
|
|
@@ -29,6 +31,10 @@ export function splitRouteRequest(value: unknown): { body: unknown; route: Route
|
|
|
29
31
|
if (!checked.ok) return { error: fail("invalid_explicit_route", "explicitRoute must be {proxyCommand, user, port} with an optional identityFile, in the accepted form.", 400, checked.reason) };
|
|
30
32
|
route = checked.route;
|
|
31
33
|
if (exclusive !== true) return { error: fail("explicit_route_requires_exclusive", "A link with an explicit route must be exclusive.", 400) };
|
|
34
|
+
// A loopback bootstrap proves no ownership of the executable supplied in ProxyCommand.
|
|
35
|
+
if (!pairedSession(ctx) && !adminLoopback(ctx)) {
|
|
36
|
+
return { error: fail("forbidden", "An explicit SSH route requires an operator-paired dashboard session or a trusted loopback admin token.", 403) };
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
return { body, route: { explicitRoute: route, exclusive: exclusive === true } };
|
|
34
40
|
}
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
waitForLoginSettled,
|
|
39
39
|
} from "../../oauth";
|
|
40
40
|
import { OAuthMutationBusyError, removeCredential } from "../../oauth/store";
|
|
41
|
+
import { isOAuthCredentialSiblingOf, oauthCredentialSiblingsOf, oauthCredentialSlot } from "../../oauth/credential-siblings";
|
|
41
42
|
import {
|
|
42
43
|
ANTIGRAVITY_RISK_PROVIDER,
|
|
43
44
|
ANTIGRAVITY_RISK_REFUSAL_CODE,
|
|
@@ -272,9 +273,13 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
272
273
|
// the provider's loopback callback server (inside this process) captures the redirect in the
|
|
273
274
|
// background, then the credential is persisted. The GUI opens the URL and polls /api/oauth/status.
|
|
274
275
|
if (url.pathname === "/api/oauth/login" && req.method === "POST") {
|
|
275
|
-
const body = await readManagementJsonBodyOr(req, {}) as { provider?: string; addAccount?: boolean; accountId?: string; reauth?: boolean; openBrowser?: unknown; method?: unknown; mode?: unknown; device?: unknown; startUrl?: unknown; region?: unknown; flowId?: unknown; profileArn?: unknown };
|
|
276
|
+
const body = await readManagementJsonBodyOr(req, {}) as { provider?: string; row?: unknown; addAccount?: boolean; accountId?: string; reauth?: boolean; openBrowser?: unknown; method?: unknown; mode?: unknown; device?: unknown; startUrl?: unknown; region?: unknown; flowId?: unknown; profileArn?: unknown };
|
|
276
277
|
const provider = (body.provider ?? "").trim().toLowerCase();
|
|
277
278
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
279
|
+
// `row`: the sibling provider row this login publishes (Kimi (Responses) through the Kimi login).
|
|
280
|
+
if (body.row !== undefined && (typeof body.row !== "string" || !isOAuthCredentialSiblingOf(body.row, provider))) {
|
|
281
|
+
return jsonResponse({ error: "row must be a provider that shares this login" }, 400);
|
|
282
|
+
}
|
|
278
283
|
// Antigravity sign-in can get the Google account disabled. Every client asks first; this is
|
|
279
284
|
// the check none of them can skip, and it runs before any flow state is created.
|
|
280
285
|
if (requiresAntigravityRiskAcknowledgement(provider) && !hasAntigravityRiskAcknowledgement(body)) {
|
|
@@ -352,6 +357,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
352
357
|
...(accountId ? { reauthAccountId: accountId } : {}),
|
|
353
358
|
...(codeMode ? { codeMode: true } : {}),
|
|
354
359
|
...(device ? { flow: "device" as const } : {}),
|
|
360
|
+
...(typeof body.row === "string" ? { publishRow: body.row } : {}),
|
|
355
361
|
}, {
|
|
356
362
|
...(flowId ? { flowId } : {}),
|
|
357
363
|
// startLoginFlow returns the authorization URL before background persistence completes.
|
|
@@ -479,7 +485,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
479
485
|
}
|
|
480
486
|
|
|
481
487
|
if (url.pathname === "/api/oauth/status" && req.method === "GET") {
|
|
482
|
-
const provider = (url.searchParams.get("provider") ?? "").trim().toLowerCase();
|
|
488
|
+
const provider = oauthCredentialSlot((url.searchParams.get("provider") ?? "").trim().toLowerCase());
|
|
483
489
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
484
490
|
if (provider === "kiro" && url.searchParams.has("flowId")) {
|
|
485
491
|
const flowId = url.searchParams.get("flowId") ?? "";
|
|
@@ -500,7 +506,9 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
500
506
|
}
|
|
501
507
|
|
|
502
508
|
if (url.pathname === "/api/oauth/logout" && req.method === "POST") {
|
|
503
|
-
|
|
509
|
+
// A sibling row (kimi-responses) has no login of its own: logging out of it removes the
|
|
510
|
+
// active account of the shared slot, exactly as the neighbouring account routes map it.
|
|
511
|
+
const provider = oauthCredentialSlot((url.searchParams.get("provider") ?? "").trim().toLowerCase());
|
|
504
512
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
505
513
|
await removeCredential(provider);
|
|
506
514
|
reconcileLiveStateStores();
|
|
@@ -508,6 +516,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
508
516
|
const { clearModelCache } = await import("../../codex/model-cache");
|
|
509
517
|
const { clearGatherRoutedModelsInflight } = await import("../../codex/catalog");
|
|
510
518
|
clearModelCache(provider);
|
|
519
|
+
for (const row of oauthCredentialSiblingsOf(provider)) clearModelCache(row);
|
|
511
520
|
clearGatherRoutedModelsInflight();
|
|
512
521
|
// Drop cached/last-good quota rows tied to the removed credential.
|
|
513
522
|
clearQuotaCachesAfterAccountMutation(provider, true);
|
|
@@ -524,7 +533,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
524
533
|
// one, or remove one. Emails and accountLabel follow privacy.maskEmails, maskedLabel is always
|
|
525
534
|
// masked, and tokens never leave the store.
|
|
526
535
|
if (url.pathname === "/api/oauth/accounts" && req.method === "GET") {
|
|
527
|
-
const provider = (url.searchParams.get("provider") ?? "").trim().toLowerCase();
|
|
536
|
+
const provider = oauthCredentialSlot((url.searchParams.get("provider") ?? "").trim().toLowerCase());
|
|
528
537
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
529
538
|
const quotaMode = providerOAuthAccountQuotaMode(provider);
|
|
530
539
|
const quotaProvider = config.providers[provider];
|
|
@@ -618,7 +627,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
618
627
|
}
|
|
619
628
|
if (url.pathname === "/api/oauth/accounts/active" && req.method === "PUT") {
|
|
620
629
|
const body = await readManagementJsonBodyOr(req, {}) as { provider?: string; accountId?: string };
|
|
621
|
-
const provider = (body.provider ?? "").trim().toLowerCase();
|
|
630
|
+
const provider = oauthCredentialSlot((body.provider ?? "").trim().toLowerCase());
|
|
622
631
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
623
632
|
if (provider === "anthropic2" && !configuredAnthropicInstance(config, provider)) return jsonResponse({ error: "Anthropic pool instance is not configured" }, 409);
|
|
624
633
|
if (!body.accountId) return jsonResponse({ error: "missing accountId" }, 400);
|
|
@@ -645,6 +654,8 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
645
654
|
const { clearModelCache } = await import("../../codex/model-cache");
|
|
646
655
|
const { clearGatherRoutedModelsInflight } = await import("../../codex/catalog");
|
|
647
656
|
clearModelCache(provider);
|
|
657
|
+
// A shared-login row (kimi-responses) caches its roster under its own name.
|
|
658
|
+
for (const row of oauthCredentialSiblingsOf(provider)) clearModelCache(row);
|
|
648
659
|
clearGatherRoutedModelsInflight();
|
|
649
660
|
clearQuotaCachesAfterAccountMutation(provider, false);
|
|
650
661
|
if (affinityReset && !await affinityReset) {
|
|
@@ -659,7 +670,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
659
670
|
if (url.pathname === "/api/oauth/accounts/pause" && req.method === "PUT") {
|
|
660
671
|
const body = await readManagementJsonBodyOr(req, {});
|
|
661
672
|
if (!isPlainRecord(body)) return jsonResponse({ error: "body must be an object" }, 400);
|
|
662
|
-
const provider = typeof body.provider === "string" ? body.provider.trim().toLowerCase() : "";
|
|
673
|
+
const provider = oauthCredentialSlot(typeof body.provider === "string" ? body.provider.trim().toLowerCase() : "");
|
|
663
674
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
664
675
|
if (typeof body.accountId !== "string" || body.accountId.length === 0) {
|
|
665
676
|
return jsonResponse({ error: "missing accountId" }, 400);
|
|
@@ -727,6 +738,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
727
738
|
const { clearModelCache } = await import("../../codex/model-cache");
|
|
728
739
|
const { clearGatherRoutedModelsInflight } = await import("../../codex/catalog");
|
|
729
740
|
clearModelCache(provider);
|
|
741
|
+
for (const row of oauthCredentialSiblingsOf(provider)) clearModelCache(row);
|
|
730
742
|
clearGatherRoutedModelsInflight();
|
|
731
743
|
clearQuotaCachesAfterAccountMutation(provider, false);
|
|
732
744
|
}
|
|
@@ -1118,7 +1130,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
1118
1130
|
|
|
1119
1131
|
if (url.pathname === "/api/oauth/accounts/alias" && req.method === "PUT") {
|
|
1120
1132
|
const body = await readManagementJsonBodyOr(req, {}) as { provider?: unknown; accountId?: unknown; alias?: unknown };
|
|
1121
|
-
const provider = typeof body.provider === "string" ? body.provider.trim().toLowerCase() : "";
|
|
1133
|
+
const provider = oauthCredentialSlot(typeof body.provider === "string" ? body.provider.trim().toLowerCase() : "");
|
|
1122
1134
|
const accountId = typeof body.accountId === "string" ? body.accountId.trim() : "";
|
|
1123
1135
|
const alias = typeof body.alias === "string" ? body.alias.trim() : "";
|
|
1124
1136
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
@@ -1131,7 +1143,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
1131
1143
|
return jsonResponse({ ok: true, provider, accountId, alias: alias || null });
|
|
1132
1144
|
}
|
|
1133
1145
|
if (url.pathname === "/api/oauth/accounts" && req.method === "DELETE") {
|
|
1134
|
-
const provider = (url.searchParams.get("provider") ?? "").trim().toLowerCase();
|
|
1146
|
+
const provider = oauthCredentialSlot((url.searchParams.get("provider") ?? "").trim().toLowerCase());
|
|
1135
1147
|
const id = url.searchParams.get("id") ?? "";
|
|
1136
1148
|
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
|
|
1137
1149
|
if (!id) return jsonResponse({ error: "missing id" }, 400);
|
|
@@ -1158,6 +1170,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
|
|
|
1158
1170
|
const { clearModelCache } = await import("../../codex/model-cache");
|
|
1159
1171
|
const { clearGatherRoutedModelsInflight } = await import("../../codex/catalog");
|
|
1160
1172
|
clearModelCache(provider);
|
|
1173
|
+
for (const row of oauthCredentialSiblingsOf(provider)) clearModelCache(row);
|
|
1161
1174
|
clearGatherRoutedModelsInflight();
|
|
1162
1175
|
clearQuotaCachesAfterAccountMutation(provider, true);
|
|
1163
1176
|
// Same reasoning as logout. Removing the last account for a provider used to
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { OcxConfig, OcxProviderConfig } from "../../types";
|
|
2
|
+
import { oauthCredentialSlot } from "../../oauth/credential-siblings";
|
|
3
|
+
import { releaseProviderAccountSetUnlessRetained } from "../../oauth/store";
|
|
4
|
+
import { getProviderRegistryEntry } from "../../providers/registry";
|
|
5
|
+
import { providerUsesKeyAuthOverride } from "../../providers/key-store";
|
|
6
|
+
import { readConfigFileSnapshot } from "../../config/diagnostics";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether a configured row signs in through its OAuth login, decided the way routing decides it
|
|
10
|
+
* (src/providers/routed-config.ts): a registry OAuth entry is OAuth whatever `authMode` says
|
|
11
|
+
* (including omitted), unless the entry allows a key override and the row selects it.
|
|
12
|
+
*/
|
|
13
|
+
export function rowUsesOAuthLogin(row: string, provider: OcxProviderConfig): boolean {
|
|
14
|
+
const entry = getProviderRegistryEntry(row);
|
|
15
|
+
if (entry?.authKind === "oauth") return !providerUsesKeyAuthOverride(entry, provider);
|
|
16
|
+
return provider.authMode === "oauth";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Release the OAuth login a removed provider row used, unless another remaining OAuth row
|
|
21
|
+
* still signs in through the same login. `config` must already be without the removed row.
|
|
22
|
+
*
|
|
23
|
+
* Kimi and Kimi (Responses) share one login (src/oauth/credential-siblings.ts): removing one of
|
|
24
|
+
* the two rows keeps the login the other still uses, and removing the last one releases it, so
|
|
25
|
+
* neither row is left on a credential it no longer owns. The "still used" check runs inside the
|
|
26
|
+
* serialized store write and reads both the live `config` and the persisted config.json, so a
|
|
27
|
+
* row published while the release waited (by this process or another, including a re-created row
|
|
28
|
+
* of the removed name) keeps the login instead of losing it.
|
|
29
|
+
*/
|
|
30
|
+
export async function releaseRemovedProviderCredentials(
|
|
31
|
+
config: OcxConfig,
|
|
32
|
+
name: string,
|
|
33
|
+
release: typeof releaseProviderAccountSetUnlessRetained = releaseProviderAccountSetUnlessRetained,
|
|
34
|
+
): Promise<"released" | "retained"> {
|
|
35
|
+
const slot = oauthCredentialSlot(name);
|
|
36
|
+
// `config` no longer holds the removed row, so any row named `name` here was re-created.
|
|
37
|
+
const usesSlot = (providers: OcxConfig["providers"]): boolean => Object.entries(providers).some(([row, provider]) =>
|
|
38
|
+
oauthCredentialSlot(row) === slot && rowUsesOAuthLogin(row, provider));
|
|
39
|
+
return release(name, () => {
|
|
40
|
+
if (usesSlot(config.providers)) return true;
|
|
41
|
+
const persisted = readConfigFileSnapshot({ passive: true }).diagnostics;
|
|
42
|
+
return persisted.source === "file" && usesSlot(persisted.config.providers);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
import { commitProviderPatch } from "./provider-patch-transaction";
|
|
43
43
|
import { captureConfigTopLevelRollback } from "../../config/rebase-provenance";
|
|
44
44
|
import { canonicalAutoReviewModelKey, mergeModelPinnedEfforts, modelPinnedEffortsConfigError, pinnedReasoningEffortConfigError } from "../../config/provider-validation";
|
|
45
|
-
import {
|
|
45
|
+
import { releaseRemovedProviderCredentials } from "./provider-credential-release";
|
|
46
46
|
import { captureModelsOAuthTarget, mayResolveModelsOAuth, modelsOAuthTargetMatches } from "../../oauth/model-discovery-auth";
|
|
47
47
|
import { providerDestinationResolvedError } from "../../lib/destination-policy";
|
|
48
48
|
import { reconcileLiveStateStores } from "../../lib/state-store-registrations";
|
|
@@ -1732,21 +1732,21 @@ export async function handleProviderRoutes(ctx: ManagementContext): Promise<Resp
|
|
|
1732
1732
|
// Same canonical-URL TUN transparency as catalog discovery: the registry's
|
|
1733
1733
|
// own fixed discovery URL survives purely-benchmark (Clash/Surge/Mihomo
|
|
1734
1734
|
// fake-IP) DNS without proxy env.
|
|
1735
|
-
const outboundDependencies = { isCanonicalUrl: isRegistryModelDiscoveryUrl,
|
|
1736
|
-
beforeSend: () => (!vertexAuth || vertexDiscoveryAuthIsCurrent(prov, vertexAuth, headers))
|
|
1735
|
+
const outboundDependencies = (requestUrl: string) => ({ isCanonicalUrl: isRegistryModelDiscoveryUrl,
|
|
1736
|
+
beforeSend: () => (!vertexAuth || vertexDiscoveryAuthIsCurrent(prov, vertexAuth, headers, requestUrl))
|
|
1737
1737
|
&& (prov.authMode !== "oauth" || (mayResolveModelsOAuth(name, config.providers[name])
|
|
1738
1738
|
&& modelsOAuthTargetMatches(name, config.providers[name], authorizedTarget)
|
|
1739
|
-
&& (name !== "anthropic2" || new URL(
|
|
1739
|
+
&& (name !== "anthropic2" || new URL(requestUrl).href === authorizedTarget))) });
|
|
1740
1740
|
const res = method === "POST"
|
|
1741
1741
|
? await providerOutboundPost(name, prov, modelsUrl, {
|
|
1742
1742
|
headers,
|
|
1743
1743
|
body: JSON.stringify({ project }),
|
|
1744
1744
|
signal: AbortSignal.timeout(8000),
|
|
1745
|
-
}, outboundDependencies)
|
|
1745
|
+
}, outboundDependencies(modelsUrl))
|
|
1746
1746
|
: await providerOutboundGet(name, prov, modelsUrl, {
|
|
1747
1747
|
headers,
|
|
1748
1748
|
signal: vertexDeadline ?? AbortSignal.timeout(8000),
|
|
1749
|
-
}, outboundDependencies);
|
|
1749
|
+
}, outboundDependencies(modelsUrl));
|
|
1750
1750
|
const latencyMs = Date.now() - started;
|
|
1751
1751
|
const redirectError = await providerRedirectError(res, modelsUrl);
|
|
1752
1752
|
if (redirectError) {
|
|
@@ -1782,7 +1782,7 @@ export async function handleProviderRoutes(ctx: ManagementContext): Promise<Resp
|
|
|
1782
1782
|
const listing = !ccaModels && vertexDeadline
|
|
1783
1783
|
? await collectVertexPublisherModelPages(modelsUrl, bounded.value,
|
|
1784
1784
|
{ ...discovery, firstPageBytes: vertexFirstPage?.bytes(), signal: vertexDeadline },
|
|
1785
|
-
(pageUrl, signal) => providerOutboundGet(name, prov, pageUrl, { headers, signal }, outboundDependencies))
|
|
1785
|
+
(pageUrl, signal) => providerOutboundGet(name, prov, pageUrl, { headers, signal }, outboundDependencies(pageUrl)))
|
|
1786
1786
|
: { ok: true as const, value: bounded.value };
|
|
1787
1787
|
if (!listing.ok) return jsonResponse({ ok: false, latencyMs, error: `upstream Vertex model listing is incomplete: ${listing.diagnostic}` });
|
|
1788
1788
|
// OpenAI-style lists (and Together top-level arrays) use the same validation/dedupe/filter
|
|
@@ -1861,7 +1861,7 @@ export async function handleProviderRoutes(ctx: ManagementContext): Promise<Resp
|
|
|
1861
1861
|
// Deleting still succeeds; the response names the shadow-call target left without a provider.
|
|
1862
1862
|
const shadowDependency = shadowInterceptProviderDependency(config, name);
|
|
1863
1863
|
const droppedCustomModels = removeProviderWithGcpCredentials(config, name, fallbackDefault, save);
|
|
1864
|
-
await
|
|
1864
|
+
await releaseRemovedProviderCredentials(config, name);
|
|
1865
1865
|
reconcileLiveStateStores();
|
|
1866
1866
|
const { clearModelCache: clearCache } = await import("../../codex/model-cache");
|
|
1867
1867
|
clearCache(name);
|
|
@@ -477,14 +477,18 @@ async function accumulateCandidates(
|
|
|
477
477
|
try {
|
|
478
478
|
let first = true;
|
|
479
479
|
for (;;) {
|
|
480
|
-
// Candidate selection
|
|
481
|
-
//
|
|
480
|
+
// Candidate selection is synchronous and bounded. Row decoding and accumulation also
|
|
481
|
+
// yield within each page; keep the page-boundary yield for cheap rows and SQL work.
|
|
482
482
|
if (!first) await new Promise<void>(resolve => setTimeout(resolve, 0));
|
|
483
483
|
const offsets = read.nextPage();
|
|
484
484
|
if (!first && offsets.length === 0) break;
|
|
485
485
|
first = false;
|
|
486
486
|
const rows = await readUsageLedgerRowsAtOffsets({
|
|
487
487
|
offsets,
|
|
488
|
+
// This accumulator is private to the rebuild/append attempt and is discarded if the
|
|
489
|
+
// reader's final validation fails. Fold inside its time slice instead of retaining a
|
|
490
|
+
// page of parsed rows and then aggregating all of them in one synchronous turn.
|
|
491
|
+
onEntry: entry => accumulator.add(entry),
|
|
488
492
|
expectedIdentityKey: read.snapshot.identityKey,
|
|
489
493
|
// The offsets belong to this index snapshot. If the ledger moved since the snapshot,
|
|
490
494
|
// the reader re-validates the boundary before trusting any of them, and a rewrite of
|
|
@@ -499,7 +503,6 @@ async function accumulateCandidates(
|
|
|
499
503
|
// Serving only the rows that happened to parse would silently under-report the filter.
|
|
500
504
|
throw new UsageFilterIndexCorruptError();
|
|
501
505
|
}
|
|
502
|
-
for (const entry of rows.entries) accumulator.add(entry);
|
|
503
506
|
if (offsets.length === 0) break;
|
|
504
507
|
}
|
|
505
508
|
} finally {
|
|
@@ -6,7 +6,8 @@ import { boundedMessagesDisplayCount, ownedAnthropicErrorPayload, ownedAnthropic
|
|
|
6
6
|
import { attachComboFailureEvidence, isProxyError, markProxyError } from "../lib/client-error-body";
|
|
7
7
|
import { captureAccountAutoPauseAttempt, wasAccountAutoPaused } from "../oauth/account-auto-pause";
|
|
8
8
|
import { createPhysicalSendReporter, reportDispatchSends, type RequestExecutionBudget, type SingleUseDispatchPermit } from "../lib/request-execution-budget";
|
|
9
|
-
import { createInferenceSendBudget } from "./inference/context";
|
|
9
|
+
import { createInferenceSendBudget, expandInferenceOAuthSendBudget } from "./inference/context";
|
|
10
|
+
import { GENERIC_OAUTH_MAX_ACCOUNTS_PER_REQUEST } from "../oauth/generic-account-failover";
|
|
10
11
|
/**
|
|
11
12
|
* Managed native Messages lane (PF-08, behind `protocols.rollout.managedMessagesNative`).
|
|
12
13
|
*
|
|
@@ -566,7 +567,15 @@ async function runNativeMessagesAttempt(options: NativeMessagesExecution, attemp
|
|
|
566
567
|
if (oauthBinding) logCtx.provider = formatAnthropicProviderForLog(route.providerName, oauthBinding.snapshot.accountId, config);
|
|
567
568
|
const spendTracker = options.sendBudget ? undefined : attachRequestSpendTracker(req, logCtx);
|
|
568
569
|
const physicalBudget = options.sendBudget ?? createInferenceSendBudget(req, logCtx);
|
|
570
|
+
// Freeze funding before any refusal cools an account; selection still checks live eligibility.
|
|
571
|
+
const fundedAccounts = oauthBinding ? Math.min(new Set([
|
|
572
|
+
oauthBinding.snapshot.accountId,
|
|
573
|
+
...anthropicRoutingFor(oauthBinding.instance).getEligibleAnthropicAccounts(Date.now(), route.modelId),
|
|
574
|
+
]).size, GENERIC_OAUTH_MAX_ACCOUNTS_PER_REQUEST) : 0;
|
|
575
|
+
const oauthFailoverLimit = Math.max(ANTHROPIC_POOL_MAX_FAILOVERS_PER_REQUEST, fundedAccounts - 1);
|
|
576
|
+
if (oauthBinding) expandInferenceOAuthSendBudget(physicalBudget, fundedAccounts);
|
|
569
577
|
// Observe-only spend is already booked by the tracker; count billing sends without booking again.
|
|
578
|
+
const priorSends = Math.max(0, physicalBudget.used - (options.comboDispatchPermit ? 1 : 0));
|
|
570
579
|
let physicalSendsUsed = 0;
|
|
571
580
|
let activeRequest: AnthropicMessagesPassthroughRequest;
|
|
572
581
|
let retainedRequestBytes = 0;
|
|
@@ -638,6 +647,10 @@ async function runNativeMessagesAttempt(options: NativeMessagesExecution, attemp
|
|
|
638
647
|
options.sendBudget ? Math.min(sharedSendCap, options.sendBudget.remainingBaseSends(sharedSendCap)
|
|
639
648
|
+ (!initialSendStarted && options.comboDispatchPermit ? 1 : 0)) : Number.POSITIVE_INFINITY,
|
|
640
649
|
);
|
|
650
|
+
const oauthPhysicalSendAvailable = (): boolean =>
|
|
651
|
+
Math.max(priorSends + physicalSendsUsed, physicalBudget.used, physicalBudget.physicalStarted ?? 0)
|
|
652
|
+
< Math.min(physicalBudget.policy.maxTotalModelSends, physicalBudget.physicalLimit ?? Number.POSITIVE_INFINITY)
|
|
653
|
+
+ (!initialSendStarted && options.comboDispatchPermit ? 1 : 0);
|
|
641
654
|
const transientSendAvailable = (): boolean => remainingTransientSends() > 0;
|
|
642
655
|
const selector: NativeMessagesSelector = options.selector ?? {};
|
|
643
656
|
const nativeOAuthRouteIsCurrent = (binding: NativeOAuthBinding): boolean => {
|
|
@@ -662,6 +675,7 @@ async function runNativeMessagesAttempt(options: NativeMessagesExecution, attemp
|
|
|
662
675
|
/** Send the native Messages request under the transient retry policy, re-validating the selected OAuth account or API key at the dispatch boundary. */
|
|
663
676
|
const send = async (recovery?: "rate-limit-429" | "oauth-401" | "oauth-account-403" | "key-429" | "key-401"): Promise<Response> => {
|
|
664
677
|
const remaining = remainingTransientSends();
|
|
678
|
+
if (oauthBinding && !oauthPhysicalSendAvailable()) throw new SendBudgetExhaustedError();
|
|
665
679
|
if (options.sendBudget && remaining <= 0) throw new SendBudgetExhaustedError();
|
|
666
680
|
if (requestTransientPolicy && remaining <= 0) {
|
|
667
681
|
throw markProxyError(new Error("native Messages transient send budget exhausted before recovery dispatch"));
|
|
@@ -937,7 +951,7 @@ async function runNativeMessagesAttempt(options: NativeMessagesExecution, attemp
|
|
|
937
951
|
return resolved.decision;
|
|
938
952
|
},
|
|
939
953
|
signal: upstream.signal, requestKey: oauthRetryKey,
|
|
940
|
-
canRetry: transientSendAvailable() && oauthFailovers <
|
|
954
|
+
canRetry: transientSendAvailable() && oauthFailovers < oauthFailoverLimit && oauthPhysicalSendAvailable(),
|
|
941
955
|
});
|
|
942
956
|
if (!nextAccountId) break;
|
|
943
957
|
const recovery = response.status === 401 ? "oauth-401" : response.status === 403 ? "oauth-account-403" : "rate-limit-429";
|
|
@@ -181,7 +181,11 @@ function firstSanitizedConversationId(
|
|
|
181
181
|
/**
|
|
182
182
|
* Conversation namespace for reasoning replay. Unlike the persisted log id, this stays the raw
|
|
183
183
|
* sanitized identity so mixed headers that carry the same conversation still hit one serving
|
|
184
|
-
* record.
|
|
184
|
+
* record. The request's own thread-id precedes the parent routing identity: a child agent sends
|
|
185
|
+
* both, and letting it resolve to the parent's record lets a successful child route overwrite
|
|
186
|
+
* the parent's serving provenance, which strips the parent's replayed thinking signatures on its
|
|
187
|
+
* next turn (#8632). The parent header stays the fallback for callers that only carry it.
|
|
188
|
+
* Do not hash, and do not prefer session_id over a true per-conversation thread/Cursor
|
|
185
189
|
* identity: session_id can be synthesized from a shared prompt_cache_key.
|
|
186
190
|
*/
|
|
187
191
|
export function reasoningReplayConversationIdFromResponsesRequest(input: {
|
|
@@ -191,8 +195,8 @@ export function reasoningReplayConversationIdFromResponsesRequest(input: {
|
|
|
191
195
|
sessionIdHeader?: string | null;
|
|
192
196
|
}): string | undefined {
|
|
193
197
|
return firstSanitizedConversationId(
|
|
194
|
-
input.clientThreadId,
|
|
195
198
|
input.threadIdHeader,
|
|
199
|
+
input.clientThreadId,
|
|
196
200
|
input.cursorConversationId,
|
|
197
201
|
input.sessionIdHeader,
|
|
198
202
|
);
|