@bitkyc08/opencodex 2.100.3 → 2.100.4

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.
Files changed (181) hide show
  1. package/AGENTS_INSTALL.md +23 -1
  2. package/bin/ocx.mjs +8 -1
  3. package/gui/dist/assets/{App-Dnb6VMsP.js → App-DcpyI78f.js} +20 -19
  4. package/gui/dist/assets/{Tray-BV4ms9U9.js → Tray-CzjPJprT.js} +1 -1
  5. package/gui/dist/assets/brand-mark-BTIi7e69.js +1 -0
  6. package/gui/dist/assets/index-DJxM-imn.css +2 -0
  7. package/gui/dist/assets/index-DVgU6S3y.js +138 -0
  8. package/gui/dist/assets/{segment-thumb-features-DXSidY6D.js → segment-thumb-features-Bn6Y-g3R.js} +1 -1
  9. package/gui/dist/classic/assets/{App-DA-scMPq.js → App-eYJAyNHM.js} +19 -18
  10. package/gui/dist/classic/assets/{Tray-BrHaVRAq.js → Tray-xHMYxLkV.js} +1 -1
  11. package/gui/dist/classic/assets/index-DSaVRW4F.js +138 -0
  12. package/gui/dist/classic/assets/quota-summary-DyzHlkFl.js +1 -0
  13. package/gui/dist/classic/index.html +1 -1
  14. package/gui/dist/index.html +2 -2
  15. package/native/ocx-child/src/cli.rs +5 -3
  16. package/native/ocx-child/src/codex_home.rs +1 -0
  17. package/package.json +2 -2
  18. package/src/adapters/anthropic/per-message-effort.ts +296 -0
  19. package/src/adapters/anthropic.ts +3 -0
  20. package/src/adapters/claude-cli/adapter.ts +1 -0
  21. package/src/adapters/devin/cloud-direct/chat.ts +71 -14
  22. package/src/adapters/google-errors.ts +14 -2
  23. package/src/adapters/qoder/adapter.ts +9 -1
  24. package/src/adapters/zed.ts +4 -2
  25. package/src/claude/desktop-remote-store.ts +60 -10
  26. package/src/cli/account-api.ts +4 -0
  27. package/src/cli/account-auth.ts +30 -2
  28. package/src/cli/account-extended.ts +33 -2
  29. package/src/cli/capabilities-access-remote.ts +3 -3
  30. package/src/cli/capabilities-accounts.ts +3 -3
  31. package/src/cli/capabilities-base.ts +11 -6
  32. package/src/cli/capabilities-observe-system.ts +2 -2
  33. package/src/cli/claude.ts +3 -3
  34. package/src/cli/disconnect-runtime.ts +16 -6
  35. package/src/cli/dispatch.ts +7 -1
  36. package/src/cli/index.ts +2 -2
  37. package/src/cli/link-apply-restart.ts +4 -2
  38. package/src/cli/link-routes.ts +4 -1
  39. package/src/cli/link.ts +5 -4
  40. package/src/cli/preflight-exemptions.ts +3 -0
  41. package/src/cli/registry.ts +5 -2
  42. package/src/cli/resolve.ts +23 -8
  43. package/src/cli/restart-failure.ts +11 -1
  44. package/src/cli/runtime-api.ts +4 -0
  45. package/src/cli/status.ts +4 -1
  46. package/src/cli/system-command.ts +1 -1
  47. package/src/cli/system-restart-client.ts +9 -3
  48. package/src/cli/system-settings-parity.ts +2 -1
  49. package/src/client/connect.ts +63 -9
  50. package/src/client/desktop-refusal.ts +38 -0
  51. package/src/client/lifecycle-lock.ts +29 -4
  52. package/src/client/runtime-restart.ts +27 -15
  53. package/src/client/runtime.ts +4 -2
  54. package/src/client/state.ts +14 -0
  55. package/src/codex/account-pause.ts +4 -0
  56. package/src/codex/account-runtime-state.ts +4 -0
  57. package/src/codex/auth-api/main-account-probe.ts +3 -1
  58. package/src/codex/auth-api/main-hard-lock-refusal-read.ts +172 -0
  59. package/src/codex/auth-context.ts +40 -2
  60. package/src/codex/catalog/build-entries.ts +10 -0
  61. package/src/codex/catalog/derive-entry.ts +7 -0
  62. package/src/codex/catalog/reserve-warn.ts +7 -5
  63. package/src/codex/catalog/reserve.ts +4 -3
  64. package/src/codex/catalog/retained-sync.ts +2 -0
  65. package/src/codex/catalog/routed-defaults.ts +35 -0
  66. package/src/codex/convergence.ts +2 -0
  67. package/src/codex/loopback-target.ts +22 -8
  68. package/src/codex/main-account.ts +88 -29
  69. package/src/codex/native-main-auth-file.ts +14 -0
  70. package/src/codex/native-main-credentials.ts +270 -0
  71. package/src/codex/native-main-owner.ts +3 -0
  72. package/src/codex/native-main-refresh-mode.ts +14 -1
  73. package/src/codex/quota.ts +63 -14
  74. package/src/combos/failover.ts +12 -1
  75. package/src/combos/index.ts +5 -0
  76. package/src/combos/resolve.ts +115 -19
  77. package/src/config/diagnostics.ts +3 -0
  78. package/src/config/live-reconcile.ts +6 -3
  79. package/src/config/load-degrade.ts +2 -0
  80. package/src/config/persisted-mutation.ts +2 -2
  81. package/src/config/persisted-projections.ts +18 -0
  82. package/src/config/process-state.ts +4 -3
  83. package/src/config/reserve-capability.ts +96 -0
  84. package/src/config/schema/config-schema.ts +6 -0
  85. package/src/config/schema/leaf-validators.ts +2 -0
  86. package/src/config/schema/routed-catalog-defaults.ts +49 -0
  87. package/src/config.ts +7 -7
  88. package/src/desktop-update/acquire.ts +202 -0
  89. package/src/desktop-update/cli.ts +168 -0
  90. package/src/desktop-update/drain.ts +40 -0
  91. package/src/desktop-update/headless.ts +285 -0
  92. package/src/desktop-update/image.ts +85 -0
  93. package/src/desktop-update/install.ts +53 -0
  94. package/src/desktop-update/msi.ts +72 -0
  95. package/src/desktop-update/release.ts +128 -0
  96. package/src/desktop-update/runtime.ts +155 -0
  97. package/src/desktop-update/staging.ts +118 -0
  98. package/src/desktop-update/trust.ts +45 -0
  99. package/src/generated/compatibility-version.json +246 -130
  100. package/src/images/fulfill-video.ts +3 -3
  101. package/src/images/loop.ts +6 -2
  102. package/src/images/plan.ts +147 -11
  103. package/src/images/types.ts +13 -4
  104. package/src/images/xai-video-client.ts +72 -10
  105. package/src/lib/gcp-adc.ts +48 -4
  106. package/src/lib/offline-resend.ts +150 -0
  107. package/src/lib/paced-stream.ts +3 -3
  108. package/src/lib/provider-outbound.ts +17 -6
  109. package/src/lib/request-failure-model.ts +2 -0
  110. package/src/lib/response-body-inactivity.ts +23 -1
  111. package/src/lib/upstream-retry.ts +38 -5
  112. package/src/link/explicit-route.ts +4 -4
  113. package/src/link/remote-windows.ts +79 -31
  114. package/src/link/residual-recovery.ts +20 -8
  115. package/src/messaging/budget.ts +23 -5
  116. package/src/messaging/rpc.ts +4 -4
  117. package/src/oauth/antigravity-risk.ts +126 -0
  118. package/src/oauth/generic-account-failover.ts +89 -18
  119. package/src/oauth/generic-session-affinity.ts +10 -3
  120. package/src/oauth/login-cli.ts +35 -1
  121. package/src/oauth/pool-kernel.ts +3 -3
  122. package/src/providers/anthropic-billing-refusal.ts +27 -3
  123. package/src/providers/google-vertex-model-discovery.ts +6 -1
  124. package/src/providers/model-rename-fields.ts +2 -0
  125. package/src/providers/quota/workbuddy.ts +6 -2
  126. package/src/providers/workbuddy-credit-balance.ts +125 -16
  127. package/src/responses/effort-history.ts +732 -0
  128. package/src/routing/history/integrity.ts +41 -4
  129. package/src/server/auth-cors.ts +13 -3
  130. package/src/server/codex-model-list.ts +2 -1
  131. package/src/server/direct-local-http.ts +26 -3
  132. package/src/server/index/link-listener.ts +20 -14
  133. package/src/server/index/serve-options.ts +1 -0
  134. package/src/server/index.ts +3 -2
  135. package/src/server/link-turn.ts +17 -5
  136. package/src/server/management/config-routes.ts +39 -3
  137. package/src/server/management/link-child-preflight.ts +1 -1
  138. package/src/server/management/link-route-edit.ts +20 -1
  139. package/src/server/management/oauth-account-routes.ts +22 -5
  140. package/src/server/management/provider-overwrite-carry.ts +3 -0
  141. package/src/server/management/provider-routes.ts +4 -4
  142. package/src/server/management/static-catalog-probe.ts +33 -0
  143. package/src/server/proxy-liveness.ts +54 -9
  144. package/src/server/relay.ts +6 -1
  145. package/src/server/request-log-conversation.ts +2 -2
  146. package/src/server/request-log.ts +5 -1
  147. package/src/server/reserve-capability-startup.ts +32 -0
  148. package/src/server/responses/adapter-delivery.ts +2 -0
  149. package/src/server/responses/adapter-dispatch.ts +31 -10
  150. package/src/server/responses/antigravity-fault-rotation.ts +24 -0
  151. package/src/server/responses/antigravity-validation-refusal.ts +43 -6
  152. package/src/server/responses/combo-selection-keepalive.ts +254 -0
  153. package/src/server/responses/core-combo.ts +24 -9
  154. package/src/server/responses/core-errors.ts +9 -6
  155. package/src/server/responses/core-options.ts +8 -0
  156. package/src/server/responses/core.ts +21 -0
  157. package/src/server/responses/estimated-usage.ts +115 -0
  158. package/src/server/responses/jev-model-invoke.ts +7 -2
  159. package/src/server/responses/passthrough-completion.ts +6 -3
  160. package/src/server/responses/passthrough-delivery.ts +47 -8
  161. package/src/server/responses/passthrough-dispatch.ts +3 -0
  162. package/src/server/responses/request-prepare.ts +9 -5
  163. package/src/server/responses/sidecar-execution.ts +5 -0
  164. package/src/service/desktop-supervision.d.mts +2 -0
  165. package/src/service/desktop-supervision.mjs +5 -0
  166. package/src/stall-timeout.ts +11 -0
  167. package/src/types/config.ts +15 -92
  168. package/src/types/provider.ts +13 -0
  169. package/src/types/request.ts +19 -0
  170. package/src/types/routed-catalog-defaults.ts +17 -0
  171. package/src/types/routing-profile.ts +90 -0
  172. package/src/types.ts +1 -0
  173. package/src/update/index.ts +1 -1
  174. package/src/usage/log.ts +14 -4
  175. package/src/usage/telemetry-contract.ts +1 -0
  176. package/src/web-search/passthrough-bridge.ts +7 -0
  177. package/gui/dist/assets/brand-mark-XOLJbomA.js +0 -1
  178. package/gui/dist/assets/index-DCdXsMyZ.js +0 -105
  179. package/gui/dist/assets/index-DQtCRNAw.css +0 -2
  180. package/gui/dist/classic/assets/index-BqOaGLf5.js +0 -105
  181. package/gui/dist/classic/assets/quota-summary-Dy5_wfTT.js +0 -1
