@bitkyc08/opencodex 2.94.0 → 2.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/gui/dist/assets/App-8yedBkhm.js +58 -0
  2. package/gui/dist/assets/App-B4j-Txmb.css +1 -0
  3. package/gui/dist/assets/{Tray-CZatQdoF.js → Tray-erSMzxPG.js} +1 -1
  4. package/gui/dist/assets/index-D7DCm5eQ.js +94 -0
  5. package/gui/dist/assets/quota-summary-BK4VuQNc.js +1 -0
  6. package/gui/dist/index.html +1 -1
  7. package/package.json +1 -1
  8. package/src/adapters/anthropic.ts +10 -3
  9. package/src/adapters/command-code-project-context.ts +3 -3
  10. package/src/adapters/kiro/adapter.ts +4 -1
  11. package/src/adapters/kiro/stream.ts +1 -0
  12. package/src/adapters/kiro-events.ts +1 -0
  13. package/src/adapters/openai-chat/messages.ts +20 -7
  14. package/src/adapters/openai-chat/passthrough.ts +4 -2
  15. package/src/adapters/openai-chat/single-system.ts +24 -0
  16. package/src/adapters/openai-responses/muse-tool-catalog.ts +87 -0
  17. package/src/adapters/openai-responses/passthrough.ts +42 -7
  18. package/src/adapters/openai-responses/prompt-cache.ts +3 -1
  19. package/src/adapters/openai-responses/request-strips.ts +23 -4
  20. package/src/adapters/openai-responses/tool-output-recovery.ts +21 -8
  21. package/src/adapters/openai-responses/tool-schema.ts +20 -8
  22. package/src/adapters/opencode-go-additional-tools.ts +39 -6
  23. package/src/adapters/routed-agent-messages.ts +3 -0
  24. package/src/adapters/xai-web-search.ts +6 -3
  25. package/src/adapters/zed-additional-tools.ts +7 -7
  26. package/src/adapters/zed.ts +1 -6
  27. package/src/advisor/consult.ts +22 -10
  28. package/src/advisor/runtime.ts +10 -4
  29. package/src/bridge/max-output-completion.ts +41 -0
  30. package/src/bridge/response-json.ts +9 -4
  31. package/src/bridge/sse.ts +13 -2
  32. package/src/chatgpt/app-server-shim/bundle-trust-policy.ts +5 -0
  33. package/src/chatgpt/app-server-shim/launcher.ts +40 -6
  34. package/src/claude/compatibility.ts +5 -1
  35. package/src/claude/desktop-3p.ts +27 -6
  36. package/src/claude/desktop-model-visibility.ts +141 -0
  37. package/src/claude/desktop-remote-store-io.ts +8 -8
  38. package/src/claude/inbound-content-options.ts +11 -1
  39. package/src/claude/intercept/proxy-auth.ts +16 -16
  40. package/src/cli/account-main.ts +3 -2
  41. package/src/cli/capabilities-provider-models.ts +7 -0
  42. package/src/cli/chatgpt-command.ts +1 -1
  43. package/src/cli/codex-launcher.ts +20 -8
  44. package/src/cli/codex-shim-autorestore.ts +19 -1
  45. package/src/cli/dispatch.ts +6 -6
  46. package/src/cli/doctor.ts +5 -5
  47. package/src/cli/index.ts +4 -9
  48. package/src/cli/init.ts +2 -2
  49. package/src/cli/internal-command.ts +29 -2
  50. package/src/cli/provider-cc-switch-import.ts +185 -0
  51. package/src/cli/provider.ts +5 -0
  52. package/src/cli/registry.ts +1 -0
  53. package/src/cli/restart-scope.ts +2 -2
  54. package/src/cli/root.ts +6 -6
  55. package/src/cli/stop-approval.ts +15 -1
  56. package/src/cli/v2.ts +69 -19
  57. package/src/client/machine-api.ts +2 -2
  58. package/src/clients/config-export.ts +14 -3
  59. package/src/codex/account-cooldown-response.ts +18 -0
  60. package/src/codex/app-server-restart-service.ts +2 -2
  61. package/src/codex/auth-api/login-flow.ts +2 -2
  62. package/src/codex/auth-api/pool-quota-probe.ts +2 -2
  63. package/src/codex/auth-context.ts +4 -4
  64. package/src/codex/catalog/bundled.ts +10 -3
  65. package/src/codex/catalog/metadata.ts +4 -5
  66. package/src/codex/catalog/native-omission.ts +28 -0
  67. package/src/codex/catalog/native-template.ts +58 -0
  68. package/src/codex/catalog/parsing.ts +3 -29
  69. package/src/codex/catalog/provider-models.ts +2 -1
  70. package/src/codex/catalog/retained-sync.ts +15 -5
  71. package/src/codex/catalog/write-audit.ts +18 -18
  72. package/src/codex/cli-install-provenance.ts +46 -45
  73. package/src/codex/cli-update-artifacts.ts +8 -6
  74. package/src/codex/cli-update-job-store-windows.ts +99 -27
  75. package/src/codex/cli-update-job-worker.ts +3 -11
  76. package/src/codex/cli-update-recovery.ts +54 -8
  77. package/src/codex/cli-update-selection-gate.ts +74 -4
  78. package/src/codex/cli-windows-plan-provenance.ts +37 -19
  79. package/src/codex/codex-home-owner.ts +9 -8
  80. package/src/codex/convergence.ts +13 -3
  81. package/src/codex/coordinator-doctor.ts +14 -8
  82. package/src/codex/desktop-app/handoff.ts +1 -1
  83. package/src/codex/desktop-app-restart.ts +11 -1
  84. package/src/codex/exec-boundary.ts +26 -5
  85. package/src/codex/history-provider.ts +11 -10
  86. package/src/codex/inject/bounded-config-reader.ts +14 -13
  87. package/src/codex/main-account.ts +6 -6
  88. package/src/codex/native-main-lock-file.ts +13 -12
  89. package/src/codex/native-residue.ts +18 -14
  90. package/src/codex/orca-auth-source.ts +8 -7
  91. package/src/codex/quota-types.ts +5 -0
  92. package/src/codex/quota.ts +49 -7
  93. package/src/codex/role-auto-assign.ts +50 -26
  94. package/src/codex/role-capability.ts +160 -0
  95. package/src/codex/role-sizing.ts +24 -6
  96. package/src/codex/routing/cooldown-math.ts +3 -2
  97. package/src/codex/runtime.ts +43 -3
  98. package/src/codex/shim-fingerprint.ts +11 -9
  99. package/src/codex/shim-inspect.ts +3 -2
  100. package/src/codex/shim-restore-lock.ts +11 -14
  101. package/src/codex/shim-state-file.ts +22 -14
  102. package/src/codex/shim-wrapper-write.ts +7 -6
  103. package/src/codex/shim.ts +25 -2
  104. package/src/codex/transition-state.ts +5 -4
  105. package/src/combos/failover.ts +43 -4
  106. package/src/config/atomic-write.ts +38 -7
  107. package/src/config/diagnostics.ts +3 -0
  108. package/src/config/initialize.ts +6 -6
  109. package/src/config/load-degrade.ts +2 -0
  110. package/src/config/process-state.ts +23 -5
  111. package/src/config/salvage.ts +1 -0
  112. package/src/config/schema/config-schema.ts +29 -1
  113. package/src/config/schema/leaf-validators.ts +7 -0
  114. package/src/config/schema/workflow-budget.ts +43 -0
  115. package/src/config/tracked-runtime-inspection.ts +188 -0
  116. package/src/generated/compatibility-version.json +313 -213
  117. package/src/integrations/aside-profile-context.ts +1 -1
  118. package/src/integrations/droid-settings.ts +4 -4
  119. package/src/integrations/hermes-profiles.ts +3 -3
  120. package/src/lib/bounded-file-read.ts +3 -9
  121. package/src/lib/bun-runtime-preflight.ts +9 -8
  122. package/src/lib/file-identity.ts +15 -0
  123. package/src/lib/local-chat-completion.ts +8 -6
  124. package/src/lib/local-destinations.ts +32 -3
  125. package/src/lib/redact-folding.ts +9 -0
  126. package/src/lib/spend-pool-alias-validation.ts +6 -6
  127. package/src/lib/state-store-registrations.ts +2 -0
  128. package/src/lib/test-home-guard.ts +37 -9
  129. package/src/lib/windows-secret-acl.ts +47 -29
  130. package/src/lib/workflow-budget-config.ts +39 -0
  131. package/src/local-credentials/generation.ts +6 -2
  132. package/src/local-credentials/inventory.ts +132 -8
  133. package/src/messaging/remote-forward-failure.ts +35 -0
  134. package/src/messaging/remote-ports.ts +27 -5
  135. package/src/messaging/remote-process.ts +30 -4
  136. package/src/messaging/remote-tunnels.ts +80 -15
  137. package/src/oauth/antigravity-discovery-diagnostics.ts +65 -0
  138. package/src/oauth/google-antigravity.ts +23 -10
  139. package/src/oauth/index.ts +2 -0
  140. package/src/oauth/kiro-device-login.ts +87 -30
  141. package/src/oauth/kiro-iam-identity-center.ts +107 -0
  142. package/src/oauth/store.ts +9 -7
  143. package/src/providers/account-quota-disk.ts +18 -4
  144. package/src/providers/cc-switch-import-bytes.ts +991 -0
  145. package/src/providers/cc-switch-import-source.ts +1083 -0
  146. package/src/providers/cc-switch-import.ts +942 -0
  147. package/src/providers/derive.ts +6 -0
  148. package/src/providers/model-discovery-diagnostic.ts +4 -0
  149. package/src/providers/model-discovery.ts +4 -4
  150. package/src/providers/model-rename-fields.ts +2 -0
  151. package/src/providers/model-rename-migration.ts +41 -6
  152. package/src/providers/quota/report-cache.ts +17 -4
  153. package/src/providers/quota.ts +2 -2
  154. package/src/providers/reasoning-metadata.ts +31 -15
  155. package/src/providers/registry/entries-core.ts +1 -1
  156. package/src/providers/registry/entries-extended.ts +1 -1
  157. package/src/providers/registry/model-ids.ts +1 -0
  158. package/src/providers/registry/model-seeds.ts +2 -1
  159. package/src/providers/registry/types.ts +3 -1
  160. package/src/providers/resolved-model-policy.ts +2 -2
  161. package/src/providers/routed-config.ts +2 -0
  162. package/src/providers/stale-model-roster-migration.ts +5 -1
  163. package/src/providers/xai-transport.ts +4 -4
  164. package/src/remote-control/workspace-codex-runtime.ts +2 -2
  165. package/src/remote-control/workspace-executor.ts +14 -13
  166. package/src/responses/custom-tool-compat.ts +2 -1
  167. package/src/responses/item-provenance.ts +79 -0
  168. package/src/responses/namespace-tool-compat.ts +21 -3
  169. package/src/router.ts +21 -2
  170. package/src/routing/analytics.ts +3 -5
  171. package/src/routing/fallback-policy.ts +7 -3
  172. package/src/routing/health.ts +5 -3
  173. package/src/routing/history/build-file.ts +6 -0
  174. package/src/routing/history/indexer.ts +158 -31
  175. package/src/routing/history/ingest.ts +1 -1
  176. package/src/routing/history/integrity.ts +208 -0
  177. package/src/routing/history/rebuild-job.ts +20 -6
  178. package/src/routing/history/rebuild-protocol.ts +2 -1
  179. package/src/routing/history/rebuild-worker.ts +18 -0
  180. package/src/routing/history/sqlite-errors.ts +9 -0
  181. package/src/server/admission-model-scope.ts +21 -4
  182. package/src/server/advisor-admission-scope.ts +29 -0
  183. package/src/server/auth-cors.ts +5 -2
  184. package/src/server/capture-admission-policy.ts +91 -0
  185. package/src/server/chat-completions.ts +33 -7
  186. package/src/server/claude-messages.ts +90 -2
  187. package/src/server/codex-model-list.ts +2 -1
  188. package/src/server/configured-credentials.ts +5 -0
  189. package/src/server/index/serve-options.ts +12 -2
  190. package/src/server/index/websocket-handler.ts +3 -0
  191. package/src/server/management/agent-settings-routes.ts +34 -9
  192. package/src/server/management/codex-agent-role-routes.ts +1 -0
  193. package/src/server/management/codex-role-auto-assign.ts +50 -6
  194. package/src/server/management/config-routes.ts +15 -4
  195. package/src/server/management/context.ts +3 -0
  196. package/src/server/management/native-integration-routes.ts +22 -0
  197. package/src/server/management/oauth-account-routes.ts +20 -4
  198. package/src/server/management/provider-overwrite-carry.ts +21 -0
  199. package/src/server/management/provider-routes.ts +3 -1
  200. package/src/server/management/route-registry.ts +2 -0
  201. package/src/server/management/shared.ts +17 -1
  202. package/src/server/management/workflow-budget-routes.ts +70 -3
  203. package/src/server/messages-native-eligibility.ts +6 -5
  204. package/src/server/messages-native-scope.ts +6 -1
  205. package/src/server/messages-shared.ts +57 -17
  206. package/src/server/persistent-gui-session.ts +4 -4
  207. package/src/server/request-log.ts +30 -2
  208. package/src/server/responses/adapter-delivery.ts +4 -0
  209. package/src/server/responses/advisor-plan-slot.ts +4 -0
  210. package/src/server/responses/advisor-slot.ts +73 -46
  211. package/src/server/responses/codex-auth-error.ts +5 -1
  212. package/src/server/responses/combo-required-tool-contract.ts +27 -0
  213. package/src/server/responses/compact.ts +4 -1
  214. package/src/server/responses/core-combo-failure.ts +2 -0
  215. package/src/server/responses/core-combo.ts +66 -5
  216. package/src/server/responses/core-lifetime.ts +4 -0
  217. package/src/server/responses/core-options.ts +9 -0
  218. package/src/server/responses/core.ts +2 -0
  219. package/src/server/responses/jev-model-invoke.ts +4 -2
  220. package/src/server/responses/passthrough-dispatch.ts +5 -4
  221. package/src/server/responses/policy-fallback.ts +2 -0
  222. package/src/server/responses/request-prepare.ts +4 -5
  223. package/src/server/responses/request-send-budget.ts +2 -1
  224. package/src/server/responses/request-sidecar-auth.ts +1 -0
  225. package/src/server/responses/request-transport.ts +2 -3
  226. package/src/server/responses/run-turn-execution.ts +4 -0
  227. package/src/server/responses/sidecar-execution.ts +21 -5
  228. package/src/server/responses-snapshot-repair.ts +18 -4
  229. package/src/server/responses-undeclared-tool-guard.ts +4 -0
  230. package/src/server/workflow-refusal.ts +2 -1
  231. package/src/service/state-lock.ts +12 -11
  232. package/src/service-manager-probe.ts +53 -8
  233. package/src/types/admission-policy.ts +13 -0
  234. package/src/types/config.ts +25 -0
  235. package/src/types/provider.ts +10 -0
  236. package/src/types/request.ts +7 -0
  237. package/src/types.ts +1 -0
  238. package/src/update/job.ts +20 -0
  239. package/src/update/worker-launch.ts +71 -1
  240. package/src/usage/log.ts +25 -4
  241. package/src/vision/index.ts +2 -0
  242. package/src/vision/plan.ts +4 -0
  243. package/src/vision/routed-describe.ts +38 -23
  244. package/src/web-search/loop.ts +104 -9
  245. package/src/web-search/parse.ts +10 -2
  246. package/gui/dist/assets/App-DMps4OLk.css +0 -1
  247. package/gui/dist/assets/App-DmvwlhQq.js +0 -58
  248. package/gui/dist/assets/index-3EPO_KbX.js +0 -94
  249. package/gui/dist/assets/quota-summary-BHvWg9mi.js +0 -1
