@openai/codex-security 0.1.31 → 0.2.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 (314) hide show
  1. package/README.md +295 -32
  2. package/_bundled_plugin/.mcp.json +1 -0
  3. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
  5. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  6. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  14. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  15. package/_bundled_plugin/references/artifact-storage.md +4 -4
  16. package/_bundled_plugin/references/config-preflight.md +1 -1
  17. package/_bundled_plugin/references/core-scan.md +14 -2
  18. package/_bundled_plugin/references/final-report.md +4 -2
  19. package/_bundled_plugin/references/scan-artifacts.md +2 -2
  20. package/_bundled_plugin/references/scan-contract.md +2 -2
  21. package/_bundled_plugin/references/threat-model.md +2 -2
  22. package/_bundled_plugin/schemas/coverage.schema.json +22 -0
  23. package/_bundled_plugin/schemas/scan-manifest.schema.json +100 -85
  24. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +116 -102
  25. package/_bundled_plugin/scripts/config_preflight.py +4 -8
  26. package/_bundled_plugin/scripts/deep_scan_workbench.py +83 -217
  27. package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
  28. package/_bundled_plugin/scripts/finalize_scan_contract.py +441 -166
  29. package/_bundled_plugin/scripts/finding_preview.py +42 -82
  30. package/_bundled_plugin/scripts/generate_in_scope_files.py +30 -34
  31. package/_bundled_plugin/scripts/generate_rank_input.py +58 -99
  32. package/_bundled_plugin/scripts/launch_codex_security_mcp +5 -1
  33. package/_bundled_plugin/scripts/rank_preview.py +85 -68
  34. package/_bundled_plugin/scripts/report_projection.py +37 -58
  35. package/_bundled_plugin/scripts/threat_model_projection.py +164 -0
  36. package/_bundled_plugin/scripts/windows_scan_local_files.py +11 -6
  37. package/_bundled_plugin/scripts/workbench/storage.py +11 -0
  38. package/_bundled_plugin/scripts/workbench_cli.py +11 -17
  39. package/_bundled_plugin/scripts/workbench_constants.py +6 -14
  40. package/_bundled_plugin/scripts/workbench_db.py +116 -228
  41. package/_bundled_plugin/scripts/workbench_finding_index.py +1 -6
  42. package/_bundled_plugin/scripts/workbench_native_indexes.py +1 -4
  43. package/_bundled_plugin/scripts/workbench_progress.py +12 -34
  44. package/_bundled_plugin/scripts/workbench_publication.py +47 -62
  45. package/_bundled_plugin/scripts/workbench_remediation.py +2 -20
  46. package/_bundled_plugin/scripts/workbench_saved_results.py +1246 -230
  47. package/_bundled_plugin/scripts/workbench_scan_start.py +4 -11
  48. package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -15
  49. package/_bundled_plugin/scripts/workbench_schema.py +86 -271
  50. package/_bundled_plugin/scripts/workbench_severity.py +3 -0
  51. package/_bundled_plugin/scripts/workbench_source_excerpt.py +5 -6
  52. package/_bundled_plugin/scripts/workbench_target.py +98 -10
  53. package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
  54. package/_bundled_plugin/scripts/workbench_validation.py +6 -20
  55. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +3 -3
  56. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +3 -3
  57. package/_bundled_plugin/skills/security-scan/SKILL.md +2 -2
  58. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
  59. package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
  60. package/dist/api.d.ts +3 -5
  61. package/dist/api.d.ts.map +1 -1
  62. package/dist/api.js +201 -207
  63. package/dist/api.js.map +1 -1
  64. package/dist/artifact-export.d.ts +70 -0
  65. package/dist/artifact-export.d.ts.map +1 -0
  66. package/dist/artifact-export.js +277 -0
  67. package/dist/artifact-export.js.map +1 -0
  68. package/dist/auth.d.ts.map +1 -1
  69. package/dist/auth.js +8 -3
  70. package/dist/auth.js.map +1 -1
  71. package/dist/bulk-scan-discovery.d.ts +1 -0
  72. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  73. package/dist/bulk-scan-discovery.js +8 -9
  74. package/dist/bulk-scan-discovery.js.map +1 -1
  75. package/dist/classify-scan-severity.d.ts.map +1 -1
  76. package/dist/classify-scan-severity.js +2 -5
  77. package/dist/classify-scan-severity.js.map +1 -1
  78. package/dist/classify-severity.d.ts +2 -8
  79. package/dist/classify-severity.d.ts.map +1 -1
  80. package/dist/classify-severity.js +3 -5
  81. package/dist/classify-severity.js.map +1 -1
  82. package/dist/cli-help.d.ts +3 -0
  83. package/dist/cli-help.d.ts.map +1 -0
  84. package/dist/cli-help.js +281 -0
  85. package/dist/cli-help.js.map +1 -0
  86. package/dist/cli.d.ts +19 -22
  87. package/dist/cli.d.ts.map +1 -1
  88. package/dist/cli.js +631 -714
  89. package/dist/cli.js.map +1 -1
  90. package/dist/cloud-publish.d.ts.map +1 -1
  91. package/dist/cloud-publish.js +1 -8
  92. package/dist/cloud-publish.js.map +1 -1
  93. package/dist/codex-prompt.d.ts.map +1 -1
  94. package/dist/codex-prompt.js +1 -2
  95. package/dist/codex-prompt.js.map +1 -1
  96. package/dist/codex-sdk-environment.d.ts +2 -0
  97. package/dist/codex-sdk-environment.d.ts.map +1 -0
  98. package/dist/codex-sdk-environment.js +30 -0
  99. package/dist/codex-sdk-environment.js.map +1 -0
  100. package/dist/component-plan.d.ts.map +1 -1
  101. package/dist/component-plan.js +2 -6
  102. package/dist/component-plan.js.map +1 -1
  103. package/dist/component-scan.d.ts +1 -0
  104. package/dist/component-scan.d.ts.map +1 -1
  105. package/dist/component-scan.js +31 -9
  106. package/dist/component-scan.js.map +1 -1
  107. package/dist/config.d.ts.map +1 -1
  108. package/dist/config.js +32 -33
  109. package/dist/config.js.map +1 -1
  110. package/dist/contract.d.ts +2 -1
  111. package/dist/contract.d.ts.map +1 -1
  112. package/dist/contract.js +63 -122
  113. package/dist/contract.js.map +1 -1
  114. package/dist/cost-model.d.ts.map +1 -1
  115. package/dist/cost-model.js +65 -34
  116. package/dist/cost-model.js.map +1 -1
  117. package/dist/cost.d.ts.map +1 -1
  118. package/dist/cost.js +15 -31
  119. package/dist/cost.js.map +1 -1
  120. package/dist/custom-validation-prompt.js +4 -4
  121. package/dist/custom-validation-prompt.js.map +1 -1
  122. package/dist/custom-validation.d.ts.map +1 -1
  123. package/dist/custom-validation.js +17 -16
  124. package/dist/custom-validation.js.map +1 -1
  125. package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
  126. package/dist/deduplication/checkpointed-review.js +10 -11
  127. package/dist/deduplication/checkpointed-review.js.map +1 -1
  128. package/dist/deduplication/codex-review.d.ts +2 -0
  129. package/dist/deduplication/codex-review.d.ts.map +1 -1
  130. package/dist/deduplication/codex-review.js +3 -3
  131. package/dist/deduplication/codex-review.js.map +1 -1
  132. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  133. package/dist/deduplication/deduplication-reviewer.js +2 -0
  134. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  135. package/dist/deduplication/deduplication.js +40 -62
  136. package/dist/deduplication/deduplication.js.map +1 -1
  137. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  138. package/dist/deduplication/records-protocol.js +1 -4
  139. package/dist/deduplication/records-protocol.js.map +1 -1
  140. package/dist/deduplication/records.d.ts +2 -1
  141. package/dist/deduplication/records.d.ts.map +1 -1
  142. package/dist/deduplication/records.js +24 -6
  143. package/dist/deduplication/records.js.map +1 -1
  144. package/dist/deduplication/review.d.ts +7 -0
  145. package/dist/deduplication/review.d.ts.map +1 -1
  146. package/dist/deduplication/review.js.map +1 -1
  147. package/dist/deduplication/scan.js +3 -7
  148. package/dist/deduplication/scan.js.map +1 -1
  149. package/dist/deep-config.d.ts.map +1 -1
  150. package/dist/deep-config.js +3 -19
  151. package/dist/deep-config.js.map +1 -1
  152. package/dist/deep-progress.d.ts +0 -1
  153. package/dist/deep-progress.d.ts.map +1 -1
  154. package/dist/deep-progress.js +22 -40
  155. package/dist/deep-progress.js.map +1 -1
  156. package/dist/errors.d.ts +3 -2
  157. package/dist/errors.d.ts.map +1 -1
  158. package/dist/errors.js +5 -7
  159. package/dist/errors.js.map +1 -1
  160. package/dist/finding-catalogue.d.ts.map +1 -1
  161. package/dist/finding-catalogue.js +22 -22
  162. package/dist/finding-catalogue.js.map +1 -1
  163. package/dist/finding-workflow.d.ts.map +1 -1
  164. package/dist/finding-workflow.js +4 -7
  165. package/dist/finding-workflow.js.map +1 -1
  166. package/dist/findings-import.d.ts.map +1 -1
  167. package/dist/findings-import.js +7 -17
  168. package/dist/findings-import.js.map +1 -1
  169. package/dist/github.d.ts.map +1 -1
  170. package/dist/github.js +2 -3
  171. package/dist/github.js.map +1 -1
  172. package/dist/import-scan.js +2 -2
  173. package/dist/import-scan.js.map +1 -1
  174. package/dist/index.d.ts +4 -2
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +2 -1
  177. package/dist/index.js.map +1 -1
  178. package/dist/knowledge-base.js +2 -2
  179. package/dist/knowledge-base.js.map +1 -1
  180. package/dist/linear.d.ts.map +1 -1
  181. package/dist/linear.js +2 -3
  182. package/dist/linear.js.map +1 -1
  183. package/dist/models.d.ts +24 -0
  184. package/dist/models.d.ts.map +1 -1
  185. package/dist/models.js.map +1 -1
  186. package/dist/multiscan.d.ts.map +1 -1
  187. package/dist/multiscan.js +36 -31
  188. package/dist/multiscan.js.map +1 -1
  189. package/dist/owner-evidence.d.ts.map +1 -1
  190. package/dist/owner-evidence.js +2 -6
  191. package/dist/owner-evidence.js.map +1 -1
  192. package/dist/patch-tui.d.ts.map +1 -1
  193. package/dist/patch-tui.js +2 -4
  194. package/dist/patch-tui.js.map +1 -1
  195. package/dist/project-config-schema.d.ts +10 -0
  196. package/dist/project-config-schema.d.ts.map +1 -1
  197. package/dist/project-config-schema.js +1 -0
  198. package/dist/project-config-schema.js.map +1 -1
  199. package/dist/project-config.d.ts +1 -0
  200. package/dist/project-config.d.ts.map +1 -1
  201. package/dist/project-config.js +2 -0
  202. package/dist/project-config.js.map +1 -1
  203. package/dist/prompt-files.d.ts +0 -1
  204. package/dist/prompt-files.d.ts.map +1 -1
  205. package/dist/prompt-files.js +2 -4
  206. package/dist/prompt-files.js.map +1 -1
  207. package/dist/publication-events.d.ts.map +1 -1
  208. package/dist/publication-events.js +15 -29
  209. package/dist/publication-events.js.map +1 -1
  210. package/dist/publication-store.d.ts.map +1 -1
  211. package/dist/publication-store.js +9 -13
  212. package/dist/publication-store.js.map +1 -1
  213. package/dist/publication.d.ts.map +1 -1
  214. package/dist/publication.js +11 -14
  215. package/dist/publication.js.map +1 -1
  216. package/dist/publish.d.ts.map +1 -1
  217. package/dist/publish.js +31 -41
  218. package/dist/publish.js.map +1 -1
  219. package/dist/record.d.ts +2 -0
  220. package/dist/record.d.ts.map +1 -0
  221. package/dist/record.js +4 -0
  222. package/dist/record.js.map +1 -0
  223. package/dist/result.d.ts +4 -1
  224. package/dist/result.d.ts.map +1 -1
  225. package/dist/result.js +7 -0
  226. package/dist/result.js.map +1 -1
  227. package/dist/runtime.d.ts +10 -13
  228. package/dist/runtime.d.ts.map +1 -1
  229. package/dist/runtime.js +203 -131
  230. package/dist/runtime.js.map +1 -1
  231. package/dist/saved-scan.d.ts.map +1 -1
  232. package/dist/saved-scan.js +10 -20
  233. package/dist/saved-scan.js.map +1 -1
  234. package/dist/scan-activity.d.ts.map +1 -1
  235. package/dist/scan-activity.js +8 -22
  236. package/dist/scan-activity.js.map +1 -1
  237. package/dist/scan-comparison.d.ts +3 -3
  238. package/dist/scan-comparison.d.ts.map +1 -1
  239. package/dist/scan-comparison.js +38 -73
  240. package/dist/scan-comparison.js.map +1 -1
  241. package/dist/scan-dashboard.d.ts +0 -1
  242. package/dist/scan-dashboard.d.ts.map +1 -1
  243. package/dist/scan-dashboard.js +10 -19
  244. package/dist/scan-dashboard.js.map +1 -1
  245. package/dist/scan-history-renderer.d.ts.map +1 -1
  246. package/dist/scan-history-renderer.js +1 -2
  247. package/dist/scan-history-renderer.js.map +1 -1
  248. package/dist/scan-logs.d.ts.map +1 -1
  249. package/dist/scan-logs.js +2 -6
  250. package/dist/scan-logs.js.map +1 -1
  251. package/dist/scan-sessions.d.ts.map +1 -1
  252. package/dist/scan-sessions.js +1 -3
  253. package/dist/scan-sessions.js.map +1 -1
  254. package/dist/scan-settings.d.ts +5 -0
  255. package/dist/scan-settings.d.ts.map +1 -1
  256. package/dist/scan-settings.js +4 -0
  257. package/dist/scan-settings.js.map +1 -1
  258. package/dist/security-policy-cli.d.ts.map +1 -1
  259. package/dist/security-policy-cli.js +8 -6
  260. package/dist/security-policy-cli.js.map +1 -1
  261. package/dist/security-policy.d.ts +8 -4
  262. package/dist/security-policy.d.ts.map +1 -1
  263. package/dist/security-policy.js +98 -84
  264. package/dist/security-policy.js.map +1 -1
  265. package/dist/server/dashboard/app.js +5 -5
  266. package/dist/server/embeddings.d.ts.map +1 -1
  267. package/dist/server/embeddings.js +1 -0
  268. package/dist/server/embeddings.js.map +1 -1
  269. package/dist/server/routes.d.ts +3 -2
  270. package/dist/server/routes.d.ts.map +1 -1
  271. package/dist/server/routes.js +19 -7
  272. package/dist/server/routes.js.map +1 -1
  273. package/dist/server/server.d.ts.map +1 -1
  274. package/dist/server/server.js +2 -3
  275. package/dist/server/server.js.map +1 -1
  276. package/dist/server/sqlite-store.d.ts.map +1 -1
  277. package/dist/server/sqlite-store.js +4 -14
  278. package/dist/server/sqlite-store.js.map +1 -1
  279. package/dist/severity-store.js +8 -15
  280. package/dist/severity-store.js.map +1 -1
  281. package/dist/suggest-owners.d.ts +2 -3
  282. package/dist/suggest-owners.d.ts.map +1 -1
  283. package/dist/suggest-owners.js +4 -5
  284. package/dist/suggest-owners.js.map +1 -1
  285. package/dist/targets.d.ts +1 -0
  286. package/dist/targets.d.ts.map +1 -1
  287. package/dist/targets.js +24 -21
  288. package/dist/targets.js.map +1 -1
  289. package/dist/trusted-executable.d.ts +5 -0
  290. package/dist/trusted-executable.d.ts.map +1 -1
  291. package/dist/trusted-executable.js +22 -5
  292. package/dist/trusted-executable.js.map +1 -1
  293. package/dist/value.d.ts +2 -0
  294. package/dist/value.d.ts.map +1 -0
  295. package/dist/value.js +20 -0
  296. package/dist/value.js.map +1 -0
  297. package/dist/version.d.ts.map +1 -1
  298. package/dist/version.js +3 -6
  299. package/dist/version.js.map +1 -1
  300. package/dist/windows-path.d.ts.map +1 -1
  301. package/dist/windows-path.js +1 -2
  302. package/dist/windows-path.js.map +1 -1
  303. package/dist/worker-progress.d.ts +1 -0
  304. package/dist/worker-progress.d.ts.map +1 -1
  305. package/dist/worker-progress.js +13 -34
  306. package/dist/worker-progress.js.map +1 -1
  307. package/docs/dedupe-records.md +24 -0
  308. package/package.json +11 -10
  309. package/schemas/project-config.schema.json +5 -0
  310. package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
  311. package/dist/server/findings-service.d.ts +0 -20
  312. package/dist/server/findings-service.d.ts.map +0 -1
  313. package/dist/server/findings-service.js +0 -31
  314. package/dist/server/findings-service.js.map +0 -1
