@bitkyc08/opencodex 2.7.43 → 2.8.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 (73) hide show
  1. package/bin/ocx.mjs +34 -8
  2. package/gui/dist/assets/index-BDjpkcRN.js +67 -0
  3. package/gui/dist/assets/index-BHsKRFh9.css +1 -0
  4. package/gui/dist/index.html +2 -2
  5. package/package.json +1 -1
  6. package/src/adapters/cursor/discovery.ts +4 -1
  7. package/src/adapters/cursor/effort-map.ts +3 -0
  8. package/src/adapters/kiro.ts +15 -1
  9. package/src/claude/alias.ts +94 -14
  10. package/src/claude/outbound.ts +6 -3
  11. package/src/cli/catalog-prewarm.ts +24 -0
  12. package/src/cli/claude.ts +32 -7
  13. package/src/cli/doctor.ts +48 -1
  14. package/src/cli/index.ts +5 -0
  15. package/src/cli/interactive-confirm.ts +5 -1
  16. package/src/cli/star-prompt.ts +26 -4
  17. package/src/cli/v2.ts +10 -1
  18. package/src/codex/account-store.ts +2 -0
  19. package/src/codex/catalog/bundled.ts +9 -2
  20. package/src/codex/catalog/parsing.ts +26 -1
  21. package/src/codex/catalog/provider-fetch.ts +240 -82
  22. package/src/codex/catalog/sync.ts +27 -5
  23. package/src/codex/catalog.ts +1 -1
  24. package/src/codex/features.ts +524 -5
  25. package/src/codex/quota.ts +77 -2
  26. package/src/codex/runtime.ts +10 -1
  27. package/src/config.ts +8 -0
  28. package/src/generated/jawcode-model-metadata.ts +12 -12
  29. package/src/github/star-state.ts +191 -0
  30. package/src/lib/bun-binary-validator.d.mts +3 -0
  31. package/src/lib/bun-binary-validator.mjs +18 -0
  32. package/src/lib/bun-runtime.ts +6 -20
  33. package/src/lib/destination-policy.ts +10 -3
  34. package/src/lib/provider-outbound.ts +5 -2
  35. package/src/lib/shadow-call.ts +30 -0
  36. package/src/lib/test-home-guard.ts +90 -0
  37. package/src/lib/win-exec.ts +12 -2
  38. package/src/oauth/index.ts +29 -5
  39. package/src/oauth/key-providers.ts +21 -2
  40. package/src/oauth/kiro-credentials.ts +57 -8
  41. package/src/oauth/kiro.ts +2 -1
  42. package/src/oauth/login-cli.ts +1 -1
  43. package/src/oauth/store.ts +2 -0
  44. package/src/providers/derive.ts +2 -2
  45. package/src/providers/model-discovery.ts +356 -0
  46. package/src/providers/registry.ts +114 -0
  47. package/src/router.ts +5 -3
  48. package/src/server/auth-cors.ts +4 -2
  49. package/src/server/live.ts +75 -25
  50. package/src/server/management/agent-settings-routes.ts +78 -4
  51. package/src/server/management/config-routes.ts +19 -7
  52. package/src/server/management/context.ts +11 -1
  53. package/src/server/management/model-routes.ts +46 -13
  54. package/src/server/management/provider-routes.ts +44 -9
  55. package/src/server/management/shared.ts +2 -2
  56. package/src/server/management/sidebar-routes.ts +39 -0
  57. package/src/server/management-api.ts +3 -1
  58. package/src/server/responses/core.ts +31 -20
  59. package/src/server/responses/upstream-error.ts +48 -0
  60. package/src/server/startup-action-control.ts +30 -14
  61. package/src/service.ts +237 -19
  62. package/src/storage/policy-job.ts +26 -5
  63. package/src/storage/restore-job.ts +16 -5
  64. package/src/storage/worker-lifecycle.ts +81 -0
  65. package/src/tray/windows.ts +32 -4
  66. package/src/types.ts +11 -0
  67. package/src/update/badge.ts +72 -0
  68. package/src/update/job.ts +8 -4
  69. package/src/usage/expected-prices.ts +6 -5
  70. package/src/usage/log.ts +8 -0
  71. package/src/web-search/loop.ts +57 -16
  72. package/gui/dist/assets/index-Czw-jpTU.css +0 -1
  73. package/gui/dist/assets/index-cmds12BG.js +0 -67
package/bin/ocx.mjs CHANGED
@@ -10,10 +10,11 @@
10
10
  */
11
11
  import { spawn, spawnSync } from "node:child_process";
12
12
  import { createRequire } from "node:module";
13
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
13
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
14
14
  import { homedir } from "node:os";
