@vercel/factory 0.0.13 → 0.0.15
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 +307 -1
- package/dist/agent-routes.d.mts +69 -0
- package/dist/agent-routes.mjs +64 -0
- package/dist/agent-routes.mjs.map +1 -0
- package/dist/api-contracts.d.mts +1749 -0
- package/dist/api-contracts.mjs +118 -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 +77 -0
- package/dist/api.mjs +1087 -0
- package/dist/api.mjs.map +1 -0
- 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 +692 -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 +44 -8
- package/dist/blob/index.mjs +159 -35
- package/dist/blob/index.mjs.map +1 -1
- package/dist/budget.d.mts +108 -0
- package/dist/budget.mjs +141 -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 +6 -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 +24 -0
- package/dist/change-verification/dispatch.mjs +45 -0
- package/dist/change-verification/dispatch.mjs.map +1 -0
- package/dist/change-verification/eve-tool.d.mts +60 -0
- package/dist/change-verification/eve-tool.mjs +101 -0
- package/dist/change-verification/eve-tool.mjs.map +1 -0
- package/dist/changes/eve-record-change.d.mts +56 -0
- package/dist/changes/eve-record-change.mjs +97 -0
- package/dist/changes/eve-record-change.mjs.map +1 -0
- package/dist/changes/presentation.d.mts +14 -0
- package/dist/changes.d.mts +23 -0
- package/dist/changes.mjs +29 -0
- package/dist/changes.mjs.map +1 -0
- package/dist/client-events.d.mts +18 -0
- package/dist/client-events.mjs +41 -0
- package/dist/client-events.mjs.map +1 -0
- package/dist/client-stream.d.mts +28 -0
- package/dist/client-stream.mjs +204 -0
- package/dist/client-stream.mjs.map +1 -0
- package/dist/client-transcript.d.mts +41 -0
- package/dist/client-transcript.mjs +229 -0
- package/dist/client-transcript.mjs.map +1 -0
- package/dist/client.d.mts +234 -0
- package/dist/client.mjs +258 -0
- package/dist/client.mjs.map +1 -0
- package/dist/code-review/contracts.d.mts +26 -0
- package/dist/code-review/eve-post-review.d.mts +70 -0
- package/dist/code-review/eve-post-review.mjs +183 -0
- package/dist/code-review/eve-post-review.mjs.map +1 -0
- package/dist/code-review/eve-review-comments.d.mts +64 -0
- package/dist/code-review/eve-review-comments.mjs +159 -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 +44 -0
- package/dist/code-review/github-reporter.mjs +260 -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 +6 -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 -2
- package/dist/connectors/index.mjs +4 -26
- 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 -41
- package/dist/connectors/slack.mjs +13 -69
- package/dist/connectors/slack.mjs.map +1 -1
- package/dist/deepsec/eve-tool.d.mts +110 -0
- package/dist/deepsec/eve-tool.mjs +164 -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 +81 -0
- package/dist/dispatch.mjs +140 -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 +143 -1561
- package/dist/eve/index.mjs +244 -1063
- package/dist/eve/index.mjs.map +1 -1
- package/dist/eve/invoke.d.mts +144 -0
- package/dist/eve/invoke.mjs +241 -0
- package/dist/eve/invoke.mjs.map +1 -0
- package/dist/eve/session-client.d.mts +68 -0
- package/dist/eve/session-client.mjs +131 -0
- package/dist/eve/session-client.mjs.map +1 -0
- package/dist/eve/task-execution.mjs +18 -0
- package/dist/eve/task-execution.mjs.map +1 -0
- package/dist/eve/task-session.d.mts +87 -0
- package/dist/eve/task-session.mjs +203 -0
- package/dist/eve/task-session.mjs.map +1 -0
- package/dist/eve/transcript.d.mts +37 -0
- package/dist/eve/transcript.mjs +65 -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 +75 -0
- package/dist/execution.mjs +153 -0
- package/dist/execution.mjs.map +1 -0
- package/dist/finding-remediation/admission.d.mts +51 -0
- package/dist/finding-remediation/admission.mjs +87 -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 +6 -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 +198 -0
- package/dist/github-publication.mjs +429 -0
- package/dist/github-publication.mjs.map +1 -0
- package/dist/github-transfer.d.mts +72 -0
- package/dist/github-transfer.mjs +125 -0
- package/dist/github-transfer.mjs.map +1 -0
- package/dist/github.d.mts +406 -2
- package/dist/github.mjs +250 -37
- 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/index.d.mts +14 -314
- package/dist/index.mjs +14 -1124
- package/dist/intake-contracts.d.mts +56 -0
- package/dist/intake-contracts.mjs +33 -0
- package/dist/intake-contracts.mjs.map +1 -0
- package/dist/integrations/deepsec.d.mts +4 -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 +3 -0
- package/dist/integrations/slack.mjs +3 -0
- package/dist/integrations/vercel.d.mts +3 -0
- package/dist/integrations/vercel.mjs +3 -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 +46 -0
- package/dist/merge-resolution/eve-tools.mjs +117 -0
- package/dist/merge-resolution/eve-tools.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 +273 -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 +7 -1
- package/dist/postgres/index.mjs +7 -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 +53 -0
- package/dist/presets/software-development/dispatch.mjs +66 -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 +23 -0
- package/dist/presets/software-development/task-communication.mjs +120 -0
- package/dist/presets/software-development/task-communication.mjs.map +1 -0
- package/dist/presets/software-development.d.mts +9 -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 +53 -0
- package/dist/pull-requests/github-publisher.mjs +345 -0
- package/dist/pull-requests/github-publisher.mjs.map +1 -0
- package/dist/pull-requests.d.mts +5 -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 +9 -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 +22 -0
- package/dist/schema/agent-route.mjs +15 -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-DwCihQr4.mjs → schema/common.mjs} +7 -14
- package/dist/schema/common.mjs.map +1 -0
- package/dist/schema/communication.d.mts +52 -0
- package/dist/schema/communication.mjs +35 -0
- 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 +95 -0
- package/dist/schema/factory-config.mjs +60 -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 +26 -0
- package/dist/schema/repository.mjs +25 -0
- package/dist/schema/repository.mjs.map +1 -0
- package/dist/schema/session.d.mts +135 -0
- package/dist/schema/session.mjs +53 -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/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 +3134 -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 +272 -0
- package/dist/schema/task.mjs +199 -0
- package/dist/schema/task.mjs.map +1 -0
- package/dist/schema/transcript.d.mts +170 -0
- package/dist/schema/transcript.mjs +86 -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 +101 -0
- package/dist/schema/work.mjs +102 -0
- package/dist/schema/work.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 +19 -0
- package/dist/signals.mjs +19 -0
- package/dist/signals.mjs.map +1 -0
- package/dist/stall.d.mts +38 -0
- package/dist/stall.mjs +79 -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 +485 -0
- package/dist/store/engine.mjs +2175 -0
- package/dist/store/engine.mjs.map +1 -0
- package/dist/store/memory.d.mts +7 -0
- package/dist/store/memory.mjs +52 -0
- package/dist/store/memory.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 +65 -0
- package/dist/store/task-work.mjs +134 -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 +57 -0
- package/dist/sweep.mjs +143 -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 +264 -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 +21 -0
- package/dist/vercel-git.mjs +112 -0
- package/dist/vercel-git.mjs.map +1 -0
- package/dist/vercel.d.mts +33 -2
- package/dist/vercel.mjs +48 -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 +3 -0
- package/dist/work-triage.mjs +3 -0
- package/dist/workflows.d.mts +48 -0
- package/dist/workflows.mjs +86 -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-snapshot.d.mts +26 -0
- package/dist/workspace-snapshot.mjs +80 -0
- package/dist/workspace-snapshot.mjs.map +1 -0
- package/package.json +129 -40
- package/dist/approval-CwhTP1XB.mjs +0 -269
- package/dist/approval-CwhTP1XB.mjs.map +0 -1
- package/dist/change-CzEAoFVE.mjs +0 -620
- package/dist/change-CzEAoFVE.mjs.map +0 -1
- package/dist/dispatch-B77cuPxh.d.mts +0 -713
- package/dist/driver-BJutB0PE.d.mts +0 -34
- package/dist/driver-Bbd25rNM.mjs +0 -23
- package/dist/driver-Bbd25rNM.mjs.map +0 -1
- package/dist/factory-config-BJcjsPKl.mjs +0 -86
- package/dist/factory-config-BJcjsPKl.mjs.map +0 -1
- package/dist/factory-config-D2yU3G0c.d.mts +0 -58
- package/dist/github-DXsxboUL.d.mts +0 -271
- package/dist/id-DwCihQr4.mjs.map +0 -1
- package/dist/index-Cy4jfXh5.d.mts +0 -67
- package/dist/index.mjs.map +0 -1
- package/dist/signal-CHVEmzvI.d.mts +0 -59
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { JsonValue } from "./schema/work.mjs";
|
|
2
|
+
import { Task, TaskKind } from "./schema/task.mjs";
|
|
3
|
+
import "./workflows.mjs";
|
|
4
|
+
import "./tasks.mjs";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/task-graph-view.d.ts
|
|
7
|
+
declare const taskGraphViewSchema: z.ZodObject<{
|
|
8
|
+
rootTaskId: z.ZodNullable<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
|
|
9
|
+
currentTaskId: z.ZodOptional<z.ZodNullable<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>>;
|
|
10
|
+
nodes: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
11
|
+
task: Omit<z.ZodObject<{
|
|
12
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
13
|
+
id: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
|
|
14
|
+
repositoryIds: z.ZodReadonly<z.ZodTuple<[z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>], z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>>>;
|
|
15
|
+
kind: z.ZodType<TaskKind, unknown, z.core.$ZodTypeInternals<TaskKind, unknown>>;
|
|
16
|
+
area: z.ZodOptional<z.ZodString>;
|
|
17
|
+
state: z.ZodEnum<{
|
|
18
|
+
queued: "queued";
|
|
19
|
+
running: "running";
|
|
20
|
+
stalled: "stalled";
|
|
21
|
+
verifying: "verifying";
|
|
22
|
+
succeeded: "succeeded";
|
|
23
|
+
failed: "failed";
|
|
24
|
+
needs_human: "needs_human";
|
|
25
|
+
cancelled: "cancelled";
|
|
26
|
+
}>;
|
|
27
|
+
approval: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
required: "required";
|
|
29
|
+
granted: "granted";
|
|
30
|
+
denied: "denied";
|
|
31
|
+
}>>;
|
|
32
|
+
origin: z.ZodObject<{
|
|
33
|
+
signalId: z.ZodOptional<z.ZodType<`sig_${string}`, string, z.core.$ZodTypeInternals<`sig_${string}`, string>>>;
|
|
34
|
+
operator: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
work: z.ZodObject<{
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
input: z.ZodCustom<JsonValue, JsonValue>;
|
|
39
|
+
completionCriteria: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
40
|
+
workflow: z.core.$ZodBranded<z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
version: z.ZodNumber;
|
|
43
|
+
}, z.core.$strict>, "WorkflowBinding", "out">;
|
|
44
|
+
route: z.ZodOptional<z.core.$ZodBranded<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
version: z.ZodNumber;
|
|
47
|
+
}, z.core.$strict>, "AgentRouteBinding", "out">>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
workResult: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
output: z.ZodCustom<JsonValue, JsonValue>;
|
|
51
|
+
completedAt: z.ZodISODateTime;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
waitingForMessages: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
workflowPhase: z.ZodOptional<z.ZodString>;
|
|
55
|
+
rootTaskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
|
|
56
|
+
parentTaskId: z.ZodOptional<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
|
|
57
|
+
parentTaskAttempt: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
replyTo: z.ZodObject<{
|
|
59
|
+
channel: z.ZodString;
|
|
60
|
+
address: z.ZodString;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
pendingCommunicationReceiptIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodType<`rcpt_${string}`, string, z.core.$ZodTypeInternals<`rcpt_${string}`, string>>>>>;
|
|
63
|
+
failureReceiptId: z.ZodOptional<z.ZodType<`rcpt_${string}`, string, z.core.$ZodTypeInternals<`rcpt_${string}`, string>>>;
|
|
64
|
+
attempt: z.ZodNumber;
|
|
65
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
provider: z.ZodString;
|
|
67
|
+
sessionId: z.ZodString;
|
|
68
|
+
environmentId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
harness: z.ZodOptional<z.ZodString>;
|
|
70
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strict>>;
|
|
72
|
+
lastProgressAt: z.ZodOptional<z.ZodISODateTime>;
|
|
73
|
+
stalledAt: z.ZodOptional<z.ZodISODateTime>;
|
|
74
|
+
stalledReason: z.ZodOptional<z.ZodString>;
|
|
75
|
+
needsHumanAction: z.ZodOptional<z.ZodString>;
|
|
76
|
+
needsHumanNotifiedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
77
|
+
reservedUsd: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
reservedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
79
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
costUsd: z.ZodNumber;
|
|
81
|
+
inputTokens: z.ZodNumber;
|
|
82
|
+
outputTokens: z.ZodNumber;
|
|
83
|
+
cacheReadTokens: z.ZodNumber;
|
|
84
|
+
cacheWriteTokens: z.ZodNumber;
|
|
85
|
+
steps: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
86
|
+
}, z.core.$strict>>;
|
|
87
|
+
settledUsd: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
question: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
text: z.ZodString;
|
|
90
|
+
options: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
91
|
+
closingOptions: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
92
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
93
|
+
answeredBy: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, z.core.$strict>>;
|
|
95
|
+
questionTaskId: z.ZodOptional<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
|
|
96
|
+
answerEventIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodType<`ans_${string}`, string, z.core.$ZodTypeInternals<`ans_${string}`, string>>>>>;
|
|
97
|
+
changeId: z.ZodOptional<z.ZodType<`chg_${string}`, string, z.core.$ZodTypeInternals<`chg_${string}`, string>>>;
|
|
98
|
+
reportRef: z.ZodOptional<z.ZodString>;
|
|
99
|
+
createdAt: z.ZodISODateTime;
|
|
100
|
+
updatedAt: z.ZodISODateTime;
|
|
101
|
+
}, z.core.$strict>, keyof z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>> & z.ZodType<Task, {
|
|
102
|
+
schemaVersion: 1;
|
|
103
|
+
id: string;
|
|
104
|
+
repositoryIds: readonly [string, ...string[]];
|
|
105
|
+
kind: unknown;
|
|
106
|
+
state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
|
|
107
|
+
origin: {
|
|
108
|
+
signalId?: string | undefined;
|
|
109
|
+
operator?: string | undefined;
|
|
110
|
+
};
|
|
111
|
+
work: {
|
|
112
|
+
title: string;
|
|
113
|
+
input: JsonValue;
|
|
114
|
+
completionCriteria: readonly string[];
|
|
115
|
+
workflow: {
|
|
116
|
+
id: string;
|
|
117
|
+
version: number;
|
|
118
|
+
};
|
|
119
|
+
route?: {
|
|
120
|
+
id: string;
|
|
121
|
+
version: number;
|
|
122
|
+
} | undefined;
|
|
123
|
+
};
|
|
124
|
+
rootTaskId: string;
|
|
125
|
+
replyTo: {
|
|
126
|
+
channel: string;
|
|
127
|
+
address: string;
|
|
128
|
+
};
|
|
129
|
+
attempt: number;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
updatedAt: string;
|
|
132
|
+
area?: string | undefined;
|
|
133
|
+
approval?: "required" | "granted" | "denied" | undefined;
|
|
134
|
+
workResult?: {
|
|
135
|
+
output: JsonValue;
|
|
136
|
+
completedAt: string;
|
|
137
|
+
} | undefined;
|
|
138
|
+
waitingForMessages?: boolean | undefined;
|
|
139
|
+
workflowPhase?: string | undefined;
|
|
140
|
+
parentTaskId?: string | undefined;
|
|
141
|
+
parentTaskAttempt?: number | undefined;
|
|
142
|
+
pendingCommunicationReceiptIds?: readonly string[] | undefined;
|
|
143
|
+
failureReceiptId?: string | undefined;
|
|
144
|
+
execution?: {
|
|
145
|
+
provider: string;
|
|
146
|
+
sessionId: string;
|
|
147
|
+
environmentId?: string | undefined;
|
|
148
|
+
harness?: string | undefined;
|
|
149
|
+
traceId?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
lastProgressAt?: string | undefined;
|
|
152
|
+
stalledAt?: string | undefined;
|
|
153
|
+
stalledReason?: string | undefined;
|
|
154
|
+
needsHumanAction?: string | undefined;
|
|
155
|
+
needsHumanNotifiedAt?: string | undefined;
|
|
156
|
+
reservedUsd?: number | undefined;
|
|
157
|
+
reservedAt?: string | undefined;
|
|
158
|
+
usage?: {
|
|
159
|
+
costUsd: number;
|
|
160
|
+
inputTokens: number;
|
|
161
|
+
outputTokens: number;
|
|
162
|
+
cacheReadTokens: number;
|
|
163
|
+
cacheWriteTokens: number;
|
|
164
|
+
steps: Record<string, number>;
|
|
165
|
+
} | undefined;
|
|
166
|
+
settledUsd?: number | undefined;
|
|
167
|
+
question?: {
|
|
168
|
+
text: string;
|
|
169
|
+
options: readonly string[];
|
|
170
|
+
closingOptions?: readonly string[] | undefined;
|
|
171
|
+
answer?: string | undefined;
|
|
172
|
+
answeredBy?: string | undefined;
|
|
173
|
+
} | undefined;
|
|
174
|
+
questionTaskId?: string | undefined;
|
|
175
|
+
answerEventIds?: readonly string[] | undefined;
|
|
176
|
+
changeId?: string | undefined;
|
|
177
|
+
reportRef?: string | undefined;
|
|
178
|
+
}, z.core.$ZodTypeInternals<Task, {
|
|
179
|
+
schemaVersion: 1;
|
|
180
|
+
id: string;
|
|
181
|
+
repositoryIds: readonly [string, ...string[]];
|
|
182
|
+
kind: unknown;
|
|
183
|
+
state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
|
|
184
|
+
origin: {
|
|
185
|
+
signalId?: string | undefined;
|
|
186
|
+
operator?: string | undefined;
|
|
187
|
+
};
|
|
188
|
+
work: {
|
|
189
|
+
title: string;
|
|
190
|
+
input: JsonValue;
|
|
191
|
+
completionCriteria: readonly string[];
|
|
192
|
+
workflow: {
|
|
193
|
+
id: string;
|
|
194
|
+
version: number;
|
|
195
|
+
};
|
|
196
|
+
route?: {
|
|
197
|
+
id: string;
|
|
198
|
+
version: number;
|
|
199
|
+
} | undefined;
|
|
200
|
+
};
|
|
201
|
+
rootTaskId: string;
|
|
202
|
+
replyTo: {
|
|
203
|
+
channel: string;
|
|
204
|
+
address: string;
|
|
205
|
+
};
|
|
206
|
+
attempt: number;
|
|
207
|
+
createdAt: string;
|
|
208
|
+
updatedAt: string;
|
|
209
|
+
area?: string | undefined;
|
|
210
|
+
approval?: "required" | "granted" | "denied" | undefined;
|
|
211
|
+
workResult?: {
|
|
212
|
+
output: JsonValue;
|
|
213
|
+
completedAt: string;
|
|
214
|
+
} | undefined;
|
|
215
|
+
waitingForMessages?: boolean | undefined;
|
|
216
|
+
workflowPhase?: string | undefined;
|
|
217
|
+
parentTaskId?: string | undefined;
|
|
218
|
+
parentTaskAttempt?: number | undefined;
|
|
219
|
+
pendingCommunicationReceiptIds?: readonly string[] | undefined;
|
|
220
|
+
failureReceiptId?: string | undefined;
|
|
221
|
+
execution?: {
|
|
222
|
+
provider: string;
|
|
223
|
+
sessionId: string;
|
|
224
|
+
environmentId?: string | undefined;
|
|
225
|
+
harness?: string | undefined;
|
|
226
|
+
traceId?: string | undefined;
|
|
227
|
+
} | undefined;
|
|
228
|
+
lastProgressAt?: string | undefined;
|
|
229
|
+
stalledAt?: string | undefined;
|
|
230
|
+
stalledReason?: string | undefined;
|
|
231
|
+
needsHumanAction?: string | undefined;
|
|
232
|
+
needsHumanNotifiedAt?: string | undefined;
|
|
233
|
+
reservedUsd?: number | undefined;
|
|
234
|
+
reservedAt?: string | undefined;
|
|
235
|
+
usage?: {
|
|
236
|
+
costUsd: number;
|
|
237
|
+
inputTokens: number;
|
|
238
|
+
outputTokens: number;
|
|
239
|
+
cacheReadTokens: number;
|
|
240
|
+
cacheWriteTokens: number;
|
|
241
|
+
steps: Record<string, number>;
|
|
242
|
+
} | undefined;
|
|
243
|
+
settledUsd?: number | undefined;
|
|
244
|
+
question?: {
|
|
245
|
+
text: string;
|
|
246
|
+
options: readonly string[];
|
|
247
|
+
closingOptions?: readonly string[] | undefined;
|
|
248
|
+
answer?: string | undefined;
|
|
249
|
+
answeredBy?: string | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
questionTaskId?: string | undefined;
|
|
252
|
+
answerEventIds?: readonly string[] | undefined;
|
|
253
|
+
changeId?: string | undefined;
|
|
254
|
+
reportRef?: string | undefined;
|
|
255
|
+
}>>;
|
|
256
|
+
dependencyTaskIds: z.ZodReadonly<z.ZodArray<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>>;
|
|
257
|
+
agent: z.ZodNullable<z.ZodString>;
|
|
258
|
+
}, z.core.$strict>>>;
|
|
259
|
+
}, z.core.$strict>;
|
|
260
|
+
/** An authorized, read-only operator projection of one canonical Task graph. */
|
|
261
|
+
type TaskGraphView = z.infer<typeof taskGraphViewSchema>;
|
|
262
|
+
//#endregion
|
|
263
|
+
export { TaskGraphView, taskGraphViewSchema };
|
|
264
|
+
//# sourceMappingURL=task-graph-view.d.mts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { taskIdSchema } from "./schema/id.mjs";
|
|
2
|
+
import { taskSchema } from "./schema/task.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/task-graph-view.ts
|
|
5
|
+
const taskGraphViewSchema = z.strictObject({
|
|
6
|
+
rootTaskId: taskIdSchema.nullable().describe("Canonical root, or null for a taskless conversation."),
|
|
7
|
+
currentTaskId: taskIdSchema.nullable().optional().describe("Task currently shown by the entrypoint conversation, or null when it is not in this graph."),
|
|
8
|
+
nodes: z.array(z.strictObject({
|
|
9
|
+
task: taskSchema.describe("Current persisted Task snapshot."),
|
|
10
|
+
dependencyTaskIds: z.array(taskIdSchema).max(255).readonly().describe("Canonical prerequisites, distinct from parent ownership."),
|
|
11
|
+
agent: z.string().nullable().describe("Exact exposed route agent, or null for workflow-owned or unavailable execution.")
|
|
12
|
+
})).max(256).readonly().describe("Authorized canonical graph membership, independent of session pagination.")
|
|
13
|
+
}).describe("Read-only operator view of one root Task graph.");
|
|
14
|
+
//#endregion
|
|
15
|
+
export { taskGraphViewSchema };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=task-graph-view.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-graph-view.mjs","names":[],"sources":["../src/task-graph-view.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { taskIdSchema } from \"./schema/id\";\nimport { taskSchema } from \"./schema/task\";\n\nexport const taskGraphViewSchema = z\n .strictObject({\n rootTaskId: taskIdSchema\n .nullable()\n .describe(\"Canonical root, or null for a taskless conversation.\"),\n currentTaskId: taskIdSchema\n .nullable()\n .optional()\n .describe(\n \"Task currently shown by the entrypoint conversation, or null when it is not in this graph.\",\n ),\n nodes: z\n .array(\n z.strictObject({\n task: taskSchema.describe(\"Current persisted Task snapshot.\"),\n dependencyTaskIds: z\n .array(taskIdSchema)\n .max(255)\n .readonly()\n .describe(\"Canonical prerequisites, distinct from parent ownership.\"),\n agent: z\n .string()\n .nullable()\n .describe(\n \"Exact exposed route agent, or null for workflow-owned or unavailable execution.\",\n ),\n }),\n )\n .max(256)\n .readonly()\n .describe(\"Authorized canonical graph membership, independent of session pagination.\"),\n })\n .describe(\"Read-only operator view of one root Task graph.\");\n/** An authorized, read-only operator projection of one canonical Task graph. */\nexport type TaskGraphView = z.infer<typeof taskGraphViewSchema>;\n"],"mappings":";;;;AAIA,MAAa,sBAAsB,EAChC,aAAa;CACZ,YAAY,aACT,SAAS,CAAC,CACV,SAAS,sDAAsD;CAClE,eAAe,aACZ,SAAS,CAAC,CACV,SAAS,CAAC,CACV,SACC,4FACF;CACF,OAAO,EACJ,MACC,EAAE,aAAa;EACb,MAAM,WAAW,SAAS,kCAAkC;EAC5D,mBAAmB,EAChB,MAAM,YAAY,CAAC,CACnB,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,0DAA0D;EACtE,OAAO,EACJ,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,iFACF;CACJ,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,2EAA2E;AACzF,CAAC,CAAC,CACD,SAAS,iDAAiD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { WorkflowBinding } from "./schema/work.mjs";
|
|
2
|
+
import { Task } from "./schema/task.mjs";
|
|
3
|
+
import { TaskMessageForProtocol, TaskMessageId, TaskMessagePrincipal, TaskMessageProtocol } from "./schema/task-message.mjs";
|
|
4
|
+
import { IsoDateTimeClock } from "./schema/common.mjs";
|
|
5
|
+
import { TaskAttemptRef } from "./schema/execution.mjs";
|
|
6
|
+
import { FactoryStores } from "./store/engine.mjs";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
//#region src/task-message-processing.d.ts
|
|
9
|
+
/** Minimal persistence capabilities required to decide and apply one Task message. */
|
|
10
|
+
type TaskMessageProcessingStores = Pick<FactoryStores, "messages" | "tasks" | "workflowRecords">;
|
|
11
|
+
/** Trusted dependencies and pure/effectful callbacks for processing one Task inbox head. */
|
|
12
|
+
interface ProcessTaskMessageOptions<Schema extends z.ZodType, Protocol extends TaskMessageProtocol = TaskMessageProtocol> {
|
|
13
|
+
readonly stores: TaskMessageProcessingStores;
|
|
14
|
+
/** Authenticated externally; the message store enforces its configured claim policy. */
|
|
15
|
+
readonly principal: TaskMessagePrincipal;
|
|
16
|
+
/** Exact recipient Task attempt authorized to process the inbox head. */
|
|
17
|
+
readonly task: TaskAttemptRef;
|
|
18
|
+
/** Refuse a different inbox head before deciding or replaying effects. */
|
|
19
|
+
readonly expectMessageId?: TaskMessageId;
|
|
20
|
+
readonly leaseMs: number;
|
|
21
|
+
readonly workflow: WorkflowBinding;
|
|
22
|
+
/** Exact protocol required for the claimed message and exposed to typed callbacks. */
|
|
23
|
+
readonly protocol: Protocol;
|
|
24
|
+
/** Trusted UTC clock for decision timestamps; defaults to the system clock. */
|
|
25
|
+
readonly now?: IsoDateTimeClock;
|
|
26
|
+
/** Must accept its canonical JSON output unchanged. Exclude secrets from the decision contract. */
|
|
27
|
+
readonly decisionSchema: Schema;
|
|
28
|
+
/** Pure computation: may run concurrently or repeat until a decision is durably inserted. */
|
|
29
|
+
decide(context: Readonly<{
|
|
30
|
+
task: Task;
|
|
31
|
+
message: TaskMessageForProtocol<Protocol>;
|
|
32
|
+
}>): Promise<z.input<Schema>>;
|
|
33
|
+
/**
|
|
34
|
+
* Honor effectKey for every external write (derive stable subkeys for multiple effects).
|
|
35
|
+
* Lease checks cannot fence external systems: apply may repeat, overlap, or outlive its claim.
|
|
36
|
+
* Resolve only after all effects commit; never mutate the decision to select different effects.
|
|
37
|
+
*/
|
|
38
|
+
apply(context: Readonly<{
|
|
39
|
+
task: Task;
|
|
40
|
+
message: TaskMessageForProtocol<Protocol>;
|
|
41
|
+
decision: z.output<Schema>;
|
|
42
|
+
effectKey: string;
|
|
43
|
+
}>): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/** Result of finding no claimable work or durably processing one Task message. */
|
|
46
|
+
type ProcessTaskMessageResult<Decision> = {
|
|
47
|
+
status: "idle";
|
|
48
|
+
} | {
|
|
49
|
+
status: "processed";
|
|
50
|
+
messageId: TaskMessageId;
|
|
51
|
+
decision: Decision;
|
|
52
|
+
effectKey: string;
|
|
53
|
+
};
|
|
54
|
+
/** Authorized typed inspection; null means no committed decision, not permission to decide for a terminal Task. */
|
|
55
|
+
declare function readTaskMessageDecision<Schema extends z.ZodType>(options: Pick<ProcessTaskMessageOptions<Schema>, "stores" | "principal" | "task" | "workflow" | "decisionSchema">, messageId: TaskMessageId): Promise<z.output<Schema> | null>;
|
|
56
|
+
/** Process one authorized inbox head. Idle means empty or already leased, not necessarily drained. */
|
|
57
|
+
declare function processTaskMessage<Schema extends z.ZodType, Protocol extends TaskMessageProtocol = TaskMessageProtocol>(options: ProcessTaskMessageOptions<Schema, Protocol>): Promise<ProcessTaskMessageResult<z.output<Schema>>>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ProcessTaskMessageOptions, ProcessTaskMessageResult, TaskMessageProcessingStores, processTaskMessage, readTaskMessageDecision };
|
|
60
|
+
//# sourceMappingURL=task-message-processing.d.mts.map
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { taskIdSchema } from "./schema/id.mjs";
|
|
2
|
+
import { isoDateTimeSchema, schemaVersionSchema } from "./schema/common.mjs";
|
|
3
|
+
import { jsonValueSchema, workflowBindingSchema } from "./schema/work.mjs";
|
|
4
|
+
import { taskAttemptRefSchema } from "./schema/execution.mjs";
|
|
5
|
+
import { RecordExistsError } from "./store/driver.mjs";
|
|
6
|
+
import { defineTaskMessageProtocol, taskMessageIdSchema, taskMessagePrincipalSchema } from "./schema/task-message.mjs";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { isDeepStrictEqual } from "node:util";
|
|
10
|
+
//#region src/task-message-processing.ts
|
|
11
|
+
const decisionRecordSchema = z.strictObject({
|
|
12
|
+
schemaVersion: schemaVersionSchema,
|
|
13
|
+
id: z.string().regex(/^decision_[a-f0-9]{64}$/).describe("Immutable workflow and message decision identity."),
|
|
14
|
+
toTaskId: taskIdSchema.describe("Authorized recipient Task of the decided message."),
|
|
15
|
+
messageId: taskMessageIdSchema,
|
|
16
|
+
workflow: workflowBindingSchema.describe("Exact workflow contract that produced this decision."),
|
|
17
|
+
decision: jsonValueSchema.describe("Schema-validated bounded decision; never credentials or execution context."),
|
|
18
|
+
createdAt: isoDateTimeSchema.describe("Timestamp of the first committed decision.")
|
|
19
|
+
});
|
|
20
|
+
function snapshotProtocol(protocol) {
|
|
21
|
+
const snapshot = defineTaskMessageProtocol(protocol);
|
|
22
|
+
if (!isDeepStrictEqual(snapshot.binding, protocol.binding)) throw new Error("Task-message protocol binding must match its definition");
|
|
23
|
+
return snapshot;
|
|
24
|
+
}
|
|
25
|
+
function validateProtocolMessage(protocol, message) {
|
|
26
|
+
if (message.type.id !== protocol.id || message.type.version !== protocol.version) throw new Error(`Task message ${message.id} requires exact protocol ${protocol.id}@${protocol.version}`);
|
|
27
|
+
const json = structuredClone(jsonValueSchema.parse(message.payload));
|
|
28
|
+
const payload = jsonValueSchema.parse((protocol.storedPayload ?? protocol.payload).parse(structuredClone(json)));
|
|
29
|
+
if (!isDeepStrictEqual(json, payload)) throw new Error("Stored message protocol validation must preserve canonical JSON; provide storedPayload for transforming protocols");
|
|
30
|
+
return structuredClone({
|
|
31
|
+
...message,
|
|
32
|
+
type: protocol.binding,
|
|
33
|
+
payload
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function validateStoredDecision(schema, value) {
|
|
37
|
+
const json = structuredClone(jsonValueSchema.parse(value));
|
|
38
|
+
const parsed = schema.parse(structuredClone(json));
|
|
39
|
+
const validated = jsonValueSchema.parse(parsed);
|
|
40
|
+
if (!isDeepStrictEqual(json, validated)) throw new Error("Decision schema must preserve canonical JSON; non-idempotent transforms are not permitted");
|
|
41
|
+
return structuredClone(parsed);
|
|
42
|
+
}
|
|
43
|
+
function decisionIdentity(workflow, messageId) {
|
|
44
|
+
return `decision_${createHash("sha256").update(JSON.stringify([
|
|
45
|
+
workflow.id,
|
|
46
|
+
workflow.version,
|
|
47
|
+
messageId
|
|
48
|
+
])).digest("hex")}`;
|
|
49
|
+
}
|
|
50
|
+
/** Authorized typed inspection; null means no committed decision, not permission to decide for a terminal Task. */
|
|
51
|
+
async function readTaskMessageDecision(options, messageId) {
|
|
52
|
+
const workflow = workflowBindingSchema.parse(options.workflow);
|
|
53
|
+
const task = await options.stores.tasks.get(options.task.taskId);
|
|
54
|
+
if (!task || !isDeepStrictEqual(task.work.workflow, workflow)) throw new Error("Exact recipient workflow required");
|
|
55
|
+
if (!await options.stores.messages.get({
|
|
56
|
+
principal: options.principal,
|
|
57
|
+
toTaskId: task.id,
|
|
58
|
+
messageId
|
|
59
|
+
})) return null;
|
|
60
|
+
const id = decisionIdentity(workflow, messageId);
|
|
61
|
+
const stored = await options.stores.workflowRecords.get("taskMessageDecisions", id);
|
|
62
|
+
if (!stored) return null;
|
|
63
|
+
const record = decisionRecordSchema.parse(stored.value);
|
|
64
|
+
if (record.id !== id || record.toTaskId !== task.id || record.messageId !== messageId || !isDeepStrictEqual(record.workflow, workflow)) throw new Error("Stored Task message decision identity mismatch");
|
|
65
|
+
return validateStoredDecision(options.decisionSchema, record.decision);
|
|
66
|
+
}
|
|
67
|
+
/** Process one authorized inbox head. Idle means empty or already leased, not necessarily drained. */
|
|
68
|
+
async function processTaskMessage(options) {
|
|
69
|
+
const { stores, decisionSchema, decide, apply } = options;
|
|
70
|
+
const protocol = snapshotProtocol(options.protocol);
|
|
71
|
+
const driver = stores.workflowRecords;
|
|
72
|
+
const workflow = workflowBindingSchema.parse(options.workflow);
|
|
73
|
+
const principal = taskMessagePrincipalSchema.parse(options.principal);
|
|
74
|
+
const { taskId, attempt } = taskAttemptRefSchema.parse(options.task);
|
|
75
|
+
const loadTask = async () => {
|
|
76
|
+
const task = await stores.tasks.get(taskId);
|
|
77
|
+
if (!task || task.id !== taskId || !isDeepStrictEqual(task.work.workflow, workflow)) throw new Error(`Task ${taskId} requires exact workflow ${workflow.id}@${workflow.version}`);
|
|
78
|
+
if (task.state === "cancelled") throw new Error(`Cancelled Task ${taskId} cannot replay message effects`);
|
|
79
|
+
return task;
|
|
80
|
+
};
|
|
81
|
+
const completed = (task) => task.state === "succeeded" || task.state === "failed";
|
|
82
|
+
const decisionId = (messageId) => decisionIdentity(workflow, messageId);
|
|
83
|
+
const readDecision = (value, messageId) => {
|
|
84
|
+
const record = decisionRecordSchema.parse(value);
|
|
85
|
+
if (record.id !== decisionId(messageId) || record.toTaskId !== taskId || record.messageId !== messageId || !isDeepStrictEqual(record.workflow, workflow)) throw new Error("Stored Task message decision identity does not match its recipient, message, and workflow");
|
|
86
|
+
return validateStoredDecision(decisionSchema, record.decision);
|
|
87
|
+
};
|
|
88
|
+
let task = await loadTask();
|
|
89
|
+
if (options.expectMessageId !== void 0) {
|
|
90
|
+
const head = (await stores.messages.pending({
|
|
91
|
+
principal,
|
|
92
|
+
toTaskId: taskId
|
|
93
|
+
}))[0];
|
|
94
|
+
if (head?.id !== options.expectMessageId) throw new Error("Inbox head differs from expected message");
|
|
95
|
+
if (head) validateProtocolMessage(protocol, head);
|
|
96
|
+
}
|
|
97
|
+
let recoveryMessageId;
|
|
98
|
+
if (completed(task)) {
|
|
99
|
+
const head = (await stores.messages.pending({
|
|
100
|
+
principal,
|
|
101
|
+
toTaskId: taskId
|
|
102
|
+
}))[0];
|
|
103
|
+
if (!head) return { status: "idle" };
|
|
104
|
+
validateProtocolMessage(protocol, head);
|
|
105
|
+
const stored = await driver.get("taskMessageDecisions", decisionId(head.id));
|
|
106
|
+
if (!stored) throw new Error(`Completed Task ${taskId} requires an existing decision for message recovery`);
|
|
107
|
+
readDecision(stored.value, head.id);
|
|
108
|
+
recoveryMessageId = head.id;
|
|
109
|
+
}
|
|
110
|
+
const claimed = await stores.messages.claim({
|
|
111
|
+
principal,
|
|
112
|
+
task: {
|
|
113
|
+
taskId,
|
|
114
|
+
attempt
|
|
115
|
+
},
|
|
116
|
+
leaseMs: options.leaseMs,
|
|
117
|
+
...recoveryMessageId === void 0 ? {} : { recoverCompleted: true }
|
|
118
|
+
});
|
|
119
|
+
if (!claimed) return { status: "idle" };
|
|
120
|
+
const { claim, message: claimedMessage } = claimed;
|
|
121
|
+
const message = validateProtocolMessage(protocol, claimedMessage);
|
|
122
|
+
if (options.expectMessageId !== void 0 && message.id !== options.expectMessageId) throw new Error("Claimed message differs from expected message");
|
|
123
|
+
if (recoveryMessageId !== void 0 && message.id !== recoveryMessageId) throw new Error("Claimed message differs from the validated terminal recovery head");
|
|
124
|
+
task = await loadTask();
|
|
125
|
+
const id = decisionId(message.id);
|
|
126
|
+
const effectKey = stores.messages.effectKey({
|
|
127
|
+
messageId: message.id,
|
|
128
|
+
operation: `workflow:${workflow.id}@${workflow.version}`
|
|
129
|
+
});
|
|
130
|
+
await stores.messages.assertClaim({
|
|
131
|
+
principal,
|
|
132
|
+
claim
|
|
133
|
+
});
|
|
134
|
+
const existing = await driver.get("taskMessageDecisions", id);
|
|
135
|
+
let decision;
|
|
136
|
+
if (existing) decision = readDecision(existing.value, message.id);
|
|
137
|
+
else {
|
|
138
|
+
if (recoveryMessageId !== void 0 || completed(task)) throw new Error(`Completed Task ${taskId} requires an existing decision for message recovery`);
|
|
139
|
+
const raw = jsonValueSchema.parse(await decide({
|
|
140
|
+
task: structuredClone(task),
|
|
141
|
+
message: structuredClone(message)
|
|
142
|
+
}));
|
|
143
|
+
decision = validateStoredDecision(decisionSchema, jsonValueSchema.parse(decisionSchema.parse(structuredClone(raw))));
|
|
144
|
+
const record = decisionRecordSchema.parse({
|
|
145
|
+
schemaVersion: 1,
|
|
146
|
+
id,
|
|
147
|
+
toTaskId: taskId,
|
|
148
|
+
messageId: message.id,
|
|
149
|
+
workflow,
|
|
150
|
+
decision,
|
|
151
|
+
createdAt: (options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString()))()
|
|
152
|
+
});
|
|
153
|
+
await stores.messages.assertClaim({
|
|
154
|
+
principal,
|
|
155
|
+
claim
|
|
156
|
+
});
|
|
157
|
+
try {
|
|
158
|
+
await driver.insert({
|
|
159
|
+
collection: "taskMessageDecisions",
|
|
160
|
+
id,
|
|
161
|
+
value: record
|
|
162
|
+
});
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (!(error instanceof RecordExistsError)) throw error;
|
|
165
|
+
const winner = await driver.get("taskMessageDecisions", id);
|
|
166
|
+
if (!winner) throw new Error("Winning Task message decision is missing", { cause: error });
|
|
167
|
+
decision = readDecision(winner.value, message.id);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
task = await loadTask();
|
|
171
|
+
await stores.messages.assertClaim({
|
|
172
|
+
principal,
|
|
173
|
+
claim
|
|
174
|
+
});
|
|
175
|
+
await apply({
|
|
176
|
+
task: structuredClone(task),
|
|
177
|
+
message: structuredClone(message),
|
|
178
|
+
decision: structuredClone(decision),
|
|
179
|
+
effectKey
|
|
180
|
+
});
|
|
181
|
+
await stores.messages.assertClaim({
|
|
182
|
+
principal,
|
|
183
|
+
claim
|
|
184
|
+
});
|
|
185
|
+
await stores.messages.complete({
|
|
186
|
+
principal,
|
|
187
|
+
claim,
|
|
188
|
+
effectsCommitted: true
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
status: "processed",
|
|
192
|
+
messageId: message.id,
|
|
193
|
+
decision,
|
|
194
|
+
effectKey
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { processTaskMessage, readTaskMessageDecision };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=task-message-processing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-message-processing.mjs","names":[],"sources":["../src/task-message-processing.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { z } from \"zod\";\nimport {\n isoDateTimeSchema,\n schemaVersionSchema,\n SCHEMA_VERSION,\n type IsoDateTimeClock,\n} from \"./schema/common\";\nimport { taskAttemptRefSchema, type TaskAttemptRef } from \"./schema/execution\";\nimport { taskIdSchema } from \"./schema/id\";\nimport type { Task } from \"./schema/task\";\nimport {\n defineTaskMessageProtocol,\n taskMessageIdSchema,\n taskMessagePrincipalSchema,\n type TaskMessage,\n type TaskMessageForProtocol,\n type TaskMessageId,\n type TaskMessagePrincipal,\n type TaskMessageProtocol,\n} from \"./schema/task-message\";\nimport { jsonValueSchema, workflowBindingSchema, type WorkflowBinding } from \"./schema/work\";\nimport { RecordExistsError } from \"./store/driver\";\nimport type { FactoryStores } from \"./store/engine\";\n\n/** Minimal persistence capabilities required to decide and apply one Task message. */\nexport type TaskMessageProcessingStores = Pick<\n FactoryStores,\n \"messages\" | \"tasks\" | \"workflowRecords\"\n>;\n\nconst decisionRecordSchema = z.strictObject({\n schemaVersion: schemaVersionSchema,\n id: z\n .string()\n .regex(/^decision_[a-f0-9]{64}$/)\n .describe(\"Immutable workflow and message decision identity.\"),\n toTaskId: taskIdSchema.describe(\"Authorized recipient Task of the decided message.\"),\n messageId: taskMessageIdSchema,\n workflow: workflowBindingSchema.describe(\"Exact workflow contract that produced this decision.\"),\n decision: jsonValueSchema.describe(\n \"Schema-validated bounded decision; never credentials or execution context.\",\n ),\n createdAt: isoDateTimeSchema.describe(\"Timestamp of the first committed decision.\"),\n});\n\n/** Trusted dependencies and pure/effectful callbacks for processing one Task inbox head. */\nexport interface ProcessTaskMessageOptions<\n Schema extends z.ZodType,\n Protocol extends TaskMessageProtocol = TaskMessageProtocol,\n> {\n readonly stores: TaskMessageProcessingStores;\n /** Authenticated externally; the message store enforces its configured claim policy. */\n readonly principal: TaskMessagePrincipal;\n /** Exact recipient Task attempt authorized to process the inbox head. */\n readonly task: TaskAttemptRef;\n /** Refuse a different inbox head before deciding or replaying effects. */\n readonly expectMessageId?: TaskMessageId;\n readonly leaseMs: number;\n readonly workflow: WorkflowBinding;\n /** Exact protocol required for the claimed message and exposed to typed callbacks. */\n readonly protocol: Protocol;\n /** Trusted UTC clock for decision timestamps; defaults to the system clock. */\n readonly now?: IsoDateTimeClock;\n /** Must accept its canonical JSON output unchanged. Exclude secrets from the decision contract. */\n readonly decisionSchema: Schema;\n /** Pure computation: may run concurrently or repeat until a decision is durably inserted. */\n decide(\n context: Readonly<{ task: Task; message: TaskMessageForProtocol<Protocol> }>,\n ): Promise<z.input<Schema>>;\n /**\n * Honor effectKey for every external write (derive stable subkeys for multiple effects).\n * Lease checks cannot fence external systems: apply may repeat, overlap, or outlive its claim.\n * Resolve only after all effects commit; never mutate the decision to select different effects.\n */\n apply(\n context: Readonly<{\n task: Task;\n message: TaskMessageForProtocol<Protocol>;\n decision: z.output<Schema>;\n effectKey: string;\n }>,\n ): Promise<void>;\n}\n\n/** Result of finding no claimable work or durably processing one Task message. */\nexport type ProcessTaskMessageResult<Decision> =\n | { status: \"idle\" }\n | { status: \"processed\"; messageId: TaskMessageId; decision: Decision; effectKey: string };\n\nfunction snapshotProtocol<Protocol extends TaskMessageProtocol>(\n protocol: Protocol,\n): Readonly<Protocol> {\n const snapshot = defineTaskMessageProtocol(protocol);\n if (!isDeepStrictEqual(snapshot.binding, protocol.binding))\n throw new Error(\"Task-message protocol binding must match its definition\");\n return snapshot as Readonly<Protocol>;\n}\n\nfunction validateProtocolMessage<Protocol extends TaskMessageProtocol>(\n protocol: Protocol,\n message: TaskMessage,\n): TaskMessageForProtocol<Protocol> {\n if (message.type.id !== protocol.id || message.type.version !== protocol.version) {\n throw new Error(\n `Task message ${message.id} requires exact protocol ${protocol.id}@${protocol.version}`,\n );\n }\n const json = structuredClone(jsonValueSchema.parse(message.payload));\n const payload = jsonValueSchema.parse(\n (protocol.storedPayload ?? protocol.payload).parse(structuredClone(json)),\n );\n if (!isDeepStrictEqual(json, payload)) {\n throw new Error(\n \"Stored message protocol validation must preserve canonical JSON; provide storedPayload for transforming protocols\",\n );\n }\n return structuredClone({\n ...message,\n type: protocol.binding,\n payload,\n }) as TaskMessageForProtocol<Protocol>;\n}\n\nfunction validateStoredDecision<Schema extends z.ZodType>(\n schema: Schema,\n value: unknown,\n): z.output<Schema> {\n const json = structuredClone(jsonValueSchema.parse(value));\n const parsed = schema.parse(structuredClone(json));\n const validated = jsonValueSchema.parse(parsed);\n if (!isDeepStrictEqual(json, validated)) {\n throw new Error(\n \"Decision schema must preserve canonical JSON; non-idempotent transforms are not permitted\",\n );\n }\n return structuredClone(parsed);\n}\n\nfunction decisionIdentity(workflow: WorkflowBinding, messageId: TaskMessageId): string {\n return `decision_${createHash(\"sha256\")\n .update(JSON.stringify([workflow.id, workflow.version, messageId]))\n .digest(\"hex\")}`;\n}\n\n/** Authorized typed inspection; null means no committed decision, not permission to decide for a terminal Task. */\nexport async function readTaskMessageDecision<Schema extends z.ZodType>(\n options: Pick<\n ProcessTaskMessageOptions<Schema>,\n \"stores\" | \"principal\" | \"task\" | \"workflow\" | \"decisionSchema\"\n >,\n messageId: TaskMessageId,\n): Promise<z.output<Schema> | null> {\n const workflow = workflowBindingSchema.parse(options.workflow);\n const task = await options.stores.tasks.get(options.task.taskId);\n if (!task || !isDeepStrictEqual(task.work.workflow, workflow))\n throw new Error(\"Exact recipient workflow required\");\n if (\n !(await options.stores.messages.get({\n principal: options.principal,\n toTaskId: task.id,\n messageId,\n }))\n )\n return null;\n const id = decisionIdentity(workflow, messageId);\n const stored = await options.stores.workflowRecords.get(\"taskMessageDecisions\", id);\n if (!stored) return null;\n const record = decisionRecordSchema.parse(stored.value);\n if (\n record.id !== id ||\n record.toTaskId !== task.id ||\n record.messageId !== messageId ||\n !isDeepStrictEqual(record.workflow, workflow)\n )\n throw new Error(\"Stored Task message decision identity mismatch\");\n return validateStoredDecision(options.decisionSchema, record.decision);\n}\n\n/** Process one authorized inbox head. Idle means empty or already leased, not necessarily drained. */\nexport async function processTaskMessage<\n Schema extends z.ZodType,\n Protocol extends TaskMessageProtocol = TaskMessageProtocol,\n>(\n options: ProcessTaskMessageOptions<Schema, Protocol>,\n): Promise<ProcessTaskMessageResult<z.output<Schema>>> {\n const { stores, decisionSchema, decide, apply } = options;\n const protocol = snapshotProtocol(options.protocol);\n const driver = stores.workflowRecords;\n const workflow = workflowBindingSchema.parse(options.workflow);\n const principal = taskMessagePrincipalSchema.parse(options.principal);\n const { taskId, attempt } = taskAttemptRefSchema.parse(options.task);\n const loadTask = async (): Promise<Task> => {\n const task = await stores.tasks.get(taskId);\n if (!task || task.id !== taskId || !isDeepStrictEqual(task.work.workflow, workflow)) {\n throw new Error(`Task ${taskId} requires exact workflow ${workflow.id}@${workflow.version}`);\n }\n if (task.state === \"cancelled\")\n throw new Error(`Cancelled Task ${taskId} cannot replay message effects`);\n return task;\n };\n const completed = (task: Task): boolean => task.state === \"succeeded\" || task.state === \"failed\";\n const decisionId = (messageId: TaskMessageId): string => decisionIdentity(workflow, messageId);\n const readDecision = (value: unknown, messageId: TaskMessageId): z.output<Schema> => {\n const record = decisionRecordSchema.parse(value);\n if (\n record.id !== decisionId(messageId) ||\n record.toTaskId !== taskId ||\n record.messageId !== messageId ||\n !isDeepStrictEqual(record.workflow, workflow)\n ) {\n throw new Error(\n \"Stored Task message decision identity does not match its recipient, message, and workflow\",\n );\n }\n return validateStoredDecision(decisionSchema, record.decision);\n };\n\n let task = await loadTask();\n if (options.expectMessageId !== undefined) {\n const head = (await stores.messages.pending({ principal, toTaskId: taskId }))[0];\n if (head?.id !== options.expectMessageId)\n throw new Error(\"Inbox head differs from expected message\");\n if (head) validateProtocolMessage(protocol, head);\n }\n let recoveryMessageId: TaskMessageId | undefined;\n if (completed(task)) {\n const head = (await stores.messages.pending({ principal, toTaskId: taskId }))[0];\n if (!head) return { status: \"idle\" };\n validateProtocolMessage(protocol, head);\n const stored = await driver.get(\"taskMessageDecisions\", decisionId(head.id));\n if (!stored)\n throw new Error(\n `Completed Task ${taskId} requires an existing decision for message recovery`,\n );\n readDecision(stored.value, head.id);\n recoveryMessageId = head.id;\n }\n const claimed = await stores.messages.claim({\n principal,\n task: { taskId, attempt },\n leaseMs: options.leaseMs,\n ...(recoveryMessageId === undefined ? {} : { recoverCompleted: true }),\n });\n if (!claimed) return { status: \"idle\" };\n const { claim, message: claimedMessage } = claimed;\n const message = validateProtocolMessage(protocol, claimedMessage);\n if (options.expectMessageId !== undefined && message.id !== options.expectMessageId) {\n throw new Error(\"Claimed message differs from expected message\");\n }\n if (recoveryMessageId !== undefined && message.id !== recoveryMessageId) {\n throw new Error(\"Claimed message differs from the validated terminal recovery head\");\n }\n task = await loadTask();\n const id = decisionId(message.id);\n const effectKey = stores.messages.effectKey({\n messageId: message.id,\n operation: `workflow:${workflow.id}@${workflow.version}`,\n });\n await stores.messages.assertClaim({ principal, claim });\n const existing = await driver.get(\"taskMessageDecisions\", id);\n let decision: z.output<Schema>;\n if (existing) {\n decision = readDecision(existing.value, message.id);\n } else {\n if (recoveryMessageId !== undefined || completed(task)) {\n throw new Error(\n `Completed Task ${taskId} requires an existing decision for message recovery`,\n );\n }\n const raw = jsonValueSchema.parse(\n await decide({ task: structuredClone(task), message: structuredClone(message) }),\n );\n const canonical = jsonValueSchema.parse(decisionSchema.parse(structuredClone(raw)));\n decision = validateStoredDecision(decisionSchema, canonical);\n const record = decisionRecordSchema.parse({\n schemaVersion: SCHEMA_VERSION,\n id,\n toTaskId: taskId,\n messageId: message.id,\n workflow,\n decision,\n createdAt: (options.now ?? (() => new Date().toISOString()))(),\n });\n await stores.messages.assertClaim({ principal, claim });\n try {\n await driver.insert({ collection: \"taskMessageDecisions\", id, value: record });\n } catch (error) {\n if (!(error instanceof RecordExistsError)) throw error;\n const winner = await driver.get(\"taskMessageDecisions\", id);\n if (!winner) throw new Error(\"Winning Task message decision is missing\", { cause: error });\n decision = readDecision(winner.value, message.id);\n }\n }\n\n task = await loadTask();\n await stores.messages.assertClaim({ principal, claim });\n await apply({\n task: structuredClone(task),\n message: structuredClone(message),\n decision: structuredClone(decision),\n effectKey,\n });\n await stores.messages.assertClaim({ principal, claim });\n await stores.messages.complete({ principal, claim, effectsCommitted: true });\n return { status: \"processed\", messageId: message.id, decision, effectKey };\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,uBAAuB,EAAE,aAAa;CAC1C,eAAe;CACf,IAAI,EACD,OAAO,CAAC,CACR,MAAM,yBAAyB,CAAC,CAChC,SAAS,mDAAmD;CAC/D,UAAU,aAAa,SAAS,mDAAmD;CACnF,WAAW;CACX,UAAU,sBAAsB,SAAS,sDAAsD;CAC/F,UAAU,gBAAgB,SACxB,4EACF;CACA,WAAW,kBAAkB,SAAS,4CAA4C;AACpF,CAAC;AA8CD,SAAS,iBACP,UACoB;CACpB,MAAM,WAAW,0BAA0B,QAAQ;CACnD,IAAI,CAAC,kBAAkB,SAAS,SAAS,SAAS,OAAO,GACvD,MAAM,IAAI,MAAM,yDAAyD;CAC3E,OAAO;AACT;AA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