package/dist/runtime.js CHANGED
@@ -1,11 +1,11 @@
1
+ import { isNonEmptyString } from "./value.js";
1
2
  import { execFile as execFileCallback, spawn } from "node:child_process";
2
3
  import { randomUUID } from "node:crypto";
3
4
  import { chmodSync, constants, createWriteStream, existsSync, readdirSync, } from "node:fs";
4
5
  import { chmod, cp, copyFile, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, rmdir, stat, utimes, writeFile, } from "node:fs/promises";
5
6
  import { homedir, tmpdir } from "node:os";
6
7
  import { createRequire } from "node:module";
7
- import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep, win32, } from "node:path";
8
- import { createInterface } from "node:readline";
8
+ import { basename, dirname, extname, join, relative, resolve, win32, } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { promisify } from "node:util";
11
11
  import { pipeline } from "node:stream/promises";
@@ -13,8 +13,9 @@ import { crc32 } from "node:zlib";
13
13
  import { setTimeout as delay } from "node:timers/promises";
14
14
  import { openPromise as openZip } from "yauzl";
15
15
  import { parse } from "smol-toml";
16
- import { CodexSecurityError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, errorMessage, } from "./errors.js";
17
- import { resolveTrustedExecutable } from "./trusted-executable.js";
16
+ import { CodexSecurityError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, SandboxUnavailableError, errorMessage, abortReason, } from "./errors.js";
17
+ import { isRecord } from "./record.js";
18
+ import { isWithin, resolveTrustedExecutable, } from "./trusted-executable.js";
18
19
  import { isWindowsUnsafePathComponent, windowsUnsafePathComponent, } from "./windows-path.js";
