@bitkyc08/opencodex 2.37.0 → 2.39.0-preview.20260901

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 (131) hide show
  1. package/bin/ocx.mjs +127 -16
  2. package/gui/dist/assets/index-6HZDkIpX.js +112 -0
  3. package/gui/dist/assets/index-uvENYLin.css +1 -0
  4. package/gui/dist/index.html +2 -2
  5. package/gui/dist/provider-icons/aside.svg +3 -0
  6. package/gui/dist/provider-icons/baseten.svg +13 -0
  7. package/gui/dist/provider-icons/bizrouter.svg +41 -0
  8. package/gui/dist/provider-icons/cerebras.svg +26 -0
  9. package/gui/dist/provider-icons/deepinfra.svg +75 -0
  10. package/gui/dist/provider-icons/deepseek-harness.svg +3 -0
  11. package/gui/dist/provider-icons/digitalocean.svg +10 -0
  12. package/gui/dist/provider-icons/featherless.svg +4 -0
  13. package/gui/dist/provider-icons/gajae-code.svg +410 -0
  14. package/gui/dist/provider-icons/hermes-agent.svg +207 -0
  15. package/gui/dist/provider-icons/hyperbolic.svg +18 -0
  16. package/gui/dist/provider-icons/kilo.svg +13 -0
  17. package/gui/dist/provider-icons/litellm.svg +1 -0
  18. package/gui/dist/provider-icons/minimax.svg +1 -0
  19. package/gui/dist/provider-icons/nanogpt.svg +74 -0
  20. package/gui/dist/provider-icons/nebius.svg +1 -0
  21. package/gui/dist/provider-icons/neuralwatt.svg +27 -0
  22. package/gui/dist/provider-icons/nous.svg +149 -0
  23. package/gui/dist/provider-icons/novita.svg +32 -0
  24. package/gui/dist/provider-icons/oh-my-pi.svg +11 -0
  25. package/gui/dist/provider-icons/openclaw.svg +54 -0
  26. package/gui/dist/provider-icons/orcarouter.svg +175 -0
  27. package/gui/dist/provider-icons/parallel.svg +13 -0
  28. package/gui/dist/provider-icons/prime-agent.svg +21 -0
  29. package/gui/dist/provider-icons/sambanova.svg +276 -0
  30. package/gui/dist/provider-icons/scaleway.svg +11 -0
  31. package/gui/dist/provider-icons/siliconflow.svg +18 -0
  32. package/gui/dist/provider-icons/synthetic.svg +12 -0
  33. package/gui/dist/provider-icons/together.svg +18 -0
  34. package/gui/dist/provider-icons/umans.svg +30 -0
  35. package/gui/dist/provider-icons/venice.svg +165 -0
  36. package/gui/dist/provider-icons/vultr.svg +15 -0
  37. package/gui/dist/provider-icons/zai.svg +218 -0
  38. package/gui/dist/provider-icons/zcode.svg +219 -0
  39. package/gui/dist/provider-icons/zenmux.svg +1 -0
  40. package/package.json +1 -1
  41. package/src/adapters/cursor/live-models.ts +1 -0
  42. package/src/adapters/cursor/protobuf-request.ts +4 -1
  43. package/src/adapters/cursor/tool-definitions.ts +36 -4
  44. package/src/adapters/openai-responses.ts +72 -10
  45. package/src/bridge.ts +15 -15
  46. package/src/cli/capabilities.ts +14 -0
  47. package/src/cli/codex-cli-update.ts +96 -0
  48. package/src/cli/codex-shim-autorestore.ts +3 -0
  49. package/src/cli/dispatch.ts +54 -18
  50. package/src/cli/export-command.ts +18 -17
  51. package/src/cli/help.ts +2 -2
  52. package/src/cli/index.ts +423 -32
  53. package/src/cli/integrations.ts +24 -2
  54. package/src/cli/launcher-context.ts +53 -2
  55. package/src/cli/opencode.ts +126 -33
  56. package/src/cli/registry.ts +16 -10
  57. package/src/cli/system-command.ts +6 -1
  58. package/src/cli/uninstall-plan.ts +86 -0
  59. package/src/clients/config-export.ts +293 -28
  60. package/src/codex/account-store.ts +131 -12
  61. package/src/codex/auth-api.ts +202 -33
  62. package/src/codex/autostart-health.ts +3 -3
  63. package/src/codex/catalog/provider-fetch.ts +96 -10
  64. package/src/codex/catalog/sync.ts +4 -3
  65. package/src/codex/cli-install-provenance.ts +795 -0
  66. package/src/codex/convergence.ts +4 -3
  67. package/src/codex/credential-mutation-epoch.ts +11 -0
  68. package/src/codex/history-job.ts +10 -0
  69. package/src/codex/history-manifest.ts +35 -2
  70. package/src/codex/history-provider.ts +196 -19
  71. package/src/codex/history-worker.ts +3 -0
  72. package/src/codex/main-account.ts +2 -0
  73. package/src/codex/model-entitlements.ts +430 -27
  74. package/src/codex/native-profile-manager.ts +4 -0
  75. package/src/codex/quota-401-recovery.ts +190 -0
  76. package/src/codex/quota-recovery-timing.ts +28 -0
  77. package/src/codex/quota.ts +6 -0
  78. package/src/codex/reset-credit-operation-ledger.ts +1411 -0
  79. package/src/codex/reset-credit-recovery.ts +20 -2
  80. package/src/codex/routing.ts +68 -16
  81. package/src/codex/shim.ts +204 -18
  82. package/src/codex/subagent-model-fallback.ts +4 -1
  83. package/src/codex/user-identity.ts +2 -1
  84. package/src/config/paths.ts +18 -3
  85. package/src/config/pending-teardown-names.d.mts +8 -0
  86. package/src/config/pending-teardown-names.mjs +69 -0
  87. package/src/config/pending-teardown.ts +286 -0
  88. package/src/config.ts +23 -0
  89. package/src/generated/compatibility-version.json +155 -67
  90. package/src/integrations/journal.ts +12 -1
  91. package/src/integrations/registry.ts +112 -0
  92. package/src/integrations/state.ts +67 -5
  93. package/src/integrations/writer.ts +107 -16
  94. package/src/lib/bounded-subprocess.ts +36 -0
  95. package/src/lib/process-control.ts +30 -5
  96. package/src/lib/state-store-registrations.ts +8 -0
  97. package/src/lib/strict-semver.ts +47 -0
  98. package/src/lib/windows-elevation.ts +32 -1
  99. package/src/lib/windows-secret-acl.ts +47 -25
  100. package/src/lib/windows-service-mutation-lock.ts +133 -0
  101. package/src/lib/windows-user-principal.ts +15 -17
  102. package/src/oauth/index.ts +220 -13
  103. package/src/oauth/store.ts +220 -18
  104. package/src/responses/spill-store.ts +354 -29
  105. package/src/responses/state.ts +775 -8
  106. package/src/server/index.ts +4 -3
  107. package/src/server/lifecycle.ts +5 -1
  108. package/src/server/management/integration-routes.ts +36 -5
  109. package/src/server/management/model-rows.ts +11 -2
  110. package/src/server/management/provider-routes.ts +4 -0
  111. package/src/server/management/system-restart.ts +5 -5
  112. package/src/server/management-api.ts +72 -13
  113. package/src/server/responses/encrypted-payload.ts +18 -1
  114. package/src/server/startup-action-control.ts +3 -2
  115. package/src/server/stop-teardown.ts +84 -0
  116. package/src/service.ts +749 -53
  117. package/src/sidecar/candidates.ts +1 -1
  118. package/src/update/codex-cli-update-launch-policy.d.mts +18 -0
  119. package/src/update/codex-cli-update-launch-policy.mjs +30 -0
  120. package/src/update/index.ts +39 -6
  121. package/src/update/job.ts +10 -11
  122. package/src/update/proxy-liveness-probe.d.mts +6 -0
  123. package/src/update/proxy-liveness-probe.mjs +84 -0
  124. package/src/update/stop-contract.d.mts +2 -0
  125. package/src/update/stop-contract.mjs +15 -0
  126. package/src/update/stop-decision.d.mts +10 -0
  127. package/src/update/stop-decision.mjs +34 -0
  128. package/src/vision/eligibility.ts +19 -1
  129. package/src/vision/index.ts +4 -18
  130. package/gui/dist/assets/index-CowztZdo.js +0 -112
  131. package/gui/dist/assets/index-jqE_VOKI.css +0 -1
