@openai/codex-security 0.8.2 → 0.8.3

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 (375) hide show
  1. package/README.md +43 -61
  2. package/_bundled_plugin/.app.json +4 -0
  3. package/_bundled_plugin/.mcp.json +1 -0
  4. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  14. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +46 -12
  15. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  16. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  17. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  18. package/_bundled_plugin/references/artifact-storage.md +1 -1
  19. package/_bundled_plugin/references/core-scan.md +14 -5
  20. package/_bundled_plugin/references/default-severity-rubric.md +28 -0
  21. package/_bundled_plugin/references/finding-detail-fields.md +1 -0
  22. package/_bundled_plugin/references/threat-model.md +1 -0
  23. package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
  24. package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
  25. package/_bundled_plugin/scripts/finding_preview.py +5 -29
  26. package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
  27. package/_bundled_plugin/scripts/report_projection.py +87 -136
  28. package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
  29. package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
  30. package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
  31. package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
  32. package/_bundled_plugin/scripts/workbench_cli.py +102 -13
  33. package/_bundled_plugin/scripts/workbench_constants.py +9 -0
  34. package/_bundled_plugin/scripts/workbench_db.py +186 -360
  35. package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
  36. package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
  37. package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
  38. package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
  39. package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
  40. package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
  41. package/_bundled_plugin/scripts/workbench_schema.py +1 -1
  42. package/_bundled_plugin/scripts/workbench_setup.py +239 -0
  43. package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
  44. package/_bundled_plugin/scripts/workbench_target.py +213 -20
  45. package/_bundled_plugin/scripts/workbench_validation.py +1 -9
  46. package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
  47. package/_bundled_plugin/shared/workbench-migrations.json +19 -0
  48. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
  49. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
  50. package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
  51. package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
  52. package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
  53. package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
  54. package/_bundled_plugin/skills/publish-findings/SKILL.md +64 -35
  55. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
  56. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +14 -8
  57. package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
  58. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
  59. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
  60. package/dist/api.d.ts +6 -1
  61. package/dist/api.d.ts.map +1 -1
  62. package/dist/api.js +411 -160
  63. package/dist/api.js.map +1 -1
  64. package/dist/auth.js +6 -1
  65. package/dist/auth.js.map +1 -1
  66. package/dist/blackduck-findings.d.ts +8 -0
  67. package/dist/blackduck-findings.d.ts.map +1 -0
  68. package/dist/blackduck-findings.js +305 -0
  69. package/dist/blackduck-findings.js.map +1 -0
  70. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  71. package/dist/bulk-scan-discovery.js +51 -36
  72. package/dist/bulk-scan-discovery.js.map +1 -1
  73. package/dist/classify-severity-records.d.ts +5 -0
  74. package/dist/classify-severity-records.d.ts.map +1 -1
  75. package/dist/classify-severity-records.js +6 -8
  76. package/dist/classify-severity-records.js.map +1 -1
  77. package/dist/classify-severity.d.ts +4 -1
  78. package/dist/classify-severity.d.ts.map +1 -1
  79. package/dist/classify-severity.js +28 -9
  80. package/dist/classify-severity.js.map +1 -1
  81. package/dist/cli.d.ts +3 -0
  82. package/dist/cli.d.ts.map +1 -1
  83. package/dist/cli.js +608 -258
  84. package/dist/cli.js.map +1 -1
  85. package/dist/codex-prompt.d.ts +2 -0
  86. package/dist/codex-prompt.d.ts.map +1 -1
  87. package/dist/codex-prompt.js +6 -0
  88. package/dist/codex-prompt.js.map +1 -1
  89. package/dist/component-scan.d.ts.map +1 -1
  90. package/dist/component-scan.js +6 -5
  91. package/dist/component-scan.js.map +1 -1
  92. package/dist/config.d.ts +2 -1
  93. package/dist/config.d.ts.map +1 -1
  94. package/dist/config.js +162 -40
  95. package/dist/config.js.map +1 -1
  96. package/dist/continuum-findings.d.ts +7 -0
  97. package/dist/continuum-findings.d.ts.map +1 -0
  98. package/dist/continuum-findings.js +157 -0
  99. package/dist/continuum-findings.js.map +1 -0
  100. package/dist/contract-values.d.ts +28 -0
  101. package/dist/contract-values.d.ts.map +1 -0
  102. package/dist/contract-values.js +75 -0
  103. package/dist/contract-values.js.map +1 -0
  104. package/dist/contract.d.ts +2 -20
  105. package/dist/contract.d.ts.map +1 -1
  106. package/dist/contract.js +58 -669
  107. package/dist/contract.js.map +1 -1
  108. package/dist/cost-model.d.ts.map +1 -1
  109. package/dist/cost-model.js +1 -4
  110. package/dist/cost-model.js.map +1 -1
  111. package/dist/cost.d.ts +19 -1
  112. package/dist/cost.d.ts.map +1 -1
  113. package/dist/cost.js +2120 -39
  114. package/dist/cost.js.map +1 -1
  115. package/dist/custom-validation-prompt.d.ts +1 -1
  116. package/dist/custom-validation-prompt.d.ts.map +1 -1
  117. package/dist/custom-validation-prompt.js +5 -0
  118. package/dist/custom-validation-prompt.js.map +1 -1
  119. package/dist/custom-validation.d.ts +2 -0
  120. package/dist/custom-validation.d.ts.map +1 -1
  121. package/dist/custom-validation.js +4 -0
  122. package/dist/custom-validation.js.map +1 -1
  123. package/dist/deduplication/deduplication-prompts.d.ts +4 -4
  124. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  125. package/dist/deduplication/deduplication-prompts.js +2 -2
  126. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  127. package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
  128. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  129. package/dist/deduplication/deduplication-reviewer.js +11 -4
  130. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  131. package/dist/deduplication/deduplication.js.map +1 -1
  132. package/dist/deduplication/finding-schema.d.ts +19 -1
  133. package/dist/deduplication/finding-schema.d.ts.map +1 -1
  134. package/dist/deduplication/finding-schema.js +25 -0
  135. package/dist/deduplication/finding-schema.js.map +1 -1
  136. package/dist/deduplication/local.d.ts.map +1 -1
  137. package/dist/deduplication/local.js +3 -8
  138. package/dist/deduplication/local.js.map +1 -1
  139. package/dist/deduplication/records.d.ts +8 -2
  140. package/dist/deduplication/records.d.ts.map +1 -1
  141. package/dist/deduplication/records.js +36 -8
  142. package/dist/deduplication/records.js.map +1 -1
  143. package/dist/deep-scan.d.ts +11 -0
  144. package/dist/deep-scan.d.ts.map +1 -1
  145. package/dist/deep-scan.js +235 -4
  146. package/dist/deep-scan.js.map +1 -1
  147. package/dist/default-severity-rubric.d.ts +1 -2
  148. package/dist/default-severity-rubric.d.ts.map +1 -1
  149. package/dist/default-severity-rubric.js +2 -66
  150. package/dist/default-severity-rubric.js.map +1 -1
  151. package/dist/endor-findings.d.ts.map +1 -1
  152. package/dist/endor-findings.js +7 -37
  153. package/dist/endor-findings.js.map +1 -1
  154. package/dist/errors.js +1 -1
  155. package/dist/errors.js.map +1 -1
  156. package/dist/external-findings-import.d.ts.map +1 -1
  157. package/dist/external-findings-import.js +5 -11
  158. package/dist/external-findings-import.js.map +1 -1
  159. package/dist/external-findings-local.d.ts +9 -0
  160. package/dist/external-findings-local.d.ts.map +1 -1
  161. package/dist/external-findings-local.js +325 -179
  162. package/dist/external-findings-local.js.map +1 -1
  163. package/dist/external-findings-publish.d.ts +12 -0
  164. package/dist/external-findings-publish.d.ts.map +1 -1
  165. package/dist/external-findings-publish.js +1202 -214
  166. package/dist/external-findings-publish.js.map +1 -1
  167. package/dist/external-findings-read.d.ts +8 -0
  168. package/dist/external-findings-read.d.ts.map +1 -1
  169. package/dist/external-findings-read.js +65 -54
  170. package/dist/external-findings-read.js.map +1 -1
  171. package/dist/external-findings.d.ts +2 -0
  172. package/dist/external-findings.d.ts.map +1 -1
  173. package/dist/external-findings.js +111 -0
  174. package/dist/external-findings.js.map +1 -1
  175. package/dist/external-import-contract.d.ts +29 -1
  176. package/dist/external-import-contract.d.ts.map +1 -1
  177. package/dist/external-import-contract.js +314 -44
  178. package/dist/external-import-contract.js.map +1 -1
  179. package/dist/external-import-models.d.ts +1 -1
  180. package/dist/external-import-models.d.ts.map +1 -1
  181. package/dist/external-import-models.js.map +1 -1
  182. package/dist/finding-normalization.d.ts +1 -1
  183. package/dist/finding-normalization.d.ts.map +1 -1
  184. package/dist/finding-normalization.js +46 -11
  185. package/dist/finding-normalization.js.map +1 -1
  186. package/dist/finding-retrieval.d.ts +3 -3
  187. package/dist/finding-retrieval.d.ts.map +1 -1
  188. package/dist/finding-retrieval.js.map +1 -1
  189. package/dist/finding-workflow.d.ts +6 -1
  190. package/dist/finding-workflow.d.ts.map +1 -1
  191. package/dist/finding-workflow.js +2 -2
  192. package/dist/finding-workflow.js.map +1 -1
  193. package/dist/git-remote.d.ts +4 -0
  194. package/dist/git-remote.d.ts.map +1 -1
  195. package/dist/git-remote.js +20 -0
  196. package/dist/git-remote.js.map +1 -1
  197. package/dist/github-advisories.d.ts +3 -12
  198. package/dist/github-advisories.d.ts.map +1 -1
  199. package/dist/github-advisories.js +9 -29
  200. package/dist/github-advisories.js.map +1 -1
  201. package/dist/github-dependabot-findings.d.ts.map +1 -1
  202. package/dist/github-dependabot-findings.js +7 -16
  203. package/dist/github-dependabot-findings.js.map +1 -1
  204. package/dist/github-findings.d.ts.map +1 -1
  205. package/dist/github-findings.js +344 -56
  206. package/dist/github-findings.js.map +1 -1
  207. package/dist/github.d.ts +17 -7
  208. package/dist/github.d.ts.map +1 -1
  209. package/dist/github.js +43 -30
  210. package/dist/github.js.map +1 -1
  211. package/dist/host-protocol.d.ts +2 -2
  212. package/dist/host-protocol.d.ts.map +1 -1
  213. package/dist/host-protocol.js.map +1 -1
  214. package/dist/host-records-protocol.d.ts +10 -11
  215. package/dist/host-records-protocol.d.ts.map +1 -1
  216. package/dist/host-records-protocol.js +69 -9
  217. package/dist/host-records-protocol.js.map +1 -1
  218. package/dist/hosted-scan.d.ts +15 -0
  219. package/dist/hosted-scan.d.ts.map +1 -1
  220. package/dist/hosted-scan.js +55 -33
  221. package/dist/hosted-scan.js.map +1 -1
  222. package/dist/index.d.ts +7 -0
  223. package/dist/index.d.ts.map +1 -1
  224. package/dist/index.js +6 -0
  225. package/dist/index.js.map +1 -1
  226. package/dist/inspector-findings.d.ts.map +1 -1
  227. package/dist/inspector-findings.js +13 -18
  228. package/dist/inspector-findings.js.map +1 -1
  229. package/dist/knowledge-base.js +18 -5
  230. package/dist/knowledge-base.js.map +1 -1
  231. package/dist/local-git-metadata.d.ts +5 -0
  232. package/dist/local-git-metadata.d.ts.map +1 -0
  233. package/dist/local-git-metadata.js +131 -0
  234. package/dist/local-git-metadata.js.map +1 -0
  235. package/dist/multiscan.d.ts.map +1 -1
  236. package/dist/multiscan.js +22 -12
  237. package/dist/multiscan.js.map +1 -1
  238. package/dist/opengrep-findings.d.ts.map +1 -1
  239. package/dist/opengrep-findings.js +34 -20
  240. package/dist/opengrep-findings.js.map +1 -1
  241. package/dist/patch-tui.d.ts.map +1 -1
  242. package/dist/patch-tui.js +90 -35
  243. package/dist/patch-tui.js.map +1 -1
  244. package/dist/private-finding-import.d.ts +246 -0
  245. package/dist/private-finding-import.d.ts.map +1 -0
  246. package/dist/private-finding-import.js +387 -0
  247. package/dist/private-finding-import.js.map +1 -0
  248. package/dist/project-config.d.ts.map +1 -1
  249. package/dist/project-config.js +2 -2
  250. package/dist/project-config.js.map +1 -1
  251. package/dist/provider-profile.d.ts +10 -2
  252. package/dist/provider-profile.d.ts.map +1 -1
  253. package/dist/provider-profile.js +72 -10
  254. package/dist/provider-profile.js.map +1 -1
  255. package/dist/publication.js +7 -1
  256. package/dist/publication.js.map +1 -1
  257. package/dist/reader-selection.d.ts +13 -0
  258. package/dist/reader-selection.d.ts.map +1 -0
  259. package/dist/reader-selection.js +81 -0
  260. package/dist/reader-selection.js.map +1 -0
  261. package/dist/record.d.ts +6 -1
  262. package/dist/record.d.ts.map +1 -1
  263. package/dist/record.js +53 -2
  264. package/dist/record.js.map +1 -1
  265. package/dist/remediation.d.ts +5 -0
  266. package/dist/remediation.d.ts.map +1 -1
  267. package/dist/remediation.js +30 -0
  268. package/dist/remediation.js.map +1 -1
  269. package/dist/result.d.ts +2 -0
  270. package/dist/result.d.ts.map +1 -1
  271. package/dist/result.js +3 -1
  272. package/dist/result.js.map +1 -1
  273. package/dist/runtime.d.ts +2 -1
  274. package/dist/runtime.d.ts.map +1 -1
  275. package/dist/runtime.js +95 -52
  276. package/dist/runtime.js.map +1 -1
  277. package/dist/scan-activity.js +40 -17
  278. package/dist/scan-activity.js.map +1 -1
  279. package/dist/scan-comparison.d.ts +1 -1
  280. package/dist/scan-comparison.d.ts.map +1 -1
  281. package/dist/scan-comparison.js +11 -13
  282. package/dist/scan-comparison.js.map +1 -1
  283. package/dist/scan-dashboard.d.ts +1 -0
  284. package/dist/scan-dashboard.d.ts.map +1 -1
  285. package/dist/scan-dashboard.js +16 -37
  286. package/dist/scan-dashboard.js.map +1 -1
  287. package/dist/scan-executor.d.ts +2 -0
  288. package/dist/scan-executor.d.ts.map +1 -1
  289. package/dist/scan-executor.js.map +1 -1
  290. package/dist/scan-history-renderer.d.ts.map +1 -1
  291. package/dist/scan-history-renderer.js +22 -9
  292. package/dist/scan-history-renderer.js.map +1 -1
  293. package/dist/scan-logs.d.ts.map +1 -1
  294. package/dist/scan-logs.js +5 -5
  295. package/dist/scan-logs.js.map +1 -1
  296. package/dist/scanner-import.d.ts +46 -6
  297. package/dist/scanner-import.d.ts.map +1 -1
  298. package/dist/scanner-import.js +208 -42
  299. package/dist/scanner-import.js.map +1 -1
  300. package/dist/scanner-repository-url.d.ts +14 -0
  301. package/dist/scanner-repository-url.d.ts.map +1 -0
  302. package/dist/scanner-repository-url.js +67 -0
  303. package/dist/scanner-repository-url.js.map +1 -0
  304. package/dist/semgrep-findings.d.ts.map +1 -1
  305. package/dist/semgrep-findings.js +20 -48
  306. package/dist/semgrep-findings.js.map +1 -1
  307. package/dist/semgrep-platform-findings.d.ts +12 -0
  308. package/dist/semgrep-platform-findings.d.ts.map +1 -0
  309. package/dist/semgrep-platform-findings.js +198 -0
  310. package/dist/semgrep-platform-findings.js.map +1 -0
  311. package/dist/severity-rubric.d.ts +20 -0
  312. package/dist/severity-rubric.d.ts.map +1 -0
  313. package/dist/severity-rubric.js +73 -0
  314. package/dist/severity-rubric.js.map +1 -0
  315. package/dist/severity-store.js +15 -5
  316. package/dist/severity-store.js.map +1 -1
  317. package/dist/snyk-findings.d.ts.map +1 -1
  318. package/dist/snyk-findings.js +21 -20
  319. package/dist/snyk-findings.js.map +1 -1
  320. package/dist/sonar-collector.d.ts +16 -0
  321. package/dist/sonar-collector.d.ts.map +1 -0
  322. package/dist/sonar-collector.js +383 -0
  323. package/dist/sonar-collector.js.map +1 -0
  324. package/dist/sonar-findings.d.ts +49 -0
  325. package/dist/sonar-findings.d.ts.map +1 -0
  326. package/dist/sonar-findings.js +288 -0
  327. package/dist/sonar-findings.js.map +1 -0
  328. package/dist/sonar-import.d.ts +111 -0
  329. package/dist/sonar-import.d.ts.map +1 -0
  330. package/dist/sonar-import.js +279 -0
  331. package/dist/sonar-import.js.map +1 -0
  332. package/dist/suggest-owners.d.ts.map +1 -1
  333. package/dist/suggest-owners.js +2 -1
  334. package/dist/suggest-owners.js.map +1 -1
  335. package/dist/targets.d.ts +3 -0
  336. package/dist/targets.d.ts.map +1 -1
  337. package/dist/targets.js +18 -12
  338. package/dist/targets.js.map +1 -1
  339. package/dist/terminal-columns.d.ts +4 -0
  340. package/dist/terminal-columns.d.ts.map +1 -0
  341. package/dist/terminal-columns.js +19 -0
  342. package/dist/terminal-columns.js.map +1 -0
  343. package/dist/validation-records.d.ts +0 -3
  344. package/dist/validation-records.d.ts.map +1 -1
  345. package/dist/validation-records.js +0 -16
  346. package/dist/validation-records.js.map +1 -1
  347. package/dist/veracode-findings.d.ts +7 -0
  348. package/dist/veracode-findings.d.ts.map +1 -0
  349. package/dist/veracode-findings.js +371 -0
  350. package/dist/veracode-findings.js.map +1 -0
  351. package/dist/windows-path.d.ts.map +1 -1
  352. package/dist/windows-path.js +1 -0
  353. package/dist/windows-path.js.map +1 -1
  354. package/dist/wiz-csv.d.ts +2 -2
  355. package/dist/wiz-csv.d.ts.map +1 -1
  356. package/dist/wiz-csv.js +1 -3
  357. package/dist/wiz-csv.js.map +1 -1
  358. package/dist/wiz-findings.d.ts +10 -2
  359. package/dist/wiz-findings.d.ts.map +1 -1
  360. package/dist/wiz-findings.js +88 -49
  361. package/dist/wiz-findings.js.map +1 -1
  362. package/docs/classify-severity-records.md +1 -1
  363. package/docs/cli.md +310 -477
  364. package/docs/dedupe-records.md +10 -0
  365. package/docs/findings-service.md +21 -8
  366. package/docs/hosted-scans.md +16 -1
  367. package/package.json +8 -9
  368. package/schemas/external-findings.schema.json +12 -1
  369. package/schemas/hosted-scan-v2.fixture.json +16 -1
  370. package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
  371. package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
  372. package/dist/deduplication/records-protocol.d.ts +0 -4
  373. package/dist/deduplication/records-protocol.d.ts.map +0 -1
  374. package/dist/deduplication/records-protocol.js +0 -49
  375. package/dist/deduplication/records-protocol.js.map +0 -1