19
20
  const execFile = promisify(execFileCallback);
20
21
  export const MARKETPLACE_NAME = "codex-security-sdk";
@@ -32,6 +33,7 @@ const CREDENTIAL_LOCK_POLL_MILLISECONDS = 25;
32
33
  const INCOMPLETE_CREDENTIAL_LOCK_MILLISECONDS = 30_000;
33
34
  const MAX_PROCESS_ID = 2_147_483_647;
34
35
  const MAX_WINDOWS_CREDENTIAL_ACL_STDERR = 64 * 1024;
36
+ const SANDBOX_PROBE_TIMEOUT_MILLISECONDS = 10_000;
35
37
  const PLUGIN_HELPER_SECRET_ENVIRONMENT_VARIABLES = new Set([
36
38
  "OPENAI_API_KEY",
37
39
  "CODEX_API_KEY",
@@ -98,9 +100,7 @@ export async function prepareCodexSecurityCredentialHome(environment = process.e
98
100
  }
99
101
  catch (error) {
100
102
  if (nodeErrorCode(error) === "EEXIST") {
101
- const existing = await lstat(path).catch(() => null);
102
- if (existing !== null &&
103
- (!existing.isDirectory() || existing.isSymbolicLink())) {
103
+ if ((await lstat(path).catch(() => null))?.isDirectory() === false) {
104
104
  throw new OutputDirectoryError(`Codex Security credential home is not a directory: ${path}`, { cause: error });
105
105
  }
106
106
  }
@@ -109,7 +109,7 @@ export async function prepareCodexSecurityCredentialHome(environment = process.e
109
109
  if ((process.umask() & 0o700) !== 0)
110
110
  await chmod(path, 0o700);
111
111
  const metadata = await lstat(path, { bigint: true });
112
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
112
+ if (!metadata.isDirectory()) {
113
113
  throw new OutputDirectoryError(`Codex Security credential home is not a directory: ${path}`);
114
114
  }
115
115
  const canonical = await realpath(path);
@@ -156,7 +156,7 @@ export async function requireSecureCredentialHome(path, options = {}) {
156
156
  throw new OutputDirectoryError(`Codex Security credential home was replaced: ${canonical}`);
157
157
  }
158
158
  metadata = canonicalMetadata;
159
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
159
+ if (!metadata.isDirectory()) {
160
160
  throw new OutputDirectoryError(`Codex Security credential home is not a directory: ${path}`);
161
161
  }
162
162
  if (options.expectedDevice !== undefined &&
@@ -201,9 +201,7 @@ function windowsCredentialAclFailure(error) {
201
201
  : undefined;
202
202
  const detail = typeof stderr === "string" && stderr.trim() !== ""
203
203
  ? stderr
204
- : error instanceof Error
205
- ? error.message
206
- : String(error);
204
+ : errorMessage(error);
207
205
  const normalized = errorMessage(detail)
208
206
  .replace(/\s+/gu, " ")
209
207
  .trim()
@@ -478,20 +476,25 @@ export async function streamWindowsCredentialAclDescriptors(command, args, inspe
478
476
  reject(Object.assign(new Error(`Windows credential ACL inspection failed with ${reason}`), { code, signal, stderr }));
479
477
  });
480
478
  });
481
- let descriptors = 0;
482
479
  try {
483
480
  await Promise.all([
484
481
  completion,
485
482
  (async () => {
486
- const lines = createInterface({
487
- input: child.stdout,
488
- crlfDelay: Infinity,
489
- });
490
- for await (const descriptor of lines) {
491
- if (descriptor === "")
492
- continue;
493
- await inspectDescriptor(descriptor);
494
- descriptors += 1;
483
+ // Consume chunks directly: readline can resume its queued-line
484
+ // iterator after EOF and throw instead of draining the last lines.
485
+ child.stdout.setEncoding("utf8");
486
+ let pending = "";
487
+ for await (const chunk of child.stdout) {
488
+ const lines = (pending + chunk).split(/[\r\n]/u);
489
+ pending = lines.pop();
490
+ for (const descriptor of lines) {
491
+ if (descriptor === "")
492
+ continue;
493
+ await inspectDescriptor(descriptor);
494
+ }
495
+ }
496
+ if (pending !== "") {
497
+ await inspectDescriptor(pending);
495
498
  }
496
499
  })(),
497
500
  ]);
@@ -505,7 +508,6 @@ export async function streamWindowsCredentialAclDescriptors(command, args, inspe
505
508
  // Finish descriptor callbacks before allowing another snapshot attempt.
506
509
  throw new WindowsCredentialDescendantsChangedError("Windows credential descendants changed during ACL inspection");
507
510
  }
508
- return descriptors;
509
511
  }
510
512
  export async function inspectWindowsCredentialAclSnapshot(path, currentUserSid, options) {
511
513
  let ancestors = 0;
@@ -784,11 +786,7 @@ export async function acquireCodexSecurityCredentialHomeLock(codexHome, signal,
784
786
  const ownerPath = join(lock, "owner.json");
785
787
  const token = randomUUID();
786
788
  const databasePath = join(codexHome, CREDENTIAL_LOCK_DATABASE);
787
- const existingDatabaseMetadata = await lstat(databasePath).catch((error) => {
788
- if (nodeErrorCode(error) === "ENOENT")
789
- return null;
790
- throw error;
791
- });
789
+ const existingDatabaseMetadata = await lstat(databasePath).catch(nullIfMissingFileError);
792
790
  if (existingDatabaseMetadata !== null) {
793
791
  requireCredentialLockDatabaseFile(existingDatabaseMetadata, databasePath);
794
792
  }
@@ -847,12 +845,7 @@ export async function acquireCodexSecurityCredentialHomeLock(codexHome, signal,
847
845
  }
848
846
  databaseLocked = true;
849
847
  }
850
- const existingLock = await lstat(lock).catch((error) => {
851
- if (nodeErrorCode(error) === "ENOENT")
852
- return null;
853
- throw error;
854
- });
855
- if (existingLock !== null) {
848
+ if ((await lstat(lock).catch(nullIfMissingFileError)) !== null) {
856
849
  if (await recoverStaleCredentialHomeLock(lock))
857
850
  continue;
858
851
  await delay(CREDENTIAL_LOCK_POLL_MILLISECONDS, undefined, { signal });
@@ -925,14 +918,10 @@ function requireCredentialLockDatabaseFile(metadata, path) {
925
918
  }
926
919
  }
927
920
  async function recoverStaleCredentialHomeLock(lock) {
928
- const metadata = await lstat(lock).catch((error) => {
929
- if (nodeErrorCode(error) === "ENOENT")
930
- return null;
931
- throw error;
932
- });
921
+ const metadata = await lstat(lock).catch(nullIfMissingFileError);
933
922
  if (metadata === null)
934
923
  return true;
935
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
924
+ if (!metadata.isDirectory()) {
936
925
  throw new OutputDirectoryError(`Codex Security credential-home lock is not a directory: ${lock}`);
937
926
  }
938
927
  let owner;
@@ -1009,8 +998,7 @@ export async function setCodexSecurityCredentialLogout(codexHome, loggedOut) {
1009
998
  export async function codexSecurityCredentialAllowsAmbientImport(codexHome) {
1010
999
  await requireSecureCredentialHome(codexHome);
1011
1000
  try {
1012
- const marker = await lstat(join(codexHome, CREDENTIAL_LOGOUT_MARKER));
1013
- if (!marker.isFile() || marker.isSymbolicLink()) {
1001
+ if (!(await lstat(join(codexHome, CREDENTIAL_LOGOUT_MARKER))).isFile()) {
1014
1002
  throw new OutputDirectoryError(`Codex Security logout marker is not a regular file: ${codexHome}`);
1015
1003
  }
1016
1004
  return false;
@@ -1033,7 +1021,7 @@ export async function codexSecurityHasStoredFileCredentials(codexHome) {
1033
1021
  return false;
1034
1022
  throw error;
1035
1023
  }
1036
- if (!metadata.isFile() || metadata.isSymbolicLink()) {
1024
+ if (!metadata.isFile()) {
1037
1025
  throw new OutputDirectoryError(`Codex Security stored authentication is not a regular file: ${path}`);
1038
1026
  }
1039
1027
  requirePrivateCredentialFile(metadata, path);
@@ -1089,16 +1077,8 @@ export async function preserveCodexSecurityPluginRegistration(codexHome, config)
1089
1077
  };
1090
1078
  }
1091
1079
  export function requireOutputOutsideRepository(repository, outputDirectory, pathKind = "output") {
1092
- const outputRelative = relative(repository, outputDirectory);
1093
- const repositoryRelative = relative(outputDirectory, repository);
1094
- if (outputRelative === "" ||
1095
- (outputRelative !== ".." &&
1096
- !outputRelative.startsWith(`..${sep}`) &&
1097
- !isAbsolute(outputRelative)) ||
1098
- (pathKind === "output" &&
1099
- repositoryRelative !== ".." &&
1100
- !repositoryRelative.startsWith(`..${sep}`) &&
1101
- !isAbsolute(repositoryRelative))) {
1080
+ if (isWithin(repository, outputDirectory) ||
1081
+ (pathKind === "output" && isWithin(outputDirectory, repository))) {
1102
1082
  throw new OutputInsideProtectedRootError(outputDirectory, repository, pathKind);
1103
1083
  }
1104
1084
  }
@@ -1207,13 +1187,9 @@ export async function validateOutputDir(outputDirectory, archiveExisting = false
1207
1187
  requireModelSafeOutputDir(outputDirectory);
1208
1188
  const path = resolve(expandHome(outputDirectory));
1209
1189
  try {
1210
- const metadata = await lstat(path).catch((error) => {
1211
- if (nodeErrorCode(error) === "ENOENT")
1212
- return null;
1213
- throw error;
1214
- });
1190
+ const metadata = await lstat(path).catch(nullIfMissingFileError);
1215
1191
  if (metadata !== null) {
1216
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
1192
+ if (!metadata.isDirectory()) {
1217
1193
  throw new OutputDirectoryError(`Scan output is not a directory: ${path}`);
1218
1194
  }
1219
1195
  if (!archiveExisting && (await readdir(path)).length !== 0) {
@@ -1278,8 +1254,7 @@ export async function prepareScanArtifactRestorer(options, scanDirectory) {
1278
1254
  }
1279
1255
  const prepared = JSON.parse(result.stdout);
1280
1256
  if (!isRecord(prepared) ||
1281
- typeof prepared["canonicalPath"] !== "string" ||
1282
- prepared["canonicalPath"].length === 0 ||
1257
+ !isNonEmptyString(prepared["canonicalPath"]) ||
1283
1258
  typeof prepared["dev"] !== "string" ||
1284
1259
  !/^(?:0|[1-9]\d*)$/u.test(prepared["dev"]) ||
1285
1260
  typeof prepared["ino"] !== "string" ||
@@ -1310,7 +1285,7 @@ export async function prepareScanArtifactRestorer(options, scanDirectory) {
1310
1285
  relativePath,
1311
1286
  dev,
1312
1287
  ino,
1313
- ], pluginHelperEnvironment(options.environment), contents, options.signal);
1288
+ ], pluginHelperEnvironment(options.environment), contents);
1314
1289
  if (!result.success) {
1315
1290
  throw new Error(result.stderr.trim() ||
1316
1291
  result.stdout.trim() ||
@@ -1318,8 +1293,6 @@ export async function prepareScanArtifactRestorer(options, scanDirectory) {
1318
1293
  }
1319
1294
  }
1320
1295
  catch (error) {
1321
- if (options.signal?.aborted)
1322
- throw error;
1323
1296
  throw new OutputDirectoryError("Could not safely restore a completed scan artifact.", { cause: error });
1324
1297
  }
1325
1298
  },
@@ -1328,18 +1301,13 @@ export async function prepareScanArtifactRestorer(options, scanDirectory) {
1328
1301
  export async function planOutputArchive(outputDirectory) {
1329
1302
  if (outputDirectory === null)
1330
1303
  return null;
1331
- const entries = await readdir(outputDirectory).catch((error) => {
1332
- if (nodeErrorCode(error) === "ENOENT")
1333
- return null;
1334
- throw error;
1335
- });
1304
+ const entries = await readdir(outputDirectory).catch(nullIfMissingFileError);
1336
1305
  if (entries === null || entries.length === 0)
1337
1306
  return null;
1338
- const timestamp = new Date()
1307
+ return `${outputDirectory}.previous-${new Date()
1339
1308
  .toISOString()
1340
1309
  .replaceAll(/[-:]/g, "")
1341
- .replace(/\.\d{3}Z$/, "");
1342
- return `${outputDirectory}.previous-${timestamp}-${randomUUID().slice(0, 8)}`;
1310
+ .replace(/\.\d{3}Z$/, "")}-${randomUUID().slice(0, 8)}`;
1343
1311
  }
1344
1312
  export function requireModelSafeOutputDir(path) {
1345
1313
  if (MODEL_UNSAFE_PATH.test(path)) {
@@ -1353,18 +1321,24 @@ export function requireModelSafeOutputDir(path) {
1353
1321
  export async function canonicalizeModelSafePath(input) {
1354
1322
  const path = resolve(expandHome(input));
1355
1323
  requireModelSafeOutputDir(path);
1356
- for (let ancestor = path;; ancestor = dirname(ancestor)) {
1324
+ const canonical = await canonicalConfigPath(path);
1325
+ requireModelSafeOutputDir(canonical);
1326
+ return canonical;
1327
+ }
1328
+ export async function canonicalConfigPath(path) {
1329
+ let existing = resolve(path);
1330
+ const missing = [];
1331
+ while (true) {
1357
1332
  try {
1358
- const canonicalAncestor = resolve(ancestor, await realpath(ancestor));
1359
- const canonical = resolve(canonicalAncestor, relative(ancestor, path));
1360
- requireModelSafeOutputDir(canonical);
1361
- return canonical;
1333
+ return join(await realpath(existing), ...missing);
1362
1334
  }
1363
1335
  catch (error) {
1364
- if (nodeErrorCode(error) !== "ENOENT")
1365
- throw error;
1366
- if (dirname(ancestor) === ancestor)
1336
+ const parent = dirname(existing);
1337
+ if (error.code !== "ENOENT" ||
1338
+ parent === existing)
1367
1339
  throw error;
1340
+ missing.unshift(basename(existing));
1341
+ existing = parent;
1368
1342
  }
1369
1343
  }
1370
1344
  }
@@ -1389,11 +1363,7 @@ export async function prepareOutputDir(outputDirectory, repositoryName, temporar
1389
1363
  }
1390
1364
  let createdRoot;
1391
1365
  try {
1392
- let existing = await lstat(path).catch((error) => {
1393
- if (nodeErrorCode(error) === "ENOENT")
1394
- return null;
1395
- throw error;
1396
- });
1366
+ let existing = await lstat(path).catch(nullIfMissingFileError);
1397
1367
  if (existing !== null && archiveExisting) {
1398
1368
  const archiveDir = await planOutputArchive(path);
1399
1369
  if (archiveDir !== null) {
@@ -1422,7 +1392,7 @@ export async function prepareOutputDir(outputDirectory, repositoryName, temporar
1422
1392
  }
1423
1393
  export async function validatePreparedOutputDir(path, validateLocation) {
1424
1394
  const metadata = await lstat(path);
1425
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
1395
+ if (!metadata.isDirectory()) {
1426
1396
  throw new OutputDirectoryError(`Scan output is not a directory: ${path}`);
1427
1397
  }
1428
1398
  const canonical = await realpath(path);
@@ -1475,7 +1445,7 @@ export async function requireSecureOutputAncestry(path, effectiveUid = process.g
1475
1445
  catch (error) {
1476
1446
  throw new OutputDirectoryError(`Unable to inspect scan output parent directory: ${current}`, { cause: error });
1477
1447
  }
1478
- if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
1448
+ if (!metadata.isDirectory()) {
1479
1449
  throw new OutputDirectoryError(`Scan output parent must be a non-symlink directory: ${current}`);
1480
1450
  }
1481
1451
  requireTrustedOutputAncestor(metadata, current, effectiveUid);
@@ -1732,7 +1702,7 @@ export async function resolvePluginPath(pluginPath, workspace, signal) {
1732
1702
  if (metadata?.isFile() && extname(path).toLowerCase() === ".zip") {
1733
1703
  return await extractPluginZip(path, join(workspace, "extracted-plugin"), signal);
1734
1704
  }
1735
- if (metadata?.isDirectory() && !metadata.isSymbolicLink()) {
1705
+ if (metadata?.isDirectory()) {
1736
1706
  throwIfSignalAborted(signal);
1737
1707
  return await validatePluginRoot(path);
1738
1708
  }
@@ -1814,18 +1784,17 @@ export async function bootstrapPlugin(codexHome, pluginRoot, options = {}) {
1814
1784
  CODEX_HOME: codexHome,
1815
1785
  };
1816
1786
  const run = options.runCodex ?? runPluginCommand;
1817
- const existing = await lstat(marketplace).catch((error) => {
1818
- if (nodeErrorCode(error) === "ENOENT")
1819
- return null;
1820
- throw error;
1821
- });
1787
+ const existing = await lstat(marketplace).catch(nullIfMissingFileError);
1822
1788
  if (existing !== null && !existing.isDirectory()) {
1823
1789
  throw new PluginBootstrapError(`Codex Security plugin marketplace path must be a directory: ${marketplace}`);
1824
1790
  }
1825
1791
  const staged = existing === null
1826
1792
  ? null
1827
1793
  : await pluginMetadata(join(marketplace, "plugins", PLUGIN_NAME)).catch(() => null);
1828
- if (staged?.version !== version) {
1794
+ const stagedRoot = join(marketplace, "plugins", PLUGIN_NAME);
1795
+ const stagedMatches = staged?.version === version &&
1796
+ (await pluginContentsMatch(root, stagedRoot, options.signal));
1797
+ if (!stagedMatches) {
1829
1798
  if (existing !== null) {
1830
1799
  await rm(marketplace, { recursive: true, force: true });
1831
1800
  }
@@ -1836,16 +1805,50 @@ export async function bootstrapPlugin(codexHome, pluginRoot, options = {}) {
1836
1805
  return "";
1837
1806
  throw error;
1838
1807
  });
1839
- const marketplaces = parse(config)["marketplaces"];
1808
+ const configuration = parse(config);
1809
+ const marketplaces = configuration["marketplaces"];
1840
1810
  const registration = isRecord(marketplaces)
1841
1811
  ? marketplaces[MARKETPLACE_NAME]
1842
1812
  : undefined;
1843
- if (!isRecord(registration) ||
1844
- registration["source_type"] !== "local" ||
1845
- typeof registration["source"] !== "string" ||
1846
- !(await sameFile(registration["source"], marketplace))) {
1813
+ const registered = isRecord(registration) &&
1814
+ registration["source_type"] === "local" &&
1815
+ typeof registration["source"] === "string" &&
1816
+ (await sameFile(registration["source"], marketplace));
1817
+ if (!registered) {
1847
1818
  await run(command, ["plugin", "marketplace", "add", marketplace], environment, options.signal);
1848
1819
  }
1820
+ const installRecord = join(marketplace, "installed-plugin.json");
1821
+ const previous = await readFile(installRecord, "utf8")
1822
+ .then((value) => JSON.parse(value))
1823
+ .catch((error) => {
1824
+ if (nodeErrorCode(error) === "ENOENT" || error instanceof SyntaxError) {
1825
+ return null;
1826
+ }
1827
+ throw error;
1828
+ });
1829
+ const plugins = configuration["plugins"];
1830
+ const plugin = isRecord(plugins)
1831
+ ? plugins[`${PLUGIN_NAME}@${MARKETPLACE_NAME}`]
1832
+ : undefined;
1833
+ // Codex replaces the shared install even at the same version. Reuse it so
1834
+ // workers from an earlier scan can keep using their plugin files.
1835
+ if (stagedMatches &&
1836
+ registered &&
1837
+ isRecord(plugin) &&
1838
+ plugin["enabled"] === true &&
1839
+ isRecord(previous) &&
1840
+ typeof previous["installedPath"] === "string" &&
1841
+ previous["version"] === version &&
1842
+ (await pluginContentsMatch(root, previous["installedPath"], options.signal, true))) {
1843
+ return {
1844
+ pluginRoot: root,
1845
+ marketplaceRoot: marketplace,
1846
+ installedRoot: previous["installedPath"],
1847
+ marketplaceName: MARKETPLACE_NAME,
1848
+ name,
1849
+ version,
1850
+ };
1851
+ }
1849
1852
  const output = await run(command, ["plugin", "add", "--json", `${PLUGIN_NAME}@${MARKETPLACE_NAME}`], environment, options.signal);
1850
1853
  let installed;
1851
1854
  try {
@@ -1859,6 +1862,10 @@ export async function bootstrapPlugin(codexHome, pluginRoot, options = {}) {
1859
1862
  installed["version"] !== version) {
1860
1863
  throw new PluginBootstrapError("Codex plugin install did not return the selected plugin path and version.");
1861
1864
  }
1865
+ await writeFile(installRecord, JSON.stringify({
1866
+ installedPath: installed["installedPath"],
1867
+ version,
1868
+ }), { mode: 0o600, signal: options.signal });
1862
1869
  return {
1863
1870
  pluginRoot: root,
1864
1871
  marketplaceRoot: marketplace,
@@ -1868,12 +1875,48 @@ export async function bootstrapPlugin(codexHome, pluginRoot, options = {}) {
1868
1875
  version,
1869
1876
  };
1870
1877
  }
1878
+ async function pluginContentsMatch(source, destination, signal, allowExtraFiles = false) {
1879
+ throwIfSignalAborted(signal);
1880
+ const sourceMetadata = await lstat(source);
1881
+ const destinationMetadata = await lstat(destination).catch((error) => {
1882
+ if (["ENOENT", "ENOTDIR"].includes(nodeErrorCode(error) ?? "")) {
1883
+ return null;
1884
+ }
1885
+ throw error;
1886
+ });
1887
+ if (destinationMetadata === null)
1888
+ return false;
1889
+ if (sourceMetadata.isFile() && destinationMetadata.isFile()) {
1890
+ if (sourceMetadata.size !== destinationMetadata.size ||
1891
+ (sourceMetadata.mode & 0o111) !== (destinationMetadata.mode & 0o111)) {
1892
+ return false;
1893
+ }
1894
+ const [sourceBytes, destinationBytes] = await Promise.all([
1895
+ readFile(source, { signal }),
1896
+ readFile(destination, { signal }),
1897
+ ]);
1898
+ return sourceBytes.equals(destinationBytes);
1899
+ }
1900
+ if (!sourceMetadata.isDirectory() || !destinationMetadata.isDirectory()) {
1901
+ return false;
1902
+ }
1903
+ const entries = await readdir(source);
1904
+ if (!allowExtraFiles &&
1905
+ entries.length !== (await readdir(destination)).length) {
1906
+ return false;
1907
+ }
1908
+ for (const entry of entries) {
1909
+ if (!(await pluginContentsMatch(join(source, entry), join(destination, entry), signal, allowExtraFiles))) {
1910
+ return false;
1911
+ }
1912
+ }
1913
+ return true;
1914
+ }
1871
1915
  export async function pluginMetadata(root) {
1872
1916
  const manifestPath = join(root, ".codex-plugin", "plugin.json");
1873
1917
  let manifest;
1874
1918
  try {
1875
- const metadata = await lstat(manifestPath);
1876
- if (!metadata.isFile() || metadata.isSymbolicLink()) {
1919
+ if (!(await lstat(manifestPath)).isFile()) {
1877
1920
  throw new Error("plugin manifest is not a regular file");
1878
1921
  }
1879
1922
  manifest = JSON.parse(await readFile(manifestPath, "utf8"));
@@ -1941,6 +1984,20 @@ export function pluginExecutionEnvironment(python, environment = process.env) {
1941
1984
  CODEX_CLI_PATH: resolveCodexCommand(environment).command,
1942
1985
  };
1943
1986
  }
1987
+ export function environmentWithGit(environment, git) {
1988
+ if (git === undefined)
1989
+ return environment;
1990
+ const result = { ...environment };
1991
+ for (const name of Object.keys(result)) {
1992
+ const normalized = name.toUpperCase();
1993
+ if (normalized === "CODEX_SECURITY_GIT" || normalized === "PATH") {
1994
+ delete result[name];
1995
+ }
1996
+ }
1997
+ result["CODEX_SECURITY_GIT"] = git.executable ?? "";
1998
+ result["PATH"] = git.environment["PATH"] ?? "";
1999
+ return result;
2000
+ }
1944
2001
  export function pythonUtf8Environment(environment) {
1945
2002
  const normalized = { ...environment };
1946
2003
  for (const name of Object.keys(normalized)) {
@@ -1989,6 +2046,29 @@ export async function runCodexCommand(command, args, environment, input, signal)
1989
2046
  child.stdin.end(input);
1990
2047
  return await completion;
1991
2048
  }
2049
+ export async function probeCodexSandbox(command, environment, signal) {
2050
+ // This preflight covers the Unix sandbox backends.
2051
+ if (process.platform === "win32")
2052
+ return;
2053
+ // Reuse the resolved Codex executable instead of looking up a probe on PATH.
2054
+ const args = ["sandbox", "--", command.command, "--version"];
2055
+ const timeout = AbortSignal.timeout(SANDBOX_PROBE_TIMEOUT_MILLISECONDS);
2056
+ let detail;
2057
+ try {
2058
+ const result = await runCodexCommand(command, args, environment, undefined, signal === undefined ? timeout : AbortSignal.any([signal, timeout]));
2059
+ if (result.success)
2060
+ return;
2061
+ detail =
2062
+ result.stderr.trim() ||
2063
+ result.stdout.trim() ||
2064
+ `Codex exited with status ${result.exitCode}.`;
2065
+ }
2066
+ catch (error) {
2067
+ signal?.throwIfAborted();
2068
+ detail = processErrorDetail(error);
2069
+ }
2070
+ throw new SandboxUnavailableError(`Codex could not run a command in its sandbox; reproduce with '${command.command} ${args.join(" ")}'. On Linux this usually means unprivileged user namespaces are restricted (kernel.apparmor_restrict_unprivileged_userns=1 on Ubuntu 24.04 and later), which Bubblewrap needs; inside the container image, use the AppArmor profile and Compose override from the SDK README. Codex reported: ${detail}`);
2071
+ }
1992
2072
  async function runPluginCommand(command, args, environment, signal) {
1993
2073
  try {
1994
2074
  const { success, exitCode, stdout, stderr } = await runCodexCommand(command, args, environment, undefined, signal);
@@ -2115,30 +2195,15 @@ export function isPythonPathCandidate(candidate) {
2115
2195
  candidate.startsWith("."));
2116
2196
  }
2117
2197
  async function hasPluginManifest(root) {
2118
- return await isRegularFile(join(root, ".codex-plugin", "plugin.json"));
2198
+ return await lstat(join(root, ".codex-plugin", "plugin.json")).then((metadata) => metadata.isFile(), () => false);
2119
2199
  }
2120
- async function isRegularFile(path) {
2121
- try {
2122
- const metadata = await lstat(path);
2123
- return metadata.isFile() && !metadata.isSymbolicLink();
2124
- }
2125
- catch {
2126
- return false;
2127
- }
2128
- }
2129
- async function sameFile(left, right) {
2130
- try {
2131
- // NTFS file IDs can exceed JavaScript's safe integer range.
2132
- const [leftMetadata, rightMetadata] = await Promise.all([
2133
- stat(left, { bigint: true }),
2134
- stat(right, { bigint: true }),
2135
- ]);
2136
- return (leftMetadata.dev === rightMetadata.dev &&
2137
- leftMetadata.ino === rightMetadata.ino);
2138
- }
2139
- catch {
2140
- return false;
2141
- }
2200
+ function sameFile(left, right) {
2201
+ // NTFS file IDs can exceed JavaScript's safe integer range.
2202
+ return Promise.all([
2203
+ stat(left, { bigint: true }),
2204
+ stat(right, { bigint: true }),
2205
+ ]).then(([leftMetadata, rightMetadata]) => leftMetadata.dev === rightMetadata.dev &&
2206
+ leftMetadata.ino === rightMetadata.ino, () => false);
2142
2207
  }
2143
2208
  export function expandHome(value, environment = process.env) {
2144
2209
  const home = (process.platform === "win32"
@@ -2173,20 +2238,27 @@ function processErrorDetail(error) {
2173
2238
  }
2174
2239
  return String(error) || "unknown error";
2175
2240
  }
2176
- function isRecord(value) {
2177
- return typeof value === "object" && value !== null && !Array.isArray(value);
2178
- }
2179
2241
  function nodeErrorCode(error) {
2180
2242
  return isRecord(error) && typeof error["code"] === "string"
2181
2243
  ? error["code"]
2182
2244
  : undefined;
2183
2245
  }
2184
- function abortReason(signal) {
2185
- return (signal.reason ??
2186
- new DOMException("The operation was aborted.", "AbortError"));
2187
- }
2188
2246
  function throwIfSignalAborted(signal) {
2189
2247
  if (signal?.aborted)
2190
2248
  throw abortReason(signal);
2191
2249
  }
2250
+ function nullIfMissingFileError(error) {
2251
+ if (nodeErrorCode(error) === "ENOENT")
2252
+ return null;
2253
+ throw error;
2254
+ }
2255
+ /** @internal */
2256
+ export function workbenchEnvironment(environment) {
2257
+ return {
2258
+ ...environment,
2259
+ CODEX_SECURITY_STATE_DIR: codexSecurityStateDirectory(environment),
2260
+ };
2261
+ }
2262
+ /** @internal */
2263
+ export const resolveWorkbenchRuntime = (options) => Promise.all([resolvePluginPython(options), bundledPluginRoot()]);
2192
2264
  //# sourceMappingURL=runtime.js.map