@@ -7,11 +7,39 @@
7
7
  * serving-thread scan is needed, and operational failures only delay retry.
8
8
  */
9
9
 
10
+ import { statSync } from "node:fs";
10
11
  import { RebuildWorkerJob } from "./rebuild-job";
11
12
 
12
13
  export const REQUEST_HISTORY_INTEGRITY_INTERVAL_MS = 5 * 60_000;
13
14
  export const REQUEST_HISTORY_INTEGRITY_FAILURE_COOLDOWN_MS = 30_000;
14
15
  export const REQUEST_HISTORY_INTEGRITY_CHECK_TIMEOUT_MS = 30_000;
16
+ export const REQUEST_HISTORY_INTEGRITY_CHECK_MAX_TIMEOUT_MS = 15 * 60_000;
17
+ /**
18
+ * quick_check reads every index page, so its cost scales with file size. Assume
19
+ * a conservative sustained scan rate well below observed throughput; the 30 s
20
+ * constant stays the floor for the small indexes it was chosen for.
21
+ */
22
+ const REQUEST_HISTORY_INTEGRITY_CHECK_MIN_SCAN_BYTES_PER_SECOND = 32 * 1024 * 1024;
23
+
24
+ function indexFileSizeBytes(path: string): number | undefined {
25
+ try {
26
+ return statSync(path).size;
27
+ } catch {
28
+ return undefined;
29
+ }
30
+ }
31
+
32
+ /** Per-generation check bound: the 30 s floor, scaled by index size, capped. */
33
+ export function requestHistoryIntegrityCheckTimeoutMs(indexBytes: number | undefined): number {
34
+ if (indexBytes === undefined || !Number.isFinite(indexBytes) || indexBytes <= 0) {
35
+ return REQUEST_HISTORY_INTEGRITY_CHECK_TIMEOUT_MS;
36
+ }
37
+ const scaledMs = Math.ceil(indexBytes / REQUEST_HISTORY_INTEGRITY_CHECK_MIN_SCAN_BYTES_PER_SECOND * 1000);
38
+ return Math.min(
39
+ REQUEST_HISTORY_INTEGRITY_CHECK_MAX_TIMEOUT_MS,
40
+ Math.max(REQUEST_HISTORY_INTEGRITY_CHECK_TIMEOUT_MS, scaledMs),
41
+ );
42
+ }
15
43
 