@@ -66,6 +66,16 @@ must describe the actual source; it does not authorize additional repository
66
66
  access. Unknown extension fields are preserved. This does not require creating
67
67
  scan manifests or other saved-scan artifacts.
68
68
 
69
+ For an imported observation, set `"kind": "imported"` on its entry alongside
70
+ `id` and `finding`. Supply the actual source in `finding.provenance.source`
71
+ and retain original source references and evidence as extensions. Imported
72
+ findings may omit `ruleId`, `identity`, `taxonomy`, and `remediation`. If
73
+ there is no known repository line, supply an empty `locations` array and
74
+ preserve any file-level evidence in the original source data. All other
75
+ Finding requirements apply. Entries without a kind use the full Finding
76
+ schema. A SAME review must return a merged finding that satisfies the schema
77
+ of the assigned canonical original.
78
+
69
79
  Observation IDs are host-owned, nonempty strings, unique within `observations`.
70
80
  Supply the pending observations and their retrieved neighbors together as original
71
81
  observations. Each `candidateRelationships` entry selects one anchor to process;
@@ -310,7 +310,10 @@ Use `--scan` for a saved scan, `--scan-dir` for an external scan directory, or
310
310
  the interactive picker. Custom publication accepts one scan; CSV input and
311
311
  Linear options do not apply. Add `--dry-run` to preview the payload without an
