@bitkyc08/opencodex 2.25.0 → 2.26.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 (99) hide show
  1. package/bin/ocx.mjs +59 -7
  2. package/gui/dist/assets/index-RL6b1bTV.js +102 -0
  3. package/gui/dist/index.html +1 -1
  4. package/package.json +1 -1
  5. package/src/adapters/base.ts +18 -0
  6. package/src/adapters/client-fingerprint.ts +0 -2
  7. package/src/adapters/cursor/http1-bidi.ts +361 -0
  8. package/src/adapters/cursor/live-models.ts +117 -30
  9. package/src/adapters/cursor/live-transport.ts +137 -56
  10. package/src/adapters/cursor/native-exec-fs.ts +1 -1
  11. package/src/adapters/cursor/native-exec-network.ts +1 -1
  12. package/src/adapters/cursor/native-exec-shell.ts +0 -1
  13. package/src/adapters/cursor/protobuf-request.ts +89 -21
  14. package/src/adapters/cursor/tool-definitions.ts +18 -7
  15. package/src/adapters/cursor/tool-result-normalize.ts +92 -0
  16. package/src/adapters/cursor/transport.ts +7 -0
  17. package/src/adapters/cursor.ts +2 -0
  18. package/src/adapters/google-http.ts +38 -10
  19. package/src/adapters/google.ts +23 -3
  20. package/src/adapters/openai-chat.ts +38 -13
  21. package/src/adapters/openai-responses.ts +129 -9
  22. package/src/adapters/registry.ts +30 -1
  23. package/src/bridge.ts +50 -12
  24. package/src/chat/inbound.ts +1 -0
  25. package/src/claude/agents-inject.ts +3 -2
  26. package/src/cli/dispatch.ts +19 -6
  27. package/src/cli/help.ts +2 -1
  28. package/src/cli/integrations.ts +35 -0
  29. package/src/cli/minimax.ts +8 -2
  30. package/src/cli/registry.ts +13 -2
  31. package/src/clients/config-export.ts +120 -1
  32. package/src/codex/account-store.ts +17 -1
  33. package/src/codex/auth-api.ts +51 -17
  34. package/src/codex/catalog/effort.ts +8 -5
  35. package/src/codex/catalog/provider-fetch.ts +39 -27
  36. package/src/codex/catalog/sync.ts +30 -8
  37. package/src/codex/inject.ts +39 -13
  38. package/src/codex/main-account.ts +29 -1
  39. package/src/codex/plan-from-token.ts +140 -0
  40. package/src/codex/plan.ts +25 -0
  41. package/src/codex/prompt-journal.ts +6 -2
  42. package/src/codex/quota-rejection.ts +21 -7
  43. package/src/codex/refresh.ts +4 -2
  44. package/src/codex/sync.ts +106 -3
  45. package/src/codex/warmup.ts +187 -81
  46. package/src/config.ts +85 -46
  47. package/src/generated/compatibility-version.json +127 -83
  48. package/src/grok/inject.ts +1 -1
  49. package/src/images/loop.ts +1 -0
  50. package/src/integrations/registry.ts +7 -0
  51. package/src/lab/automation/config-persistence.ts +2 -2
  52. package/src/lab/automation/persistence.ts +2 -2
  53. package/src/lab/ledger/purge.ts +2 -2
  54. package/src/lab/subject/behavior-fingerprint.ts +2 -2
  55. package/src/lib/config-ownership.ts +5 -2
  56. package/src/lib/destination-policy.ts +18 -1
  57. package/src/lib/provider-outbound.ts +7 -0
  58. package/src/lib/redact.ts +11 -0
  59. package/src/lib/tool-argument-integers.ts +50 -6
  60. package/src/lib/upstream-http-version.ts +57 -0
  61. package/src/lib/upstream-retry.ts +2 -1
  62. package/src/lib/windows-atomic-replace.ts +155 -0
  63. package/src/lib/windows-service-wrappers.ts +72 -0
  64. package/src/oauth/google-antigravity.ts +2 -2
  65. package/src/oauth/index.ts +60 -8
  66. package/src/providers/antigravity-models.ts +58 -4
  67. package/src/providers/command-code-efforts.ts +36 -9
  68. package/src/providers/context-cap.ts +9 -0
  69. package/src/providers/derive.ts +4 -0
  70. package/src/providers/fastwire.ts +453 -0
  71. package/src/providers/registry.ts +21 -1
  72. package/src/providers/service-tier.ts +173 -89
  73. package/src/responses/parser.ts +25 -16
  74. package/src/responses/reasoning-replay-cache.ts +30 -0
  75. package/src/responses/thought-signature-replay.ts +74 -4
  76. package/src/router.ts +6 -0
  77. package/src/routing/compatibility/behavior.ts +27 -16
  78. package/src/server/index.ts +10 -1
  79. package/src/server/management/oauth-account-routes.ts +10 -2
  80. package/src/server/management/shared.ts +1 -1
  81. package/src/server/management/system-routes.ts +15 -0
  82. package/src/server/request-log.ts +57 -3
  83. package/src/server/responses/agent-task-recovery.ts +6 -1
  84. package/src/server/responses/core.ts +209 -40
  85. package/src/server/responses/fetch-helpers.ts +15 -36
  86. package/src/server/responses/responses-field-backfill.ts +173 -0
  87. package/src/server/responses-reasoning-summary-rewrite.ts +171 -0
  88. package/src/service.ts +38 -36
  89. package/src/storage/cleanup.ts +2 -2
  90. package/src/tray/windows.ts +3 -2
  91. package/src/types.ts +101 -14
  92. package/src/update/job.ts +9 -18
  93. package/src/update/transactional-install.d.mts +22 -0
  94. package/src/update/transactional-install.mjs +259 -0
  95. package/src/usage/cost.ts +34 -5
  96. package/src/usage/log.ts +74 -4
  97. package/src/vision/anthropic-describe.ts +10 -6
  98. package/src/web-search/anthropic-executor.ts +8 -6
  99. package/gui/dist/assets/index-DxJ7kXj9.js +0 -102
