@atolis-hq/wake 0.2.97 → 0.3.0
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/dist/src/activities/agent/agent-activity-definition.js +26 -0
- package/dist/src/activities/agent/agent-activity.js +171 -0
- package/dist/src/activities/agent/agent-result.js +149 -0
- package/dist/src/activities/contracts/activity.js +10 -0
- package/dist/src/activities/contracts/config.js +2 -0
- package/dist/src/activities/contracts/event-schema.js +302 -0
- package/dist/src/activities/contracts/events.js +42 -0
- package/dist/src/activities/contracts/identifiers.js +29 -0
- package/dist/src/activities/contracts/registry.js +71 -0
- package/dist/src/activities/contracts/streams.js +17 -0
- package/dist/src/activities/contracts/vocabulary.js +58 -0
- package/dist/src/activities/index.js +21 -0
- package/dist/src/activities/pr/activity-support.js +111 -0
- package/dist/src/activities/pr/application.js +158 -0
- package/dist/src/activities/pr/approve.js +85 -0
- package/dist/src/activities/pr/capability.js +11 -0
- package/dist/src/activities/pr/decision-claim.js +76 -0
- package/dist/src/activities/pr/event-drafts.js +66 -0
- package/dist/src/activities/pr/intent.js +37 -0
- package/dist/src/activities/pr/merge-authority-gate.js +14 -0
- package/dist/src/activities/pr/merge.js +110 -0
- package/dist/src/activities/pr/policy.js +135 -0
- package/dist/src/activities/pr/projection.js +130 -0
- package/dist/src/activities/pr/vocabulary.js +30 -0
- package/dist/src/activities/review/authorization.js +22 -0
- package/dist/src/activities/review/contracts.js +22 -0
- package/dist/src/activities/review/signals.js +3 -0
- package/dist/src/bootstrap/analytics-projection.js +26 -0
- package/dist/src/bootstrap/board-projection.js +337 -0
- package/dist/src/bootstrap/composition-root.js +382 -0
- package/dist/src/bootstrap/config/load-config.js +51 -0
- package/dist/src/bootstrap/config/root-schema.js +134 -0
- package/dist/src/bootstrap/external-ref.js +12 -0
- package/dist/src/bootstrap/fake-provider-files.js +44 -0
- package/dist/src/bootstrap/fake-scenarios.js +22 -0
- package/dist/src/bootstrap/index.js +48 -0
- package/dist/src/bootstrap/initialise.js +434 -0
- package/dist/src/bootstrap/paths.js +15 -0
- package/dist/src/bootstrap/projection-runtime.js +27 -0
- package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
- package/dist/src/bootstrap/runner-registry.js +30 -0
- package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
- package/dist/src/bootstrap/self-update-application.js +195 -0
- package/dist/src/bootstrap/self-update-failure-log.js +33 -0
- package/dist/src/bootstrap/source-update-port.js +47 -0
- package/dist/src/bootstrap/status-publish-activity.js +42 -0
- package/dist/src/bootstrap/surface-api-applications.js +325 -0
- package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
- package/dist/src/bootstrap/surface-api-metadata.js +12 -0
- package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
- package/dist/src/bootstrap/surface-api-run-context.js +5 -0
- package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
- package/dist/src/bootstrap/surface-applications.js +7 -0
- package/dist/src/bootstrap/surface-cli-applications.js +701 -0
- package/dist/src/bootstrap/update-ledger.js +61 -0
- package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
- package/dist/src/{version.js → bootstrap/version.js} +35 -51
- package/dist/src/control-plane/application/advance-once.js +184 -0
- package/dist/src/control-plane/application/control-plane-projection.js +42 -0
- package/dist/src/control-plane/application/control-plane-service.js +42 -0
- package/dist/src/control-plane/application/intake-pipeline.js +29 -0
- package/dist/src/control-plane/application/runner-control-service.js +66 -0
- package/dist/src/control-plane/application/runner-pipeline.js +57 -0
- package/dist/src/control-plane/application/schedule-service.js +47 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
- package/dist/src/control-plane/contracts/commands.js +10 -0
- package/dist/src/control-plane/contracts/config.js +22 -0
- package/dist/src/control-plane/contracts/events.js +81 -0
- package/dist/src/control-plane/contracts/streams.js +5 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
- package/dist/src/control-plane/domain/quota-policy.js +26 -0
- package/dist/src/control-plane/domain/runner-quota.js +35 -0
- package/dist/src/control-plane/domain/schedule-policy.js +46 -0
- package/dist/src/control-plane/index.js +20 -0
- package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
- package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
- package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
- package/dist/src/execution/application/activation-claim.js +50 -0
- package/dist/src/execution/application/active-run-cancellation.js +14 -0
- package/dist/src/execution/application/execution-activity.js +97 -0
- package/dist/src/execution/application/execution-projection.js +17 -0
- package/dist/src/execution/application/execution-service.js +372 -0
- package/dist/src/execution/application/execution-validation.js +26 -0
- package/dist/src/execution/application/recovery-service.js +212 -0
- package/dist/src/execution/application/run-lifecycle.js +115 -0
- package/dist/src/execution/application/run-liveness-service.js +80 -0
- package/dist/src/execution/application/run-repository.js +27 -0
- package/dist/src/execution/contracts/commands.js +1 -0
- package/dist/src/execution/contracts/config.js +35 -0
- package/dist/src/execution/contracts/control-plane.js +1 -0
- package/dist/src/execution/contracts/event-factory.js +53 -0
- package/dist/src/execution/contracts/events.js +274 -0
- package/dist/src/execution/contracts/identifiers.js +5 -0
- package/dist/src/execution/contracts/liveness.js +1 -0
- package/dist/src/execution/contracts/results.js +1 -0
- package/dist/src/execution/contracts/runner.js +15 -0
- package/dist/src/execution/contracts/streams.js +10 -0
- package/dist/src/execution/contracts/views.js +1 -0
- package/dist/src/execution/contracts/vocabulary.js +43 -0
- package/dist/src/execution/contracts/workspace.js +1 -0
- package/dist/src/execution/domain/run-result.js +34 -0
- package/dist/src/execution/domain/run.js +142 -0
- package/dist/src/execution/index.js +31 -0
- package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
- package/dist/src/execution/infrastructure/process-execution.js +29 -0
- package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
- package/dist/src/execution/infrastructure/runners/claude.js +120 -0
- package/dist/src/execution/infrastructure/runners/codex.js +143 -0
- package/dist/src/execution/infrastructure/runners/command.js +4 -0
- package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
- package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
- package/dist/src/execution/infrastructure/runners/fake.js +65 -0
- package/dist/src/execution/infrastructure/runners/registry.js +26 -0
- package/dist/src/execution/infrastructure/transcript-store.js +223 -0
- package/dist/src/execution/infrastructure/transcripts.js +11 -0
- package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
- package/dist/src/integrations/application/poll-service.js +25 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
- package/dist/src/integrations/application/work-admission.js +31 -0
- package/dist/src/integrations/application/work-conclusion.js +19 -0
- package/dist/src/integrations/contracts/artifact-events.js +60 -0
- package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
- package/dist/src/integrations/contracts/config.js +14 -0
- package/dist/src/integrations/contracts/identifiers.js +5 -0
- package/dist/src/integrations/contracts/intake-rules.js +14 -0
- package/dist/src/integrations/contracts/intake.js +1 -0
- package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
- package/dist/src/integrations/contracts/provider.js +37 -0
- package/dist/src/integrations/contracts/streams.js +10 -0
- package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
- package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
- package/dist/src/integrations/delivery/contracts/commands.js +1 -0
- package/dist/src/integrations/delivery/contracts/config.js +1 -0
- package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
- package/dist/src/integrations/delivery/contracts/events.js +86 -0
- package/dist/src/integrations/delivery/contracts/intents.js +89 -0
- package/dist/src/integrations/delivery/contracts/views.js +1 -0
- package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
- package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
- package/dist/src/integrations/fake/external-sink.js +9 -0
- package/dist/src/integrations/fake/external-source.js +44 -0
- package/dist/src/integrations/fake/inbound-translator.js +130 -0
- package/dist/src/integrations/fake/provider.js +95 -0
- package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
- package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
- package/dist/src/integrations/github/application/inbound-context.js +10 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
- package/dist/src/integrations/github/application/inbound-translator.js +231 -0
- package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
- package/dist/src/integrations/github/application/intake-policy.js +23 -0
- package/dist/src/integrations/github/application/outbound-translator.js +47 -0
- package/dist/src/integrations/github/application/poll-service.js +29 -0
- package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
- package/dist/src/integrations/github/application/resource-links.js +8 -0
- package/dist/src/integrations/github/application/review-command-translator.js +16 -0
- package/dist/src/integrations/github/application/wake-labels.js +95 -0
- package/dist/src/integrations/github/contracts/config.js +47 -0
- package/dist/src/integrations/github/contracts/events.js +127 -0
- package/dist/src/integrations/github/contracts/external-key.js +19 -0
- package/dist/src/integrations/github/contracts/payloads.js +9 -0
- package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
- package/dist/src/integrations/github/index.js +31 -0
- package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
- package/dist/src/integrations/github/infrastructure/client.js +132 -0
- package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
- package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
- package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
- package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
- package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
- package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
- package/dist/src/integrations/github/infrastructure/source.js +108 -0
- package/dist/src/integrations/github/provider.js +96 -0
- package/dist/src/integrations/index.js +30 -0
- package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
- package/dist/src/kernel/contracts/clock.js +1 -0
- package/dist/src/kernel/contracts/commands.js +1 -0
- package/dist/src/kernel/contracts/event-journal.js +2 -0
- package/dist/src/kernel/contracts/event-schema.js +54 -0
- package/dist/src/kernel/contracts/events.js +11 -0
- package/dist/src/kernel/contracts/id-generator.js +1 -0
- package/dist/src/kernel/contracts/identifiers.js +8 -0
- package/dist/src/kernel/contracts/projection-store.js +1 -0
- package/dist/src/kernel/contracts/relations.js +1 -0
- package/dist/src/kernel/contracts/schema.js +17 -0
- package/dist/src/kernel/contracts/vocabulary.js +6 -0
- package/dist/src/kernel/domain/event-envelope.js +29 -0
- package/dist/src/kernel/domain/match-mode.js +11 -0
- package/dist/src/kernel/domain/relation.js +10 -0
- package/dist/src/kernel/index.js +17 -0
- package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
- package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
- package/dist/src/main.js +137 -1030
- package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
- package/dist/src/orchestration/application/accept-signal.js +35 -0
- package/dist/src/orchestration/application/advance-workflow.js +160 -0
- package/dist/src/orchestration/application/coordination-claims.js +107 -0
- package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
- package/dist/src/orchestration/application/orchestration-projection.js +20 -0
- package/dist/src/orchestration/application/orchestration-repository.js +36 -0
- package/dist/src/orchestration/application/orchestration-service.js +82 -0
- package/dist/src/orchestration/application/request-child.js +118 -0
- package/dist/src/orchestration/application/signal-reactor.js +17 -0
- package/dist/src/orchestration/application/start-workflow.js +51 -0
- package/dist/src/orchestration/application/watch-reactor.js +82 -0
- package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
- package/dist/src/orchestration/contracts/commands.js +1 -0
- package/dist/src/orchestration/contracts/config.js +128 -0
- package/dist/src/orchestration/contracts/event-decoder.js +263 -0
- package/dist/src/orchestration/contracts/events.js +41 -0
- package/dist/src/orchestration/contracts/identifiers.js +35 -0
- package/dist/src/orchestration/contracts/streams.js +38 -0
- package/dist/src/orchestration/contracts/views.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +30 -0
- package/dist/src/orchestration/domain/activation-policy.js +55 -0
- package/dist/src/orchestration/domain/approval-defaults.js +17 -0
- package/dist/src/orchestration/domain/child-policy.js +63 -0
- package/dist/src/orchestration/domain/compiler.js +162 -0
- package/dist/src/orchestration/domain/coordination-events.js +25 -0
- package/dist/src/orchestration/domain/decision-events.js +47 -0
- package/dist/src/orchestration/domain/interpreter.js +49 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
- package/dist/src/orchestration/domain/retry-policy.js +26 -0
- package/dist/src/orchestration/domain/signal-policy.js +120 -0
- package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
- package/dist/src/orchestration/domain/transition.js +55 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
- package/dist/src/orchestration/domain/workflow-instance.js +41 -0
- package/dist/src/orchestration/domain/workflow-selector.js +21 -0
- package/dist/src/orchestration/index.js +19 -0
- package/dist/src/persistence/application/projection-runner.js +79 -0
- package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
- package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
- package/dist/src/persistence/filesystem/file-lock.js +91 -0
- package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
- package/dist/src/persistence/index.js +8 -0
- package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
- package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
- package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
- package/dist/src/resources/application/lookup-projections.js +48 -0
- package/dist/src/resources/application/resource-lookup.js +16 -0
- package/dist/src/resources/application/resource-projections.js +81 -0
- package/dist/src/resources/application/resource-repository.js +18 -0
- package/dist/src/resources/application/resource-service.js +83 -0
- package/dist/src/resources/contracts/commands.js +1 -0
- package/dist/src/resources/contracts/config.js +2 -0
- package/dist/src/resources/contracts/events.js +83 -0
- package/dist/src/resources/contracts/identifiers.js +15 -0
- package/dist/src/resources/contracts/streams.js +6 -0
- package/dist/src/resources/contracts/views.js +1 -0
- package/dist/src/resources/contracts/vocabulary.js +67 -0
- package/dist/src/resources/domain/correlation.js +8 -0
- package/dist/src/resources/domain/resource.js +58 -0
- package/dist/src/resources/index.js +14 -0
- package/dist/src/surfaces/api/contracts/activities.js +1 -0
- package/dist/src/surfaces/api/contracts/board.js +2 -0
- package/dist/src/surfaces/api/contracts/common.js +46 -0
- package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
- package/dist/src/surfaces/api/contracts/events.js +1 -0
- package/dist/src/surfaces/api/contracts/execution.js +1 -0
- package/dist/src/surfaces/api/contracts/index.js +13 -0
- package/dist/src/surfaces/api/contracts/observability.js +1 -0
- package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
- package/dist/src/surfaces/api/contracts/resources.js +1 -0
- package/dist/src/surfaces/api/contracts/status.js +1 -0
- package/dist/src/surfaces/api/contracts/system.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
- package/dist/src/surfaces/api/contracts/work.js +17 -0
- package/dist/src/surfaces/api/http-server.js +121 -0
- package/dist/src/surfaces/api/presenters/activities.js +1 -0
- package/dist/src/surfaces/api/presenters/board.js +3 -0
- package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
- package/dist/src/surfaces/api/presenters/events.js +1 -0
- package/dist/src/surfaces/api/presenters/execution.js +59 -0
- package/dist/src/surfaces/api/presenters/observability.js +1 -0
- package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
- package/dist/src/surfaces/api/presenters/resources.js +15 -0
- package/dist/src/surfaces/api/presenters/status.js +3 -0
- package/dist/src/surfaces/api/presenters/system.js +14 -0
- package/dist/src/surfaces/api/presenters/work.js +16 -0
- package/dist/src/surfaces/api/problem-details.js +9 -0
- package/dist/src/surfaces/api/router.js +13 -0
- package/dist/src/surfaces/api/routes/activities.js +1 -0
- package/dist/src/surfaces/api/routes/applications.js +1 -0
- package/dist/src/surfaces/api/routes/commands.js +82 -0
- package/dist/src/surfaces/api/routes/control-plane.js +6 -0
- package/dist/src/surfaces/api/routes/events.js +1 -0
- package/dist/src/surfaces/api/routes/execution.js +8 -0
- package/dist/src/surfaces/api/routes/index.js +18 -0
- package/dist/src/surfaces/api/routes/observability.js +1 -0
- package/dist/src/surfaces/api/routes/orchestration.js +1 -0
- package/dist/src/surfaces/api/routes/pagination.js +78 -0
- package/dist/src/surfaces/api/routes/read.js +135 -0
- package/dist/src/surfaces/api/routes/resources.js +1 -0
- package/dist/src/surfaces/api/routes/responses.js +67 -0
- package/dist/src/surfaces/api/routes/system.js +1 -0
- package/dist/src/surfaces/api/routes/work.js +9 -0
- package/dist/src/surfaces/cli/commands/api.js +1 -0
- package/dist/src/surfaces/cli/commands/audit.js +10 -0
- package/dist/src/surfaces/cli/commands/correlate.js +2 -0
- package/dist/src/surfaces/cli/commands/doctor.js +6 -0
- package/dist/src/surfaces/cli/commands/init.js +39 -0
- package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
- package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
- package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
- package/dist/src/surfaces/cli/commands/self-update.js +38 -0
- package/dist/src/surfaces/cli/commands/smoke.js +16 -0
- package/dist/src/surfaces/cli/commands/start.js +1 -0
- package/dist/src/surfaces/cli/commands/stop.js +13 -0
- package/dist/src/surfaces/cli/commands/tick.js +1 -0
- package/dist/src/surfaces/cli/commands/ui.js +2 -0
- package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
- package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
- package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
- package/dist/src/surfaces/cli/main.js +140 -0
- package/dist/src/surfaces/cli/usage.js +33 -0
- package/dist/src/surfaces/contracts/config.js +34 -0
- package/dist/src/surfaces/index.js +47 -0
- package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
- package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
- package/dist/src/surfaces/web-assets/index.html +13 -0
- package/dist/src/surfaces/web-host/asset-source.js +1 -0
- package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
- package/dist/src/work/application/work-projection.js +59 -0
- package/dist/src/work/application/work-repository.js +18 -0
- package/dist/src/work/application/work-service.js +117 -0
- package/dist/src/work/contracts/commands.js +1 -0
- package/dist/src/work/contracts/config.js +2 -0
- package/dist/src/work/contracts/events.js +103 -0
- package/dist/src/work/contracts/identifiers.js +5 -0
- package/dist/src/work/contracts/streams.js +6 -0
- package/dist/src/work/contracts/views.js +1 -0
- package/dist/src/work/contracts/vocabulary.js +6 -0
- package/dist/src/work/domain/work-item.js +89 -0
- package/dist/src/work/index.js +11 -0
- package/docker/Dockerfile +10 -6
- package/docker/Dockerfile.packaged +3 -3
- package/package.json +29 -4
- package/prompts/implement.md +2 -2
- package/templates/SETUP.md +7 -7
- package/dist/src/adapters/claude/claude-runner.js +0 -529
- package/dist/src/adapters/codex/codex-runner.js +0 -503
- package/dist/src/adapters/cursor/cursor-runner.js +0 -418
- package/dist/src/adapters/docker/docker-cli.js +0 -150
- package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
- package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
- package/dist/src/adapters/fake/fake-resource-index.js +0 -21
- package/dist/src/adapters/fake/fake-runner.js +0 -77
- package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
- package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
- package/dist/src/adapters/fs/resource-index.js +0 -126
- package/dist/src/adapters/fs/self-update-ledger.js +0 -17
- package/dist/src/adapters/fs/state-store.js +0 -775
- package/dist/src/adapters/git/git-workspace-manager.js +0 -289
- package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
- package/dist/src/adapters/github/github-auth.js +0 -16
- package/dist/src/adapters/github/github-client.js +0 -249
- package/dist/src/adapters/github/github-etag-cache.js +0 -57
- package/dist/src/adapters/github/github-issues-work-source.js +0 -692
- package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
- package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
- package/dist/src/adapters/http/ui-assets.js +0 -1188
- package/dist/src/adapters/http/ui-data.js +0 -1107
- package/dist/src/adapters/http/ui-server.js +0 -458
- package/dist/src/adapters/runner/cli-command.js +0 -73
- package/dist/src/adapters/runner/prompt-templates.js +0 -76
- package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
- package/dist/src/adapters/runner/runner-registry.js +0 -139
- package/dist/src/adapters/runner/runtime-events.js +0 -32
- package/dist/src/adapters/runner/stage-prompt.js +0 -268
- package/dist/src/adapters/runner/transcripts.js +0 -25
- package/dist/src/cli/audit-command.js +0 -36
- package/dist/src/cli/correlate-command.js +0 -62
- package/dist/src/cli/doctor-command.js +0 -48
- package/dist/src/cli/init-command.js +0 -18
- package/dist/src/cli/sandbox-command.js +0 -258
- package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
- package/dist/src/cli/sandbox-exec-logging.js +0 -7
- package/dist/src/cli/sandbox-resume.js +0 -79
- package/dist/src/cli/sandbox-setup-command.js +0 -31
- package/dist/src/cli/scaffold-assets.js +0 -100
- package/dist/src/cli/self-update-command.js +0 -198
- package/dist/src/cli/startup-preflight.js +0 -134
- package/dist/src/cli/stop-command.js +0 -46
- package/dist/src/cli/ui-command.js +0 -27
- package/dist/src/config/defaults.js +0 -10
- package/dist/src/config/discover-config-files.js +0 -11
- package/dist/src/config/load-config.js +0 -69
- package/dist/src/config/split-config.js +0 -14
- package/dist/src/core/active-run-recovery.js +0 -44
- package/dist/src/core/approval-intents.js +0 -16
- package/dist/src/core/audit-events.js +0 -82
- package/dist/src/core/control-plane.js +0 -192
- package/dist/src/core/event-builders.js +0 -153
- package/dist/src/core/event-resolver.js +0 -249
- package/dist/src/core/lifecycle-service.js +0 -8
- package/dist/src/core/live-execution.js +0 -81
- package/dist/src/core/outbox.js +0 -198
- package/dist/src/core/policy-engine.js +0 -389
- package/dist/src/core/projection-updater.js +0 -693
- package/dist/src/core/quota-backoff.js +0 -69
- package/dist/src/core/run-lease.js +0 -38
- package/dist/src/core/scheduled-workflow-source.js +0 -199
- package/dist/src/core/sink-router.js +0 -107
- package/dist/src/core/stale-run-reconciler.js +0 -352
- package/dist/src/core/tick-runner.js +0 -2442
- package/dist/src/core/workspace-cleanup.js +0 -117
- package/dist/src/domain/branch-naming.js +0 -14
- package/dist/src/domain/custom-commands.js +0 -58
- package/dist/src/domain/event-types.js +0 -158
- package/dist/src/domain/manual-labels.js +0 -1
- package/dist/src/domain/resource-uri.js +0 -38
- package/dist/src/domain/runner-routing.js +0 -127
- package/dist/src/domain/runtime-events.js +0 -36
- package/dist/src/domain/schema.js +0 -1233
- package/dist/src/domain/sources.js +0 -16
- package/dist/src/domain/stages.js +0 -36
- package/dist/src/domain/work-item-labels.js +0 -48
- package/dist/src/domain/work-item-lifecycle.js +0 -10
- package/dist/src/domain/work-item-status.js +0 -33
- package/dist/src/domain/workflows.js +0 -159
- package/dist/src/lib/deep-merge.js +0 -14
- package/dist/src/lib/detached-process-logging.js +0 -46
- package/dist/src/lib/event-log.js +0 -21
- package/dist/src/lib/format.js +0 -41
- package/dist/src/lib/json-file.js +0 -23
- package/dist/src/lib/lock.js +0 -181
- package/dist/src/lib/log-rotation.js +0 -42
- package/dist/src/lib/paths.js +0 -52
- package/dist/src/lib/process-identity.js +0 -54
- package/dist/src/lib/state-health.js +0 -30
- package/dist/src/lib/work-id.js +0 -19
- package/dist/src/lib/yaml-file.js +0 -20
- /package/dist/src/{core → activities/pr}/contracts.js +0 -0
- /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ControlStreamKind, ineligibleRunners, } from '../control-plane/index.js';
|
|
2
|
+
import { ApiCommandStatus, presentRun } from '../surfaces/index.js';
|
|
3
|
+
import { projectionMeta, sampledMeta } from './surface-api-metadata.js';
|
|
4
|
+
import { projectionPage } from './surface-api-projection-pages.js';
|
|
5
|
+
import { withWorkflowContext } from './surface-api-run-context.js';
|
|
6
|
+
import { readWorkTranscript } from './surface-api-transcripts.js';
|
|
7
|
+
export function createExecutionApplications(root, now) {
|
|
8
|
+
return {
|
|
9
|
+
async pauseRunner(runnerId, command) {
|
|
10
|
+
await root.runnerControls.pause(runnerId, command.idempotencyKey);
|
|
11
|
+
return commandAccepted(command, now());
|
|
12
|
+
},
|
|
13
|
+
async unpauseRunner(runnerId, command) {
|
|
14
|
+
await root.runnerControls.unpause(runnerId, command.idempotencyKey);
|
|
15
|
+
return commandAccepted(command, now());
|
|
16
|
+
},
|
|
17
|
+
async list(query) {
|
|
18
|
+
const stored = (await root.projections.list('execution')).flatMap((entry) => entry.value.view === null ? [] : [{ ...entry, value: entry.value.view }]);
|
|
19
|
+
const filtered = stored.filter((entry) => query.state === undefined || entry.value.status === query.state);
|
|
20
|
+
const page = await projectionPage(root.journal, filtered, query, presentRun, {
|
|
21
|
+
emptyAsOf: now(),
|
|
22
|
+
provenance: stored,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
...page,
|
|
26
|
+
items: await Promise.all(page.items.map((item) => withWorkflowContext(root, item))),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
async get(runId) {
|
|
30
|
+
const stored = await root.projections.read('execution', runId);
|
|
31
|
+
if (stored?.value.view == null)
|
|
32
|
+
return undefined;
|
|
33
|
+
return {
|
|
34
|
+
data: await withWorkflowContext(root, presentRun(stored.value.view)),
|
|
35
|
+
meta: await projectionMeta(root.journal, [stored], now()),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
async transcript(runId) {
|
|
39
|
+
const stored = await root.projections.read('execution', runId);
|
|
40
|
+
const run = stored?.value.view;
|
|
41
|
+
if (run === null || run === undefined)
|
|
42
|
+
return undefined;
|
|
43
|
+
const workflow = await root.projections.read('orchestration', run.workflowInstanceId);
|
|
44
|
+
const workItemId = workflow?.value.view?.workItemId;
|
|
45
|
+
if (workItemId === undefined)
|
|
46
|
+
return { data: { runId, available: false, entries: [] }, meta: sampledMeta(now()) };
|
|
47
|
+
const groupId = await root.transcriptStore?.groupForRun(workItemId, runId);
|
|
48
|
+
if (groupId === undefined)
|
|
49
|
+
return { data: { runId, available: false, entries: [] }, meta: sampledMeta(now()) };
|
|
50
|
+
const runs = (await root.projections.list('execution')).flatMap((entry) => (entry.value.view === null ? [] : [entry.value.view]));
|
|
51
|
+
const workflowIds = [...new Set(runs.map((candidate) => candidate.workflowInstanceId))];
|
|
52
|
+
const workflows = await Promise.all(workflowIds.map(async (workflowInstanceId) => root.projections.read('orchestration', workflowInstanceId)));
|
|
53
|
+
const workItemIdsByWorkflow = new Map(workflowIds.map((workflowInstanceId, index) => [
|
|
54
|
+
workflowInstanceId,
|
|
55
|
+
workflows[index]?.value.view?.workItemId,
|
|
56
|
+
]));
|
|
57
|
+
const groupRuns = runs.filter((candidate) => workItemIdsByWorkflow.get(candidate.workflowInstanceId) === workItemId);
|
|
58
|
+
const group = await readWorkTranscript(root.transcriptStore, workItemId, groupId, groupRuns);
|
|
59
|
+
return {
|
|
60
|
+
data: { runId, groupId, available: group.available, entries: group.entries },
|
|
61
|
+
meta: sampledMeta(now()),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
async runners(query) {
|
|
65
|
+
const sampledAt = now();
|
|
66
|
+
const stored = await root.projections.read(ControlStreamKind.Global, 'global');
|
|
67
|
+
const paused = stored === null ? new Set() : ineligibleRunners(stored.value, sampledAt);
|
|
68
|
+
const all = [...new Set(Object.values(root.config.execution.runnerPools).flat())].map((runnerId) => paused.has(runnerId)
|
|
69
|
+
? {
|
|
70
|
+
runnerId,
|
|
71
|
+
status: 'paused',
|
|
72
|
+
available: false,
|
|
73
|
+
detail: 'runner is paused',
|
|
74
|
+
updatedAt: sampledAt,
|
|
75
|
+
}
|
|
76
|
+
: { runnerId, status: 'available', available: true, updatedAt: sampledAt });
|
|
77
|
+
const offset = query.cursor?.position ?? 0;
|
|
78
|
+
const items = all.slice(offset, offset + query.limit);
|
|
79
|
+
return {
|
|
80
|
+
items,
|
|
81
|
+
total: all.length,
|
|
82
|
+
meta: sampledMeta(sampledAt),
|
|
83
|
+
...(offset + items.length < all.length ? { nextPosition: offset + items.length } : {}),
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function commandAccepted(command, acceptedAt) {
|
|
89
|
+
return {
|
|
90
|
+
commandId: `runner:${command.idempotencyKey}`,
|
|
91
|
+
idempotencyKey: command.idempotencyKey,
|
|
92
|
+
acceptedAt,
|
|
93
|
+
status: ApiCommandStatus.Completed,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function sampledMeta(asOf) {
|
|
2
|
+
return { asOf };
|
|
3
|
+
}
|
|
4
|
+
export async function projectionMeta(journal, projections, emptyAsOf) {
|
|
5
|
+
const position = projections.reduce((latest, projection) => Math.max(latest, projection.lastGlobalPosition), 0);
|
|
6
|
+
if (position === 0)
|
|
7
|
+
return sampledMeta(emptyAsOf);
|
|
8
|
+
const event = (await journal.readAll(position - 1, 1))[0];
|
|
9
|
+
if (event === undefined || event.globalPosition !== position)
|
|
10
|
+
throw new Error(`Journal fact unavailable for projection position ${position}`);
|
|
11
|
+
return { asOf: event.occurredAt, position };
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { projectionMeta } from './surface-api-metadata.js';
|
|
2
|
+
export async function projectionPage(journal, values, query, present, options) {
|
|
3
|
+
const provenance = options.provenance ?? values;
|
|
4
|
+
const after = query.cursor?.position ?? Number.POSITIVE_INFINITY;
|
|
5
|
+
const candidates = [...values]
|
|
6
|
+
.filter((entry) => entry.lastGlobalPosition < after)
|
|
7
|
+
.sort((left, right) => right.lastGlobalPosition - left.lastGlobalPosition);
|
|
8
|
+
const visible = candidates.slice(0, query.limit);
|
|
9
|
+
const last = visible.at(-1);
|
|
10
|
+
const metaSources = provenance.length === 0 && query.cursor !== undefined
|
|
11
|
+
? [{ lastGlobalPosition: query.cursor.position }]
|
|
12
|
+
: provenance;
|
|
13
|
+
const meta = await projectionMeta(journal, metaSources, options.emptyAsOf);
|
|
14
|
+
return {
|
|
15
|
+
items: visible.map((entry) => present(entry.value)),
|
|
16
|
+
meta,
|
|
17
|
+
total: values.length,
|
|
18
|
+
...(candidates.length > query.limit && last !== undefined
|
|
19
|
+
? { nextPosition: last.lastGlobalPosition }
|
|
20
|
+
: {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { workflowInstanceId } from '../orchestration/index.js';
|
|
2
|
+
export async function withWorkflowContext(root, run) {
|
|
3
|
+
const instance = await root.orchestration.get(workflowInstanceId(run.workflowInstanceId));
|
|
4
|
+
return instance === null ? run : { ...run, workflowName: instance.workflowName };
|
|
5
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TranscriptChannel } from '../execution/index.js';
|
|
2
|
+
export async function transcriptGroups(store, workItemId, runs) {
|
|
3
|
+
if (store === undefined)
|
|
4
|
+
return [];
|
|
5
|
+
const owned = new Set(runs.map((run) => run.runId));
|
|
6
|
+
const visible = await Promise.all((await store.listGroups(workItemId)).map(async (group) => {
|
|
7
|
+
const messages = (await store.readGroup(workItemId, group.id)).filter((message) => owned.has(message.runId));
|
|
8
|
+
const latest = messages.at(-1);
|
|
9
|
+
if (latest === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
return {
|
|
12
|
+
groupId: group.id,
|
|
13
|
+
kind: group.kind,
|
|
14
|
+
...(group.cli === undefined ? {} : { cli: group.cli }),
|
|
15
|
+
latestAt: latest.timestamp,
|
|
16
|
+
runIds: [...new Set(messages.map((message) => message.runId))],
|
|
17
|
+
};
|
|
18
|
+
}));
|
|
19
|
+
return visible.filter((group) => group !== undefined);
|
|
20
|
+
}
|
|
21
|
+
export async function readWorkTranscript(store, workItemId, groupId, runs) {
|
|
22
|
+
if (store === undefined)
|
|
23
|
+
return unavailable(groupId);
|
|
24
|
+
const group = (await store.listGroups(workItemId)).find((item) => item.id === groupId);
|
|
25
|
+
if (group === undefined)
|
|
26
|
+
return unavailable(groupId);
|
|
27
|
+
const included = new Set(group.runIds);
|
|
28
|
+
const metadata = new Map(runs.filter((run) => included.has(run.runId)).map((run) => [run.runId, run]));
|
|
29
|
+
if (metadata.size === 0)
|
|
30
|
+
return unavailable(groupId);
|
|
31
|
+
return {
|
|
32
|
+
groupId,
|
|
33
|
+
available: true,
|
|
34
|
+
entries: (await store.readGroup(workItemId, groupId))
|
|
35
|
+
.filter((message) => metadata.has(message.runId))
|
|
36
|
+
.map((message) => presentEntry(message, groupId, metadata.get(message.runId))),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function unavailable(groupId) {
|
|
40
|
+
return { groupId, available: false, entries: [] };
|
|
41
|
+
}
|
|
42
|
+
export function presentEntry(message, groupId, run) {
|
|
43
|
+
const durationMs = runDuration(run);
|
|
44
|
+
return {
|
|
45
|
+
occurredAt: message.timestamp,
|
|
46
|
+
channel: message.kind === 'prompt' ? TranscriptChannel.Input : TranscriptChannel.Agent,
|
|
47
|
+
text: message.text,
|
|
48
|
+
runId: message.runId,
|
|
49
|
+
groupId,
|
|
50
|
+
...(durationMs === undefined ? {} : { durationMs }),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function runDuration(run) {
|
|
54
|
+
if (run?.finishedAt === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
return Date.parse(run.finishedAt) - Date.parse(run.startedAt);
|
|
57
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { correlationId, EventActorKind } from '../kernel/index.js';
|
|
2
|
+
import { isOperatorRetryEligible, OperatorRetryIneligibleError, } from '../orchestration/index.js';
|
|
3
|
+
import { ResourceEventType, selectResourceEvent } from '../resources/index.js';
|
|
4
|
+
import { ApiCommandStatus, fromWorkItemKey, presentResource, presentRun, presentWorkflowInstance, presentWorkItem, } from '../surfaces/index.js';
|
|
5
|
+
import { workItemId, WorkStatus } from '../work/index.js';
|
|
6
|
+
import { primaryExternalRef } from './external-ref.js';
|
|
7
|
+
import { projectionMeta } from './surface-api-metadata.js';
|
|
8
|
+
import { projectionPage } from './surface-api-projection-pages.js';
|
|
9
|
+
import { withWorkflowContext } from './surface-api-run-context.js';
|
|
10
|
+
import { readWorkTranscript, transcriptGroups } from './surface-api-transcripts.js';
|
|
11
|
+
export function createSurfaceWorkApplications(root, now) {
|
|
12
|
+
return {
|
|
13
|
+
async list(query) {
|
|
14
|
+
const stored = (await root.projections.list('work')).flatMap((entry) => entry.value === null ? [] : [{ ...entry, value: entry.value }]);
|
|
15
|
+
const filtered = stored
|
|
16
|
+
.filter((entry) => query.search === undefined ||
|
|
17
|
+
`${entry.value.workItemId} ${entry.value.objective}`
|
|
18
|
+
.toLocaleLowerCase()
|
|
19
|
+
.includes(query.search.toLocaleLowerCase()))
|
|
20
|
+
.filter((entry) => query.state === undefined || entry.value.state === query.state);
|
|
21
|
+
return projectionPage(root.journal, filtered, query, presentWorkItem, {
|
|
22
|
+
emptyAsOf: now(),
|
|
23
|
+
provenance: stored,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
detail: (key) => workDetail(root, key, now),
|
|
27
|
+
async transcript(key, groupId) {
|
|
28
|
+
const id = decodeWorkItemId(key);
|
|
29
|
+
if (id === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
const work = await root.projections.read('work', id);
|
|
32
|
+
if (work === null || work.value === null)
|
|
33
|
+
return undefined;
|
|
34
|
+
return readWorkTranscript(root.transcriptStore, id, groupId, await runsForWorkItem(root, id)).then(async (data) => ({ data, meta: await projectionMeta(root.journal, [], now()) }));
|
|
35
|
+
},
|
|
36
|
+
async freeze(key, command) {
|
|
37
|
+
const id = decodeWorkItemId(key);
|
|
38
|
+
if (id === undefined)
|
|
39
|
+
throw new Error('Work item not found');
|
|
40
|
+
await root.work.freeze(id, commandContext(command.idempotencyKey, now));
|
|
41
|
+
return accepted(command.idempotencyKey, now());
|
|
42
|
+
},
|
|
43
|
+
async unfreeze(key, command) {
|
|
44
|
+
const id = decodeWorkItemId(key);
|
|
45
|
+
if (id === undefined)
|
|
46
|
+
throw new Error('Work item not found');
|
|
47
|
+
await root.work.unfreeze(id, commandContext(command.idempotencyKey, now));
|
|
48
|
+
return accepted(command.idempotencyKey, now());
|
|
49
|
+
},
|
|
50
|
+
async delete(key, command) {
|
|
51
|
+
const id = decodeWorkItemId(key);
|
|
52
|
+
if (id === undefined)
|
|
53
|
+
throw new Error('Work item not found');
|
|
54
|
+
const context = commandContext(command.idempotencyKey, now);
|
|
55
|
+
const correlations = await root.resources.correlationsForWork(id);
|
|
56
|
+
await root.work.delete(id, context);
|
|
57
|
+
await Promise.all(correlations.map((entry) => root.resources.retract(entry.resourceId, id, context)));
|
|
58
|
+
return accepted(command.idempotencyKey, now());
|
|
59
|
+
},
|
|
60
|
+
async retry(key, command) {
|
|
61
|
+
const id = decodeWorkItemId(key);
|
|
62
|
+
if (id === undefined)
|
|
63
|
+
return retryIneligible('Work item was not found');
|
|
64
|
+
const work = await root.work.get(id);
|
|
65
|
+
if (work === null)
|
|
66
|
+
return retryIneligible('Work item was not found');
|
|
67
|
+
if (work.deleted === true)
|
|
68
|
+
return retryIneligible('Work item is deleted');
|
|
69
|
+
if (work.state !== WorkStatus.Open)
|
|
70
|
+
return retryIneligible('Work item is not open');
|
|
71
|
+
const primary = (await root.orchestration.listAll()).find((value) => value.workItemId === id && value.parentWorkflowInstanceId === undefined);
|
|
72
|
+
if (primary === undefined)
|
|
73
|
+
return retryIneligible('Work item has no primary workflow');
|
|
74
|
+
if (!isOperatorRetryEligible(primary))
|
|
75
|
+
return retryIneligible('Workflow is not retry eligible');
|
|
76
|
+
try {
|
|
77
|
+
await root.orchestration.retryBlockedFailedStage(primary.workflowInstanceId, commandContext(command.idempotencyKey, now));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error instanceof OperatorRetryIneligibleError)
|
|
81
|
+
return retryIneligible(error.message);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
return accepted(command.idempotencyKey, now());
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async function workDetail(root, key, now) {
|
|
89
|
+
const id = decodeWorkItemId(key);
|
|
90
|
+
if (id === undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const work = await root.work.get(id);
|
|
93
|
+
if (work === null)
|
|
94
|
+
return undefined;
|
|
95
|
+
const correlations = await root.resources.correlationsForWork(id);
|
|
96
|
+
const resources = (await Promise.all(correlations.map((item) => root.resources.get(item.resourceId)))).filter((value) => value !== null);
|
|
97
|
+
const workflows = (await root.orchestration.listAll()).filter((value) => value.workItemId === id);
|
|
98
|
+
const runs = await runsForWorkItem(root, id, workflows);
|
|
99
|
+
const pullRequests = await root.projections.list('activities-pr');
|
|
100
|
+
const pullRequest = pullRequests.find((entry) => resources.some((resource) => resource.resourceId === entry.key));
|
|
101
|
+
const primary = workflows.find((value) => value.parentWorkflowInstanceId === undefined) ?? null;
|
|
102
|
+
const externalRef = await primaryExternalRef(root, work.workItemId);
|
|
103
|
+
const data = {
|
|
104
|
+
work: { ...presentWorkItem(work), ...(externalRef === undefined ? {} : { externalRef }) },
|
|
105
|
+
resources: resources.map(presentResource(root.resolveResourceLink)),
|
|
106
|
+
orchestration: {
|
|
107
|
+
primary: primary === null ? null : presentWorkflowInstance(primary),
|
|
108
|
+
children: workflows
|
|
109
|
+
.filter((value) => value.parentWorkflowInstanceId !== undefined)
|
|
110
|
+
.map(presentWorkflowInstance),
|
|
111
|
+
},
|
|
112
|
+
execution: {
|
|
113
|
+
runs: await Promise.all(runs.map((run) => withWorkflowContext(root, presentRun(run)))),
|
|
114
|
+
transcriptGroups: await transcriptGroups(root.transcriptStore, id, runs),
|
|
115
|
+
},
|
|
116
|
+
activities: presentPullRequest(pullRequest?.value),
|
|
117
|
+
};
|
|
118
|
+
const [projections, correlationFacts] = await Promise.all([
|
|
119
|
+
contributingProjections(root, id, resources, workflows, runs),
|
|
120
|
+
contributingResourceCorrelationFacts(root, id),
|
|
121
|
+
]);
|
|
122
|
+
return {
|
|
123
|
+
data,
|
|
124
|
+
meta: await projectionMeta(root.journal, [...projections, ...correlationFacts, ...(pullRequest === undefined ? [] : [pullRequest])], now()),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async function runsForWorkItem(root, id, workflows) {
|
|
128
|
+
const matching = workflows ??
|
|
129
|
+
(await root.projections.list('orchestration'))
|
|
130
|
+
.flatMap((entry) => (entry.value.view === null ? [] : [entry.value.view]))
|
|
131
|
+
.filter((workflow) => workflow.workItemId === id);
|
|
132
|
+
return (await root.projections.list('execution'))
|
|
133
|
+
.flatMap((entry) => (entry.value.view === null ? [] : [entry.value.view]))
|
|
134
|
+
.filter((run) => matching.some((workflow) => workflow.workflowInstanceId === run.workflowInstanceId))
|
|
135
|
+
.sort((left, right) => right.startedAt.localeCompare(left.startedAt));
|
|
136
|
+
}
|
|
137
|
+
function decodeWorkItemId(key) {
|
|
138
|
+
try {
|
|
139
|
+
return workItemId(fromWorkItemKey(key));
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function presentPullRequest(value) {
|
|
146
|
+
return value == null
|
|
147
|
+
? {}
|
|
148
|
+
: {
|
|
149
|
+
pullRequest: {
|
|
150
|
+
resourceId: value.resourceId,
|
|
151
|
+
state: value.state,
|
|
152
|
+
headRevision: value.headRevision,
|
|
153
|
+
baseRevision: value.baseRevision,
|
|
154
|
+
checks: value.checks,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function contributingProjections(root, id, resources, workflows, runs) {
|
|
159
|
+
const records = await Promise.all([
|
|
160
|
+
root.projections.read('work', id),
|
|
161
|
+
...resources.map((value) => root.projections.read('resources', value.resourceId)),
|
|
162
|
+
...workflows.map((value) => root.projections.read('orchestration', value.workflowInstanceId)),
|
|
163
|
+
...runs.map((value) => root.projections.read('execution', value.runId)),
|
|
164
|
+
]);
|
|
165
|
+
return records.filter((value) => value !== null);
|
|
166
|
+
}
|
|
167
|
+
async function contributingResourceCorrelationFacts(root, id) {
|
|
168
|
+
const events = await root.journal.readAll(0);
|
|
169
|
+
return events.flatMap((event) => {
|
|
170
|
+
const owned = selectResourceEvent(event);
|
|
171
|
+
if (owned === null)
|
|
172
|
+
return [];
|
|
173
|
+
if (owned.eventType !== ResourceEventType.WorkCorrelationEstablished &&
|
|
174
|
+
owned.eventType !== ResourceEventType.WorkCorrelationRetracted &&
|
|
175
|
+
owned.eventType !== ResourceEventType.WorkCorrelationConflicted)
|
|
176
|
+
return [];
|
|
177
|
+
return owned.payload.workItemId === id ? [{ lastGlobalPosition: owned.globalPosition }] : [];
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function commandContext(idempotencyKey, now) {
|
|
181
|
+
const occurredAt = now();
|
|
182
|
+
return {
|
|
183
|
+
commandId: `work:${idempotencyKey}`,
|
|
184
|
+
correlationId: correlationId(`work:${idempotencyKey}`),
|
|
185
|
+
occurredAt,
|
|
186
|
+
actor: { kind: EventActorKind.Operator, id: 'web' },
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function accepted(idempotencyKey, acceptedAt) {
|
|
190
|
+
return {
|
|
191
|
+
commandId: `work:${idempotencyKey}`,
|
|
192
|
+
idempotencyKey,
|
|
193
|
+
acceptedAt,
|
|
194
|
+
status: ApiCommandStatus.Accepted,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function retryIneligible(detail) {
|
|
198
|
+
return { conflict: true, code: 'retry-ineligible', detail };
|
|
199
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createSurfaceApiApplications } from './surface-api-applications.js';
|
|
2
|
+
import { createSurfaceCliApplications } from './surface-cli-applications.js';
|
|
3
|
+
export function createSurfaceApplications(root, options = {}) {
|
|
4
|
+
const now = options.now ?? (() => new Date().toISOString());
|
|
5
|
+
const api = createSurfaceApiApplications(root, now);
|
|
6
|
+
return { api, cli: createSurfaceCliApplications(root, api, now) };
|
|
7
|
+
}
|