312
312
  HTTP request. Upload failures and incomplete receipts fail the command. Uploads
313
- are not automatically retried because a lost response may have been committed.
313
+ are not automatically retried because the receiver may have committed a request
314
+ whose response was lost. Resuming publication or remote dedupe in a workflow
315
+ without its receipt resends the entire sealed batch. Before resuming, ask the
316
+ receiver to confirm that replaying that exact request is safe.
314
317
 
315
318
  ```typescript
316
319
  import { publishScanToCustom } from "@openai/codex-security";
@@ -396,13 +399,23 @@ and JSON on stdin. For example, `request.json` selects the existing database:
396
399
  Use an absolute Windows path on Windows. The retained helper commands accept
397
400
  these `payload` fields:
398
401
 
399
- | Command | Payload |
400
- | --------------------------- | ------------------------------------------------------------------------------------------------------- |
401
- | `store-findings` | `entries` containing finding and embedding records; optional `repositoryId`. |
402
- | `list-stored-findings` | Positive integer `limit` and non-negative integer `offset`. |
403
- | `find-potential-duplicates` | `findingId` and `scope`: either `{ "repositoryId": "REPOSITORY_ID" }` or `{ "allRepositories": true }`. |
404
- | `store-dedupe-groups` | `groups`, an array of finding-ID arrays. |
405
- | `list-dedupe-groups` | `findingId`. |
402
+ | Command | Payload |
403
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
404
+ | `store-findings` | `entries` containing finding and embedding records; optional `repositoryId`. |
405
+ | `list-stored-findings` | Positive integer `limit` and non-negative integer `offset`. |
406
+ | `find-potential-duplicates` | `findingId` and `scope`: either `{ "repositoryId": "REPOSITORY_ID" }` or `{ "allRepositories": true }`. |
407
+ | `store-dedupe-groups` | `groups`, an array of finding-ID arrays. |
408
+ | `list-dedupe-groups` | `findingId`. |
409
+ | `local-dedupe` | `action: "prepare"` with `findings`, `repositoryPath`, `anchorRepositoryId`, optional `repositoryId`, and `space`; or `action: "embed"` with `entries`, `space`, `model`, and `dimensions`. |
410
+
411
+ Local embedding preparation and cache writes now use the bundled Node helper
412
+ instead of `workbench_db.py local-dedupe`. Each embed entry contains `findingId`,
413
+ the preparation response's `cacheKey`, and an `embedding` with `model` and
414
+ `vector`. Preparation returns `cacheKeys` and `findingsToEmbed`; embedding returns
415
+ an empty object. These operations use Node even when `PYTHON` is configured.
416
+ Explicitly selected external plugins retain their Python workbench route.
417
+ Saved-scan lookup and export still require Python, so the complete saved-scan
418
+ deduplication workflow continues to need it.
406
419
 
407
420
  Retained scan commands such as `workbench_db.py list-findings` keep their existing
408
421
  interface.
@@ -74,6 +74,18 @@ Standard scan lifecycle. Omit `scope` for the entire repository, or pass literal
74
74
  repository-relative folders/files. Model settings come from the frozen input;
75
75
  local profiles and other local scan options are not accepted.
76
76
 
77
+ To supply grading rules, pass `severityRubric` with the Markdown text in
78
+ `markdown`, a positive integer `revision`, and the lowercase `sha256` digest of
79
+ the exact UTF-8 text, including any trailing newline. The SDK verifies the digest
80
+ before dispatch, includes the rubric in the model prompt, and echoes the snapshot
81
+ in `execution.run` and the terminal scan receipt. Omit the field to use the
82
+ existing Standard scan grading rules.
83
+
84
+ When a logical run spans multiple attempts, save the selected snapshot in the
85
+ host's durable run state before starting its first CLI process. Send that saved
86
+ snapshot with every subsequent attempt for the same run, including attempts in
87
+ a fresh checkout or container. A configuration change then applies to new runs.
88
+
77
89
  Set `ownerSuggestions: true` to record ownership evidence during the existing
78
90
  scan execution. The scan agent may include an optional hint on each finding:
79
91
 
@@ -271,7 +283,10 @@ with `{id: <original run RPC id>, event}`. Invalid optional event payloads are
271
283
  ignored; mismatched request IDs are rejected. Stdout contains JSON-RPC only.
272
284
 
273
285
  Send `{"jsonrpc":"2.0","method":"cancel","params":{"id":"run"}}` with the
274
- original run request ID. The CLI aborts its executor signal, emits
286
+ original run request ID. If canceled during checkout verification, the CLI returns
287
+ a canceled receipt with the requested checkout, scope, and rubric before starting
288
+ the executor. Invalid request fields still return a JSON-RPC error.
289
+ After dispatch the CLI aborts its executor signal, emits
275
290
  `execution.cancel` with `{requestId}`, and waits for the host's outcome/usage
276
291
  before returning a canceled result. The host must continue reading notifications
277
292
  while executing. SIGINT/SIGTERM, output errors/closure, and cancellation with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openai/codex-security",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "TypeScript SDK and CLI for Codex Security",
5
5
  "license": "Apache-2.0",
6
6
  "author": "OpenAI",
@@ -60,8 +60,8 @@
60
60
  "@inquirer/prompts": "8.7.4",
61
61
  "@linear/sdk": "99.0.0",
62
62
  "@octokit/core": "7.0.8",
63
- "@openai/codex": "0.165.0",
64
- "@openai/codex-sdk": "0.165.0",
63
+ "@openai/codex": "0.166.0",
64
+ "@openai/codex-sdk": "0.166.0",
65
65
  "ajv": "8.20.0",
66
66
  "fflate": "0.8.3",
67
67
  "incur": "0.7.1",
@@ -80,8 +80,8 @@
80
80
  "zod": "4.6.7"
81
81
  },
82
82
  "devDependencies": {
83
- "@stryker-mutator/core": "10.0.0",
84
- "@types/bun": "1.4.3",
83
+ "@stryker-mutator/core": "10.1.1",
84
+ "@types/bun": "1.4.4",
85
85
  "@types/node": "26.6.5",
86
86
  "@types/papaparse": "5.5.2",
87
87
  "@types/react": "19.3.0",
@@ -92,15 +92,14 @@
92
92
  "ink-testing-library": "4.0.0",
93
93
  "json-schema-to-typescript": "16.0.0",
94
94
  "json5": "2.2.3",
95
- "minimatch": "10.2.6",
96
95
  "prettier": "3.9.10",
97
96
  "typescript": "7.0.2"
98
97
  },
99
- "gitHead": "79ff4bde8a4685b9c31ad8f449bdb40df8f468f7",
98
+ "gitHead": "e5d5f2c7d4986c5aeb3bb773dfbd334dfee47d2d",
100
99
  "scripts": {
101
100
  "audit:prod": "pnpm audit --prod --audit-level high",
102
101
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
103
- "build": "node --run clean && node scripts/generate-deep-defaults.mjs && tsc -p tsconfig.build.json && node scripts/generate-project-config-schema.mjs",
102
+ "build": "node --run clean && node scripts/generate-plugin-defaults.mjs && tsc -p tsconfig.build.json && node scripts/generate-project-config-schema.mjs",
104
103
  "build:ci": "tsc -p tsconfig.ci.json",
105
104
  "build:evals": "node --run build && tsc -p ../../evals/tsconfig.json",
106
105
  "build:examples": "tsc -p tsconfig.examples.json",
@@ -118,6 +117,6 @@
118
117
  "test:mcp": "node --run build:plugin && pnpm --dir ../../plugins/codex-security/mcp-app run test:mcp",
119
118
  "test:mutation": "stryker run",
120
119
  "test:package": "node scripts/smoke-package.mjs",
121
- "types": "node scripts/generate-deep-defaults.mjs --check && node scripts/generate-project-config-schema.mjs --check && pnpm run generate:models:check && pnpm run generate:external-import-models:check && pnpm --dir ../../plugins/codex-security/mcp-app run typecheck && tsc --noEmit"
120
+ "types": "node scripts/generate-plugin-defaults.mjs --check && node scripts/generate-project-config-schema.mjs --check && pnpm run generate:models:check && pnpm run generate:external-import-models:check && pnpm --dir ../../plugins/codex-security/mcp-app run typecheck && tsc --noEmit"
122
121
  }
123
122
  }
@@ -378,7 +378,18 @@
378
378
  "additionalProperties": false,
379
379
  "properties": {
380
380
  "provider": {
381
- "enum": ["wiz", "endor", "snyk", "github", "semgrep", "inspector"],
381
+ "enum": [
382
+ "wiz",
383
+ "endor",
384
+ "snyk",
385
+ "github",
386
+ "semgrep",
387
+ "inspector",
388
+ "blackduck",
389
+ "veracode",
390
+ "sonar",
391
+ "continuum"
392
+ ],
382
393
  "title": "Provider",
383
394
  "type": "string"
384
395
  },
@@ -14,6 +14,11 @@
14
14
  "stateDirectory": "/scan/state",
15
15
  "model": "fixture-model",
16
16
  "reasoningEffort": "medium",
17
+ "severityRubric": {
18
+ "markdown": "# Security team rubric\n\nGrade the impact on the affected tenant.\n",
19
+ "revision": 3,
20
+ "sha256": "0735ad8680e64cc58dae0f2ac171cfbe98816494176fe95ca28b122476b61cfa"
21
+ },
17
22
  "identity": {
18
23
  "runId": "run-1",
19
24
  "attemptId": "attempt-1",
@@ -39,9 +44,14 @@
39
44
  },
40
45
  "model": "fixture-model",
41
46
  "reasoningEffort": "medium",
47
+ "severityRubric": {
48
+ "markdown": "# Security team rubric\n\nGrade the impact on the affected tenant.\n",
49
+ "revision": 3,
50
+ "sha256": "0735ad8680e64cc58dae0f2ac171cfbe98816494176fe95ca28b122476b61cfa"
51
+ },
42
52
  "requestId": "request-1",
43
53
  "scanId": "scan-1",
44
- "prompt": "Scan the selected paths.",
54
+ "prompt": "Scan the selected paths using the supplied severity rubric.\n{\"severityRubric\":{\"markdown\":\"# Security team rubric\\n\\nGrade the impact on the affected tenant.\\n\",\"revision\":3,\"sha256\":\"0735ad8680e64cc58dae0f2ac171cfbe98816494176fe95ca28b122476b61cfa\"}}",
45
55
  "runtime": {
46
56
  "pluginRoot": "/opt/runtime/cli/_bundled_plugin",
47
57
  "pluginVersion": "0.1.95",
@@ -99,6 +109,11 @@
99
109
  "attemptId": "attempt-1",
100
110
  "buildId": "fixture-build"
101
111
  },
112
+ "severityRubric": {
113
+ "markdown": "# Security team rubric\n\nGrade the impact on the affected tenant.\n",
114
+ "revision": 3,
115
+ "sha256": "0735ad8680e64cc58dae0f2ac171cfbe98816494176fe95ca28b122476b61cfa"
116
+ },
102
117
  "outputDirectory": "/scan/output",
103
118
  "status": "completed",
104
119
  "scanId": "scan-1",
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Validate a sealed scan and list or select findings for tracking."""
3
-
4
- from __future__ import annotations
5
-
6
- import argparse
7
- import sys
8
- from pathlib import Path
9
- from typing import Any
10
-
11
- # Keep sibling helpers importable when Python starts in isolated mode.
12
- sys.path.insert(0, str(Path(__file__).resolve().parent))
13
- import validate_scan_contract as SCAN_CONTRACT
14
-
15
- FINALIZER = SCAN_CONTRACT.FINALIZER
16
- validate_contract = SCAN_CONTRACT.validate_contract
17
-
18
-
19
- def _select_findings(
20
- findings: list[dict[str, Any]],
21
- finding_id: str | None,
22
- fingerprint: str | None,
23
- ) -> list[dict[str, Any]]:
24
- if finding_id is not None:
25
- matches = [finding for finding in findings if finding["findingId"] == finding_id]
26
- elif fingerprint is not None:
27
- matches = [
28
- finding for finding in findings if finding["fingerprints"]["primary"] == fingerprint
29
- ]
30
- else:
31
- return findings
32
-
33
- if len(matches) != 1:
34
- raise ValueError("the selector did not resolve exactly one finding")
35
- return matches
36
-
37
-
38
- def validate_source(
39
- scan_dir: Path,
40
- *,
41
- finding_id: str | None = None,
42
- fingerprint: str | None = None,
43
- ) -> list[dict[str, Any]]:
44
- if finding_id is not None and fingerprint is not None:
45
- raise ValueError("use only one of --finding-id or --fingerprint")
46
-
47
- validated = validate_contract(scan_dir)
48
- findings_document = validated["findings"]
49
- return _select_findings(
50
- findings_document["findings"],
51
- finding_id,
52
- fingerprint,
53
- )
54
-
55
-
56
- def _parse_args(argv: list[str]) -> argparse.Namespace:
57
- parser = argparse.ArgumentParser(description=__doc__)
58
- parser.add_argument("scan_dir", type=Path)
59
- selector = parser.add_mutually_exclusive_group()
60
- selector.add_argument("--finding-id")
61
- selector.add_argument("--fingerprint")
62
- return parser.parse_args(argv)
63
-
64
-
65
- def main(argv: list[str] | None = None) -> int:
66
- args = _parse_args(sys.argv[1:] if argv is None else argv)
67
- try:
68
- findings = validate_source(
69
- args.scan_dir,
70
- finding_id=args.finding_id,
71
- fingerprint=args.fingerprint,
72
- )
73
- except (OSError, ValueError, RecursionError) as exc:
74
- print(f"tracking source preflight failed: {exc}", file=sys.stderr)
75
- return 2
76
- for finding in findings:
77
- print(finding["findingId"])
78
- return 0
79
-
80
-
81
- if __name__ == "__main__":
82
- raise SystemExit(main())
@@ -1,136 +0,0 @@
1
- """Prepare and cache embeddings without publishing findings to an HTTP service."""
2
-
3
- from __future__ import annotations
4
-
5
- import argparse
6
- import hashlib
7
- import json
8
- import math
9
- import sqlite3
10
- import sys
11
- from pathlib import Path
12
- from typing import Any
13
-
14
- sys.path.insert(0, str(Path(__file__).resolve().parent))
15
- from workbench_finding_index import upsert_finding
16
- from workbench_target_state import stable_target_id
17
-
18
-
19
- def cache_key(space: str, document: str) -> str:
20
- return hashlib.sha256(f"{space}\0{document}".encode()).hexdigest()
21
-
22
-
23
- def local_dedupe(
24
- connection: sqlite3.Connection, payload: dict[str, Any], timestamp: str
25
- ) -> dict[str, Any]:
26
- action = payload["action"]
27
- try:
28
- with connection:
29
- connection.execute("BEGIN IMMEDIATE")
30
- if action == "prepare":
31
- return prepare(connection, payload, timestamp)
32
- if action == "embed":
33
- for entry in payload["entries"]:
34
- row = connection.execute(
35
- "SELECT details_json FROM findings WHERE id = ?", (entry["findingId"],)
36
- ).fetchone()
37
- if (
38
- row is None
39
- or cache_key(payload["space"], row["details_json"]) != entry["cacheKey"]
40
- ):
41
- raise ValueError("finding_changed")
42
- embedding = entry["embedding"]
43
- vector = embedding["vector"]
44
- if (
45
- embedding["model"] != payload["model"]
46
- or len(vector) != payload["dimensions"]
47
- or not all(isinstance(v, (int, float)) and math.isfinite(v) for v in vector)
48
- or not math.isfinite(math.hypot(*vector))
49
- or math.hypot(*vector) == 0
50
- ):
51
- raise ValueError("embedding_failed")
52
- connection.execute(
53
- "INSERT INTO local_finding_embeddings (finding_id, model, vector_json, cache_key) "
54
- "VALUES (?, ?, ?, ?) ON CONFLICT(finding_id) DO UPDATE SET "
55
- "model = excluded.model, vector_json = excluded.vector_json, "
56
- "cache_key = excluded.cache_key",
57
- (
58
- entry["findingId"],
59
- embedding["model"],
60
- json.dumps(vector, allow_nan=False),
61
- entry["cacheKey"],
62
- ),
63
- )
64
- return {}
65
- raise ValueError("invalid_request")
66
- except sqlite3.IntegrityError:
67
- return {"error": "finding_conflict"}
68
- except ValueError as exc:
69
- return {"error": str(exc)}
70
-
71
-
72
- def prepare(
73
- connection: sqlite3.Connection, payload: dict[str, Any], timestamp: str
74
- ) -> dict[str, Any]:
75
- # Artifact seals establish consistency, not permission to select another local corpus.
76
- target = Path(payload["repositoryPath"]).resolve()
77
- registered = connection.execute(
78
- "SELECT id FROM security_targets WHERE current_path = ?", (str(target),)
79
- ).fetchone()
80
- target_id = registered["id"] if registered is not None else stable_target_id(target)
81
- if (
82
- payload["anchorRepositoryId"] != target_id
83
- or payload.get("repositoryId", target_id) != target_id
84
- ):
85
- raise ValueError("target_mismatch")
86
- if not payload["findings"]:
87
- return {"cacheKeys": {}, "findingsToEmbed": []}
88
- # A sealed historical scan selects logical IDs; never overwrite their current bodies.
89
- for finding in payload["findings"]:
90
- existing = connection.execute(
91
- "SELECT fingerprint, rule_id, identity_anchor, identity_instance, details_json "
92
- "FROM findings WHERE id = ?",
93
- (finding["findingId"],),
94
- ).fetchone()
95
- identity = (
96
- finding["fingerprints"]["primary"],
97
- finding["ruleId"],
98
- finding["identity"]["anchor"],
99
- finding["identity"].get("instance"),
100
- )
101
- if existing is not None and tuple(existing)[:4] != identity:
102
- raise sqlite3.IntegrityError("Conflicting finding identity")
103
- if existing is None or existing["details_json"] is None:
104
- upsert_finding(connection, finding, timestamp, payload["anchorRepositoryId"])
105
- else:
106
- connection.execute(
107
- "INSERT OR IGNORE INTO finding_repositories (repository_id, finding_id) VALUES (?, ?)",
108
- (payload["anchorRepositoryId"], finding["findingId"]),
109
- )
110
- repository_id = payload.get("repositoryId")
111
- rows = connection.execute(
112
- "SELECT findings.id, findings.details_json, embeddings.cache_key FROM findings "
113
- "LEFT JOIN local_finding_embeddings AS embeddings ON findings.id = embeddings.finding_id "
114
- + (
115
- "WHERE EXISTS (SELECT 1 FROM finding_repositories WHERE finding_id = findings.id "
116
- "AND repository_id = ?) "
117
- if repository_id is not None
118
- else ""
119
- )
120
- + "ORDER BY findings.created_at, findings.id",
121
- (repository_id,) if repository_id is not None else (),
122
- )
123
- cache_keys = {}
124
- findings_to_embed = []
125
- for row in rows:
126
- if row["details_json"] is None:
127
- raise ValueError("finding_not_indexed")
128
- key = cache_key(payload["space"], row["details_json"])
129
- cache_keys[row["id"]] = key
130
- if key != row["cache_key"]:
131
- findings_to_embed.append(json.loads(row["details_json"]))
132
- return {"cacheKeys": cache_keys, "findingsToEmbed": findings_to_embed}
133
-
134
-
135
- if __name__ == "__main__":
136
- argparse.ArgumentParser(description=__doc__).parse_args()
@@ -1,4 +0,0 @@
1
- import type { Readable } from "node:stream";
2
- import { runHostProtocol } from "../host-protocol.js";
3
- export declare function runRecordsProtocol(input: Readable, output: Parameters<typeof runHostProtocol>[1], signal?: AbortSignal): Promise<number>;
4
- //# sourceMappingURL=records-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records-protocol.d.ts","sourceRoot":"","sources":["../../src/deduplication/records-protocol.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAA2B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ/E,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
@@ -1,49 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { z } from "zod";
3
- import { missingSubmissionPrompt } from "./deduplication-prompts.js";
4
- import { PendingReviewSubmission, runHostProtocol } from "../host-protocol.js";
5
- import { runRecords } from "./records.js";
6
- const missingSubmission = z.strictObject({
7
- status: z.literal("missing_submission"),
8
- });
9
- const released = z.strictObject({ status: z.literal("released") });
10
- export async function runRecordsProtocol(input, output, signal) {
11
- return await runHostProtocol(input, output, {
12
- label: "Deduplication",
13
- requestMethod: "review.run",
14
- run: (params, execute, signal) => runRecords(params, async (request, validateSubmission) => {
15
- const first = await execute(request.requestId, {
16
- ...request,
17
- supportsContinuation: true,
18
- supportsSubmissionValidation: true,
19
- });
20
- let rejection;
21
- if (first instanceof PendingReviewSubmission) {
22
- try {
23
- validateSubmission(first.submission);
24
- }
25
- catch (error) {
26
- rejection =
27
- error instanceof Error
28
- ? error.message
29
- : "Invalid submission.";
30
- }
31
- if (rejection === undefined) {
32
- const receipt = await execute(randomUUID(), { requestId: request.requestId }, undefined, "review.release");
33
- released.parse(receipt);
34
- return first.submission;
35
- }
36
- }
37
- else if (!missingSubmission.safeParse(first).success)
38
- return first;
39
- const result = await execute(randomUUID(), {
40
- requestId: request.requestId,
41
- prompt: missingSubmissionPrompt(rejection),
42
- }, undefined, "review.continue");
43
- if (missingSubmission.safeParse(result).success)
44
- throw new Error("Review ended without a terminal submission after correction.");
45
- return result;
46
- }, signal),
47
- }, signal);
48
- }
49
- //# sourceMappingURL=records-protocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records-protocol.js","sourceRoot":"","sources":["../../src/deduplication/records-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAgC,MAAM,cAAc,CAAC;AAExE,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;CACxC,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AAEnE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAe,EACf,MAA6C,EAC7C,MAAoB;IAEpB,OAAO,MAAM,eAAe,CAC1B,KAAK,EACL,MAAM,EACN;QACE,KAAK,EAAE,eAAe;QACtB,aAAa,EAAE,YAAY;QAC3B,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC/B,UAAU,CACR,MAAiC,EACjC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC7C,GAAG,OAAO;gBACV,oBAAoB,EAAE,IAAI;gBAC1B,4BAA4B,EAAE,IAAI;aACnC,CAAC,CAAC;YACH,IAAI,SAA6B,CAAC;YAClC,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;gBAC7C,IAAI,CAAC;oBACH,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACvC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,SAAS;wBACP,KAAK,YAAY,KAAK;4BACpB,CAAC,CAAC,KAAK,CAAC,OAAO;4BACf,CAAC,CAAC,qBAAqB,CAAC;gBAC9B,CAAC;gBACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;oBAC5B,MAAM,OAAO,GAAG,MAAM,OAAO,CAC3B,UAAU,EAAE,EACZ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAChC,SAAS,EACT,gBAAgB,CACjB,CAAC;oBACF,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACxB,OAAO,KAAK,CAAC,UAAU,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO;gBACpD,OAAO,KAAK,CAAC;YACf,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B,UAAU,EAAE,EACZ;gBACE,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,uBAAuB,CAAC,SAAS,CAAC;aAC3C,EACD,SAAS,EACT,iBAAiB,CAClB,CAAC;YACF,IAAI,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO;gBAC7C,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;YACJ,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,MAAM,CACP;KACJ,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { Readable } from \"node:stream\";\nimport { z } from \"zod\";\nimport { missingSubmissionPrompt } from \"./deduplication-prompts.js\";\nimport { PendingReviewSubmission, runHostProtocol } from \"../host-protocol.js\";\nimport { runRecords, type DeduplicateRecordsInput } from \"./records.js\";\n\nconst missingSubmission = z.strictObject({\n status: z.literal(\"missing_submission\"),\n});\nconst released = z.strictObject({ status: z.literal(\"released\") });\n\nexport async function runRecordsProtocol(\n input: Readable,\n output: Parameters<typeof runHostProtocol>[1],\n signal?: AbortSignal,\n): Promise<number> {\n return await runHostProtocol(\n input,\n output,\n {\n label: \"Deduplication\",\n requestMethod: \"review.run\",\n run: (params, execute, signal) =>\n runRecords(\n params as DeduplicateRecordsInput,\n async (request, validateSubmission) => {\n const first = await execute(request.requestId, {\n ...request,\n supportsContinuation: true,\n supportsSubmissionValidation: true,\n });\n let rejection: string | undefined;\n if (first instanceof PendingReviewSubmission) {\n try {\n validateSubmission(first.submission);\n } catch (error) {\n rejection =\n error instanceof Error\n ? error.message\n : \"Invalid submission.\";\n }\n if (rejection === undefined) {\n const receipt = await execute(\n randomUUID(),\n { requestId: request.requestId },\n undefined,\n \"review.release\",\n );\n released.parse(receipt);\n return first.submission;\n }\n } else if (!missingSubmission.safeParse(first).success)\n return first;\n const result = await execute(\n randomUUID(),\n {\n requestId: request.requestId,\n prompt: missingSubmissionPrompt(rejection),\n },\n undefined,\n \"review.continue\",\n );\n if (missingSubmission.safeParse(result).success)\n throw new Error(\n \"Review ended without a terminal submission after correction.\",\n );\n return result;\n },\n signal,\n ),\n },\n signal,\n );\n}\n"]}