@bitkyc08/opencodex 2.99.0-preview.20261108 → 2.100.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 (258) hide show
  1. package/AGENTS_INSTALL.md +19 -1
  2. package/README.md +37 -33
  3. package/SPONSORS.md +5 -1
  4. package/bin/ocx.mjs +1 -1
  5. package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
  6. package/gui/dist/assets/App-CitvEefy.js +59 -0
  7. package/gui/dist/assets/Tray-CeKVWQyB.js +1 -0
  8. package/gui/dist/assets/{brand-mark-DpiBmFGI.js → brand-mark-M92UnxX2.js} +1 -1
  9. package/gui/dist/assets/index-BP47do6-.js +94 -0
  10. package/gui/dist/assets/index-DmDooSAG.css +2 -0
  11. package/gui/dist/assets/{segment-thumb-features-JcszQ18T.js → segment-thumb-features-CcxZBnxv.js} +1 -1
  12. package/gui/dist/classic/assets/App-aYgIQMxI.js +58 -0
  13. package/gui/dist/classic/assets/{Tray-5v86r9Az.js → Tray-D8jfUXpQ.js} +1 -1
  14. package/gui/dist/classic/assets/index-CfGqHooN.js +94 -0
  15. package/gui/dist/classic/assets/quota-summary-R-ih7OlS.js +1 -0
  16. package/gui/dist/classic/index.html +1 -1
  17. package/gui/dist/index.html +2 -2
  18. package/native/ocx-child/Cargo.lock +215 -0
  19. package/native/ocx-child/Cargo.toml +31 -0
  20. package/native/ocx-child/src/cli.rs +1901 -0
  21. package/native/ocx-child/src/codex_home.rs +429 -0
  22. package/native/ocx-child/src/codex_settings.rs +231 -0
  23. package/native/ocx-child/src/daemon.rs +363 -0
  24. package/native/ocx-child/src/http_wire.rs +619 -0
  25. package/native/ocx-child/src/journal.rs +977 -0
  26. package/native/ocx-child/src/lib.rs +22 -0
  27. package/native/ocx-child/src/main.rs +9 -0
  28. package/native/ocx-child/src/parity.rs +102 -0
  29. package/native/ocx-child/src/platform.rs +1487 -0
  30. package/native/ocx-child/src/relay.rs +1288 -0
  31. package/native/ocx-child/src/relay_auth.rs +166 -0
  32. package/native/ocx-child/src/routes.rs +236 -0
  33. package/native/ocx-child/src/state.rs +190 -0
  34. package/native/ocx-child/src/test_hooks.rs +58 -0
  35. package/native/ocx-child/src/toml_surgeon.rs +1156 -0
  36. package/package.json +8 -2
  37. package/src/adapters/anthropic.ts +28 -2
  38. package/src/adapters/claude-cli/adapter.ts +5 -25
  39. package/src/adapters/claude-cli/instruction-images.ts +31 -0
  40. package/src/adapters/claude-cli/stable-replay.ts +42 -14
  41. package/src/adapters/claude-cli/usage-admission.ts +53 -64
  42. package/src/adapters/coding-agent/protocol.ts +1 -1
  43. package/src/adapters/devin/live-models.ts +3 -0
  44. package/src/adapters/google-http.ts +3 -0
  45. package/src/adapters/google-vertex-key-project.ts +10 -2
  46. package/src/adapters/google.ts +40 -8
  47. package/src/adapters/kiro/usage.ts +3 -13
  48. package/src/adapters/openai-responses/passthrough.ts +5 -2
  49. package/src/adapters/openai-responses/request-strips.ts +32 -0
  50. package/src/adapters/openai-responses/tool-schema.ts +9 -4
  51. package/src/chat/inbound.ts +1 -1
  52. package/src/claude/auth-detect.ts +26 -8
  53. package/src/claude/inbound-content-options.ts +18 -3
  54. package/src/claude/inbound.ts +5 -2
  55. package/src/cli/bundled-bun-diagnostic.ts +91 -0
  56. package/src/cli/capabilities-agents-routing.ts +2 -2
  57. package/src/cli/capabilities-observe-system.ts +60 -0
  58. package/src/cli/combo-input.ts +6 -0
  59. package/src/cli/combo-result.ts +1 -1
  60. package/src/cli/combo.ts +4 -0
  61. package/src/cli/config-command.ts +16 -2
  62. package/src/cli/connect.ts +12 -10
  63. package/src/cli/dispatch.ts +4 -0
  64. package/src/cli/doctor.ts +11 -0
  65. package/src/cli/help.ts +1 -0
  66. package/src/cli/init.ts +4 -0
  67. package/src/cli/link-enrollment.ts +152 -25
  68. package/src/cli/link-local-control.ts +49 -0
  69. package/src/cli/link.ts +37 -10
  70. package/src/cli/provider-lifecycle-runtime.ts +4 -2
  71. package/src/cli/registry.ts +13 -0
  72. package/src/cli/star-prompt.ts +2 -0
  73. package/src/cli/status.ts +1 -1
  74. package/src/cli/telemetry-profile.ts +206 -0
  75. package/src/cli/telemetry.ts +260 -0
  76. package/src/client/hub-relay.ts +26 -0
  77. package/src/client/machine-api.ts +3 -0
  78. package/src/clients/config-export/t3code.ts +44 -5
  79. package/src/clients/omo-role-models.ts +1 -1
  80. package/src/codex/catalog/bundled.ts +44 -2
  81. package/src/codex/runtime.ts +12 -0
  82. package/src/codex/shim-restore-lock.ts +67 -30
  83. package/src/combos/types.ts +21 -1
  84. package/src/config/atomic-write.ts +24 -1
  85. package/src/config/diagnostics.ts +15 -0
  86. package/src/config/live-reconcile.ts +17 -0
  87. package/src/config/load-degrade.ts +16 -0
  88. package/src/config/provider-validation.ts +29 -0
  89. package/src/config/schema/config-schema.ts +24 -0
  90. package/src/config/schema/leaf-validators.ts +17 -0
  91. package/src/config/telemetry-carry.ts +30 -0
  92. package/src/config.ts +13 -1
  93. package/src/generated/compatibility-version.json +405 -153
  94. package/src/generated/model-metadata.ts +3 -3
  95. package/src/integrations/aside-profiles.ts +7 -1
  96. package/src/integrations/owned-refresh.ts +9 -2
  97. package/src/lab/artifacts/secure-fs.ts +12 -11
  98. package/src/lab/fabric/scratch.ts +11 -9
  99. package/src/lab/public/community.ts +2 -3
  100. package/src/lab/public/file-safety.ts +18 -20
  101. package/src/lab/public/mutation-lock.ts +109 -337
  102. package/src/lab/public/private-file.ts +4 -3
  103. package/src/lib/bun-runtime-preflight.ts +1 -1
  104. package/src/lib/codex-catalog-read-only.ts +122 -0
  105. package/src/lib/config-ownership.ts +49 -18
  106. package/src/lib/errors.ts +11 -0
  107. package/src/lib/gcp-adc.ts +167 -48
  108. package/src/lib/jsonc.ts +4 -2
  109. package/src/lib/local-control-socket.ts +88 -0
  110. package/src/lib/privacy.ts +15 -0
  111. package/src/lib/provider-client-headers.ts +3 -0
  112. package/src/lib/token-estimate.ts +13 -2
  113. package/src/link/child-binary-source.ts +228 -0
  114. package/src/link/ephemeral-child.ts +45 -0
  115. package/src/link/remote-plant.ts +306 -0
  116. package/src/link/remote-windows.ts +59 -5
  117. package/src/link/ssh-argv.ts +71 -8
  118. package/src/link/status-projection.ts +2 -0
  119. package/src/link/store.ts +5 -1
  120. package/src/oauth/claude-keychain-read.ts +165 -0
  121. package/src/oauth/local-token-detect.ts +14 -17
  122. package/src/protocols/envelope.ts +20 -2
  123. package/src/providers/api-key-selection.ts +8 -2
  124. package/src/providers/claude-cli-usage-state.ts +93 -0
  125. package/src/providers/github-copilot-auto.ts +25 -5
  126. package/src/providers/meta-muse-plan-refusal.ts +94 -0
  127. package/src/providers/model-rename-fields.ts +3 -0
  128. package/src/providers/quota/vendor-probes-key.ts +23 -4
  129. package/src/providers/quota/vendor-probes-oauth.ts +59 -0
  130. package/src/providers/quota/workbuddy.ts +2 -2
  131. package/src/providers/quota.ts +25 -18
  132. package/src/providers/registry/entries-core.ts +7 -4
  133. package/src/providers/registry/entries-extended.ts +39 -7
  134. package/src/providers/registry/model-seeds.ts +10 -2
  135. package/src/providers/resolved-model-policy.ts +4 -0
  136. package/src/providers/routed-config.ts +30 -3
  137. package/src/providers/stale-no-vision-seed-migration.ts +7 -0
  138. package/src/providers/vertex-environment-authority.ts +50 -0
  139. package/src/providers/workbuddy-credit-balance.ts +38 -6
  140. package/src/quota-pool/assemble.ts +14 -6
  141. package/src/router.ts +1 -0
  142. package/src/server/adapter-resolve.ts +11 -6
  143. package/src/server/audio-dictation.ts +21 -7
  144. package/src/server/auth-cors.ts +19 -0
  145. package/src/server/background-lifecycle.ts +71 -0
  146. package/src/server/chat-completions.ts +2 -0
  147. package/src/server/claude-messages.ts +30 -3
  148. package/src/server/index/live-sideband.ts +15 -1
  149. package/src/server/index/local-control-listener.ts +515 -0
  150. package/src/server/index/optional-listeners.ts +21 -1
  151. package/src/server/index/serve-options.ts +4 -3
  152. package/src/server/index/websocket-handler.ts +2 -0
  153. package/src/server/index.ts +3 -0
  154. package/src/server/management/combo-routes.ts +6 -1
  155. package/src/server/management/context.ts +1 -0
  156. package/src/server/management/link-child-preflight.ts +74 -0
  157. package/src/server/management/link-enrollment.ts +190 -25
  158. package/src/server/management/link-route-state.ts +6 -1
  159. package/src/server/management/link-routes.ts +27 -9
  160. package/src/server/management/model-rows.ts +4 -0
  161. package/src/server/management/oauth-account-routes.ts +9 -4
  162. package/src/server/management/provider-overwrite-carry.ts +9 -2
  163. package/src/server/management/provider-routes.ts +14 -0
  164. package/src/server/management/provider-thinking-display-patch.ts +54 -0
  165. package/src/server/management/route-registry.ts +7 -0
  166. package/src/server/management/session-routes.ts +4 -1
  167. package/src/server/management/telemetry-routes.ts +37 -0
  168. package/src/server/management/usage-aggregate-cache.ts +290 -67
  169. package/src/server/management-api.ts +11 -2
  170. package/src/server/messages-native-preflight.ts +166 -0
  171. package/src/server/messages-native.ts +143 -43
  172. package/src/server/messages-shared.ts +14 -0
  173. package/src/server/proxy-liveness.ts +99 -6
  174. package/src/server/request-log-conversation.ts +18 -2
  175. package/src/server/request-log.ts +7 -2
  176. package/src/server/responses/adapter-continuation.ts +1 -0
  177. package/src/server/responses/adapter-dispatch.ts +11 -28
  178. package/src/server/responses/adapter-failure-message.ts +68 -0
  179. package/src/server/responses/combo-stream-preflight.ts +14 -2
  180. package/src/server/responses/core-auth.ts +26 -5
  181. package/src/server/responses/core-codex-account.ts +8 -1
  182. package/src/server/responses/core-combo-failure.ts +6 -1
  183. package/src/server/responses/core-combo-native.ts +150 -37
  184. package/src/server/responses/core-combo.ts +15 -9
  185. package/src/server/responses/core-normalize.ts +1 -0
  186. package/src/server/responses/core-options.ts +7 -1
  187. package/src/server/responses/core-pipeline.ts +21 -1
  188. package/src/server/responses/fetch-helpers.ts +5 -0
  189. package/src/server/responses/opengateway-completion-guard.ts +7 -3
  190. package/src/server/responses/passthrough-delivery.ts +8 -1
  191. package/src/server/responses/passthrough-error.ts +22 -0
  192. package/src/server/responses/request-prepare.ts +7 -1
  193. package/src/server/responses/request-transport.ts +28 -5
  194. package/src/server/responses/run-turn-execution.ts +13 -0
  195. package/src/server/sse-frame-buffer.ts +5 -0
  196. package/src/server/ws-bridge.ts +10 -0
  197. package/src/service/launchd.ts +78 -4
  198. package/src/telemetry/aggregate.ts +348 -0
  199. package/src/telemetry/consent.ts +128 -0
  200. package/src/telemetry/contract.ts +403 -0
  201. package/src/telemetry/disclosure.ts +19 -0
  202. package/src/telemetry/install-id.ts +226 -0
  203. package/src/telemetry/payload.ts +129 -0
  204. package/src/telemetry/profile/client.ts +150 -0
  205. package/src/telemetry/profile/contract.ts +288 -0
  206. package/src/telemetry/profile/disclosure.ts +14 -0
  207. package/src/telemetry/profile/paths.ts +13 -0
  208. package/src/telemetry/profile/routes.ts +99 -0
  209. package/src/telemetry/profile/service.ts +234 -0
  210. package/src/telemetry/profile/state.ts +189 -0
  211. package/src/telemetry/profile/sync.ts +276 -0
  212. package/src/telemetry/routes.ts +183 -0
  213. package/src/telemetry/scheduler.ts +386 -0
  214. package/src/telemetry/sender.ts +97 -0
  215. package/src/telemetry/state.ts +334 -0
  216. package/src/types/combo-jev-effort-mode.ts +11 -0
  217. package/src/types/config.ts +3 -0
  218. package/src/types/provider.ts +11 -1
  219. package/src/types/request.ts +2 -0
  220. package/src/types/telemetry.ts +15 -0
  221. package/src/types/wire.ts +10 -0
  222. package/src/types.ts +5 -0
  223. package/src/update/index.ts +7 -1
  224. package/src/update/minisign.d.mts +17 -0
  225. package/src/update/minisign.mjs +88 -0
  226. package/src/update/signed-supply.d.mts +59 -0
  227. package/src/update/signed-supply.mjs +289 -0
  228. package/src/update/trust-root.json +38 -0
  229. package/src/update/update-bounded-json.d.mts +4 -0
  230. package/src/update/update-bounded-json.mjs +113 -0
  231. package/src/update/update-bytes.d.mts +2 -0
  232. package/src/update/update-bytes.mjs +23 -0
  233. package/src/update/update-candidate-id.d.mts +2 -0
  234. package/src/update/update-candidate-id.mjs +23 -0
  235. package/src/update/update-checkpoint-codec.d.mts +33 -0
  236. package/src/update/update-checkpoint-codec.mjs +217 -0
  237. package/src/update/update-contracts.d.mts +24 -0
  238. package/src/update/update-contracts.mjs +207 -0
  239. package/src/update/update-signature-threshold.d.mts +12 -0
  240. package/src/update/update-signature-threshold.mjs +47 -0
  241. package/src/update/update-signed-version.d.mts +5 -0
  242. package/src/update/update-signed-version.mjs +25 -0
  243. package/src/update/update-trust-anchor.d.mts +2 -0
  244. package/src/update/update-trust-anchor.mjs +2 -0
  245. package/src/usage/cache-diagnostic.ts +195 -50
  246. package/src/usage/expected-prices.ts +20 -2
  247. package/src/usage/filter-index.ts +1469 -0
  248. package/src/usage/ledger-scanner.ts +245 -4
  249. package/src/usage/source-filter.ts +10 -2
  250. package/src/usage/summary.ts +16 -0
  251. package/src/web-search/parse.ts +244 -38
  252. package/gui/dist/assets/App-CWz0areF.js +0 -59
  253. package/gui/dist/assets/Tray-BosDoskm.js +0 -1
  254. package/gui/dist/assets/index-CAxjGWkm.js +0 -94
  255. package/gui/dist/assets/index-bnUWypyz.css +0 -2
  256. package/gui/dist/classic/assets/App-BOEsFmiN.js +0 -58
  257. package/gui/dist/classic/assets/index-ClZ_zZ77.js +0 -94
  258. package/gui/dist/classic/assets/quota-summary-xwvDtvu7.js +0 -1
