@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,382 @@
|
|
|
1
|
+
import { ActivityRegistry, agentActivityDefinition, createAgentActivity, createPullRequestApproveActivity, createPullRequestMergeActivity, createPullRequestService, } from '../activities/index.js';
|
|
2
|
+
import { ControlStreamKind, DispatchPolicy, ScheduleService, createAdvanceOnce, createControlPlaneService, createIntakePipeline, createRunnerControlService, createRunnerPipeline, createWorkCancellationPolicy, ineligibleRunners, } from '../control-plane/index.js';
|
|
3
|
+
import { ExternalExecutionState, GitWorkspaceProvider, RecoveryService, RunRepository, TranscriptStore, createExecutionService, loadPromptTemplate, renderPromptTemplate, } from '../execution/index.js';
|
|
4
|
+
import { AgentRunPublicationReactor, ArtifactRegistrationReactor, DeliveryOutcomeReactor, DeliveryService, IntegrationStreamKind, PollService, ProviderRegistry, fakeProviderDefinition, } from '../integrations/index.js';
|
|
5
|
+
import { EventActorKind, SystemClock, UlidIdGenerator, } from '../kernel/index.js';
|
|
6
|
+
import { compileWorkflow, compileWorkflowSelectors, createOrchestrationService, createWatchReactor, selectWorkflow, workflowName, } from '../orchestration/index.js';
|
|
7
|
+
import { FileCheckpointStore, FileEventJournal, FileProjectionStore, } from '../persistence/index.js';
|
|
8
|
+
import { createResourceLookup, createResourceService, resourceId, } from '../resources/index.js';
|
|
9
|
+
// The shared Integration barrel must not re-export a provider namespace
|
|
10
|
+
// (see provider-locality); composition-root is the exempt production
|
|
11
|
+
// composition point that is allowed to name it directly.
|
|
12
|
+
import { createGitHubAgentContextReader, gitHubProviderDefinition, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
|
|
13
|
+
import { WorkStatus, createWorkService } from '../work/index.js';
|
|
14
|
+
import { loadConfig } from './config/load-config.js';
|
|
15
|
+
import { hydrateFakeProviderEvidence } from './fake-provider-files.js';
|
|
16
|
+
import { loadFakeScenarios } from './fake-scenarios.js';
|
|
17
|
+
import { resolveWakePaths } from './paths.js';
|
|
18
|
+
import { createRuntimeProjectionRunner } from './projection-runtime.js';
|
|
19
|
+
import { createRunnerQuotaReporter } from './runner-quota-reporter.js';
|
|
20
|
+
import { createRunnerRegistry } from './runner-registry.js';
|
|
21
|
+
import { FileScheduleCheckpointStore } from './schedule-checkpoint-store.js';
|
|
22
|
+
import { createStatusPublishActivity } from './status-publish-activity.js';
|
|
23
|
+
import { createUpdateMaintenanceLease, } from './update-maintenance-lease.js';
|
|
24
|
+
const resourceLinkResolvers = {
|
|
25
|
+
github: resolveGitHubResourceUrl,
|
|
26
|
+
};
|
|
27
|
+
function resolveResourceLink(externalKey) {
|
|
28
|
+
return resourceLinkResolvers[externalKey.adapter]?.(externalKey) ?? null;
|
|
29
|
+
}
|
|
30
|
+
// Composition is deliberately the one place that assembles every module.
|
|
31
|
+
// eslint-disable-next-line complexity
|
|
32
|
+
export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
33
|
+
const config = options.config ?? (await loadConfig(wakeRoot));
|
|
34
|
+
const fakeScenarios = await loadFakeScenarios(wakeRoot);
|
|
35
|
+
const paths = resolveWakePaths(wakeRoot);
|
|
36
|
+
const maintenance = createUpdateMaintenanceLease(paths.wakeRoot);
|
|
37
|
+
const clock = options.clock ?? new SystemClock();
|
|
38
|
+
const ids = new UlidIdGenerator();
|
|
39
|
+
const { journal, projections, checkpoints } = composePersistence(paths, clock, options);
|
|
40
|
+
const work = createWorkService(journal);
|
|
41
|
+
const lookup = createResourceLookup({ journal, projections });
|
|
42
|
+
const resources = createResourceService(journal, lookup);
|
|
43
|
+
const pullRequests = createPullRequestService(journal, work, resources);
|
|
44
|
+
const activities = options.activities ?? createBuiltInActivityRegistry(journal, pullRequests, resources, wakeRoot);
|
|
45
|
+
const definitions = Object.fromEntries(Object.entries(config.orchestration.workflows).map(([name, definition]) => [
|
|
46
|
+
name,
|
|
47
|
+
compileWorkflow(name, definition, activities, Object.keys(config.orchestration.workflows)),
|
|
48
|
+
]));
|
|
49
|
+
const orchestration = createOrchestrationService(journal, work, definitions);
|
|
50
|
+
const workspaces = new GitWorkspaceProvider(paths.workspacesRoot, {
|
|
51
|
+
async cloneLocator(id) {
|
|
52
|
+
const resource = await resources.get(resourceId(id));
|
|
53
|
+
const match = resource === null ? null : /^([^/]+\/[^#]+)#\d+$/.exec(resource.externalKey.key);
|
|
54
|
+
if (match === null)
|
|
55
|
+
throw new Error('Workspace resource ' + id + ' does not identify a GitHub repository');
|
|
56
|
+
return 'https://github.com/' + match[1] + '.git';
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const transcriptStore = config.transcripts.enabled
|
|
60
|
+
? (options.transcriptStore ?? new TranscriptStore(paths.transcriptsRoot))
|
|
61
|
+
: undefined;
|
|
62
|
+
const execution = createExecutionService(journal, activities, config.execution, {
|
|
63
|
+
clock,
|
|
64
|
+
ids,
|
|
65
|
+
runners: createRunnerRegistry(config.execution, fakeScenarios, options.decorateRunner),
|
|
66
|
+
reportRunnerQuota: createRunnerQuotaReporter(journal, clock, ids),
|
|
67
|
+
...(transcriptStore !== undefined
|
|
68
|
+
? {
|
|
69
|
+
transcriptRecorder: transcriptStore,
|
|
70
|
+
logOperationalError(error) {
|
|
71
|
+
console.error('Transcript capture failed', error);
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
workspaces,
|
|
76
|
+
});
|
|
77
|
+
const recovery = new RecoveryService(journal, clock, {
|
|
78
|
+
async inspect() {
|
|
79
|
+
// Runner adapters do not yet expose a portable process-inspection API.
|
|
80
|
+
// Preserve safety on restart: unknown external work is reconciled through
|
|
81
|
+
// the existing ambiguity path rather than being guessed as absent.
|
|
82
|
+
return {
|
|
83
|
+
kind: ExternalExecutionState.Unknown,
|
|
84
|
+
reason: 'External execution inspection is not configured for this runtime',
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
}, activities, config.execution, orchestration);
|
|
88
|
+
const controlPlane = createControlPlaneService({ journal, clock, ids });
|
|
89
|
+
const isRuntimePaused = async () => (await controlPlane.isPaused()) || (await maintenanceBlocksRuntime(maintenance));
|
|
90
|
+
const runnerControls = createRunnerControlService({
|
|
91
|
+
journal,
|
|
92
|
+
clock,
|
|
93
|
+
ids,
|
|
94
|
+
runners: new Set(Object.values(config.execution.runnerPools).flat()),
|
|
95
|
+
});
|
|
96
|
+
const advanceOnce = createAdvanceOnce(orchestration, {
|
|
97
|
+
...execution,
|
|
98
|
+
recoverActive: (owner) => recovery.recoverActive(owner, execution.isLocallyActive),
|
|
99
|
+
}, resources, clock, {
|
|
100
|
+
ids,
|
|
101
|
+
dispatchPolicy: new DispatchPolicy({ maxDispatches: config.controlPlane.maxDispatches }),
|
|
102
|
+
isDispatchPaused: isRuntimePaused,
|
|
103
|
+
workspaceRecovery: workspaces,
|
|
104
|
+
work,
|
|
105
|
+
...(transcriptStore === undefined
|
|
106
|
+
? {}
|
|
107
|
+
: {
|
|
108
|
+
transcriptRetention: {
|
|
109
|
+
async markClosedWorkItem(workItemId) {
|
|
110
|
+
try {
|
|
111
|
+
await transcriptStore.markWorkItemCleaned(workItemId, config.transcripts.retentionMs, clock.now().toISOString());
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('Transcript retention failed', error);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async sweep() {
|
|
120
|
+
try {
|
|
121
|
+
await transcriptStore.sweepExpired(config.transcripts.retentionMs, clock.now().toISOString(), (_workItemId, error) => console.error('Transcript retention failed', error));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('Transcript retention failed', error);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
closedWorkItemIds: () => closedWorkItemIds(projections),
|
|
129
|
+
}),
|
|
130
|
+
runnerIneligibility: async () => {
|
|
131
|
+
const stored = await projections.read(ControlStreamKind.Global, 'global');
|
|
132
|
+
return stored === null
|
|
133
|
+
? new Set()
|
|
134
|
+
: ineligibleRunners(stored.value, clock.now().toISOString());
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const runtime = await composeIntegrationRuntime({
|
|
138
|
+
config,
|
|
139
|
+
journal,
|
|
140
|
+
projections,
|
|
141
|
+
checkpoints,
|
|
142
|
+
resources,
|
|
143
|
+
lookup,
|
|
144
|
+
pullRequests,
|
|
145
|
+
orchestration,
|
|
146
|
+
execution,
|
|
147
|
+
...(transcriptStore === undefined ? {} : { transcriptStore }),
|
|
148
|
+
advanceOnce,
|
|
149
|
+
controlPlane,
|
|
150
|
+
isPaused: isRuntimePaused,
|
|
151
|
+
clock,
|
|
152
|
+
work,
|
|
153
|
+
ids,
|
|
154
|
+
wakeRoot,
|
|
155
|
+
scheduleCheckpoints: options.scheduleCheckpoints ?? new FileScheduleCheckpointStore(paths.dataRoot),
|
|
156
|
+
...(options.decorateDeliveryAdapter === undefined
|
|
157
|
+
? {}
|
|
158
|
+
: { decorateDeliveryAdapter: options.decorateDeliveryAdapter }),
|
|
159
|
+
...(options.fakeDeliveryProvider === undefined
|
|
160
|
+
? {}
|
|
161
|
+
: { fakeDeliveryProvider: options.fakeDeliveryProvider }),
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
config,
|
|
165
|
+
fakeScenarios,
|
|
166
|
+
paths,
|
|
167
|
+
maintenance,
|
|
168
|
+
journal,
|
|
169
|
+
projections,
|
|
170
|
+
checkpoints,
|
|
171
|
+
activities,
|
|
172
|
+
work,
|
|
173
|
+
resources,
|
|
174
|
+
lookup,
|
|
175
|
+
orchestration,
|
|
176
|
+
execution,
|
|
177
|
+
...(transcriptStore === undefined ? {} : { transcriptStore }),
|
|
178
|
+
runnerControls,
|
|
179
|
+
controlPlane,
|
|
180
|
+
isPaused: isRuntimePaused,
|
|
181
|
+
advanceOnce,
|
|
182
|
+
resolveResourceLink,
|
|
183
|
+
...runtime,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function maintenanceBlocksRuntime(maintenance) {
|
|
187
|
+
return (await maintenance.read()) !== null;
|
|
188
|
+
}
|
|
189
|
+
async function closedWorkItemIds(projections) {
|
|
190
|
+
return (await projections.list('work')).flatMap(({ value }) => value?.state === WorkStatus.Closed ? [value.workItemId] : []);
|
|
191
|
+
}
|
|
192
|
+
function serializeRunRegisteredOnce(runner) {
|
|
193
|
+
let queue = Promise.resolve();
|
|
194
|
+
const runRegisteredOnce = runner.runRegisteredOnce.bind(runner);
|
|
195
|
+
runner.runRegisteredOnce = (limit) => {
|
|
196
|
+
const result = queue.then(() => runRegisteredOnce(limit));
|
|
197
|
+
queue = result.catch(() => { });
|
|
198
|
+
return result;
|
|
199
|
+
};
|
|
200
|
+
return runner;
|
|
201
|
+
}
|
|
202
|
+
async function composeIntegrationRuntime(input) {
|
|
203
|
+
const registry = new ProviderRegistry();
|
|
204
|
+
registry.register(fakeProviderDefinition);
|
|
205
|
+
registry.register(gitHubProviderDefinition);
|
|
206
|
+
const { instances, failures: providerFailures } = registry.compose(await hydrateFakeProviderEvidence(input.wakeRoot, input.config.integrations), {
|
|
207
|
+
work: input.work,
|
|
208
|
+
resources: input.resources,
|
|
209
|
+
resourceLookup: input.lookup,
|
|
210
|
+
pullRequests: input.pullRequests,
|
|
211
|
+
runs: new RunRepository(input.journal),
|
|
212
|
+
orchestration: input.orchestration,
|
|
213
|
+
ids: input.ids,
|
|
214
|
+
clock: input.clock,
|
|
215
|
+
journal: input.journal,
|
|
216
|
+
checkpoints: input.checkpoints,
|
|
217
|
+
routing: createWorkflowRouter(input.config.orchestration),
|
|
218
|
+
conclusion: createWorkCancellationPolicy(input.work, input.orchestration, input.execution, input.clock, input.ids),
|
|
219
|
+
});
|
|
220
|
+
const composedProviders = input.fakeDeliveryProvider === undefined
|
|
221
|
+
? instances
|
|
222
|
+
: instances.map((provider) => provider.adapter === 'fake'
|
|
223
|
+
? { ...provider, delivery: input.fakeDeliveryProvider }
|
|
224
|
+
: provider);
|
|
225
|
+
const providers = input.decorateDeliveryAdapter
|
|
226
|
+
? composedProviders.map((provider) => ({
|
|
227
|
+
...provider,
|
|
228
|
+
delivery: input.decorateDeliveryAdapter(provider.delivery, provider),
|
|
229
|
+
}))
|
|
230
|
+
: composedProviders;
|
|
231
|
+
// FileCheckpointStore.save throws on any regression (persistence/filesystem/
|
|
232
|
+
// file-checkpoint-store.ts), so two concurrent runRegisteredOnce calls that
|
|
233
|
+
// interleave can race a slower caller's stale checkpoint save against a
|
|
234
|
+
// faster one that already advanced past it. Every caller (the tick
|
|
235
|
+
// pipeline's own catchUpProjections, the API's manual tick, and the
|
|
236
|
+
// resident's standalone projection pump) shares this one instance, so
|
|
237
|
+
// serializing it here in-process covers all of them without a file lock.
|
|
238
|
+
const projectionRunner = serializeRunRegisteredOnce(createRuntimeProjectionRunner(input.journal, input.projections, input.checkpoints));
|
|
239
|
+
const delivery = new DeliveryService({
|
|
240
|
+
journal: input.journal,
|
|
241
|
+
intents: async () => (await input.projections.list(IntegrationStreamKind.Delivery)).map(({ value }) => value),
|
|
242
|
+
resource: async (id) => {
|
|
243
|
+
const resource = await input.resources.get(resourceId(id));
|
|
244
|
+
return resource === null
|
|
245
|
+
? null
|
|
246
|
+
: { resourceId: resource.resourceId, adapter: resource.externalKey.adapter };
|
|
247
|
+
},
|
|
248
|
+
adapter: (name) => {
|
|
249
|
+
const provider = providers.find((candidate) => candidate.adapter === name);
|
|
250
|
+
if (provider === undefined)
|
|
251
|
+
throw new Error(`Delivery provider ${name} is not configured`);
|
|
252
|
+
return provider.delivery;
|
|
253
|
+
},
|
|
254
|
+
now: () => input.clock.now().toISOString(),
|
|
255
|
+
});
|
|
256
|
+
const schedules = new ScheduleService({
|
|
257
|
+
checkpoint: input.scheduleCheckpoints,
|
|
258
|
+
ids: input.ids,
|
|
259
|
+
work: input.work,
|
|
260
|
+
orchestration: input.orchestration,
|
|
261
|
+
now: () => input.clock.now().toISOString(),
|
|
262
|
+
});
|
|
263
|
+
const artifacts = new ArtifactRegistrationReactor({
|
|
264
|
+
journal: input.journal,
|
|
265
|
+
checkpoints: input.checkpoints,
|
|
266
|
+
resources: input.resources,
|
|
267
|
+
ids: input.ids,
|
|
268
|
+
providers,
|
|
269
|
+
runs: input.execution,
|
|
270
|
+
});
|
|
271
|
+
const runs = new RunRepository(input.journal);
|
|
272
|
+
const agentRunPublications = new AgentRunPublicationReactor({
|
|
273
|
+
journal: input.journal,
|
|
274
|
+
checkpoints: input.checkpoints,
|
|
275
|
+
runs,
|
|
276
|
+
resources: input.resources,
|
|
277
|
+
orchestration: input.orchestration,
|
|
278
|
+
});
|
|
279
|
+
const watch = createWatchReactor(input.orchestration, input.journal, input.checkpoints, runs);
|
|
280
|
+
const outcomes = new DeliveryOutcomeReactor(input.journal, input.checkpoints, input.orchestration);
|
|
281
|
+
const catchUpProjections = async () => {
|
|
282
|
+
await projectionRunner.runRegisteredOnce();
|
|
283
|
+
};
|
|
284
|
+
// Only poll hits a rate-limited external API, so only this half of the
|
|
285
|
+
// tick needs a backing-off host — see bootstrap/surface-cli-applications.ts.
|
|
286
|
+
const intakePipeline = createIntakePipeline({
|
|
287
|
+
isPaused: input.isPaused,
|
|
288
|
+
catchUpProjections,
|
|
289
|
+
poll: async (signal) => {
|
|
290
|
+
let appended = 0;
|
|
291
|
+
for (const provider of providers)
|
|
292
|
+
appended += await new PollService(input.journal, provider).pollOnce(signal);
|
|
293
|
+
return appended;
|
|
294
|
+
},
|
|
295
|
+
translateInbound: async () => {
|
|
296
|
+
let translated = 0;
|
|
297
|
+
for (const provider of providers)
|
|
298
|
+
translated += await provider.inbound.runOnce();
|
|
299
|
+
return translated;
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
const runnerPipeline = createRunnerPipeline({
|
|
303
|
+
isPaused: input.isPaused,
|
|
304
|
+
catchUpProjections,
|
|
305
|
+
runSchedules: async () => {
|
|
306
|
+
for (const schedule of input.config.controlPlane.schedules)
|
|
307
|
+
await schedules.run(schedule, {
|
|
308
|
+
commandId: input.ids.next('command'),
|
|
309
|
+
correlationId: 'schedule-tick',
|
|
310
|
+
occurredAt: input.clock.now().toISOString(),
|
|
311
|
+
actor: { kind: EventActorKind.System, id: ControlStreamKind.Global },
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
react: async () => {
|
|
315
|
+
await watch.runOnce();
|
|
316
|
+
await artifacts.runOnce();
|
|
317
|
+
await outcomes.runOnce();
|
|
318
|
+
for (const provider of providers)
|
|
319
|
+
await provider.maintenance?.runOnce();
|
|
320
|
+
},
|
|
321
|
+
advance: input.advanceOnce,
|
|
322
|
+
publishAgentRuns: async () => {
|
|
323
|
+
await agentRunPublications.runOnce();
|
|
324
|
+
},
|
|
325
|
+
deliver: async (signal) => {
|
|
326
|
+
await delivery.deliverNext(signal);
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
projectionRunner,
|
|
331
|
+
providers,
|
|
332
|
+
providerFailures,
|
|
333
|
+
delivery,
|
|
334
|
+
intakePipeline,
|
|
335
|
+
runnerPipeline,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function identity(value) {
|
|
339
|
+
return value;
|
|
340
|
+
}
|
|
341
|
+
function composePersistence(paths, clock, options) {
|
|
342
|
+
return {
|
|
343
|
+
journal: (options.decorateJournal ?? identity)(options.journal ?? new FileEventJournal(paths.dataRoot, clock)),
|
|
344
|
+
projections: (options.decorateProjections ?? identity)(options.projections ?? new FileProjectionStore(paths.dataRoot)),
|
|
345
|
+
checkpoints: (options.decorateCheckpoints ?? identity)(options.checkpoints ?? new FileCheckpointStore(paths.dataRoot)),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function createBuiltInActivityRegistry(journal, pullRequests, resources, wakeRoot) {
|
|
349
|
+
const activities = new ActivityRegistry();
|
|
350
|
+
const contextReader = createGitHubAgentContextReader(journal, resources);
|
|
351
|
+
activities.register({
|
|
352
|
+
...agentActivityDefinition,
|
|
353
|
+
handler: createAgentActivity({
|
|
354
|
+
async render(name, context) {
|
|
355
|
+
const template = await loadPromptTemplate(wakeRoot, name);
|
|
356
|
+
return {
|
|
357
|
+
prompt: renderPromptTemplate(template, context),
|
|
358
|
+
...(template.frontmatter.model === undefined || template.frontmatter.model === null
|
|
359
|
+
? {}
|
|
360
|
+
: { model: template.frontmatter.model }),
|
|
361
|
+
...(template.frontmatter.allowedTools === undefined ||
|
|
362
|
+
template.frontmatter.allowedTools === null
|
|
363
|
+
? {}
|
|
364
|
+
: { allowedTools: template.frontmatter.allowedTools }),
|
|
365
|
+
...(template.frontmatter.maxTurns === undefined
|
|
366
|
+
? {}
|
|
367
|
+
: { maxTurns: template.frontmatter.maxTurns }),
|
|
368
|
+
};
|
|
369
|
+
},
|
|
370
|
+
}, contextReader),
|
|
371
|
+
});
|
|
372
|
+
activities.register(createStatusPublishActivity(journal));
|
|
373
|
+
activities.register(createPullRequestApproveActivity(journal, pullRequests));
|
|
374
|
+
activities.register(createPullRequestMergeActivity(journal, pullRequests));
|
|
375
|
+
return activities;
|
|
376
|
+
}
|
|
377
|
+
// Configuration is the only routing authority: adapters ask, they never propose.
|
|
378
|
+
function createWorkflowRouter(orchestration) {
|
|
379
|
+
const selectors = compileWorkflowSelectors(orchestration.workflowSelectors);
|
|
380
|
+
const fallback = workflowName(orchestration.default);
|
|
381
|
+
return { select: (candidate) => selectWorkflow(candidate, selectors, fallback) };
|
|
382
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import YAML from 'yaml';
|
|
4
|
+
import { parseRootConfig } from './root-schema.js';
|
|
5
|
+
export async function loadConfig(wakeRoot) {
|
|
6
|
+
const main = await readYaml(join(wakeRoot, 'config.yaml'));
|
|
7
|
+
const workflows = await readYamlIfPresent(join(wakeRoot, 'config.workflows.yaml'));
|
|
8
|
+
const merged = merge(main, workflows === undefined ? {} : normalizeWorkflowFile(workflows));
|
|
9
|
+
try {
|
|
10
|
+
return parseRootConfig(merged);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error instanceof Error && 'issues' in error) {
|
|
14
|
+
const issues = error.issues;
|
|
15
|
+
throw new Error(`Configuration validation failed: ${issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ')}`, { cause: error });
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function readYaml(path) {
|
|
21
|
+
return YAML.parse(await readFile(path, 'utf8')) ?? {};
|
|
22
|
+
}
|
|
23
|
+
async function readYamlIfPresent(path) {
|
|
24
|
+
try {
|
|
25
|
+
return await readYaml(path);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code === 'ENOENT')
|
|
29
|
+
return undefined;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function normalizeWorkflowFile(value) {
|
|
34
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
35
|
+
return value;
|
|
36
|
+
const record = value;
|
|
37
|
+
return 'workflows' in record
|
|
38
|
+
? { orchestration: record }
|
|
39
|
+
: { orchestration: { workflows: record } };
|
|
40
|
+
}
|
|
41
|
+
function merge(left, right) {
|
|
42
|
+
if (!isRecord(left) || !isRecord(right))
|
|
43
|
+
return right;
|
|
44
|
+
const result = { ...left };
|
|
45
|
+
for (const [key, value] of Object.entries(right))
|
|
46
|
+
result[key] = key in result ? merge(result[key], value) : value;
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activitiesConfigSchema } from '../../activities/index.js';
|
|
3
|
+
import { controlPlaneConfigSchema } from '../../control-plane/index.js';
|
|
4
|
+
import { executionConfigSchema } from '../../execution/index.js';
|
|
5
|
+
import { integrationsConfigSchema } from '../../integrations/index.js';
|
|
6
|
+
import { workflowDefinitionConfigSchema, workflowSelectorConfigSchema, } from '../../orchestration/index.js';
|
|
7
|
+
import { resourcesConfigSchema } from '../../resources/index.js';
|
|
8
|
+
import { surfacesConfigSchema } from '../../surfaces/index.js';
|
|
9
|
+
import { workConfigSchema } from '../../work/index.js';
|
|
10
|
+
const orchestrationConfigSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
workflows: z.record(z.string().trim().min(1), workflowDefinitionConfigSchema).default({}),
|
|
13
|
+
workflowSelectors: z.array(workflowSelectorConfigSchema).readonly().default([]),
|
|
14
|
+
default: z.string().trim().min(1).default('default'),
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
// Routing may only name a workflow that exists; a root with no workflows configured
|
|
18
|
+
// routes nothing, so its unused fallback is not an error.
|
|
19
|
+
.superRefine((value, ctx) => {
|
|
20
|
+
const configured = new Set(Object.keys(value.workflows));
|
|
21
|
+
if (configured.size > 0 && !configured.has(value.default)) {
|
|
22
|
+
ctx.addIssue({
|
|
23
|
+
code: 'custom',
|
|
24
|
+
path: ['default'],
|
|
25
|
+
message: `default workflow "${value.default}" is not configured in orchestration.workflows`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
for (const [index, selector] of value.workflowSelectors.entries()) {
|
|
29
|
+
if (configured.has(selector.workflow))
|
|
30
|
+
continue;
|
|
31
|
+
ctx.addIssue({
|
|
32
|
+
code: 'custom',
|
|
33
|
+
path: ['workflowSelectors', index, 'workflow'],
|
|
34
|
+
message: `selector workflow "${selector.workflow}" is not configured in orchestration.workflows`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
.default({ workflows: {}, workflowSelectors: [], default: 'default' });
|
|
39
|
+
const transcriptsConfigSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
enabled: z.boolean().default(false),
|
|
42
|
+
retentionMs: z.number().int().nonnegative().default(86_400_000),
|
|
43
|
+
})
|
|
44
|
+
.strict()
|
|
45
|
+
.default({ enabled: false, retentionMs: 86_400_000 });
|
|
46
|
+
const hostConfigSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
sandbox: z
|
|
49
|
+
.object({
|
|
50
|
+
image: z.string().trim().min(1).default('wake-sandbox'),
|
|
51
|
+
imageRepository: z.string().trim().min(1).default('wake-sandbox'),
|
|
52
|
+
containerName: z.string().trim().min(1).default('wake-sandbox'),
|
|
53
|
+
wakeMountPath: z.string().trim().min(1).default('/wake'),
|
|
54
|
+
containerHomeMountPath: z.string().trim().min(1).default('/home/wake'),
|
|
55
|
+
start: z
|
|
56
|
+
.object({ enabled: z.boolean().default(true) })
|
|
57
|
+
.strict()
|
|
58
|
+
.default({ enabled: true }),
|
|
59
|
+
extraMounts: z
|
|
60
|
+
.array(z
|
|
61
|
+
.object({
|
|
62
|
+
source: z.string().trim().min(1),
|
|
63
|
+
target: z.string().trim().min(1),
|
|
64
|
+
readOnly: z.boolean().optional(),
|
|
65
|
+
})
|
|
66
|
+
.strict())
|
|
67
|
+
.readonly()
|
|
68
|
+
.default([]),
|
|
69
|
+
})
|
|
70
|
+
.strict()
|
|
71
|
+
.default({
|
|
72
|
+
image: 'wake-sandbox',
|
|
73
|
+
imageRepository: 'wake-sandbox',
|
|
74
|
+
containerName: 'wake-sandbox',
|
|
75
|
+
wakeMountPath: '/wake',
|
|
76
|
+
containerHomeMountPath: '/home/wake',
|
|
77
|
+
start: { enabled: true },
|
|
78
|
+
extraMounts: [],
|
|
79
|
+
}),
|
|
80
|
+
development: z
|
|
81
|
+
.object({
|
|
82
|
+
repoRoot: z.string().trim().min(1).optional(),
|
|
83
|
+
mode: z.enum(['source', 'packaged']).optional(),
|
|
84
|
+
})
|
|
85
|
+
.strict()
|
|
86
|
+
.default({}),
|
|
87
|
+
selfUpdate: z
|
|
88
|
+
.object({
|
|
89
|
+
drainTimeoutMs: z.number().int().positive().default(30_000),
|
|
90
|
+
cancellationTimeoutMs: z.number().int().positive().default(30_000),
|
|
91
|
+
})
|
|
92
|
+
.strict()
|
|
93
|
+
.default({ drainTimeoutMs: 30_000, cancellationTimeoutMs: 30_000 }),
|
|
94
|
+
})
|
|
95
|
+
.strict()
|
|
96
|
+
.default({
|
|
97
|
+
sandbox: {
|
|
98
|
+
image: 'wake-sandbox',
|
|
99
|
+
imageRepository: 'wake-sandbox',
|
|
100
|
+
containerName: 'wake-sandbox',
|
|
101
|
+
wakeMountPath: '/wake',
|
|
102
|
+
containerHomeMountPath: '/home/wake',
|
|
103
|
+
start: { enabled: true },
|
|
104
|
+
extraMounts: [],
|
|
105
|
+
},
|
|
106
|
+
development: {},
|
|
107
|
+
selfUpdate: { drainTimeoutMs: 30_000, cancellationTimeoutMs: 30_000 },
|
|
108
|
+
})
|
|
109
|
+
.superRefine((value, context) => {
|
|
110
|
+
if (value.development.mode === 'source' && value.development.repoRoot === undefined)
|
|
111
|
+
context.addIssue({
|
|
112
|
+
code: z.ZodIssueCode.custom,
|
|
113
|
+
path: ['development', 'repoRoot'],
|
|
114
|
+
message: 'source host development requires repoRoot',
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
export const rootConfigSchema = z
|
|
118
|
+
.object({
|
|
119
|
+
schemaVersion: z.literal(1).default(1),
|
|
120
|
+
work: workConfigSchema.default({}),
|
|
121
|
+
resources: resourcesConfigSchema.default({}),
|
|
122
|
+
activities: activitiesConfigSchema.default({}),
|
|
123
|
+
orchestration: orchestrationConfigSchema,
|
|
124
|
+
transcripts: transcriptsConfigSchema,
|
|
125
|
+
execution: executionConfigSchema,
|
|
126
|
+
controlPlane: controlPlaneConfigSchema,
|
|
127
|
+
integrations: integrationsConfigSchema,
|
|
128
|
+
surfaces: surfacesConfigSchema,
|
|
129
|
+
host: hostConfigSchema,
|
|
130
|
+
})
|
|
131
|
+
.strict();
|
|
132
|
+
export function parseRootConfig(input) {
|
|
133
|
+
return rootConfigSchema.parse(input);
|
|
134
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResourceCorrelationRole } from '../resources/index.js';
|
|
2
|
+
import { workItemId } from '../work/index.js';
|
|
3
|
+
// Work items never embed a provider/repo/issue number (see docs/adrs/0001); this joins
|
|
4
|
+
// the primary correlated resource's adapter-formatted key at the presentation layer only.
|
|
5
|
+
export async function primaryExternalRef(root, rawWorkItemId) {
|
|
6
|
+
const correlations = await root.resources.correlationsForWork(workItemId(rawWorkItemId));
|
|
7
|
+
const primary = correlations.find((value) => value.role === ResourceCorrelationRole.Primary);
|
|
8
|
+
if (primary === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
const resource = await root.resources.get(primary.resourceId);
|
|
11
|
+
return resource?.externalKey.key;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const fakeFileConfigSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
provider: z.literal('fake'),
|
|
7
|
+
evidenceFile: z.string().min(1),
|
|
8
|
+
effectsFile: z.string().min(1).optional(),
|
|
9
|
+
})
|
|
10
|
+
.passthrough();
|
|
11
|
+
/** Resolves fake-provider evidence files before providers are composed. */
|
|
12
|
+
export async function hydrateFakeProviderEvidence(wakeRoot, integrations) {
|
|
13
|
+
const entries = await Promise.all(Object.entries(integrations).map(async ([name, entry]) => {
|
|
14
|
+
const parsed = fakeFileConfigSchema.safeParse(entry);
|
|
15
|
+
if (!parsed.success)
|
|
16
|
+
return [name, entry];
|
|
17
|
+
const events = JSON.parse(await readFile(join(wakeRoot, parsed.data.evidenceFile), 'utf8'));
|
|
18
|
+
const effectsPath = parsed.data.effectsFile === undefined ? undefined : join(wakeRoot, parsed.data.effectsFile);
|
|
19
|
+
const deliveryEffects = effectsPath === undefined ? {} : await readEffectsFile(effectsPath);
|
|
20
|
+
return [
|
|
21
|
+
name,
|
|
22
|
+
{
|
|
23
|
+
...entry,
|
|
24
|
+
events,
|
|
25
|
+
deliveryEffects,
|
|
26
|
+
...(effectsPath === undefined ? {} : { effectsFile: effectsPath }),
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}));
|
|
30
|
+
return Object.fromEntries(entries);
|
|
31
|
+
}
|
|
32
|
+
async function readEffectsFile(path) {
|
|
33
|
+
try {
|
|
34
|
+
return z.record(z.string(), z.string()).parse(JSON.parse(await readFile(path, 'utf8')));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (isMissingFile(error))
|
|
38
|
+
return {};
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isMissingFile(error) {
|
|
43
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
|
|
44
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import YAML from 'yaml';
|
|
4
|
+
import { emptyFakeScenarios, parseFakeScenarios, } from '../execution/index.js';
|
|
5
|
+
export async function loadFakeScenarios(wakeRoot) {
|
|
6
|
+
const path = join(wakeRoot, 'fake-scenarios.yaml');
|
|
7
|
+
let source;
|
|
8
|
+
try {
|
|
9
|
+
source = await readFile(path, 'utf8');
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error.code === 'ENOENT')
|
|
13
|
+
return emptyFakeScenarios;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
return parseFakeScenarios(YAML.parse(source) ?? {});
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error(`Fake scenario configuration validation failed in fake-scenarios.yaml: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
21
|
+
}
|
|
22
|
+
}
|