@@ -12,7 +12,7 @@ import { CLI_COMMANDS } from "./registry";
12
12
  import { isValidProviderName } from "../config/provider-name";
13
13
  import type { CliHead } from "./root";
14
14
  import type { ReadyArgs } from "./ready";
15
- import type { LiveProxy } from "../server/proxy-liveness";
15
+ import type { LivenessIo, LiveProxy } from "../server/proxy-liveness";
16
16
  import type { OcxConfig } from "../types";
17
17
  import { hasHelpFlag, printSubcommandUsage, printUsage } from "./help";
18
18
  import { setIntegrationEnabled, shouldSyncCodexOnStart } from "../codex/desired-state";
@@ -29,7 +29,7 @@ export interface CliDispatchDeps {
29
29
  command: string | undefined;
30
30
  head: CliHead;
31
31
  loadConfig: () => OcxConfig;
32
- findLiveProxy: () => Promise<LiveProxy | null>;
32
+ findLiveProxy: (io?: LivenessIo) => Promise<LiveProxy | null>;
33
33
  probeHostname: (hostname: string | undefined) => string;
34
34
  waitForProxy: (timeoutMs?: number) => Promise<LiveProxy | null>;
35
35
  startArgv: (port?: number) => string[];
@@ -121,14 +121,31 @@ const commandRunners: Record<string, CommandRunner> = {
121
121
  if (desired.status === "unchanged") {
122
122
  const { classifyNativeRoutedResidue } = await import("../codex/native-residue");
123
123
  if (classifyNativeRoutedResidue().kind === "clean") {
124
- const alreadyOff = "Codex integration is already OFF and native; no Codex files changed.";
124
+ // The Codex half being a no-op says nothing about the Grok half. Returning here
125
+ // without stripping the fence meant `ocx restore` could report success while Grok
126
+ // still pointed at a stopped proxy — and the deferred-teardown recovery path
127
+ // (#3008) tells operators to run exactly this command before deleting a receipt,
128
+ // so the incomplete teardown would be signed off and the obligation erased.
129
+ let grokNote = "";
130
+ let grokCode = 0;
131
+ try {
132
+ const g = stripGrokConfig();
133
+ if (g.changed) grokNote = ` ${g.message}`;
134
+ else if (!g.ok) { grokNote = ` Grok config cleanup failed: ${g.message}`; grokCode = 1; }
135
+ } catch (err) {
136
+ grokNote = ` Grok config cleanup failed: ${err instanceof Error ? err.message : String(err)}`;
137
+ grokCode = 1;
138
+ }
139
+ const alreadyOff = `Codex integration is already OFF and native; no Codex files changed.${grokNote}`;
125
140
  if (restoreJson) {
126
141
  const { skippedRestoreEnvelope } = await import("../codex/inject");
127
- console.log(JSON.stringify(skippedRestoreEnvelope(true, alreadyOff)));
128
- } else {
142
+ console.log(JSON.stringify(skippedRestoreEnvelope(grokCode === 0, alreadyOff)));
143
+ } else if (grokCode === 0) {
129
144
  console.log(alreadyOff);
145
+ } else {
146
+ console.error(alreadyOff);
130
147
  }
131
- return 0;
148
+ return grokCode;
132
149
  }
133
150
  }
134
151
  let r: { success: boolean; message: string };
@@ -137,26 +154,40 @@ const commandRunners: Record<string, CommandRunner> = {
137
154
  } catch (err) {
138
155
  r = { success: false, message: err instanceof Error ? err.message : String(err) };
139
156
  }
157
+ // Grok BEFORE either output. The JSON path used to return here, so `ocx restore --json`
158
+ // (and `ocx eject --json`, the same runner) could report success while the fence still
159
+ // pointed at the stopped proxy — and the deferred-teardown recovery on this branch
160
+ // tells operators to run exactly this before deleting a receipt (#3008).
161
+ let grokFailure: string | null = null;
162
+ let grokChangedMessage: string | null = null;
163
+ try {
164
+ const g = stripGrokConfig();
165
+ if (g.changed) grokChangedMessage = g.message;
166
+ else if (!g.ok) grokFailure = g.message;
167
+ } catch (err) {
168
+ grokFailure = err instanceof Error ? err.message : String(err);
169
+ }
140
170
  if (restoreJson) {
141
171
  // Spawned callers need the artifact-level result to distinguish a busy
142
172
  // history worker from a successful native restore. Keep stdout machine
143
- // readable; human framing remains the default command contract.
144
- console.log(JSON.stringify(r));
145
- return r.success ? 0 : 1;
173
+ // readable the Codex artifact schema is unchanged; the Grok outcome is
174
+ // folded into success/message so a caller cannot read a half teardown as done.
175
+ const message = grokFailure
176
+ ? `${r.message} Grok config cleanup failed: ${grokFailure}`
177
+ : grokChangedMessage ? `${r.message} ${grokChangedMessage}` : r.message;
178
+ console.log(JSON.stringify({ ...r, success: r.success && !grokFailure, message }));
179
+ return r.success && !grokFailure ? 0 : 1;
146
180
  }
147
181
  if (r.success) console.log(`✅ ${r.message}`);
148
182
  else {
149
183
  console.error(`⚠️ ${r.message}`);
150
184
  }
151
185
  let code = r.success ? 0 : 1;
152
- try {
153
- const g = stripGrokConfig();
154
- if (g.changed) console.log(`✅ ${g.message}`);
155
- else if (!g.ok) {
156
- console.error(`⚠️ ${g.message}`);
157
- code = 1;
158
- }
159
- } catch { /* best-effort */ }
186
+ if (grokChangedMessage) console.log(`✅ ${grokChangedMessage}`);
187
+ if (grokFailure) {
188
+ console.error(`⚠️ ${grokFailure}`);
189
+ code = 1;
190
+ }
160
191
  if (r.success) {
161
192
  console.log("Codex integration is OFF and plain `codex` now runs natively. Switch back with: ocx restore back");
162
193
  } else {
@@ -542,7 +573,12 @@ const commandRunners: Record<string, CommandRunner> = {
542
573
  health: async deps => {
543
574
  const healthArgs = deps.args.slice(1);
544
575
  const wantsHealthJson = healthArgs.includes("--json");
545
- const live = await deps.findLiveProxy();
576
+ // A proxy that has only just bound can miss a single probe while its event loop
577
+ // is still settling startup work — the same just-started race the stop paths
578
+ // already retry for (#764, SERVICE_STOP_LIVENESS). Without this, `ocx health`
579
+ // run seconds after a service restart reports a false negative on a proxy that
580
+ // is in fact serving.
581
+ const live = await deps.findLiveProxy({ attempts: 3 });
546
582
  if (wantsHealthJson) {
547
583
  console.log(JSON.stringify({ ok: !!live, pid: live?.pid ?? null, port: live?.port ?? null }));
548
584
  } else {
@@ -80,28 +80,24 @@ function hasContextLimit(model: ExportModel): boolean {
80
80
  *
81
81
  * `opencodeCatalogFromProxyRows` owns the visibility rules (drop `disabled`, drop dupes,
82
82
  * drop native under Codex Direct) — the export core does none of that, so a row filtered
83
- * here is the only thing keeping a disabled model out of a client's picker. Modalities are
84
- * re-joined by `namespaced` because the launcher's catalog type does not carry them.
83
+ * here is the only thing keeping a disabled model out of a client's picker. It also carries
84
+ * the effort ladder, so the ladder a client receives comes from the same filtered, deduped
85
+ * row as the model itself: a second lookup over the raw rows would let a hidden or disabled
86
+ * duplicate donate its ladder to the visible entry.
87
+ *
88
+ * Only modalities are re-joined by `namespaced`, because the catalog type does not carry them.
85
89
  */
86
90
  export function exportModelsFromProxyRows(
87
91
  rows: readonly ExportProxyModelRow[],
88
92
  config: OcxConfig,
89
93
  ): ExportModel[] {
90
- const metadata = new Map<string, Pick<ExportModel, "inputModalities" | "reasoningEfforts" | "defaultReasoningEffort">>();
94
+ const modalities = new Map<string, string[]>();
91
95
  for (const row of rows) {
92
96
  const namespaced = row.namespaced?.trim();
93
- if (!namespaced || metadata.has(namespaced)) continue;
94
- metadata.set(namespaced, {
95
- ...(Array.isArray(row.inputModalities) && row.inputModalities.length > 0
96
- ? { inputModalities: [...row.inputModalities] }
97
- : {}),
98
- ...(Array.isArray(row.reasoningEfforts) && row.reasoningEfforts.length > 0
99
- ? { reasoningEfforts: [...row.reasoningEfforts] }
100
- : {}),
101
- ...(typeof row.defaultReasoningEffort === "string" && row.defaultReasoningEffort.length > 0
102
- ? { defaultReasoningEffort: row.defaultReasoningEffort }
103
- : {}),
104
- });
97
+ if (!namespaced || modalities.has(namespaced)) continue;
98
+ if (Array.isArray(row.inputModalities) && row.inputModalities.length > 0) {
99
+ modalities.set(namespaced, [...row.inputModalities]);
100
+ }
105
101
  }
106
102
  return opencodeCatalogFromProxyRows(rows, config).map(entry => {
107
103
  const model: ExportModel = {
@@ -112,7 +108,12 @@ export function exportModelsFromProxyRows(
112
108
  if (entry.native) model.native = true;
113
109
  if (entry.displayName) model.displayName = entry.displayName;
114
110
  if (entry.contextWindow !== undefined) model.contextWindow = entry.contextWindow;
115
- Object.assign(model, metadata.get(entry.namespaced));
111
+ if (entry.reasoningEfforts && entry.reasoningEfforts.length > 0) {
112
+ model.reasoningEfforts = [...entry.reasoningEfforts];
113
+ }
114
+ if (entry.defaultReasoningEffort) model.defaultReasoningEffort = entry.defaultReasoningEffort;
115
+ const input = modalities.get(entry.namespaced);
116
+ if (input) model.inputModalities = [...input];
116
117
  return model;
117
118
  });
118
119
  }
@@ -203,7 +204,7 @@ export async function handleExportCommand(argv: string[], deps: ExportCommandDep
203
204
  "",
204
205
  ...(out !== undefined ? [`Wrote ${out}`] : []),
205
206
  `Destination: ${spec.destination(process.env)}`,
206
- "Merge this provider block into that file; do not replace it.",
207
+ "Merge this generated configuration into that file; do not replace it.",
207
208
  `Before launching: ${spec.exportHint}`,
208
209
  `${models.length} model${models.length === 1 ? "" : "s"}; ${degraded} omit context limits (the client applies its own defaults).`,
209
210
  ]);
package/src/cli/help.ts CHANGED
@@ -73,10 +73,10 @@ Usage:
73
73
  ocx memory [--json] Alias of ocx observe memory
74
74
  ocx api-key <sub> Alias of ocx access key
75
75
  ocx access <sub> External API keys and endpoint information
76
- ocx export --client <id> Print a client config wired to the running proxy (11 clients)
76
+ ocx export --client <id> Print a client config wired to the running proxy (12 clients)
77
77
  ocx integration client <sub> Enable, disable, inspect or roll back a client integration
78
78
  ocx grok <sub> Grok Build model selection and apply
79
- ocx system <sub> Runtime settings, startup, sync, and updates
79
+ ocx system <sub> Runtime settings, startup, sync, OpenCodex updates, and Codex CLI inspection
80
80
  ocx config <sub> Validated configuration show/get/set/import/export
81
81
  ocx lab <sub> Read-only Compatibility Lab projection inspection
82
82
  ocx claude [args...] Launch Claude Code wired to the proxy (model discovery on)