@yansigit/opencodex 2.35.0 → 2.35.1-dev.20260828.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gui/dist/assets/{index-BjCaHxdz.js → index-Bk24wkK_.js} +21 -21
- package/gui/dist/index.html +1 -1
- package/package.json +3 -1
- package/src/adapters/google-http.ts +1 -0
- package/src/config.ts +13 -0
- package/src/generated/compatibility-version.json +11 -7
- package/src/oauth/index.ts +12 -9
- package/src/server/management/agent-settings-routes.ts +30 -2
- package/src/server/responses/core.ts +69 -9
- package/src/server/responses/v2-routed-delegation-bridge.ts +233 -0
- package/src/types/config.ts +2 -0
package/gui/dist/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
} catch (e) {}
|
|
17
17
|
})();
|
|
18
18
|
</script>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-Bk24wkK_.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-DLkXOXLC.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yansigit/opencodex",
|
|
3
|
-
"version": "2.35.
|
|
3
|
+
"version": "2.35.1-dev.20260828.10",
|
|
4
4
|
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/package-main.mjs",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"dev:gui": "cd gui && bun run dev",
|
|
40
40
|
"start": "bun run src/cli/index.ts start",
|
|
41
41
|
"test": "bun scripts/test.ts",
|
|
42
|
+
"test:v2-bridge": "bun scripts/test.ts tests/config.test.ts tests/multi-agent-keep-native-v1.test.ts tests/namespace-tool-compat.test.ts tests/v2-routed-delegation-bridge.test.ts tests/responses-v2-routed-delegation-bridge.test.ts tests/v2-agent-message-failfast.test.ts tests/responses-compaction-routing.test.ts tests/responses-v2-native-parent-override.test.ts tests/passthrough-abort.test.ts tests/ws-upstream.test.ts tests/core-lab-boundary.test.ts",
|
|
42
43
|
"typecheck": "bun x tsc --noEmit",
|
|
44
|
+
"verify:v2-bridge": "bun run typecheck && bun run test:v2-bridge && cd gui && bun test tests/subagents-ultra-mode.test.tsx && bun run lint:i18n",
|
|
43
45
|
"audit:high": "bun audit --audit-level=high && cd gui && bun audit --audit-level=high",
|
|
44
46
|
"privacy:scan": "bun scripts/privacy-scan.ts",
|
|
45
47
|
"generate:model-metadata": "bun scripts/generate-model-metadata.ts",
|
|
@@ -67,6 +67,7 @@ function probeCcaSseEvent(bytes: Uint8Array): CcaSseProbe {
|
|
|
67
67
|
}
|
|
68
68
|
const serialized = JSON.stringify(frame);
|
|
69
69
|
if (isQuotaExhaustedBody(serialized)) return "quota_exhausted";
|
|
70
|
+
if (errorRecord.code === 429 || status === "RESOURCE_EXHAUSTED") return "rate_limit";
|
|
70
71
|
if (/rate[- ]limit|too many requests|per[- ]minute|requests per minute|concurrent request/i.test(serialized)) return "rate_limit";
|
|
71
72
|
if (isAntigravityGeoBlockedBody(serialized)) return "geo_blocked";
|
|
72
73
|
return "terminal";
|
package/src/config.ts
CHANGED
|
@@ -928,6 +928,9 @@ const configSchema = z.object({
|
|
|
928
928
|
providerContextCaps: z.record(z.string(), z.number().int().positive()).optional(),
|
|
929
929
|
contextCapValue: z.number().int().positive().optional(),
|
|
930
930
|
multiAgentGuidanceEnabled: z.boolean().optional(),
|
|
931
|
+
// Invalid hand edits disable only this experimental opt-in.
|
|
932
|
+
v2RoutedDelegationBridge: z.boolean().optional().catch(undefined),
|
|
933
|
+
// Invalid hand edits disable only this experimental opt-in subtree.
|
|
931
934
|
v2NativeParentOverride: v2NativeParentOverrideSchema.optional().catch(undefined),
|
|
932
935
|
// Invalid optional recovery config must not discard unrelated provider/account state.
|
|
933
936
|
agentTaskRecovery: agentTaskRecoverySchema.optional().catch(undefined),
|
|
@@ -2240,6 +2243,15 @@ function agentTaskRecoveryError(value: unknown): string | null {
|
|
|
2240
2243
|
return `schema_invalid: agentTaskRecovery${field ? `.${field}` : ""}: ${issue?.message ?? "invalid configuration"}`;
|
|
2241
2244
|
}
|
|
2242
2245
|
|
|
2246
|
+
function v2RoutedDelegationBridgeError(value: unknown): string | null {
|
|
2247
|
+
const raw = rawConfigRecord(value);
|
|
2248
|
+
if (!raw || !Object.hasOwn(raw, "v2RoutedDelegationBridge")) return null;
|
|
2249
|
+
const enabled = raw.v2RoutedDelegationBridge;
|
|
2250
|
+
return enabled === undefined || typeof enabled === "boolean"
|
|
2251
|
+
? null
|
|
2252
|
+
: "schema_invalid: v2RoutedDelegationBridge: must be a boolean or omitted";
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2243
2255
|
function v2NativeParentOverrideError(value: unknown): string | null {
|
|
2244
2256
|
const raw = rawConfigRecord(value);
|
|
2245
2257
|
if (!raw || !Object.hasOwn(raw, "v2NativeParentOverride") || raw.v2NativeParentOverride === undefined) return null;
|
|
@@ -2363,6 +2375,7 @@ export function validateConfigCandidate(value: unknown): { ok: true; config: Ocx
|
|
|
2363
2375
|
?? appOwnedMemoryBudgetError(value)
|
|
2364
2376
|
?? upstreamHostCircuitThresholdError(value)
|
|
2365
2377
|
?? agentTaskRecoveryError(value)
|
|
2378
|
+
?? v2RoutedDelegationBridgeError(value)
|
|
2366
2379
|
?? v2NativeParentOverrideError(value)
|
|
2367
2380
|
?? googleAntigravityStaticCatalogVersionError(value)
|
|
2368
2381
|
?? codexAccountPrioritiesError(value)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"path": "package.json",
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "95bec9ad35e50ab0249efda2fd4c4f58ab7765bd13f6fda5c13e46fbdf227637"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "scripts/model-metadata.source.json",
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
},
|
|
251
251
|
{
|
|
252
252
|
"path": "src/adapters/google-http.ts",
|
|
253
|
-
"sha256": "
|
|
253
|
+
"sha256": "83768c8cd3368e55ba6cc2a36c0551fbc67fb94534d27c5bb27e3d7de2dcdf50"
|
|
254
254
|
},
|
|
255
255
|
{
|
|
256
256
|
"path": "src/adapters/google-tool-schema.ts",
|
|
@@ -1166,7 +1166,7 @@
|
|
|
1166
1166
|
},
|
|
1167
1167
|
{
|
|
1168
1168
|
"path": "src/config.ts",
|
|
1169
|
-
"sha256": "
|
|
1169
|
+
"sha256": "4534807abf3722078ae2c6d377885a12d4e6921b376601ea6d76ccc3f677cfb9"
|
|
1170
1170
|
},
|
|
1171
1171
|
{
|
|
1172
1172
|
"path": "src/config/atomic-write.ts",
|
|
@@ -2174,7 +2174,7 @@
|
|
|
2174
2174
|
},
|
|
2175
2175
|
{
|
|
2176
2176
|
"path": "src/oauth/index.ts",
|
|
2177
|
-
"sha256": "
|
|
2177
|
+
"sha256": "d2891b2d232f7c4821e6a83860f335a6179e82b7f4f58d840bd2be8e5e8ba701"
|
|
2178
2178
|
},
|
|
2179
2179
|
{
|
|
2180
2180
|
"path": "src/oauth/key-providers.ts",
|
|
@@ -2710,7 +2710,7 @@
|
|
|
2710
2710
|
},
|
|
2711
2711
|
{
|
|
2712
2712
|
"path": "src/server/management/agent-settings-routes.ts",
|
|
2713
|
-
"sha256": "
|
|
2713
|
+
"sha256": "1fb5e34401044aedbc3164c083d0c1d37857083f3144e296d4e5ad4993bc3cee"
|
|
2714
2714
|
},
|
|
2715
2715
|
{
|
|
2716
2716
|
"path": "src/server/management/api-access.ts",
|
|
@@ -2946,7 +2946,7 @@
|
|
|
2946
2946
|
},
|
|
2947
2947
|
{
|
|
2948
2948
|
"path": "src/server/responses/core.ts",
|
|
2949
|
-
"sha256": "
|
|
2949
|
+
"sha256": "90ce7232996139a594f4055155db1cba61692f680c85e9d6d5601a0657c12c49"
|
|
2950
2950
|
},
|
|
2951
2951
|
{
|
|
2952
2952
|
"path": "src/server/responses/empty-completion-guard.ts",
|
|
@@ -2992,6 +2992,10 @@
|
|
|
2992
2992
|
"path": "src/server/responses/v2-native-parent-override.ts",
|
|
2993
2993
|
"sha256": "ec20872a1cf656d0c3d29bebdb8863e80f16140913f725612b617f1e271abada"
|
|
2994
2994
|
},
|
|
2995
|
+
{
|
|
2996
|
+
"path": "src/server/responses/v2-routed-delegation-bridge.ts",
|
|
2997
|
+
"sha256": "a0ea013323d54c81426a0abc42eef6682d160a9ce71e3fc209c3124034ee514b"
|
|
2998
|
+
},
|
|
2995
2999
|
{
|
|
2996
3000
|
"path": "src/server/responses/ws-upstream.ts",
|
|
2997
3001
|
"sha256": "a892b860cdc50e9f15f23fdb2f286a8e3416eff4ce163650f5226aab4159fd38"
|
|
@@ -3162,7 +3166,7 @@
|
|
|
3162
3166
|
},
|
|
3163
3167
|
{
|
|
3164
3168
|
"path": "src/types/config.ts",
|
|
3165
|
-
"sha256": "
|
|
3169
|
+
"sha256": "2947399e84229ff915fbe1677b4b29ddefafbde0cf42a10bdb130460fa1715fd"
|
|
3166
3170
|
},
|
|
3167
3171
|
{
|
|
3168
3172
|
"path": "src/types/provider.ts",
|
package/src/oauth/index.ts
CHANGED
|
@@ -1240,15 +1240,18 @@ export async function runLogin(
|
|
|
1240
1240
|
const existing = getAccountCredential(provider, opts.reauthAccountId);
|
|
1241
1241
|
if (!existing) throw new Error(`Unknown account for reauth: ${opts.reauthAccountId}`);
|
|
1242
1242
|
if (!existing.accountId && !existing.email) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
? existing.
|
|
1249
|
-
:
|
|
1250
|
-
|
|
1251
|
-
|
|
1243
|
+
if (provider !== GOOGLE_ANTIGRAVITY_PROVIDER || (!cred.accountId && !cred.email)) {
|
|
1244
|
+
throw new OAuthReauthIdentityUnverifiedError();
|
|
1245
|
+
}
|
|
1246
|
+
} else {
|
|
1247
|
+
const identityMatches = existing.accountId && cred.accountId
|
|
1248
|
+
? existing.accountId === cred.accountId
|
|
1249
|
+
: existing.email && cred.email
|
|
1250
|
+
? existing.email.toLowerCase() === cred.email.toLowerCase()
|
|
1251
|
+
: false;
|
|
1252
|
+
if (!identityMatches) {
|
|
1253
|
+
throw new OAuthReauthIdentityMismatchError();
|
|
1254
|
+
}
|
|
1252
1255
|
}
|
|
1253
1256
|
await (deps.saveAccountCredential ?? saveAccountCredential)(provider, opts.reauthAccountId, cred, {
|
|
1254
1257
|
assertBeforePersist: deps.assertCurrentOwner,
|
|
@@ -92,6 +92,17 @@ let grokApplyTestHooks: { now?: () => number; run?: () => Promise<unknown> } | n
|
|
|
92
92
|
type V2NativeParentOverrideInput = { enabled: boolean; model: string | null };
|
|
93
93
|
type AgentTaskRecoveryInput = { enabled: boolean; model: string | null };
|
|
94
94
|
|
|
95
|
+
function persistV2RoutedDelegationBridge(config: OcxConfig, enabled: boolean): { ok: true } | { ok: false; reason: string } {
|
|
96
|
+
const outcome = mutatePersistedConfig(persisted => {
|
|
97
|
+
const changed = persisted.v2RoutedDelegationBridge !== enabled;
|
|
98
|
+
if (changed) persisted.v2RoutedDelegationBridge = enabled;
|
|
99
|
+
return { changed, value: true };
|
|
100
|
+
});
|
|
101
|
+
if (outcome.status === "unavailable") return { ok: false, reason: outcome.reason };
|
|
102
|
+
config.v2RoutedDelegationBridge = enabled;
|
|
103
|
+
return { ok: true };
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
function agentTaskRecoveryDto(
|
|
96
107
|
config: OcxConfig,
|
|
97
108
|
): { enabled: boolean; model: string | null } {
|
|
@@ -342,6 +353,7 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
342
353
|
// server-side so no client can present it as an effective V2 limit.
|
|
343
354
|
agentsMaxDepthAppliesWhenV2Disabled: !enabled,
|
|
344
355
|
v2NativeParentOverride,
|
|
356
|
+
v2RoutedDelegationBridge: config.v2RoutedDelegationBridge === true,
|
|
345
357
|
agentTaskRecovery: agentTaskRecoveryDto(config),
|
|
346
358
|
});
|
|
347
359
|
}
|
|
@@ -356,6 +368,7 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
356
368
|
subagentDeveloperInstructions?: unknown;
|
|
357
369
|
multiAgentModeHintText?: unknown;
|
|
358
370
|
v2NativeParentOverride?: unknown;
|
|
371
|
+
v2RoutedDelegationBridge?: unknown;
|
|
359
372
|
agentTaskRecovery?: unknown;
|
|
360
373
|
};
|
|
361
374
|
try { body = await readManagementJsonBody(req); } catch (error) { rethrowManagementBodyTooLarge(error); return jsonResponse({ error: "invalid JSON body" }, 400); }
|
|
@@ -368,9 +381,10 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
368
381
|
const wantsSubagentInstructions = body.subagentDeveloperInstructions !== undefined;
|
|
369
382
|
const wantsModeHintText = body.multiAgentModeHintText !== undefined;
|
|
370
383
|
const wantsV2NativeParentOverride = body.v2NativeParentOverride !== undefined;
|
|
384
|
+
const wantsV2RoutedDelegationBridge = body.v2RoutedDelegationBridge !== undefined;
|
|
371
385
|
const wantsAgentTaskRecovery = body.agentTaskRecovery !== undefined;
|
|
372
|
-
if (!wantsFlag && !wantsThreads && !wantsMode && !wantsKeepNative && !wantsAgentsEnabled && !wantsMaxDepth && !wantsSubagentInstructions && !wantsModeHintText && !wantsV2NativeParentOverride && !wantsAgentTaskRecovery) {
|
|
373
|
-
return jsonResponse({ error: "body must set enabled, multiAgentMode, keepNativeChatGptOnV1, maxConcurrentThreadsPerSession, agentsEnabled, agentsMaxDepth, subagentDeveloperInstructions, multiAgentModeHintText, v2NativeParentOverride, and/or agentTaskRecovery" }, 400);
|
|
386
|
+
if (!wantsFlag && !wantsThreads && !wantsMode && !wantsKeepNative && !wantsAgentsEnabled && !wantsMaxDepth && !wantsSubagentInstructions && !wantsModeHintText && !wantsV2NativeParentOverride && !wantsV2RoutedDelegationBridge && !wantsAgentTaskRecovery) {
|
|
387
|
+
return jsonResponse({ error: "body must set enabled, multiAgentMode, keepNativeChatGptOnV1, maxConcurrentThreadsPerSession, agentsEnabled, agentsMaxDepth, subagentDeveloperInstructions, multiAgentModeHintText, v2NativeParentOverride, v2RoutedDelegationBridge, and/or agentTaskRecovery" }, 400);
|
|
374
388
|
}
|
|
375
389
|
if (wantsFlag && typeof body.enabled !== "boolean") return jsonResponse({ error: "body.enabled must be a boolean" }, 400);
|
|
376
390
|
if (wantsMode && body.multiAgentMode !== "v1" && body.multiAgentMode !== "default" && body.multiAgentMode !== "v2") {
|
|
@@ -379,6 +393,9 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
379
393
|
if (wantsKeepNative && typeof body.keepNativeChatGptOnV1 !== "boolean") {
|
|
380
394
|
return jsonResponse({ error: "body.keepNativeChatGptOnV1 must be a boolean" }, 400);
|
|
381
395
|
}
|
|
396
|
+
if (wantsV2RoutedDelegationBridge && typeof body.v2RoutedDelegationBridge !== "boolean") {
|
|
397
|
+
return jsonResponse({ error: "body.v2RoutedDelegationBridge must be a boolean" }, 400);
|
|
398
|
+
}
|
|
382
399
|
if (wantsThreads && (typeof body.maxConcurrentThreadsPerSession !== "number" || !Number.isInteger(body.maxConcurrentThreadsPerSession) || body.maxConcurrentThreadsPerSession < 1)) {
|
|
383
400
|
return jsonResponse({ error: "body.maxConcurrentThreadsPerSession must be an integer >= 1" }, 400);
|
|
384
401
|
}
|
|
@@ -493,6 +510,12 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
493
510
|
model: candidate.model === null || candidate.model === undefined ? null : (candidate.model as string).trim(),
|
|
494
511
|
};
|
|
495
512
|
}
|
|
513
|
+
if (wantsV2RoutedDelegationBridge && !wantsFlag && !wantsThreads && !wantsMode && !wantsKeepNative
|
|
514
|
+
&& !wantsAgentsEnabled && !wantsMaxDepth && !wantsSubagentInstructions && !wantsModeHintText && !wantsV2NativeParentOverride && !wantsAgentTaskRecovery) {
|
|
515
|
+
const persisted = persistV2RoutedDelegationBridge(config, body.v2RoutedDelegationBridge as boolean);
|
|
516
|
+
if (!persisted.ok) return jsonResponse({ error: `persisting v2RoutedDelegationBridge failed: ${persisted.reason}` }, 502);
|
|
517
|
+
return jsonResponse({ ok: true, v2RoutedDelegationBridge: config.v2RoutedDelegationBridge === true });
|
|
518
|
+
}
|
|
496
519
|
if (agentTaskRecovery && !wantsFlag && !wantsThreads && !wantsMode && !wantsKeepNative
|
|
497
520
|
&& !wantsAgentsEnabled && !wantsMaxDepth && !wantsSubagentInstructions && !wantsModeHintText && !wantsV2NativeParentOverride) {
|
|
498
521
|
const persisted = persistAgentTaskRecovery(config, agentTaskRecovery);
|
|
@@ -593,6 +616,10 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
593
616
|
const persisted = persistV2NativeParentOverride(config, v2NativeParentOverride);
|
|
594
617
|
if (!persisted.ok) return jsonResponse({ error: `persisting v2NativeParentOverride failed: ${persisted.reason}` }, 502);
|
|
595
618
|
}
|
|
619
|
+
if (wantsV2RoutedDelegationBridge) {
|
|
620
|
+
const persisted = persistV2RoutedDelegationBridge(config, body.v2RoutedDelegationBridge as boolean);
|
|
621
|
+
if (!persisted.ok) return jsonResponse({ error: `persisting v2RoutedDelegationBridge failed: ${persisted.reason}` }, 502);
|
|
622
|
+
}
|
|
596
623
|
if (agentTaskRecovery) {
|
|
597
624
|
const persisted = persistAgentTaskRecovery(config, agentTaskRecovery);
|
|
598
625
|
if (!persisted.ok) return jsonResponse({ error: `persisting agentTaskRecovery failed: ${persisted.reason}` }, 502);
|
|
@@ -613,6 +640,7 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
|
|
|
613
640
|
multiAgentModeHintText: getMultiAgentModeHintText(),
|
|
614
641
|
agentsMaxDepthAppliesWhenV2Disabled: !enabled,
|
|
615
642
|
v2NativeParentOverride: v2NativeParentOverrideDto(config, enabled),
|
|
643
|
+
v2RoutedDelegationBridge: config.v2RoutedDelegationBridge === true,
|
|
616
644
|
agentTaskRecovery: agentTaskRecoveryDto(config),
|
|
617
645
|
warnings,
|
|
618
646
|
catalogRefresh,
|
|
@@ -244,6 +244,7 @@ import { readBoundedResponseBody } from "../../lib/bounded-body";
|
|
|
244
244
|
import type { AdmissionLease } from "../../lib/admission";
|
|
245
245
|
import { supportedLadderFor } from "../effort-policy";
|
|
246
246
|
import { isThreadSpawnRequest } from "../effort-policy";
|
|
247
|
+
import { isMultiAgentV2Enabled } from "../../codex/features";
|
|
247
248
|
import {
|
|
248
249
|
applySubagentModelFallback,
|
|
249
250
|
maybePrimeSubagentQuota,
|
|
@@ -321,6 +322,12 @@ import type { EffectiveSubagentRoster, SpawnAgentSurface } from "../../codex/cat
|
|
|
321
322
|
|
|
322
323
|
import { buildToolBridgeMaps, collabSurface, injectDeveloperMessage, multiAgentGuidanceText } from "./collaboration";
|
|
323
324
|
import { decideV2NativeParentOverride } from "./v2-native-parent-override";
|
|
325
|
+
import {
|
|
326
|
+
createV2RoutedDelegationSseRewrite,
|
|
327
|
+
injectV2RoutedDelegationBridge,
|
|
328
|
+
rewriteV2RoutedDelegationCallsInJson,
|
|
329
|
+
type V2RoutedDelegationBridgeContext,
|
|
330
|
+
} from "./v2-routed-delegation-bridge";
|
|
324
331
|
import { mapCodexAuthContextErrorToResponse } from "./codex-auth-error";
|
|
325
332
|
import { hasUnreadableEncryptedAgentTask, looksLikeBackendCiphertext, sanitizeEncryptedContentInPlace } from "./encrypted-payload";
|
|
326
333
|
import { fetchWithHeaderTimeout, providerFetch, safeHostLabel, safeOriginLabel } from "./fetch-helpers";
|
|
@@ -2529,11 +2536,13 @@ async function handleResponsesInner(
|
|
|
2529
2536
|
|
|
2530
2537
|
// Shadow call intercept: rewrite Codex 0.145.0+ helper calls (gpt-5.6-luna).
|
|
2531
2538
|
// Ancient clients using gpt-5.4-mini remain configurable via sourceModels.
|
|
2539
|
+
let shadowIntercepted = false;
|
|
2532
2540
|
const _sci = config.shadowCallIntercept;
|
|
2533
2541
|
if (_sci?.enabled && _sci.model && shouldInterceptShadowCall(
|
|
2534
2542
|
parsed.modelId,
|
|
2535
2543
|
_sci.sourceModels,
|
|
2536
2544
|
)) {
|
|
2545
|
+
shadowIntercepted = true;
|
|
2537
2546
|
const _sciOriginal = parsed.modelId;
|
|
2538
2547
|
parsed.modelId = _sci.model;
|
|
2539
2548
|
if (parsed._rawBody && typeof parsed._rawBody === "object") {
|
|
@@ -2596,6 +2605,28 @@ async function handleResponsesInner(
|
|
|
2596
2605
|
}
|
|
2597
2606
|
}
|
|
2598
2607
|
|
|
2608
|
+
let v2RoutedDelegationBridge: V2RoutedDelegationBridgeContext | undefined;
|
|
2609
|
+
if (
|
|
2610
|
+
inboundWire === "responses"
|
|
2611
|
+
&& config.v2RoutedDelegationBridge === true
|
|
2612
|
+
&& config.multiAgentMode === "v2"
|
|
2613
|
+
&& isMultiAgentV2Enabled()
|
|
2614
|
+
&& isCanonicalOpenAiForwardProvider(route.provider)
|
|
2615
|
+
&& collabSurface(parsed) === "v2"
|
|
2616
|
+
&& !isThreadSpawnRequest(req.headers)
|
|
2617
|
+
&& !req.headers.has("x-openai-subagent")
|
|
2618
|
+
&& !options.comboAttempt
|
|
2619
|
+
&& parsed._compactionRequest !== true
|
|
2620
|
+
&& !shadowIntercepted
|
|
2621
|
+
) {
|
|
2622
|
+
try {
|
|
2623
|
+
v2RoutedDelegationBridge = injectV2RoutedDelegationBridge(parsed);
|
|
2624
|
+
if (v2RoutedDelegationBridge) toolBridgeMaps = buildToolBridgeMaps(parsed, translatorBudget);
|
|
2625
|
+
} catch (error) {
|
|
2626
|
+
return formatErrorResponse(400, "invalid_request_error", error instanceof Error ? error.message : String(error));
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2599
2630
|
const hasUnexpandedPreviousResponse = !!parsed.previousResponseId
|
|
2600
2631
|
&& parsed._previousResponseInputExpanded !== true;
|
|
2601
2632
|
// Exact account selectors are isolated from Pool-wide quota work. A canonical replay miss must
|
|
@@ -3000,6 +3031,16 @@ async function handleResponsesInner(
|
|
|
3000
3031
|
if (snapshot.projectId) rotatedProvider = { ...rotatedProvider, project: snapshot.projectId };
|
|
3001
3032
|
route.provider = rotatedProvider;
|
|
3002
3033
|
if (route.providerName === "kiro") parsed._kiroAuthContext = { ...(snapshot.kiro ?? {}) };
|
|
3034
|
+
if (isAntigravityOAuth) {
|
|
3035
|
+
antigravityAccountId = snapshot.accountId;
|
|
3036
|
+
sentOAuthSnapshot = snapshot;
|
|
3037
|
+
replayOAuthCredentialSnapshot = {
|
|
3038
|
+
accountId: snapshot.accountId,
|
|
3039
|
+
generation: snapshot.generation,
|
|
3040
|
+
};
|
|
3041
|
+
logCtx.accountLogLabel = snapshot.accountId ?? genericFailoverAccountId;
|
|
3042
|
+
bindAntigravitySessionAffinity(antigravitySessionKey, snapshot.accountId ?? genericFailoverAccountId);
|
|
3043
|
+
}
|
|
3003
3044
|
return true;
|
|
3004
3045
|
};
|
|
3005
3046
|
const oauthSessionKeyParts = {
|
|
@@ -3412,7 +3453,12 @@ async function handleResponsesInner(
|
|
|
3412
3453
|
&& (!parsed.previousResponseId || parsed._previousResponseInputExpanded === true);
|
|
3413
3454
|
const rememberPassthroughResponse = passthroughRecordEligible
|
|
3414
3455
|
? (response: { id?: unknown; output?: unknown; status?: unknown }) =>
|
|
3415
|
-
rememberResponseState(
|
|
3456
|
+
rememberResponseState(
|
|
3457
|
+
v2RoutedDelegationBridge?.requestStateBody ?? parsed._rawBody,
|
|
3458
|
+
response,
|
|
3459
|
+
undefined,
|
|
3460
|
+
responseStateOptions(true),
|
|
3461
|
+
)
|
|
3416
3462
|
: undefined;
|
|
3417
3463
|
if (parsed.previousResponseId && !parsed._previousResponseInputExpanded) {
|
|
3418
3464
|
console.warn(
|
|
@@ -4198,6 +4244,17 @@ async function handleResponsesInner(
|
|
|
4198
4244
|
options.responsesTerminalRepairScheduler,
|
|
4199
4245
|
)
|
|
4200
4246
|
: upstreamResponse.body;
|
|
4247
|
+
// The bridge owns request-scoped item-id admission. Apply it before the
|
|
4248
|
+
// stream is split so the client, inspector, and continuation cache see
|
|
4249
|
+
// the same authorized event history.
|
|
4250
|
+
const bridgeSseRewrite = createV2RoutedDelegationSseRewrite(v2RoutedDelegationBridge);
|
|
4251
|
+
const normalizedPassthroughSseBody = bridgeSseRewrite
|
|
4252
|
+
? relaySseWithBlockRewrite(
|
|
4253
|
+
passthroughSseBody,
|
|
4254
|
+
payloadRewriteAsBlockRewrite(bridgeSseRewrite),
|
|
4255
|
+
translatorBudget,
|
|
4256
|
+
)
|
|
4257
|
+
: passthroughSseBody;
|
|
4201
4258
|
const repairConfig = route.provider.responsesItemIdRepair;
|
|
4202
4259
|
const snapshotRepairEnabled = hasResponsesSnapshotRepair(route.provider.responsesSnapshotRepair);
|
|
4203
4260
|
const githubCopilotRepairEnabled = route.providerName === "github-copilot";
|
|
@@ -4259,7 +4316,7 @@ async function handleResponsesInner(
|
|
|
4259
4316
|
const clientBlockRewrite = blockRewrites.length > 0
|
|
4260
4317
|
? composeSseBlockRewrites(...blockRewrites)
|
|
4261
4318
|
: undefined;
|
|
4262
|
-
const needsClientRewrite = clientBlockRewrite !== undefined;
|
|
4319
|
+
const needsClientRewrite = bridgeSseRewrite !== undefined || clientBlockRewrite !== undefined;
|
|
4263
4320
|
// #864: win32 rewrite traffic must never enter the tee()+JS-pull chain
|
|
4264
4321
|
// (Bun#32111 JS-sink segfault — text frames pass, the terminal block is
|
|
4265
4322
|
// lost). The eager single reader applies the same rewrites inline.
|
|
@@ -4308,7 +4365,7 @@ async function handleResponsesInner(
|
|
|
4308
4365
|
onFirstOutput: options.onFirstOutput,
|
|
4309
4366
|
pinCompletedResponseIdToFirstSeen: githubCopilotRepairEnabled,
|
|
4310
4367
|
});
|
|
4311
|
-
const eagerBody = relaySseEagerBounded(
|
|
4368
|
+
const eagerBody = relaySseEagerBounded(normalizedPassthroughSseBody, turnAc, {
|
|
4312
4369
|
inspectChunk: chunk => inspector.feed(chunk),
|
|
4313
4370
|
finishInspection: () => inspector.finish(),
|
|
4314
4371
|
disposeInspection: () => inspector.dispose(),
|
|
@@ -4345,7 +4402,7 @@ async function handleResponsesInner(
|
|
|
4345
4402
|
})),
|
|
4346
4403
|
);
|
|
4347
4404
|
}
|
|
4348
|
-
const [nativeBody, inspectBody] =
|
|
4405
|
+
const [nativeBody, inspectBody] = normalizedPassthroughSseBody.tee();
|
|
4349
4406
|
const turnAc = new AbortController();
|
|
4350
4407
|
const clientGone = new AbortController();
|
|
4351
4408
|
linkAbortSignal(upstream, turnAc.signal);
|
|
@@ -4436,8 +4493,12 @@ async function handleResponsesInner(
|
|
|
4436
4493
|
restoreImageGenCallsInJson(text, imageGenCallAliases),
|
|
4437
4494
|
routedNamespaceToolAliases,
|
|
4438
4495
|
);
|
|
4439
|
-
const
|
|
4496
|
+
const bridgeNormalized = rewriteV2RoutedDelegationCallsInJson(
|
|
4440
4497
|
restoredNamespace,
|
|
4498
|
+
v2RoutedDelegationBridge,
|
|
4499
|
+
);
|
|
4500
|
+
const restored = restoreRoutedCustomCallsInJson(
|
|
4501
|
+
bridgeNormalized,
|
|
4441
4502
|
routedCustomToolNames,
|
|
4442
4503
|
routedCustomToolRepairNames,
|
|
4443
4504
|
declaredWireToolNames,
|
|
@@ -4485,7 +4546,7 @@ async function handleResponsesInner(
|
|
|
4485
4546
|
if (rememberPassthroughResponseChecked) {
|
|
4486
4547
|
try {
|
|
4487
4548
|
rememberPassthroughResponseChecked(
|
|
4488
|
-
JSON.parse(
|
|
4549
|
+
JSON.parse(clientJson) as { id?: unknown; output?: unknown; status?: unknown },
|
|
4489
4550
|
);
|
|
4490
4551
|
} catch { /* non-JSON despite content-type; recording is best-effort */ }
|
|
4491
4552
|
}
|
|
@@ -5502,9 +5563,8 @@ async function handleResponsesInner(
|
|
|
5502
5563
|
upstreamResponse = result;
|
|
5503
5564
|
}
|
|
5504
5565
|
|
|
5505
|
-
// Antigravity
|
|
5506
|
-
//
|
|
5507
|
-
// the client so a conversation cannot churn through accounts or requests.
|
|
5566
|
+
// Antigravity-specific recovery allows only one short, abort-aware replay on the same
|
|
5567
|
+
// credential. The generic OAuth failover below may still rotate when another account exists.
|
|
5508
5568
|
if (upstreamResponse.status === 403 && isAntigravityOAuth && antigravityAccountId) {
|
|
5509
5569
|
recordAntigravityCooldown(antigravityAccountId, upstreamResponse.headers.get("retry-after"), Date.now(), "geoblock");
|
|
5510
5570
|
}
|