16
44
  type IntegrityJob = Pick<RebuildWorkerJob, "check" | "dispose" | "afterExit">;
17
45
 
@@ -38,6 +66,7 @@ interface Generation {
38
66
  corrupt: boolean;
39
67
  nextCheckAt: number;
40
68
  failure: { error: unknown } | null;
69
+ timeoutMs: number;
41
70
  }
42
71
 
43
72
  interface ActiveCheck {
@@ -59,7 +88,7 @@ export class RequestHistoryIntegrityMonitor {
59
88
  private readonly now: () => number;
60
89
  private readonly intervalMs: number;
61
90
  private readonly failureCooldownMs: number;
62
- private readonly checkTimeoutMs: number;
91
+ private readonly checkTimeoutMs: number | undefined;
63
92
  private readonly scheduleTimeout: (callback: () => void, ms: number) => () => void;
64
93
  private current: Generation | null = null;
65
94
  private active: ActiveCheck | null = null;
@@ -70,7 +99,7 @@ export class RequestHistoryIntegrityMonitor {
70
99
  this.now = options.now ?? Date.now;
71
100
  this.intervalMs = options.intervalMs ?? REQUEST_HISTORY_INTEGRITY_INTERVAL_MS;
72
101
  this.failureCooldownMs = options.failureCooldownMs ?? REQUEST_HISTORY_INTEGRITY_FAILURE_COOLDOWN_MS;
73
- this.checkTimeoutMs = options.checkTimeoutMs ?? REQUEST_HISTORY_INTEGRITY_CHECK_TIMEOUT_MS;
102
+ this.checkTimeoutMs = options.checkTimeoutMs;
74
103
  this.scheduleTimeout = options.scheduleTimeout ?? ((callback, ms) => {
75
104
  const timer = setTimeout(callback, ms);
76
105
  return () => clearTimeout(timer);
@@ -80,7 +109,10 @@ export class RequestHistoryIntegrityMonitor {
80
109
  inspect(handle: object, path: string): RequestHistoryIntegrityState {
81
110
  if (this.current?.handle !== handle || this.current.path !== path) {
82
111
  this.quiesce();
83
- this.current = { handle, path, verified: false, corrupt: false, nextCheckAt: -Infinity, failure: null };
112
+ this.current = {
113
+ handle, path, verified: false, corrupt: false, nextCheckAt: -Infinity, failure: null,
114
+ timeoutMs: this.generationTimeoutMs(path),
115
+ };
84
116
  }
85
117
  const generation = this.current;
86
118
  if (generation.corrupt) return { state: "corrupt" };
@@ -115,9 +147,14 @@ export class RequestHistoryIntegrityMonitor {
115
147
  this.current = {
116
148
  handle, path, verified: true, corrupt: false,
117
149
  nextCheckAt: this.now() + this.intervalMs, failure: null,
150
+ timeoutMs: this.generationTimeoutMs(path),
118
151
  };
119
152
  }
120
153
 
154
+ private generationTimeoutMs(path: string): number {
155
+ return this.checkTimeoutMs ?? requestHistoryIntegrityCheckTimeoutMs(indexFileSizeBytes(path));
156
+ }
157
+
121
158
  /**
122
159
  * Invalidate and stop the current check. Null means the index can be replaced
123
160
  * now; otherwise await the returned barrier before deleting or renaming it.
@@ -166,7 +203,7 @@ export class RequestHistoryIntegrityMonitor {
166
203
  private async run(check: ActiveCheck, job: IntegrityJob, cancelled: Promise<CheckOutcome>, release: () => void): Promise<void> {
167
204
  let expire!: (outcome: CheckOutcome) => void;
168
205
  const timeout = new Promise<CheckOutcome>(resolve => { expire = resolve; });
169
- const clear = this.scheduleTimeout(() => expire({ kind: "timeout", error: new Error("request-history integrity check timed out") }), this.checkTimeoutMs);
206
+ const clear = this.scheduleTimeout(() => expire({ kind: "timeout", error: new Error("request-history integrity check timed out") }), check.generation.timeoutMs);
170
207
  const observed = Promise.resolve().then(async (): Promise<CheckOutcome> => {
171
208
  if (check.cancelled) return { kind: "cancelled" };
172
209
  try {
@@ -35,6 +35,8 @@ import {
35
35
  credentialPinnedProviderConfigError,
36
36
  } from "../config/provider-validation";
37
37
  import { providerDestinationConfigError } from "../lib/destination-policy";
38
+ import { gcpCredentialMarkerAccount, vertexAdcCredentialVerified, vertexConfiguredCredentialKind } from "../lib/gcp-adc";
39
+ import { selectVertexDiscoveryCredential } from "../providers/google-vertex-model-discovery";
38
40
  import { providerEgressConfigError } from "../lib/provider-egress";
39
41
  import { providerTlsProfileConfigError } from "../lib/provider-tls-profile";
40
42
  import { redactSecretString } from "../lib/redact";
@@ -1329,6 +1331,7 @@ const PROVIDER_CONFIG_FIELD_POLICY = {
1329
1331
  escapeBuiltinToolNames: "editor",
1330
1332
  anthropicEofTolerance: "editor",
1331
1333
  forwardAdvisorTool: "editor",
1334
+ perMessageEffort: "editor",
1332
1335
  noVisionModels: "editor",
1333
1336
  googleMode: "editor",
1334
1337
  project: "editor",
@@ -1338,6 +1341,7 @@ const PROVIDER_CONFIG_FIELD_POLICY = {
1338
1341
  unsafeAllowNativeLocalExec: "editor",
1339
1342
  nativeLocalExec: "editor",
1340
1343
  messagePhaseInference: "editor",
1344
+ estimateMissingUsage: "editor",
1341
1345
  tlsProfile: "editor",
1342
1346
  } as const satisfies Record<keyof OcxProviderConfig, ProviderConfigFieldPolicy>;
1343
1347
 
@@ -1476,9 +1480,15 @@ export function safeConfigDTO(config: OcxConfig): unknown {
1476
1480
  && providerMatchesRegistryTransport(name, provider));
1477
1481
  if (vertex) {
1478
1482
  const key = provider.apiKey;
1479
- dto.vertexCredentialKind = key?.startsWith("gcp-sa:") ? "marker"
1480
- : !key?.trim() || key === "N/A" || key.startsWith("<") ? "ambient"
1481
- : key.startsWith("keychain:") || /^\$\{?\w+\}?$/.test(key) ? "reference" : "api-key";
1483
+ dto.vertexCredentialKind = vertexConfiguredCredentialKind(key);
1484
+ if (dto.vertexCredentialKind === "ambient" || dto.vertexCredentialKind === "marker") {
1485
+ // Proof is reported only for the credential inference selects: an ambient row with
1486
+ // GOOGLE_CLOUD_API_KEY set sends that key, so an ADC token says nothing about it.
1487
+ try {
1488
+ const selection = selectVertexDiscoveryCredential(provider);
1489
+ if (selection.kind === "adc") dto.vertexCredentialVerified = vertexAdcCredentialVerified(gcpCredentialMarkerAccount(selection.marker));
1490
+ } catch { dto.vertexCredentialVerified = false; }
1491
+ }
1482
1492
  }
1483
1493
  if (name === "xai") {
1484
1494
  dto.xaiResponsesOptInState = xaiResponsesOptInState(provider);
@@ -7,6 +7,7 @@ import { applyNativeVisibility, nativeContextLimits } from "../codex/catalog/met
7
7
  import { readCatalog, readCodexCatalogPath, type CatalogModel } from "../codex/catalog/parsing";
8
8
  import { readNativeBaseline, retainedNativeSourcePriorities } from "../codex/catalog/native-priority";
9
9
  import { resolveMultiAgentMode } from "../config/multi-agent-surface";
10
+ import { resolveRoutedCatalogDefaults } from "../config/schema/routed-catalog-defaults";
10
11
 
11
12
  interface CodexModelListInput {
12
13
  config: OcxConfig;
@@ -42,7 +43,7 @@ export function buildCodexModelList({
42
43
  websocketsEnabled(config), maMode, exactComboSlugs, accountSelectors,
43
44
  suppressedBareNativeSlugs, new Set(), nativeContextLimits(config), accountNativeSlugs,
44
45
  accountNativeSlugsBySelector, config.keepNativeChatGptOnV1 === true, config.modelPickerOrder,
45
- nativeSource,
46
+ nativeSource, resolveRoutedCatalogDefaults(config),
46
47
  );
47
48
  return { models: omitDisabledNativeCatalogEntries(applyNativeVisibility(entries, disabledModels, accountSelectors.length > 0, new Set(accountNativeSlugs)), config) };
48
49
  }
@@ -18,6 +18,25 @@ function abortReason(signal: AbortSignal): Error {
18
18
  return error;
19
19
  }
20
20
 
21
+ const connectPhaseTimeouts = new WeakSet<object>();
22
+
23
+ /**
24
+ * Whether a direct request timed out before its TCP connect completed (#8318). Only such a timeout
25
+ * says nothing accepted the connection; one after the connect is a slow or silent listener. The
26
+ * caller's own abort reason is never marked, because one signal can cover several requests.
27
+ */
28
+ export function isConnectPhaseTimeout(error: unknown): boolean {
29
+ return typeof error === "object" && error !== null && connectPhaseTimeouts.has(error);
30
+ }
31
+
32
+ function connectPhaseTimeout(error: Error): Error {
33
+ if (error.name !== "TimeoutError") return error;
34
+ const marked = new Error(error.message, { cause: error });
35
+ marked.name = "TimeoutError";
36
+ connectPhaseTimeouts.add(marked);
37
+ return marked;
38
+ }
39
+
21
40
  function headerBoundary(bytes: Buffer): number {
22
41
  return bytes.indexOf("\r\n\r\n");
23
42
  }
@@ -274,6 +293,7 @@ export async function directLocalHttpFetch(
274
293
  return await new Promise<Response>((resolve, reject) => {
275
294
  let socket: Socket | undefined;
276
295
  let settled = false;
296
+ let connected = false;
277
297
  let closed = false;
278
298
  let completed = false;
279
299
  let outcomeError: Error | undefined;
@@ -312,14 +332,16 @@ export async function directLocalHttpFetch(
312
332
  settleAfterClose();
313
333
  };
314
334
  const onAbort = () => {
315
- const error = signal ? abortReason(signal) : new Error("direct local HTTP request aborted");
335
+ const reason = signal ? abortReason(signal) : new Error("direct local HTTP request aborted");
336
+ const error = connected ? reason : connectPhaseTimeout(reason);
316
337
  if (settled) outcomeError ??= error;
317
338
  else finish(error);
318
339
  if (error.name === "TimeoutError") settleAfterClose(error);
319
340
  };
320
341
  const onDeadline = () => {
321
- const error = new Error("direct local HTTP request timed out");
322
- error.name = "TimeoutError";
342
+ const timeout = new Error("direct local HTTP request timed out");
343
+ timeout.name = "TimeoutError";
344
+ const error = connected ? timeout : connectPhaseTimeout(timeout);
323
345
  finish(error);
324
346
  settleAfterClose(error);
325
347
  };
@@ -332,6 +354,7 @@ export async function directLocalHttpFetch(
332
354
  socket.setTimeout(timeoutMs, onDeadline);
333
355
  socket.on("connect", () => {
334
356
  if (settled) return;
357
+ connected = true;
335
358
  try { socket?.write(requestBytes); } catch (error) {
336
359
  finish(error instanceof Error ? error : new Error(String(error)));
337
360
  }
@@ -242,22 +242,28 @@ export function createLinkListenerLifecycle<T>(deps: LinkListenerDeps = {}): Lin
242
242
  const threadId = header || (metadata && typeof metadata.thread_id === "string" ? metadata.thread_id : "");
243
243
  try { return threadId ? holds.threadHash(threadId) : null; } catch { return null; }
244
244
  };
245
- // Running marks, and while the feature is on the request-log fields of design 9.1: the pipeline reports this
246
- // request's expanded input and its terminal (src/server/link-turn.ts), through a token header it removes before
247
- // anything is forwarded. With the feature off and no marks, no token is set and the request is unchanged.
245
+ // Every relayed turn reads its upstream only as its client drains (#8601, owner decision 2026-11-16), so a stalled
246
+ // Child reader holds about one upstream chunk on this Home whether or not the link WebSocket feature is on. Running
247
+ // marks, and while the feature is on the request-log fields of design 9.1, ride the same observer: the pipeline
248
+ // reports this request's expanded input and its terminal (src/server/link-turn.ts), through a token header it
249
+ // removes before anything is forwarded. With the feature off and no marks the observer only asks for paced reads.
248
250
  let token: string | null = null;
249
251
  const logging = websocketEnabled();
250
- if (logging || holds.hasMarks(linkId)) {
251
- let resent: StoredMark[] = [];
252
- let threadHash: string | null = null;
253
- token = registerLinkTurnToken({
254
- expanded(body, chain) { threadHash = threadHashOf(body); resent = chain === "unexpanded" ? [] : marksResent(holds, linkId, threadHash, body); },
255
- expansionFailed() { resent = []; },
256
- terminal(status, source) { if (resent.length && threadHash && upstreamCompleted(status, source)) holds.releaseMarks(linkId, threadHash, resent); },
257
- ...(logging ? { pacedReads: true, logFields: (body: unknown) => ({ transport: "http" as const, first: false, ...linkLogRefs(holds, linkId, header?.trim() ?? "", body) }) } : {}),
258
- });
259
- try { req.headers.set(LINK_TURN_HEADER, token); } catch { releaseLinkTurnToken(token); token = null; }
260
- }
252
+ const tracksMarks = logging || holds.hasMarks(linkId);
253
+ let resent: StoredMark[] = [];
254
+ let threadHash: string | null = null;
255
+ token = registerLinkTurnToken({
256
+ pacedReads: true,
257
+ expanded(body, chain) {
258
+ if (!tracksMarks) return;
259
+ threadHash = threadHashOf(body);
260
+ resent = chain === "unexpanded" ? [] : marksResent(holds, linkId, threadHash, body);
261
+ },
262
+ expansionFailed() { resent = []; },
263
+ terminal(status, source) { if (resent.length && threadHash && upstreamCompleted(status, source)) holds.releaseMarks(linkId, threadHash, resent); },
264
+ ...(logging ? { logFields: (body: unknown) => ({ transport: "http" as const, first: false, ...linkLogRefs(holds, linkId, header?.trim() ?? "", body) }) } : {}),
265
+ });
266
+ try { req.headers.set(LINK_TURN_HEADER, token); } catch { releaseLinkTurnToken(token); token = null; }
261
267
  // Pending result keys: only a link with a releasable hold pays for reading a copy of the body. The
262
268
  // request settles only holds that exist now, as it begins (a later hold may reuse an id).
263
269
  let decide: ((accepted: boolean) => void) | undefined;
@@ -1464,6 +1464,7 @@ export function createServeOptions(ctx: ServeOptionsContext) {
1464
1464
  advisorAdmissionPolicy,
1465
1465
  onRequestBodyRead: () => disableResponsesRequestTimeout(req, requestServer),
1466
1466
  abortSignal: req.signal,
1467
+ comboSelectionKeepalive: {},
1467
1468
  onFirstOutput: () => recordFirstOutput(logCtx, start),
1468
1469
  onNativePassthroughTerminal: status => {
1469
1470
  finalizeNativePassthroughLog(httpStatusForRequestLogTerminal(status, logCtx), {
@@ -30,6 +30,7 @@ import {
30
30
  import { flushConfigDirHardeningAndReaps } from "../config/paths";
31
31
  import { trackBackgroundWork } from "../lib/background-work";
32
32
  import { migrateStartupSubagentModels } from "./subagent-models-startup";
33
+ import { migrateStartupReserveCapability } from "./reserve-capability-startup";
33
34
  import { migrateStartupXaiResponses } from "./xai-responses-startup";
34
35
  import { migrateStartupZaiResponses } from "./zai-responses-startup";
35
36
  import { reconcileOAuthProviders } from "../oauth";
@@ -217,13 +218,13 @@ function startServerWithSpendLedgerOwner(port: number | undefined, deps: StartSe
217
218
  // Captured before loadConfig() starts the optional ACL flight so stop() drains the same dir
218
219
  // even if OPENCODEX_HOME changes underneath a long-lived process.
219
220
  const startupConfigDir = getConfigDir();
220
- const startupConfig = migrateStartupSubagentModels(
221
+ const startupConfig = migrateStartupReserveCapability(migrateStartupSubagentModels(
221
222
  runModelRenameStartupMigration(
222
223
  runDevinProviderMergeStartupMigration(
223
224
  runAlibabaRegionStartupMigration(runOpenAiTierStartupMigration(loadConfig())),
224
225
  ),
225
226
  ),
226
- );
227
+ ));
227
228
  // Reconcile disk-backed presets first: it replaces provider rows and must not undo
228
229
  // an in-memory wire upgrade when that upgrade's persistence is temporarily unavailable.
229
230
  reconcileOAuthProviders(startupConfig);
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The seam between the Responses pipeline and Remote Link activity holds (design T4 section 5).
3
3
  *
4
- * A link turn may carry an observer: a link WebSocket passes one in handleResponses options, and a
5
- * relayed HTTP request carries a short-lived random token header the link relay registered. The
4
+ * A link turn carries an observer: a link WebSocket passes one in handleResponses options, and every relayed HTTP
5
+ * Responses request carries a short-lived random token header the link relay registered. The
6
6
  * pipeline reports the expanded input right after continuation expansion and before any upstream
7
7
  * I/O, and the final request log reports the terminal status and whether the terminal came from the
8
8
  * upstream. No content leaves this module: observers hash what they need. Nothing here runs for a
@@ -30,8 +30,9 @@ export interface LinkTurnObserver {
30
30
  /** Request-log fields; present only while the link WebSocket feature is on. */
31
31
  logFields?(body: unknown): LinkTurnLogFields | null;
32
32
  /**
33
- * Set only while the link WebSocket feature is on (#8601): the turn's upstream body is read only as its client drains,
34
- * so a stalled link reader holds about one upstream chunk instead of the pipeline's inspection read-ahead.
33
+ * Set by every relayed link turn, HTTP or WebSocket, whether or not the link WebSocket feature is on (#8601): the
34
+ * turn's upstream body is read only as its client drains, so a stalled link reader holds about one upstream chunk
35
+ * instead of the pipeline's inspection read-ahead. Only logFields depends on the feature switch.
35
36
  */
36
37
  pacedReads?: boolean;
37
38
  }
@@ -46,6 +47,8 @@ export const LINK_PACED_SLICE_BYTES = 256 * 1024;
46
47
 
47
48
  const byToken = new Map<string, LinkTurnObserver>();
48
49
  const byLog = new WeakMap<object, LinkTurnObserver>();
50
+ /** Contexts that pace for a link turn bound elsewhere (a combo child's); never notified of the terminal. */
51
+ const pacingByLog = new WeakMap<object, LinkTurnObserver>();
49
52
 
50
53
  /** Registers an observer for one relayed request; the caller sets the returned token as LINK_TURN_HEADER. */
51
54
  export function registerLinkTurnToken(observer: LinkTurnObserver): string {
@@ -123,7 +126,16 @@ export function markLinkTurnMissing(logCtx: object): void {
123
126
 
124
127
  /** Whether a link turn bound to this context reads its upstream only as its client drains; false for every other request. */
125
128
  export function linkTurnPacesReads(logCtx: object): boolean {
126
- return byLog.get(logCtx)?.pacedReads === true;
129
+ return (byLog.get(logCtx) ?? pacingByLog.get(logCtx))?.pacedReads === true;
130
+ }
131
+
132
+ /**
133
+ * A combo child runs the pipeline on a log context of its own, after the combo observed the turn on its parent's. The child
134
+ * reads its upstream as the parent's link turn does; the terminal notice stays with the parent's final log, so it fires once.
135
+ */
136
+ export function bindLinkTurnChild(parentLogCtx: object, childLogCtx: object): void {
137
+ const observer = byLog.get(parentLogCtx) ?? pacingByLog.get(parentLogCtx);
138
+ if (observer) pacingByLog.set(childLogCtx, observer);
127
139
  }
128
140
 
129
141
  /** Called by the final request log of every turn; a no-op unless a link turn bound this context. */
@@ -11,6 +11,8 @@ import { mainAccountHardLockFallbackSchema } from "../../config/schema/main-acco
11
11
  import { anthropicSidecarPatchError } from "../../config/schema/anthropic-account-pool";
12
12
  import { isAnthropicInstanceId } from "../../providers/anthropic-instance-id";
13
13
  import { captureConfigTopLevelRollback } from "../../config/rebase-provenance";
14
+ import { adoptReserveCapabilityMigration, isCodexReserveEnabled, RESERVE_CAPABILITY_MIGRATION_VERSION } from "../../config/reserve-capability";
15
+ import { readConfigFileSnapshot } from "../../config/diagnostics";
14
16
  import type { IntegrationClientId } from "../../integrations/registry";
15
17
  import { randomUUID } from "node:crypto";
16
18
  import { isDeepStrictEqual } from "node:util";
@@ -470,6 +472,8 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
470
472
  showCodexCredits: config.showCodexCredits === true,
471
473
  // Absent means off (today's Design B injection), so the GUI/CLI render a plain switch.
472
474
  codexDesktopAuthless: config.codexDesktopAuthless === true,
475
+ // Luna Reserve's own switch (#4961); before its one-time seed it still reads the legacy flag.
476
+ codexReserveEnabled: isCodexReserveEnabled(config),
473
477
  // Absent keeps Design B remote compaction; true selects the dedicated provider identity.
474
478
  codexClientCompaction: config.codexClientCompaction === true,
475
479
  codexDesktopSwitches: describeCodexDesktopSwitches(config, await observedCodexDesktopSwitchApply()),
@@ -571,6 +575,7 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
571
575
  codexMainAccountHardLockThresholds?: unknown;
572
576
  codexMainAccountHardLockFallback?: unknown;
573
577
  codexDesktopAuthless?: unknown;
578
+ codexReserveEnabled?: unknown;
574
579
  codexClientCompaction?: unknown;
575
580
  compactionRouting?: unknown;
576
581
  compactionRecovery?: unknown;
@@ -590,12 +595,13 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
590
595
  && body.codexMainAccountHardLockThresholds === undefined
591
596
  && body.codexMainAccountHardLockFallback === undefined
592
597
  && body.codexDesktopAuthless === undefined
598
+ && body.codexReserveEnabled === undefined
593
599
  && body.codexClientCompaction === undefined
594
600
  && body.compactionRouting === undefined
595
601
  && body.compactionRecovery === undefined
596
602
  && body.reasoningRetention === undefined
597
603
  && body.memoryModels === undefined) {
598
- return jsonResponse({ error: "provide codexAutoStart, streamMode, appOwnedMemoryBudgetMb, codexAccountPickerEnabled, codexQuotaAutoRefresh, oauthOpenBrowser, showCodexCredits, ultraFastTier, fastRows, codexMainAccountHardLock, codexMainAccountHardLockThresholds, codexMainAccountHardLockFallback, codexDesktopAuthless, codexClientCompaction, compactionRouting, compactionRecovery, reasoningRetention, or memoryModels" }, 400);
604
+ return jsonResponse({ error: "provide codexAutoStart, streamMode, appOwnedMemoryBudgetMb, codexAccountPickerEnabled, codexQuotaAutoRefresh, oauthOpenBrowser, showCodexCredits, ultraFastTier, fastRows, codexMainAccountHardLock, codexMainAccountHardLockThresholds, codexMainAccountHardLockFallback, codexDesktopAuthless, codexReserveEnabled, codexClientCompaction, compactionRouting, compactionRecovery, reasoningRetention, or memoryModels" }, 400);
599
605
  }
600
606
  if (body.codexAutoStart !== undefined && typeof body.codexAutoStart !== "boolean") {
601
607
  return jsonResponse({ error: "codexAutoStart boolean is required" }, 400);
@@ -644,6 +650,9 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
644
650
  if (body.codexDesktopAuthless !== undefined && typeof body.codexDesktopAuthless !== "boolean") {
645
651
  return jsonResponse({ error: "codexDesktopAuthless boolean is required" }, 400);
646
652
  }
653
+ if (body.codexReserveEnabled !== undefined && typeof body.codexReserveEnabled !== "boolean") {
654
+ return jsonResponse({ error: "codexReserveEnabled boolean is required" }, 400);
655
+ }
647
656
  if (body.codexClientCompaction !== undefined && typeof body.codexClientCompaction !== "boolean") {
648
657
  return jsonResponse({ error: "codexClientCompaction boolean is required" }, 400);
649
658
  }
@@ -694,7 +703,7 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
694
703
  }
695
704
  let pickerWasEnabled = false, pickerIsEnabled = false;
696
705
  let authlessIsEnabled = false, clientCompactionIsEnabled = false, fastRowsIsEnabled = false;
697
- let desktopSwitchesChanged = false, fastRowsChanged = false;
706
+ let desktopSwitchesChanged = false, fastRowsChanged = false, reserveIsEnabled = false, reserveChanged = false;
698
707
  const refusal = await settleConfigRoot(configRoot(), () => {
699
708
  if (hardLockThresholds) {
700
709
  hardLockThresholds = { ...config.codexMainAccountHardLockThresholds, ...hardLockThresholds };
@@ -708,6 +717,7 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
708
717
  }
709
718
  pickerWasEnabled = codexAccountPickerEnabled(config);
710
719
  const authlessWasEnabled = config.codexDesktopAuthless === true;
720
+ const reserveWasEnabled = isCodexReserveEnabled(config);
711
721
  const clientCompactionWasEnabled = config.codexClientCompaction === true;
712
722
  const fastRowsWasEnabled = config.fastRows !== false;
713
723
  const restoreCompactionRouting = captureConfigTopLevelRollback(config, ["compactionRouting", "compactionRecovery", "memoryModels", "reasoningRetention"]);
@@ -740,6 +750,10 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
740
750
  hasCodexMainAccountHardLockFallback: Object.hasOwn(config, "codexMainAccountHardLockFallback"),
741
751
  codexDesktopAuthless: config.codexDesktopAuthless,
742
752
  hasCodexDesktopAuthless: Object.hasOwn(config, "codexDesktopAuthless"),
753
+ codexReserveEnabled: config.codexReserveEnabled,
754
+ hasCodexReserveEnabled: Object.hasOwn(config, "codexReserveEnabled"),
755
+ codexReserveMigration: config.codexReserveMigration,
756
+ hasCodexReserveMigration: Object.hasOwn(config, "codexReserveMigration"),
743
757
  codexClientCompaction: config.codexClientCompaction,
744
758
  hasCodexClientCompaction: Object.hasOwn(config, "codexClientCompaction"),
745
759
  };
@@ -780,6 +794,13 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
780
794
  else if (body.codexMainAccountHardLock === true) deleteConfigTopLevelKey(config, "codexMainAccountHardLock");
781
795
  if (hardLockFallback === null) deleteConfigTopLevelKey(config, "codexMainAccountHardLockFallback");
782
796
  else if (hardLockFallback?.success) config.codexMainAccountHardLockFallback = hardLockFallback.data;
797
+ // An explicit Reserve choice is the operator's decision (#4961); an explicit false is persisted.
798
+ // An authless-only change is not seeded here: the writer seeds from the file under its lock,
799
+ // so a stale live object cannot overwrite another process's Reserve decision.
800
+ if (typeof body.codexReserveEnabled === "boolean") {
801
+ config.codexReserveEnabled = body.codexReserveEnabled;
802
+ config.codexReserveMigration = RESERVE_CAPABILITY_MIGRATION_VERSION;
803
+ }
783
804
  if (body.codexDesktopAuthless === true) config.codexDesktopAuthless = true;
784
805
  else if (body.codexDesktopAuthless === false) deleteConfigTopLevelKey(config, "codexDesktopAuthless");
785
806
  if (body.codexClientCompaction === true) config.codexClientCompaction = true;
@@ -807,6 +828,8 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
807
828
  pickerIsEnabled = codexAccountPickerEnabled(config);
808
829
  (deps.saveConfigPreservingClaudeCode ?? saveConfigPreservingClaudeCode)(config);
809
830
  authlessIsEnabled = config.codexDesktopAuthless === true;
831
+ reserveIsEnabled = isCodexReserveEnabled(config);
832
+ reserveChanged = reserveWasEnabled !== reserveIsEnabled;
810
833
  clientCompactionIsEnabled = config.codexClientCompaction === true;
811
834
  fastRowsIsEnabled = config.fastRows !== false;
812
835
  fastRowsChanged = fastRowsWasEnabled !== fastRowsIsEnabled;
@@ -851,6 +874,17 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
851
874
  if (previousSettings.hasCodexDesktopAuthless) {
852
875
  config.codexDesktopAuthless = previousSettings.codexDesktopAuthless;
853
876
  } else deleteConfigTopLevelKey(config, "codexDesktopAuthless");
877
+ // Once the file was published it is the authority: adopt its Reserve fields, since the
878
+ // failure may have come before the writer adopted the projection it wrote.
879
+ if (error instanceof ConfigWritePublishedError) {
880
+ const published = readConfigFileSnapshot();
881
+ if (published.diagnostics.source === "file") adoptReserveCapabilityMigration(config, published.diagnostics.config);
882
+ } else {
883
+ if (previousSettings.hasCodexReserveEnabled) config.codexReserveEnabled = previousSettings.codexReserveEnabled;
884
+ else deleteConfigTopLevelKey(config, "codexReserveEnabled");
885
+ if (previousSettings.hasCodexReserveMigration) config.codexReserveMigration = previousSettings.codexReserveMigration;
886
+ else deleteConfigTopLevelKey(config, "codexReserveMigration");
887
+ }
854
888
  if (previousSettings.hasCodexClientCompaction) {
855
889
  config.codexClientCompaction = previousSettings.codexClientCompaction;
856
890
  } else deleteConfigTopLevelKey(config, "codexClientCompaction");
@@ -869,7 +903,8 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
869
903
  // injector, which is why flipping either switch left `config.toml` in its old shape until
870
904
  // a separate `ocx sync` (#4809). Both halves are needed when a Desktop switch changes; a
871
905
  // picker-only update still refreshes just the catalog.
872
- const catalogRefresh = pickerWasEnabled !== pickerIsEnabled || desktopSwitchesChanged || fastRowsChanged
906
+ // A Reserve change adds or removes the account-qualified Reserve row; config.toml is unaffected.
907
+ const catalogRefresh = pickerWasEnabled !== pickerIsEnabled || desktopSwitchesChanged || fastRowsChanged || reserveChanged
873
908
  ? await convergeCodexCatalog()
874
909
  : undefined;
875
910
  if (fastRowsChanged) {
@@ -902,6 +937,7 @@ async function handleConfigRoutesImpl(ctx: ManagementContext): Promise<Response
902
937
  catalogRefreshPending,
903
938
  fastRows: config.fastRows !== false,
904
939
  codexDesktopAuthless: authlessIsEnabled,
940
+ codexReserveEnabled: reserveIsEnabled,
905
941
  codexClientCompaction: clientCompactionIsEnabled,
906
942
  codexDesktopSwitches,
907
943
  compactionRouting: config.compactionRouting ?? null,
@@ -38,7 +38,7 @@ export function childConfigFailureHint(result: { code: number; stderr: string })
38
38
  */
39
39
  export function childRoleRefusalHint(runtimeRole: unknown): string {
40
40
  return runtimeRole === "client"
41
- ? "The Child is still linked to a Home (config runtimeRole client). On the Child run: ocx disconnect, then ocx restart."
41
+ ? "The Child is still linked to a Home (config runtimeRole client). To end that link and move it here, on the Child run: ocx disconnect, then ocx restart."
42
42
  : `The Child is a Hub (config runtimeRole ${runtimeRole === "hub" ? "hub" : "unknown"}). On the Child run: ocx hub disable, then retry.`;
43
43
  }
44
44
 
@@ -10,6 +10,7 @@ import { tmpdir } from "node:os";
10
10
  import { join } from "node:path";
11
11
  import { withConfigMutationLockSync } from "../../config/mutation-lock";
12
12
  import { checkRouteTrust } from "../../link/route-trust";
13
+ import { readLinkRetirement } from "../../link/retirement";
13
14
  import { routeOutcomeOfStderr } from "../../link/route-select";
14
15
  import { buildRouteProbeArgv, isSshAlias } from "../../link/ssh-argv";
15
16
  import { effectiveLinkRoutes, MAX_LINK_ROUTES, type LinkRecord } from "../../link/store";
@@ -46,6 +47,20 @@ function exclusiveRefusal(): Response {
46
47
  return fail("link_exclusive", "This link is exclusive: its one route is fixed, so routes cannot be added, removed or reordered.", 409);
47
48
  }
48
49
 
50
+ /**
51
+ * An outstanding retirement receipt (an interrupted removal, src/link/retirement.ts) holds a byte-exact copy of the record,
52
+ * and every revoke compares the stored record with it. An edit now would leave them unequal and the removal unfinishable
53
+ * (lidge-jun/opencodex#8678), so the edit waits for the removal to finish. A receipt that cannot be read counts as
54
+ * outstanding: the revoke that would finish it refuses the same file.
55
+ */
56
+ function retirementPending(id: string): boolean {
57
+ try { return readLinkRetirement(id) !== null; } catch { return true; }
58
+ }
59
+
60
+ function retirementRefusal(): Response {
61
+ return fail("link_retirement_pending", "An unfinished removal holds this link: finish the revoke before editing its routes.", 409);
62
+ }
63
+
49
64
  function document(record: LinkRecord): Response {
50
65
  return Response.json(routesBody(record), { headers: { "cache-control": "no-store" } });
51
66
  }
@@ -108,6 +123,8 @@ export async function handleLinkRouteEdit(ctx: ManagementContext, state: LinkRou
108
123
  }
109
124
 
110
125
  async function applyEdit(ctx: ManagementContext, state: LinkRouteState, record: LinkRecord, current: string[], next: string[], added: string | null): Promise<Response> {
126
+ // Checked before the probe, and again under the config mutation lock at the commit, which claimLinkRetirement also holds.
127
+ if (retirementPending(record.id)) return retirementRefusal();
111
128
  const hostsPath = knownHostsFile(ctx);
112
129
  let pinned: string | null = null;
113
130
  if (added !== null) {
@@ -121,7 +138,8 @@ async function applyEdit(ctx: ManagementContext, state: LinkRouteState, record:
121
138
  const refused = await proveRoute(ctx, record, added, pinned);
122
139
  if (refused) return refused;
123
140
  }
124
- const outcome = withConfigMutationLockSync((): "link_changed" | "pin_changed" | "link_exclusive" | LinkRecord => {
141
+ const outcome = withConfigMutationLockSync((): "link_changed" | "pin_changed" | "link_exclusive" | "link_retirement_pending" | LinkRecord => {
142
+ if (retirementPending(record.id)) return "link_retirement_pending";
125
143
  const fresh = readStoreFor(ctx);
126
144
  const target = fresh.links.find(link => link.id === record.id);
127
145
  if (target?.exclusive) return "link_exclusive";
@@ -136,6 +154,7 @@ async function applyEdit(ctx: ManagementContext, state: LinkRouteState, record:
136
154
  return target;
137
155
  });
138
156
  if (outcome === "link_exclusive") return exclusiveRefusal();
157
+ if (outcome === "link_retirement_pending") return retirementRefusal();
139
158
  if (outcome === "link_changed") return fail("link_changed", "The link changed while its routes were being edited; read it again.", 409);
140
159
  if (outcome === "pin_changed") return fail("pin_changed", "The link's pinned key changed while the route was being proved.", 409);
141
160
  try { await state.supervisor.reload(); } catch {
@@ -38,6 +38,13 @@ import {
38
38
  waitForLoginSettled,
39
39
  } from "../../oauth";
40
40
  import { OAuthMutationBusyError, removeCredential } from "../../oauth/store";
41
+ import {
42
+ ANTIGRAVITY_RISK_PROVIDER,
43
+ ANTIGRAVITY_RISK_REFUSAL_CODE,
44
+ antigravityRiskRefusalBody,
45
+ hasAntigravityRiskAcknowledgement,
46
+ requiresAntigravityRiskAcknowledgement,
47
+ } from "../../oauth/antigravity-risk";
41
48
  import { cancelKiroDeviceLogin, kiroDeviceConfigBaseline, selectKiroDeviceProfile, startKiroDeviceLogin, statusKiroDeviceLogin, type KiroDeviceMethod } from "../../oauth/kiro-device-login";
42
49
  import { parseKiroIamOptions } from "../../oauth/kiro-iam-identity-center";
43
50
  import { providerDestinationResolvedError } from "../../lib/destination-policy";
@@ -268,6 +275,11 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
268
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 };
269
276
  const provider = (body.provider ?? "").trim().toLowerCase();
270
277
  if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
278
+ // Antigravity sign-in can get the Google account disabled. Every client asks first; this is
279
+ // the check none of them can skip, and it runs before any flow state is created.
280
+ if (requiresAntigravityRiskAcknowledgement(provider) && !hasAntigravityRiskAcknowledgement(body)) {
281
+ return jsonResponse(antigravityRiskRefusalBody(), 403);
282
+ }
271
283
  // Omitted mode is the localhost-callback flow this route has always run.
272
284
  if (body.mode !== undefined && body.mode !== "callback" && body.mode !== "code") {
273
285
  return jsonResponse({ error: "mode must be \"callback\" or \"code\"" }, 400);
@@ -619,14 +631,13 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
619
631
  if (!latest) return jsonResponse({ error: "account not found" }, 404);
620
632
  return jsonResponse({ error: latest.paused ? "account is paused" : "account selection changed" }, 409);
621
633
  }
622
- const { forgetGenericFailoverRoster } = await import("../../oauth/generic-account-failover");
634
+ const { forgetGenericFailoverRoster, seedGenericPoolSelection } = await import("../../oauth/generic-account-failover");
623
635
  forgetGenericFailoverRoster(provider);
624
636
  // Seed the rotation cursor on the operator's pick, or a sticky round-robin ring hands the
625
637
  // very next dispatch back to whatever the pool had chosen. forgetGenericFailoverRoster
626
638
  // only drops the presence count; it has never touched the cursor. Same defect the Codex
627
639
  // side carries resetCodexRoutingForManualSelection for.
628
- const { genericPoolKey, seedPoolRotationAccount } = await import("../../oauth/pool-kernel");
629
- seedPoolRotationAccount(genericPoolKey(provider), body.accountId);
640
+ seedGenericPoolSelection(provider, body.accountId);
630
641
  const anthropicRouting = isAnthropicOAuthInstance(provider)
631
642
  ? (await import("../../oauth/anthropic-routing")).anthropicRoutingFor(provider) : undefined;
632
643
  anthropicRouting?.resetAnthropicRoutingForManualSelection(body.accountId);
@@ -710,8 +721,8 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
710
721
  }
711
722
  if (result.activeAccountChanged) {
712
723
  if (!anthropicRouting) {
713
- const { genericPoolKey, seedPoolRotationAccount } = await import("../../oauth/pool-kernel");
714
- seedPoolRotationAccount(genericPoolKey(provider), result.activeAccountId);
724
+ const { seedGenericPoolSelection } = await import("../../oauth/generic-account-failover");
725
+ seedGenericPoolSelection(provider, result.activeAccountId);
715
726
  }
716
727
  const { clearModelCache } = await import("../../codex/model-cache");
717
728
  const { clearGatherRoutedModelsInflight } = await import("../../codex/catalog");
@@ -1073,6 +1084,12 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
1073
1084
  if (!isPlainRecord(rawBody)) return jsonResponse({ code: "invalid_document" }, 400);
1074
1085
  const provider = typeof rawBody.provider === "string" ? rawBody.provider : "";
1075
1086
  const format = typeof rawBody.format === "string" ? rawBody.format : "";
1087
+ // An imported Antigravity credential carries the same account risk as a fresh login. Import
1088
+ // admits only the exact provider id, so the gate matches it exactly too; other spellings
1089
+ // keep their unsupported_provider answer.
1090
+ if (provider === ANTIGRAVITY_RISK_PROVIDER && !hasAntigravityRiskAcknowledgement(rawBody)) {
1091
+ return jsonResponse({ code: ANTIGRAVITY_RISK_REFUSAL_CODE }, 403);
1092
+ }
1076
1093
  const { importAccounts } = await import("../../oauth/account-import");
1077
1094
  const imported = await importAccounts({
1078
1095
  provider,
@@ -75,6 +75,9 @@ export const PROVIDER_DISPLAY_CARRY_FIELDS = [
75
75
  // cannot send either, so an unrelated save must not silently return the model to the default.
76
76
  "thinkingDisplay",
77
77
  "modelThinkingDisplay",
78
+ // The experimental Anthropic per-message effort switch (#6895) is operator configuration the form
79
+ // cannot send; an unrelated save must not silently turn it off.
80
+ "perMessageEffort",
78
81
  ] as const satisfies readonly (keyof OcxProviderConfig)[];
79
82
 
80
83
  export type ProviderCompatCarryField = typeof PROVIDER_COMPAT_CARRY_FIELDS[number];