@openai/codex-security 0.1.31 → 0.3.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 (514) hide show
  1. package/README.md +442 -2434
  2. package/_bundled_plugin/.app.json +5 -1
  3. package/_bundled_plugin/.codex-plugin/plugin.json +9 -5
  4. package/_bundled_plugin/.mcp.json +3 -0
  5. package/_bundled_plugin/examples/completed-scan/coverage.json +0 -1
  6. package/_bundled_plugin/examples/completed-scan/report.md +28 -26
  7. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +1 -1
  8. package/_bundled_plugin/mcp/helpers.mjs +1 -0
  9. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  10. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +7 -214
  11. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  13. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  14. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  15. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  16. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  17. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  18. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  19. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +563 -0
  20. package/_bundled_plugin/mcp/server.mjs +1 -0
  21. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  22. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  23. package/_bundled_plugin/preflight/capability-profiles.toml +0 -13
  24. package/_bundled_plugin/references/artifact-storage.md +5 -5
  25. package/_bundled_plugin/references/config-preflight.md +1 -5
  26. package/_bundled_plugin/references/core-scan.md +34 -10
  27. package/_bundled_plugin/references/final-report.md +13 -13
  28. package/_bundled_plugin/references/finding-detail-fields.md +90 -80
  29. package/_bundled_plugin/references/sarif-adapter.md +1 -1
  30. package/_bundled_plugin/references/scan-artifacts.md +3 -4
  31. package/_bundled_plugin/references/scan-contract.md +11 -6
  32. package/_bundled_plugin/references/scan-prologue.md +12 -0
  33. package/_bundled_plugin/references/security-guidance.md +2 -2
  34. package/_bundled_plugin/references/standalone-validation.md +11 -0
  35. package/_bundled_plugin/references/threat-model.md +2 -2
  36. package/_bundled_plugin/schemas/coverage.schema.json +23 -47
  37. package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +2 -24
  38. package/_bundled_plugin/schemas/definitions/discovery-candidate.schema.json +49 -25
  39. package/_bundled_plugin/schemas/findings.schema.json +71 -192
  40. package/_bundled_plugin/schemas/scan-manifest.schema.json +83 -95
  41. package/_bundled_plugin/schemas/tools/candidate-attack-paths.schema.json +91 -83
  42. package/_bundled_plugin/schemas/tools/candidate-validations.schema.json +35 -64
  43. package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +5 -2
  44. package/_bundled_plugin/schemas/tools/discovery-candidates.schema.json +6 -55
  45. package/_bundled_plugin/schemas/tools/review-items.schema.json +2 -38
  46. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +245 -356
  47. package/_bundled_plugin/scripts/codex_profile.mjs +239 -0
  48. package/_bundled_plugin/scripts/codex_session.mjs +53 -0
  49. package/_bundled_plugin/scripts/config_preflight.py +29 -69
  50. package/_bundled_plugin/scripts/deep_scan_config.py +9 -11
  51. package/_bundled_plugin/scripts/deep_scan_workbench.py +208 -363
  52. package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
  53. package/_bundled_plugin/scripts/finalize_scan_contract.py +733 -375
  54. package/_bundled_plugin/scripts/finding_preview.py +81 -91
  55. package/_bundled_plugin/scripts/generate_in_scope_files.py +48 -102
  56. package/_bundled_plugin/scripts/generate_rank_input.py +117 -888
  57. package/_bundled_plugin/scripts/launch_codex_security_mcp +35 -6
  58. package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +5 -5
  59. package/_bundled_plugin/scripts/rank_preview.py +43 -902
  60. package/_bundled_plugin/scripts/report_projection.py +143 -219
  61. package/_bundled_plugin/scripts/snapshot_sqlite.py +6 -1
  62. package/_bundled_plugin/scripts/threat_model_projection.py +161 -0
  63. package/_bundled_plugin/scripts/validate_scan_contract.py +4 -34
  64. package/_bundled_plugin/scripts/validate_tracking_source.py +3 -13
  65. package/_bundled_plugin/scripts/windows_scan_local_files.py +59 -9
  66. package/_bundled_plugin/scripts/workbench/handoff.py +25 -50
  67. package/_bundled_plugin/scripts/workbench/runtime_toml.py +22 -0
  68. package/_bundled_plugin/scripts/workbench/storage.py +21 -6
  69. package/_bundled_plugin/scripts/workbench_cli.py +99 -190
  70. package/_bundled_plugin/scripts/workbench_constants.py +6 -14
  71. package/_bundled_plugin/scripts/workbench_db.py +524 -672
  72. package/_bundled_plugin/scripts/workbench_feedback.py +6 -3
  73. package/_bundled_plugin/scripts/workbench_finding_index.py +20 -7
  74. package/_bundled_plugin/scripts/workbench_finding_workflows.py +18 -4
  75. package/_bundled_plugin/scripts/workbench_local_dedupe.py +136 -0
  76. package/_bundled_plugin/scripts/workbench_native_indexes.py +28 -18
  77. package/_bundled_plugin/scripts/workbench_progress.py +26 -92
  78. package/_bundled_plugin/scripts/workbench_publication.py +77 -116
  79. package/_bundled_plugin/scripts/workbench_remediation.py +14 -20
  80. package/_bundled_plugin/scripts/workbench_saved_results.py +1402 -263
  81. package/_bundled_plugin/scripts/workbench_scan_history.py +57 -57
  82. package/_bundled_plugin/scripts/workbench_scan_start.py +109 -52
  83. package/_bundled_plugin/scripts/workbench_scan_usage.py +30 -49
  84. package/_bundled_plugin/scripts/workbench_schema.py +71 -1370
  85. package/_bundled_plugin/scripts/workbench_source_excerpt.py +16 -7
  86. package/_bundled_plugin/scripts/workbench_target.py +526 -150
  87. package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
  88. package/_bundled_plugin/scripts/workbench_validation.py +19 -44
  89. package/_bundled_plugin/shared/workbench-history-repairs.json +218 -0
  90. package/_bundled_plugin/shared/workbench-migrations.json +397 -0
  91. package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +15 -4
  92. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -0
  93. package/_bundled_plugin/skills/cloud-findings/SKILL.md +54 -0
  94. package/_bundled_plugin/skills/cloud-findings/agents/openai.yaml +4 -0
  95. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +6 -6
  96. package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
  97. package/_bundled_plugin/skills/finding-discovery/SKILL.md +3 -3
  98. package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +50 -20
  99. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +8 -14
  100. package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
  101. package/_bundled_plugin/skills/security-scan/SKILL.md +22 -7
  102. package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
  103. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
  104. package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +13 -1
  105. package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
  106. package/_bundled_plugin/skills/track-findings/SKILL.md +46 -178
  107. package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
  108. package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +16 -24
  109. package/_bundled_plugin/skills/track-findings/references/jira.md +15 -61
  110. package/_bundled_plugin/skills/triage-finding/SKILL.md +50 -289
  111. package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +2 -2
  112. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +23 -43
  113. package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +7 -1
  114. package/bin/codex-security.mjs +9 -2
  115. package/dist/api.d.ts +63 -15
  116. package/dist/api.d.ts.map +1 -1
  117. package/dist/api.js +970 -553
  118. package/dist/api.js.map +1 -1
  119. package/dist/artifact-export.d.ts +70 -0
  120. package/dist/artifact-export.d.ts.map +1 -0
  121. package/dist/artifact-export.js +292 -0
  122. package/dist/artifact-export.js.map +1 -0
  123. package/dist/auth.d.ts +2 -6
  124. package/dist/auth.d.ts.map +1 -1
  125. package/dist/auth.js +27 -12
  126. package/dist/auth.js.map +1 -1
  127. package/dist/bulk-scan-discovery.d.ts +1 -0
  128. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  129. package/dist/bulk-scan-discovery.js +9 -9
  130. package/dist/bulk-scan-discovery.js.map +1 -1
  131. package/dist/classify-scan-severity.d.ts.map +1 -1
  132. package/dist/classify-scan-severity.js +2 -5
  133. package/dist/classify-scan-severity.js.map +1 -1
  134. package/dist/classify-severity.d.ts +28 -17
  135. package/dist/classify-severity.d.ts.map +1 -1
  136. package/dist/classify-severity.js +16 -35
  137. package/dist/classify-severity.js.map +1 -1
  138. package/dist/cli-help.d.ts +3 -0
  139. package/dist/cli-help.d.ts.map +1 -0
  140. package/dist/cli-help.js +285 -0
  141. package/dist/cli-help.js.map +1 -0
  142. package/dist/cli-signals.d.ts +8 -0
  143. package/dist/cli-signals.d.ts.map +1 -0
  144. package/dist/cli-signals.js +28 -0
  145. package/dist/cli-signals.js.map +1 -0
  146. package/dist/cli.d.ts +22 -24
  147. package/dist/cli.d.ts.map +1 -1
  148. package/dist/cli.js +1660 -1556
  149. package/dist/cli.js.map +1 -1
  150. package/dist/cloud-publish.d.ts.map +1 -1
  151. package/dist/cloud-publish.js +11 -17
  152. package/dist/cloud-publish.js.map +1 -1
  153. package/dist/codeowners.d.ts +19 -0
  154. package/dist/codeowners.d.ts.map +1 -0
  155. package/dist/codeowners.js +138 -0
  156. package/dist/codeowners.js.map +1 -0
  157. package/dist/codex-prompt.d.ts.map +1 -1
  158. package/dist/codex-prompt.js +1 -2
  159. package/dist/codex-prompt.js.map +1 -1
  160. package/dist/codex-sdk-environment.d.ts +3 -0
  161. package/dist/codex-sdk-environment.d.ts.map +1 -0
  162. package/dist/codex-sdk-environment.js +68 -0
  163. package/dist/codex-sdk-environment.js.map +1 -0
  164. package/dist/component-plan.d.ts +2 -5
  165. package/dist/component-plan.d.ts.map +1 -1
  166. package/dist/component-plan.js +38 -34
  167. package/dist/component-plan.js.map +1 -1
  168. package/dist/component-scan.d.ts +7 -5
  169. package/dist/component-scan.d.ts.map +1 -1
  170. package/dist/component-scan.js +54 -44
  171. package/dist/component-scan.js.map +1 -1
  172. package/dist/config.d.ts.map +1 -1
  173. package/dist/config.js +93 -104
  174. package/dist/config.js.map +1 -1
  175. package/dist/contract.d.ts +15 -2
  176. package/dist/contract.d.ts.map +1 -1
  177. package/dist/contract.js +124 -348
  178. package/dist/contract.js.map +1 -1
  179. package/dist/cost-model.d.ts +13 -6
  180. package/dist/cost-model.d.ts.map +1 -1
  181. package/dist/cost-model.js +75 -34
  182. package/dist/cost-model.js.map +1 -1
  183. package/dist/cost.d.ts +10 -2
  184. package/dist/cost.d.ts.map +1 -1
  185. package/dist/cost.js +116 -134
  186. package/dist/cost.js.map +1 -1
  187. package/dist/custom-validation-prompt.d.ts.map +1 -1
  188. package/dist/custom-validation-prompt.js +7 -6
  189. package/dist/custom-validation-prompt.js.map +1 -1
  190. package/dist/custom-validation.d.ts +1 -2
  191. package/dist/custom-validation.d.ts.map +1 -1
  192. package/dist/custom-validation.js +23 -16
  193. package/dist/custom-validation.js.map +1 -1
  194. package/dist/deduplication/checkpointed-review.d.ts +4 -2
  195. package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
  196. package/dist/deduplication/checkpointed-review.js +33 -20
  197. package/dist/deduplication/checkpointed-review.js.map +1 -1
  198. package/dist/deduplication/codex-review.d.ts +9 -1
  199. package/dist/deduplication/codex-review.d.ts.map +1 -1
  200. package/dist/deduplication/codex-review.js +129 -20
  201. package/dist/deduplication/codex-review.js.map +1 -1
  202. package/dist/deduplication/deduplication-prompts.d.ts +5 -2
  203. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  204. package/dist/deduplication/deduplication-prompts.js +18 -4
  205. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  206. package/dist/deduplication/deduplication-reviewer.d.ts +26 -4
  207. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  208. package/dist/deduplication/deduplication-reviewer.js +59 -47
  209. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  210. package/dist/deduplication/deduplication.d.ts.map +1 -1
  211. package/dist/deduplication/deduplication.js +59 -113
  212. package/dist/deduplication/deduplication.js.map +1 -1
  213. package/dist/deduplication/diagnostics.d.ts +17 -0
  214. package/dist/deduplication/diagnostics.d.ts.map +1 -0
  215. package/dist/deduplication/diagnostics.js +5 -0
  216. package/dist/deduplication/diagnostics.js.map +1 -0
  217. package/dist/deduplication/finding-schema.d.ts.map +1 -1
  218. package/dist/deduplication/finding-schema.js +7 -1
  219. package/dist/deduplication/finding-schema.js.map +1 -1
  220. package/dist/deduplication/local.d.ts +31 -0
  221. package/dist/deduplication/local.d.ts.map +1 -0
  222. package/dist/deduplication/local.js +166 -0
  223. package/dist/deduplication/local.js.map +1 -0
  224. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  225. package/dist/deduplication/records-protocol.js +12 -28
  226. package/dist/deduplication/records-protocol.js.map +1 -1
  227. package/dist/deduplication/records.d.ts +188 -12
  228. package/dist/deduplication/records.d.ts.map +1 -1
  229. package/dist/deduplication/records.js +34 -24
  230. package/dist/deduplication/records.js.map +1 -1
  231. package/dist/deduplication/review.d.ts +7 -0
  232. package/dist/deduplication/review.d.ts.map +1 -1
  233. package/dist/deduplication/review.js.map +1 -1
  234. package/dist/deduplication/scan.d.ts +9 -3
  235. package/dist/deduplication/scan.d.ts.map +1 -1
  236. package/dist/deduplication/scan.js +159 -44
  237. package/dist/deduplication/scan.js.map +1 -1
  238. package/dist/deep-config.d.ts +2 -1
  239. package/dist/deep-config.d.ts.map +1 -1
  240. package/dist/deep-config.js +7 -23
  241. package/dist/deep-config.js.map +1 -1
  242. package/dist/deep-progress.d.ts +2 -1
  243. package/dist/deep-progress.d.ts.map +1 -1
  244. package/dist/deep-progress.js +32 -47
  245. package/dist/deep-progress.js.map +1 -1
  246. package/dist/deep-scan.d.ts +20 -0
  247. package/dist/deep-scan.d.ts.map +1 -0
  248. package/dist/deep-scan.js +113 -0
  249. package/dist/deep-scan.js.map +1 -0
  250. package/dist/errors.d.ts +5 -2
  251. package/dist/errors.d.ts.map +1 -1
  252. package/dist/errors.js +7 -7
  253. package/dist/errors.js.map +1 -1
  254. package/dist/feedback.d.ts.map +1 -1
  255. package/dist/feedback.js +53 -21
  256. package/dist/feedback.js.map +1 -1
  257. package/dist/finding-catalogue.d.ts.map +1 -1
  258. package/dist/finding-catalogue.js +26 -30
  259. package/dist/finding-catalogue.js.map +1 -1
  260. package/dist/finding-normalization.d.ts +5 -0
  261. package/dist/finding-normalization.d.ts.map +1 -0
  262. package/dist/finding-normalization.js +120 -0
  263. package/dist/finding-normalization.js.map +1 -0
  264. package/dist/finding-retrieval.d.ts +9 -0
  265. package/dist/finding-retrieval.d.ts.map +1 -1
  266. package/dist/finding-retrieval.js.map +1 -1
  267. package/dist/finding-workflow.d.ts +13 -8
  268. package/dist/finding-workflow.d.ts.map +1 -1
  269. package/dist/finding-workflow.js +18 -13
  270. package/dist/finding-workflow.js.map +1 -1
  271. package/dist/findings-client.d.ts +2 -1
  272. package/dist/findings-client.d.ts.map +1 -1
  273. package/dist/findings-client.js +36 -9
  274. package/dist/findings-client.js.map +1 -1
  275. package/dist/findings-errors.d.ts +16 -0
  276. package/dist/findings-errors.d.ts.map +1 -0
  277. package/dist/findings-errors.js +24 -0
  278. package/dist/findings-errors.js.map +1 -0
  279. package/dist/findings-import.d.ts +1 -1
  280. package/dist/findings-import.d.ts.map +1 -1
  281. package/dist/findings-import.js +16 -44
  282. package/dist/findings-import.js.map +1 -1
  283. package/dist/github.d.ts.map +1 -1
  284. package/dist/github.js +9 -4
  285. package/dist/github.js.map +1 -1
  286. package/dist/import-scan.d.ts.map +1 -1
  287. package/dist/import-scan.js +49 -39
  288. package/dist/import-scan.js.map +1 -1
  289. package/dist/index.d.ts +11 -5
  290. package/dist/index.d.ts.map +1 -1
  291. package/dist/index.js +2 -1
  292. package/dist/index.js.map +1 -1
  293. package/dist/knowledge-base.d.ts +7 -1
  294. package/dist/knowledge-base.d.ts.map +1 -1
  295. package/dist/knowledge-base.js +115 -47
  296. package/dist/knowledge-base.js.map +1 -1
  297. package/dist/linear.d.ts.map +1 -1
  298. package/dist/linear.js +4 -10
  299. package/dist/linear.js.map +1 -1
  300. package/dist/mock-scan.d.ts.map +1 -1
  301. package/dist/mock-scan.js +0 -1
  302. package/dist/mock-scan.js.map +1 -1
  303. package/dist/models.d.ts +24 -2
  304. package/dist/models.d.ts.map +1 -1
  305. package/dist/models.js.map +1 -1
  306. package/dist/multiscan.d.ts +9 -3
  307. package/dist/multiscan.d.ts.map +1 -1
  308. package/dist/multiscan.js +225 -153
  309. package/dist/multiscan.js.map +1 -1
  310. package/dist/owner-evidence.d.ts +10 -2
  311. package/dist/owner-evidence.d.ts.map +1 -1
  312. package/dist/owner-evidence.js +69 -14
  313. package/dist/owner-evidence.js.map +1 -1
  314. package/dist/patch-tui.d.ts.map +1 -1
  315. package/dist/patch-tui.js +5 -6
  316. package/dist/patch-tui.js.map +1 -1
  317. package/dist/project-config-schema.d.ts +10 -0
  318. package/dist/project-config-schema.d.ts.map +1 -1
  319. package/dist/project-config-schema.js +1 -0
  320. package/dist/project-config-schema.js.map +1 -1
  321. package/dist/project-config.d.ts +1 -0
  322. package/dist/project-config.d.ts.map +1 -1
  323. package/dist/project-config.js +5 -3
  324. package/dist/project-config.js.map +1 -1
  325. package/dist/prompt-files.d.ts +0 -1
  326. package/dist/prompt-files.d.ts.map +1 -1
  327. package/dist/prompt-files.js +2 -4
  328. package/dist/prompt-files.js.map +1 -1
  329. package/dist/provider-profile.d.ts +21 -0
  330. package/dist/provider-profile.d.ts.map +1 -0
  331. package/dist/provider-profile.js +133 -0
  332. package/dist/provider-profile.js.map +1 -0
  333. package/dist/publication-events.d.ts +6 -8
  334. package/dist/publication-events.d.ts.map +1 -1
  335. package/dist/publication-events.js +40 -79
  336. package/dist/publication-events.js.map +1 -1
  337. package/dist/publication-store.d.ts.map +1 -1
  338. package/dist/publication-store.js +48 -76
  339. package/dist/publication-store.js.map +1 -1
  340. package/dist/publication.d.ts +1 -2
  341. package/dist/publication.d.ts.map +1 -1
  342. package/dist/publication.js +7 -16
  343. package/dist/publication.js.map +1 -1
  344. package/dist/publish.d.ts +1 -5
  345. package/dist/publish.d.ts.map +1 -1
  346. package/dist/publish.js +138 -199
  347. package/dist/publish.js.map +1 -1
  348. package/dist/record.d.ts +2 -0
  349. package/dist/record.d.ts.map +1 -0
  350. package/dist/record.js +4 -0
  351. package/dist/record.js.map +1 -0
  352. package/dist/request-metadata.d.ts +9 -0
  353. package/dist/request-metadata.d.ts.map +1 -0
  354. package/dist/request-metadata.js +13 -0
  355. package/dist/request-metadata.js.map +1 -0
  356. package/dist/result.d.ts +4 -1
  357. package/dist/result.d.ts.map +1 -1
  358. package/dist/result.js +7 -0
  359. package/dist/result.js.map +1 -1
  360. package/dist/runtime.d.ts +25 -17
  361. package/dist/runtime.d.ts.map +1 -1
  362. package/dist/runtime.js +619 -255
  363. package/dist/runtime.js.map +1 -1
  364. package/dist/saved-scan-bootstrap.d.ts +14 -0
  365. package/dist/saved-scan-bootstrap.d.ts.map +1 -0
  366. package/dist/saved-scan-bootstrap.js +261 -0
  367. package/dist/saved-scan-bootstrap.js.map +1 -0
  368. package/dist/saved-scan.d.ts +1 -1
  369. package/dist/saved-scan.d.ts.map +1 -1
  370. package/dist/saved-scan.js +16 -32
  371. package/dist/saved-scan.js.map +1 -1
  372. package/dist/scan-activity.d.ts.map +1 -1
  373. package/dist/scan-activity.js +19 -30
  374. package/dist/scan-activity.js.map +1 -1
  375. package/dist/scan-comparison.d.ts +31 -18
  376. package/dist/scan-comparison.d.ts.map +1 -1
  377. package/dist/scan-comparison.js +307 -347
  378. package/dist/scan-comparison.js.map +1 -1
  379. package/dist/scan-dashboard.d.ts +3 -1
  380. package/dist/scan-dashboard.d.ts.map +1 -1
  381. package/dist/scan-dashboard.js +351 -92
  382. package/dist/scan-dashboard.js.map +1 -1
  383. package/dist/scan-history-renderer.d.ts.map +1 -1
  384. package/dist/scan-history-renderer.js +55 -15
  385. package/dist/scan-history-renderer.js.map +1 -1
  386. package/dist/scan-inputs.d.ts +6 -0
  387. package/dist/scan-inputs.d.ts.map +1 -0
  388. package/dist/scan-inputs.js +71 -0
  389. package/dist/scan-inputs.js.map +1 -0
  390. package/dist/scan-logs.d.ts +2 -3
  391. package/dist/scan-logs.d.ts.map +1 -1
  392. package/dist/scan-logs.js +14 -12
  393. package/dist/scan-logs.js.map +1 -1
  394. package/dist/scan-sessions.d.ts +4 -0
  395. package/dist/scan-sessions.d.ts.map +1 -1
  396. package/dist/scan-sessions.js +18 -3
  397. package/dist/scan-sessions.js.map +1 -1
  398. package/dist/scan-settings.d.ts +5 -0
  399. package/dist/scan-settings.d.ts.map +1 -1
  400. package/dist/scan-settings.js +4 -0
  401. package/dist/scan-settings.js.map +1 -1
  402. package/dist/scan-skill-paths.d.ts +8 -0
  403. package/dist/scan-skill-paths.d.ts.map +1 -0
  404. package/dist/scan-skill-paths.js +47 -0
  405. package/dist/scan-skill-paths.js.map +1 -0
  406. package/dist/security-policy-cli.d.ts.map +1 -1
  407. package/dist/security-policy-cli.js +15 -33
  408. package/dist/security-policy-cli.js.map +1 -1
  409. package/dist/security-policy.d.ts +17 -9
  410. package/dist/security-policy.d.ts.map +1 -1
  411. package/dist/security-policy.js +131 -98
  412. package/dist/security-policy.js.map +1 -1
  413. package/dist/server/api.d.ts +0 -1
  414. package/dist/server/api.d.ts.map +1 -1
  415. package/dist/server/api.js +0 -1
  416. package/dist/server/api.js.map +1 -1
  417. package/dist/server/embeddings.d.ts +3 -1
  418. package/dist/server/embeddings.d.ts.map +1 -1
  419. package/dist/server/embeddings.js +11 -3
  420. package/dist/server/embeddings.js.map +1 -1
  421. package/dist/server/errors.d.ts +5 -2
  422. package/dist/server/errors.d.ts.map +1 -1
  423. package/dist/server/errors.js +7 -0
  424. package/dist/server/errors.js.map +1 -1
  425. package/dist/server/sqlite-store.d.ts +0 -2
  426. package/dist/server/sqlite-store.d.ts.map +1 -1
  427. package/dist/server/sqlite-store.js +55 -55
  428. package/dist/server/sqlite-store.js.map +1 -1
  429. package/dist/server/storage.d.ts +0 -2
  430. package/dist/server/storage.d.ts.map +1 -1
  431. package/dist/server/storage.js.map +1 -1
  432. package/dist/severity-store.js +20 -32
  433. package/dist/severity-store.js.map +1 -1
  434. package/dist/standalone-validation-prompt.d.ts +2 -0
  435. package/dist/standalone-validation-prompt.d.ts.map +1 -0
  436. package/dist/standalone-validation-prompt.js +10 -0
  437. package/dist/standalone-validation-prompt.js.map +1 -0
  438. package/dist/suggest-owners.d.ts +6 -5
  439. package/dist/suggest-owners.d.ts.map +1 -1
  440. package/dist/suggest-owners.js +15 -10
  441. package/dist/suggest-owners.js.map +1 -1
  442. package/dist/targets.d.ts +12 -0
  443. package/dist/targets.d.ts.map +1 -1
  444. package/dist/targets.js +124 -62
  445. package/dist/targets.js.map +1 -1
  446. package/dist/trusted-executable.d.ts +6 -1
  447. package/dist/trusted-executable.d.ts.map +1 -1
  448. package/dist/trusted-executable.js +28 -9
  449. package/dist/trusted-executable.js.map +1 -1
  450. package/dist/value.d.ts +2 -0
  451. package/dist/value.d.ts.map +1 -0
  452. package/dist/value.js +27 -0
  453. package/dist/value.js.map +1 -0
  454. package/dist/version.d.ts.map +1 -1
  455. package/dist/version.js +3 -6
  456. package/dist/version.js.map +1 -1
  457. package/dist/windows-path.d.ts.map +1 -1
  458. package/dist/windows-path.js +1 -2
  459. package/dist/windows-path.js.map +1 -1
  460. package/dist/workbench-arguments.d.ts +3 -0
  461. package/dist/workbench-arguments.d.ts.map +1 -0
  462. package/dist/workbench-arguments.js +15 -0
  463. package/dist/workbench-arguments.js.map +1 -0
  464. package/dist/worker-progress.d.ts +2 -0
  465. package/dist/worker-progress.d.ts.map +1 -1
  466. package/dist/worker-progress.js +40 -46
  467. package/dist/worker-progress.js.map +1 -1
  468. package/docs/cli.md +1778 -0
  469. package/docs/dedupe-records.md +24 -0
  470. package/docs/findings-service.md +402 -0
  471. package/package.json +23 -23
  472. package/schemas/project-config.schema.json +5 -0
  473. package/_bundled_plugin/schemas/tools/worker-threat-model.schema.json +0 -18
  474. package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
  475. package/_bundled_plugin/scripts/workbench_dashboard.py +0 -159
  476. package/_bundled_plugin/scripts/workbench_findings.py +0 -221
  477. package/_bundled_plugin/scripts/workbench_severity.py +0 -119
  478. package/_bundled_plugin/skills/assess-patch-risk/scripts/validate_patch_risk_assessment.py +0 -163
  479. package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +0 -276
  480. package/dist/server/dashboard/app.css +0 -2
  481. package/dist/server/dashboard/app.js +0 -66
  482. package/dist/server/dashboard/index.html +0 -18
  483. package/dist/server/dashboard-types.d.ts +0 -48
  484. package/dist/server/dashboard-types.d.ts.map +0 -1
  485. package/dist/server/dashboard-types.js +0 -2
  486. package/dist/server/dashboard-types.js.map +0 -1
  487. package/dist/server/dashboard.d.ts +0 -6
  488. package/dist/server/dashboard.d.ts.map +0 -1
  489. package/dist/server/dashboard.js +0 -59
  490. package/dist/server/dashboard.js.map +0 -1
  491. package/dist/server/findings-service.d.ts +0 -20
  492. package/dist/server/findings-service.d.ts.map +0 -1
  493. package/dist/server/findings-service.js +0 -31
  494. package/dist/server/findings-service.js.map +0 -1
  495. package/dist/server/index.d.ts +0 -2
  496. package/dist/server/index.d.ts.map +0 -1
  497. package/dist/server/index.js +0 -6
  498. package/dist/server/index.js.map +0 -1
  499. package/dist/server/routes.d.ts +0 -6
  500. package/dist/server/routes.d.ts.map +0 -1
  501. package/dist/server/routes.js +0 -86
  502. package/dist/server/routes.js.map +0 -1
  503. package/dist/server/serve.d.ts +0 -2
  504. package/dist/server/serve.d.ts.map +0 -1
  505. package/dist/server/serve.js +0 -28
  506. package/dist/server/serve.js.map +0 -1
  507. package/dist/server/server.d.ts +0 -10
  508. package/dist/server/server.d.ts.map +0 -1
  509. package/dist/server/server.js +0 -17
  510. package/dist/server/server.js.map +0 -1
  511. package/dist/server/validation.d.ts +0 -17
  512. package/dist/server/validation.d.ts.map +0 -1
  513. package/dist/server/validation.js +0 -53
  514. package/dist/server/validation.js.map +0 -1