@@ -61,6 +61,7 @@ export interface DerivedKeyLoginProvider {
61
61
  escapeBuiltinToolNames?: boolean;
62
62
  openaiChatEofTolerance?: boolean;
63
63
  foldDeveloperRoleToSystem?: boolean;
64
+ singleLeadingSystemMessage?: boolean;
64
65
  googleMode?: "ai-studio" | "vertex" | "cloud-code-assist";
65
66
  project?: string;
66
67
  location?: string;
@@ -287,6 +288,7 @@ export function providerConfigSeed(entry: ProviderRegistryEntry): OcxProviderCon
287
288
  ...(entry.chatServiceTier !== undefined ? { chatServiceTier: entry.chatServiceTier } : {}),
288
289
  ...(entry.openaiChatEofTolerance !== undefined ? { openaiChatEofTolerance: entry.openaiChatEofTolerance } : {}),
289
290
  ...(entry.foldDeveloperRoleToSystem !== undefined ? { foldDeveloperRoleToSystem: entry.foldDeveloperRoleToSystem } : {}),
291
+ ...(entry.singleLeadingSystemMessage !== undefined ? { singleLeadingSystemMessage: entry.singleLeadingSystemMessage } : {}),
290
292
  ...(entry.responsesPath !== undefined ? { responsesPath: entry.responsesPath } : {}),
291
293
  ...(entry.chatCompletionsPath !== undefined ? { chatCompletionsPath: entry.chatCompletionsPath } : {}),
292
294
  ...(entry.statelessResponses !== undefined ? { statelessResponses: entry.statelessResponses } : {}),
@@ -367,6 +369,7 @@ export function deriveKeyLoginMap(): Record<string, DerivedKeyLoginProvider> {
367
369
  ...(entry.escapeBuiltinToolNames !== undefined ? { escapeBuiltinToolNames: entry.escapeBuiltinToolNames } : {}),
368
370
  ...(entry.openaiChatEofTolerance !== undefined ? { openaiChatEofTolerance: entry.openaiChatEofTolerance } : {}),
369
371
  ...(entry.foldDeveloperRoleToSystem !== undefined ? { foldDeveloperRoleToSystem: entry.foldDeveloperRoleToSystem } : {}),
372
+ ...(entry.singleLeadingSystemMessage !== undefined ? { singleLeadingSystemMessage: entry.singleLeadingSystemMessage } : {}),
370
373
  ...(entry.googleMode ? { googleMode: entry.googleMode } : {}),
371
374
  ...(entry.project ? { project: entry.project } : {}),
372
375
  ...(entry.location ? { location: entry.location } : {}),
@@ -615,6 +618,9 @@ export function enrichProviderFromRegistry(name: string, prov: OcxProviderConfig
615
618
  if (prov.foldDeveloperRoleToSystem === undefined && seed.foldDeveloperRoleToSystem !== undefined) {
616
619
  prov.foldDeveloperRoleToSystem = seed.foldDeveloperRoleToSystem;
617
620
  }
621
+ if (prov.singleLeadingSystemMessage === undefined && seed.singleLeadingSystemMessage !== undefined) {
622
+ prov.singleLeadingSystemMessage = seed.singleLeadingSystemMessage;
623
+ }
618
624
  // Fill-only: a hand-edited path must survive, and a config saved before the registry
619
625
  // learned this route still gets backfilled.
620
626
  if (prov.responsesPath === undefined && seed.responsesPath !== undefined) prov.responsesPath = seed.responsesPath;
@@ -0,0 +1,4 @@
1
+ /** Safe operator guidance for malformed upstream model lists. */
2
+ export function invalidModelDiscoveryHint(diagnostic?: string): string {
3
+ return `${diagnostic ? ` (${diagnostic})` : ""}. A newly added API-key provider can keep its model selection pending while discovery fails; a static models list with liveModels: false avoids discovery for gateways publishing invalid rows.`;
4
+ }
@@ -47,7 +47,7 @@ export type BoundedDiscoveryJsonResult =
47
47
 
48
48
  export type ProviderModelItemsResult =
49
49
  | { ok: true; items: ProviderModelsApiItem[]; rawCount: number }
50
- | { ok: false; reason: "invalid_shape" | "too_many_models" };
50
+ | { ok: false; reason: "invalid_shape" | "too_many_models"; diagnostic?: string };
51
51
 
52
52
  export type ModelEnvelopeRowsResult =
53
53
  | { ok: true; rows: unknown[] }
@@ -534,12 +534,12 @@ export function extractProviderModelItems(
534
534
  const preferred: ProviderModelsApiItem[] = [];
535
535
  const seen = new Set<string>();
536
536
  const idField = discovery.spec?.idField ?? "id";
537
- for (const raw of data) {
537
+ for (const [index, raw] of data.entries()) {
538
538
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
539
- return { ok: false, reason: "invalid_shape" };
539
+ return { ok: false, reason: "invalid_shape", diagnostic: `row ${index} is not an object` };
540
540
  }
541
541
  const id = (raw as Record<string, unknown>)[idField];
542
- if (!isValidModelDiscoveryModelId(id)) return { ok: false, reason: "invalid_shape" };
542
+ if (!isValidModelDiscoveryModelId(id)) return { ok: false, reason: "invalid_shape", diagnostic: `row ${index} has ${typeof id !== "string" ? "a non-string id" : !id.trim() ? "an empty id" : "an invalid id"}` };
543
543
  const prefix = discovery.spec?.stripIdPrefix;
544
544
  let finalId = id;
545
545
  if (prefix && finalId.startsWith(prefix)) {
@@ -29,6 +29,7 @@ export const PROVIDER_MODEL_RENAME_ROLES = {
29
29
  supportsServiceTier: "none",
30
30
  fastEnabled: "none",
31
31
  modelSupportsServiceTier: "record",
32
+ promoteAdditionalTools: "none",
32
33
  preserveResponsesReasoningContent: "none",
33
34
  preserveResponsesInputItemIds: "none",
34
35
  preserveResponsesMessageMetadata: "none",
@@ -127,6 +128,7 @@ export const PROVIDER_MODEL_RENAME_ROLES = {
127
128
  terminalContinuationGuard: "none",
128
129
  openaiChatEofTolerance: "none",
129
130
  foldDeveloperRoleToSystem: "none",
131
+ singleLeadingSystemMessage: "none",
130
132
  promptCacheKey: "none",
131
133
  chatServiceTier: "none",
132
134
  responsesItemIdRepair: "none",
@@ -19,7 +19,7 @@
19
19
  // Everything else in the row is left alone.
20
20
 
21
21
  import { PROVIDER_REGISTRY, normalizedProviderEndpoint } from "./registry";
22
- import { MINIMAX_M31_FLASH, MINIMAX_M31_FLASH_PREVIEW_RETIRED } from "./registry/model-seeds";
22
+ import { KIMI_API_K31_REASONING_EFFORT_MAP, MINIMAX_M31_FLASH, MINIMAX_M31_FLASH_PREVIEW_RETIRED } from "./registry/model-seeds";
23
23
  import { MODEL_KEYED_RECORDS, MODEL_ID_LISTS, MODEL_ID_SCALARS, MODEL_NESTED_RECORDS } from "./model-rename-fields";
24
24
  import { providerConfigSeed } from "./derive";
25
25
  import type { OcxConfig, OcxProviderConfig } from "../types";
@@ -57,6 +57,12 @@ export interface ModelRename {
57
57
  dropNoReasoningModels?: boolean;
58
58
  /** Refresh exact registry defaults already saved under the replacement id. */
59
59
  targetSeedRefresh?: {
60
+ /**
61
+ * Refresh only values carried over from the retired id. Set this when the registry never
62
+ * seeded the replacement id with the stale values, so anything already saved under it is a
63
+ * user override even when it happens to equal the old seed.
64
+ */
65
+ onlyTransferred?: boolean;
60
66
  contextWindow?: { from: number; to: number };
61
67
  reasoning?: {
62
68
  fromEfforts: readonly string[];
@@ -121,6 +127,24 @@ export const MODEL_RENAMES: readonly ModelRename[] = [
121
127
  // rather than a merely outdated one.
122
128
  ...kimiCodingRenames("kimi", "subscription endpoint after K2.8 Preview shipped"),
123
129
  ...kimiCodingRenames("kimi-code", "coding endpoint after K2.8 Preview shipped"),
130
+ {
131
+ provider: "moonshot",
132
+ from: "kimi-k2.5",
133
+ to: "kimi-k3.1-pro",
134
+ // Verified 2026-10-28: https://platform.kimi.ai/docs/models.md
135
+ reason: "Moonshot discontinued K2.5 on 2026-08-31 and recommends K3.1 Pro for API users",
136
+ dropNoReasoningModels: true,
137
+ targetSeedRefresh: {
138
+ onlyTransferred: true,
139
+ contextWindow: { from: 262_144, to: 1_048_576 },
140
+ reasoning: {
141
+ fromEfforts: [],
142
+ toEfforts: ["low", "high", "max"],
143
+ defaultEffort: "max",
144
+ effortMap: KIMI_API_K31_REASONING_EFFORT_MAP,
145
+ },
146
+ },
147
+ },
124
148
  // Antigravity Flash generations. Google takes the previous Flash model off Cloud Code
125
149
  // Assist almost immediately when the next ships, so a saved 3.6 (or older 3.5) id is a
126
150
  // dead selection rather than a merely outdated one. Routing already redirects these ids
@@ -171,11 +195,12 @@ function dropRenamedIdsFromList(
171
195
  from: string,
172
196
  to: string,
173
197
  dropStaleTarget: boolean,
198
+ keepTarget = false,
174
199
  ): string[] | null {
175
200
  if (!Array.isArray(value)) return null;
176
201
  const hasRetired = value.includes(from);
177
- if (!hasRetired && !(dropStaleTarget && value.includes(to))) return null;
178
- return value.filter(entry => typeof entry === "string" && entry !== from && entry !== to);
202
+ if (!hasRetired && !(dropStaleTarget && !keepTarget && value.includes(to))) return null;
203
+ return value.filter(entry => typeof entry === "string" && entry !== from && (keepTarget || entry !== to));
179
204
  }
180
205
 
181
206
  function renameInRecord(value: unknown, from: string, to: string): Record<string, unknown> | null {
@@ -218,18 +243,22 @@ function targetReasoningMatchesStaleSeed(row: Record<string, unknown>, rename: M
218
243
  }
219
244
 
220
245
  /** Refresh only exact defaults emitted by the previous registry; preserve user overrides. */
221
- function refreshTargetSeed(row: Record<string, unknown>, rename: ModelRename): boolean {
246
+ function refreshTargetSeed(
247
+ row: Record<string, unknown>, rename: ModelRename, savedBefore: { window: boolean; efforts: boolean },
248
+ ): boolean {
222
249
  const refresh = rename.targetSeedRefresh;
223
250
  if (!refresh) return false;
224
251
  let changed = false;
225
252
 
226
253
  const windows = row.modelContextWindows as Record<string, unknown> | undefined;
227
- if (windows && refresh.contextWindow && windows[rename.to] === refresh.contextWindow.from) {
254
+ if (windows && refresh.contextWindow && windows[rename.to] === refresh.contextWindow.from
255
+ && !(refresh.onlyTransferred && savedBefore.window)) {
228
256
  windows[rename.to] = refresh.contextWindow.to;
229
257
  changed = true;
230
258
  }
231
259
 
232
260
  const reasoning = refresh.reasoning;
261
+ if (refresh.onlyTransferred && savedBefore.efforts) return changed;
233
262
  const efforts = row.modelReasoningEfforts as Record<string, unknown> | undefined;
234
263
  if (!reasoning || !efforts || !sameStringArray(efforts[rename.to], reasoning.fromEfforts)) return changed;
235
264
  efforts[rename.to] = [...reasoning.toEfforts];
@@ -359,6 +388,10 @@ export function projectModelRenames(
359
388
  // view rather than casting at each assignment.
360
389
  const row = prov as unknown as Record<string, unknown>;
361
390
  const seed = registrySeed(rename.provider);
391
+ const savedBefore = {
392
+ window: publishes(row.modelContextWindows, rename.to),
393
+ efforts: publishes(row.modelReasoningEfforts, rename.to),
394
+ };
362
395
  let touched = false;
363
396
  for (const field of MODEL_ID_LISTS) {
364
397
  if (isRegistryResidue(seed, field, row[field], rename)) continue;
@@ -368,6 +401,8 @@ export function projectModelRenames(
368
401
  rename.from,
369
402
  rename.to,
370
403
  targetReasoningMatchesStaleSeed(row, rename),
404
+ // A successor classification saved before the migration is the user's, not registry residue.
405
+ rename.targetSeedRefresh?.onlyTransferred === true,
371
406
  )
372
407
  : renameInList(row[field], rename.from, rename.to);
373
408
  if (!next) continue;
@@ -398,7 +433,7 @@ export function projectModelRenames(
398
433
  touched = true;
399
434
  }
400
435
  if (renameDisabledModels(config, rename)) touched = true;
401
- if (touched && refreshTargetSeed(row, rename)) touched = true;
436
+ if (touched && refreshTargetSeed(row, rename, savedBefore)) touched = true;
402
437
 
403
438
  if (touched) {
404
439
  changed = true;
@@ -3,7 +3,7 @@ import { providerDecisionWindows } from "../quota-decision-publication";
3
3
  import type { DecisionQuotaWindow } from "../quota-decision-snapshot";
4
4
  import { createHash } from "node:crypto";
5
5
  import { effectiveCodexAuthAccountId, listCodexAuthAccountsSnapshot } from "../../codex/auth-api";
6
- import { withoutRetiredCodexQuota, type StoredAccountQuota } from "../../codex/quota";
6
+ import { CODEX_EXHAUSTED_USAGE_PERCENT, withoutRetiredCodexQuota, type StoredAccountQuota } from "../../codex/quota";
7
7
  import { isMainAccountIdentityGenerationLive } from "../../codex/main-account-cache";
8
8
  import { codexPlanKey } from "../../codex/plan";
9
9
  import { resolveProviderApiKey } from "../key-store";
@@ -154,16 +154,28 @@ export function hasCodexPoolProvider(config: OcxConfig): boolean {
154
154
  ));
155
155
  }
156
156
 
157
- function quotaSignatureValue(quota: CodexCapacityQuota | null): unknown {
157
+ /**
158
+ * Signature of one pool account's presentation state. Every proxied Codex response restamps the
159
+ * observation, so a raw `updatedAt` in the key stopped the report cache from ever committing
160
+ * while traffic flowed (#7956). The key carries the fresh/stale verdict aggregation derives
161
+ * from it instead; value changes and freshness transitions still miss the cache. A displayed
162
+ * window `updatedAt` can therefore lag a restamp by up to the report cache TTL. The exception is
163
+ * an exhausted short window without a reset: its `shortObservedAt` alone decides whether it
164
+ * still blocks, over a window as short as that TTL, so that clock stays in the key.
165
+ */
166
+ function quotaSignatureValue(quota: CodexCapacityQuota | null, now: number): unknown {
158
167
  if (!quota) return null;
168
+ const resetless = !(typeof quota.fiveHourResetAt === "number" && quota.fiveHourResetAt > 0);
169
+ const observationDecides = resetless && (quota.fiveHourPercent ?? 0) >= CODEX_EXHAUSTED_USAGE_PERCENT;
159
170
  return {
160
171
  fiveHourPercent: quota.fiveHourPercent,
161
172
  fiveHourResetAt: quota.fiveHourResetAt,
173
+ ...(observationDecides ? { shortObservedAt: quota.shortObservedAt } : {}),
162
174
  weeklyPercent: quota.weeklyPercent,
163
175
  weeklyResetAt: quota.weeklyResetAt,
164
176
  monthlyPercent: quota.monthlyPercent,
165
177
  monthlyResetAt: quota.monthlyResetAt,
166
- updatedAt: quota.updatedAt,
178
+ fresh: Number.isFinite(quota.updatedAt) && now - quota.updatedAt <= CODEX_CAPACITY_MAX_QUOTA_AGE_MS,
167
179
  customWindows: [...(quota.customWindows ?? [])]
168
180
  .map(window => ({ label: window.label, percent: window.percent, resetAt: window.resetAt }))
169
181
  .sort((a, b) => a.label.localeCompare(b.label)),
@@ -204,13 +216,14 @@ export function cacheKeyWithAggregationState(
204
216
  try {
205
217
  const activeId = effectiveCodexAuthAccountId(config);
206
218
  const snapshot = await (prefetchedSnapshot ?? listCodexAuthAccountsSnapshot(config, false));
219
+ const now = Date.now();
207
220
  const rows = snapshot.accounts.map(account => ({
208
221
  isMain: account.isMain,
209
222
  active: account.id === activeId,
210
223
  plan: codexPlanKey(account.plan) ?? null,
211
224
  paused: account.paused,
212
225
  needsReauth: account.needsReauth === true,
213
- quota: quotaSignatureValue(providerQuotaFromCodexQuota(account.quota)),
226
+ quota: quotaSignatureValue(providerQuotaFromCodexQuota(account.quota), now),
214
227
  }));
215
228
  const canonicalRows = rows.map(row => JSON.stringify(row)).sort();
216
229
  const digest = createHash("sha256").update(JSON.stringify(canonicalRows)).digest("hex").slice(0, 24);
@@ -151,8 +151,8 @@ async function maybeFetchProviderQuota(
151
151
  *
152
152
  * No previous snapshot is passed. The observer keeps its own persisted last-seen map,
153
153
  * because `previous` here is bound only when `cache.key === key` and the key digest at
154
- * cacheKeyWithAggregationState includes quota values and updatedAt — so it is empty exactly
155
- * when a reset happened.
154
+ * cacheKeyWithAggregationState includes quota values and their freshness — so it is empty
155
+ * exactly when a reset happened.
156
156
  *
157
157
  * Account identity is resolved SYNCHRONOUSLY, before any await. Two reasons, both observed:
158
158
  * pool failover rewrites `activeAccountId` during request routing
@@ -25,7 +25,7 @@ import { join } from "node:path";
25
25
  // already imports. Going through the ../config barrel closes a cycle back into account-namespaces.ts
26
26
  // and leaves COMBO_NAMESPACE in its temporal dead zone for entry points that start at combos/types.ts.
27
27
  import { atomicWriteFile } from "../config/atomic-write";
28
- import { getConfigDir } from "../config/paths";
28
+ import { getConfigDir, withConfigDirHardeningSettled } from "../config/paths";
29
29
  import type { OcxProviderConfig } from "../types";
30
30
  import { resolveProviderApiKey } from "./api-key-resolve";
31
31
 
@@ -96,7 +96,9 @@ interface SupportSnapshot {
96
96
  let snapshotMemo: MetadataSnapshot | null | undefined;
97
97
  let supportMemo: Map<string, number> | undefined;
98
98
  let persistTimer: ReturnType<typeof setTimeout> | null = null;
99
- let refreshInFlight: Promise<unknown> | null = null;
99
+ let refreshInFlight: Promise<RefreshOutcome> | null = null;
100
+ /** Bumped by reset so a fired support write still waiting for ACL admission writes nothing. */
101
+ let persistGeneration = 0;
100
102
 
101
103
  /** Test seam: drop the memoised snapshot/support caches so a suite can drive the load paths. */
102
104
  export function resetReasoningMetadataCachesForTests(): void {
@@ -107,6 +109,7 @@ export function resetReasoningMetadataCachesForTests(): void {
107
109
  persistTimer = null;
108
110
  }
109
111
  refreshInFlight = null;
112
+ persistGeneration += 1;
110
113
  }
111
114
 
112
115
  function readJsonFile<T>(filename: string): T | null {
@@ -375,7 +378,12 @@ export function recordUnsupportedReasoningEffort(
375
378
  if (persistTimer) clearTimeout(persistTimer);
376
379
  persistTimer = setTimeout(() => {
377
380
  persistTimer = null;
378
- try {
381
+ // Admitted after an overlapping optional config-root ACL flight (#7815); rows are read
382
+ // inside the callback, and a timed-out admission skips this best-effort write.
383
+ const dir = getConfigDir();
384
+ const generation = persistGeneration;
385
+ void withConfigDirHardeningSettled(dir, () => {
386
+ if (generation !== persistGeneration) return;
379
387
  const out: SupportSnapshot["rows"] = {};
380
388
  for (const [rowKey, at] of rows) {
381
389
  const evidenceText = supportEvidence.get(rowKey);
@@ -385,30 +393,33 @@ export function recordUnsupportedReasoningEffort(
385
393
  ...(evidenceText ? { evidence: evidenceText } : {}),
386
394
  };
387
395
  }
388
- atomicWriteFile(join(getConfigDir(), SUPPORT_FILENAME), JSON.stringify({ version: 2, rows: out }) + "\n");
389
- } catch {
396
+ atomicWriteFile(join(dir, SUPPORT_FILENAME), JSON.stringify({ version: 2, rows: out }) + "\n");
397
+ }).catch(() => {
390
398
  // Best-effort persistence only.
391
- }
399
+ });
392
400
  }, PERSIST_DEBOUNCE_MS);
393
401
  return true;
394
402
  }
395
403
 
396
- /** Test seam: flush a pending support write so a script sees the snapshot immediately. */
397
- export function flushReasoningSupportCache(): void {
404
+ /** Test seam: flush a pending support write, admitted like the timer write (#7815). */
405
+ export async function flushReasoningSupportCache(): Promise<void> {
398
406
  if (!persistTimer) return;
399
407
  clearTimeout(persistTimer);
400
408
  persistTimer = null;
401
- try {
409
+ const dir = getConfigDir();
410
+ const generation = persistGeneration;
411
+ await withConfigDirHardeningSettled(dir, () => {
412
+ if (generation !== persistGeneration) return;
402
413
  const rows = loadSupport();
403
414
  const out: SupportSnapshot["rows"] = {};
404
415
  for (const [rowKey, at] of rows) {
405
416
  const evidenceText = supportEvidence.get(rowKey);
406
417
  out[rowKey] = { effort: JSON.parse(rowKey)[3] ?? "", at, ...(evidenceText ? { evidence: evidenceText } : {}) };
407
418
  }
408
- atomicWriteFile(join(getConfigDir(), SUPPORT_FILENAME), JSON.stringify({ version: 2, rows: out }) + "\n");
409
- } catch {
419
+ atomicWriteFile(join(dir, SUPPORT_FILENAME), JSON.stringify({ version: 2, rows: out }) + "\n");
420
+ }).catch(() => {
410
421
  // Best-effort persistence only.
411
- }
422
+ });
412
423
  }
413
424
 
414
425
  /**
@@ -521,7 +532,8 @@ export async function refreshReasoningMetadata(options: { force?: boolean; waitM
521
532
  return { ok: true, reason: "fresh" };
522
533
  }
523
534
  if (refreshInFlight) {
524
- return waitForRefresh(refreshInFlight.then(() => ({ ok: true, reason: "coalesced" })), options.waitMs);
535
+ // A joined caller learns the shared outcome: a refused or failed refresh is not a success.
536
+ return waitForRefresh(refreshInFlight.then(outcome => outcome.ok ? { ok: true, reason: "coalesced" } : outcome), options.waitMs);
525
537
  }
526
538
  const job = (async () => {
527
539
  const response = await fetch(SOURCE_URL, {
@@ -565,15 +577,19 @@ export async function refreshReasoningMetadata(options: { force?: boolean; waitM
565
577
  providers[providerKey] = out;
566
578
  }
567
579
  const next: MetadataSnapshot = { version: 2, fetchedAt: Date.now(), source: SOURCE_URL, providers, apis };
568
- atomicWriteFile(join(getConfigDir(), FILENAME), JSON.stringify(next) + "\n");
580
+ // The last await is the network read; publication waits out an overlapping optional
581
+ // config-root ACL flight (#7815) and a timed-out admission fails this refresh unpublished.
582
+ const dir = getConfigDir();
583
+ await withConfigDirHardeningSettled(dir, () => atomicWriteFile(join(dir, FILENAME), JSON.stringify(next) + "\n"));
569
584
  snapshotMemo = next;
570
585
  return { ok: true, reason: "refreshed", providers: Object.keys(providers).length, models };
571
586
  })();
572
- refreshInFlight = job.catch(() => undefined).finally(() => { refreshInFlight = null; });
573
587
  const settled = job.catch((error): RefreshOutcome => ({
574
588
  ok: false,
575
589
  reason: error instanceof Error ? error.message : String(error),
576
590
  }));
591
+ const shared = settled.finally(() => { if (refreshInFlight === shared) refreshInFlight = null; });
592
+ refreshInFlight = shared;
577
593
  return waitForRefresh(settled, options.waitMs);
578
594
  }
579
595
 
@@ -1242,7 +1242,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
1242
1242
  { id: "azure-openai", label: "Azure OpenAI", adapter: "azure-openai", baseUrl: "https://{resource}.openai.azure.com/openai", authKind: "key", featured: true, dashboardUrl: "https://portal.azure.com" },
1243
1243
  { id: "ollama", label: "Ollama (local)", adapter: "openai-chat", baseUrl: "http://localhost:11434/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — key usually blank" },
1244
1244
  { id: "vllm", label: "vLLM (local)", adapter: "openai-chat", baseUrl: "http://localhost:8000/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — key usually blank" },
1245
- { id: "lm-studio", label: "LM Studio (local)", adapter: "openai-chat", baseUrl: "http://localhost:1234/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — no key needed" },
1245
+ { id: "lm-studio", singleLeadingSystemMessage: true, label: "LM Studio (local)", adapter: "openai-chat", baseUrl: "http://localhost:1234/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — no key needed" },
1246
1246
  {
1247
1247
  id: "deepseek",
1248
1248
  label: "DeepSeek",
@@ -479,7 +479,7 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
479
479
  id: "moonshot", label: "Moonshot (Kimi API)", baseUrl: MOONSHOT_INTL_BASE_URL, adapter: "openai-chat", authKind: "key",
480
480
  allowBaseUrlOverride: true,
481
481
  baseUrlChoices: MOONSHOT_BASE_URL_CHOICES,
482
- dashboardUrl: "https://platform.moonshot.ai/console/api-keys", defaultModel: "kimi-k2.7-code", jawcodeBundle: "moonshot",
482
+ dashboardUrl: "https://platform.moonshot.ai/console/api-keys", defaultModel: "kimi-k3.1-pro", jawcodeBundle: "moonshot",
483
483
  models: KIMI_API_MODELS,
484
484
  modelContextWindows: KIMI_API_MODEL_CONTEXT_WINDOWS,
485
485
  modelInputModalities: KIMI_API_MODEL_INPUT_MODALITIES,
@@ -123,6 +123,7 @@ export const REGISTRY_FIELD_MODEL_ID_ROLES = {
123
123
  chatServiceTier: NONE,
124
124
  openaiChatEofTolerance: NONE,
125
125
  foldDeveloperRoleToSystem: NONE,
126
+ singleLeadingSystemMessage: NONE,
126
127
  autoToolChoiceOnlyModels: NONE,
127
128
  preserveReasoningContentModels: NONE,
128
129
  requiresReasoningPlaceholderModels: NONE,
@@ -770,7 +770,8 @@ export const KIMI_CODING_K31_MODELS = ["k3.1-pro", "k3.1-pro-highspeed"];
770
770
  export const KIMI_CODING_K28_MODELS = ["kimi-for-coding"];
771
771
  export const KIMI_CODING_LIVE_MODELS = [...KIMI_CODING_K3_MODELS, ...KIMI_CODING_K31_MODELS, ...KIMI_CODING_K28_MODELS];
772
772
  export const KIMI_CODING_ADJUSTABLE_THINKING_MODELS = [...KIMI_CODING_LIVE_MODELS];
773
- export const KIMI_LEGACY_API_MODELS = ["kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k2.6", "kimi-k2.5"];
773
+ // 2026-10-28: models.md recommends K3.1 Pro; K2.5 ended 2026-08-31. Other K2 ids retire in December.
774
+ export const KIMI_LEGACY_API_MODELS = ["kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k2.6"];
774
775
  // 261025 Kimi K3.1 Pro on the Moonshot API (#7653): the platform model list names kimi-k3.1-pro
775
776
  // and kimi-k3.1-pro-highspeed (same model, 2-3x speed) on both the International and China
776
777
  // platforms. Every K3-series model has a 1,048,576-token window, and both ids share kimi-k3's
@@ -373,6 +373,8 @@ export interface ProviderRegistryEntry {
373
373
  * `system` instead. Seeds `foldDeveloperRoleToSystem` on the provider config; a user value wins.
374
374
  */
375
375
  foldDeveloperRoleToSystem?: boolean;
376
+ /** Seed the text-only single-leading-system Chat compatibility policy. A user value wins. */
377
+ singleLeadingSystemMessage?: boolean;
376
378
  autoToolChoiceOnlyModels?: string[];
377
379
  preserveReasoningContentModels?: string[];
378
380
  requiresReasoningPlaceholderModels?: string[];
@@ -409,6 +411,6 @@ export type ProviderConfigSeed = Pick<
409
411
  | "modelMaxInputTokens" | "defaultMaxOutputTokens" | "modelMaxOutputTokens"
410
412
  | "reasoningEfforts" | "modelReasoningEfforts" | "modelDefaultReasoningEfforts" | "reasoningEffortMap" | "modelReasoningEffortMap" | "reasoningWireFormat"
411
413
  | "noVisionModels" | "noReasoningModels" | "noTemperatureModels" | "noTopPModels" | "noStopModels" | "noPenaltyModels"
412
- | "autoToolChoiceOnlyModels" | "preserveReasoningContentModels" | "requiresReasoningPlaceholderModels" | "reasoningSplitModels" | "inlineThinkTagModels" | "reasoningDetailsModels" | "thinkingToggleModels" | "thinkingBudgetModels" | "escapeBuiltinToolNames" | "openaiChatEofTolerance" | "foldDeveloperRoleToSystem" | "showThinkingSummary"
414
+ | "autoToolChoiceOnlyModels" | "preserveReasoningContentModels" | "requiresReasoningPlaceholderModels" | "reasoningSplitModels" | "inlineThinkTagModels" | "reasoningDetailsModels" | "thinkingToggleModels" | "thinkingBudgetModels" | "escapeBuiltinToolNames" | "openaiChatEofTolerance" | "foldDeveloperRoleToSystem" | "singleLeadingSystemMessage" | "showThinkingSummary"
413
415
  | "googleMode" | "project" | "location" | "headers"
414
416
  >;
@@ -33,7 +33,7 @@ export type StaticProviderPolicyField =
33
33
  | "modelDefaultReasoningEfforts" | "reasoningEffortMap" | "modelReasoningEffortMap"
34
34
  | "reasoningWireFormat" | "noVisionModels" | "noReasoningModels" | "noTemperatureModels"
35
35
  | "noTopPModels" | "noStopModels" | "noPenaltyModels" | "noJsonSchemaModels" | "noStructuredOutputModels" | "parallelToolCalls"
36
- | "promptCacheKey" | "chatServiceTier" | "openaiChatEofTolerance" | "foldDeveloperRoleToSystem" | "statelessResponses"
36
+ | "promptCacheKey" | "chatServiceTier" | "openaiChatEofTolerance" | "foldDeveloperRoleToSystem" | "singleLeadingSystemMessage" | "statelessResponses"
37
37
  | "requiresAdjacentResponsesToolResults" | "requiresPairedResponsesToolResults" | "annotateEmptyToolOutputs"
38
38
  | "fastWire" | "supportsServiceTier" | "modelSupportsServiceTier" | "supportsOpenAiWebSearchToolFields"
39
39
  | "supportsResponsesCustomTools" | "preserveResponsesReasoningContent" | "dropResponsesReasoningItems"
@@ -174,7 +174,7 @@ export function resolveModelPolicy(input: ResolveModelPolicyInput): ResolvedMode
174
174
  "responsesPath", "chatCompletionsPath", "keyOptional", "freeTier", "modelSuffixBracketStrip",
175
175
  "defaultModel", "models", "liveModels", "contextWindow", "defaultMaxOutputTokens",
176
176
  "reasoningWireFormat", "parallelToolCalls", "promptCacheKey",
177
- "openaiChatEofTolerance", "foldDeveloperRoleToSystem", "statelessResponses",
177
+ "openaiChatEofTolerance", "foldDeveloperRoleToSystem", "singleLeadingSystemMessage", "statelessResponses",
178
178
  "requiresAdjacentResponsesToolResults", "requiresPairedResponsesToolResults",
179
179
  "annotateEmptyToolOutputs", "fastWire", "supportsServiceTier",
180
180
  "supportsOpenAiWebSearchToolFields", "supportsResponsesCustomTools",
@@ -324,6 +324,8 @@ export function routedProviderConfig(providerName: string, provider: OcxProvider
324
324
  ...(provider.foldDeveloperRoleToSystem === undefined && registryEntry.foldDeveloperRoleToSystem !== undefined
325
325
  ? { foldDeveloperRoleToSystem: registryEntry.foldDeveloperRoleToSystem }
326
326
  : {}),
327
+ ...(provider.singleLeadingSystemMessage === undefined && registryEntry.singleLeadingSystemMessage !== undefined
328
+ ? { singleLeadingSystemMessage: registryEntry.singleLeadingSystemMessage } : {}),
327
329
  ...(provider.reasoningWireFormat === undefined && registryEntry.reasoningWireFormat !== undefined
328
330
  ? { reasoningWireFormat: registryEntry.reasoningWireFormat }
329
331
  : {}),
@@ -45,6 +45,8 @@ export interface StaleModelRoster {
45
45
  provider: string;
46
46
  /** The exact saved roster this migration may replace, and nothing else. */
47
47
  from: readonly string[];
48
+ /** Exact old roster after id renames; metadata additions still compare against `from`. */
49
+ afterModelRenames?: readonly string[];
48
50
  to: readonly string[];
49
51
  /** Per-model seed values for the added ids, written only into containers that exist. */
50
52
  contextWindows?: Readonly<Record<string, number>>;
@@ -131,6 +133,7 @@ export const STALE_MODEL_ROSTERS: readonly StaleModelRoster[] = [
131
133
  {
132
134
  provider: "moonshot",
133
135
  from: KIMI_API_MODELS_BEFORE_K31,
136
+ afterModelRenames: KIMI_API_MODELS_BEFORE_K31.map(id => id === "kimi-k2.5" ? "kimi-k3.1-pro" : id),
134
137
  to: KIMI_API_MODELS,
135
138
  contextWindows: KIMI_API_MODEL_CONTEXT_WINDOWS,
136
139
  defaultReasoningEfforts: KIMI_API_DEFAULT_REASONING_EFFORTS,
@@ -193,7 +196,8 @@ export function projectStaleModelRosters(
193
196
  }
194
197
  continue;
195
198
  }
196
- if (!sameList(prov.models, entry.from)) continue;
199
+ if (!sameList(prov.models, entry.from)
200
+ && !(entry.afterModelRenames && sameList(prov.models, entry.afterModelRenames))) continue;
197
201
  prov.models = [...entry.to];
198
202
  fillExisting(prov.modelContextWindows, entry.contextWindows, added);
199
203
  fillExisting(prov.modelMaxOutputTokens, entry.maxOutputTokens, added);
@@ -7,14 +7,14 @@ import { resolveMistralTransport } from "./mistral-transport";
7
7
 
8
8
  export const XAI_GROK_CLI_BASE_URL = "https://cli-chat-proxy.grok.com/v1";
9
9
 
10
- /** The two hosts that serve xAI's Responses API: the public API and the Grok CLI proxy. */
11
- const XAI_RESPONSES_HOSTS = new Set(["api.x.ai", "cli-chat-proxy.grok.com"]);
10
+ /** Exact xAI Responses hosts: global and US public APIs, and the Grok CLI proxy. */
11
+ const XAI_RESPONSES_HOSTS = new Set(["api.x.ai", "us.api.x.ai", "cli-chat-proxy.grok.com"]);
12
12
 
13
13
  /**
14
14
  * True when this provider's Responses traffic terminates at xAI itself.
15
15
  *
16
- * Probed 2026-08-22 one field per request: the two hosts accept and refuse exactly the same
17
- * web_search fields, so they are one dialect rather than two. Matching is exact-host over
16
+ * The global API and CLI proxy were probed 2026-08-22; the US regional API documents
17
+ * the same request parameters. Matching is exact-host over
18
18
  * https, which keeps lookalikes (`api.x.ai.evil.test`) and nonstandard ports out.
19
19
  */
20
20
  export function isXaiResponsesDestination(provider: Pick<OcxProviderConfig, "baseUrl">): boolean {
@@ -7,7 +7,7 @@ import {
7
7
  type CodexExecBoundaryAsyncDeps,
8
8
  } from "../codex/exec-boundary";
9
9
  import {
10
- beginCodexCliSelectionParentWrite,
10
+ beginCodexCliSelectionParentWriteAsync,
11
11
  CodexCliSelectionMutationBusyError,
12
12
  } from "../codex/cli-update-selection-gate";
13
13
  import { remoteWorkspaceThreadStartParams } from "./workspace-coordinator";
@@ -371,7 +371,7 @@ export class CodexRemoteWorkspaceRuntimeFactory implements RemoteWorkspaceRuntim
371
371
  // installer termination/readback; a new session must not appear inside that
372
372
  // window. Busy is the same explicit pre-spawn failure path as a spawn
373
373
  // throw, so the bridge and isolation are reclaimed identically.
374
- const selectionWrite = beginCodexCliSelectionParentWrite();
374
+ const selectionWrite = await beginCodexCliSelectionParentWriteAsync();
375
375
  if (!selectionWrite.entered) {
376
376
  // Both teardown steps are attempted before the refusal leaves: the
377
377
  // ordered runner keeps a rejected bridge stop from skipping isolation
@@ -14,6 +14,7 @@ import {
14
14
  } from "node:fs";
15
15
  import { basename, dirname, isAbsolute, posix, relative, resolve, sep, win32 } from "node:path";
16
16
  import { renameAtomicFile } from "../lib/windows-atomic-replace";
17
+ import { sameFileIdentity, statTimeMs } from "../lib/file-identity";
17
18
  import {
18
19
  REMOTE_WORKSPACE_MAX_TOOL_RESULT_BYTES,
19
20
  type RemoteWorkspaceToolName,
@@ -65,8 +66,8 @@ export interface RemoteWorkspaceCommandRunner {
65
66
  interface ApprovedRoot {
66
67
  id: string;
67
68
  path: string;
68
- dev: number;
69
- ino: number;
69
+ dev: bigint;
70
+ ino: bigint;
70
71
  birthtimeMs: number;
71
72
  }
72
73
 
@@ -170,20 +171,20 @@ function decodeUtf8(value: Uint8Array): string {
170
171
  }
171
172
 
172
173
  function assertOpenedRegularFile(root: string, target: string, descriptor: number, maximum: number) {
173
- const opened = fstatSync(descriptor);
174
- const linked = lstatSync(target);
175
- if (opened.isFile() && linked.isFile() && (opened.nlink !== 1 || linked.nlink !== 1)) {
174
+ const opened = fstatSync(descriptor, { bigint: true });
175
+ const linked = lstatSync(target, { bigint: true });
176
+ if (opened.isFile() && linked.isFile() && (opened.nlink !== 1n || linked.nlink !== 1n)) {
176
177
  throw new Error("remote workspace hard-linked files are not allowed");
177
178
  }
178
179
  if (!opened.isFile() || !linked.isFile() || linked.isSymbolicLink()
179
- || opened.dev !== linked.dev || opened.ino !== linked.ino
180
- || opened.birthtimeMs !== linked.birthtimeMs) {
180
+ || !sameFileIdentity(opened, linked)
181
+ || statTimeMs(opened.birthtimeNs) !== statTimeMs(linked.birthtimeNs)) {
181
182
  throw new Error("remote workspace file identity changed during access");
182
183
  }
183
184
  const canonical = realpathSync(target);
184
185
  if (!inside(root, canonical)) throw new Error("remote workspace path escapes the approved root");
185
186
  if (opened.size > maximum) throw new Error("remote workspace file exceeds the read limit");
186
- return opened;
187
+ return { size: Number(opened.size), mode: Number(opened.mode) };
187
188
  }
188
189
 
189
190
  function readBoundedRegularFile(root: string, target: string, maximum: number): { body: Buffer; mode: number } {
@@ -216,11 +217,11 @@ function assertStableWritableParent(root: string, target: string): void {
216
217
  }
217
218
 
218
219
  function assertApprovedRootIdentity(root: ApprovedRoot): void {
219
- const linked = lstatSync(root.path);
220
+ const linked = lstatSync(root.path, { bigint: true });
220
221
  const canonical = realpathSync(root.path);
221
222
  if (!linked.isDirectory() || linked.isSymbolicLink()
222
- || linked.dev !== root.dev || linked.ino !== root.ino
223
- || linked.birthtimeMs !== root.birthtimeMs
223
+ || !sameFileIdentity(linked, root)
224
+ || statTimeMs(linked.birthtimeNs) !== root.birthtimeMs
224
225
  || relative(root.path, canonical) !== "") {
225
226
  throw new Error("remote workspace approved root identity changed; pair the folder again");
226
227
  }
@@ -256,13 +257,13 @@ export class RemoteWorkspaceExecutor {
256
257
  const metadata = lstatSync(root.path);
257
258
  if (!metadata.isDirectory() || metadata.isSymbolicLink()) throw new Error("remote workspace root must be a real directory");
258
259
  const canonical = realpathSync(root.path);
259
- const identity = lstatSync(canonical);
260
+ const identity = lstatSync(canonical, { bigint: true });
260
261
  this.roots.set(root.id, {
261
262
  id: root.id,
262
263
  path: canonical,
263
264
  dev: identity.dev,
264
265
  ino: identity.ino,
265
- birthtimeMs: identity.birthtimeMs,
266
+ birthtimeMs: statTimeMs(identity.birthtimeNs),
266
267
  });
267
268
  }
268
269
  if (this.roots.size === 0) throw new Error("remote workspace executor needs one approved root");
@@ -232,7 +232,8 @@ function rewriteForUpstream(
232
232
  }
233
233
 
234
234
  let changed = false;
235
- const next: Record<string, unknown> = {};
235
+ // Recursive tool lowering must retain the input item's historical/live symbol marker.
236
+ const next: Record<string, unknown> = { ...value };
236
237
  for (const [key, entry] of Object.entries(value)) {
237
238
  const rewritten = rewriteForUpstream(entry, names, callIds);
238
239
  next[key] = rewritten;