@openai/codex-security 0.9.1 → 0.10.1
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.
- package/README.md +37 -788
- package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
- package/_bundled_plugin/.mcp.json +3 -0
- package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br +0 -0
- package/_bundled_plugin/references/access-advisory.md +1 -1
- package/_bundled_plugin/references/artifact-storage.md +1 -1
- package/_bundled_plugin/references/baseline-auditor.md +18 -0
- package/_bundled_plugin/references/core-scan.md +5 -42
- package/_bundled_plugin/references/final-report.md +1 -1
- package/_bundled_plugin/references/focused-investigator.md +13 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -2
- package/_bundled_plugin/references/scan-runtime.md +4 -2
- package/_bundled_plugin/references/security-guidance.md +14 -1
- package/_bundled_plugin/references/threat-model.md +1 -0
- package/_bundled_plugin/references/validate-scan-findings.md +3 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +30 -12
- package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +47 -9
- package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
- package/_bundled_plugin/scripts/posix_scan_local_files.py +26 -1
- package/_bundled_plugin/scripts/snapshot_sqlite.py +8 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +216 -25
- package/_bundled_plugin/scripts/workbench/handoff.py +55 -25
- package/_bundled_plugin/scripts/workbench/storage.py +25 -5
- package/_bundled_plugin/scripts/workbench_cli.py +24 -2
- package/_bundled_plugin/scripts/workbench_constants.py +2 -0
- package/_bundled_plugin/scripts/workbench_db.py +257 -268
- package/_bundled_plugin/scripts/workbench_feedback.py +49 -4
- package/_bundled_plugin/scripts/workbench_native_indexes.py +226 -29
- package/_bundled_plugin/scripts/workbench_progress.py +159 -3
- package/_bundled_plugin/scripts/workbench_publication.py +2 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +142 -2
- package/_bundled_plugin/scripts/workbench_saved_results.py +48 -8
- package/_bundled_plugin/scripts/workbench_scan_history.py +291 -134
- package/_bundled_plugin/scripts/workbench_scan_start.py +208 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +36 -10
- package/_bundled_plugin/scripts/workbench_schema.py +220 -14
- package/_bundled_plugin/scripts/workbench_setup.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +8 -0
- package/_bundled_plugin/scripts/workbench_target.py +486 -85
- package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
- package/_bundled_plugin/shared/workbench-history-repairs.json +64 -14
- package/_bundled_plugin/shared/workbench-migrations.json +66 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
- package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
- package/_bundled_plugin/skills/publish-findings/SKILL.md +26 -160
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +2 -2
- package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +3 -58
- package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
- package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
- package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
- package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
- package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
- package/bin/codex-security.mjs +2 -2
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +459 -157
- package/dist/api.js.map +1 -1
- package/dist/armorcode-findings.d.ts +9 -0
- package/dist/armorcode-findings.d.ts.map +1 -0
- package/dist/armorcode-findings.js +145 -0
- package/dist/armorcode-findings.js.map +1 -0
- package/dist/artifact-export.d.ts +2 -0
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +29 -13
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.d.ts +6 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +33 -12
- package/dist/auth.js.map +1 -1
- package/dist/batch-cost.d.ts +18 -0
- package/dist/batch-cost.d.ts.map +1 -0
- package/dist/batch-cost.js +41 -0
- package/dist/batch-cost.js.map +1 -0
- package/dist/blackduck-findings.d.ts +1 -1
- package/dist/blackduck-findings.d.ts.map +1 -1
- package/dist/blackduck-findings.js +5 -18
- package/dist/blackduck-findings.js.map +1 -1
- package/dist/bundled-plugin.d.ts +4 -0
- package/dist/bundled-plugin.d.ts.map +1 -0
- package/dist/bundled-plugin.js +23 -0
- package/dist/bundled-plugin.js.map +1 -0
- package/dist/classify-scan-severity.d.ts +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +11 -3
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-diagnostics.d.ts +10 -0
- package/dist/classify-severity-diagnostics.d.ts.map +1 -0
- package/dist/classify-severity-diagnostics.js +57 -0
- package/dist/classify-severity-diagnostics.js.map +1 -0
- package/dist/classify-severity-records.d.ts +4 -0
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +35 -8
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +9 -6
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-argument.d.ts +4 -0
- package/dist/cli-argument.d.ts.map +1 -0
- package/dist/cli-argument.js +17 -0
- package/dist/cli-argument.js.map +1 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +71 -29
- package/dist/cli-help.js.map +1 -1
- package/dist/cli-hook.d.ts +3 -0
- package/dist/cli-hook.d.ts.map +1 -0
- package/dist/cli-hook.js +87 -0
- package/dist/cli-hook.js.map +1 -0
- package/dist/cli-integrations.d.ts +13 -0
- package/dist/cli-integrations.d.ts.map +1 -0
- package/dist/cli-integrations.js +333 -0
- package/dist/cli-integrations.js.map +1 -0
- package/dist/cli-mcp.d.ts +15 -0
- package/dist/cli-mcp.d.ts.map +1 -0
- package/dist/cli-mcp.js +178 -0
- package/dist/cli-mcp.js.map +1 -0
- package/dist/cli-token-view.d.ts +10 -0
- package/dist/cli-token-view.d.ts.map +1 -0
- package/dist/cli-token-view.js +41 -0
- package/dist/cli-token-view.js.map +1 -0
- package/dist/cli.d.ts +8 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1860 -903
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +33 -31
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +6 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -1
- package/dist/codex-sdk-environment.js +19 -0
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/command-words.d.ts +3 -0
- package/dist/command-words.d.ts.map +1 -0
- package/dist/command-words.js +46 -0
- package/dist/command-words.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -3
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +3 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +40 -7
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -1
- package/dist/config.js.map +1 -1
- package/dist/continuum-aws.d.ts +6 -0
- package/dist/continuum-aws.d.ts.map +1 -0
- package/dist/continuum-aws.js +202 -0
- package/dist/continuum-aws.js.map +1 -0
- package/dist/continuum-collector.d.ts +44 -0
- package/dist/continuum-collector.d.ts.map +1 -0
- package/dist/continuum-collector.js +266 -0
- package/dist/continuum-collector.js.map +1 -0
- package/dist/continuum-findings.d.ts +31 -2
- package/dist/continuum-findings.d.ts.map +1 -1
- package/dist/continuum-findings.js +497 -59
- package/dist/continuum-findings.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -0
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -45
- package/dist/cost.js.map +1 -1
- package/dist/crowdstrike-findings.d.ts +7 -0
- package/dist/crowdstrike-findings.d.ts.map +1 -0
- package/dist/crowdstrike-findings.js +210 -0
- package/dist/crowdstrike-findings.js.map +1 -0
- package/dist/custom-validation-prompt.d.ts +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +29 -19
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/local.d.ts +3 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +8 -1
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/refusal.d.ts.map +1 -1
- package/dist/deduplication/refusal.js +2 -1
- package/dist/deduplication/refusal.js.map +1 -1
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +16 -15
- package/dist/deep-scan.js.map +1 -1
- package/dist/endor-findings.d.ts +2 -2
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +6 -23
- package/dist/endor-findings.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/executable-path.d.ts +3 -0
- package/dist/executable-path.d.ts.map +1 -1
- package/dist/executable-path.js +26 -0
- package/dist/executable-path.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +12 -1
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +66 -4
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +258 -59
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +6 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +330 -1633
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -2
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +56 -53
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +1 -1
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +12 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-contract.d.ts +6 -11
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +35 -177
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/finding-prompt.d.ts.map +1 -1
- package/dist/finding-prompt.js +2 -2
- package/dist/finding-prompt.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts.map +1 -1
- package/dist/github-dependabot-findings.js +3 -4
- package/dist/github-dependabot-findings.js.map +1 -1
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +19 -287
- package/dist/github-findings.js.map +1 -1
- package/dist/host-protocol.d.ts +6 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +11 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +2 -0
- package/dist/host-records-protocol.d.ts.map +1 -1
- package/dist/host-records-protocol.js +4 -0
- package/dist/host-records-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts +1 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +23 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts.map +1 -1
- package/dist/inspector-findings.js +19 -35
- package/dist/inspector-findings.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +34 -27
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts +11 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js.map +1 -1
- package/dist/local-git-metadata.d.ts +5 -2
- package/dist/local-git-metadata.d.ts.map +1 -1
- package/dist/local-git-metadata.js +8 -4
- package/dist/local-git-metadata.js.map +1 -1
- package/dist/multiscan.d.ts +4 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +83 -39
- package/dist/multiscan.js.map +1 -1
- package/dist/opengrep-findings.d.ts +4 -2
- package/dist/opengrep-findings.d.ts.map +1 -1
- package/dist/opengrep-findings.js +39 -22
- package/dist/opengrep-findings.js.map +1 -1
- package/dist/private-finding-import.d.ts +8 -13
- package/dist/private-finding-import.d.ts.map +1 -1
- package/dist/private-finding-import.js +69 -129
- package/dist/private-finding-import.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +56 -13
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +7 -2
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +42 -20
- package/dist/prompt-files.js.map +1 -1
- package/dist/provider-profile.d.ts.map +1 -1
- package/dist/provider-profile.js +4 -9
- package/dist/provider-profile.js.map +1 -1
- package/dist/publication.d.ts +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js.map +1 -1
- package/dist/record.d.ts +1 -5
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +3 -51
- package/dist/record.js.map +1 -1
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -1
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts +35 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +782 -153
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +6 -1
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +267 -115
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-archive-path.d.ts +2 -0
- package/dist/scan-archive-path.d.ts.map +1 -0
- package/dist/scan-archive-path.js +5 -0
- package/dist/scan-archive-path.js.map +1 -0
- package/dist/scan-comparison.d.ts +20 -2
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +26 -5
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +18 -2
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +4 -2
- package/dist/scan-executor.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -0
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +25 -9
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +28 -4
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +1 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +5 -11
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +16 -89
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +26 -6
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +14 -48
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/semgrep-platform-findings.d.ts +20 -70
- package/dist/semgrep-platform-findings.d.ts.map +1 -1
- package/dist/semgrep-platform-findings.js +116 -333
- package/dist/semgrep-platform-findings.js.map +1 -1
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +1 -0
- package/dist/severity-review.js.map +1 -1
- package/dist/snyk-findings.d.ts +2 -0
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +5 -8
- package/dist/snyk-findings.js.map +1 -1
- package/dist/snyk-rest-findings.d.ts +3 -20
- package/dist/snyk-rest-findings.d.ts.map +1 -1
- package/dist/snyk-rest-findings.js +45 -217
- package/dist/snyk-rest-findings.js.map +1 -1
- package/dist/sonar-findings.d.ts +1 -1
- package/dist/sonar-findings.d.ts.map +1 -1
- package/dist/sonar-findings.js +2 -4
- package/dist/sonar-findings.js.map +1 -1
- package/dist/sonar-import.d.ts +3 -0
- package/dist/sonar-import.d.ts.map +1 -1
- package/dist/sonar-import.js +28 -30
- package/dist/sonar-import.js.map +1 -1
- package/dist/stored-finding-projection.d.ts +6 -0
- package/dist/stored-finding-projection.d.ts.map +1 -0
- package/dist/stored-finding-projection.js +129 -0
- package/dist/stored-finding-projection.js.map +1 -0
- package/dist/stored-findings-publication.d.ts +23 -0
- package/dist/stored-findings-publication.d.ts.map +1 -0
- package/dist/stored-findings-publication.js +169 -0
- package/dist/stored-findings-publication.js.map +1 -0
- package/dist/targets.d.ts +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +103 -23
- package/dist/targets.js.map +1 -1
- package/dist/tenable-findings.d.ts +1 -4
- package/dist/tenable-findings.d.ts.map +1 -1
- package/dist/tenable-findings.js.map +1 -1
- package/dist/trivy-findings.d.ts.map +1 -1
- package/dist/trivy-findings.js +0 -11
- package/dist/trivy-findings.js.map +1 -1
- package/dist/trusted-executable.d.ts +7 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +148 -37
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.js +3 -1
- package/dist/value.js.map +1 -1
- package/dist/veracode-findings.d.ts +1 -3
- package/dist/veracode-findings.d.ts.map +1 -1
- package/dist/veracode-findings.js +13 -38
- package/dist/veracode-findings.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +184 -32
- package/dist/version.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -2
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +14 -92
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +30 -0
- package/docs/cli.md +537 -124
- package/docs/findings-service.md +22 -9
- package/docs/hosted-remediation.md +13 -4
- package/docs/sdk.md +918 -0
- package/package.json +15 -6
- package/schemas/external-findings.schema.json +2 -1
- package/schemas/project-config.schema.json +5 -0
- package/dist/hosted-scanner-v1.d.ts +0 -6
- package/dist/hosted-scanner-v1.d.ts.map +0 -1
- package/dist/hosted-scanner-v1.js +0 -60
- package/dist/hosted-scanner-v1.js.map +0 -1
- package/dist/reader-selection.d.ts +0 -15
- package/dist/reader-selection.d.ts.map +0 -1
- package/dist/reader-selection.js +0 -89
- package/dist/reader-selection.js.map +0 -1
- package/dist/semgrep-platform-v1.d.ts +0 -6
- package/dist/semgrep-platform-v1.d.ts.map +0 -1
- package/dist/semgrep-platform-v1.js +0 -83
- package/dist/semgrep-platform-v1.js.map +0 -1
- package/dist/snyk-rest-v1.d.ts +0 -28
- package/dist/snyk-rest-v1.d.ts.map +0 -1
- package/dist/snyk-rest-v1.js +0 -132
- package/dist/snyk-rest-v1.js.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
+
import errno
|
|
6
7
|
import json
|
|
7
8
|
import os
|
|
8
9
|
import re
|
|
@@ -11,22 +12,29 @@ import sys
|
|
|
11
12
|
import tempfile
|
|
12
13
|
from collections.abc import Callable, Iterator
|
|
13
14
|
from contextlib import contextmanager
|
|
15
|
+
from dataclasses import dataclass
|
|
14
16
|
from datetime import datetime, timezone
|
|
15
|
-
from pathlib import Path
|
|
17
|
+
from pathlib import Path, PurePosixPath
|
|
16
18
|
from typing import Any
|
|
17
19
|
|
|
18
20
|
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
19
21
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
20
22
|
from filesystem_identity import serialize_filesystem_identity
|
|
21
23
|
from finalize_scan_contract import write_scan_local_bytes
|
|
22
|
-
from workbench.storage import
|
|
24
|
+
from workbench.storage import (
|
|
25
|
+
archive_source_directory,
|
|
26
|
+
create_private_temporary_directory,
|
|
27
|
+
short_archive_prefix,
|
|
28
|
+
state_dir,
|
|
29
|
+
)
|
|
23
30
|
from workbench_feedback import get_scan_feedback
|
|
31
|
+
from workbench_setup import require_target
|
|
24
32
|
from workbench_target import (
|
|
25
33
|
directory_content_digest,
|
|
26
34
|
git_revision,
|
|
27
35
|
worktree_content_digest,
|
|
28
36
|
)
|
|
29
|
-
from workbench_validation import optional_text, read_json_object
|
|
37
|
+
from workbench_validation import optional_text, read_json_object, reject_non_finite_json
|
|
30
38
|
|
|
31
39
|
|
|
32
40
|
def safe_segment(value: str) -> str:
|
|
@@ -58,6 +66,7 @@ def scan_target_identity(
|
|
|
58
66
|
diff_target: dict[str, str] | None,
|
|
59
67
|
*,
|
|
60
68
|
metadata: os.stat_result | None = None,
|
|
69
|
+
expected_digest: str | None = None,
|
|
61
70
|
) -> tuple[str, str | None, int | str, int | str]:
|
|
62
71
|
"""Return revision, content digest, device ID, and inode for scan registration.
|
|
63
72
|
|
|
@@ -72,7 +81,7 @@ def scan_target_identity(
|
|
|
72
81
|
snapshot_digest = (
|
|
73
82
|
directory_content_digest(target)
|
|
74
83
|
if revision == "unversioned"
|
|
75
|
-
else worktree_content_digest(target)
|
|
84
|
+
else worktree_content_digest(target, expected_digest=expected_digest)
|
|
76
85
|
)
|
|
77
86
|
return (
|
|
78
87
|
revision,
|
|
@@ -82,6 +91,25 @@ def scan_target_identity(
|
|
|
82
91
|
)
|
|
83
92
|
|
|
84
93
|
|
|
94
|
+
@dataclass(frozen=True)
|
|
95
|
+
class WindowsResumeTarget:
|
|
96
|
+
path: Path
|
|
97
|
+
snapshot: tuple[str, str | None, int | str, int | str]
|
|
98
|
+
native_id: tuple[int, int] | None
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def prepare_cli_scan_target(
|
|
102
|
+
target: Path, diff_target: dict[str, str] | None, mode: str, launch_kind: str
|
|
103
|
+
) -> tuple[tuple[str, str | None, int | str, int | str], WindowsResumeTarget | None]:
|
|
104
|
+
if os.name == "nt" and mode in {"standard", "deep"} and launch_kind == "scan":
|
|
105
|
+
from windows_scan_local_files import pinned_resume_checkout
|
|
106
|
+
|
|
107
|
+
with pinned_resume_checkout(target) as native:
|
|
108
|
+
snapshot = scan_target_identity(target, diff_target)
|
|
109
|
+
return snapshot, WindowsResumeTarget(target, snapshot, native)
|
|
110
|
+
return scan_target_identity(target, diff_target), None
|
|
111
|
+
|
|
112
|
+
|
|
85
113
|
def scan_diff_identity(
|
|
86
114
|
diff_target: dict[str, str] | None,
|
|
87
115
|
) -> tuple[str | None, str | None, str | None, str | None]:
|
|
@@ -129,7 +157,7 @@ def archive_scan(
|
|
|
129
157
|
if archived_scan_dir is not None and (
|
|
130
158
|
not args.archive_existing
|
|
131
159
|
or archived_scan_dir.parent != scan_dir.parent
|
|
132
|
-
or
|
|
160
|
+
or archive_source_directory(archived_scan_dir, scan_dir) != scan_dir
|
|
133
161
|
):
|
|
134
162
|
raise SystemExit("The archived scan must be a previous sibling of the scan directory.")
|
|
135
163
|
|
|
@@ -179,9 +207,17 @@ def archive_scan(
|
|
|
179
207
|
)
|
|
180
208
|
if before_archive is not None:
|
|
181
209
|
before_archive()
|
|
182
|
-
|
|
183
|
-
tempfile.mkdtemp(
|
|
184
|
-
|
|
210
|
+
try:
|
|
211
|
+
reserved = tempfile.mkdtemp(
|
|
212
|
+
prefix=f"{scan_dir.name}.previous-", dir=scan_dir.parent
|
|
213
|
+
)
|
|
214
|
+
except OSError as error:
|
|
215
|
+
if os.name != "posix" or error.errno != errno.ENAMETOOLONG:
|
|
216
|
+
raise
|
|
217
|
+
reserved = tempfile.mkdtemp(
|
|
218
|
+
prefix=short_archive_prefix(scan_dir.name), dir=scan_dir.parent
|
|
219
|
+
)
|
|
220
|
+
archived_scan_dir = Path(reserved).resolve()
|
|
185
221
|
archived_scan_dir.rmdir()
|
|
186
222
|
scan_dir.rename(archived_scan_dir)
|
|
187
223
|
moved = True
|
|
@@ -269,6 +305,95 @@ def archive_scan(
|
|
|
269
305
|
raise
|
|
270
306
|
|
|
271
307
|
|
|
308
|
+
def restore_cli_scan_archive(
|
|
309
|
+
connection: sqlite3.Connection,
|
|
310
|
+
args: argparse.Namespace,
|
|
311
|
+
canonical_directory: Callable[[Path], Path],
|
|
312
|
+
) -> dict[str, str]:
|
|
313
|
+
supplied_scan_dir = Path(args.scan_dir).expanduser().absolute()
|
|
314
|
+
supplied_archive = Path(args.archived_scan_dir).expanduser().absolute()
|
|
315
|
+
connection.execute("BEGIN IMMEDIATE")
|
|
316
|
+
try:
|
|
317
|
+
scan_dir = supplied_scan_dir.resolve()
|
|
318
|
+
archived_scan_dir = supplied_archive.resolve()
|
|
319
|
+
archived_owner = connection.execute(
|
|
320
|
+
"SELECT id FROM scans WHERE scan_dir = ?", (str(archived_scan_dir),)
|
|
321
|
+
).fetchone()
|
|
322
|
+
previous_scan = connection.execute(
|
|
323
|
+
"SELECT id FROM scans WHERE scan_dir = ?", (str(scan_dir),)
|
|
324
|
+
).fetchone()
|
|
325
|
+
previous_scan_id = previous_scan["id"] if previous_scan is not None else None
|
|
326
|
+
if archived_owner is not None:
|
|
327
|
+
disposition = "already-recorded"
|
|
328
|
+
elif previous_scan_id != args.previous_scan_id:
|
|
329
|
+
disposition = "ownership-changed"
|
|
330
|
+
else:
|
|
331
|
+
archived_scan_dir = canonical_directory(supplied_archive)
|
|
332
|
+
if (
|
|
333
|
+
os.path.normcase(supplied_scan_dir) != os.path.normcase(scan_dir)
|
|
334
|
+
or archived_scan_dir.parent != scan_dir.parent
|
|
335
|
+
or not archived_scan_dir.name.startswith(f"{scan_dir.name}.previous-")
|
|
336
|
+
):
|
|
337
|
+
raise SystemExit(
|
|
338
|
+
"The archived scan must be a previous sibling of the scan directory."
|
|
339
|
+
)
|
|
340
|
+
try:
|
|
341
|
+
supplied_scan_dir.lstat()
|
|
342
|
+
except FileNotFoundError:
|
|
343
|
+
pass
|
|
344
|
+
else:
|
|
345
|
+
canonical_directory(supplied_scan_dir).rmdir()
|
|
346
|
+
archived_scan_dir.rename(scan_dir)
|
|
347
|
+
disposition = "restored"
|
|
348
|
+
connection.commit()
|
|
349
|
+
except BaseException:
|
|
350
|
+
connection.rollback()
|
|
351
|
+
raise
|
|
352
|
+
return {
|
|
353
|
+
"disposition": disposition,
|
|
354
|
+
"scanDir": str(scan_dir),
|
|
355
|
+
"archivedScanDir": str(archived_scan_dir),
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
@contextmanager
|
|
360
|
+
def register_windows_resume_output(
|
|
361
|
+
connection: sqlite3.Connection,
|
|
362
|
+
scan_id: str,
|
|
363
|
+
scan_dir: Path,
|
|
364
|
+
target: WindowsResumeTarget,
|
|
365
|
+
before_create: Callable[[], None],
|
|
366
|
+
) -> Iterator[None]:
|
|
367
|
+
from windows_scan_local_files import create_deep_resume_output, pinned_resume_checkout
|
|
368
|
+
|
|
369
|
+
def committed() -> bool:
|
|
370
|
+
# A signal can arrive after commit. The registered scan then owns its child.
|
|
371
|
+
return (
|
|
372
|
+
not connection.in_transaction
|
|
373
|
+
and connection.execute("SELECT 1 FROM scans WHERE id = ?", (scan_id,)).fetchone()
|
|
374
|
+
is not None
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
with pinned_resume_checkout(target.path) as current:
|
|
378
|
+
if current != target.native_id or (
|
|
379
|
+
current is None and scan_target_identity(target.path, None) != target.snapshot
|
|
380
|
+
):
|
|
381
|
+
raise SystemExit(
|
|
382
|
+
"The selected scan target changed while the scan was starting. Try again."
|
|
383
|
+
)
|
|
384
|
+
before_create()
|
|
385
|
+
with create_deep_resume_output(scan_dir, committed) as identity:
|
|
386
|
+
connection.execute(
|
|
387
|
+
"UPDATE scans SET windows_resume_output_identity = ?, windows_resume_target_identity = ? WHERE id = ?",
|
|
388
|
+
(
|
|
389
|
+
json.dumps(identity),
|
|
390
|
+
json.dumps(target.native_id) if target.native_id is not None else None,
|
|
391
|
+
scan_id,
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
yield
|
|
395
|
+
|
|
396
|
+
|
|
272
397
|
def insert_running_scan(
|
|
273
398
|
connection: sqlite3.Connection,
|
|
274
399
|
*,
|
|
@@ -278,6 +403,7 @@ def insert_running_scan(
|
|
|
278
403
|
scope: str,
|
|
279
404
|
diff_target: dict[str, str] | None,
|
|
280
405
|
target_identity: tuple[str, str | None, int | str, int | str],
|
|
406
|
+
repository_generation: str | None,
|
|
281
407
|
source_scopes: dict[str, Any],
|
|
282
408
|
target_root: Path,
|
|
283
409
|
target_summary: str | None,
|
|
@@ -290,6 +416,7 @@ def insert_running_scan(
|
|
|
290
416
|
surface: str | None = "plugin",
|
|
291
417
|
package_version: str | None = None,
|
|
292
418
|
launch_kind: str = "scan",
|
|
419
|
+
hosted: bool = False,
|
|
293
420
|
) -> str:
|
|
294
421
|
revision = target_identity[0]
|
|
295
422
|
native_scan = scan_dir is None
|
|
@@ -307,19 +434,21 @@ def insert_running_scan(
|
|
|
307
434
|
connection.execute(
|
|
308
435
|
"""
|
|
309
436
|
INSERT INTO scans (
|
|
310
|
-
id, workspace_id, target_id,
|
|
437
|
+
id, workspace_id, target_id, repository_generation, target_path,
|
|
438
|
+
target_revision, target_snapshot_digest,
|
|
311
439
|
target_device, target_inode, source_scopes_json, scope, mode, user_context,
|
|
312
440
|
deep_scan_owner_thread_id, diff_target_kind, diff_base_revision,
|
|
313
441
|
diff_head_revision, diff_content_digest, target_summary, scan_dir, model,
|
|
314
442
|
reasoning_effort, status, phase, handoff_status, started_at, created_at, updated_at,
|
|
315
443
|
launch_surface, launch_package_version, launch_plugin_version, launch_kind
|
|
316
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
317
|
-
'running',
|
|
444
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
445
|
+
'running', ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
318
446
|
""",
|
|
319
447
|
(
|
|
320
448
|
scan_id,
|
|
321
449
|
workspace["id"],
|
|
322
450
|
workspace["target_id"],
|
|
451
|
+
repository_generation,
|
|
323
452
|
str(target),
|
|
324
453
|
*target_identity,
|
|
325
454
|
json.dumps(source_scopes, allow_nan=False, separators=(",", ":"), sort_keys=True),
|
|
@@ -332,6 +461,12 @@ def insert_running_scan(
|
|
|
332
461
|
str(scan_dir),
|
|
333
462
|
optional_text(model, maximum=200),
|
|
334
463
|
optional_text(reasoning_effort, maximum=32),
|
|
464
|
+
"threat_model"
|
|
465
|
+
if not hosted
|
|
466
|
+
and launch_kind == "scan"
|
|
467
|
+
and workspace["default_mode"] == "standard"
|
|
468
|
+
and handoff_status == "delivered"
|
|
469
|
+
else "preflight",
|
|
335
470
|
handoff_status,
|
|
336
471
|
timestamp,
|
|
337
472
|
timestamp,
|
|
@@ -367,5 +502,67 @@ def insert_running_scan(
|
|
|
367
502
|
return scan_id
|
|
368
503
|
|
|
369
504
|
|
|
505
|
+
def parse_scan_recipe(value: str, repository: Path) -> dict[str, Any]:
|
|
506
|
+
try:
|
|
507
|
+
recipe = json.loads(value, parse_constant=reject_non_finite_json)
|
|
508
|
+
except (TypeError, UnicodeError, ValueError) as exc:
|
|
509
|
+
raise SystemExit("Scan launch recipe must be a valid JSON object.") from exc
|
|
510
|
+
if not isinstance(recipe, dict):
|
|
511
|
+
raise SystemExit("Scan launch recipe must be a JSON object.")
|
|
512
|
+
requested_repository = recipe.get("repository")
|
|
513
|
+
if (
|
|
514
|
+
not isinstance(requested_repository, str)
|
|
515
|
+
or require_target(requested_repository) != repository
|
|
516
|
+
):
|
|
517
|
+
raise SystemExit("Scan launch recipe repository must match the scanned repository.")
|
|
518
|
+
if recipe.get("mode") not in {"standard", "deep"}:
|
|
519
|
+
raise SystemExit("Scan launch recipe mode must be standard or deep.")
|
|
520
|
+
if not isinstance(recipe.get("config"), dict):
|
|
521
|
+
raise SystemExit("Scan launch recipe config must be a JSON object.")
|
|
522
|
+
target = recipe.get("target")
|
|
523
|
+
if not isinstance(target, dict) or target.get("kind") not in {
|
|
524
|
+
"repository",
|
|
525
|
+
"paths",
|
|
526
|
+
"refs",
|
|
527
|
+
"working_tree",
|
|
528
|
+
}:
|
|
529
|
+
raise SystemExit("Scan launch recipe target must identify a supported scan target.")
|
|
530
|
+
paths = target.get("paths")
|
|
531
|
+
if not isinstance(paths, list) or not all(isinstance(path, str) for path in paths):
|
|
532
|
+
raise SystemExit("Scan launch recipe target paths must be an array of strings.")
|
|
533
|
+
if target["kind"] == "paths" and not paths:
|
|
534
|
+
raise SystemExit("A scoped scan launch recipe must include at least one target path.")
|
|
535
|
+
if target["kind"] != "paths" and paths:
|
|
536
|
+
raise SystemExit("Only scoped scan launch recipes can include target paths.")
|
|
537
|
+
for path in paths:
|
|
538
|
+
candidate = PurePosixPath(path)
|
|
539
|
+
if (
|
|
540
|
+
not path
|
|
541
|
+
or candidate.is_absolute()
|
|
542
|
+
or ".." in candidate.parts
|
|
543
|
+
or "\\" in path
|
|
544
|
+
or not (repository / candidate).exists()
|
|
545
|
+
or not (repository / candidate).resolve().is_relative_to(repository)
|
|
546
|
+
):
|
|
547
|
+
raise SystemExit("Scan launch recipe target paths must exist inside the repository.")
|
|
548
|
+
exclusions = recipe.get("excludePaths", [])
|
|
549
|
+
if not isinstance(exclusions, list) or any(
|
|
550
|
+
not isinstance(path, str)
|
|
551
|
+
or not path
|
|
552
|
+
or any(ord(character) < 32 for character in path)
|
|
553
|
+
or re.match(r"^[A-Za-z]:", path)
|
|
554
|
+
or "\\" in path
|
|
555
|
+
or PurePosixPath(path).is_absolute()
|
|
556
|
+
or ".." in PurePosixPath(path).parts
|
|
557
|
+
or PurePosixPath(path).as_posix() != path
|
|
558
|
+
for path in exclusions
|
|
559
|
+
):
|
|
560
|
+
raise SystemExit("Scan launch recipe exclusions must be literal repository-relative paths.")
|
|
561
|
+
if target["kind"] in {"refs", "working_tree"}:
|
|
562
|
+
if not isinstance(target.get("base"), str) or not isinstance(target.get("head"), str):
|
|
563
|
+
raise SystemExit("Diff scan launch recipes require resolved base and head revisions.")
|
|
564
|
+
return recipe
|
|
565
|
+
|
|
566
|
+
|
|
370
567
|
if __name__ == "__main__":
|
|
371
568
|
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
@@ -17,10 +17,10 @@ from dataclasses import dataclass
|
|
|
17
17
|
from datetime import datetime, timezone
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import Any, Mapping
|
|
20
|
-
from urllib.parse import quote
|
|
21
20
|
|
|
22
21
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
23
|
-
from
|
|
22
|
+
from snapshot_sqlite import readonly_sqlite_uri
|
|
23
|
+
from workbench.storage import archive_source_directory, worker_usage_directory
|
|
24
24
|
|
|
25
25
|
TOKEN_FIELDS = {
|
|
26
26
|
"input_tokens": "inputTokens",
|
|
@@ -336,6 +336,12 @@ def collect_scan_usage(
|
|
|
336
336
|
started_at=started_at,
|
|
337
337
|
completed_at=stopped_at,
|
|
338
338
|
completed_turn_id=completed_turn_id if session.thread_id == thread_id else None,
|
|
339
|
+
resume_owner=(
|
|
340
|
+
scan["mode"] == "standard"
|
|
341
|
+
and "recipe_json" in scan.keys()
|
|
342
|
+
and scan["recipe_json"] is not None
|
|
343
|
+
and session.thread_id == scan["continuation_thread_id"]
|
|
344
|
+
),
|
|
339
345
|
is_scan_owner=(
|
|
340
346
|
scan["mode"] == "deep"
|
|
341
347
|
and session.thread_id == scan["deep_scan_owner_thread_id"]
|
|
@@ -607,9 +613,9 @@ def _scan_worker_directories(
|
|
|
607
613
|
|
|
608
614
|
|
|
609
615
|
def _codex_state_database() -> Path | None:
|
|
610
|
-
configured_database = os.environ.get("CODEX_STATE_DB", "")
|
|
611
|
-
if configured_database:
|
|
612
|
-
path = Path(
|
|
616
|
+
configured_database = os.environ.get("CODEX_STATE_DB", "")
|
|
617
|
+
if configured_database.strip():
|
|
618
|
+
path = Path(os.path.expanduser(configured_database))
|
|
613
619
|
return path.resolve() if path.is_file() and os.access(path, os.R_OK) else None
|
|
614
620
|
|
|
615
621
|
configured_home = os.environ.get("CODEX_HOME", "")
|
|
@@ -654,7 +660,7 @@ def _discover_rollout_sessions(
|
|
|
654
660
|
completed_at: datetime | None,
|
|
655
661
|
) -> tuple[list[RolloutSession], set[str]]:
|
|
656
662
|
database = sqlite3.connect(
|
|
657
|
-
|
|
663
|
+
readonly_sqlite_uri(state_database),
|
|
658
664
|
uri=True,
|
|
659
665
|
timeout=STATE_DATABASE_TIMEOUT_SECONDS,
|
|
660
666
|
)
|
|
@@ -708,10 +714,12 @@ def _discover_rollout_sessions(
|
|
|
708
714
|
for path in worker_directories
|
|
709
715
|
if Path(path).is_relative_to(scan_directory)
|
|
710
716
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
original
|
|
717
|
+
originals = {
|
|
718
|
+
original
|
|
719
|
+
for path in bound_directories | {Path(path) for path in worker_directories}
|
|
720
|
+
if (original := archive_source_directory(scan_directory, path)) is not None
|
|
721
|
+
}
|
|
722
|
+
for original in originals:
|
|
715
723
|
candidates = {original / relative: path for relative, path in relatives.items()}
|
|
716
724
|
# Older archives kept absolute discovery paths in their original directory.
|
|
717
725
|
if (
|
|
@@ -924,6 +932,7 @@ def _read_rollout_usage(
|
|
|
924
932
|
completed_at: datetime | None,
|
|
925
933
|
completed_turn_id: str | None = None,
|
|
926
934
|
is_scan_owner: bool = False,
|
|
935
|
+
resume_owner: bool = False,
|
|
927
936
|
) -> RolloutUsage:
|
|
928
937
|
result = RolloutUsage(_empty_token_usage(), set(), None, {})
|
|
929
938
|
total = result.tokens
|
|
@@ -945,6 +954,7 @@ def _read_rollout_usage(
|
|
|
945
954
|
started_turns: set[str] = set()
|
|
946
955
|
open_turns: set[str] = set()
|
|
947
956
|
closed_turns: set[str] = set()
|
|
957
|
+
failed_turns: set[str] = set()
|
|
948
958
|
measured_turns: set[str] = set()
|
|
949
959
|
|
|
950
960
|
def past_scan_end(timestamp: datetime, turn_id: object) -> bool:
|
|
@@ -1075,6 +1085,8 @@ def _read_rollout_usage(
|
|
|
1075
1085
|
if timestamp >= started_at:
|
|
1076
1086
|
if terminal_turn_id in started_turns:
|
|
1077
1087
|
closed_turns.add(terminal_turn_id)
|
|
1088
|
+
if payload.get("type") == "task_complete" and payload.get("error"):
|
|
1089
|
+
failed_turns.add(terminal_turn_id)
|
|
1078
1090
|
if payload.get("type") == "turn_aborted":
|
|
1079
1091
|
# Later successful work does not recover interrupted request usage.
|
|
1080
1092
|
warnings.add("turn_interrupted")
|
|
@@ -1141,6 +1153,20 @@ def _read_rollout_usage(
|
|
|
1141
1153
|
warnings.add("token_record_incomplete")
|
|
1142
1154
|
result.tokens_updated_at = max(result.tokens_updated_at or timestamp, timestamp)
|
|
1143
1155
|
_add_token_usage(response_usage, usage)
|
|
1156
|
+
if (
|
|
1157
|
+
resume_owner
|
|
1158
|
+
and receipt_turn_id == current_turn_id
|
|
1159
|
+
and current_turn_id in started_turns
|
|
1160
|
+
and (open_turns - {current_turn_id} or failed_turns)
|
|
1161
|
+
):
|
|
1162
|
+
# Matching thread totals account for turns left open or failed before resume.
|
|
1163
|
+
cumulative = _usage_counts(payload.get("thread_token_usage"))
|
|
1164
|
+
if cumulative is not None and all(
|
|
1165
|
+
cumulative[key] == total[key] + response_usage[key]
|
|
1166
|
+
for key in TOKEN_FIELDS.values()
|
|
1167
|
+
):
|
|
1168
|
+
open_turns.intersection_update({current_turn_id})
|
|
1169
|
+
closed_turns.difference_update(failed_turns - {current_turn_id})
|
|
1144
1170
|
continue
|
|
1145
1171
|
if event.get("type") != "event_msg" or payload.get("type") != "token_count":
|
|
1146
1172
|
continue
|