@@ -10,6 +10,7 @@ import {
10
10
  unlinkSync,
11
11
  } from "node:fs";
12
12
  import { basename, dirname, join } from "node:path";
13
+ import { sameFileIdentity } from "../../lib/file-identity";
13
14
  import { isPrivateFileStageName } from "./private-file";
14
15
  import { PublicEvidenceValidationError } from "./validate";
15
16
 
@@ -38,8 +39,8 @@ function sizeError(options: PrivateRegularFileReadOptions): PublicEvidenceValida
38
39
  */
39
40
  function recoverPublishedPrivateFileStage(path: string): void {
40
41
  if (process.platform === "win32") return;
41
- const finalStats = lstatSync(path);
42
- if (finalStats.isSymbolicLink() || !finalStats.isFile() || finalStats.nlink <= 1) return;
42
+ const finalStats = lstatSync(path, { bigint: true });
43
+ if (finalStats.isSymbolicLink() || !finalStats.isFile() || finalStats.nlink <= 1n) return;
43
44
 
44
45
  const dir = dirname(path);
45
46
  const prefix = `.${basename(path)}.`;
@@ -48,12 +49,11 @@ function recoverPublishedPrivateFileStage(path: string): void {
48
49
  if (!name.startsWith(prefix) || !isPrivateFileStageName(name)) continue;
49
50
  const stagePath = join(dir, name);
50
51
  try {
51
- const stageStats = lstatSync(stagePath);
52
+ const stageStats = lstatSync(stagePath, { bigint: true });
52
53
  if (
53
54
  stageStats.isFile()
54
55
  && !stageStats.isSymbolicLink()
55
- && stageStats.dev === finalStats.dev
56
- && stageStats.ino === finalStats.ino
56
+ && sameFileIdentity(stageStats, finalStats)
57
57
  ) {
58
58
  candidates.push(stagePath);
59
59
  }
@@ -75,12 +75,11 @@ function recoverPublishedPrivateFileStage(path: string): void {
75
75
 
76
76
  for (const stagePath of candidates) {
77
77
  try {
78
- const stageStats = lstatSync(stagePath);
78
+ const stageStats = lstatSync(stagePath, { bigint: true });
79
79
  if (
80
80
  stageStats.isFile()
81
81
  && !stageStats.isSymbolicLink()
82
- && stageStats.dev === finalStats.dev
83
- && stageStats.ino === finalStats.ino
82
+ && sameFileIdentity(stageStats, finalStats)
84
83
  ) {
85
84
  unlinkSync(stagePath);
86
85
  }
@@ -95,32 +94,31 @@ function withPrivateRegularFile<T>(
95
94
  options: PrivateRegularFileReadOptions,
96
95
  consume: (fd: number, size: number) => T,
97
96
  ): T {
98
- let pathStats = lstatSync(path);
99
- if (!pathStats.isSymbolicLink() && pathStats.isFile() && pathStats.nlink > 1) {
97
+ let pathStats = lstatSync(path, { bigint: true });
98
+ if (!pathStats.isSymbolicLink() && pathStats.isFile() && Number(pathStats.nlink) > 1) {
100
99
  recoverPublishedPrivateFileStage(path);
101
- pathStats = lstatSync(path);
100
+ pathStats = lstatSync(path, { bigint: true });
102
101
  }
103
- if (pathStats.isSymbolicLink() || !pathStats.isFile() || pathStats.nlink !== 1) {
102
+ if (pathStats.isSymbolicLink() || !pathStats.isFile() || Number(pathStats.nlink) !== 1) {
104
103
  throw new PublicEvidenceValidationError(options.errorCode, options.errorMessage);
105
104
  }
106
- if (pathStats.size > options.maxBytes) throw sizeError(options);
105
+ if (Number(pathStats.size) > options.maxBytes) throw sizeError(options);
107
106
 
108
107
  const fd = openSync(path, fsConstants.O_RDONLY | O_NOFOLLOW);
109
108
  try {
110
- const stats = fstatSync(fd);
109
+ const stats = fstatSync(fd, { bigint: true });
111
110
  if (
112
111
  !stats.isFile()
113
- || stats.nlink !== 1
114
- || stats.dev !== pathStats.dev
115
- || stats.ino !== pathStats.ino
112
+ || Number(stats.nlink) !== 1
113
+ || !sameFileIdentity(stats, pathStats)
116
114
  ) {
117
115
  throw new PublicEvidenceValidationError(options.errorCode, options.errorMessage);
118
116
  }
119
- if (stats.size > options.maxBytes) throw sizeError(options);
120
- if (options.requireMode600 && process.platform !== "win32" && (stats.mode & 0o777) !== 0o600) {
117
+ if (Number(stats.size) > options.maxBytes) throw sizeError(options);
118
+ if (options.requireMode600 && process.platform !== "win32" && (Number(stats.mode) & 0o777) !== 0o600) {
121
119
  throw new PublicEvidenceValidationError(options.errorCode, options.errorMessage);
122
120
  }
123
- return consume(fd, stats.size);
121
+ return consume(fd, Number(stats.size));
124
122
  } finally {
125
123
  closeSync(fd);
126
124
  }
@@ -1,25 +1,18 @@
1
- import { randomUUID } from "node:crypto";
2
- import {
3
- lstatSync,
4
- mkdirSync,
5
- readdirSync,
6
- renameSync,
7
- rmSync,
8
- unlinkSync,
9
- writeFileSync,
10
- } from "node:fs";
11
- import { dirname, join } from "node:path";
12
- import { ensureLabDirs, labCommunityDir } from "../paths";
1
+ import { Database } from "bun:sqlite";
2
+ import { lstatSync, readdirSync, rmSync, writeFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { sameFileIdentity, statTimeMs, type FileIdentity } from "../../lib/file-identity";
5
+ import { ensureLabDirs, labCommunityDir, labRoot } from "../paths";
13
6
  import { readPrivateRegularFile } from "./file-safety";
14
7
  import { PublicEvidenceValidationError } from "./validate";
15
8
 
16
- const PUBLIC_EVIDENCE_MUTATION_LOCK_NAME = ".mutation-lock";
17
- const PUBLIC_EVIDENCE_MUTATION_LOCK_OWNER = "owner.json";
18
- const PUBLIC_EVIDENCE_MUTATION_LOCK_RECLAIM = ".reclaim.json";
19
- const PUBLIC_EVIDENCE_MUTATION_LOCK_INCOMPLETE_STALE_MS = 24 * 60 * 60 * 1000;
20
- const PUBLIC_EVIDENCE_MUTATION_LOCK_ABSOLUTE_STALE_MS = 7 * 24 * 60 * 60 * 1000;
9
+ const PUBLIC_EVIDENCE_MUTATION_DB_NAME = "public-evidence-mutation.sqlite";
10
+ const LEGACY_MUTATION_LOCK_NAME = ".mutation-lock";
11
+ const LEGACY_MUTATION_LOCK_OWNER = "owner.json";
12
+ const LEGACY_MUTATION_LOCK_INCOMPLETE_STALE_MS = 24 * 60 * 60 * 1000;
13
+ const LEGACY_MUTATION_LOCK_ABSOLUTE_STALE_MS = 7 * 24 * 60 * 60 * 1000;
21
14
  const DETACHED_MUTATION_LOCK_RE = /^\.mutation-lock-(?:stale|release)-\d+-[0-9a-f-]{36}$/;
22
- const MUTATION_LOCK_META_FILE_OPTIONS = {
15
+ const LEGACY_OWNER_FILE_OPTIONS = {
23
16
  maxBytes: 1024,
24
17
  errorCode: "community_cache_lock",
25
18
  errorMessage: "community cache mutation lock metadata is unsafe",
@@ -28,33 +21,22 @@ const MUTATION_LOCK_META_FILE_OPTIONS = {
28
21
  requireMode600: true,
29
22
  } as const;
30
23
 
31
- type MutationLockOwner = {
24
+ type LegacyMutationLockOwner = {
32
25
  pid: number;
33
- token: string;
34
26
  createdAt: number;
35
27
  };
36
28
 
37
- type MutationLockReclaim = {
38
- pid: number;
39
- token: string;
40
- createdAt: number;
41
- };
42
-
43
- type MutationLockDirectoryIdentity = {
44
- dev: number;
45
- ino: number;
46
- };
47
-
48
- function mutationLockPath(configDir?: string): string {
49
- return join(labCommunityDir(configDir), PUBLIC_EVIDENCE_MUTATION_LOCK_NAME);
29
+ function mutationLockDatabasePath(configDir?: string): string {
30
+ return join(labRoot(configDir), PUBLIC_EVIDENCE_MUTATION_DB_NAME);
50
31
  }
51
32
 
52
- function mutationLockOwnerPath(lockPath: string): string {
53
- return join(lockPath, PUBLIC_EVIDENCE_MUTATION_LOCK_OWNER);
33
+ /** Lock bookkeeping entries an older build may leave in the community cache directory. */
34
+ export function isMutationLockEntryName(name: string): boolean {
35
+ return name === LEGACY_MUTATION_LOCK_NAME || DETACHED_MUTATION_LOCK_RE.test(name);
54
36
  }
55
37
 
56
- function mutationLockReclaimPath(lockPath: string): string {
57
- return join(lockPath, PUBLIC_EVIDENCE_MUTATION_LOCK_RECLAIM);
38
+ function legacyMutationLockPath(configDir?: string): string {
39
+ return join(labCommunityDir(configDir), LEGACY_MUTATION_LOCK_NAME);
58
40
  }
59
41
 
60
42
  function pidDefinitelyDead(pid: number): boolean {
@@ -66,47 +48,22 @@ function pidDefinitelyDead(pid: number): boolean {
66
48
  }
67
49
  }
68
50
 
69
- function exceedsAbsoluteLockAge(createdAt: number, nowMs: number): boolean {
70
- return nowMs - createdAt > PUBLIC_EVIDENCE_MUTATION_LOCK_ABSOLUTE_STALE_MS;
71
- }
72
-
73
- function readLockMetadata<T extends MutationLockOwner | MutationLockReclaim>(
74
- path: string,
75
- ): T | null {
51
+ function readLegacyMutationLockOwner(lockPath: string): LegacyMutationLockOwner | null {
76
52
  try {
77
- const bytes = readPrivateRegularFile(path, MUTATION_LOCK_META_FILE_OPTIONS);
78
- const raw = JSON.parse(bytes.toString("utf8")) as Partial<T>;
53
+ const bytes = readPrivateRegularFile(join(lockPath, LEGACY_MUTATION_LOCK_OWNER), LEGACY_OWNER_FILE_OPTIONS);
54
+ const raw = JSON.parse(bytes.toString("utf8")) as Partial<LegacyMutationLockOwner>;
79
55
  if (
80
- Number.isSafeInteger(raw.pid)
81
- && Number(raw.pid) > 0
82
- && typeof raw.token === "string"
83
- && /^[0-9a-f-]{36}$/.test(raw.token)
84
- && Number.isSafeInteger(raw.createdAt)
85
- && Number(raw.createdAt) > 0
86
- ) {
87
- return {
88
- pid: Number(raw.pid),
89
- token: raw.token,
90
- createdAt: Number(raw.createdAt),
91
- } as T;
92
- }
56
+ Number.isSafeInteger(raw.pid) && Number(raw.pid) > 0
57
+ && Number.isSafeInteger(raw.createdAt) && Number(raw.createdAt) > 0
58
+ ) return { pid: Number(raw.pid), createdAt: Number(raw.createdAt) };
93
59
  } catch {
94
- // Incomplete metadata is handled conservatively by the age fallback where
95
- // applicable. Normal acquisition never trusts malformed metadata.
60
+ // Missing or malformed metadata falls back to the directory-age rule below.
96
61
  }
97
62
  return null;
98
63
  }
99
64
 
100
- function readMutationLockOwner(lockPath: string): MutationLockOwner | null {
101
- return readLockMetadata<MutationLockOwner>(mutationLockOwnerPath(lockPath));
102
- }
103
-
104
- function readMutationLockReclaim(lockPath: string): MutationLockReclaim | null {
105
- return readLockMetadata<MutationLockReclaim>(mutationLockReclaimPath(lockPath));
106
- }
107
-
108
65
  function assertMutationLockDirectory(lockPath: string) {
109
- const stat = lstatSync(lockPath);
66
+ const stat = lstatSync(lockPath, { bigint: true });
110
67
  if (!stat.isDirectory() || stat.isSymbolicLink()) {
111
68
  throw new PublicEvidenceValidationError(
112
69
  "community_cache_lock",
@@ -116,309 +73,124 @@ function assertMutationLockDirectory(lockPath: string) {
116
73
  return stat;
117
74
  }
118
75
 
119
- function sameDirectoryIdentity(
120
- left: MutationLockDirectoryIdentity,
121
- right: MutationLockDirectoryIdentity,
122
- ): boolean {
123
- return left.dev === right.dev && left.ino === right.ino;
124
- }
125
-
126
- function currentDirectoryIdentity(lockPath: string): MutationLockDirectoryIdentity {
127
- const stat = assertMutationLockDirectory(lockPath);
128
- return { dev: stat.dev, ino: stat.ino };
129
- }
130
-
131
- function mutationLockIsReclaimable(lockPath: string, nowMs: number): boolean {
132
- const stat = assertMutationLockDirectory(lockPath);
133
- const owner = readMutationLockOwner(lockPath);
134
- if (owner) {
135
- // A live PID is strong evidence only while the recorded ownership generation is
136
- // reasonably recent. The absolute ceiling recovers from PID reuse after a crash.
137
- return pidDefinitelyDead(owner.pid) || exceedsAbsoluteLockAge(owner.createdAt, nowMs);
138
- }
139
- // The only ownerless state is the tiny mkdir-to-owner publication window. Use
140
- // a deliberately long fallback so a crashed acquisition can eventually heal
141
- // without treating an ordinary pause as proof that the owner disappeared.
142
- return nowMs - stat.mtimeMs > PUBLIC_EVIDENCE_MUTATION_LOCK_INCOMPLETE_STALE_MS;
143
- }
144
-
145
- function unlinkIfPresent(path: string): void {
76
+ /**
77
+ * Whether a directory lock left by an older OpenCodex build still has a holder.
78
+ *
79
+ * Older builds serialized through a `.mutation-lock` directory. This build never creates,
80
+ * renames or removes one; it only declines to run beside a holder that still looks alive, using
81
+ * the same evidence the older builds used: a live owner PID within the absolute age ceiling, or
82
+ * an ownerless directory recent enough to be an acquisition in progress.
83
+ */
84
+ function legacyMutationLockBlocks(lockPath: string, nowMs: number): boolean {
85
+ let stat: ReturnType<typeof assertMutationLockDirectory>;
146
86
  try {
147
- unlinkSync(path);
87
+ stat = assertMutationLockDirectory(lockPath);
148
88
  } catch (error) {
149
- if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
89
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
90
+ throw error;
91
+ }
92
+ const owner = readLegacyMutationLockOwner(lockPath);
93
+ if (owner) {
94
+ return !pidDefinitelyDead(owner.pid) && nowMs - owner.createdAt <= LEGACY_MUTATION_LOCK_ABSOLUTE_STALE_MS;
150
95
  }
96
+ return nowMs - statTimeMs(stat.mtimeNs) <= LEGACY_MUTATION_LOCK_INCOMPLETE_STALE_MS;
151
97
  }
152
98
 
153
- function cleanupDetachedMutationLocks(lockPath: string): void {
154
- const dir = dirname(lockPath);
99
+ function cleanupDetachedMutationLocks(configDir: string | undefined, nowMs: number): void {
100
+ const dir = labCommunityDir(configDir);
155
101
  for (const name of readdirSync(dir)) {
156
102
  if (!DETACHED_MUTATION_LOCK_RE.test(name)) continue;
157
- // Detached lock directories are no longer authoritative once a new canonical
158
- // lock has been acquired. Removing only their UUID-scoped names prevents them
159
- // from leaking storage or being mistaken for community cache objects.
160
- rmSync(join(dir, name), { recursive: true, force: true });
103
+ const detachedPath = join(dir, name);
104
+ // Older builds moved a released or reclaimed lock directory to one of these UUID-scoped
105
+ // names before deleting it. One that still records a live owner may belong to a running
106
+ // older-build holder, so it is left alone. Removing the rest keeps them from leaking
107
+ // storage or being mistaken for community cache objects.
108
+ const owner = readLegacyMutationLockOwner(detachedPath);
109
+ if (owner && !pidDefinitelyDead(owner.pid) && nowMs - owner.createdAt <= LEGACY_MUTATION_LOCK_ABSOLUTE_STALE_MS) continue;
110
+ rmSync(detachedPath, { recursive: true, force: true });
161
111
  }
162
112
  }
163
113
 
164
- function publishMutationLockOwner(
165
- lockPath: string,
166
- owner: MutationLockOwner,
167
- expectedDirectory: MutationLockDirectoryIdentity,
168
- ): void {
169
- // Write through a unique temporary pathname first. If an ancient ownerless
170
- // lock is reclaimed while this process was suspended, the inode check prevents
171
- // this acquisition from publishing its owner metadata into a replacement lock.
172
- const tempPath = join(lockPath, `.owner-${owner.token}.tmp`);
173
- try {
174
- writeFileSync(tempPath, JSON.stringify(owner), {
175
- encoding: "utf8",
176
- flag: "wx",
177
- mode: 0o600,
178
- });
179
- if (!sameDirectoryIdentity(currentDirectoryIdentity(lockPath), expectedDirectory)) {
180
- throw new PublicEvidenceValidationError(
181
- "community_cache_lock",
182
- "community cache mutation lock changed during owner publication",
183
- );
184
- }
185
- renameSync(tempPath, mutationLockOwnerPath(lockPath));
186
- if (!sameDirectoryIdentity(currentDirectoryIdentity(lockPath), expectedDirectory)) {
187
- throw new PublicEvidenceValidationError(
188
- "community_cache_lock",
189
- "community cache mutation lock changed after owner publication",
190
- );
191
- }
192
- const persisted = readMutationLockOwner(lockPath);
193
- if (!persisted || persisted.pid !== owner.pid || persisted.token !== owner.token) {
194
- throw new PublicEvidenceValidationError(
195
- "community_cache_lock",
196
- "community cache mutation lock owner publication was not durable",
197
- );
198
- }
199
- } finally {
200
- // The rename normally makes this ENOENT. If the lock pathname was replaced,
201
- // the UUID-scoped temporary name can be removed without touching successor state.
202
- unlinkIfPresent(tempPath);
114
+ /** The lock file's identity, after proving it is a single-link regular file. */
115
+ function mutationLockFileIdentity(path: string): FileIdentity {
116
+ const stat = lstatSync(path, { bigint: true });
117
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1n) {
118
+ throw new PublicEvidenceValidationError("community_cache_lock", "community cache mutation lock is unsafe");
203
119
  }
120
+ return { dev: stat.dev, ino: stat.ino };
204
121
  }
205
122
 
206
- function reclaimClaimIsRecoverable(lockPath: string, nowMs: number): boolean {
207
- const claimPath = mutationLockReclaimPath(lockPath);
208
- const claim = readMutationLockReclaim(lockPath);
209
- if (claim) {
210
- return pidDefinitelyDead(claim.pid) || exceedsAbsoluteLockAge(claim.createdAt, nowMs);
211
- }
123
+ /**
124
+ * Open the lock database on a file this module created as a private regular file.
125
+ *
126
+ * The Lab root is owner-only, so the processes that can replace this pathname are the user's own,
127
+ * the same trust boundary as the config mutation lock. Within it, the file is created exclusively
128
+ * with mode 0600 (never chmod-ed through the pathname), and the caller re-proves after locking
129
+ * that the pathname still names the file inspected before the open.
130
+ */
131
+ function openMutationLockDatabase(path: string): { database: Database; identity: FileIdentity } {
212
132
  try {
213
- const stat = lstatSync(claimPath);
214
- return nowMs - stat.mtimeMs > PUBLIC_EVIDENCE_MUTATION_LOCK_INCOMPLETE_STALE_MS;
133
+ writeFileSync(path, "", { flag: "wx", mode: 0o600 });
215
134
  } catch (error) {
216
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return true;
217
- throw error;
135
+ if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
218
136
  }
219
- }
220
-
221
- function recoverStaleReclaimClaim(lockPath: string, nowMs: number): boolean {
222
- if (!reclaimClaimIsRecoverable(lockPath, nowMs)) return false;
223
- const claimPath = mutationLockReclaimPath(lockPath);
224
- const quarantinePath = join(lockPath, `.reclaim-stale-${randomUUID()}.json`);
137
+ const identity = mutationLockFileIdentity(path);
225
138
  try {
226
- renameSync(claimPath, quarantinePath);
227
- } catch (error) {
228
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return true;
229
- throw error;
230
- }
231
- unlinkIfPresent(quarantinePath);
232
- return true;
233
- }
234
-
235
- function tryAcquireReclaimClaim(
236
- lockPath: string,
237
- nowMs: number,
238
- ): MutationLockReclaim | null {
239
- for (let attempt = 0; attempt < 2; attempt += 1) {
240
- const claim: MutationLockReclaim = {
241
- pid: process.pid,
242
- token: randomUUID(),
243
- createdAt: nowMs,
244
- };
245
- try {
246
- writeFileSync(mutationLockReclaimPath(lockPath), JSON.stringify(claim), {
247
- encoding: "utf8",
248
- flag: "wx",
249
- mode: 0o600,
250
- });
251
- return claim;
252
- } catch (error) {
253
- const code = (error as NodeJS.ErrnoException).code;
254
- if (code === "ENOENT") return null;
255
- if (code !== "EEXIST") throw error;
256
- if (!recoverStaleReclaimClaim(lockPath, nowMs)) return null;
257
- }
258
- }
259
- return null;
260
- }
261
-
262
- function reclaimClaimStillOwned(lockPath: string, claim: MutationLockReclaim): boolean {
263
- const current = readMutationLockReclaim(lockPath);
264
- return current?.pid === claim.pid && current.token === claim.token;
265
- }
266
-
267
- function releaseReclaimClaim(lockPath: string, claim: MutationLockReclaim): void {
268
- if (!reclaimClaimStillOwned(lockPath, claim)) return;
269
- unlinkIfPresent(mutationLockReclaimPath(lockPath));
270
- }
271
-
272
- function tryReclaimMutationLock(lockPath: string, nowMs: number): boolean {
273
- // Capture the exact stale directory before the claim write changes its mtime.
274
- // After claiming, revalidate the inode and owner instead of reusing an age check
275
- // that our own .reclaim.json creation would make appear fresh.
276
- if (!mutationLockIsReclaimable(lockPath, nowMs)) return false;
277
- const staleDirectory = currentDirectoryIdentity(lockPath);
278
- const claim = tryAcquireReclaimClaim(lockPath, nowMs);
279
- if (!claim) return false;
280
-
281
- let moved = false;
282
- try {
283
- if (!reclaimClaimStillOwned(lockPath, claim)) return false;
284
- if (!sameDirectoryIdentity(currentDirectoryIdentity(lockPath), staleDirectory)) return false;
285
- const currentOwner = readMutationLockOwner(lockPath);
286
- if (
287
- currentOwner
288
- && !pidDefinitelyDead(currentOwner.pid)
289
- && !exceedsAbsoluteLockAge(currentOwner.createdAt, nowMs)
290
- ) return false;
291
- if (!reclaimClaimStillOwned(lockPath, claim)) return false;
292
-
293
- const quarantinePath = join(
294
- dirname(lockPath),
295
- `.mutation-lock-stale-${process.pid}-${randomUUID()}`,
296
- );
297
- try {
298
- // Rename the exact claimed directory away from the canonical pathname before
299
- // deleting it. A successor can create a new lock immediately afterwards, but
300
- // cleanup is confined to this unique quarantine path and cannot delete it.
301
- renameSync(lockPath, quarantinePath);
302
- moved = true;
303
- } catch (error) {
304
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return true;
305
- throw error;
306
- }
307
- rmSync(quarantinePath, { recursive: true, force: true });
308
- return true;
309
- } finally {
310
- if (!moved) releaseReclaimClaim(lockPath, claim);
311
- }
312
- }
313
-
314
- function discardUncommittedMutationLock(
315
- lockPath: string,
316
- expectedDirectory: MutationLockDirectoryIdentity,
317
- ): void {
318
- try {
319
- if (!sameDirectoryIdentity(currentDirectoryIdentity(lockPath), expectedDirectory)) return;
320
- const quarantinePath = join(
321
- dirname(lockPath),
322
- `.mutation-lock-release-${process.pid}-${randomUUID()}`,
323
- );
324
- renameSync(lockPath, quarantinePath);
325
- rmSync(quarantinePath, { recursive: true, force: true });
139
+ return { database: new Database(path, { create: false, readwrite: true }), identity };
326
140
  } catch {
327
- // Preserve the owner-publication error. An unrecoverable cleanup witness stays
328
- // ownerless and can be reclaimed by the long incomplete-acquisition fallback.
141
+ // The SQLite error text can name local paths; the stable code is what callers act on.
142
+ throw new PublicEvidenceValidationError("community_cache_lock", "community cache mutation lock is unavailable");
329
143
  }
330
144
  }
331
145
 
332
- function releaseMutationLock(
333
- lockPath: string,
334
- owner: MutationLockOwner,
335
- expectedDirectory: MutationLockDirectoryIdentity,
336
- ): void {
337
- let currentDirectory: MutationLockDirectoryIdentity;
338
- try {
339
- currentDirectory = currentDirectoryIdentity(lockPath);
340
- } catch (error) {
341
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return;
342
- throw error;
343
- }
344
- if (!sameDirectoryIdentity(currentDirectory, expectedDirectory)) return;
345
- const current = readMutationLockOwner(lockPath);
346
- if (!current || current.pid !== owner.pid || current.token !== owner.token) return;
347
-
348
- const quarantinePath = join(
349
- dirname(lockPath),
350
- `.mutation-lock-release-${process.pid}-${randomUUID()}`,
351
- );
352
- try {
353
- renameSync(lockPath, quarantinePath);
354
- } catch (error) {
355
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return;
356
- throw error;
357
- }
358
- rmSync(quarantinePath, { recursive: true, force: true });
359
- }
360
-
361
- /** Serialize public-evidence mutations across CLI/server processes with ownership-safe stale recovery. */
146
+ /**
147
+ * Serialize public-evidence mutations across CLI/server processes.
148
+ *
149
+ * The lock is an OS-held SQLite write transaction on a dedicated database, with
150
+ * `busy_timeout=0` so a second holder fails fast as `community_cache_busy`. Closing the handle,
151
+ * including at process exit or crash, releases it, so there is no stale-owner recovery and no
152
+ * step that renames or deletes another process's lock state. Never return a Promise from `run`.
153
+ */
362
154
  export function withPublicEvidenceMutationLock<T>(
363
155
  configDir: string | undefined,
364
156
  run: () => T,
365
157
  ): T {
366
158
  ensureLabDirs(configDir);
367
- const lockPath = mutationLockPath(configDir);
368
- let owner: MutationLockOwner | null = null;
369
- let ownedDirectory: MutationLockDirectoryIdentity | null = null;
370
-
371
- while (true) {
159
+ const path = mutationLockDatabasePath(configDir);
160
+ const { database, identity } = openMutationLockDatabase(path);
161
+ let transactionOpen = false;
162
+ try {
372
163
  try {
373
- mkdirSync(lockPath, { mode: 0o700 });
374
- } catch (error) {
375
- if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
376
- try {
377
- if (tryReclaimMutationLock(lockPath, Date.now())) continue;
378
- } catch (reclaimError) {
379
- if ((reclaimError as NodeJS.ErrnoException).code === "ENOENT") continue;
380
- throw reclaimError;
164
+ database.exec("PRAGMA busy_timeout = 0; BEGIN IMMEDIATE");
165
+ transactionOpen = true;
166
+ } catch (cause) {
167
+ const code = cause && typeof cause === "object" && "code" in cause ? String((cause as { code?: unknown }).code) : "";
168
+ if (code.startsWith("SQLITE_BUSY") || code.startsWith("SQLITE_LOCKED")) {
169
+ throw new PublicEvidenceValidationError("community_cache_busy", "community cache is busy");
381
170
  }
382
- throw new PublicEvidenceValidationError("community_cache_busy", "community cache is busy");
171
+ throw new PublicEvidenceValidationError("community_cache_lock", "community cache mutation lock is unavailable");
383
172
  }
384
-
385
- const directory = currentDirectoryIdentity(lockPath);
386
- const candidate: MutationLockOwner = {
387
- pid: process.pid,
388
- token: randomUUID(),
389
- createdAt: Date.now(),
390
- };
391
- try {
392
- publishMutationLockOwner(lockPath, candidate, directory);
393
- } catch (error) {
394
- discardUncommittedMutationLock(lockPath, directory);
395
- throw error;
173
+ if (!sameFileIdentity(mutationLockFileIdentity(path), identity)) {
174
+ throw new PublicEvidenceValidationError("community_cache_lock", "community cache mutation lock changed while opening");
396
175
  }
397
- owner = candidate;
398
- ownedDirectory = directory;
399
- break;
400
- }
401
-
402
- try {
403
- cleanupDetachedMutationLocks(lockPath);
176
+ const nowMs = Date.now();
177
+ if (legacyMutationLockBlocks(legacyMutationLockPath(configDir), nowMs)) {
178
+ throw new PublicEvidenceValidationError("community_cache_busy", "community cache is busy");
179
+ }
180
+ cleanupDetachedMutationLocks(configDir, nowMs);
404
181
  return run();
405
182
  } finally {
406
- if (owner && ownedDirectory) releaseMutationLock(lockPath, owner, ownedDirectory);
183
+ if (transactionOpen) {
184
+ try { database.exec("ROLLBACK"); } catch { /* closing the handle below still releases the OS lock */ }
185
+ }
186
+ try { database.close(); } catch { /* the OS lock is released with the handle */ }
407
187
  }
408
188
  }
409
189
 
410
- /** Test-only seam for stale-owner policy. This module is not barrel-exported. */
411
- export function publicEvidenceMutationLockIsReclaimableForTests(
412
- configDir: string | undefined,
413
- nowMs = Date.now(),
414
- ): boolean {
415
- return mutationLockIsReclaimable(mutationLockPath(configDir), nowMs);
416
- }
417
-
418
- /** Test-only seam for the exclusive stale-reclaimer claim. */
419
- export function publicEvidenceTryReclaimMutationLockForTests(
190
+ /** Test-only seam for the older-build lock policy. This module is not barrel-exported. */
191
+ export function publicEvidenceLegacyMutationLockBlocksForTests(
420
192
  configDir: string | undefined,
421
193
  nowMs = Date.now(),
422
194
  ): boolean {
423
- return tryReclaimMutationLock(mutationLockPath(configDir), nowMs);
195
+ return legacyMutationLockBlocks(legacyMutationLockPath(configDir), nowMs);
424
196
  }
@@ -12,6 +12,7 @@ import {
12
12
  } from "node:fs";
13
13
  import type { Stats } from "node:fs";
14
14
  import { basename, dirname, join } from "node:path";
15
+ import { sameFileIdentity } from "../../lib/file-identity";
15
16
 
16
17
  export type PrivateFileCommitFault = "before_publish" | "parent_directory_sync" | null;
17
18
  let privateFileCommitFaultForTests: PrivateFileCommitFault = null;
@@ -152,7 +153,7 @@ export function cleanupStalePrivateFileStages(finalPath: string): void {
152
153
  function cleanupPublishedPrivateFileStages(finalPath: string): void {
153
154
  let finalStats;
154
155
  try {
155
- finalStats = lstatSync(finalPath);
156
+ finalStats = lstatSync(finalPath, { bigint: true });
156
157
  } catch (error) {
157
158
  if ((error as NodeJS.ErrnoException).code === "ENOENT") return;
158
159
  throw error;
@@ -166,9 +167,9 @@ function cleanupPublishedPrivateFileStages(finalPath: string): void {
166
167
  if (!name.startsWith(prefix) || !PRIVATE_STAGE_RE.test(name)) continue;
167
168
  const stagePath = join(dir, name);
168
169
  try {
169
- const stageStats = lstatSync(stagePath);
170
+ const stageStats = lstatSync(stagePath, { bigint: true });
170
171
  if (!stageStats.isFile() || stageStats.isSymbolicLink()) continue;
171
- if (stageStats.dev !== finalStats.dev || stageStats.ino !== finalStats.ino) continue;
172
+ if (!sameFileIdentity(stageStats, finalStats)) continue;
172
173
  unlinkSync(stagePath);
173
174
  changed = true;
174
175
  } catch (error) {
@@ -9,7 +9,7 @@ export const RUNTIME_PREFLIGHT_TIMEOUT_MS = 5_000;
9
9
  export const RUNTIME_PREFLIGHT_GUIDANCE = "The selected Bun runtime could not create and remove a directory in the OpenCodex config directory. "
10
10
  + "Windows application policy may deny writes from this executable location. "
11
11
  + "Set OPENCODEX_BUN_PATH to a trusted Bun executable allowed by your policy before launching ocx, "
12
- + "or reinstall opencodex with npm install -g @bitkyc08/opencodex, then retry. No alternate runtime was selected.";
12
+ + "or reinstall opencodex with npm install -g --allow-scripts=bun @bitkyc08/opencodex, then retry. No alternate runtime was selected.";
13
13
 
14
14
  export class RuntimePreflightError extends Error {
15
15
  readonly code = "OCX_RUNTIME_PREFLIGHT_FAILED";