@fitlab-ai/agent-infra 0.9.12 → 0.9.14
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 +11 -11
- package/README.zh-CN.md +11 -11
- package/bin/cli.ts +26 -9
- package/dist/bin/cli.js +173 -157
- package/dist/bin/internal-cli.js +66 -40
- package/dist/lib/agent-client.js +5 -0
- package/dist/lib/agent-clients/next-steps.js +6 -1
- package/dist/lib/decide.js +3 -3
- package/dist/lib/internal/agent-client.js +5 -2
- package/dist/lib/internal/cli-route-inventory.js +152 -0
- package/dist/lib/internal/codex-lifecycle.js +9 -6
- package/dist/lib/internal/codex-sandbox-controller.js +8 -2
- package/dist/lib/internal/git-workflow.js +10 -6
- package/dist/lib/internal/platform-checks.js +19 -7
- package/dist/lib/internal/platform-comment.js +25 -13
- package/dist/lib/internal/platform-context.js +6 -3
- package/dist/lib/internal/platform-issue.js +20 -13
- package/dist/lib/internal/platform-metadata.js +88 -0
- package/dist/lib/internal/platform-pr-review.js +26 -13
- package/dist/lib/internal/platform-pr.js +84 -31
- package/dist/lib/internal/platform-release-notes.js +9 -6
- package/dist/lib/internal/platform-security.js +93 -0
- package/dist/lib/internal/pr-review-grade.js +25 -12
- package/dist/lib/internal/release-workflow.js +23 -9
- package/dist/lib/internal/sandbox-control.js +50 -7
- package/dist/lib/internal/task-activity.js +16 -7
- package/dist/lib/internal/task-artifact.js +235 -24
- package/dist/lib/internal/task-context.js +4 -1
- package/dist/lib/internal/task-create.js +50 -17
- package/dist/lib/internal/task-delivery.js +4 -1
- package/dist/lib/internal/task-event.js +10 -4
- package/dist/lib/internal/task-finalization.js +6 -3
- package/dist/lib/internal/task-invalidation.js +63 -0
- package/dist/lib/internal/task-ledger.js +20 -6
- package/dist/lib/internal/task-lifecycle.js +6 -3
- package/dist/lib/internal/task-operation-registry.js +421 -0
- package/dist/lib/internal/task-orchestration.js +12 -0
- package/dist/lib/internal/task-override.js +14 -7
- package/dist/lib/internal/task-qualification.js +90 -0
- package/dist/lib/internal/task-review.js +7 -4
- package/dist/lib/internal/task-short-id.js +11 -1
- package/dist/lib/internal/task-snapshot.js +4 -1
- package/dist/lib/internal/task-validate.js +7 -2
- package/dist/lib/internal/task-verify.js +11 -7
- package/dist/lib/internal/task-warning.js +11 -4
- package/dist/lib/platform/adapters.js +1 -3
- package/dist/lib/platform/change-request-git-evidence.js +27 -7
- package/dist/lib/platform/comment-safety.js +226 -0
- package/dist/lib/platform/completion-backfill.js +6 -5
- package/dist/lib/platform/context.js +70 -130
- package/dist/lib/platform/github-client.js +1 -1
- package/dist/lib/platform/github-provider.js +1130 -0
- package/dist/lib/platform/in-label-sync.js +143 -0
- package/dist/lib/platform/issue-comments.js +237 -72
- package/dist/lib/platform/issues.js +335 -189
- package/dist/lib/platform/metadata-labels.js +6 -2
- package/dist/lib/platform/none-provider.js +28 -0
- package/dist/lib/platform/pr-change-report.js +545 -0
- package/dist/lib/platform/pr-checks.js +119 -104
- package/dist/lib/platform/pr-review.js +88 -72
- package/dist/lib/platform/pr-summary.js +541 -50
- package/dist/lib/platform/provider-bridge.js +45 -0
- package/dist/lib/platform/provider-contract.d.ts +553 -0
- package/dist/lib/platform/provider-contract.js +99 -0
- package/dist/lib/platform/provider-loader.js +251 -0
- package/dist/lib/platform/provider-validation.js +577 -0
- package/dist/lib/platform/pull-request-metadata.js +8 -6
- package/dist/lib/platform/pull-requests.js +734 -543
- package/dist/lib/platform/release-notes.js +78 -55
- package/dist/lib/platform/releases.js +79 -50
- package/dist/lib/platform/repository-metadata.js +377 -0
- package/dist/lib/platform/resource-identity.d.ts +26 -0
- package/dist/lib/platform/resource-identity.js +92 -0
- package/dist/lib/platform/security-alerts.js +155 -0
- package/dist/lib/platform/task-identities.js +31 -0
- package/dist/lib/platform/verification-required.js +11 -12
- package/dist/lib/platform/verification-sync.js +129 -248
- package/dist/lib/pr-review/evidence-grading.js +19 -6
- package/dist/lib/process-data/index.js +7 -0
- package/dist/lib/run/index.js +68 -23
- package/dist/lib/sandbox/commands/control-status.js +22 -0
- package/dist/lib/sandbox/commands/create.js +32 -6
- package/dist/lib/sandbox/commands/ls.js +5 -0
- package/dist/lib/sandbox/commands/rm.js +827 -120
- package/dist/lib/sandbox/commands/show.js +16 -0
- package/dist/lib/sandbox/control/client.js +174 -19
- package/dist/lib/sandbox/control/completed-reentry.js +85 -0
- package/dist/lib/sandbox/control/container-identity.js +28 -31
- package/dist/lib/sandbox/control/executor.js +151 -16
- package/dist/lib/sandbox/control/lifecycle.js +621 -127
- package/dist/lib/sandbox/control/native-file-lock.js +177 -0
- package/dist/lib/sandbox/control/protocol.js +77 -0
- package/dist/lib/sandbox/control/server.js +677 -34
- package/dist/lib/sandbox/control/state.js +209 -4
- package/dist/lib/sandbox/control/task-view.js +183 -0
- package/dist/lib/sandbox/engines/authority.js +289 -0
- package/dist/lib/sandbox/engines/docker-exact-discovery.js +97 -0
- package/dist/lib/sandbox/index.js +5 -0
- package/dist/lib/sandbox/recovery.js +21 -1
- package/dist/lib/sandbox/workspace-view.js +2 -1
- package/dist/lib/sandbox/worktree-safety.js +4 -1
- package/dist/lib/server/index.js +8 -0
- package/dist/lib/server/protocol.js +38 -1
- package/dist/lib/task/activity-log.js +8 -1
- package/dist/lib/task/artifact-lifecycle.js +75 -18
- package/dist/lib/task/artifact-operations.js +520 -0
- package/dist/lib/task/artifact-repair-intent.js +59 -0
- package/dist/lib/task/artifact-schema.js +135 -0
- package/dist/lib/task/capabilities.js +310 -0
- package/dist/lib/task/commands/status.js +32 -0
- package/dist/lib/task/commit-operation.js +12 -1
- package/dist/lib/task/control-authority.js +12 -5
- package/dist/lib/task/create-service.js +111 -12
- package/dist/lib/task/create.js +25 -0
- package/dist/lib/task/current-contract.js +5 -1
- package/dist/lib/task/decision-details.js +1 -1
- package/dist/lib/task/events.js +416 -17
- package/dist/lib/task/finalization.js +37 -13
- package/dist/lib/task/human-override.js +58 -36
- package/dist/lib/task/index.js +11 -3
- package/dist/lib/task/invalidation-command.js +86 -0
- package/dist/lib/task/invalidation.js +260 -0
- package/dist/lib/task/ledger-intents.js +37 -0
- package/dist/lib/task/local-artifact-finalization.js +299 -0
- package/dist/lib/task/orchestration.js +240 -144
- package/dist/lib/task/pr-delivery-fact.js +102 -101
- package/dist/lib/task/qualification-audit.js +490 -0
- package/dist/lib/task/qualification-confirmation.js +109 -0
- package/dist/lib/task/qualification-intents.js +148 -0
- package/dist/lib/task/review-artifacts.js +22 -23
- package/dist/lib/task/review-finalization.js +121 -4
- package/dist/lib/task/review-fingerprint.js +24 -2
- package/dist/lib/task/rework-intent.js +138 -0
- package/dist/lib/task/sections.js +6 -4
- package/dist/lib/task/skill-scope.js +23 -0
- package/dist/lib/task/task-execution-lock.js +27 -17
- package/dist/lib/task/verification-config.js +11 -0
- package/dist/lib/task/verification-engine.js +93 -16
- package/dist/lib/task/verification.js +3 -3
- package/dist/lib/task/workflow-warning-intents.js +1 -1
- package/dist/lib/task/write.js +11 -0
- package/dist/lib/version.js +11 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-client.ts +9 -0
- package/lib/agent-clients/next-steps.ts +6 -1
- package/lib/decide.ts +3 -3
- package/lib/init.ts +1 -1
- package/lib/internal/agent-client.ts +4 -2
- package/lib/internal/cli-route-inventory.ts +140 -0
- package/lib/internal/codex-lifecycle.ts +8 -6
- package/lib/internal/codex-sandbox-controller.ts +7 -2
- package/lib/internal/git-workflow.ts +9 -6
- package/lib/internal/platform-checks.ts +14 -6
- package/lib/internal/platform-comment.ts +20 -12
- package/lib/internal/platform-context.ts +5 -3
- package/lib/internal/platform-issue.ts +17 -11
- package/lib/internal/platform-metadata.ts +70 -0
- package/lib/internal/platform-pr-review.ts +23 -12
- package/lib/internal/platform-pr.ts +65 -27
- package/lib/internal/platform-release-notes.ts +8 -6
- package/lib/internal/platform-security.ts +83 -0
- package/lib/internal/pr-review-grade.ts +20 -11
- package/lib/internal/release-workflow.ts +21 -9
- package/lib/internal/sandbox-control.ts +44 -6
- package/lib/internal/task-activity.ts +15 -7
- package/lib/internal/task-artifact.ts +204 -22
- package/lib/internal/task-context.ts +3 -1
- package/lib/internal/task-create.ts +78 -17
- package/lib/internal/task-delivery.ts +3 -1
- package/lib/internal/task-event.ts +9 -4
- package/lib/internal/task-finalization.ts +6 -4
- package/lib/internal/task-invalidation.ts +41 -0
- package/lib/internal/task-ledger.ts +21 -8
- package/lib/internal/task-lifecycle.ts +5 -3
- package/lib/internal/task-operation-registry.ts +482 -0
- package/lib/internal/task-orchestration.ts +12 -0
- package/lib/internal/task-override.ts +15 -9
- package/lib/internal/task-qualification.ts +61 -0
- package/lib/internal/task-review.ts +6 -4
- package/lib/internal/task-short-id.ts +10 -1
- package/lib/internal/task-snapshot.ts +3 -1
- package/lib/internal/task-validate.ts +6 -2
- package/lib/internal/task-verify.ts +10 -7
- package/lib/internal/task-warning.ts +10 -4
- package/lib/platform/adapters.ts +3 -2
- package/lib/platform/change-request-git-evidence.ts +36 -9
- package/lib/platform/comment-safety.ts +250 -0
- package/lib/platform/completion-backfill.ts +9 -8
- package/lib/platform/context.ts +97 -134
- package/lib/platform/github-client.ts +2 -2
- package/lib/platform/github-provider.ts +1132 -0
- package/lib/platform/in-label-sync.ts +208 -0
- package/lib/platform/issue-comments.ts +255 -80
- package/lib/platform/issues.ts +344 -174
- package/lib/platform/metadata-labels.ts +5 -2
- package/lib/platform/none-provider.ts +35 -0
- package/lib/platform/pr-change-report.ts +639 -0
- package/lib/platform/pr-checks.ts +126 -106
- package/lib/platform/pr-review.ts +88 -85
- package/lib/platform/pr-summary.ts +581 -53
- package/lib/platform/provider-bridge.ts +82 -0
- package/lib/platform/provider-contract.ts +611 -0
- package/lib/platform/provider-loader.ts +307 -0
- package/lib/platform/provider-validation.ts +611 -0
- package/lib/platform/pull-request-metadata.ts +10 -7
- package/lib/platform/pull-requests.ts +781 -550
- package/lib/platform/release-notes.ts +76 -59
- package/lib/platform/releases.ts +77 -43
- package/lib/platform/repository-metadata.ts +453 -0
- package/lib/platform/resource-identity.ts +121 -0
- package/lib/platform/security-alerts.ts +191 -0
- package/lib/platform/task-identities.ts +40 -0
- package/lib/platform/types.ts +4 -2
- package/lib/platform/verification-required.ts +11 -13
- package/lib/platform/verification-sync.ts +128 -304
- package/lib/pr-review/evidence-grading.ts +25 -8
- package/lib/process-data/index.ts +7 -0
- package/lib/run/index.ts +62 -22
- package/lib/sandbox/commands/control-status.ts +26 -0
- package/lib/sandbox/commands/create.ts +46 -6
- package/lib/sandbox/commands/ls.ts +7 -0
- package/lib/sandbox/commands/rm.ts +1000 -87
- package/lib/sandbox/commands/show.ts +16 -0
- package/lib/sandbox/control/client.ts +203 -19
- package/lib/sandbox/control/completed-reentry.ts +98 -0
- package/lib/sandbox/control/container-identity.ts +27 -43
- package/lib/sandbox/control/executor.ts +180 -15
- package/lib/sandbox/control/lifecycle.ts +629 -17
- package/lib/sandbox/control/native-file-lock.ts +209 -0
- package/lib/sandbox/control/protocol.ts +118 -2
- package/lib/sandbox/control/server.ts +724 -34
- package/lib/sandbox/control/state.ts +257 -4
- package/lib/sandbox/control/task-view.ts +240 -0
- package/lib/sandbox/engines/authority.ts +365 -0
- package/lib/sandbox/engines/docker-exact-discovery.ts +132 -0
- package/lib/sandbox/index.ts +7 -0
- package/lib/sandbox/recovery.ts +21 -1
- package/lib/sandbox/workspace-view.ts +9 -3
- package/lib/sandbox/worktree-safety.ts +4 -1
- package/lib/server/index.ts +10 -0
- package/lib/server/protocol.ts +36 -1
- package/lib/task/activity-log.ts +8 -0
- package/lib/task/artifact-lifecycle.ts +70 -22
- package/lib/task/artifact-operations.ts +626 -0
- package/lib/task/artifact-repair-intent.ts +71 -0
- package/lib/task/artifact-schema.ts +192 -0
- package/lib/task/capabilities.ts +331 -0
- package/lib/task/commands/status.ts +38 -0
- package/lib/task/commit-operation.ts +12 -1
- package/lib/task/control-authority.ts +22 -9
- package/lib/task/create-service.ts +139 -14
- package/lib/task/create.ts +27 -0
- package/lib/task/current-contract.ts +6 -1
- package/lib/task/decision-details.ts +6 -2
- package/lib/task/events.ts +392 -16
- package/lib/task/finalization.ts +50 -14
- package/lib/task/human-override.ts +70 -46
- package/lib/task/index.ts +16 -3
- package/lib/task/invalidation-command.ts +86 -0
- package/lib/task/invalidation.ts +332 -0
- package/lib/task/ledger-intents.ts +35 -1
- package/lib/task/local-artifact-finalization.ts +432 -0
- package/lib/task/orchestration.ts +223 -133
- package/lib/task/pr-delivery-fact.ts +131 -148
- package/lib/task/qualification-audit.ts +599 -0
- package/lib/task/qualification-confirmation.ts +117 -0
- package/lib/task/qualification-intents.ts +150 -0
- package/lib/task/review-artifacts.ts +21 -22
- package/lib/task/review-finalization.ts +133 -4
- package/lib/task/review-fingerprint.ts +23 -2
- package/lib/task/rework-intent.ts +165 -0
- package/lib/task/sections.ts +6 -4
- package/lib/task/skill-scope.ts +24 -0
- package/lib/task/task-execution-lock.ts +23 -14
- package/lib/task/verification-config.ts +12 -0
- package/lib/task/verification-engine.ts +103 -17
- package/lib/task/verification.ts +4 -4
- package/lib/task/workflow-warning-intents.ts +1 -1
- package/lib/task/write.ts +19 -0
- package/lib/update.ts +1 -1
- package/lib/version.ts +15 -1
- package/package.json +12 -1
- package/templates/.agents/rules/README.en.md +3 -1
- package/templates/.agents/rules/README.zh-CN.md +3 -1
- package/templates/.agents/rules/decision-qualification.en.md +22 -0
- package/templates/.agents/rules/decision-qualification.zh-CN.md +22 -0
- package/templates/.agents/rules/evidence-reporting.en.md +28 -0
- package/templates/.agents/rules/evidence-reporting.zh-CN.md +28 -0
- package/templates/.agents/rules/issue-pr-commands.en.md +1 -1
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +2 -0
- package/templates/.agents/rules/issue-sync.zh-CN.md +2 -0
- package/templates/.agents/rules/label-milestone-setup.en.md +7 -7
- package/templates/.agents/rules/label-milestone-setup.zh-CN.md +7 -7
- package/templates/.agents/rules/local-artifact-repair.en.md +13 -2
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +13 -2
- package/templates/.agents/rules/pr-sync.en.md +10 -4
- package/templates/.agents/rules/pr-sync.zh-CN.md +17 -4
- package/templates/.agents/rules/security-alerts.en.md +8 -8
- package/templates/.agents/rules/security-alerts.zh-CN.md +8 -8
- package/templates/.agents/rules/task-short-id.en.md +1 -4
- package/templates/.agents/rules/task-short-id.zh-CN.md +1 -3
- package/templates/.agents/skills/analyze-task/SKILL.en.md +28 -5
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +29 -5
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -12
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -12
- package/templates/.agents/skills/check-task/SKILL.en.md +16 -37
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -37
- package/templates/.agents/skills/close-codescan/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +41 -9
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +43 -11
- package/templates/.agents/skills/code-task/config/verify.en.json +6 -14
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +6 -14
- package/templates/.agents/skills/code-task/reference/code-rules.en.md +5 -4
- package/templates/.agents/skills/code-task/reference/code-rules.zh-CN.md +5 -4
- package/templates/.agents/skills/code-task/reference/dual-mode.en.md +1 -1
- package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +1 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +3 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +3 -1
- package/templates/.agents/skills/code-task/reference/report-template.en.md +42 -15
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +39 -12
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +2 -0
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +2 -0
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +3 -3
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +3 -3
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +10 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +10 -4
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.en.md +2 -0
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.zh-CN.md +2 -0
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +4 -3
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +4 -3
- package/templates/.agents/skills/complete-task/SKILL.en.md +26 -21
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +25 -21
- package/templates/.agents/skills/create-pr/SKILL.en.md +7 -6
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -7
- package/templates/.agents/skills/create-pr/config/verify.json +1 -0
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +16 -4
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +16 -4
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +5 -3
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +5 -3
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/scripts/change-report.mjs +3 -0
- package/templates/.agents/skills/create-task/SKILL.en.md +8 -0
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +7 -0
- package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/init-labels/SKILL.en.md +8 -8
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/init-milestones/SKILL.en.md +9 -11
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +9 -11
- package/templates/.agents/skills/plan-task/SKILL.en.md +27 -4
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +26 -4
- package/templates/.agents/skills/plan-task/config/verify.en.json +4 -14
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +4 -14
- package/templates/.agents/skills/review-analysis/SKILL.en.md +17 -4
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +17 -4
- package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -18
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -18
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +50 -23
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-code/SKILL.en.md +18 -5
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +18 -5
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -23
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -23
- package/templates/.agents/skills/review-code/reference/report-template.en.md +49 -22
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-plan/SKILL.en.md +17 -4
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +17 -4
- package/templates/.agents/skills/review-plan/config/verify.en.json +1 -18
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -18
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +49 -22
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-pr/SKILL.en.md +5 -1
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +5 -1
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +4 -3
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +4 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +9 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +9 -3
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +3 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +3 -1
- package/templates/.agents/skills/test/SKILL.en.md +13 -2
- package/templates/.agents/skills/test/SKILL.zh-CN.md +13 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +14 -0
- package/templates/.agents/skills/watch-pr/SKILL.en.md +2 -2
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +6 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +6 -0
- package/templates/.agents/templates/task.en.md +24 -1
- package/templates/.agents/templates/task.zh-CN.md +24 -1
- package/templates/.github/workflows/pr-label.yml +7 -26
- package/templates/.agents/scripts/security-alerts.github.sh +0 -151
- package/templates/.agents/scripts/security-alerts.sh +0 -31
- package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +0 -146
- package/templates/.agents/skills/init-labels/scripts/init-labels.sh +0 -32
- package/templates/.agents/skills/init-milestones/scripts/init-milestones.github.sh +0 -294
- package/templates/.agents/skills/init-milestones/scripts/init-milestones.sh +0 -6
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
recoverSandboxControl,
|
|
2
3
|
requestSandboxControl,
|
|
3
4
|
requestSandboxTaskFinalization,
|
|
4
5
|
requestSandboxTaskControl,
|
|
@@ -11,6 +12,8 @@ import {
|
|
|
11
12
|
controllerProofFromContext,
|
|
12
13
|
verifyCodexSandboxControllerContextWithWarnings
|
|
13
14
|
} from '../agent-clients/adapters/codex-lifecycle/sandbox-controller.ts';
|
|
15
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
16
|
+
import { parseTaskCreateResult, taskCreateExitCode } from '../task/create-service.ts';
|
|
14
17
|
|
|
15
18
|
function isCanonicalCodexPrepare(args: readonly string[]): boolean {
|
|
16
19
|
if (args[1] !== 'prepare') return false;
|
|
@@ -39,6 +42,22 @@ function finalizationErrorStatus(error: { retryable: boolean; code: string }): F
|
|
|
39
42
|
return error.retryable ? 'blocked' : 'failed';
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
function writeClientError(error: SandboxControlClientError): void {
|
|
46
|
+
process.stderr.write(`${error.detail.message}\n`);
|
|
47
|
+
if (error.requestId) process.stderr.write(`SANDBOX_CONTROL_REQUEST_ID: ${error.requestId}\n`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function recoveredExitCode(response: Awaited<ReturnType<typeof recoverSandboxControl>>): number {
|
|
51
|
+
if (response.phase !== 'completed') return response.exitCode ?? 1;
|
|
52
|
+
try {
|
|
53
|
+
const result = parseTaskCreateResult(JSON.parse(response.stdout));
|
|
54
|
+
if (result.control?.requestId === response.id) return taskCreateExitCode(result);
|
|
55
|
+
} catch {
|
|
56
|
+
// Other control families use their own result envelopes.
|
|
57
|
+
}
|
|
58
|
+
return response.exitCode ?? 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
42
61
|
function sandboxFinalizationClient(args: string[]): void {
|
|
43
62
|
if (args.length !== 4 || !args[0] || args[1] !== 'complete' || args[2] !== '--agent' || !args[3]) {
|
|
44
63
|
const error = { code: 'TASK_FINALIZATION_PAYLOAD_INVALID', message: 'task ref, complete intent, and --agent are required', retryable: false };
|
|
@@ -60,7 +79,7 @@ function sandboxFinalizationClient(args: string[]): void {
|
|
|
60
79
|
} catch (error) {
|
|
61
80
|
if (!(error instanceof SandboxControlClientError)) throw error;
|
|
62
81
|
writeFinalizationEnvelope(finalizationErrorStatus(error.detail), error.accepted, error.detail);
|
|
63
|
-
|
|
82
|
+
writeClientError(error);
|
|
64
83
|
process.exitCode = error.detail.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN' ? 1 : error.detail.retryable ? 2 : 1;
|
|
65
84
|
return;
|
|
66
85
|
}
|
|
@@ -81,8 +100,9 @@ function sandboxFinalizationClient(args: string[]): void {
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
async function sandboxControl(args: string[]): Promise<void> {
|
|
103
|
+
if (!ensureInternalHandlerRoute('sandbox-control', args)) return;
|
|
84
104
|
const [operation, ...rest] = args;
|
|
85
|
-
if (operation
|
|
105
|
+
if (internalHandlerRoute('sandbox-control', 'serve', operation ?? '')) {
|
|
86
106
|
const manifestIndex = rest.indexOf('--manifest');
|
|
87
107
|
const manifest = manifestIndex >= 0 ? rest[manifestIndex + 1] : undefined;
|
|
88
108
|
if (!manifest) throw new Error('sandbox-control serve requires --manifest');
|
|
@@ -98,7 +118,7 @@ async function sandboxControl(args: string[]): Promise<void> {
|
|
|
98
118
|
}
|
|
99
119
|
return;
|
|
100
120
|
}
|
|
101
|
-
if (operation
|
|
121
|
+
if (internalHandlerRoute('sandbox-control', 'execute', operation ?? '')) {
|
|
102
122
|
const requestIndex = rest.indexOf('--request');
|
|
103
123
|
const nonceIndex = rest.indexOf('--nonce');
|
|
104
124
|
const request = requestIndex >= 0 ? rest[requestIndex + 1] : undefined;
|
|
@@ -107,7 +127,25 @@ async function sandboxControl(args: string[]): Promise<void> {
|
|
|
107
127
|
await runSandboxControlExecutor(request, nonce);
|
|
108
128
|
return;
|
|
109
129
|
}
|
|
110
|
-
if (operation
|
|
130
|
+
if (internalHandlerRoute('sandbox-control', 'recover', operation ?? '')) {
|
|
131
|
+
if (rest.length !== 1 || !rest[0]) throw new Error('sandbox-control recover requires <request-id>');
|
|
132
|
+
let response;
|
|
133
|
+
try {
|
|
134
|
+
response = recoverSandboxControl(rest[0]);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (!(error instanceof SandboxControlClientError)) throw error;
|
|
137
|
+
writeClientError(error);
|
|
138
|
+
process.exitCode = error.detail.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN' ? 1 : error.detail.retryable ? 75 : 1;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
process.stdout.write(response.stdout);
|
|
142
|
+
process.stderr.write(response.stderr);
|
|
143
|
+
process.exitCode = response.phase === 'rejected'
|
|
144
|
+
? response.error?.retryable ? 75 : 1
|
|
145
|
+
: recoveredExitCode(response);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (internalHandlerRoute('sandbox-control', 'client', operation ?? '')) {
|
|
111
149
|
const [family = '', ...commandArgs] = rest;
|
|
112
150
|
if (family === 'task-finalization') {
|
|
113
151
|
sandboxFinalizationClient(commandArgs);
|
|
@@ -126,7 +164,7 @@ async function sandboxControl(args: string[]): Promise<void> {
|
|
|
126
164
|
}
|
|
127
165
|
} catch (error) {
|
|
128
166
|
if (!(error instanceof SandboxControlClientError)) throw error;
|
|
129
|
-
|
|
167
|
+
writeClientError(error);
|
|
130
168
|
process.exitCode = error.detail.retryable ? 75 : 1;
|
|
131
169
|
return;
|
|
132
170
|
}
|
|
@@ -140,7 +178,7 @@ async function sandboxControl(args: string[]): Promise<void> {
|
|
|
140
178
|
}
|
|
141
179
|
return;
|
|
142
180
|
}
|
|
143
|
-
throw new Error('Usage: agent-infra-internal sandbox-control serve --manifest <path> | execute --request <path> --nonce <nonce> | client <family> [args...]');
|
|
181
|
+
throw new Error('Usage: agent-infra-internal sandbox-control serve --manifest <path> | execute --request <path> --nonce <nonce> | client <family> [args...] | recover <request-id>');
|
|
144
182
|
}
|
|
145
183
|
|
|
146
184
|
export { sandboxControl };
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
import { consumeHumanOverride, failureId, overrideDryRunConflict } from '../task/human-override.ts';
|
|
10
10
|
import { resolveTaskRef } from '../task/resolve-ref.ts';
|
|
11
11
|
import { TaskExecutionLockError, withTaskExecutionLock } from '../task/task-execution-lock.ts';
|
|
12
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
12
13
|
|
|
13
14
|
const USAGE = `Usage: agent-infra-internal task-activity <task-ref> pr-review-inspect
|
|
14
15
|
agent-infra-internal task-activity <task-ref> pr-review-start --agent <agent> --artifact <canonical.md> --head <40hex> [--dry-run]
|
|
@@ -43,10 +44,17 @@ function usageFailure(message: string): void {
|
|
|
43
44
|
process.exitCode = 1;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
function taskActivity(args: string[] = []): void {
|
|
47
|
+
async function taskActivity(args: string[] = []): Promise<void> {
|
|
48
|
+
if (!ensureInternalHandlerRoute('task-activity', args)) return;
|
|
47
49
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
48
50
|
const [taskRef, kind] = args;
|
|
49
|
-
if (!taskRef || taskRef.startsWith('--') || !kind || !OPERATIONS.has(kind)
|
|
51
|
+
if (!taskRef || taskRef.startsWith('--') || !kind || !OPERATIONS.has(kind)
|
|
52
|
+
|| ![
|
|
53
|
+
internalHandlerRoute('task-activity', 'pr-review-inspect', kind),
|
|
54
|
+
internalHandlerRoute('task-activity', 'pr-review-start', kind),
|
|
55
|
+
internalHandlerRoute('task-activity', 'pr-review-complete', kind),
|
|
56
|
+
internalHandlerRoute('task-activity', 'pr-review-terminate', kind)
|
|
57
|
+
].some(Boolean)) {
|
|
50
58
|
usageFailure('task ref and a supported PR review intent are required');
|
|
51
59
|
return;
|
|
52
60
|
}
|
|
@@ -72,7 +80,7 @@ function taskActivity(args: string[] = []): void {
|
|
|
72
80
|
const allowed = ALLOWED[kind]!;
|
|
73
81
|
const unexpected = Object.keys(values).find((key) => !allowed.has(key));
|
|
74
82
|
if (unexpected) { usageFailure(`${kind} does not accept '${unexpected}'`); return; }
|
|
75
|
-
if (
|
|
83
|
+
if (internalHandlerRoute('task-activity', 'pr-review-inspect', kind)) {
|
|
76
84
|
const result = inspectPrReviewActivity(values as PrReviewInspectIntent);
|
|
77
85
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
78
86
|
if (result.status === 'failed') process.exitCode = 1;
|
|
@@ -81,9 +89,9 @@ function taskActivity(args: string[] = []): void {
|
|
|
81
89
|
for (const key of COMMON) {
|
|
82
90
|
if (values[key] === undefined) { usageFailure(`${kind} requires '${key}'`); return; }
|
|
83
91
|
}
|
|
84
|
-
const operationRequired =
|
|
92
|
+
const operationRequired = internalHandlerRoute('task-activity', 'pr-review-complete', kind)
|
|
85
93
|
? ['verdict', 'blockers', 'major', 'minor']
|
|
86
|
-
:
|
|
94
|
+
: internalHandlerRoute('task-activity', 'pr-review-terminate', kind) ? ['outcome', 'reason'] : [];
|
|
87
95
|
for (const key of operationRequired) {
|
|
88
96
|
if (values[key] === undefined) { usageFailure(`${kind} requires '${key}'`); return; }
|
|
89
97
|
}
|
|
@@ -94,11 +102,11 @@ function taskActivity(args: string[] = []): void {
|
|
|
94
102
|
let result;
|
|
95
103
|
let humanOverride: unknown = null;
|
|
96
104
|
try {
|
|
97
|
-
result = withTaskExecutionLock(resolved.repoRoot, resolved.taskId, `task-activity.${kind}`, () => {
|
|
105
|
+
result = await withTaskExecutionLock(resolved.repoRoot, resolved.taskId, `task-activity.${kind}`, async () => {
|
|
98
106
|
let current = applyPrReviewActivityIntent(values as PrReviewActivityIntent, { lockAlreadyHeld: true });
|
|
99
107
|
if (current.status !== 'failed' || !values.overrideTicket) return current;
|
|
100
108
|
if (!values.overrideTarget || !values.overrideScope) { usageFailure('override ticket requires target and scope'); return current; }
|
|
101
|
-
const consumed = consumeHumanOverride({
|
|
109
|
+
const consumed = await consumeHumanOverride({
|
|
102
110
|
taskRef, ticketId: String(values.overrideTicket),
|
|
103
111
|
failureId: failureId('activity-intent', current.error?.code ?? 'TASK_STATE_MISMATCH'),
|
|
104
112
|
target: String(values.overrideTarget), scope: String(values.overrideScope)
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
1
4
|
import { resolveArtifactContext } from '../task/artifact-lifecycle.ts';
|
|
5
|
+
import { parseArtifactName } from '../task/artifact-lifecycle.ts';
|
|
6
|
+
import { locateActivityLog, pairEntries, startedBackedRows } from '../task/activity-log.ts';
|
|
7
|
+
import { finalizeLocalArtifact } from '../task/local-artifact-finalization.ts';
|
|
8
|
+
import type { LocalArtifactFamily } from '../task/local-artifact-finalization.ts';
|
|
9
|
+
import { resolveTaskRef } from '../task/resolve-ref.ts';
|
|
10
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
11
|
+
import { getArtifactSchema } from '../task/artifact-schema.ts';
|
|
12
|
+
import {
|
|
13
|
+
applyArtifactRepair,
|
|
14
|
+
initializeArtifactSkeleton,
|
|
15
|
+
inspectArtifactStructure
|
|
16
|
+
} from '../task/artifact-operations.ts';
|
|
2
17
|
|
|
3
|
-
const USAGE = `Usage: agent-infra-internal task-artifact <N | TASK-id> inspect --family <family>\n\
|
|
18
|
+
const USAGE = `Usage: agent-infra-internal task-artifact <N | TASK-id> inspect --family <family>\n agent-infra-internal task-artifact <N | TASK-id> init --family <family> --artifact <artifact> [--locale <zh-CN|en>]\n agent-infra-internal task-artifact <N | TASK-id> repair --family <family> --artifact <artifact> --expected-sha256 <sha256> --expected-semantic-digest <digest>\n agent-infra-internal task-artifact <N | TASK-id> finalize-local --family <analysis|plan|code> --artifact <artifact>\n\nInspect, initialize, repair, or finalize a workflow artifact without changing task state.\n`;
|
|
4
19
|
|
|
5
20
|
function failUsage(message: string): void {
|
|
6
21
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_PAYLOAD_INVALID', message } })}\n`);
|
|
@@ -8,40 +23,207 @@ function failUsage(message: string): void {
|
|
|
8
23
|
process.exitCode = 2;
|
|
9
24
|
}
|
|
10
25
|
|
|
26
|
+
function hasOpenLocalArtifactRound(taskDir: string, family: string, round: number): boolean {
|
|
27
|
+
try {
|
|
28
|
+
const activity = locateActivityLog(fs.readFileSync(path.join(taskDir, 'task.md'), 'utf8'));
|
|
29
|
+
if (!activity) return false;
|
|
30
|
+
const label = family === 'analysis'
|
|
31
|
+
? 'Analyze Task'
|
|
32
|
+
: family === 'review-analysis'
|
|
33
|
+
? 'Review Analysis'
|
|
34
|
+
: family === 'plan'
|
|
35
|
+
? 'Plan Task'
|
|
36
|
+
: family === 'review-plan'
|
|
37
|
+
? 'Review Plan'
|
|
38
|
+
: family === 'code'
|
|
39
|
+
? 'Code Task'
|
|
40
|
+
: 'Review Code';
|
|
41
|
+
const qualifier = family === 'code'
|
|
42
|
+
? '(?:, (?:fix for review-code(?:-r\\d+)?\\.md|decision II-[1-9]\\d*))?'
|
|
43
|
+
: '';
|
|
44
|
+
const expected = new RegExp(`^${label} \\(Round ${round}${qualifier}\\)$`);
|
|
45
|
+
return startedBackedRows(pairEntries(activity.entries)).some((row) => expected.test(row.step) && !row.done);
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
11
51
|
function taskArtifact(args: string[] = []): void {
|
|
52
|
+
if (!ensureInternalHandlerRoute('task-artifact', args)) return;
|
|
12
53
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
13
54
|
if (args.length < 2) { failUsage('task ref and operation are required'); return; }
|
|
14
|
-
|
|
55
|
+
const operation = args[1];
|
|
56
|
+
if (!internalHandlerRoute('task-artifact', 'inspect', operation ?? '')
|
|
57
|
+
&& !internalHandlerRoute('task-artifact', 'init', operation ?? '')
|
|
58
|
+
&& !internalHandlerRoute('task-artifact', 'repair', operation ?? '')
|
|
59
|
+
&& !internalHandlerRoute('task-artifact', 'finalize-local', operation ?? '')) { failUsage(`unknown operation '${operation}'`); return; }
|
|
15
60
|
let family = '';
|
|
61
|
+
let artifact = '';
|
|
62
|
+
let locale: 'zh-CN' | 'en' | undefined;
|
|
63
|
+
let expectedSha256 = '';
|
|
64
|
+
let expectedSemanticDigest = '';
|
|
16
65
|
const seen = new Set<string>();
|
|
17
66
|
for (let index = 2; index < args.length; index += 1) {
|
|
18
67
|
const flag = args[index]!;
|
|
19
|
-
if (flag !== '--family') { failUsage(`unknown option '${flag}'`); return; }
|
|
68
|
+
if (flag !== '--family' && flag !== '--artifact' && flag !== '--locale' && flag !== '--expected-sha256' && flag !== '--expected-semantic-digest') { failUsage(`unknown option '${flag}'`); return; }
|
|
20
69
|
if (seen.has(flag)) { failUsage(`duplicate option '${flag}'`); return; }
|
|
21
70
|
const value = args[++index];
|
|
22
71
|
if (!value || value.startsWith('--')) { failUsage(`option '${flag}' requires a value`); return; }
|
|
23
72
|
seen.add(flag);
|
|
24
|
-
family = value;
|
|
73
|
+
if (flag === '--family') family = value;
|
|
74
|
+
else if (flag === '--artifact') artifact = value;
|
|
75
|
+
else if (flag === '--locale') {
|
|
76
|
+
if (value !== 'zh-CN' && value !== 'en') { failUsage("option '--locale' must be 'zh-CN' or 'en'"); return; }
|
|
77
|
+
locale = value;
|
|
78
|
+
} else if (flag === '--expected-sha256') expectedSha256 = value;
|
|
79
|
+
else expectedSemanticDigest = value;
|
|
25
80
|
}
|
|
26
81
|
if (!family) { failUsage("option '--family' is required"); return; }
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
82
|
+
if ((operation === 'init' || operation === 'repair' || operation === 'finalize-local') && !artifact) { failUsage("option '--artifact' is required"); return; }
|
|
83
|
+
if (internalHandlerRoute('task-artifact', 'inspect', operation ?? '')) {
|
|
84
|
+
if (artifact || locale || expectedSha256 || expectedSemanticDigest) { failUsage("artifact options are only valid for init, repair, or finalize-local"); return; }
|
|
85
|
+
const result = resolveArtifactContext(args[0]!, family);
|
|
86
|
+
const output = family === 'code' && result.codeMode ? {
|
|
87
|
+
...result,
|
|
88
|
+
mode: result.codeMode.mode,
|
|
89
|
+
code_max: result.codeMode.codeMax,
|
|
90
|
+
rev_max: result.codeMode.reviewMax,
|
|
91
|
+
verdict: result.codeMode.verdict,
|
|
92
|
+
next_round: result.next?.round ?? null,
|
|
93
|
+
next_artifact: result.next?.name ?? null,
|
|
94
|
+
review_artifact: result.codeMode.reviewArtifact,
|
|
95
|
+
implementation_input: result.codeMode.implementationInput,
|
|
96
|
+
decision_id: result.codeMode.decisionId,
|
|
97
|
+
decision_evidence: result.codeMode.decisionEvidence,
|
|
98
|
+
message: result.codeMode.message
|
|
99
|
+
} : result;
|
|
100
|
+
process.stdout.write(`${JSON.stringify(output)}\n`);
|
|
101
|
+
if (result.status === 'refused') process.exitCode = 1;
|
|
102
|
+
else if (result.status === 'failed') process.exitCode = 2;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (internalHandlerRoute('task-artifact', 'init', operation ?? '')) {
|
|
106
|
+
if (expectedSha256 || expectedSemanticDigest) { failUsage("repair baseline options are only valid for repair"); return; }
|
|
107
|
+
const schema = getArtifactSchema(family);
|
|
108
|
+
const resolved = resolveTaskRef(args[0]!);
|
|
109
|
+
if (!schema) { failUsage(`init does not support artifact family '${family}'`); return; }
|
|
110
|
+
if (!resolved.ok) {
|
|
111
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: resolved.code, message: resolved.message } })}\n`);
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const parsed = parseArtifactName(artifact);
|
|
116
|
+
if (!parsed || parsed.family !== family) {
|
|
117
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_INIT_CONTEXT_INVALID', message: `artifact '${artifact}' does not match ${family}` } })}\n`);
|
|
118
|
+
process.exitCode = 1;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const context = resolveArtifactContext(args[0]!, family);
|
|
122
|
+
const isNextArtifact = context.status === 'ready' && context.next?.name === artifact;
|
|
123
|
+
const isCurrentOpenArtifact = context.status === 'ready'
|
|
124
|
+
&& context.taskDir !== null
|
|
125
|
+
&& hasOpenLocalArtifactRound(context.taskDir, family, parsed.round);
|
|
126
|
+
if (!isNextArtifact && !isCurrentOpenArtifact) {
|
|
127
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_INIT_CONTEXT_INVALID', message: context.error?.message ?? `artifact '${artifact}' is not the next ${family} artifact` } })}\n`);
|
|
128
|
+
process.exitCode = 1;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!context.taskId || !context.taskDir) {
|
|
132
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_INIT_CONTEXT_INVALID', message: `artifact '${artifact}' does not match ${family}` } })}\n`);
|
|
133
|
+
process.exitCode = 1;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const existing = fs.lstatSync(path.join(resolved.taskDir, artifact));
|
|
138
|
+
if (existing.isSymbolicLink() || !existing.isFile()) {
|
|
139
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_INIT_TARGET_INVALID', message: 'artifact target is not a regular file' } })}\n`);
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const result = initializeArtifactSkeleton({ repoRoot: resolved.repoRoot, taskId: resolved.taskId, taskDir: resolved.taskDir, family: schema.family, artifact, ...(locale ? { locale } : {}) });
|
|
144
|
+
process.stdout.write(`${JSON.stringify({ ...result, taskId: resolved.taskId, taskDir: resolved.taskDir, family, artifact })}\n`);
|
|
145
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
146
|
+
return;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
149
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_INIT_TARGET_INVALID', message: String(error) } })}\n`);
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const result = initializeArtifactSkeleton({
|
|
155
|
+
repoRoot: resolved.repoRoot,
|
|
156
|
+
taskId: context.taskId,
|
|
157
|
+
taskDir: context.taskDir,
|
|
158
|
+
family: schema.family,
|
|
159
|
+
artifact,
|
|
160
|
+
...(locale ? { locale } : {})
|
|
161
|
+
});
|
|
162
|
+
process.stdout.write(`${JSON.stringify({ ...result, taskId: context.taskId, taskDir: context.taskDir, family, artifact })}\n`);
|
|
163
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (internalHandlerRoute('task-artifact', 'repair', operation ?? '')) {
|
|
167
|
+
if (locale) { failUsage("option '--locale' is only valid for init"); return; }
|
|
168
|
+
if (!/^[a-f0-9]{64}$/.test(expectedSha256) || !/^[a-f0-9]{64}$/.test(expectedSemanticDigest)) {
|
|
169
|
+
failUsage("repair requires lowercase 64-character '--expected-sha256' and '--expected-semantic-digest'");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const schema = getArtifactSchema(family);
|
|
173
|
+
const resolved = resolveTaskRef(args[0]!);
|
|
174
|
+
const parsed = parseArtifactName(artifact);
|
|
175
|
+
if (!schema || !parsed || parsed.family !== family) {
|
|
176
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_REPAIR_TARGET_INVALID', message: `artifact '${artifact}' does not match ${family}` } })}\n`);
|
|
177
|
+
process.exitCode = 1;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!resolved.ok) {
|
|
181
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: resolved.code, message: resolved.message } })}\n`);
|
|
182
|
+
process.exitCode = 1;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
let content: string;
|
|
186
|
+
try { content = fs.readFileSync(path.join(resolved.taskDir, artifact), 'utf8'); }
|
|
187
|
+
catch (error) {
|
|
188
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ARTIFACT_REPAIR_TARGET_INVALID', message: String(error) } })}\n`);
|
|
189
|
+
process.exitCode = 1;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const inspection = inspectArtifactStructure(content, schema);
|
|
193
|
+
if (!inspection.repair) {
|
|
194
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, artifact, family, diagnostics: inspection.diagnostics, error: { code: 'ARTIFACT_REPAIR_UNSAFE', message: inspection.diagnostics.map((item) => `${item.code}: ${item.message}`).join('; ') || 'no deterministic structural repair is available' } })}\n`);
|
|
195
|
+
process.exitCode = 1;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const result = applyArtifactRepair({
|
|
199
|
+
repoRoot: resolved.repoRoot,
|
|
200
|
+
taskId: resolved.taskId,
|
|
201
|
+
taskDir: resolved.taskDir,
|
|
202
|
+
family: schema.family,
|
|
203
|
+
artifact,
|
|
204
|
+
expectedSha256,
|
|
205
|
+
expectedSemanticDigest,
|
|
206
|
+
operation: inspection.repair
|
|
207
|
+
});
|
|
208
|
+
process.stdout.write(`${JSON.stringify({ ...result, taskId: resolved.taskId, taskDir: resolved.taskDir, family, artifact })}\n`);
|
|
209
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const resolved = resolveTaskRef(args[0]!);
|
|
213
|
+
const repositoryRoot = resolved.ok ? resolved.repoRoot : process.cwd();
|
|
214
|
+
if (!artifact) { failUsage("option '--artifact' is required"); return; }
|
|
215
|
+
if (family !== 'analysis' && family !== 'plan' && family !== 'code') {
|
|
216
|
+
failUsage("finalize-local only supports 'analysis', 'plan', and 'code'");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const result = finalizeLocalArtifact({
|
|
220
|
+
taskRef: args[0]!,
|
|
221
|
+
family: family as LocalArtifactFamily,
|
|
222
|
+
artifact,
|
|
223
|
+
repoRoot: repositoryRoot
|
|
224
|
+
});
|
|
225
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
226
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
45
227
|
}
|
|
46
228
|
|
|
47
229
|
export { taskArtifact };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseTaskScope } from '../task/command-options.ts';
|
|
2
2
|
import { resolveTaskContext } from '../task/resolve-ref.ts';
|
|
3
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
3
4
|
|
|
4
5
|
const USAGE = `Usage: agent-infra-internal task-context resolve [<task-ref> | --task <task-ref> | -t <task-ref>]\n`;
|
|
5
6
|
|
|
@@ -10,8 +11,9 @@ function fail(code: string, message: string, usage = false): void {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function taskContext(args: string[] = []): void {
|
|
14
|
+
if (!ensureInternalHandlerRoute('task-context', args)) return;
|
|
13
15
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
14
|
-
if (args[0]
|
|
16
|
+
if (!internalHandlerRoute('task-context', 'resolve', args[0] ?? '')) { fail('TASK_CONTEXT_PAYLOAD_INVALID', "operation 'resolve' is required", true); return; }
|
|
15
17
|
let scope;
|
|
16
18
|
try {
|
|
17
19
|
scope = parseTaskScope(args.slice(1));
|
|
@@ -1,25 +1,77 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
classifySandboxControlEnvironment,
|
|
6
|
+
requestSandboxTaskCreate,
|
|
7
|
+
SandboxControlClientError
|
|
8
|
+
} from '../sandbox/control/client.ts';
|
|
5
9
|
import { SANDBOX_CONTROL_MAX_BYTES } from '../sandbox/control/protocol.ts';
|
|
6
10
|
import { validateTaskCreateCandidate } from '../task/create.ts';
|
|
7
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
createTask,
|
|
13
|
+
parseTaskCreateResult,
|
|
14
|
+
projectTaskCreateResult,
|
|
15
|
+
taskCreateExitCode,
|
|
16
|
+
taskCreateFailure,
|
|
17
|
+
type TaskCreateControl,
|
|
18
|
+
type TaskCreateResult
|
|
19
|
+
} from '../task/create-service.ts';
|
|
20
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
8
21
|
|
|
9
|
-
function failed(code: string, message: string, retryable = false): TaskCreateResult {
|
|
10
|
-
return {
|
|
11
|
-
status: retryable ? 'blocked' : 'failed', changed: false, task: { id: null, shortId: null }, issue: null,
|
|
12
|
-
operations: [], warnings: [], error: { code, message, retryable }
|
|
13
|
-
};
|
|
22
|
+
function failed(code: string, message: string, retryable = false, control?: TaskCreateControl): TaskCreateResult {
|
|
23
|
+
return taskCreateFailure({ code, message, retryable }, control);
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
function output(result: TaskCreateResult): void {
|
|
17
27
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
18
|
-
process.exitCode = result
|
|
28
|
+
process.exitCode = taskCreateExitCode(result);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function clientErrorControl(error: SandboxControlClientError): TaskCreateControl {
|
|
32
|
+
return {
|
|
33
|
+
requestId: error.requestId,
|
|
34
|
+
accepted: error.accepted,
|
|
35
|
+
recovery: error.accepted ? 'same-request-id' : error.detail.retryable ? 'new-request-id' : 'none'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function parseControlledResult(response: ReturnType<typeof requestSandboxTaskCreate>): TaskCreateResult {
|
|
40
|
+
if (response.phase !== 'completed' || response.error !== null) {
|
|
41
|
+
return failed(
|
|
42
|
+
'SANDBOX_CONTROL_RESPONSE_INVALID',
|
|
43
|
+
'SANDBOX_CONTROL_RESPONSE_INVALID: completed task-create response is invalid',
|
|
44
|
+
false,
|
|
45
|
+
{ requestId: response.id, accepted: true, recovery: 'same-request-id' }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
let result: TaskCreateResult;
|
|
49
|
+
try {
|
|
50
|
+
result = parseTaskCreateResult(JSON.parse(response.stdout));
|
|
51
|
+
} catch {
|
|
52
|
+
return failed(
|
|
53
|
+
'TASK_CREATE_RESULT_INVALID',
|
|
54
|
+
'TASK_CREATE_RESULT_INVALID: task-create result payload is invalid',
|
|
55
|
+
false,
|
|
56
|
+
{ requestId: response.id, accepted: true, recovery: 'same-request-id' }
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (!result.control || result.control.requestId !== response.id || result.control.accepted !== true) {
|
|
60
|
+
return failed(
|
|
61
|
+
'TASK_CREATE_RESULT_INVALID',
|
|
62
|
+
'TASK_CREATE_RESULT_INVALID: controlled task-create result is missing request evidence',
|
|
63
|
+
false,
|
|
64
|
+
{ requestId: response.id, accepted: true, recovery: 'same-request-id' }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
process.stderr.write(response.stderr);
|
|
68
|
+
return result;
|
|
19
69
|
}
|
|
20
70
|
|
|
21
|
-
function taskCreate(args: string[]): void {
|
|
22
|
-
|
|
71
|
+
async function taskCreate(args: string[]): Promise<void> {
|
|
72
|
+
if (!ensureInternalHandlerRoute('task-create', args)) return;
|
|
73
|
+
const inputSelector = args.includes('--input') ? 'input' : '';
|
|
74
|
+
const inputIndex = internalHandlerRoute('task-create', 'input', inputSelector) ? args.indexOf('--input') : -1;
|
|
23
75
|
const input = inputIndex >= 0 ? args[inputIndex + 1] : undefined;
|
|
24
76
|
if (!input || args.length !== 2 || inputIndex !== 0) {
|
|
25
77
|
output(failed('TASK_CREATE_PAYLOAD_INVALID', 'Usage: agent-infra-internal task-create --input <candidate.json>'));
|
|
@@ -31,25 +83,34 @@ function taskCreate(args: string[]): void {
|
|
|
31
83
|
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error('TASK_CREATE_INPUT_INVALID: input must be a regular file');
|
|
32
84
|
if (stat.size > SANDBOX_CONTROL_MAX_BYTES) throw new Error('TASK_CREATE_INPUT_TOO_LARGE: input exceeds the control limit');
|
|
33
85
|
const candidate = validateTaskCreateCandidate(JSON.parse(fs.readFileSync(inputPath, 'utf8')));
|
|
34
|
-
|
|
86
|
+
const environment = classifySandboxControlEnvironment();
|
|
87
|
+
if (environment.kind === 'invalid') {
|
|
88
|
+
output(failed(environment.code ?? 'TASK_CONTROL_TRANSPORT_INVALID', environment.message ?? 'sandbox client control configuration is invalid'));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (environment.kind === 'controlled') {
|
|
35
92
|
const response = requestSandboxTaskCreate({ candidate });
|
|
36
93
|
if (response.phase === 'rejected') {
|
|
94
|
+
const accepted = response.error?.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN';
|
|
37
95
|
output(failed(
|
|
38
96
|
response.error?.code ?? 'SANDBOX_CONTROL_REJECTED',
|
|
39
97
|
response.error?.message ?? response.stderr,
|
|
40
|
-
response.error?.retryable ?? false
|
|
98
|
+
response.error?.retryable ?? false,
|
|
99
|
+
{
|
|
100
|
+
requestId: response.id,
|
|
101
|
+
accepted,
|
|
102
|
+
recovery: accepted ? 'same-request-id' : response.error?.retryable ? 'new-request-id' : 'none'
|
|
103
|
+
}
|
|
41
104
|
));
|
|
42
105
|
return;
|
|
43
106
|
}
|
|
44
|
-
|
|
45
|
-
process.stderr.write(response.stderr);
|
|
46
|
-
process.exitCode = response.exitCode;
|
|
107
|
+
output(parseControlledResult(response));
|
|
47
108
|
return;
|
|
48
109
|
}
|
|
49
|
-
output(createTask(candidate, { repoRoot: process.cwd() }));
|
|
110
|
+
output(await createTask(candidate, { repoRoot: process.cwd() }));
|
|
50
111
|
} catch (error) {
|
|
51
112
|
if (error instanceof SandboxControlClientError) {
|
|
52
|
-
output(failed(error.detail.code, error.detail.message, error.detail.retryable));
|
|
113
|
+
output(failed(error.detail.code, error.detail.message, error.detail.retryable, clientErrorControl(error)));
|
|
53
114
|
return;
|
|
54
115
|
}
|
|
55
116
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2,13 +2,15 @@ import path from 'node:path';
|
|
|
2
2
|
|
|
3
3
|
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.ts';
|
|
4
4
|
import { deliverTaskBranch } from '../task/delivery.ts';
|
|
5
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
5
6
|
|
|
6
7
|
const USAGE = `Usage: agent-infra-internal task-delivery <task-ref> deliver --agent <agent> [--remote <name>] [--base <branch>] [--dry-run] [--cwd <path>]\n`;
|
|
7
8
|
|
|
8
9
|
function taskDelivery(args: string[] = []): void {
|
|
10
|
+
if (!ensureInternalHandlerRoute('task-delivery', args)) return;
|
|
9
11
|
const taskRef = args[0];
|
|
10
12
|
const operation = args[1];
|
|
11
|
-
if (!taskRef || operation
|
|
13
|
+
if (!taskRef || !internalHandlerRoute('task-delivery', 'deliver', operation ?? '')) {
|
|
12
14
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'DELIVERY_PAYLOAD_INVALID', message: 'task ref and deliver operation are required' } })}\n`);
|
|
13
15
|
process.stderr.write(USAGE);
|
|
14
16
|
process.exitCode = 1;
|
|
@@ -4,6 +4,7 @@ import type { TaskEventRequest, Verdict } from '../task/events.ts';
|
|
|
4
4
|
import { consumeHumanOverride, failureId, overrideDryRunConflict } from '../task/human-override.ts';
|
|
5
5
|
import { resolveTaskRef } from '../task/resolve-ref.ts';
|
|
6
6
|
import { TaskExecutionLockError, withTaskExecutionLock } from '../task/task-execution-lock.ts';
|
|
7
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
7
8
|
|
|
8
9
|
const USAGE = `Usage: agent-infra-internal task-event <N | TASK-id> <event> --agent <agent> [event options] [--orchestrated] [--dry-run]
|
|
9
10
|
|
|
@@ -13,6 +14,9 @@ Events: ${eventCatalog.join(', ')}
|
|
|
13
14
|
|
|
14
15
|
const FLAGS: Record<string, keyof TaskEventRequest> = {
|
|
15
16
|
'--agent': 'agent', '--round': 'round', '--question': 'question', '--artifact': 'artifact',
|
|
17
|
+
'--artifact-sha256': 'artifactSha256', '--semantic-digest': 'semanticDigest',
|
|
18
|
+
'--initiator': 'initiator', '--request-id': 'requestId', '--reason-code': 'reasonCode',
|
|
19
|
+
'--source-finding': 'sourceFinding', '--source-artifact': 'sourceArtifact', '--source-sha256': 'sourceSha256',
|
|
16
20
|
'--fix-for': 'fixFor', '--implementation-input': 'implementationInput',
|
|
17
21
|
'--verdict': 'verdict', '--blockers': 'blockers', '--major': 'major',
|
|
18
22
|
'--minor': 'minor', '--manual-validation': 'manualValidation', '--files-modified': 'filesModified',
|
|
@@ -27,9 +31,10 @@ function usageFailure(message: string): void {
|
|
|
27
31
|
process.exitCode = 1;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
function taskEvent(args: string[] = []): void {
|
|
34
|
+
async function taskEvent(args: string[] = []): Promise<void> {
|
|
35
|
+
if (!ensureInternalHandlerRoute('task-event', args)) return;
|
|
31
36
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
32
|
-
if (args.length < 2) { usageFailure('task ref and event are required'); return; }
|
|
37
|
+
if (args.length < 2 || !internalHandlerRoute('task-event', 'event', args[1] ? 'event' : '')) { usageFailure('task ref and event are required'); return; }
|
|
33
38
|
const request: TaskEventRequest = { taskRef: args[0]!, event: args[1]!, agent: '' };
|
|
34
39
|
const seen = new Set<string>();
|
|
35
40
|
for (let index = 2; index < args.length; index += 1) {
|
|
@@ -66,14 +71,14 @@ function taskEvent(args: string[] = []): void {
|
|
|
66
71
|
let result;
|
|
67
72
|
let humanOverride: unknown = null;
|
|
68
73
|
try {
|
|
69
|
-
result = withTaskExecutionLock(resolved.repoRoot, resolved.taskId, `task-event.${request.event}`, () => {
|
|
74
|
+
result = await withTaskExecutionLock(resolved.repoRoot, resolved.taskId, `task-event.${request.event}`, async () => {
|
|
70
75
|
let current = applyTaskEvent(request, { lockAlreadyHeld: true });
|
|
71
76
|
const values = request as Record<string, unknown>;
|
|
72
77
|
if (current.status !== 'failed' || !values.overrideTicket) return current;
|
|
73
78
|
if (!values.overrideTarget || !values.overrideScope) {
|
|
74
79
|
return { ...current, humanOverride: { status: 'failed', error: { code: 'OVERRIDE_PAYLOAD_INVALID', message: 'override ticket requires target and scope' } } } as typeof current & { humanOverride: unknown };
|
|
75
80
|
}
|
|
76
|
-
const consumed = consumeHumanOverride({
|
|
81
|
+
const consumed = await consumeHumanOverride({
|
|
77
82
|
taskRef: request.taskRef,
|
|
78
83
|
ticketId: String(values.overrideTicket),
|
|
79
84
|
failureId: failureId('task-event', current.error?.code ?? 'EVENT_TRANSITION_INVALID'),
|