@@ -1,8 +1,12 @@
1
1
  import { basename, isAbsolute } from "node:path";
2
+ import { emitKeypressEvents } from "node:readline";
3
+ import { PassThrough } from "node:stream";
2
4
  import { pathToFileURL } from "node:url";
3
- import { stripVTControlCharacters } from "node:util";
5
+ import stripAnsi from "strip-ansi";
6
+ import stringWidth from "string-width";
7
+ import { isRecord } from "./record.js";
4
8
  import { formatUsd } from "./cost.js";
5
- import { estimateScanCost, formatScanCost, formatScanCosts, formatScanCostTokens, } from "./cost-model.js";
9
+ import { estimateScanCost, formatScanCost, formatScanCosts, formatScanCostTokens, formatTokenUsage, } from "./cost-model.js";
6
10
  import { scanPhaseLabel } from "./worker-progress.js";
7
11
  const HIDE_CURSOR = "\u001B[?25l";
8
12
  const SHOW_CURSOR = "\u001B[?25h";
@@ -43,14 +47,17 @@ export class ScanDashboard {
43
47
  #showComponent = false;
44
48
  #componentResult = null;
45
49
  #activities = [];
50
+ #activityCache = new WeakMap();
46
51
  #details = [];
47
52
  #detailsCache = null;
48
53
  #stage = "Preparing scan";
49
54
  #files = null;
50
55
  #publicationProgress = null;
51
56
  #cost = null;
57
+ #tokens = null;
52
58
  #budget = null;
53
59
  #timer = null;
60
+ #refreshPending = false;
54
61
  #scrollOffset = 0;
55
62
  #view = "activity";
56
63
  #source = "all";
@@ -58,11 +65,119 @@ export class ScanDashboard {
58
65
  #noteCount = 0;
59
66
  #observingStreamErrors = false;
60
67
  #onStreamError = () => { };
68
+ #keyInput = null;
69
+ #ss3Parameters = false;
70
+ #inputKeys = null;
61
71
  #onInput = (chunk) => {
62
- const input = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
72
+ const batch = {
73
+ keys: [],
74
+ continued: false,
75
+ replay: false,
76
+ text: "",
77
+ };
78
+ let current = chunk;
79
+ do {
80
+ batch.replay = false;
81
+ this.#inputKeys = batch;
82
+ try {
83
+ this.#keyInput?.write(current);
84
+ }
85
+ finally {
86
+ this.#inputKeys = null;
87
+ }
88
+ if (typeof batch.replay === "string")
89
+ current = batch.replay;
90
+ } while (batch.replay);
91
+ this.#handleKeys(batch.keys);
92
+ };
93
+ #setKeyInput(input) {
94
+ const previous = this.#keyInput;
95
+ if (previous !== null) {
96
+ previous.removeAllListeners("keypress");
97
+ previous.on("keypress", () => { });
98
+ // Readline clears its Escape timer on input, after the active keypress returns.
99
+ queueMicrotask(() => {
100
+ previous.write(" ");
101
+ previous.removeAllListeners();
102
+ previous.destroy();
103
+ });
104
+ }
105
+ this.#keyInput = input;
106
+ if (input === null)
107
+ return;
108
+ let pending = 0;
109
+ this.#ss3Parameters = false;
110
+ input.setEncoding("utf8");
111
+ input.on("data", (text) => {
112
+ if (this.#inputKeys !== null) {
113
+ this.#inputKeys.continued = pending > 0;
114
+ this.#inputKeys.text = text;
115
+ }
116
+ pending += text.length;
117
+ });
118
+ emitKeypressEvents(input);
119
+ input.on("keypress", (_text, key) => {
120
+ pending -= key.sequence.length;
121
+ if (this.#ss3Parameters) {
122
+ if (/^[ -?]+$/u.test(key.sequence))
123
+ return;
124
+ this.#ss3Parameters = false;
125
+ if (/^[@-~]$/u.test(key.sequence))
126
+ return;
127
+ }
128
+ const escapes = key.code === undefined
129
+ ? undefined
130
+ : key.sequence.match(/^\u001B+(?=\u001B)/u)?.[0];
131
+ // Readline ends modified SS3 keys at the parameter separator.
132
+ const modifiedSs3 = key.code !== undefined &&
133
+ /^\u001BO[0-?]+$/u.test(key.sequence.slice(escapes?.length ?? 0));
134
+ if (modifiedSs3)
135
+ this.#ss3Parameters = true;
136
+ const keys = modifiedSs3
137
+ ? [...(escapes ?? ""), key.sequence.slice(escapes?.length ?? 0)]
138
+ : key.code !== undefined && key.sequence.endsWith("\u001B")
139
+ ? ["\u001B"]
140
+ : (key.meta && key.code === undefined) ||
141
+ key.sequence.includes("\u0003")
142
+ ? Array.from(key.sequence)
143
+ : escapes !== undefined
144
+ ? [...escapes, key.sequence.slice(escapes.length)]
145
+ : [key.sequence];
146
+ const batch = this.#inputKeys;
147
+ const continued = batch?.continued === true;
148
+ if (batch !== null)
149
+ batch.continued = false;
150
+ if (batch === null)
151
+ this.#handleKeys(keys);
152
+ else if (this.#budget !== null &&
153
+ batch.keys.length === 0 &&
154
+ keys.length > 1 &&
155
+ keys[0] === "\u001B" &&
156
+ continued) {
157
+ // The buffered Escape belongs to the prior chunk's budget dismissal.
158
+ // Replay the complete remaining key, including a prefix from prior chunks.
159
+ this.#handleKeys(["\u001B"]);
160
+ this.#setKeyInput(new PassThrough());
161
+ batch.replay =
162
+ key.sequence.slice(1) + (pending ? batch.text.slice(-pending) : "");
163
+ }
164
+ else if (keys.length > 1 && keys.every((key) => key === "\u001B")) {
165
+ // Readline can consume a following key's Escape as a repeated Escape.
166
+ // Keep that introducer with the remaining decoded text for replay.
167
+ const remaining = key.sequence + (pending ? batch.text.slice(-pending) : "");
168
+ const prefix = remaining.match(/^\u001B+/u)[0];
169
+ for (const escape of prefix.slice(0, -1))
170
+ batch.keys.push(escape);
171
+ this.#setKeyInput(new PassThrough());
172
+ batch.replay = remaining.slice(prefix.length - 1);
173
+ }
174
+ else
175
+ batch.keys.push(...keys);
176
+ });
177
+ }
178
+ #handleKeys(keys) {
63
179
  if (this.#budget !== null) {
64
- for (const key of input.match(/\u001B\[[0-?]*[ -/]*[@-~]|[\s\S]/gu) ??
65
- []) {
180
+ for (const key of keys) {
66
181
  const budget = this.#budget;
67
182
  if (budget === null)
68
183
  break;
@@ -71,7 +186,7 @@ export class ScanDashboard {
71
186
  this.#options.onInterrupt?.();
72
187
  }
73
188
  else if (key === "\u001B") {
74
- budget.finish();
189
+ budget.finish(undefined, true);
75
190
  }
76
191
  else if (key === "\r" || key === "\n") {
77
192
  const value = budget.input.trim();
@@ -98,11 +213,11 @@ export class ScanDashboard {
98
213
  return;
99
214
  }
100
215
  if (this.#options.presentation === "components") {
101
- this.#componentInput(input);
216
+ this.#componentInput(keys);
102
217
  return;
103
218
  }
104
219
  let lines = 0;
105
- for (const key of input.match(/[\u0003\u0004\u0015dam1-9]|\u001B\[(?:[ABHF]|[1456]~)/gu) ?? []) {
220
+ for (const key of keys) {
106
221
  if (key === "\u0003") {
107
222
  if (lines !== 0)
108
223
  this.scroll(lines);
@@ -146,7 +261,7 @@ export class ScanDashboard {
146
261
  else if (key === "\u001B[6~") {
147
262
  lines -= this.#activityRows();
148
263
  }
149
- else {
264
+ else if (["\u001B[H", "\u001B[F", "\u001B[1~", "\u001B[4~"].includes(key)) {
150
265
  if (lines !== 0)
151
266
  this.scroll(lines);
152
267
  this.scroll(key === "\u001B[H" || key === "\u001B[1~"
@@ -157,7 +272,7 @@ export class ScanDashboard {
157
272
  }
158
273
  if (lines !== 0)
159
274
  this.scroll(lines);
160
- };
275
+ }
161
276
  constructor(stream, options) {
162
277
  this.#stream = stream;
163
278
  this.#options = options;
@@ -178,12 +293,13 @@ export class ScanDashboard {
178
293
  }
179
294
  this.#stream.write(`${ENTER_ALTERNATE_SCREEN}${HIDE_CURSOR}`);
180
295
  if (input?.isTTY === true) {
296
+ this.#setKeyInput(new PassThrough());
181
297
  input.setRawMode?.(true);
182
298
  input.resume?.();
183
299
  input.on("data", this.#onInput);
184
300
  this.#stream.write(ENABLE_ALTERNATE_SCROLL);
185
301
  }
186
- this.#render();
302
+ this.#stream.write(this.#frame());
187
303
  }
188
304
  catch (error) {
189
305
  try {
@@ -201,6 +317,8 @@ export class ScanDashboard {
201
317
  stop() {
202
318
  if (this.#timer === null)
203
319
  return;
320
+ if (this.#refreshPending)
321
+ this.#refresh();
204
322
  this.#options.clock.clearInterval(this.#timer);
205
323
  this.#timer = null;
206
324
  this.#budget?.finish();
@@ -208,6 +326,7 @@ export class ScanDashboard {
208
326
  try {
209
327
  if (input?.isTTY === true) {
210
328
  input.off("data", this.#onInput);
329
+ this.#setKeyInput(null);
211
330
  input.setRawMode?.(this.#inputWasRaw);
212
331
  input.pause?.();
213
332
  }
@@ -290,6 +409,9 @@ export class ScanDashboard {
290
409
  case "cost":
291
410
  dashboard.setCost(event.value);
292
411
  break;
412
+ case "usage":
413
+ dashboard.setUsage(event.value);
414
+ break;
293
415
  case "workers":
294
416
  if (event.value.kind === "dispatch")
295
417
  dashboard.setStage(scanPhaseLabel(event.value.phase));
@@ -298,7 +420,7 @@ export class ScanDashboard {
298
420
  dashboard.note(event.value);
299
421
  break;
300
422
  }
301
- this.#refresh();
423
+ this.#scheduleRefresh();
302
424
  }
303
425
  showComponents(stage) {
304
426
  this.#showComponent = false;
@@ -306,10 +428,8 @@ export class ScanDashboard {
306
428
  }
307
429
  finishComponents(result) {
308
430
  this.#componentResult = result;
309
- this.showComponents(result.failed ||
310
- result.incomplete ||
311
- result.deduplication?.status === "incomplete"
312
- ? "Finished with partial results"
431
+ this.showComponents(result.failed || result.deduplication?.status === "failed"
432
+ ? "Finished with errors"
313
433
  : "Complete");
314
434
  }
315
435
  setFiles(files) {
@@ -322,9 +442,14 @@ export class ScanDashboard {
322
442
  }
323
443
  setCost(cost, maxCostUsd = this.#options.maxCostUsd) {
324
444
  this.#cost = cost;
445
+ this.#tokens = formatScanCostTokens(cost);
325
446
  this.#options.maxCostUsd = maxCostUsd;
326
447
  this.#refresh();
327
448
  }
449
+ setUsage(usage) {
450
+ this.#tokens = formatTokenUsage(usage);
451
+ this.#refresh();
452
+ }
328
453
  requestBudgetIncrease(request) {
329
454
  if (request.signal.aborted ||
330
455
  this.#timer === null ||
@@ -332,11 +457,14 @@ export class ScanDashboard {
332
457
  this.#budget !== null) {
333
458
  return Promise.resolve(undefined);
334
459
  }
460
+ this.#setKeyInput(new PassThrough());
335
461
  return new Promise((resolve) => {
336
462
  const abort = () => finish();
337
- const finish = (limit) => {
463
+ const finish = (limit, preserveInput = false) => {
338
464
  request.signal.removeEventListener("abort", abort);
339
465
  this.#budget = null;
466
+ if (this.#timer !== null && !preserveInput)
467
+ this.#setKeyInput(new PassThrough());
340
468
  this.#refresh();
341
469
  resolve(limit);
342
470
  };
@@ -376,7 +504,7 @@ export class ScanDashboard {
376
504
  if (this.#scrollOffset !== 0) {
377
505
  this.#scrollOffset += Math.max(0, this.#activityLines(this.#width()).length - previousRows);
378
506
  }
379
- this.#refresh();
507
+ this.#scheduleRefresh();
380
508
  }
381
509
  recordDetails(session) {
382
510
  const previousRows = this.#view === "details" && this.#scrollOffset !== 0
@@ -399,7 +527,7 @@ export class ScanDashboard {
399
527
  if (this.#scrollOffset !== 0) {
400
528
  this.#scrollOffset += Math.max(0, this.#activityLines(this.#width()).length - previousRows);
401
529
  }
402
- this.#refresh();
530
+ this.#scheduleRefresh();
403
531
  }
404
532
  }
405
533
  scroll(lines) {
@@ -411,12 +539,18 @@ export class ScanDashboard {
411
539
  if (this.#timer === null)
412
540
  return;
413
541
  try {
414
- this.#render();
542
+ this.#stream.write(this.#frame());
415
543
  }
416
544
  catch { }
417
545
  }
418
- #render() {
419
- this.#stream.write(this.#frame());
546
+ #scheduleRefresh() {
547
+ if (this.#timer === null || this.#refreshPending)
548
+ return;
549
+ this.#refreshPending = true;
550
+ (this.#options.clock.queueMicrotask ?? queueMicrotask)(() => {
551
+ this.#refreshPending = false;
552
+ this.#refresh();
553
+ });
420
554
  }
421
555
  #frame() {
422
556
  if (this.#options.presentation === "components") {
@@ -435,7 +569,9 @@ export class ScanDashboard {
435
569
  const time = formatElapsed(elapsed);
436
570
  const files = this.#files === null
437
571
  ? "waiting for inventory"
438
- : `${formatCount(this.#files.filesCompleted)} / ${formatCount(this.#files.filesTotal)} reviewed`;
572
+ : this.#files.filesCompleted > 0
573
+ ? `${formatCount(this.#files.filesCompleted)} / ${formatCount(this.#files.filesTotal)} reviewed`
574
+ : `${formatCount(this.#files.filesTotal)} in scope`;
439
575
  const history = this.#activityLines(width);
440
576
  const maximumOffset = Math.max(0, history.length - activityRows);
441
577
  this.#scrollOffset = Math.min(this.#scrollOffset, maximumOffset);
@@ -462,7 +598,7 @@ export class ScanDashboard {
462
598
  if (this.#options.componentName !== undefined)
463
599
  scrollStatus = `Esc components · ${scrollStatus}`;
464
600
  const model = this.#options.model;
465
- const lines = [
601
+ return this.#formatFrame([
466
602
  ` CODEX SECURITY · ${publication ? "PUBLISH · " : verification ? "VERIFY-FIX · " : ""}${basename(this.#options.repository)}${this.#options.componentName === undefined ? "" : ` · ${this.#options.componentName}`}${model === undefined ? "" : ` · ${model.model} (${model.reasoningEffort})`}${this.#view === "details" ? ` · DETAILS${this.#source === "all" ? "" : ` · ${typeof this.#source === "number" ? `worker ${this.#source}` : this.#source}`}` : ""}`,
467
603
  divider,
468
604
  ...activity,
@@ -486,8 +622,7 @@ export class ScanDashboard {
486
622
  ]),
487
623
  ]),
488
624
  ` TIME ${time} · ${this.#budget === null ? scrollStatus : "Enter to apply · Ctrl+C to exit"}`,
489
- ];
490
- return this.#formatFrame(lines);
625
+ ]);
491
626
  }
492
627
  #formatFrame(lines) {
493
628
  const width = this.#width();
@@ -495,9 +630,7 @@ export class ScanDashboard {
495
630
  lines
496
631
  .map((line, index) => {
497
632
  const text = typeof line === "string" ? line : line.text;
498
- const clean = fitLine(typeof line !== "string" && this.#view === "details"
499
- ? text
500
- : (this.#options.sanitize?.(text) ?? text), width);
633
+ const clean = fitLine(text, width);
501
634
  const colored = this.#options.color === true
502
635
  ? styleLine(clean, typeof line === "string"
503
636
  ? index === 0
@@ -509,13 +642,13 @@ export class ScanDashboard {
509
642
  ? colored
510
643
  : linkActivity(this.#options.color === true
511
644
  ? styleInlineCode(colored, line)
512
- : colored, line.links, this.#options.sanitize);
645
+ : colored, line.links, line.contentStart);
513
646
  return `${ERASE_LINE}${formatted}`;
514
647
  })
515
648
  .join("\n"));
516
649
  }
517
- #componentInput(input) {
518
- for (const key of input.match(/\u001B\[(?:[ABHF]|[1456]~)|[\u0003\u0004\u0015\r\n\u001Bbdam1-9]/gu) ?? []) {
650
+ #componentInput(keys) {
651
+ for (const key of keys) {
519
652
  if (key === "\u0003") {
520
653
  this.#options.onInterrupt?.();
521
654
  }
@@ -523,7 +656,9 @@ export class ScanDashboard {
523
656
  if (key === "\u001B" || key === "b")
524
657
  this.#showComponent = false;
525
658
  else
526
- this.#components[this.#selectedComponent].dashboard.#onInput(key);
659
+ this.#components[this.#selectedComponent].dashboard.#handleKeys([
660
+ key,
661
+ ]);
527
662
  }
528
663
  else if ((key === "\r" || key === "\n") &&
529
664
  this.#components.length > 0) {
@@ -557,7 +692,11 @@ export class ScanDashboard {
557
692
  const first = Math.max(0, Math.min(this.#selectedComponent - Math.floor(rows / 2), this.#components.length - rows));
558
693
  const costWidth = Math.max(8, ...this.#components.map(({ dashboard }) => dashboard.#cost === null ? 1 : formatScanCost(dashboard.#cost).length));
559
694
  const nameWidth = Math.max(10, width - 52 - (this.#showCost ? costWidth + 1 : 0));
560
- const row = (marker, name, status, files, findings, cost) => ` ${marker} ${fitLine(this.#options.sanitize?.(name) ?? name, nameWidth).padEnd(nameWidth)} ${fitLine(status, 24).padEnd(24)} ${files.padStart(11)} ${findings.padStart(8)}${this.#showCost ? ` ${cost.padStart(8)}` : ""}`;
695
+ const cell = (value, width) => {
696
+ const text = fitLine(value, width);
697
+ return text + " ".repeat(width - stringWidth(text));
698
+ };
699
+ const row = (marker, name, status, files, findings, cost) => ` ${marker} ${cell(name, nameWidth)} ${cell(status, 24)} ${files.padStart(11)} ${findings.padStart(8)}${this.#showCost ? ` ${cost.padStart(8)}` : ""}`;
561
700
  const table = this.#components
562
701
  .slice(first, first + rows)
563
702
  .map(({ receipt, dashboard }, index) => {
@@ -580,12 +719,12 @@ export class ScanDashboard {
580
719
  const rawFindings = this.#components.reduce((sum, { receipt }) => sum + (receipt.findingCount ?? 0), 0);
581
720
  const findings = this.#componentResult === null
582
721
  ? `${rawFindings} findings before deduplication`
583
- : `${this.#componentResult.sourceFindingCount} findings → ${this.#componentResult.findingCount} groups${this.#componentResult.deduplication?.status === "incomplete" ? " · matching incomplete" : ""}`;
722
+ : `${this.#componentResult.sourceFindingCount} findings → ${this.#componentResult.findingCount} groups${this.#componentResult.deduplication?.status === "failed" ? " · matching failed" : ""}`;
584
723
  const divider = ` ${"─".repeat(Math.max(0, width - 4))}`;
585
724
  return this.#formatFrame([
586
725
  ` CODEX SECURITY · COMPONENTS · ${basename(this.#options.repository)}`,
587
726
  divider,
588
- ` ${count("completed")} complete · ${count("started")} running · ${count("pending")} queued · ${count("incomplete")} incomplete · ${count("failed")} failed`,
727
+ ` ${count("completed")} complete · ${count("started")} running · ${count("pending")} queued · ${count("failed")} failed`,
589
728
  "",
590
729
  row(" ", "Component", "Status", "Files", "Findings", "Cost"),
591
730
  ...table,
@@ -617,29 +756,31 @@ export class ScanDashboard {
617
756
  this.#options.presentation === "verification"
618
757
  ? 0
619
758
  : this.#tokenLines().length - 1 + this.#costLines().length - 1) +
620
- (this.#options.presentation === "publication"
759
+ (this.#options.presentation === "publication" ||
760
+ this.#options.presentation === "verification"
621
761
  ? 2
622
762
  : this.#options.mode === "deep"
623
763
  ? 2
624
764
  : 0));
625
765
  }
626
766
  #tokenLines() {
627
- const tokens = this.#cost === null
628
- ? "waiting for usage"
629
- : formatScanCostTokens(this.#cost);
767
+ const tokens = this.#tokens ?? "waiting for usage";
630
768
  return wrapActivity(" TOKENS ", tokens, this.#width());
631
769
  }
632
770
  #costLines() {
633
771
  if (!this.#showCost)
634
772
  return [];
773
+ if (this.#cost === null &&
774
+ this.#options.maxCostUsd === undefined &&
775
+ estimateScanCost(this.#options.model?.model, {
776
+ input_tokens: 0,
777
+ output_tokens: 0,
778
+ }) === null) {
779
+ return [];
780
+ }
635
781
  const cost = this.#cost === null
636
782
  ? this.#options.maxCostUsd === undefined
637
- ? estimateScanCost(this.#options.model?.model, {
638
- input_tokens: 0,
639
- output_tokens: 0,
640
- }) === null
641
- ? "unavailable (model pricing missing)"
642
- : "waiting for usage"
783
+ ? "waiting for usage"
643
784
  : `— / ${formatUsd(this.#options.maxCostUsd)}`
644
785
  : `${formatScanCost(this.#cost)}${this.#options.maxCostUsd === undefined ? "" : `; short-context budget baseline: ${formatUsd(this.#cost.estimatedUsd)} / ${formatUsd(this.#options.maxCostUsd)} · ${budgetBar(this.#cost.estimatedUsd, this.#options.maxCostUsd)}`}`;
645
786
  return wrapActivity(" COST ", cost, this.#width());
@@ -701,7 +842,7 @@ export class ScanDashboard {
701
842
  cache.summaries.delete(threadId);
702
843
  }
703
844
  const source = worker === undefined ? "main" : `worker ${worker}`;
704
- const prefix = ` [${formatLocalTime(recordedAt)}] ${source} · `;
845
+ const prefix = fitActivityPrefix(` [${formatLocalTime(recordedAt)}] ${source} · `, width);
705
846
  const code = [];
706
847
  const bold = [];
707
848
  if (prose) {
@@ -716,7 +857,13 @@ export class ScanDashboard {
716
857
  ? wrapActivity(prefix, description, width)
717
858
  : paragraphs.flatMap((line, index) => wrapCode(index === 0 ? prefix : " ".repeat(prefix.length), line, width));
718
859
  for (const text of lines) {
719
- cache.lines.push({ text, kind: "path", code, bold });
860
+ cache.lines.push({
861
+ text,
862
+ kind: "path",
863
+ code,
864
+ bold,
865
+ contentStart: prefix.length,
866
+ });
720
867
  }
721
868
  }
722
869
  return cache.lines;
@@ -724,8 +871,8 @@ export class ScanDashboard {
724
871
  const elapsed = Math.max(0, Math.floor((this.#options.clock.now() - this.#startedAt) / 1_000));
725
872
  const runningIcon = ["◐", "◓", "◑", "◒"][elapsed % 4];
726
873
  const lines = [];
727
- const append = (prefix, value, kind) => {
728
- value = this.#options.sanitize?.(value) ?? value;
874
+ const append = (prefix, value, kind, generatedPrefix = "") => {
875
+ prefix = fitActivityPrefix(prefix, width);
729
876
  if (kind !== "message" && kind !== "reasoning") {
730
877
  for (const text of wrapActivity(prefix, value, width)) {
731
878
  lines.push({ text, kind });
@@ -756,7 +903,16 @@ export class ScanDashboard {
756
903
  ? wrapCode(started ? continuation : prefix, description, width)
757
904
  : wrapActivity(started ? continuation : prefix, description, width);
758
905
  for (const text of wrapped) {
759
- lines.push({ text, kind: fenced ? "code" : kind, links, code });
906
+ lines.push({
907
+ text,
908
+ kind: fenced ? "code" : kind,
909
+ links,
910
+ code,
911
+ contentStart: prefix.length + generatedPrefix.length,
912
+ });
913
+ generatedPrefix = generatedPrefix
914
+ .slice(text.length - prefix.length)
915
+ .trimStart();
760
916
  started = true;
761
917
  }
762
918
  }
@@ -772,13 +928,25 @@ export class ScanDashboard {
772
928
  : entry.status === "running"
773
929
  ? runningIcon
774
930
  : ACTIVITY_MARKERS[kind];
931
+ const cached = this.#activityCache.get(entry);
932
+ if (cached?.width === width && cached.icon === icon) {
933
+ for (const line of cached.lines)
934
+ lines.push(line);
935
+ continue;
936
+ }
937
+ const first = lines.length;
775
938
  const timestamp = `[${formatLocalTime(entry.recordedAt)}]`;
776
939
  const worker = entry.worker === undefined ? "" : `worker ${entry.worker} · `;
777
940
  const prefix = ` ${timestamp} ${icon} `;
778
- append(prefix, `${worker}${entry.description}`, kind);
941
+ append(prefix, `${worker}${entry.description}`, kind, worker);
779
942
  for (const path of entry.paths) {
780
943
  append(" ".repeat(prefix.length), path, "path");
781
944
  }
945
+ this.#activityCache.set(entry, {
946
+ width,
947
+ icon,
948
+ lines: lines.slice(first),
949
+ });
782
950
  }
783
951
  return lines;
784
952
  }
@@ -810,8 +978,7 @@ function detailsDescription(event) {
810
978
  if (itemType === "token_count")
811
979
  return undefined;
812
980
  if (itemType === "message" || itemType === "agent_message") {
813
- const role = typeof payload["role"] === "string" ? payload["role"] : "assistant";
814
- return `${role}: ${detailsText(payload["content"] ?? payload["message"])}`;
981
+ return `${typeof payload["role"] === "string" ? payload["role"] : "assistant"}: ${detailsText(payload["content"] ?? payload["message"])}`;
815
982
  }
816
983
  if (itemType === "reasoning" || itemType.startsWith("agent_reasoning")) {
817
984
  const text = detailsText(payload["summary"] ?? payload["text"] ?? payload["delta"]);
@@ -841,23 +1008,40 @@ function detailsText(value) {
841
1008
  .flatMap((item) => isRecord(item) && typeof item["text"] === "string" ? [item["text"]] : [])
842
1009
  .join("\n");
843
1010
  }
844
- function isRecord(value) {
845
- return typeof value === "object" && value !== null && !Array.isArray(value);
1011
+ function replaceVisibleText(value, search, replacement, contentStart = 0) {
1012
+ let replaced = false;
1013
+ let offset = 0;
1014
+ return value
1015
+ .split(/(\u001B\[[0-?]*[ -/]*[@-~]|\u001B\][\s\S]*?(?:\u0007|\u001B\\))/gu)
1016
+ .map((part, index) => {
1017
+ if (index % 2 === 1)
1018
+ return part;
1019
+ const start = Math.max(0, contentStart - offset);
1020
+ offset += part.length;
1021
+ if (replaced || start >= part.length)
1022
+ return part;
1023
+ return (part.slice(0, start) +
1024
+ part.slice(start).replace(search, () => {
1025
+ replaced = true;
1026
+ return replacement;
1027
+ }));
1028
+ })
1029
+ .join("");
846
1030
  }
847
1031
  function styleInlineCode(value, line) {
848
1032
  for (const text of line.bold ?? []) {
849
- value = value.replace(text, `\u001B[1m${text}\u001B[22m`);
1033
+ value = replaceVisibleText(value, text, `\u001B[1m${text}\u001B[22m`, line.contentStart);
850
1034
  }
851
1035
  for (const text of line.code ?? []) {
852
- value = value.replace(text, `\u001B[2m${text}\u001B[22m${line.kind === "message" ? "\u001B[1m" : ""}`);
1036
+ value = replaceVisibleText(value, text, `\u001B[2m${text}\u001B[22m${line.kind === "message" ? "\u001B[1m" : ""}`, line.contentStart);
853
1037
  }
854
1038
  return value;
855
1039
  }
856
- function linkActivity(value, links, sanitize) {
1040
+ function linkActivity(value, links, contentStart) {
857
1041
  for (const { label, target } of links ?? []) {
858
- const safe = safeHyperlinkTarget(sanitize?.(target) ?? target);
1042
+ const safe = safeHyperlinkTarget(target);
859
1043
  if (safe !== undefined) {
860
- value = value.replace(label, `\u001B]8;;${safe}\u0007${label}\u001B]8;;\u0007`);
1044
+ value = replaceVisibleText(value, label, `\u001B]8;;${safe}\u0007${label}\u001B]8;;\u0007`, contentStart);
861
1045
  }
862
1046
  }
863
1047
  return value;
@@ -887,7 +1071,6 @@ function componentStatus(receipt) {
887
1071
  pending: "Queued",
888
1072
  started: "Running",
889
1073
  completed: "Complete",
890
- incomplete: "Incomplete",
891
1074
  failed: "Failed",
892
1075
  }[receipt.status];
893
1076
  }
@@ -897,8 +1080,12 @@ function formatLocalTime(timestamp) {
897
1080
  .map((part) => String(part).padStart(2, "0"))
898
1081
  .join(":");
899
1082
  }
1083
+ function fitActivityPrefix(prefix, width) {
1084
+ return width <= 2 ? "" : fitLine(prefix, width - 2);
1085
+ }
900
1086
  function wrapActivity(prefix, value, width) {
901
- const available = Math.max(1, width - prefix.length);
1087
+ prefix = fitActivityPrefix(prefix, width);
1088
+ const available = Math.max(1, width - stringWidth(prefix));
902
1089
  const continuation = " ".repeat(prefix.length);
903
1090
  const lines = [];
904
1091
  const append = (text) => {
@@ -906,36 +1093,50 @@ function wrapActivity(prefix, value, width) {
906
1093
  };
907
1094
  let current = "";
908
1095
  let separator = "";
909
- for (const word of value.split(/(\s+)/u)) {
1096
+ let currentWidth = 0;
1097
+ const widths = new Map();
1098
+ const wrappedWords = new Map();
1099
+ const text = terminalText(value);
1100
+ const segments = graphemes.segment(text);
1101
+ let offset = 0;
1102
+ for (const word of text.split(/(\s+)/u)) {
1103
+ const start = offset;
1104
+ offset += word.length;
910
1105
  if (/^\s+$/u.test(word)) {
911
1106
  separator = word;
912
1107
  continue;
913
1108
  }
914
- const characters = Array.from(word);
915
- if (characters.length > available) {
1109
+ const ascii = /^[\u0020-\u007E]*$/u.test(word);
1110
+ let parts = ascii ? undefined : wrappedWords.get(word);
1111
+ if (!ascii && parts === undefined) {
1112
+ parts = columnChunks(word, available, widths, segments, start);
1113
+ wrappedWords.set(word, parts);
1114
+ }
1115
+ const wordWidth = ascii
1116
+ ? word.length
1117
+ : parts.length > 1
1118
+ ? available + 1
1119
+ : parts[0].columns;
1120
+ if (wordWidth > available) {
916
1121
  if (current !== "") {
917
1122
  append(current);
918
1123
  current = "";
919
1124
  }
920
- for (let start = 0; start < characters.length; start += available) {
921
- const part = characters.slice(start, start + available).join("");
922
- if (start + available < characters.length) {
923
- append(part);
924
- }
925
- else {
926
- current = part;
927
- }
928
- }
1125
+ const chunks = parts ?? columnChunks(word, available, widths, segments, start);
1126
+ const last = chunks.at(-1);
1127
+ current = last.text;
1128
+ currentWidth = last.columns;
1129
+ for (let index = 0; index < chunks.length - 1; index++)
1130
+ append(chunks[index].text);
929
1131
  }
930
1132
  else if (current !== "" &&
931
- Array.from(current).length +
932
- Array.from(separator).length +
933
- characters.length >
934
- available) {
1133
+ currentWidth + stringWidth(separator) + wordWidth > available) {
935
1134
  append(current);
936
1135
  current = word;
1136
+ currentWidth = wordWidth;
937
1137
  }
938
1138
  else {
1139
+ currentWidth += (current === "" ? 0 : stringWidth(separator)) + wordWidth;
939
1140
  current = current === "" ? word : `${current}${separator}${word}`;
940
1141
  }
941
1142
  separator = "";
@@ -944,12 +1145,62 @@ function wrapActivity(prefix, value, width) {
944
1145
  append(current);
945
1146
  return lines;
946
1147
  }
1148
+ const graphemes = new Intl.Segmenter();
1149
+ function columnChunks(value, width, widths = new Map(), segments = graphemes.segment(value), offset = 0) {
1150
+ const parts = [];
1151
+ let current = "";
1152
+ let columns = 0;
1153
+ const append = (text, size) => {
1154
+ if (current !== "" && columns + size > width) {
1155
+ parts.push({ text: current, columns });
1156
+ current = "";
1157
+ columns = 0;
1158
+ }
1159
+ current += text;
1160
+ columns += size;
1161
+ };
1162
+ const appendGraphemes = (start, end) => {
1163
+ while (start < end) {
1164
+ const next = segments.containing(offset + start);
1165
+ const boundary = Math.min(end, next.index + next.segment.length - offset);
1166
+ const segment = value.slice(start, boundary);
1167
+ let size = widths.get(segment);
1168
+ if (size === undefined) {
1169
+ size = stringWidth(segment);
1170
+ widths.set(segment, size);
1171
+ }
1172
+ append(segment, size);
1173
+ start = boundary;
1174
+ }
1175
+ };
1176
+ let cursor = 0;
1177
+ for (const match of value.matchAll(/[\u0020-\u007E]{2,}/gu)) {
1178
+ // Keep edge characters with Unicode that can attach to their grapheme.
1179
+ appendGraphemes(cursor, match.index + 1);
1180
+ let start = match.index + 1;
1181
+ const end = match.index + match[0].length - 1;
1182
+ while (start < end) {
1183
+ if (columns >= width) {
1184
+ parts.push({ text: current, columns });
1185
+ current = "";
1186
+ columns = 0;
1187
+ }
1188
+ const size = Math.min(width - columns, end - start);
1189
+ append(value.slice(start, start + size), size);
1190
+ start += size;
1191
+ }
1192
+ cursor = end;
1193
+ }
1194
+ appendGraphemes(cursor, value.length);
1195
+ if (current !== "" || parts.length === 0)
1196
+ parts.push({ text: current, columns });
1197
+ return parts;
1198
+ }
947
1199
  function wrapCode(prefix, value, width) {
948
- const characters = Array.from(value);
949
- const available = Math.max(1, width - prefix.length);
950
- return Array.from({ length: Math.max(1, Math.ceil(characters.length / available)) }, (_, index) => `${index === 0 ? prefix : " ".repeat(prefix.length)}${characters
951
- .slice(index * available, (index + 1) * available)
952
- .join("")}`);
1200
+ prefix = fitActivityPrefix(prefix, width);
1201
+ const prefixWidth = stringWidth(prefix);
1202
+ const continuation = " ".repeat(prefixWidth);
1203
+ return columnChunks(terminalText(value), Math.max(1, width - prefixWidth)).map((part, index) => `${index === 0 ? prefix : continuation}${part.text}`);
953
1204
  }
954
1205
  function styleLine(value, kind, details = false) {
955
1206
  if (details) {
@@ -985,9 +1236,7 @@ function styleLine(value, kind, details = false) {
985
1236
  if (kind === "status" || kind === "warning") {
986
1237
  return `${prefix}\u001B[${style}m${marker}${separator}${description}\u001B[0m`;
987
1238
  }
988
- const workerLabel = worker === undefined ? "" : `\u001B[36m${worker}\u001B[39m`;
989
- const prose = kind === "message" ? `\u001B[1m${description}\u001B[22m` : description;
990
- return `${prefix}\u001B[${style}m${marker}\u001B[39m${separator}${workerLabel}${prose}`;
1239
+ return `${prefix}\u001B[${style}m${marker}\u001B[39m${separator}${worker === undefined ? "" : `\u001B[36m${worker}\u001B[39m`}${kind === "message" ? `\u001B[1m${description}\u001B[22m` : description}`;
991
1240
  }
992
1241
  return `\u001B[${style}m${value}\u001B[0m`;
993
1242
  }
@@ -999,11 +1248,21 @@ function budgetBar(cost, limit) {
999
1248
  const filled = Math.round(proportion * 12);
1000
1249
  return `[${"█".repeat(filled)}${"░".repeat(12 - filled)}] ${Math.round(proportion * 100)}%`;
1001
1250
  }
1251
+ function terminalText(value) {
1252
+ return stripAnsi(value).replaceAll(/[\u0000-\u001F\u007F]/gu, " ");
1253
+ }
1002
1254
  function fitLine(value, width) {
1003
- const clean = stripVTControlCharacters(value).replaceAll(/[\u0000-\u001F\u007F]/gu, " ");
1004
- const characters = Array.from(clean);
1005
- return characters.length <= width
1006
- ? clean
1007
- : `${characters.slice(0, Math.max(0, width - 1)).join("")}…`;
1255
+ const clean = terminalText(value);
1256
+ if (stringWidth(clean) <= width)
1257
+ return clean;
1258
+ let clipped = "";
1259
+ let columns = 0;
1260
+ for (const { segment } of graphemes.segment(clean)) {
1261
+ columns += stringWidth(segment);
1262
+ if (columns > width - 1)
1263
+ break;
1264
+ clipped += segment;
1265
+ }
1266
+ return `${clipped}…`;
1008
1267
  }
1009
1268
  //# sourceMappingURL=scan-dashboard.js.map