package/bin/ocx.mjs CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  runNpmCachePreflight,
23
23
  } from "../src/update/npm-cache-preflight.mjs";
24
24
  import { handoffWindowsTrayForUpdate, planWindowsTrayUpdate } from "../src/update/tray-update-plan.mjs";
25
+ import { bootRestoreProbe, transactionalNpmUpdate } from "../src/update/transactional-install.mjs";
25
26
 
26
27
  const PKG = "@bitkyc08/opencodex";
27
28
  const require = createRequire(import.meta.url);
@@ -267,13 +268,50 @@ function runNpmSelfUpdate() {
267
268
  }
268
269
  }
269
270
 
270
- console.log(`Updating${latest ? ` to v${latest}` : ""}...\n$ npm install -g ${PKG}@${tag}`);
271
- const res = spawnSync(installInvocation.file, installInvocation.args, {
272
- stdio: "inherit",
273
- timeout: 180000,
274
- windowsHide: true,
275
- ...installInvocation.options,
276
- });
271
+ // #1942/#1849: stage -> verify -> swap -> rollback instead of installing straight
272
+ // into the live tree. A failure at any point leaves either the old or the new tree
273
+ // complete — never a file-less skeleton. Falls back to the legacy in-place install
274
+ // only when the transactional module cannot run at all.
275
+ const packageDir = resolve(here, "..");
276
+ console.log(`Updating${latest ? ` to v${latest}` : ""} (transactional)...`);
277
+ let res;
278
+ try {
279
+ const tx = transactionalNpmUpdate({
280
+ packageDir,
281
+ pkgName: PKG,
282
+ targetVersion: latest || undefined,
283
+ tag,
284
+ runNpm: (args) => {
285
+ const invocation = npmInvocation(args);
286
+ if (!invocation) return { status: 1 };
287
+ return spawnSync(invocation.file, invocation.args, {
288
+ stdio: "inherit",
289
+ timeout: 180000,
290
+ windowsHide: true,
291
+ ...invocation.options,
292
+ });
293
+ },
294
+ log: (line) => console.log(line),
295
+ });
296
+ if (tx.ok) {
297
+ res = { status: 0 };
298
+ } else if (tx.phase === "stage" || tx.phase === "verify") {
299
+ // Live tree untouched: report and stop. Nothing to roll back.
300
+ console.error(`opencodex: update aborted before touching the live install (${tx.phase}): ${tx.error}`);
301
+ res = { status: 1 };
302
+ } else {
303
+ console.error(`opencodex: update failed (${tx.phase}): ${tx.error}${tx.rolledBack ? " — previous version restored." : ""}`);
304
+ res = { status: 1 };
305
+ }
306
+ } catch (error) {
307
+ // An unexpected throw means we cannot prove the live tree is untouched, so the
308
+ // legacy in-place install (which deletes live first) is exactly the wrong rescue —
309
+ // it recreates the #1849 destruction path. Report and stop; the boot probe and the
310
+ // recovery marker cover the swap-window states.
311
+ console.error(`opencodex: transactional update failed unexpectedly (${error?.message ?? error}). ` +
312
+ "The live install was not knowingly modified; run 'ocx update' again or reinstall with npm install -g.");
313
+ res = { status: 1 };
314
+ }
277
315
  if (res.status === 0) {
278
316
  console.log(`\nUpdated${latest ? ` to v${latest}` : ""}.`);
279
317
  repairCodexShimIfNeeded();
@@ -449,6 +487,20 @@ if (process.argv[2] === "update" && isNodeModulesInstall() && !isBunGlobalInstal
449
487
  runNpmSelfUpdate();
450
488
  }
451
489
 
490
+ // #1849 boot probe: a prior update that lost power (or double-faulted) mid-swap leaves a
491
+ // backup sibling and a broken live tree. Restore before anything tries to run from the
492
+ // broken tree; reap stale backups once the live tree verifies healthy.
493
+ if (isNodeModulesInstall() && !isBunGlobalInstall()) {
494
+ try {
495
+ const probe = bootRestoreProbe(resolve(here, ".."));
496
+ if (probe.action === "restored") {
497
+ console.warn(`opencodex: previous update left a broken install — restored the backup from ${probe.from}.`);
498
+ } else if (probe.action === "failed") {
499
+ console.warn(`opencodex: a backup from a failed update exists but could not be restored automatically: ${probe.error}`);
500
+ }
501
+ } catch { /* the probe must never block launch */ }
502
+ }
503
+
452
504
  const bunRuntime = resolveBun();
453
505
  const bun = bunRuntime.path;
454
506