@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
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { waitForActiveRuns } from './stop-command.js';
|
|
2
|
-
import { resolveWakeVersion } from '../version.js';
|
|
3
|
-
const HEALTHCHECK_WAKE_ROOT = '/tmp/wake-self-update-healthcheck';
|
|
4
|
-
const START_PROCESS_CHECK_ATTEMPTS = 15;
|
|
5
|
-
const START_PROCESS_CHECK_INTERVAL_MS = 1000;
|
|
6
|
-
const START_PROCESS_CHECK = [
|
|
7
|
-
'sh',
|
|
8
|
-
'-lc',
|
|
9
|
-
[
|
|
10
|
-
'pid="$(cat /wake/.wake/logs/start.pid)"',
|
|
11
|
-
'test -n "$pid"',
|
|
12
|
-
'kill -0 "$pid"',
|
|
13
|
-
'tr "\\0" " " < "/proc/$pid/cmdline" | grep -F "node /app/dist/src/main.js start --wake-root /wake" >/dev/null',
|
|
14
|
-
].join(' && '),
|
|
15
|
-
];
|
|
16
|
-
function tagFromImage(imageRepository, image) {
|
|
17
|
-
if (image === null) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const prefix = `${imageRepository}:`;
|
|
21
|
-
return image.startsWith(prefix) ? image.slice(prefix.length) : null;
|
|
22
|
-
}
|
|
23
|
-
function readFlag(name, args) {
|
|
24
|
-
const index = args.indexOf(name);
|
|
25
|
-
return index === -1 ? undefined : args[index + 1];
|
|
26
|
-
}
|
|
27
|
-
function hasFlag(name, args) {
|
|
28
|
-
return args.includes(name);
|
|
29
|
-
}
|
|
30
|
-
function readNumberFlag(name, args) {
|
|
31
|
-
const raw = readFlag(name, args);
|
|
32
|
-
const parsed = raw === undefined ? Number.NaN : Number(raw);
|
|
33
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
34
|
-
}
|
|
35
|
-
const DEFAULT_LOOP_INTERVAL_MS = 5 * 60 * 1000;
|
|
36
|
-
async function verifyResidentStart(input) {
|
|
37
|
-
if (input.start?.enabled !== true) {
|
|
38
|
-
input.logger.error(`[self-update] wake start auto-start is disabled; resident loop will not be running after ${input.context}`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
let lastError;
|
|
42
|
-
for (let attempt = 1; attempt <= START_PROCESS_CHECK_ATTEMPTS; attempt += 1) {
|
|
43
|
-
try {
|
|
44
|
-
await input.docker.exec(input.containerName, START_PROCESS_CHECK);
|
|
45
|
-
input.logger.info(`[self-update] verified wake start is running after ${input.context}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
lastError = error;
|
|
50
|
-
if (attempt === START_PROCESS_CHECK_ATTEMPTS) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
await input.sleep(START_PROCESS_CHECK_INTERVAL_MS);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
57
|
-
}
|
|
58
|
-
export async function runSelfUpdateCommand(input) {
|
|
59
|
-
const force = hasFlag('--force', input.args);
|
|
60
|
-
const explicitTag = readFlag('--tag', input.args);
|
|
61
|
-
const ledger = await input.readLedger();
|
|
62
|
-
const tag = explicitTag ?? (await input.git.latestTag());
|
|
63
|
-
if (!force && tag === ledger.lastAppliedTag) {
|
|
64
|
-
input.logger.info(`[self-update] already on ${tag}; nothing to do`);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (!force && ledger.badTags.some((bad) => bad.tag === tag)) {
|
|
68
|
-
input.logger.info(`[self-update] ${tag} is recorded as a bad tag; skipping (use --force to retry)`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (!(await input.git.isWorkingTreeClean())) {
|
|
72
|
-
throw new Error(`[self-update] repo working tree has local changes; refusing to update to ${tag}`);
|
|
73
|
-
}
|
|
74
|
-
await waitForActiveRuns({
|
|
75
|
-
listRunRecords: input.stateStore.listRunRecords,
|
|
76
|
-
...(input.recoverActiveRuns === undefined
|
|
77
|
-
? {}
|
|
78
|
-
: { recoverActiveRuns: input.recoverActiveRuns }),
|
|
79
|
-
sleep: input.sleep,
|
|
80
|
-
logger: input.logger,
|
|
81
|
-
});
|
|
82
|
-
const newImage = `${input.imageRepository}:${tag}`;
|
|
83
|
-
const previousImage = (await input.docker.inspectContainerImage?.(input.containerName)) ?? null;
|
|
84
|
-
const previousImageTag = tagFromImage(input.imageRepository, previousImage);
|
|
85
|
-
const rollbackImage = previousImage ??
|
|
86
|
-
(ledger.lastKnownGoodTag !== null
|
|
87
|
-
? `${input.imageRepository}:${ledger.lastKnownGoodTag}`
|
|
88
|
-
: null);
|
|
89
|
-
const rollbackTag = previousImageTag ?? ledger.lastKnownGoodTag;
|
|
90
|
-
const updateInput = {
|
|
91
|
-
containerName: input.containerName,
|
|
92
|
-
wakeRoot: input.wakeRoot,
|
|
93
|
-
containerHomeRoot: input.containerHomeRoot,
|
|
94
|
-
containerMountPath: input.containerMountPath,
|
|
95
|
-
containerHomeMountPath: input.containerHomeMountPath,
|
|
96
|
-
ui: input.ui,
|
|
97
|
-
start: input.start,
|
|
98
|
-
};
|
|
99
|
-
try {
|
|
100
|
-
await input.git.checkoutTag(tag);
|
|
101
|
-
const buildVersion = input.resolveBuildVersion?.(input.repoRoot) ??
|
|
102
|
-
resolveWakeVersion({ repoRoot: input.repoRoot });
|
|
103
|
-
await input.docker.build({
|
|
104
|
-
image: newImage,
|
|
105
|
-
dockerfile: input.dockerfilePath,
|
|
106
|
-
contextDir: input.repoRoot,
|
|
107
|
-
buildArgs: { WAKE_BUILD_TAG: buildVersion },
|
|
108
|
-
});
|
|
109
|
-
await input.docker.update({ ...updateInput, image: newImage });
|
|
110
|
-
input.logger.info('[self-update] recreated container; entrypoint will keep wake start running');
|
|
111
|
-
await verifyResidentStart({
|
|
112
|
-
docker: input.docker,
|
|
113
|
-
containerName: input.containerName,
|
|
114
|
-
start: input.start,
|
|
115
|
-
logger: input.logger,
|
|
116
|
-
sleep: input.sleep,
|
|
117
|
-
context: 'rollout',
|
|
118
|
-
});
|
|
119
|
-
await input.docker.exec(input.containerName, [
|
|
120
|
-
'node',
|
|
121
|
-
'/app/dist/src/main.js',
|
|
122
|
-
'tick',
|
|
123
|
-
'--wake-root',
|
|
124
|
-
HEALTHCHECK_WAKE_ROOT,
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
129
|
-
input.logger.error(`[self-update] rollout of ${tag} failed: ${reason}`);
|
|
130
|
-
if (rollbackImage !== null) {
|
|
131
|
-
if (rollbackTag !== null) {
|
|
132
|
-
await input.git.checkoutTag(rollbackTag);
|
|
133
|
-
}
|
|
134
|
-
await input.docker.update({ ...updateInput, image: rollbackImage });
|
|
135
|
-
input.logger.info('[self-update] recreated rollback container; entrypoint will keep wake start running');
|
|
136
|
-
await verifyResidentStart({
|
|
137
|
-
docker: input.docker,
|
|
138
|
-
containerName: input.containerName,
|
|
139
|
-
start: input.start,
|
|
140
|
-
logger: input.logger,
|
|
141
|
-
sleep: input.sleep,
|
|
142
|
-
context: 'rollback',
|
|
143
|
-
});
|
|
144
|
-
input.logger.info(`[self-update] rolled back to ${rollbackTag ?? rollbackImage}`);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
input.logger.error('[self-update] no previous known-good tag to roll back to');
|
|
148
|
-
}
|
|
149
|
-
await input.writeLedger({
|
|
150
|
-
lastAppliedTag: rollbackTag,
|
|
151
|
-
lastKnownGoodTag: rollbackTag,
|
|
152
|
-
badTags: [...ledger.badTags, { tag, reason, recordedAt: new Date().toISOString() }],
|
|
153
|
-
});
|
|
154
|
-
try {
|
|
155
|
-
await input.issueReporter.createIssue({
|
|
156
|
-
title: `Self-update to ${tag} failed and was rolled back`,
|
|
157
|
-
body: [
|
|
158
|
-
`Automated update to \`${tag}\` failed during rollout and was rolled back to \`${rollbackTag ?? rollbackImage ?? 'unknown'}\`.`,
|
|
159
|
-
'',
|
|
160
|
-
'```',
|
|
161
|
-
reason,
|
|
162
|
-
'```',
|
|
163
|
-
].join('\n'),
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
catch (issueError) {
|
|
167
|
-
// Rollback already succeeded above; a failure to file the notification
|
|
168
|
-
// issue must not be reported as an overall self-update failure.
|
|
169
|
-
input.logger.error(`[self-update] rolled back successfully, but failed to file a GitHub issue: ${issueError instanceof Error ? issueError.message : String(issueError)}`);
|
|
170
|
-
}
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
await input.writeLedger({
|
|
174
|
-
lastAppliedTag: tag,
|
|
175
|
-
lastKnownGoodTag: tag,
|
|
176
|
-
badTags: ledger.badTags,
|
|
177
|
-
});
|
|
178
|
-
input.logger.info(`[self-update] ${tag} is live and healthy`);
|
|
179
|
-
}
|
|
180
|
-
// Runs runSelfUpdateCommand forever, polling for a new tag every
|
|
181
|
-
// --loop-interval-ms (default 5 minutes). One failed iteration (e.g. a
|
|
182
|
-
// transient git/docker error) is logged and does not stop the loop — the
|
|
183
|
-
// next iteration retries. Exits only if `sleep` itself rejects (e.g. the
|
|
184
|
-
// process is being torn down), matching the resident-loop shape in
|
|
185
|
-
// core/control-plane.ts.
|
|
186
|
-
export async function runSelfUpdateLoop(input) {
|
|
187
|
-
const loopIntervalMs = readNumberFlag('--loop-interval-ms', input.args) ?? DEFAULT_LOOP_INTERVAL_MS;
|
|
188
|
-
for (;;) {
|
|
189
|
-
try {
|
|
190
|
-
await runSelfUpdateCommand(input);
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
input.logger.error(`[self-update] loop iteration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
-
}
|
|
195
|
-
input.logger.info(`[self-update] next check in ${loopIntervalMs}ms`);
|
|
196
|
-
await input.sleep(loopIntervalMs);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { execFile as nodeExecFile } from 'node:child_process';
|
|
2
|
-
import { access } from 'node:fs/promises';
|
|
3
|
-
import { promisify } from 'node:util';
|
|
4
|
-
import { loadPromptTemplate } from '../adapters/runner/prompt-templates.js';
|
|
5
|
-
const execFile = promisify(nodeExecFile);
|
|
6
|
-
// Some CLIs (observed with Cursor's `agent --version`) take 5-6s to exit
|
|
7
|
-
// when stdout isn't a TTY, likely due to a background update/telemetry
|
|
8
|
-
// check — keep this comfortably above that or the probe kills a CLI that
|
|
9
|
-
// is actually fine.
|
|
10
|
-
const runnerVersionProbeTimeoutMs = 20_000;
|
|
11
|
-
function activeRunnerNames(config, runnerOverride) {
|
|
12
|
-
const names = new Set();
|
|
13
|
-
if (runnerOverride !== undefined) {
|
|
14
|
-
names.add(runnerOverride);
|
|
15
|
-
return names;
|
|
16
|
-
}
|
|
17
|
-
for (const candidates of Object.values(config.tiers)) {
|
|
18
|
-
for (const candidate of candidates) {
|
|
19
|
-
names.add(candidate);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
for (const workflow of Object.values(config.workflows)) {
|
|
23
|
-
for (const route of Object.values(workflow.stages)) {
|
|
24
|
-
if (route.runner !== undefined) {
|
|
25
|
-
names.add(route.runner);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return names;
|
|
30
|
-
}
|
|
31
|
-
function formatPreflightFailures(failures) {
|
|
32
|
-
return new Error([
|
|
33
|
-
'Wake startup preflight failed:',
|
|
34
|
-
...failures.map((failure) => `- ${failure}`),
|
|
35
|
-
'',
|
|
36
|
-
'Fix the configuration or environment, then run `wake start` again.',
|
|
37
|
-
].join('\n'));
|
|
38
|
-
}
|
|
39
|
-
async function defaultLoadPrompt(action, mode, promptsRoot) {
|
|
40
|
-
await loadPromptTemplate(action, mode, {
|
|
41
|
-
...(promptsRoot === undefined ? {} : { promptsRoot }),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
export function buildRunnerCommandProbeArgs(kind) {
|
|
45
|
-
return kind === 'cursor' ? ['agent', '--version'] : ['--version'];
|
|
46
|
-
}
|
|
47
|
-
async function defaultCheckRunnerCommand(runnerName, entry) {
|
|
48
|
-
try {
|
|
49
|
-
await execFile(entry.command, buildRunnerCommandProbeArgs(entry.kind), {
|
|
50
|
-
env: process.env,
|
|
51
|
-
timeout: runnerVersionProbeTimeoutMs,
|
|
52
|
-
windowsHide: true,
|
|
53
|
-
maxBuffer: 1024 * 1024,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
-
throw new Error(`runner "${runnerName}" (${entry.kind}) command "${entry.command}" is not invocable: ${message}`, { cause: error });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function assertPromptsRootAccessible(promptsRoot) {
|
|
62
|
-
if (promptsRoot === undefined) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
await access(promptsRoot);
|
|
66
|
-
}
|
|
67
|
-
export async function collectStartupPreflightFailures(config, deps = {}) {
|
|
68
|
-
const failures = [];
|
|
69
|
-
const loadPrompt = deps.loadPrompt ?? defaultLoadPrompt;
|
|
70
|
-
const checkRunnerCommand = deps.checkRunnerCommand ?? defaultCheckRunnerCommand;
|
|
71
|
-
try {
|
|
72
|
-
await assertPromptsRootAccessible(config.paths.promptsRoot);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
-
failures.push(`promptsRoot "${config.paths.promptsRoot}" is not readable: ${message}`);
|
|
77
|
-
}
|
|
78
|
-
const actions = new Set(Object.values(config.workflows).flatMap((workflow) => Object.entries(workflow.stages).map(([stageName, stage]) => stage.action ?? stageName)));
|
|
79
|
-
for (const action of actions) {
|
|
80
|
-
for (const mode of ['start', 'resume']) {
|
|
81
|
-
try {
|
|
82
|
-
await loadPrompt(action, mode, config.paths.promptsRoot);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
86
|
-
const root = config.paths.promptsRoot ?? '(bundled prompts)';
|
|
87
|
-
failures.push(`prompt template ${action}.md or ${action}.${mode}.md under ${root} is not readable: ${message}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const activeRunners = activeRunnerNames(config, deps.runnerOverride);
|
|
92
|
-
let usesRealRunner = false;
|
|
93
|
-
for (const runnerName of activeRunners) {
|
|
94
|
-
const entry = config.runners[runnerName];
|
|
95
|
-
if (entry === undefined) {
|
|
96
|
-
failures.push(`routing references unknown runner "${runnerName}"`);
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (entry.kind === 'fake') {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
usesRealRunner = true;
|
|
103
|
-
try {
|
|
104
|
-
await checkRunnerCommand(runnerName, entry);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
-
failures.push(message);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (usesRealRunner && config.sources.github.enabled && config.sources.github.repos.length > 0) {
|
|
112
|
-
if (deps.workspaceManager === undefined) {
|
|
113
|
-
failures.push('canonical clone health could not be checked: no workspace manager was provided');
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
for (const repo of config.sources.github.repos) {
|
|
117
|
-
try {
|
|
118
|
-
await deps.workspaceManager.prepareReadOnlyClone({ repo });
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
122
|
-
failures.push(`canonical clone for ${repo} is not healthy or clone-able: ${message}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return failures;
|
|
128
|
-
}
|
|
129
|
-
export async function runStartupPreflight(config, deps = {}) {
|
|
130
|
-
const failures = await collectStartupPreflightFailures(config, deps);
|
|
131
|
-
if (failures.length > 0) {
|
|
132
|
-
throw formatPreflightFailures(failures);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
2
|
-
const STOP_GRACE_PERIOD_SECONDS = 60;
|
|
3
|
-
export async function waitForActiveRuns(input) {
|
|
4
|
-
const pollIntervalMs = input.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
5
|
-
const startedAt = Date.now();
|
|
6
|
-
for (;;) {
|
|
7
|
-
await input.recoverActiveRuns?.();
|
|
8
|
-
const records = await input.listRunRecords();
|
|
9
|
-
const activeRuns = records.filter((record) => record.status === 'running');
|
|
10
|
-
if (activeRuns.length === 0) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (input.timeoutMs !== undefined && Date.now() - startedAt >= input.timeoutMs) {
|
|
14
|
-
throw new Error(`Timed out after ${input.timeoutMs}ms waiting for active runs to finish: ${activeRuns
|
|
15
|
-
.map((record) => record.runId)
|
|
16
|
-
.join(', ')}`);
|
|
17
|
-
}
|
|
18
|
-
input.logger.info(`[wake stop] waiting for ${activeRuns.length} active run(s) to finish: ${activeRuns
|
|
19
|
-
.map((record) => record.runId)
|
|
20
|
-
.join(', ')}`);
|
|
21
|
-
await input.sleep(pollIntervalMs);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function readNumberFlag(name, args) {
|
|
25
|
-
const index = args.indexOf(name);
|
|
26
|
-
if (index === -1) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
const raw = args[index + 1];
|
|
30
|
-
const parsed = raw === undefined ? Number.NaN : Number(raw);
|
|
31
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
32
|
-
}
|
|
33
|
-
export async function runStopCommand(input) {
|
|
34
|
-
await waitForActiveRuns({
|
|
35
|
-
listRunRecords: input.stateStore.listRunRecords,
|
|
36
|
-
...(input.recoverActiveRuns === undefined
|
|
37
|
-
? {}
|
|
38
|
-
: { recoverActiveRuns: input.recoverActiveRuns }),
|
|
39
|
-
sleep: input.sleep,
|
|
40
|
-
pollIntervalMs: readNumberFlag('--poll-interval-ms', input.args),
|
|
41
|
-
timeoutMs: readNumberFlag('--timeout-ms', input.args),
|
|
42
|
-
logger: input.logger,
|
|
43
|
-
});
|
|
44
|
-
input.logger.info(`[wake stop] no active runs; stopping ${input.containerName}`);
|
|
45
|
-
await input.docker.down(input.containerName, { timeoutSeconds: STOP_GRACE_PERIOD_SECONDS });
|
|
46
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createUiServer } from '../adapters/http/ui-server.js';
|
|
2
|
-
export async function runUiCommand(input) {
|
|
3
|
-
const log = input.log ?? console.log;
|
|
4
|
-
const portFlag = input.readFlag('--port', input.args);
|
|
5
|
-
const port = portFlag !== undefined ? Number(portFlag) : input.config.ui.port;
|
|
6
|
-
if (!Number.isInteger(port) || port <= 0) {
|
|
7
|
-
throw new Error(`Invalid --port: ${portFlag}`);
|
|
8
|
-
}
|
|
9
|
-
const host = input.readFlag('--host', input.args) ?? '127.0.0.1';
|
|
10
|
-
const token = input.readFlag('--token', input.args) ?? input.config.ui.token ?? process.env.WAKE_UI_TOKEN;
|
|
11
|
-
const server = createUiServer({
|
|
12
|
-
stateStore: input.stateStore,
|
|
13
|
-
resourceIndex: input.resourceIndex,
|
|
14
|
-
config: input.config,
|
|
15
|
-
...(token === undefined ? {} : { token }),
|
|
16
|
-
});
|
|
17
|
-
await new Promise((resolveListen, reject) => {
|
|
18
|
-
server.once('error', reject);
|
|
19
|
-
server.listen(port, host, () => resolveListen());
|
|
20
|
-
});
|
|
21
|
-
log(`Wake UI listening on http://${host}:${port}`);
|
|
22
|
-
return {
|
|
23
|
-
close: () => new Promise((resolveClose) => {
|
|
24
|
-
server.close(() => resolveClose());
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import { defaultAgentIdentity, defaultSmokePrompt, parseWakeConfig } from '../domain/schema.js';
|
|
3
|
-
export { defaultAgentIdentity, defaultSmokePrompt };
|
|
4
|
-
export function createDefaultWakeConfig(wakeRoot = resolve(process.cwd(), '.wake')) {
|
|
5
|
-
return parseWakeConfig({
|
|
6
|
-
paths: {
|
|
7
|
-
wakeRoot,
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { readdir } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
const configFileNamePattern = /^config(\..+)?\.yaml$/;
|
|
4
|
-
export async function discoverConfigFiles(wakeRoot) {
|
|
5
|
-
const entries = await readdir(wakeRoot, { withFileTypes: true }).catch(() => []);
|
|
6
|
-
return entries
|
|
7
|
-
.filter((entry) => entry.isFile() && configFileNamePattern.test(entry.name))
|
|
8
|
-
.map((entry) => entry.name)
|
|
9
|
-
.sort()
|
|
10
|
-
.map((name) => join(wakeRoot, name));
|
|
11
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { resolve, join } from 'node:path';
|
|
2
|
-
import { access } from 'node:fs/promises';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { readJsonFile } from '../lib/json-file.js';
|
|
5
|
-
import { readYamlFile } from '../lib/yaml-file.js';
|
|
6
|
-
import { deepMergeRaw } from '../lib/deep-merge.js';
|
|
7
|
-
import { parseWakeConfig } from '../domain/schema.js';
|
|
8
|
-
import { discoverConfigFiles } from './discover-config-files.js';
|
|
9
|
-
async function readLegacyConfigIfPresent(wakeRoot) {
|
|
10
|
-
const legacyConfigFile = join(wakeRoot, 'config.json');
|
|
11
|
-
try {
|
|
12
|
-
await access(legacyConfigFile);
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
return readJsonFile(legacyConfigFile);
|
|
18
|
-
}
|
|
19
|
-
export async function loadWakeConfig(options) {
|
|
20
|
-
const wakeRoot = options?.wakeRoot ?? resolve(process.cwd(), '.wake');
|
|
21
|
-
const configFiles = await discoverConfigFiles(wakeRoot);
|
|
22
|
-
let raw;
|
|
23
|
-
if (configFiles.length > 0) {
|
|
24
|
-
raw = {};
|
|
25
|
-
for (const configFile of configFiles) {
|
|
26
|
-
let parsed;
|
|
27
|
-
try {
|
|
28
|
-
// yaml.parse returns null for empty/comment-only files rather than
|
|
29
|
-
// {}, so coalesce before merging.
|
|
30
|
-
parsed = (await readYamlFile(configFile)) ?? {};
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw new Error(`Failed to parse ${configFile}: ${error.message}`, {
|
|
34
|
-
cause: error,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
raw = deepMergeRaw(raw, parsed);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Pre-split Wake homes only have a single config.json — Wake reads it
|
|
42
|
-
// directly rather than requiring a migration step. It stays untouched
|
|
43
|
-
// on disk; nothing here writes it back out (see docs/configuration.md).
|
|
44
|
-
raw = await readLegacyConfigIfPresent(wakeRoot);
|
|
45
|
-
}
|
|
46
|
-
// wakeRoot is always the live invocation's --wake-root/cwd, never a value
|
|
47
|
-
// to accept from a (possibly stale, possibly container-context) config
|
|
48
|
-
// file — spread rawPaths first so wakeRoot always wins. promptsRoot stays
|
|
49
|
-
// file-overridable for a genuine custom location, but when the file is
|
|
50
|
-
// silent on it we default to the live wakeRoot's own prompts/ dir (the
|
|
51
|
-
// usual colocated layout `wake init` scaffolds) rather than leaving it to
|
|
52
|
-
// fall back to bundled prompts — this keeps a scaffolded home's prompt
|
|
53
|
-
// customizations in effect across host/container re-reads of the same
|
|
54
|
-
// config file, where an absolute promptsRoot baked in at init time would
|
|
55
|
-
// not resolve the same way.
|
|
56
|
-
const rawPaths = raw.paths ?? {};
|
|
57
|
-
const wakeRootPromptsDir = join(wakeRoot, 'prompts');
|
|
58
|
-
const promptsRootDefault = rawPaths.promptsRoot === undefined && existsSync(wakeRootPromptsDir)
|
|
59
|
-
? { promptsRoot: wakeRootPromptsDir }
|
|
60
|
-
: {};
|
|
61
|
-
return parseWakeConfig({
|
|
62
|
-
...raw,
|
|
63
|
-
paths: {
|
|
64
|
-
...rawPaths,
|
|
65
|
-
...promptsRootDefault,
|
|
66
|
-
wakeRoot,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { wakeInfraConfigSchema, wakeWorkflowConfigSchema } from '../domain/schema.js';
|
|
2
|
-
const infraKeys = Object.keys(wakeInfraConfigSchema.shape);
|
|
3
|
-
const workflowKeys = Object.keys(wakeWorkflowConfigSchema.shape);
|
|
4
|
-
export function splitWakeConfig(config) {
|
|
5
|
-
const infra = {};
|
|
6
|
-
for (const key of infraKeys) {
|
|
7
|
-
infra[key] = config[key];
|
|
8
|
-
}
|
|
9
|
-
const workflow = {};
|
|
10
|
-
for (const key of workflowKeys) {
|
|
11
|
-
workflow[key] = config[key];
|
|
12
|
-
}
|
|
13
|
-
return { infra, workflow };
|
|
14
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { maxConfiguredRunnerTimeoutMs } from '../domain/runner-routing.js';
|
|
2
|
-
import { isRunLeaseExpired } from './run-lease.js';
|
|
3
|
-
import { processIdentityMatches } from '../lib/process-identity.js';
|
|
4
|
-
import { createOutbox } from './outbox.js';
|
|
5
|
-
import { createProjectionUpdater } from './projection-updater.js';
|
|
6
|
-
import { createStaleRunReconciler } from './stale-run-reconciler.js';
|
|
7
|
-
export function createActiveRunRecovery(deps) {
|
|
8
|
-
const projectionUpdater = createProjectionUpdater({
|
|
9
|
-
stateStore: deps.stateStore,
|
|
10
|
-
resourceIndex: deps.resourceIndex,
|
|
11
|
-
config: deps.config,
|
|
12
|
-
});
|
|
13
|
-
const { deliverOutboundEvent } = createOutbox({
|
|
14
|
-
clock: deps.clock,
|
|
15
|
-
stateStore: deps.stateStore,
|
|
16
|
-
projectionUpdater,
|
|
17
|
-
});
|
|
18
|
-
async function isRunningRecordActive(record, now) {
|
|
19
|
-
if (record.lease !== undefined && !isRunLeaseExpired(record, now)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return (processIdentityMatches({
|
|
23
|
-
pid: record.agentPid,
|
|
24
|
-
processStartedAt: record.agentProcessStartedAt,
|
|
25
|
-
}) ||
|
|
26
|
-
processIdentityMatches({
|
|
27
|
-
pid: record.workerPid,
|
|
28
|
-
processStartedAt: record.workerProcessStartedAt,
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
const { reconcileStaleRunningRecords } = createStaleRunReconciler({
|
|
32
|
-
config: deps.config,
|
|
33
|
-
stateStore: deps.stateStore,
|
|
34
|
-
projectionUpdater,
|
|
35
|
-
runnerTimeoutMs: () => maxConfiguredRunnerTimeoutMs(deps.config),
|
|
36
|
-
isRunningRecordActive,
|
|
37
|
-
deliverOutboundEvent,
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
recoverActiveRuns() {
|
|
41
|
-
return reconcileStaleRunningRecords(deps.clock.now());
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const autoApprovalLabel = 'wake:auto';
|
|
2
|
-
const autoApprovalCommands = new Set(['yolo', 'autoapprove']);
|
|
3
|
-
export function resolveAutoApprovalIntent(body) {
|
|
4
|
-
for (const line of (body ?? '').split(/\r?\n/)) {
|
|
5
|
-
const match = /^\/([A-Za-z0-9_.-]+)\b/.exec(line.trim());
|
|
6
|
-
const command = match?.[1]?.toLowerCase();
|
|
7
|
-
if (command !== undefined && autoApprovalCommands.has(command)) {
|
|
8
|
-
return {
|
|
9
|
-
kind: 'auto-approval-opt-in',
|
|
10
|
-
label: autoApprovalLabel,
|
|
11
|
-
command,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { AUTONOMOUS_DECISION_AUDIT_EVENT } from '../domain/schema.js';
|
|
5
|
-
import { createEventEnvelope } from '../lib/event-log.js';
|
|
6
|
-
function stableJson(value) {
|
|
7
|
-
if (value === null || typeof value !== 'object') {
|
|
8
|
-
return JSON.stringify(value);
|
|
9
|
-
}
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
return `[${value.map((entry) => stableJson(entry)).join(',')}]`;
|
|
12
|
-
}
|
|
13
|
-
const record = value;
|
|
14
|
-
return `{${Object.keys(record)
|
|
15
|
-
.sort()
|
|
16
|
-
.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
|
|
17
|
-
.join(',')}}`;
|
|
18
|
-
}
|
|
19
|
-
async function promptRevisionInput(input) {
|
|
20
|
-
if (input.action === undefined) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
const promptsRoot = input.config.paths.promptsRoot;
|
|
24
|
-
if (promptsRoot === undefined) {
|
|
25
|
-
return { prompt: { action: input.action, status: 'not-configured' } };
|
|
26
|
-
}
|
|
27
|
-
for (const suffix of ['.md', '.start.md', '.resume.md']) {
|
|
28
|
-
const path = join(promptsRoot, `${input.action}${suffix}`);
|
|
29
|
-
try {
|
|
30
|
-
return {
|
|
31
|
-
prompt: {
|
|
32
|
-
action: input.action,
|
|
33
|
-
path,
|
|
34
|
-
sha256: createHash('sha256')
|
|
35
|
-
.update(await readFile(path, 'utf8'))
|
|
36
|
-
.digest('hex'),
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Try the next supported prompt template name.
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { prompt: { action: input.action, status: 'missing' } };
|
|
45
|
-
}
|
|
46
|
-
export async function workflowRevision(input) {
|
|
47
|
-
const revisionInput = {
|
|
48
|
-
workflowName: input.workflowName,
|
|
49
|
-
workflow: input.workflow,
|
|
50
|
-
...(await promptRevisionInput({
|
|
51
|
-
config: input.config,
|
|
52
|
-
...(input.action === undefined ? {} : { action: input.action }),
|
|
53
|
-
})),
|
|
54
|
-
};
|
|
55
|
-
return `sha256:${createHash('sha256').update(stableJson(revisionInput)).digest('hex')}`;
|
|
56
|
-
}
|
|
57
|
-
export function createAutonomousDecisionAuditEvent(input) {
|
|
58
|
-
return createEventEnvelope({
|
|
59
|
-
eventId: input.eventId,
|
|
60
|
-
workItemKey: input.workItemKey,
|
|
61
|
-
streamScope: 'work-item',
|
|
62
|
-
direction: 'internal',
|
|
63
|
-
sourceSystem: 'wake',
|
|
64
|
-
sourceEventType: AUTONOMOUS_DECISION_AUDIT_EVENT,
|
|
65
|
-
sourceRefs: {
|
|
66
|
-
...(input.sourceRefs ?? {}),
|
|
67
|
-
runId: input.runId,
|
|
68
|
-
},
|
|
69
|
-
occurredAt: input.timestamp,
|
|
70
|
-
ingestedAt: input.timestamp,
|
|
71
|
-
trigger: 'context-only',
|
|
72
|
-
payload: {
|
|
73
|
-
decisionType: input.decisionType,
|
|
74
|
-
workItemId: input.workItemKey,
|
|
75
|
-
runId: input.runId,
|
|
76
|
-
workflowRevision: input.workflowRevision,
|
|
77
|
-
inputsConsidered: input.inputsConsidered,
|
|
78
|
-
outcome: input.outcome,
|
|
79
|
-
timestamp: input.timestamp,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|