15
15
  import { dirname, join, resolve } from "node:path";
16
16
  import { fileURLToPath } from "node:url";
17
+ import { isRealBunBinary } from "../src/lib/bun-binary-validator.mjs";
17
18
  import { npmInvocation } from "../src/update/npm-invocation.mjs";
18
19
  import { handoffWindowsTrayForUpdate, planWindowsTrayUpdate } from "../src/update/tray-update-plan.mjs";
19
20
 
@@ -287,18 +288,14 @@ function bunBinDir() {
287
288
  return dirname(require.resolve("bun/package.json"));
288
289
  }
289
290
 
290
- // The `bun` package ships a tiny ASCII placeholder at bin/bun.exe until its
291
- // postinstall downloads the real ~60MB binary. --ignore-scripts / pnpm leave
292
- // the ~450-byte stub in place, which is NOT executable (ENOEXEC). A size gate
293
- // cleanly distinguishes the stub from a real binary on every platform.
294
- const REAL_BUN_MIN_BYTES = 1_000_000;
291
+ const BUN_OVERRIDE_ENV = "OPENCODEX_BUN_PATH";
295
292
 
296
293
  function findBunBinary(bunDir) {
297
294
  // The npm `bun` package ships the binary as bin/bun.exe on every platform;
298
295
  // probe bin/bun too for forward compatibility.
299
296
  for (const name of ["bun.exe", "bun"]) {
300
297
  const p = join(bunDir, "bin", name);
301
- if (existsSync(p) && statSync(p).size >= REAL_BUN_MIN_BYTES) return p;
298
+ if (isRealBunBinary(p)) return p;
302
299
  }
303
300
  return null;
304
301
  }
@@ -317,6 +314,17 @@ function fail(msg) {
317
314
  }
318
315
 
319
316
  function resolveBun() {
317
+ // Keep direct npm-launcher starts aligned with durable service/shim installs:
318
+ // a valid explicit runtime must win even when the bundled dependency exists.
319
+ const override = process.env[BUN_OVERRIDE_ENV]?.trim();
320
+ if (override) {
321
+ const overridePath = resolve(override);
322
+ if (isRealBunBinary(overridePath)) return overridePath;
323
+ console.error(
324
+ `opencodex: ${BUN_OVERRIDE_ENV} is missing, unreadable, or not a complete Bun binary; falling back to the bundled runtime.`,
325
+ );
326
+ }
327
+
320
328
  let bunDir;
321
329
  try {
322
330
  bunDir = bunBinDir();
@@ -361,7 +369,25 @@ const bun = resolveBun();
361
369
  // signal delivered only to this launcher (Codex app, IDE terminal, service wrapper,
362
370
  // or `kill -INT <launcherPid>`) killed the launcher and ORPHANED the Bun proxy —
363
371
  // port left bound, pid/runtime-port files left behind, Codex config not restored.
364
- const child = spawn(bun, [cliPath, ...process.argv.slice(2)], { stdio: "inherit" });
372
+ //
373
+ // Provenance seam for issue #701: THIS launcher runs under Node, which does not
374
+ // auto-load a project `.env`/`.env.local`; the Bun child does, before any opencodex
375
+ // code evaluates. So this is the last point that can still tell a real shell export
376
+ // from a working-directory dotenv value, and we record which Anthropic credential
377
+ // slots already existed. `src/cli/claude.ts` then treats anything present in the Bun
378
+ // child but missing from this list as ambient project pollution rather than user auth,
379
+ // which stopped a project dotenv from silently moving a claude.ai subscriber onto API
380
+ // billing. An EMPTY value is meaningful (the launcher ran and saw no slots) and is
381
+ // distinct from the variable being absent (no launcher at all — change nothing), so
382
+ // this must stay a plain assignment and never be collapsed to a falsy check.
383
+ // Disabling Bun's dotenv wholesale with --no-env-file is NOT an option: config
384
+ // interpolation and provider settings legitimately read the project environment.
385
+ const preBunAnthropicSlots = ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"]
386
+ .filter(name => typeof process.env[name] === "string" && process.env[name] !== "");
387
+ const child = spawn(bun, [cliPath, ...process.argv.slice(2)], {
388
+ stdio: "inherit",
389
+ env: { ...process.env, OCX_PRE_BUN_ANTHROPIC_ENV: preBunAnthropicSlots.join(",") },
390
+ });
365
391
 
366
392
  // Windows has no real POSIX signals (no SIGHUP); forwarding is best-effort there.
367
393
  const FORWARDED = process.platform === "win32" ? ["SIGINT", "SIGTERM"] : ["SIGINT", "SIGTERM", "SIGHUP"];