@vercel/factory 0.0.14 → 0.0.16
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/CHANGELOG.md +356 -0
- package/README.md +96 -2
- package/dist/agent-routes.d.mts +113 -0
- package/dist/agent-routes.mjs +91 -0
- package/dist/agent-routes.mjs.map +1 -0
- package/dist/api-contracts.d.mts +1768 -0
- package/dist/api-contracts.mjs +119 -0
- package/dist/api-contracts.mjs.map +1 -0
- package/dist/api-images.d.mts +30 -0
- package/dist/api-images.mjs +28 -0
- package/dist/api-images.mjs.map +1 -0
- package/dist/api-task-graph.mjs +57 -0
- package/dist/api-task-graph.mjs.map +1 -0
- package/dist/api.d.mts +111 -216
- package/dist/api.mjs +1063 -99
- package/dist/api.mjs.map +1 -1
- package/dist/approval-access.d.mts +39 -0
- package/dist/approval-access.mjs +62 -0
- package/dist/approval-access.mjs.map +1 -0
- package/dist/approval-contracts.d.mts +698 -0
- package/dist/approval-contracts.mjs +27 -0
- package/dist/approval-contracts.mjs.map +1 -0
- package/dist/approval.d.mts +49 -0
- package/dist/approval.mjs +39 -0
- package/dist/approval.mjs.map +1 -0
- package/dist/blob/artifacts.d.mts +37 -0
- package/dist/blob/artifacts.mjs +45 -0
- package/dist/blob/artifacts.mjs.map +1 -0
- package/dist/blob/index.d.mts +84 -12
- package/dist/blob/index.mjs +179 -45
- package/dist/blob/index.mjs.map +1 -1
- package/dist/budget.d.mts +115 -0
- package/dist/budget.mjs +147 -0
- package/dist/budget.mjs.map +1 -0
- package/dist/budgets.d.mts +4 -0
- package/dist/budgets.mjs +4 -0
- package/dist/build-factory.d.mts +7 -4
- package/dist/build-factory.mjs +2 -1
- package/dist/build-factory.mjs.map +1 -1
- package/dist/change-verification/brief.d.mts +9 -0
- package/dist/change-verification/brief.mjs +13 -0
- package/dist/change-verification/brief.mjs.map +1 -0
- package/dist/change-verification/dispatch.d.mts +37 -0
- package/dist/change-verification/dispatch.mjs +83 -0
- package/dist/change-verification/dispatch.mjs.map +1 -0
- package/dist/change-verification/eve-tool.d.mts +61 -0
- package/dist/change-verification/eve-tool.mjs +89 -0
- package/dist/change-verification/eve-tool.mjs.map +1 -0
- package/dist/change-verification/result.mjs +130 -0
- package/dist/change-verification/result.mjs.map +1 -0
- package/dist/changes/eve-record-change.d.mts +56 -0
- package/dist/changes/eve-record-change.mjs +131 -0
- package/dist/changes/eve-record-change.mjs.map +1 -0
- package/dist/changes/presentation.d.mts +14 -0
- package/dist/changes.d.mts +24 -0
- package/dist/changes.mjs +29 -0
- package/dist/changes.mjs.map +1 -0
- package/dist/client-events.d.mts +25 -0
- package/dist/client-events.mjs +45 -0
- package/dist/client-events.mjs.map +1 -0
- package/dist/client-stream.d.mts +28 -0
- package/dist/client-stream.mjs +210 -0
- package/dist/client-stream.mjs.map +1 -0
- package/dist/client-transcript.d.mts +41 -0
- package/dist/client-transcript.mjs +233 -0
- package/dist/client-transcript.mjs.map +1 -0
- package/dist/client.d.mts +343 -0
- package/dist/client.mjs +366 -0
- package/dist/client.mjs.map +1 -0
- package/dist/code-review/contracts.d.mts +27 -0
- package/dist/code-review/eve-post-review.d.mts +70 -0
- package/dist/code-review/eve-post-review.mjs +195 -0
- package/dist/code-review/eve-post-review.mjs.map +1 -0
- package/dist/code-review/eve-review-comments.d.mts +75 -0
- package/dist/code-review/eve-review-comments.mjs +193 -0
- package/dist/code-review/eve-review-comments.mjs.map +1 -0
- package/dist/code-review/github-contracts.d.mts +10 -0
- package/dist/code-review/github-reporter.d.mts +46 -0
- package/dist/code-review/github-reporter.mjs +262 -0
- package/dist/code-review/github-reporter.mjs.map +1 -0
- package/dist/code-review/preparation.d.mts +34 -0
- package/dist/code-review/preparation.mjs +23 -0
- package/dist/code-review/preparation.mjs.map +1 -0
- package/dist/code-review/stall.d.mts +17 -0
- package/dist/code-review/stall.mjs +30 -0
- package/dist/code-review/stall.mjs.map +1 -0
- package/dist/code-review.d.mts +7 -0
- package/dist/code-review.mjs +5 -0
- package/dist/communication.d.mts +9 -0
- package/dist/communication.mjs +9 -0
- package/dist/connectors/github.d.mts +26 -0
- package/dist/connectors/github.mjs +55 -0
- package/dist/connectors/github.mjs.map +1 -0
- package/dist/connectors/index.d.mts +35 -3
- package/dist/connectors/index.mjs +3 -52
- package/dist/connectors/index.mjs.map +1 -1
- package/dist/connectors/outbox.d.mts +34 -0
- package/dist/connectors/outbox.mjs +50 -0
- package/dist/connectors/outbox.mjs.map +1 -0
- package/dist/connectors/slack-approval-blocks.mjs +136 -0
- package/dist/connectors/slack-approval-blocks.mjs.map +1 -0
- package/dist/connectors/slack-approvals.d.mts +29 -0
- package/dist/connectors/slack-approvals.mjs +346 -0
- package/dist/connectors/slack-approvals.mjs.map +1 -0
- package/dist/connectors/slack.d.mts +35 -52
- package/dist/connectors/slack.mjs +13 -85
- package/dist/connectors/slack.mjs.map +1 -1
- package/dist/deepsec/eve-tool.d.mts +110 -0
- package/dist/deepsec/eve-tool.mjs +166 -0
- package/dist/deepsec/eve-tool.mjs.map +1 -0
- package/dist/deepsec/finding.d.mts +84 -0
- package/dist/deepsec/finding.mjs +56 -0
- package/dist/deepsec/finding.mjs.map +1 -0
- package/dist/deepsec.d.mts +3 -0
- package/dist/delivery-metrics/metrics.d.mts +93 -0
- package/dist/delivery-metrics/metrics.mjs +200 -0
- package/dist/delivery-metrics/metrics.mjs.map +1 -0
- package/dist/delivery-metrics.d.mts +2 -0
- package/dist/delivery-metrics.mjs +2 -0
- package/dist/dispatch.d.mts +152 -0
- package/dist/dispatch.mjs +199 -0
- package/dist/dispatch.mjs.map +1 -0
- package/dist/errors.d.mts +15 -0
- package/dist/errors.mjs +38 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/eve/index.d.mts +209 -1277
- package/dist/eve/index.mjs +312 -1073
- package/dist/eve/index.mjs.map +1 -1
- package/dist/eve/invoke.d.mts +144 -0
- package/dist/eve/invoke.mjs +254 -0
- package/dist/eve/invoke.mjs.map +1 -0
- package/dist/eve/session-client.d.mts +186 -0
- package/dist/eve/session-client.mjs +245 -0
- package/dist/eve/session-client.mjs.map +1 -0
- package/dist/eve/task-execution.d.mts +380 -0
- package/dist/eve/task-execution.mjs +73 -0
- package/dist/eve/task-execution.mjs.map +1 -0
- package/dist/eve/task-session.d.mts +129 -0
- package/dist/eve/task-session.mjs +245 -0
- package/dist/eve/task-session.mjs.map +1 -0
- package/dist/eve/transcript.d.mts +37 -0
- package/dist/eve/transcript.mjs +69 -0
- package/dist/eve/transcript.mjs.map +1 -0
- package/dist/execution-public.d.mts +8 -0
- package/dist/execution-public.mjs +7 -0
- package/dist/execution.d.mts +183 -0
- package/dist/execution.mjs +223 -0
- package/dist/execution.mjs.map +1 -0
- package/dist/finding-remediation/admission.d.mts +53 -0
- package/dist/finding-remediation/admission.mjs +90 -0
- package/dist/finding-remediation/admission.mjs.map +1 -0
- package/dist/finding-remediation/brief.d.mts +14 -0
- package/dist/finding-remediation/brief.mjs +25 -0
- package/dist/finding-remediation/brief.mjs.map +1 -0
- package/dist/finding-remediation/eve-tool.d.mts +29 -0
- package/dist/finding-remediation/eve-tool.mjs +34 -0
- package/dist/finding-remediation/eve-tool.mjs.map +1 -0
- package/dist/findings/fingerprint.d.mts +14 -0
- package/dist/findings/fingerprint.mjs +28 -0
- package/dist/findings/fingerprint.mjs.map +1 -0
- package/dist/findings.d.mts +7 -0
- package/dist/findings.mjs +6 -0
- package/dist/github-app.d.mts +54 -0
- package/dist/github-app.mjs +121 -0
- package/dist/github-app.mjs.map +1 -0
- package/dist/github-publication.d.mts +199 -0
- package/dist/github-publication.mjs +442 -0
- package/dist/github-publication.mjs.map +1 -0
- package/dist/github-transfer.d.mts +81 -0
- package/dist/github-transfer.mjs +273 -0
- package/dist/github-transfer.mjs.map +1 -0
- package/dist/github.d.mts +446 -2
- package/dist/github.mjs +357 -56
- package/dist/github.mjs.map +1 -1
- package/dist/image-input.d.mts +51 -0
- package/dist/image-input.mjs +63 -0
- package/dist/image-input.mjs.map +1 -0
- package/dist/inbox-activity.d.mts +53 -0
- package/dist/inbox-activity.mjs +41 -0
- package/dist/inbox-activity.mjs.map +1 -0
- package/dist/index.d.mts +16 -484
- package/dist/index.mjs +15 -522
- package/dist/intake-contracts.d.mts +55 -0
- package/dist/intake-contracts.mjs +33 -0
- package/dist/intake-contracts.mjs.map +1 -0
- package/dist/integrations/deepsec.d.mts +5 -0
- package/dist/integrations/deepsec.mjs +3 -0
- package/dist/integrations/github.d.mts +11 -0
- package/dist/integrations/github.mjs +9 -0
- package/dist/integrations/slack.d.mts +5 -0
- package/dist/integrations/slack.mjs +5 -0
- package/dist/integrations/vercel.d.mts +5 -0
- package/dist/integrations/vercel.mjs +4 -0
- package/dist/merge-resolution/contracts.d.mts +17 -0
- package/dist/merge-resolution/contracts.mjs +19 -0
- package/dist/merge-resolution/contracts.mjs.map +1 -0
- package/dist/merge-resolution/eve-tools.d.mts +47 -0
- package/dist/merge-resolution/eve-tools.mjs +122 -0
- package/dist/merge-resolution/eve-tools.mjs.map +1 -0
- package/dist/model-settings.d.mts +41 -0
- package/dist/model-settings.mjs +35 -0
- package/dist/model-settings.mjs.map +1 -0
- package/dist/multi-repository-changes/coordination.d.mts +49 -0
- package/dist/multi-repository-changes/coordination.mjs +115 -0
- package/dist/multi-repository-changes/coordination.mjs.map +1 -0
- package/dist/planning/cancellation.mjs +82 -0
- package/dist/planning/cancellation.mjs.map +1 -0
- package/dist/planning/configuration.d.mts +23 -0
- package/dist/planning/configuration.mjs +56 -0
- package/dist/planning/configuration.mjs.map +1 -0
- package/dist/planning/contracts.d.mts +136 -0
- package/dist/planning/contracts.mjs +42 -0
- package/dist/planning/contracts.mjs.map +1 -0
- package/dist/planning/dependencies.mjs +44 -0
- package/dist/planning/dependencies.mjs.map +1 -0
- package/dist/planning/effects.mjs +122 -0
- package/dist/planning/effects.mjs.map +1 -0
- package/dist/planning/reconcile.mjs +279 -0
- package/dist/planning/reconcile.mjs.map +1 -0
- package/dist/planning/runtime.d.mts +27 -0
- package/dist/planning/runtime.mjs +25 -0
- package/dist/planning/runtime.mjs.map +1 -0
- package/dist/planning/state.mjs +92 -0
- package/dist/planning/state.mjs.map +1 -0
- package/dist/planning/turns.mjs +262 -0
- package/dist/planning/turns.mjs.map +1 -0
- package/dist/planning/validation.mjs +106 -0
- package/dist/planning/validation.mjs.map +1 -0
- package/dist/postgres/index.d.mts +48 -1
- package/dist/postgres/index.mjs +45 -3
- package/dist/postgres/index.mjs.map +1 -1
- package/dist/presets/software-development/approval.d.mts +14 -0
- package/dist/presets/software-development/approval.mjs +21 -0
- package/dist/presets/software-development/approval.mjs.map +1 -0
- package/dist/presets/software-development/deepsec-brief.d.mts +8 -0
- package/dist/presets/software-development/deepsec-brief.mjs +14 -0
- package/dist/presets/software-development/deepsec-brief.mjs.map +1 -0
- package/dist/presets/software-development/dispatch.d.mts +56 -0
- package/dist/presets/software-development/dispatch.mjs +67 -0
- package/dist/presets/software-development/dispatch.mjs.map +1 -0
- package/dist/presets/software-development/eve-delegation-policy.d.mts +7 -0
- package/dist/presets/software-development/eve-delegation-policy.mjs +34 -0
- package/dist/presets/software-development/eve-delegation-policy.mjs.map +1 -0
- package/dist/presets/software-development/eve.d.mts +18 -0
- package/dist/presets/software-development/eve.mjs +19 -0
- package/dist/presets/software-development/eve.mjs.map +1 -0
- package/dist/presets/software-development/finish-task-policy.d.mts +7 -0
- package/dist/presets/software-development/finish-task-policy.mjs +9 -0
- package/dist/presets/software-development/finish-task-policy.mjs.map +1 -0
- package/dist/presets/software-development/recovery.d.mts +32 -0
- package/dist/presets/software-development/recovery.mjs +120 -0
- package/dist/presets/software-development/recovery.mjs.map +1 -0
- package/dist/presets/software-development/task-communication.d.mts +24 -0
- package/dist/presets/software-development/task-communication.mjs +157 -0
- package/dist/presets/software-development/task-communication.mjs.map +1 -0
- package/dist/presets/software-development.d.mts +10 -0
- package/dist/presets/software-development.mjs +9 -0
- package/dist/pull-requests/contracts.d.mts +72 -0
- package/dist/pull-requests/eve-fetch.d.mts +57 -0
- package/dist/pull-requests/eve-fetch.mjs +151 -0
- package/dist/pull-requests/eve-fetch.mjs.map +1 -0
- package/dist/pull-requests/github-label-manager.d.mts +27 -0
- package/dist/pull-requests/github-label-manager.mjs +40 -0
- package/dist/pull-requests/github-label-manager.mjs.map +1 -0
- package/dist/pull-requests/github-publisher.d.mts +67 -0
- package/dist/pull-requests/github-publisher.mjs +405 -0
- package/dist/pull-requests/github-publisher.mjs.map +1 -0
- package/dist/pull-requests.d.mts +6 -0
- package/dist/pull-requests.mjs +4 -0
- package/dist/receipts.d.mts +4 -0
- package/dist/receipts.mjs +3 -0
- package/dist/repositories.d.mts +18 -0
- package/dist/repositories.mjs +33 -0
- package/dist/repositories.mjs.map +1 -0
- package/dist/sandbox/command.d.mts +18 -0
- package/dist/sandbox/execution-abort.d.mts +16 -0
- package/dist/sandbox/execution-abort.mjs +49 -0
- package/dist/sandbox/execution-abort.mjs.map +1 -0
- package/dist/sandbox/execution-environment.d.mts +25 -0
- package/dist/sandbox/execution-run-ledger.d.mts +115 -0
- package/dist/sandbox/execution-run-ledger.mjs +209 -0
- package/dist/sandbox/execution-run-ledger.mjs.map +1 -0
- package/dist/sandbox/execution.d.mts +54 -0
- package/dist/sandbox/execution.mjs +228 -0
- package/dist/sandbox/execution.mjs.map +1 -0
- package/dist/sandbox/harness-runner.d.mts +79 -0
- package/dist/sandbox/harness-runner.mjs +162 -0
- package/dist/sandbox/harness-runner.mjs.map +1 -0
- package/dist/sandbox/index.d.mts +10 -0
- package/dist/sandbox/index.mjs +7 -0
- package/dist/sandbox/task-environment.d.mts +50 -0
- package/dist/sandbox/task-environment.mjs +140 -0
- package/dist/sandbox/task-environment.mjs.map +1 -0
- package/dist/sandbox/workspace.d.mts +29 -0
- package/dist/sandbox/workspace.mjs +28 -0
- package/dist/sandbox/workspace.mjs.map +1 -0
- package/dist/schema/agent-route.d.mts +40 -0
- package/dist/schema/agent-route.mjs +33 -0
- package/dist/schema/agent-route.mjs.map +1 -0
- package/dist/schema/answer.d.mts +23 -0
- package/dist/schema/answer.mjs +21 -0
- package/dist/schema/answer.mjs.map +1 -0
- package/dist/schema/budget.d.mts +38 -0
- package/dist/schema/budget.mjs +30 -0
- package/dist/schema/budget.mjs.map +1 -0
- package/dist/schema/catalog.mjs +72 -0
- package/dist/schema/catalog.mjs.map +1 -0
- package/dist/schema/change.d.mts +117 -0
- package/dist/schema/change.mjs +68 -0
- package/dist/schema/change.mjs.map +1 -0
- package/dist/schema/common.d.mts +33 -0
- package/dist/{id-BLIkCVue.mjs → schema/common.mjs} +7 -16
- package/dist/schema/common.mjs.map +1 -0
- package/dist/schema/communication.d.mts +52 -0
- package/dist/{communication-Kd9nU5RP.mjs → schema/communication.mjs} +8 -3
- package/dist/schema/communication.mjs.map +1 -0
- package/dist/schema/execution.d.mts +101 -0
- package/dist/schema/execution.mjs +86 -0
- package/dist/schema/execution.mjs.map +1 -0
- package/dist/schema/factory-config.d.mts +122 -0
- package/dist/schema/factory-config.mjs +90 -0
- package/dist/schema/factory-config.mjs.map +1 -0
- package/dist/schema/finding.d.mts +125 -0
- package/dist/schema/finding.mjs +67 -0
- package/dist/schema/finding.mjs.map +1 -0
- package/dist/schema/id.d.mts +43 -0
- package/dist/schema/id.mjs +32 -0
- package/dist/schema/id.mjs.map +1 -0
- package/dist/schema/outbox.d.mts +240 -0
- package/dist/schema/outbox.mjs +53 -0
- package/dist/schema/outbox.mjs.map +1 -0
- package/dist/schema/question-route.mjs +16 -0
- package/dist/schema/question-route.mjs.map +1 -0
- package/dist/schema/receipt.d.mts +81 -0
- package/dist/schema/receipt.mjs +94 -0
- package/dist/schema/receipt.mjs.map +1 -0
- package/dist/schema/repository.d.mts +30 -0
- package/dist/schema/repository.mjs +29 -0
- package/dist/schema/repository.mjs.map +1 -0
- package/dist/schema/session.d.mts +136 -0
- package/dist/schema/session.mjs +54 -0
- package/dist/schema/session.mjs.map +1 -0
- package/dist/schema/signal.d.mts +105 -0
- package/dist/schema/signal.mjs +81 -0
- package/dist/schema/signal.mjs.map +1 -0
- package/dist/schema/slack-pr-notifications.d.mts +12 -0
- package/dist/schema/slack-pr-notifications.mjs +11 -0
- package/dist/schema/slack-pr-notifications.mjs.map +1 -0
- package/dist/schema/stored-session.mjs +10 -0
- package/dist/schema/stored-session.mjs.map +1 -0
- package/dist/schema/stored-task.mjs +20 -0
- package/dist/schema/stored-task.mjs.map +1 -0
- package/dist/schema/task-effect.d.mts +39 -0
- package/dist/schema/task-effect.mjs +29 -0
- package/dist/schema/task-effect.mjs.map +1 -0
- package/dist/schema/task-graph.d.mts +3173 -0
- package/dist/schema/task-graph.mjs +97 -0
- package/dist/schema/task-graph.mjs.map +1 -0
- package/dist/schema/task-message.d.mts +254 -0
- package/dist/schema/task-message.mjs +189 -0
- package/dist/schema/task-message.mjs.map +1 -0
- package/dist/schema/task.d.mts +273 -0
- package/dist/schema/task.mjs +200 -0
- package/dist/schema/task.mjs.map +1 -0
- package/dist/schema/transcript.d.mts +176 -0
- package/dist/schema/transcript.mjs +87 -0
- package/dist/schema/transcript.mjs.map +1 -0
- package/dist/schema/transitions.d.mts +50 -0
- package/dist/schema/transitions.mjs +303 -0
- package/dist/schema/transitions.mjs.map +1 -0
- package/dist/schema/work.d.mts +150 -0
- package/dist/schema/work.mjs +102 -0
- package/dist/schema/work.mjs.map +1 -0
- package/dist/session-previews.d.mts +76 -0
- package/dist/session-previews.mjs +55 -0
- package/dist/session-previews.mjs.map +1 -0
- package/dist/session-review.d.mts +120 -0
- package/dist/session-review.mjs +79 -0
- package/dist/session-review.mjs.map +1 -0
- package/dist/signal-triage.d.mts +20 -0
- package/dist/signal-triage.mjs +85 -0
- package/dist/signal-triage.mjs.map +1 -0
- package/dist/signals.d.mts +20 -0
- package/dist/signals.mjs +19 -0
- package/dist/signals.mjs.map +1 -0
- package/dist/stall.d.mts +41 -0
- package/dist/stall.mjs +83 -0
- package/dist/stall.mjs.map +1 -0
- package/dist/storage.d.mts +4 -0
- package/dist/storage.mjs +4 -0
- package/dist/store/driver.d.mts +65 -0
- package/dist/store/driver.mjs +42 -0
- package/dist/store/driver.mjs.map +1 -0
- package/dist/store/engine.d.mts +683 -0
- package/dist/store/engine.mjs +2309 -0
- package/dist/store/engine.mjs.map +1 -0
- package/dist/store/memory.d.mts +24 -0
- package/dist/store/memory.mjs +69 -0
- package/dist/store/memory.mjs.map +1 -0
- package/dist/store/slack-pr-notifications.d.mts +44 -0
- package/dist/store/slack-pr-notifications.mjs +121 -0
- package/dist/store/slack-pr-notifications.mjs.map +1 -0
- package/dist/store/task-effects.d.mts +38 -0
- package/dist/store/task-effects.mjs +118 -0
- package/dist/store/task-effects.mjs.map +1 -0
- package/dist/store/task-graphs.d.mts +60 -0
- package/dist/store/task-graphs.mjs +212 -0
- package/dist/store/task-graphs.mjs.map +1 -0
- package/dist/store/task-messages.d.mts +136 -0
- package/dist/store/task-messages.mjs +475 -0
- package/dist/store/task-messages.mjs.map +1 -0
- package/dist/store/task-work.d.mts +180 -0
- package/dist/store/task-work.mjs +137 -0
- package/dist/store/task-work.mjs.map +1 -0
- package/dist/store/work-notifications.d.mts +19 -0
- package/dist/store/work-notifications.mjs +48 -0
- package/dist/store/work-notifications.mjs.map +1 -0
- package/dist/sweep.d.mts +79 -0
- package/dist/sweep.mjs +171 -0
- package/dist/sweep.mjs.map +1 -0
- package/dist/task-communication.d.mts +35 -0
- package/dist/task-communication.mjs +47 -0
- package/dist/task-communication.mjs.map +1 -0
- package/dist/task-graph-view.d.mts +267 -0
- package/dist/task-graph-view.mjs +17 -0
- package/dist/task-graph-view.mjs.map +1 -0
- package/dist/task-message-processing.d.mts +60 -0
- package/dist/task-message-processing.mjs +200 -0
- package/dist/task-message-processing.mjs.map +1 -0
- package/dist/task-protocols.d.mts +80 -0
- package/dist/task-protocols.mjs +47 -0
- package/dist/task-protocols.mjs.map +1 -0
- package/dist/tasks.d.mts +17 -0
- package/dist/tasks.mjs +17 -0
- package/dist/vercel-git.d.mts +53 -0
- package/dist/vercel-git.mjs +344 -0
- package/dist/vercel-git.mjs.map +1 -0
- package/dist/vercel-github-api.d.mts +103 -0
- package/dist/vercel-github-api.mjs +363 -0
- package/dist/vercel-github-api.mjs.map +1 -0
- package/dist/vercel.d.mts +34 -2
- package/dist/vercel.mjs +49 -3
- package/dist/vercel.mjs.map +1 -1
- package/dist/work-triage/eve-tool.d.mts +29 -0
- package/dist/work-triage/eve-tool.mjs +32 -0
- package/dist/work-triage/eve-tool.mjs.map +1 -0
- package/dist/work-triage/find-existing-work.d.mts +32 -0
- package/dist/work-triage/find-existing-work.mjs +31 -0
- package/dist/work-triage/find-existing-work.mjs.map +1 -0
- package/dist/work-triage/github.d.mts +15 -0
- package/dist/work-triage/github.mjs +14 -0
- package/dist/work-triage/github.mjs.map +1 -0
- package/dist/work-triage.d.mts +4 -0
- package/dist/work-triage.mjs +3 -0
- package/dist/workflows.d.mts +146 -0
- package/dist/workflows.mjs +139 -0
- package/dist/workflows.mjs.map +1 -0
- package/dist/workspace-diff-assembly.d.mts +33 -0
- package/dist/workspace-diff-assembly.mjs +95 -0
- package/dist/workspace-diff-assembly.mjs.map +1 -0
- package/dist/workspace-diff.d.mts +90 -0
- package/dist/workspace-diff.mjs +61 -0
- package/dist/workspace-diff.mjs.map +1 -0
- package/dist/workspace-files-git.d.mts +15 -0
- package/dist/workspace-files-git.mjs +61 -0
- package/dist/workspace-files-git.mjs.map +1 -0
- package/dist/workspace-files.d.mts +107 -0
- package/dist/workspace-files.mjs +74 -0
- package/dist/workspace-files.mjs.map +1 -0
- package/dist/workspace-snapshot.d.mts +26 -0
- package/dist/workspace-snapshot.mjs +80 -0
- package/dist/workspace-snapshot.mjs.map +1 -0
- package/docs/getting-started.md +104 -0
- package/docs/index.md +100 -0
- package/docs/recipes/cancellation.md +215 -0
- package/docs/recipes/custom-workflow.md +153 -0
- package/docs/recipes/dependent-tasks.md +207 -0
- package/docs/recipes/eve-agent.md +277 -0
- package/docs/recipes/human-input.md +204 -0
- package/docs/recipes/persistence-recovery.md +268 -0
- package/docs/recipes/retry-recovery.md +241 -0
- package/docs/recipes/task-messaging.md +215 -0
- package/docs/recipes/typed-eve-result.md +161 -0
- package/docs/runtime-integration.md +137 -0
- package/package.json +142 -46
- package/dist/approval-JX2Px9IC.mjs +0 -132
- package/dist/approval-JX2Px9IC.mjs.map +0 -1
- package/dist/budget-DzSiIA4t.mjs +0 -42
- package/dist/budget-DzSiIA4t.mjs.map +0 -1
- package/dist/change-D2U6v7Ek.mjs +0 -554
- package/dist/change-D2U6v7Ek.mjs.map +0 -1
- package/dist/communication-Kd9nU5RP.mjs.map +0 -1
- package/dist/coordination-Cq08hb1l.mjs +0 -76
- package/dist/coordination-Cq08hb1l.mjs.map +0 -1
- package/dist/dispatch-BaZS3PT8.d.mts +0 -76
- package/dist/driver-BC0Mt5KG.d.mts +0 -34
- package/dist/driver-Bbd25rNM.mjs +0 -23
- package/dist/driver-Bbd25rNM.mjs.map +0 -1
- package/dist/engine-DFHU2Pe-.d.mts +0 -781
- package/dist/engine-WaUM2cGA.mjs +0 -1068
- package/dist/engine-WaUM2cGA.mjs.map +0 -1
- package/dist/factory-config-BoRXOw43.mjs +0 -50
- package/dist/factory-config-BoRXOw43.mjs.map +0 -1
- package/dist/factory-config-D2yU3G0c.d.mts +0 -58
- package/dist/github-C5HNBN6p.d.mts +0 -279
- package/dist/id-BLIkCVue.mjs.map +0 -1
- package/dist/index-Bw6hggoH.d.mts +0 -40
- package/dist/index.mjs.map +0 -1
- package/dist/task-CcOyOJ3k.mjs +0 -154
- package/dist/task-CcOyOJ3k.mjs.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { agentSessionIdSchema } from "../../schema/session.mjs";
|
|
2
|
+
import { createTaskCommunicationReconciler } from "../../task-communication.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/presets/software-development/task-communication.ts
|
|
5
|
+
const reviewOutputSchema = z.object({
|
|
6
|
+
verdict: z.enum([
|
|
7
|
+
"approve",
|
|
8
|
+
"request_changes",
|
|
9
|
+
"comment"
|
|
10
|
+
]),
|
|
11
|
+
findingCount: z.number().int().nonnegative(),
|
|
12
|
+
review: z.object({
|
|
13
|
+
url: z.url(),
|
|
14
|
+
state: z.string().optional()
|
|
15
|
+
}).optional()
|
|
16
|
+
});
|
|
17
|
+
/** Supplied Slack, GitHub, and API presentation for a task question. */
|
|
18
|
+
function createSoftwareDevelopmentTaskCommunication(options = {}) {
|
|
19
|
+
const githubMention = options.githubMention ?? "@agent-factory";
|
|
20
|
+
if (githubMention.trim().length === 0) throw new Error("githubMention must not be empty");
|
|
21
|
+
const needsHumanReplyTo = options.needsHumanReplyTo;
|
|
22
|
+
function questionEvents(task) {
|
|
23
|
+
if (task.kind !== "question" || task.question === void 0) throw new Error(`Task ${task.id} has no question.`);
|
|
24
|
+
const reference = `Reference: ${task.id}`;
|
|
25
|
+
const session = task.replyTo.channel === "api" && agentSessionIdSchema.safeParse(task.replyTo.address);
|
|
26
|
+
const instructions = session && session.success ? `Open Factory session ${session.data}: factory-tui --config REPLACE_WITH_TUI_CONFIG.json --session ${session.data}\nReplace REPLACE_WITH_TUI_CONFIG.json with an authenticated TUI config for the factory that sent this notice. Review the current question before answering; this notice may be stale.` : task.replyTo.channel === "slack" ? "To answer, reply in the original Slack thread and mention the Factory app." : task.replyTo.channel === "github" && /^[^/]+\/[^/#]+(?:#|\/pull\/)[1-9][0-9]*$/u.test(task.replyTo.address) ? `To answer, comment on ${task.replyTo.address} starting with \`${githubMention}\`.` : `No Factory conversation link recorded. Reply destination: ${task.replyTo.channel} ${task.replyTo.address}. Ask an operator to locate the original conversation using the question reference; do not use approve or retry-intake to answer it.`;
|
|
27
|
+
const common = {
|
|
28
|
+
repositoryIds: task.repositoryIds,
|
|
29
|
+
taskId: task.id
|
|
30
|
+
};
|
|
31
|
+
const action = task.needsHumanAction ?? task.question.text;
|
|
32
|
+
const events = [{
|
|
33
|
+
...common,
|
|
34
|
+
eventId: `question:${task.id}:${task.attempt}`,
|
|
35
|
+
replyTo: task.replyTo,
|
|
36
|
+
outcome: "question",
|
|
37
|
+
data: {
|
|
38
|
+
question: `${reference}\n\n${instructions}\n\n${task.question.text}`,
|
|
39
|
+
options: task.question.options
|
|
40
|
+
}
|
|
41
|
+
}];
|
|
42
|
+
if (needsHumanReplyTo !== void 0) events.push({
|
|
43
|
+
...common,
|
|
44
|
+
eventId: `needs-human:${task.id}:${task.attempt}`,
|
|
45
|
+
replyTo: needsHumanReplyTo,
|
|
46
|
+
outcome: "needs_human",
|
|
47
|
+
data: {
|
|
48
|
+
requestedAction: action.length > 2e3 ? `${action.slice(0, 2e3)}…` : action,
|
|
49
|
+
message: `${reference}\nReply destination: ${task.replyTo.channel} ${task.replyTo.address}\n${instructions}\nReplies in this notification DM do not answer the question.`,
|
|
50
|
+
options: task.question.options,
|
|
51
|
+
questionAttempt: task.attempt,
|
|
52
|
+
...task.parentTaskId === void 0 ? {} : { parentTaskId: task.parentTaskId },
|
|
53
|
+
replyChannel: task.replyTo.channel,
|
|
54
|
+
replyAddress: task.replyTo.address
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return events;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
questionEvents,
|
|
61
|
+
reconcile: createTaskCommunicationReconciler({
|
|
62
|
+
question: questionEvents,
|
|
63
|
+
async lifecycle({ stores, tasks, task, receipt }) {
|
|
64
|
+
if (receipt.state === "succeeded" && task.changeId !== void 0) {
|
|
65
|
+
if (task.work.route?.id !== "code-review" || task.work.route.version !== 1 || task.origin.operator === void 0) return [];
|
|
66
|
+
const output = reviewOutputSchema.parse(task.workResult?.output);
|
|
67
|
+
const change = await stores.changes.get(task.changeId);
|
|
68
|
+
if (change === null) throw new Error(`Review ${task.id} references a missing Change.`);
|
|
69
|
+
const findings = output.findingCount === 0 ? output.verdict === "request_changes" ? "Changes requested." : output.review?.state === "APPROVED" ? "Approved. No issues found." : "No issues found." : `${output.findingCount} finding${output.findingCount === 1 ? "" : "s"}.${output.verdict === "request_changes" ? " Changes requested." : ""}`;
|
|
70
|
+
const event = eventFor(task, receipt);
|
|
71
|
+
return [{
|
|
72
|
+
...event,
|
|
73
|
+
data: {
|
|
74
|
+
...event.data,
|
|
75
|
+
title: `Review complete for PR #${change.prNumber}`,
|
|
76
|
+
summary: findings,
|
|
77
|
+
url: output.review?.url ?? change.prUrl
|
|
78
|
+
}
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
return [task.kind === "coordination" && (receipt.state === "succeeded" || receipt.state === "failed") ? await coordinationEvent(stores, tasks, task, receipt) : eventFor(task, receipt)];
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function completionSummary(task, receipt) {
|
|
87
|
+
const output = task.workResult?.output;
|
|
88
|
+
const summary = [...typeof output === "object" && output !== null && !Array.isArray(output) ? ["summary" in output ? output.summary : void 0, "result" in output ? output.result : void 0] : [output], receipt.reason].find((value) => typeof value === "string" && value.trim().length > 0);
|
|
89
|
+
if (!summary) return "Completed. No result summary was recorded; open the chat for details.";
|
|
90
|
+
const text = summary.trim();
|
|
91
|
+
return text.length > 1e3 ? `${text.slice(0, 997)}…` : text;
|
|
92
|
+
}
|
|
93
|
+
function eventFor(task, receipt) {
|
|
94
|
+
const common = {
|
|
95
|
+
eventId: `task-lifecycle:${receipt.receiptId}`,
|
|
96
|
+
repositoryIds: task.repositoryIds,
|
|
97
|
+
taskId: task.id,
|
|
98
|
+
...task.changeId === void 0 ? {} : { changeId: task.changeId },
|
|
99
|
+
replyTo: task.replyTo
|
|
100
|
+
};
|
|
101
|
+
if (receipt.state === "dispatched" && receipt.phase === "retry") return {
|
|
102
|
+
...common,
|
|
103
|
+
outcome: "started",
|
|
104
|
+
data: { message: `Retry attempt ${receipt.attempt} started.${receipt.reason === void 0 ? "" : ` ${receipt.reason}`}` }
|
|
105
|
+
};
|
|
106
|
+
if (receipt.state === "failed") {
|
|
107
|
+
let prefix = "Work failed.";
|
|
108
|
+
if (receipt.reason?.startsWith("launch failed")) prefix = "Work failed to start.";
|
|
109
|
+
else if (receipt.phase === "retry") prefix = "Retries exhausted.";
|
|
110
|
+
return {
|
|
111
|
+
...common,
|
|
112
|
+
outcome: "failed",
|
|
113
|
+
data: { reason: `${prefix}${receipt.reason === void 0 ? "" : ` ${receipt.reason}`}` }
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (receipt.state === "cancelled") {
|
|
117
|
+
const prefix = receipt.phase === "approval" ? "Request rejected." : "Work cancelled.";
|
|
118
|
+
return {
|
|
119
|
+
...common,
|
|
120
|
+
outcome: "cancelled",
|
|
121
|
+
data: {
|
|
122
|
+
message: `${prefix}${receipt.reason === void 0 ? "" : ` ${receipt.reason}`}`,
|
|
123
|
+
...receipt.phase === "approval" ? { approvalDecision: true } : {}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (receipt.state === "succeeded") return {
|
|
128
|
+
...common,
|
|
129
|
+
outcome: "succeeded",
|
|
130
|
+
data: {
|
|
131
|
+
summary: completionSummary(task, receipt),
|
|
132
|
+
output: task.workResult?.output
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
throw new Error(`Receipt ${receipt.receiptId} is not a communicable task lifecycle event.`);
|
|
136
|
+
}
|
|
137
|
+
async function coordinationEvent(stores, tasks, parent, receipt) {
|
|
138
|
+
const children = tasks.filter((task) => task.parentTaskId === parent.id);
|
|
139
|
+
const items = await Promise.all(children.map(async (child) => {
|
|
140
|
+
const repository = await stores.repositories.get(child.repositoryIds[0]);
|
|
141
|
+
const change = child.changeId === void 0 ? null : await stores.changes.get(child.changeId);
|
|
142
|
+
return `${repository?.slug ?? child.repositoryIds[0]}: ${change?.prUrl ?? child.state}`;
|
|
143
|
+
}));
|
|
144
|
+
const event = eventFor(parent, receipt);
|
|
145
|
+
return {
|
|
146
|
+
...event,
|
|
147
|
+
data: {
|
|
148
|
+
...event.data,
|
|
149
|
+
summary: receipt.state === "succeeded" ? "Coordinated work completed." : "Coordinated work failed in one or more repositories.",
|
|
150
|
+
items
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { createSoftwareDevelopmentTaskCommunication };
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=task-communication.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-communication.mjs","names":[],"sources":["../../../src/presets/software-development/task-communication.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { CommunicationEvent } from \"../../schema/communication\";\nimport type { ReplyTo } from \"../../schema/common\";\nimport type { Receipt } from \"../../schema/receipt\";\nimport type { Task } from \"../../schema/task\";\nimport { agentSessionIdSchema } from \"../../schema/session\";\nimport type { FactoryStores } from \"../../store/engine\";\nimport {\n createTaskCommunicationReconciler,\n type TaskCommunicationReconciler,\n} from \"../../task-communication\";\n\n/** Store capabilities required by supplied software-development communication projections. */\nexport type SoftwareDevelopmentTaskCommunicationStores = Pick<\n FactoryStores,\n \"changes\" | \"outbox\" | \"receipts\" | \"repositories\" | \"tasks\"\n>;\n\n/** Connector presentation settings for supplied software Task communications. */\nexport interface SoftwareDevelopmentTaskCommunicationOptions {\n githubMention?: string;\n /** Optional additional notification destination; omitted keeps questions in their original conversation. */\n needsHumanReplyTo?: ReplyTo;\n}\n\n/** Supplied question projection and durable lifecycle communication reconciler. */\nexport interface SoftwareDevelopmentTaskCommunication {\n questionEvents(task: Task): readonly CommunicationEvent[];\n reconcile: TaskCommunicationReconciler<SoftwareDevelopmentTaskCommunicationStores>;\n}\n\nconst reviewOutputSchema = z.object({\n verdict: z.enum([\"approve\", \"request_changes\", \"comment\"]),\n findingCount: z.number().int().nonnegative(),\n review: z.object({ url: z.url(), state: z.string().optional() }).optional(),\n});\n\n/** Supplied Slack, GitHub, and API presentation for a task question. */\nexport function createSoftwareDevelopmentTaskCommunication(\n options: SoftwareDevelopmentTaskCommunicationOptions = {},\n): SoftwareDevelopmentTaskCommunication {\n const githubMention = options.githubMention ?? \"@agent-factory\";\n if (githubMention.trim().length === 0) throw new Error(\"githubMention must not be empty\");\n const needsHumanReplyTo = options.needsHumanReplyTo;\n\n function questionEvents(task: Task): readonly CommunicationEvent[] {\n if (task.kind !== \"question\" || task.question === undefined)\n throw new Error(`Task ${task.id} has no question.`);\n const reference = `Reference: ${task.id}`;\n const session =\n task.replyTo.channel === \"api\" && agentSessionIdSchema.safeParse(task.replyTo.address);\n const instructions =\n session && session.success\n ? `Open Factory session ${session.data}: factory-tui --config REPLACE_WITH_TUI_CONFIG.json --session ${session.data}\\nReplace REPLACE_WITH_TUI_CONFIG.json with an authenticated TUI config for the factory that sent this notice. Review the current question before answering; this notice may be stale.`\n : task.replyTo.channel === \"slack\"\n ? \"To answer, reply in the original Slack thread and mention the Factory app.\"\n : task.replyTo.channel === \"github\" &&\n /^[^/]+\\/[^/#]+(?:#|\\/pull\\/)[1-9][0-9]*$/u.test(task.replyTo.address)\n ? `To answer, comment on ${task.replyTo.address} starting with \\`${githubMention}\\`.`\n : `No Factory conversation link recorded. Reply destination: ${task.replyTo.channel} ${task.replyTo.address}. Ask an operator to locate the original conversation using the question reference; do not use approve or retry-intake to answer it.`;\n const common = { repositoryIds: task.repositoryIds, taskId: task.id };\n const action = task.needsHumanAction ?? task.question.text;\n const events: CommunicationEvent[] = [\n {\n ...common,\n eventId: `question:${task.id}:${task.attempt}`,\n replyTo: task.replyTo,\n outcome: \"question\",\n data: {\n question: `${reference}\\n\\n${instructions}\\n\\n${task.question.text}`,\n options: task.question.options,\n },\n },\n ];\n if (needsHumanReplyTo !== undefined) {\n events.push({\n ...common,\n eventId: `needs-human:${task.id}:${task.attempt}`,\n replyTo: needsHumanReplyTo,\n outcome: \"needs_human\",\n data: {\n requestedAction: action.length > 2000 ? `${action.slice(0, 2000)}…` : action,\n message: `${reference}\\nReply destination: ${task.replyTo.channel} ${task.replyTo.address}\\n${instructions}\\nReplies in this notification DM do not answer the question.`,\n options: task.question.options,\n questionAttempt: task.attempt,\n ...(task.parentTaskId === undefined ? {} : { parentTaskId: task.parentTaskId }),\n replyChannel: task.replyTo.channel,\n replyAddress: task.replyTo.address,\n },\n });\n }\n return events;\n }\n\n return {\n questionEvents,\n reconcile: createTaskCommunicationReconciler<SoftwareDevelopmentTaskCommunicationStores>({\n question: questionEvents,\n async lifecycle({ stores, tasks, task, receipt }) {\n if (receipt.state === \"succeeded\" && task.changeId !== undefined) {\n if (\n task.work.route?.id !== \"code-review\" ||\n task.work.route.version !== 1 ||\n task.origin.operator === undefined\n )\n return [];\n const output = reviewOutputSchema.parse(task.workResult?.output);\n const change = await stores.changes.get(task.changeId);\n if (change === null) throw new Error(`Review ${task.id} references a missing Change.`);\n const findings =\n output.findingCount === 0\n ? output.verdict === \"request_changes\"\n ? \"Changes requested.\"\n : output.review?.state === \"APPROVED\"\n ? \"Approved. No issues found.\"\n : \"No issues found.\"\n : `${output.findingCount} finding${output.findingCount === 1 ? \"\" : \"s\"}.${output.verdict === \"request_changes\" ? \" Changes requested.\" : \"\"}`;\n const event = eventFor(task, receipt);\n return [\n {\n ...event,\n data: {\n ...event.data,\n title: `Review complete for PR #${change.prNumber}`,\n summary: findings,\n url: output.review?.url ?? change.prUrl,\n },\n },\n ];\n }\n const event =\n task.kind === \"coordination\" &&\n (receipt.state === \"succeeded\" || receipt.state === \"failed\")\n ? await coordinationEvent(stores, tasks, task, receipt)\n : eventFor(task, receipt);\n return [event];\n },\n }),\n };\n}\n\nfunction completionSummary(task: Task, receipt: Receipt): string {\n const output = task.workResult?.output;\n const fields =\n typeof output === \"object\" && output !== null && !Array.isArray(output)\n ? [\n \"summary\" in output ? output.summary : undefined,\n \"result\" in output ? output.result : undefined,\n ]\n : [output];\n const summary = [...fields, receipt.reason].find(\n (value): value is string => typeof value === \"string\" && value.trim().length > 0,\n );\n if (!summary) return \"Completed. No result summary was recorded; open the chat for details.\";\n const text = summary.trim();\n return text.length > 1000 ? `${text.slice(0, 997)}…` : text;\n}\n\nfunction eventFor(task: Task, receipt: Receipt): CommunicationEvent {\n const common = {\n eventId: `task-lifecycle:${receipt.receiptId}`,\n repositoryIds: task.repositoryIds,\n taskId: task.id,\n ...(task.changeId === undefined ? {} : { changeId: task.changeId }),\n replyTo: task.replyTo,\n };\n if (receipt.state === \"dispatched\" && receipt.phase === \"retry\") {\n return {\n ...common,\n outcome: \"started\",\n data: {\n message: `Retry attempt ${receipt.attempt} started.${receipt.reason === undefined ? \"\" : ` ${receipt.reason}`}`,\n },\n };\n }\n if (receipt.state === \"failed\") {\n let prefix = \"Work failed.\";\n if (receipt.reason?.startsWith(\"launch failed\")) prefix = \"Work failed to start.\";\n else if (receipt.phase === \"retry\") prefix = \"Retries exhausted.\";\n return {\n ...common,\n outcome: \"failed\",\n data: { reason: `${prefix}${receipt.reason === undefined ? \"\" : ` ${receipt.reason}`}` },\n };\n }\n if (receipt.state === \"cancelled\") {\n const prefix = receipt.phase === \"approval\" ? \"Request rejected.\" : \"Work cancelled.\";\n return {\n ...common,\n outcome: \"cancelled\",\n data: {\n message: `${prefix}${receipt.reason === undefined ? \"\" : ` ${receipt.reason}`}`,\n ...(receipt.phase === \"approval\" ? { approvalDecision: true } : {}),\n },\n };\n }\n if (receipt.state === \"succeeded\") {\n return {\n ...common,\n outcome: \"succeeded\",\n data: {\n summary: completionSummary(task, receipt),\n output: task.workResult?.output,\n },\n };\n }\n throw new Error(`Receipt ${receipt.receiptId} is not a communicable task lifecycle event.`);\n}\n\nasync function coordinationEvent(\n stores: SoftwareDevelopmentTaskCommunicationStores,\n tasks: readonly Task[],\n parent: Task,\n receipt: Receipt,\n): Promise<CommunicationEvent> {\n const children = tasks.filter((task) => task.parentTaskId === parent.id);\n const items = await Promise.all(\n children.map(async (child) => {\n const repository = await stores.repositories.get(child.repositoryIds[0]!);\n const change = child.changeId === undefined ? null : await stores.changes.get(child.changeId);\n return `${repository?.slug ?? child.repositoryIds[0]}: ${change?.prUrl ?? child.state}`;\n }),\n );\n const event = eventFor(parent, receipt);\n return {\n ...event,\n data: {\n ...event.data,\n summary:\n receipt.state === \"succeeded\"\n ? \"Coordinated work completed.\"\n : \"Coordinated work failed in one or more repositories.\",\n items,\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { formatDeepsecScanBrief } from "./software-development/deepsec-brief.mjs";
|
|
3
|
+
import { SoftwareDevelopmentRecoveryOptions, SoftwareDevelopmentRecoveryStores, StartSoftwareDevelopmentRecovery, StartSoftwareDevelopmentRecoveryInput, createSoftwareDevelopmentRecoveryLaunchers } from "./software-development/recovery.mjs";
|
|
4
|
+
import { defaultSoftwareDevelopmentApprovalPolicy } from "./software-development/approval.mjs";
|
|
5
|
+
import { softwareDevelopmentFinishTaskPolicy } from "./software-development/finish-task-policy.mjs";
|
|
6
|
+
import { softwareDevelopmentDelegationPolicy } from "./software-development/eve-delegation-policy.mjs";
|
|
7
|
+
import { SoftwareDevelopmentTools, SoftwareDevelopmentToolsOptions, SoftwareDevelopmentToolsStores, createSoftwareDevelopmentTools } from "./software-development/eve.mjs";
|
|
8
|
+
import { SoftwareDevelopmentTaskCommunication, SoftwareDevelopmentTaskCommunicationOptions, SoftwareDevelopmentTaskCommunicationStores, createSoftwareDevelopmentTaskCommunication } from "./software-development/task-communication.mjs";
|
|
9
|
+
import { DispatchSoftwareDevelopmentWorkOptions, DispatchSoftwareDevelopmentWorkResult, SoftwareDevelopmentDispatchStores, dispatchSoftwareDevelopmentWork } from "./software-development/dispatch.mjs";
|
|
10
|
+
export { type DispatchSoftwareDevelopmentWorkOptions, type DispatchSoftwareDevelopmentWorkResult, type SoftwareDevelopmentDispatchStores, type SoftwareDevelopmentRecoveryOptions, type SoftwareDevelopmentRecoveryStores, type SoftwareDevelopmentTaskCommunication, type SoftwareDevelopmentTaskCommunicationOptions, type SoftwareDevelopmentTaskCommunicationStores, type SoftwareDevelopmentTools, type SoftwareDevelopmentToolsOptions, type SoftwareDevelopmentToolsStores, type StartSoftwareDevelopmentRecovery, type StartSoftwareDevelopmentRecoveryInput, createSoftwareDevelopmentRecoveryLaunchers, createSoftwareDevelopmentTaskCommunication, createSoftwareDevelopmentTools, defaultSoftwareDevelopmentApprovalPolicy, dispatchSoftwareDevelopmentWork, formatDeepsecScanBrief, softwareDevelopmentDelegationPolicy, softwareDevelopmentFinishTaskPolicy };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { formatDeepsecScanBrief } from "./software-development/deepsec-brief.mjs";
|
|
2
|
+
import { createSoftwareDevelopmentRecoveryLaunchers } from "./software-development/recovery.mjs";
|
|
3
|
+
import { defaultSoftwareDevelopmentApprovalPolicy } from "./software-development/approval.mjs";
|
|
4
|
+
import { softwareDevelopmentFinishTaskPolicy } from "./software-development/finish-task-policy.mjs";
|
|
5
|
+
import { softwareDevelopmentDelegationPolicy } from "./software-development/eve-delegation-policy.mjs";
|
|
6
|
+
import { createSoftwareDevelopmentTools } from "./software-development/eve.mjs";
|
|
7
|
+
import { createSoftwareDevelopmentTaskCommunication } from "./software-development/task-communication.mjs";
|
|
8
|
+
import { dispatchSoftwareDevelopmentWork } from "./software-development/dispatch.mjs";
|
|
9
|
+
export { createSoftwareDevelopmentRecoveryLaunchers, createSoftwareDevelopmentTaskCommunication, createSoftwareDevelopmentTools, defaultSoftwareDevelopmentApprovalPolicy, dispatchSoftwareDevelopmentWork, formatDeepsecScanBrief, softwareDevelopmentDelegationPolicy, softwareDevelopmentFinishTaskPolicy };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { RepositoryId, TaskId } from "../schema/id.mjs";
|
|
2
|
+
import { AgentSessionId } from "../schema/session.mjs";
|
|
3
|
+
//#region src/pull-requests/contracts.d.ts
|
|
4
|
+
/** Human-facing title and description for a new draft pull request. */
|
|
5
|
+
interface OpenPullRequestInput {
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
}
|
|
9
|
+
/** Publication state requested when pushing the current committed checkpoint. */
|
|
10
|
+
interface PushCheckpointInput {
|
|
11
|
+
/** Mark the pull request ready for review once this checkpoint lands. */
|
|
12
|
+
ready: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Pull-request identity and checkpoint details returned after publication. */
|
|
15
|
+
interface PublishedPullRequest {
|
|
16
|
+
prNumber: number;
|
|
17
|
+
prUrl: string;
|
|
18
|
+
branch: string;
|
|
19
|
+
changedFiles: number;
|
|
20
|
+
draft: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Existing open pull request owned by a durable Task branch. */
|
|
23
|
+
interface TaskPullRequest {
|
|
24
|
+
prNumber: number;
|
|
25
|
+
prUrl: string;
|
|
26
|
+
branch: string;
|
|
27
|
+
}
|
|
28
|
+
/** Open pull-request metadata used to detect work already in progress. */
|
|
29
|
+
interface OpenPullRequest {
|
|
30
|
+
prNumber: number;
|
|
31
|
+
prUrl: string;
|
|
32
|
+
title: string;
|
|
33
|
+
author: string;
|
|
34
|
+
headBranch: string;
|
|
35
|
+
draft: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Durable Task or operator session that owns a publication branch. */
|
|
38
|
+
type PullRequestPublicationOwner = TaskId | {
|
|
39
|
+
sessionId: AgentSessionId;
|
|
40
|
+
};
|
|
41
|
+
/** Task, repository, and pull request asserted before a workflow records a Change. */
|
|
42
|
+
interface PullRequestPublicationGateInput {
|
|
43
|
+
taskId: TaskId;
|
|
44
|
+
repositoryId: RepositoryId;
|
|
45
|
+
prNumber: number;
|
|
46
|
+
prUrl: string;
|
|
47
|
+
}
|
|
48
|
+
/** Machine-readable reason a pull request failed the publication gate. */
|
|
49
|
+
type PullRequestPublicationGateFailureCode = "repository_mismatch" | "task_not_found" | "change_not_found" | "linked_change_mismatch" | "repository_lookup_failed" | "authentication_failed" | "pull_request_not_found" | "pull_request_lookup_failed" | "pull_request_url_mismatch" | "pull_request_closed" | "pull_request_branch_mismatch" | "pull_request_draft";
|
|
50
|
+
/** Successful validation that a pull request belongs to the supplied Task and Change. */
|
|
51
|
+
interface PullRequestPublicationGateSuccess {
|
|
52
|
+
ok: true;
|
|
53
|
+
}
|
|
54
|
+
/** Bounded refusal from the pull-request publication gate. */
|
|
55
|
+
interface PullRequestPublicationGateFailure {
|
|
56
|
+
ok: false;
|
|
57
|
+
code: PullRequestPublicationGateFailureCode;
|
|
58
|
+
reason: string;
|
|
59
|
+
}
|
|
60
|
+
/** Fail-closed result of validating a pull request against its owning Task and Change. */
|
|
61
|
+
type PullRequestPublicationGateResult = PullRequestPublicationGateSuccess | PullRequestPublicationGateFailure;
|
|
62
|
+
/** Metadata-only label mutation supported for a pull request. */
|
|
63
|
+
type PullRequestLabelAction = "add" | "remove";
|
|
64
|
+
/** Pull-request identity and resulting label set after a label mutation. */
|
|
65
|
+
interface PullRequestLabelResult {
|
|
66
|
+
prNumber: number;
|
|
67
|
+
prUrl: string;
|
|
68
|
+
labels: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { OpenPullRequest, OpenPullRequestInput, PublishedPullRequest, PullRequestLabelAction, PullRequestLabelResult, PullRequestPublicationGateFailure, PullRequestPublicationGateFailureCode, PullRequestPublicationGateInput, PullRequestPublicationGateResult, PullRequestPublicationGateSuccess, PullRequestPublicationOwner, PushCheckpointInput, TaskPullRequest };
|
|
72
|
+
//# sourceMappingURL=contracts.d.mts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FactoryStores } from "../store/engine.mjs";
|
|
2
|
+
import { GitHubGitTransport } from "../github-transfer.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { ToolContext, ToolDefinition } from "eve/tools";
|
|
5
|
+
//#region src/pull-requests/eve-fetch.d.ts
|
|
6
|
+
/** Change, repository, and Task capabilities required by the trusted pull-request fetch tool. */
|
|
7
|
+
type GitHubFetchPullRequestToolStores = Pick<FactoryStores, "changes" | "repositories" | "tasks">;
|
|
8
|
+
/** Validates the Change identity supplied to the trusted pull-request fetch tool. */
|
|
9
|
+
declare const gitHubFetchPullRequestInputSchema: z.ZodObject<{
|
|
10
|
+
changeId: z.ZodType<`chg_${string}`, string, z.core.$ZodTypeInternals<`chg_${string}`, string>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/** Change identity supplied to the trusted pull-request fetch tool. */
|
|
13
|
+
type GitHubFetchPullRequestInput = z.infer<typeof gitHubFetchPullRequestInputSchema>;
|
|
14
|
+
/** Stores, Git credential boundary, and checkout used to construct a pull-request fetch tool. */
|
|
15
|
+
interface GitHubFetchPullRequestToolOptions {
|
|
16
|
+
stores: GitHubFetchPullRequestToolStores;
|
|
17
|
+
/** Fetches Git objects outside the agent sandbox with read-only credentials. */
|
|
18
|
+
git: GitHubGitTransport;
|
|
19
|
+
/** Path of the checkout inside the sandbox. Defaults to `repo`. */
|
|
20
|
+
repoPath?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Machine-readable reason a trusted pull-request fetch did not complete. */
|
|
23
|
+
type GitHubFetchPullRequestFailureCode = "change_not_found" | "change_not_owned_by_task" | "change_not_reviewable" | "repository_not_found" | "repository_disabled" | "git_fetch_failed" | "merge_base_failed";
|
|
24
|
+
/** Bounded refusal returned when a trusted pull-request fetch cannot complete. */
|
|
25
|
+
interface GitHubFetchPullRequestFailure {
|
|
26
|
+
fetched: false;
|
|
27
|
+
code: GitHubFetchPullRequestFailureCode;
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
/** Exact pull-request revision and diff context produced by a trusted fetch. */
|
|
31
|
+
interface GitHubFetchPullRequestSuccess {
|
|
32
|
+
fetched: true;
|
|
33
|
+
prNumber: number;
|
|
34
|
+
prUrl: string;
|
|
35
|
+
branch: string;
|
|
36
|
+
headSha: string;
|
|
37
|
+
baseBranch: string;
|
|
38
|
+
baseSha: string;
|
|
39
|
+
mergeBaseSha: string;
|
|
40
|
+
diffCommand: string;
|
|
41
|
+
}
|
|
42
|
+
/** The refusal or exact pull-request revision and diff context produced by a trusted fetch. */
|
|
43
|
+
type GitHubFetchPullRequestResult = GitHubFetchPullRequestFailure | GitHubFetchPullRequestSuccess;
|
|
44
|
+
/** Eve tool that fetches the exact pull-request revision linked to the current Task. */
|
|
45
|
+
interface GitHubFetchPullRequestTool extends ToolDefinition<GitHubFetchPullRequestInput, GitHubFetchPullRequestResult> {
|
|
46
|
+
execute(input: GitHubFetchPullRequestInput, ctx: ToolContext): Promise<GitHubFetchPullRequestResult>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create the verifier's tool for fetching the change under review. The sandbox has no
|
|
50
|
+
* GitHub credential. A separate trusted transport fetches Git objects;
|
|
51
|
+
* only a credential-free bundle enters the agent sandbox. The pull request number and repository come from the
|
|
52
|
+
* change record, never from the agent.
|
|
53
|
+
*/
|
|
54
|
+
declare function createGitHubFetchPullRequestTool(input: GitHubFetchPullRequestToolOptions): GitHubFetchPullRequestTool;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { GitHubFetchPullRequestFailure, GitHubFetchPullRequestFailureCode, GitHubFetchPullRequestInput, GitHubFetchPullRequestResult, GitHubFetchPullRequestSuccess, GitHubFetchPullRequestTool, GitHubFetchPullRequestToolOptions, GitHubFetchPullRequestToolStores, createGitHubFetchPullRequestTool, gitHubFetchPullRequestInputSchema };
|
|
57
|
+
//# sourceMappingURL=eve-fetch.d.mts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { changeIdSchema } from "../schema/id.mjs";
|
|
2
|
+
import { requireTaskIdForSession } from "../eve/task-session.mjs";
|
|
3
|
+
import { requireTaskExecution } from "../eve/task-execution.mjs";
|
|
4
|
+
import { fetchGitHubRefs, quoteShellArgument, runSandboxCommand } from "../github-transfer.mjs";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { defineTool } from "eve/tools";
|
|
7
|
+
//#region src/pull-requests/eve-fetch.ts
|
|
8
|
+
/** Validates the Change identity supplied to the trusted pull-request fetch tool. */
|
|
9
|
+
const gitHubFetchPullRequestInputSchema = z.object({ changeId: changeIdSchema.describe("The Change linked to your Task, returned by get_task.") });
|
|
10
|
+
function authorizeTaskChange(task, change) {
|
|
11
|
+
if (task.changeId !== void 0 && task.changeId !== change.id) return {
|
|
12
|
+
fetched: false,
|
|
13
|
+
code: "change_not_owned_by_task",
|
|
14
|
+
reason: `change ${change.id} is not linked to task ${task.id}`
|
|
15
|
+
};
|
|
16
|
+
if (!task.repositoryIds.includes(change.repositoryId)) return {
|
|
17
|
+
fetched: false,
|
|
18
|
+
code: "change_not_owned_by_task",
|
|
19
|
+
reason: `change ${change.id} belongs to repository ${change.repositoryId}, outside task ${task.id}'s repository scope`
|
|
20
|
+
};
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create the verifier's tool for fetching the change under review. The sandbox has no
|
|
25
|
+
* GitHub credential. A separate trusted transport fetches Git objects;
|
|
26
|
+
* only a credential-free bundle enters the agent sandbox. The pull request number and repository come from the
|
|
27
|
+
* change record, never from the agent.
|
|
28
|
+
*/
|
|
29
|
+
function createGitHubFetchPullRequestTool(input) {
|
|
30
|
+
const { stores } = input;
|
|
31
|
+
const repoPath = input.repoPath ?? "repo";
|
|
32
|
+
return defineTool({
|
|
33
|
+
description: "Fetch the pull request and the repository's current default branch, then check out the pull request as local branch `pr`. Call this after get_task, before inspecting or testing the change. Returns an exact diff command based on their merge base; use it instead of origin/HEAD.",
|
|
34
|
+
inputSchema: gitHubFetchPullRequestInputSchema,
|
|
35
|
+
async execute({ changeId }, ctx) {
|
|
36
|
+
const taskId = requireTaskIdForSession(ctx.session?.auth.initiator);
|
|
37
|
+
let task = await requireTaskExecution(stores, ctx, taskId);
|
|
38
|
+
const change = await stores.changes.get(changeId);
|
|
39
|
+
if (change === null) return {
|
|
40
|
+
fetched: false,
|
|
41
|
+
code: "change_not_found",
|
|
42
|
+
reason: `change ${changeId} does not exist`
|
|
43
|
+
};
|
|
44
|
+
const authorizationFailure = authorizeTaskChange(task, change);
|
|
45
|
+
if (authorizationFailure !== null) return authorizationFailure;
|
|
46
|
+
if (change.state !== "verifying" && change.state !== "ready") return {
|
|
47
|
+
fetched: false,
|
|
48
|
+
code: "change_not_reviewable",
|
|
49
|
+
reason: `change is ${change.state}, not open for review; nothing to fetch`
|
|
50
|
+
};
|
|
51
|
+
const repository = await stores.repositories.get(change.repositoryId);
|
|
52
|
+
if (repository === null) return {
|
|
53
|
+
fetched: false,
|
|
54
|
+
code: "repository_not_found",
|
|
55
|
+
reason: `repository ${change.repositoryId} does not exist`
|
|
56
|
+
};
|
|
57
|
+
if (!repository.enabled) return {
|
|
58
|
+
fetched: false,
|
|
59
|
+
code: "repository_disabled",
|
|
60
|
+
reason: `repository ${change.repositoryId} is disabled`
|
|
61
|
+
};
|
|
62
|
+
const sandbox = await ctx.getSandbox();
|
|
63
|
+
const currentChange = await stores.changes.get(changeId);
|
|
64
|
+
if (currentChange === null) return {
|
|
65
|
+
fetched: false,
|
|
66
|
+
code: "change_not_found",
|
|
67
|
+
reason: `change ${changeId} does not exist`
|
|
68
|
+
};
|
|
69
|
+
if (currentChange.state !== "verifying" && currentChange.state !== "ready") return {
|
|
70
|
+
fetched: false,
|
|
71
|
+
code: "change_not_reviewable",
|
|
72
|
+
reason: `change is ${currentChange.state}, not open for review; nothing to fetch`
|
|
73
|
+
};
|
|
74
|
+
const currentRepository = await stores.repositories.get(currentChange.repositoryId);
|
|
75
|
+
if (currentRepository === null) return {
|
|
76
|
+
fetched: false,
|
|
77
|
+
code: "repository_not_found",
|
|
78
|
+
reason: `repository ${currentChange.repositoryId} does not exist`
|
|
79
|
+
};
|
|
80
|
+
if (!currentRepository.enabled) return {
|
|
81
|
+
fetched: false,
|
|
82
|
+
code: "repository_disabled",
|
|
83
|
+
reason: `repository ${currentChange.repositoryId} is disabled`
|
|
84
|
+
};
|
|
85
|
+
task = await requireTaskExecution(stores, ctx, taskId);
|
|
86
|
+
const currentAuthorizationFailure = authorizeTaskChange(task, currentChange);
|
|
87
|
+
if (currentAuthorizationFailure !== null) return currentAuthorizationFailure;
|
|
88
|
+
const tracking = `refs/remotes/origin/pr-${currentChange.prNumber}`;
|
|
89
|
+
const baseTracking = `refs/remotes/origin/${currentRepository.defaultBranch}`;
|
|
90
|
+
const git = [
|
|
91
|
+
"git",
|
|
92
|
+
"-C",
|
|
93
|
+
repoPath
|
|
94
|
+
].map(quoteShellArgument).join(" ");
|
|
95
|
+
try {
|
|
96
|
+
await fetchGitHubRefs({
|
|
97
|
+
sandbox,
|
|
98
|
+
transport: input.git,
|
|
99
|
+
repository: currentRepository.slug,
|
|
100
|
+
refs: [{
|
|
101
|
+
remote: `refs/heads/${currentRepository.defaultBranch}`,
|
|
102
|
+
local: baseTracking
|
|
103
|
+
}, {
|
|
104
|
+
remote: `refs/pull/${currentChange.prNumber}/head`,
|
|
105
|
+
local: tracking
|
|
106
|
+
}],
|
|
107
|
+
repositoryPath: repoPath
|
|
108
|
+
});
|
|
109
|
+
await runSandboxCommand(sandbox, [
|
|
110
|
+
"git",
|
|
111
|
+
"-C",
|
|
112
|
+
repoPath,
|
|
113
|
+
"checkout",
|
|
114
|
+
"-B",
|
|
115
|
+
"pr",
|
|
116
|
+
tracking
|
|
117
|
+
]);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
fetched: false,
|
|
121
|
+
code: "git_fetch_failed",
|
|
122
|
+
reason: `git fetch of pull request ${currentChange.prNumber} failed: ${error instanceof Error ? error.message : "Git transfer failed"}`
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const head = await sandbox.run({ command: `${git} rev-parse HEAD` });
|
|
126
|
+
const base = await sandbox.run({ command: `${git} rev-parse ${baseTracking}` });
|
|
127
|
+
const mergeBase = await sandbox.run({ command: `${git} merge-base ${baseTracking} pr` });
|
|
128
|
+
if (typeof mergeBase.exitCode === "number" && mergeBase.exitCode !== 0) return {
|
|
129
|
+
fetched: false,
|
|
130
|
+
code: "merge_base_failed",
|
|
131
|
+
reason: `could not determine the pull request merge base: ${(mergeBase.stderr ?? "").trim()}`
|
|
132
|
+
};
|
|
133
|
+
const mergeBaseSha = mergeBase.stdout.trim();
|
|
134
|
+
return {
|
|
135
|
+
fetched: true,
|
|
136
|
+
prNumber: currentChange.prNumber,
|
|
137
|
+
prUrl: currentChange.prUrl,
|
|
138
|
+
branch: "pr",
|
|
139
|
+
headSha: head.stdout.trim(),
|
|
140
|
+
baseBranch: currentRepository.defaultBranch,
|
|
141
|
+
baseSha: base.stdout.trim(),
|
|
142
|
+
mergeBaseSha,
|
|
143
|
+
diffCommand: `${git} diff ${mergeBaseSha}..pr`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { createGitHubFetchPullRequestTool, gitHubFetchPullRequestInputSchema };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=eve-fetch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eve-fetch.mjs","names":[],"sources":["../../src/pull-requests/eve-fetch.ts"],"sourcesContent":["import {\n fetchGitHubRefs,\n quoteShellArgument,\n runSandboxCommand,\n type GitHubGitTransport,\n} from \"../github-transfer\";\nimport { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { changeIdSchema } from \"../schema/id\";\nimport type { Change } from \"../schema/change\";\nimport type { Task } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\nimport { requireTaskExecution } from \"../eve/task-execution\";\nimport { requireTaskIdForSession } from \"../eve/task-session\";\n\n/** Change, repository, and Task capabilities required by the trusted pull-request fetch tool. */\nexport type GitHubFetchPullRequestToolStores = Pick<\n FactoryStores,\n \"changes\" | \"repositories\" | \"tasks\"\n>;\n\n/** Validates the Change identity supplied to the trusted pull-request fetch tool. */\nexport const gitHubFetchPullRequestInputSchema = z.object({\n changeId: changeIdSchema.describe(\"The Change linked to your Task, returned by get_task.\"),\n});\n\n/** Change identity supplied to the trusted pull-request fetch tool. */\nexport type GitHubFetchPullRequestInput = z.infer<typeof gitHubFetchPullRequestInputSchema>;\n\n/** Stores, Git credential boundary, and checkout used to construct a pull-request fetch tool. */\nexport interface GitHubFetchPullRequestToolOptions {\n stores: GitHubFetchPullRequestToolStores;\n /** Fetches Git objects outside the agent sandbox with read-only credentials. */\n git: GitHubGitTransport;\n /** Path of the checkout inside the sandbox. Defaults to `repo`. */\n repoPath?: string;\n}\n\n/** Machine-readable reason a trusted pull-request fetch did not complete. */\nexport type GitHubFetchPullRequestFailureCode =\n | \"change_not_found\"\n | \"change_not_owned_by_task\"\n | \"change_not_reviewable\"\n | \"repository_not_found\"\n | \"repository_disabled\"\n | \"git_fetch_failed\"\n | \"merge_base_failed\";\n\n/** Bounded refusal returned when a trusted pull-request fetch cannot complete. */\nexport interface GitHubFetchPullRequestFailure {\n fetched: false;\n code: GitHubFetchPullRequestFailureCode;\n reason: string;\n}\n\n/** Exact pull-request revision and diff context produced by a trusted fetch. */\nexport interface GitHubFetchPullRequestSuccess {\n fetched: true;\n prNumber: number;\n prUrl: string;\n branch: string;\n headSha: string;\n baseBranch: string;\n baseSha: string;\n mergeBaseSha: string;\n diffCommand: string;\n}\n\n/** The refusal or exact pull-request revision and diff context produced by a trusted fetch. */\nexport type GitHubFetchPullRequestResult =\n | GitHubFetchPullRequestFailure\n | GitHubFetchPullRequestSuccess;\n\n/** Eve tool that fetches the exact pull-request revision linked to the current Task. */\nexport interface GitHubFetchPullRequestTool extends ToolDefinition<\n GitHubFetchPullRequestInput,\n GitHubFetchPullRequestResult\n> {\n execute(\n input: GitHubFetchPullRequestInput,\n ctx: ToolContext,\n ): Promise<GitHubFetchPullRequestResult>;\n}\n\nfunction authorizeTaskChange(task: Task, change: Change): GitHubFetchPullRequestFailure | null {\n if (task.changeId !== undefined && task.changeId !== change.id) {\n return {\n fetched: false,\n code: \"change_not_owned_by_task\",\n reason: `change ${change.id} is not linked to task ${task.id}`,\n };\n }\n if (!task.repositoryIds.includes(change.repositoryId)) {\n return {\n fetched: false,\n code: \"change_not_owned_by_task\",\n reason: `change ${change.id} belongs to repository ${change.repositoryId}, outside task ${task.id}'s repository scope`,\n };\n }\n return null;\n}\n\n/**\n * Create the verifier's tool for fetching the change under review. The sandbox has no\n * GitHub credential. A separate trusted transport fetches Git objects;\n * only a credential-free bundle enters the agent sandbox. The pull request number and repository come from the\n * change record, never from the agent.\n */\nexport function createGitHubFetchPullRequestTool(\n input: GitHubFetchPullRequestToolOptions,\n): GitHubFetchPullRequestTool {\n const { stores } = input;\n const repoPath = input.repoPath ?? \"repo\";\n return defineTool({\n description:\n \"Fetch the pull request and the repository's current default branch, then check out the pull request as local branch `pr`. Call this after get_task, before inspecting or testing the change. Returns an exact diff command based on their merge base; use it instead of origin/HEAD.\",\n inputSchema: gitHubFetchPullRequestInputSchema,\n async execute({ changeId }, ctx): Promise<GitHubFetchPullRequestResult> {\n const taskId = requireTaskIdForSession(ctx.session?.auth.initiator);\n let task = await requireTaskExecution(stores, ctx, taskId);\n const change = await stores.changes.get(changeId);\n if (change === null) {\n return {\n fetched: false,\n code: \"change_not_found\",\n reason: `change ${changeId} does not exist`,\n };\n }\n const authorizationFailure = authorizeTaskChange(task, change);\n if (authorizationFailure !== null) return authorizationFailure;\n if (change.state !== \"verifying\" && change.state !== \"ready\") {\n return {\n fetched: false,\n code: \"change_not_reviewable\",\n reason: `change is ${change.state}, not open for review; nothing to fetch`,\n };\n }\n const repository = await stores.repositories.get(change.repositoryId);\n if (repository === null) {\n return {\n fetched: false,\n code: \"repository_not_found\",\n reason: `repository ${change.repositoryId} does not exist`,\n };\n }\n if (!repository.enabled) {\n return {\n fetched: false,\n code: \"repository_disabled\",\n reason: `repository ${change.repositoryId} is disabled`,\n };\n }\n\n // Fetch into a remote-tracking ref (never the checked-out branch, which\n // git refuses to update), then move the local `pr` branch onto it so a\n // repeated call picks up a force-pushed head.\n const sandbox = await ctx.getSandbox();\n const currentChange = await stores.changes.get(changeId);\n if (currentChange === null) {\n return {\n fetched: false,\n code: \"change_not_found\",\n reason: `change ${changeId} does not exist`,\n };\n }\n if (currentChange.state !== \"verifying\" && currentChange.state !== \"ready\") {\n return {\n fetched: false,\n code: \"change_not_reviewable\",\n reason: `change is ${currentChange.state}, not open for review; nothing to fetch`,\n };\n }\n const currentRepository = await stores.repositories.get(currentChange.repositoryId);\n if (currentRepository === null) {\n return {\n fetched: false,\n code: \"repository_not_found\",\n reason: `repository ${currentChange.repositoryId} does not exist`,\n };\n }\n if (!currentRepository.enabled) {\n return {\n fetched: false,\n code: \"repository_disabled\",\n reason: `repository ${currentChange.repositoryId} is disabled`,\n };\n }\n task = await requireTaskExecution(stores, ctx, taskId);\n const currentAuthorizationFailure = authorizeTaskChange(task, currentChange);\n if (currentAuthorizationFailure !== null) return currentAuthorizationFailure;\n const tracking = `refs/remotes/origin/pr-${currentChange.prNumber}`;\n const baseTracking = `refs/remotes/origin/${currentRepository.defaultBranch}`;\n const git = [\"git\", \"-C\", repoPath].map(quoteShellArgument).join(\" \");\n try {\n await fetchGitHubRefs({\n sandbox,\n transport: input.git,\n repository: currentRepository.slug,\n refs: [\n { remote: `refs/heads/${currentRepository.defaultBranch}`, local: baseTracking },\n { remote: `refs/pull/${currentChange.prNumber}/head`, local: tracking },\n ],\n repositoryPath: repoPath,\n });\n await runSandboxCommand(sandbox, [\"git\", \"-C\", repoPath, \"checkout\", \"-B\", \"pr\", tracking]);\n } catch (error) {\n return {\n fetched: false,\n code: \"git_fetch_failed\",\n reason: `git fetch of pull request ${currentChange.prNumber} failed: ${error instanceof Error ? error.message : \"Git transfer failed\"}`,\n };\n }\n\n const head = await sandbox.run({ command: `${git} rev-parse HEAD` });\n const base = await sandbox.run({ command: `${git} rev-parse ${baseTracking}` });\n const mergeBase = await sandbox.run({ command: `${git} merge-base ${baseTracking} pr` });\n if (typeof mergeBase.exitCode === \"number\" && mergeBase.exitCode !== 0) {\n return {\n fetched: false,\n code: \"merge_base_failed\",\n reason: `could not determine the pull request merge base: ${(mergeBase.stderr ?? \"\").trim()}`,\n };\n }\n const mergeBaseSha = mergeBase.stdout.trim();\n return {\n fetched: true,\n prNumber: currentChange.prNumber,\n prUrl: currentChange.prUrl,\n branch: \"pr\",\n headSha: head.stdout.trim(),\n baseBranch: currentRepository.defaultBranch,\n baseSha: base.stdout.trim(),\n mergeBaseSha,\n diffCommand: `${git} diff ${mergeBaseSha}..pr`,\n };\n },\n });\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TaskId } from "../schema/id.mjs";
|
|
2
|
+
import { Repository } from "../schema/repository.mjs";
|
|
3
|
+
import { FactoryStores } from "../store/engine.mjs";
|
|
4
|
+
import { PullRequestLabelAction, PullRequestLabelResult } from "./contracts.mjs";
|
|
5
|
+
import { GitHubPullRequestPublisher, GitHubPullRequestPublisherOptions } from "./github-publisher.mjs";
|
|
6
|
+
//#region src/pull-requests/github-label-manager.d.ts
|
|
7
|
+
/** Task and Change authority required to mutate labels on an owned pull request. */
|
|
8
|
+
interface GitHubPullRequestLabelManagerOptions extends GitHubPullRequestPublisherOptions {
|
|
9
|
+
stores: Pick<FactoryStores, "tasks" | "changes">;
|
|
10
|
+
requireTaskPullRequest?: GitHubPullRequestPublisher["requireTaskPullRequest"];
|
|
11
|
+
}
|
|
12
|
+
/** Task-owned pull request and label mutation to apply. */
|
|
13
|
+
interface ManageGitHubPullRequestLabelInput {
|
|
14
|
+
repository: Repository;
|
|
15
|
+
taskId: TaskId;
|
|
16
|
+
action: PullRequestLabelAction;
|
|
17
|
+
label: string;
|
|
18
|
+
}
|
|
19
|
+
/** Task-aware label operation constrained to the workflow's owned pull request. */
|
|
20
|
+
interface GitHubPullRequestLabelManager {
|
|
21
|
+
managePullRequestLabel(input: ManageGitHubPullRequestLabelInput): Promise<PullRequestLabelResult>;
|
|
22
|
+
}
|
|
23
|
+
/** Create task-aware label operations for pull requests owned by the supplied software workflow. */
|
|
24
|
+
declare function createGitHubPullRequestLabelManager(options: GitHubPullRequestLabelManagerOptions): GitHubPullRequestLabelManager;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { GitHubPullRequestLabelManager, GitHubPullRequestLabelManagerOptions, ManageGitHubPullRequestLabelInput, createGitHubPullRequestLabelManager };
|
|
27
|
+
//# sourceMappingURL=github-label-manager.d.mts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { addLabel, removeLabel } from "../github.mjs";
|
|
2
|
+
import { createGitHubPullRequestPublisher } from "./github-publisher.mjs";
|
|
3
|
+
//#region src/pull-requests/github-label-manager.ts
|
|
4
|
+
/** Create task-aware label operations for pull requests owned by the supplied software workflow. */
|
|
5
|
+
function createGitHubPullRequestLabelManager(options) {
|
|
6
|
+
const requireTaskPullRequest = options.requireTaskPullRequest ?? createGitHubPullRequestPublisher(options).requireTaskPullRequest;
|
|
7
|
+
async function managePullRequestLabel(input) {
|
|
8
|
+
const task = await options.stores.tasks.get(input.taskId);
|
|
9
|
+
if (task === null) throw new Error(`task ${input.taskId} does not exist`);
|
|
10
|
+
if (task.repositoryIds.length !== 1 || task.repositoryIds[0] !== input.repository.id) throw new Error(`task ${input.taskId} does not identify repository ${input.repository.id}`);
|
|
11
|
+
const change = task.changeId === void 0 ? null : await options.stores.changes.get(task.changeId);
|
|
12
|
+
if (task.changeId !== void 0 && change === null) throw new Error(`change ${task.changeId} linked to task ${input.taskId} does not exist`);
|
|
13
|
+
if (change !== null && (change.repositoryId !== input.repository.id || change.state !== "verifying" && change.state !== "ready")) throw new Error(`change ${change.id} is not an open pull request in repository ${input.repository.id}`);
|
|
14
|
+
const pull = change === null ? await requireTaskPullRequest({
|
|
15
|
+
repository: input.repository,
|
|
16
|
+
taskId: input.taskId
|
|
17
|
+
}) : {
|
|
18
|
+
prNumber: change.prNumber,
|
|
19
|
+
prUrl: change.prUrl
|
|
20
|
+
};
|
|
21
|
+
const token = await options.tokenForRepository(input.repository.slug);
|
|
22
|
+
const labels = await (input.action === "add" ? addLabel : removeLabel)({
|
|
23
|
+
repository: input.repository.slug,
|
|
24
|
+
token,
|
|
25
|
+
fetch: options.fetch,
|
|
26
|
+
pullRequestNumber: pull.prNumber,
|
|
27
|
+
label: input.label
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
prNumber: pull.prNumber,
|
|
31
|
+
prUrl: pull.prUrl,
|
|
32
|
+
labels
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return Object.freeze({ managePullRequestLabel });
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createGitHubPullRequestLabelManager };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=github-label-manager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-label-manager.mjs","names":[],"sources":["../../src/pull-requests/github-label-manager.ts"],"sourcesContent":["import { addLabel, removeLabel } from \"../github\";\nimport type { TaskId } from \"../schema/id\";\nimport type { Repository } from \"../schema/repository\";\nimport type { FactoryStores } from \"../store/engine\";\nimport type { PullRequestLabelAction, PullRequestLabelResult } from \"./contracts\";\nimport {\n createGitHubPullRequestPublisher,\n type GitHubPullRequestPublisher,\n type GitHubPullRequestPublisherOptions,\n} from \"./github-publisher\";\n\n/** Task and Change authority required to mutate labels on an owned pull request. */\nexport interface GitHubPullRequestLabelManagerOptions extends GitHubPullRequestPublisherOptions {\n stores: Pick<FactoryStores, \"tasks\" | \"changes\">;\n requireTaskPullRequest?: GitHubPullRequestPublisher[\"requireTaskPullRequest\"];\n}\n\n/** Task-owned pull request and label mutation to apply. */\nexport interface ManageGitHubPullRequestLabelInput {\n repository: Repository;\n taskId: TaskId;\n action: PullRequestLabelAction;\n label: string;\n}\n\n/** Task-aware label operation constrained to the workflow's owned pull request. */\nexport interface GitHubPullRequestLabelManager {\n managePullRequestLabel(input: ManageGitHubPullRequestLabelInput): Promise<PullRequestLabelResult>;\n}\n\n/** Create task-aware label operations for pull requests owned by the supplied software workflow. */\nexport function createGitHubPullRequestLabelManager(\n options: GitHubPullRequestLabelManagerOptions,\n): GitHubPullRequestLabelManager {\n const requireTaskPullRequest =\n options.requireTaskPullRequest ??\n createGitHubPullRequestPublisher(options).requireTaskPullRequest;\n\n async function managePullRequestLabel(\n input: ManageGitHubPullRequestLabelInput,\n ): Promise<PullRequestLabelResult> {\n const task = await options.stores.tasks.get(input.taskId);\n if (task === null) throw new Error(`task ${input.taskId} does not exist`);\n if (task.repositoryIds.length !== 1 || task.repositoryIds[0] !== input.repository.id) {\n throw new Error(`task ${input.taskId} does not identify repository ${input.repository.id}`);\n }\n const change =\n task.changeId === undefined ? null : await options.stores.changes.get(task.changeId);\n if (task.changeId !== undefined && change === null) {\n throw new Error(`change ${task.changeId} linked to task ${input.taskId} does not exist`);\n }\n if (\n change !== null &&\n (change.repositoryId !== input.repository.id ||\n (change.state !== \"verifying\" && change.state !== \"ready\"))\n ) {\n throw new Error(\n `change ${change.id} is not an open pull request in repository ${input.repository.id}`,\n );\n }\n const pull =\n change === null\n ? await requireTaskPullRequest({ repository: input.repository, taskId: input.taskId })\n : { prNumber: change.prNumber, prUrl: change.prUrl };\n const token = await options.tokenForRepository(input.repository.slug);\n const labels = await (input.action === \"add\" ? addLabel : removeLabel)({\n repository: input.repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: pull.prNumber,\n label: input.label,\n });\n return { prNumber: pull.prNumber, prUrl: pull.prUrl, labels };\n }\n\n return Object.freeze({ managePullRequestLabel });\n}\n"],"mappings":";;;;AA+BA,SAAgB,oCACd,SAC+B;CAC/B,MAAM,yBACJ,QAAQ,0BACR,iCAAiC,OAAO,CAAC,CAAC;CAE5C,eAAe,uBACb,OACiC;EACjC,MAAM,OAAO,MAAM,QAAQ,OAAO,MAAM,IAAI,MAAM,MAAM;EACxD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,QAAQ,MAAM,OAAO,gBAAgB;EACxE,IAAI,KAAK,cAAc,WAAW,KAAK,KAAK,cAAc,OAAO,MAAM,WAAW,IAChF,MAAM,IAAI,MAAM,QAAQ,MAAM,OAAO,gCAAgC,MAAM,WAAW,IAAI;EAE5F,MAAM,SACJ,KAAK,aAAa,KAAA,IAAY,OAAO,MAAM,QAAQ,OAAO,QAAQ,IAAI,KAAK,QAAQ;EACrF,IAAI,KAAK,aAAa,KAAA,KAAa,WAAW,MAC5C,MAAM,IAAI,MAAM,UAAU,KAAK,SAAS,kBAAkB,MAAM,OAAO,gBAAgB;EAEzF,IACE,WAAW,SACV,OAAO,iBAAiB,MAAM,WAAW,MACvC,OAAO,UAAU,eAAe,OAAO,UAAU,UAEpD,MAAM,IAAI,MACR,UAAU,OAAO,GAAG,6CAA6C,MAAM,WAAW,IACpF;EAEF,MAAM,OACJ,WAAW,OACP,MAAM,uBAAuB;GAAE,YAAY,MAAM;GAAY,QAAQ,MAAM;EAAO,CAAC,IACnF;GAAE,UAAU,OAAO;GAAU,OAAO,OAAO;EAAM;EACvD,MAAM,QAAQ,MAAM,QAAQ,mBAAmB,MAAM,WAAW,IAAI;EACpE,MAAM,SAAS,OAAO,MAAM,WAAW,QAAQ,WAAW,YAAA,CAAa;GACrE,YAAY,MAAM,WAAW;GAC7B;GACA,OAAO,QAAQ;GACf,mBAAmB,KAAK;GACxB,OAAO,MAAM;EACf,CAAC;EACD,OAAO;GAAE,UAAU,KAAK;GAAU,OAAO,KAAK;GAAO;EAAO;CAC9D;CAEA,OAAO,OAAO,OAAO,EAAE,uBAAuB,CAAC;AACjD"}
|