@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,83 @@
|
|
|
1
|
+
import { createEventDraft, EventSourceKind, } from '../../kernel/index.js';
|
|
2
|
+
import { ResourceEventType, } from '../contracts/events.js';
|
|
3
|
+
import { resourceStream } from '../contracts/streams.js';
|
|
4
|
+
import { ResourceCorrelationProvenance, ResourceCorrelationRole, } from '../contracts/vocabulary.js';
|
|
5
|
+
import { ResourceRepository } from './resource-repository.js';
|
|
6
|
+
export function createResourceService(journal, lookup) {
|
|
7
|
+
const repository = new ResourceRepository(journal);
|
|
8
|
+
return {
|
|
9
|
+
discover: (command, context) => discoverResource(repository, command, context),
|
|
10
|
+
async get(resourceId) {
|
|
11
|
+
return (await repository.load(resourceId)).resource?.view ?? null;
|
|
12
|
+
},
|
|
13
|
+
async findByExternalKey(externalKey) {
|
|
14
|
+
const id = await lookup.resourceIdForExternalKey(externalKey);
|
|
15
|
+
return id === null ? null : ((await repository.load(id)).resource?.view ?? null);
|
|
16
|
+
},
|
|
17
|
+
async correlations(resourceId) {
|
|
18
|
+
return (await repository.load(resourceId)).resource?.correlations ?? [];
|
|
19
|
+
},
|
|
20
|
+
correlationsForWork: (workItemId) => lookup.correlationsForWork(workItemId),
|
|
21
|
+
correlate: (resourceId, workItemId, role, context, provenance) => correlateResource(repository, resourceId, workItemId, role, context, provenance),
|
|
22
|
+
async retract(resourceId, workItemId, context) {
|
|
23
|
+
await appendResourceEvent(repository, resourceId, resourceDraft(resourceId, context, ResourceEventType.WorkCorrelationRetracted, {
|
|
24
|
+
workItemId,
|
|
25
|
+
}));
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function discoverResource(repository, command, context) {
|
|
30
|
+
await appendResourceEvent(repository, command.resourceId, resourceDraft(command.resourceId, context, ResourceEventType.ResourceDiscovered, {
|
|
31
|
+
kind: command.kind,
|
|
32
|
+
externalKey: command.externalKey,
|
|
33
|
+
capabilities: command.capabilities,
|
|
34
|
+
...(command.revision === undefined ? {} : { revision: command.revision }),
|
|
35
|
+
...(command.title === undefined ? {} : { title: command.title }),
|
|
36
|
+
}));
|
|
37
|
+
const resource = (await repository.load(command.resourceId)).resource;
|
|
38
|
+
if (resource === null)
|
|
39
|
+
throw new Error(`Resource ${command.resourceId} was not discovered`);
|
|
40
|
+
return resource.view;
|
|
41
|
+
}
|
|
42
|
+
// Provenance is an explicit fifth command argument; the repository dependency is the sixth implementation concern.
|
|
43
|
+
async function correlateResource(repository, resourceId, workItemId, role, context, provenance = ResourceCorrelationProvenance.ProviderObserved) {
|
|
44
|
+
const loaded = await repository.load(resourceId);
|
|
45
|
+
if (loaded.resource === null)
|
|
46
|
+
throw new Error(`Resource ${resourceId} does not exist`);
|
|
47
|
+
const primary = loaded.resource.correlations.find((correlation) => correlation.role === ResourceCorrelationRole.Primary);
|
|
48
|
+
if (role === ResourceCorrelationRole.Primary &&
|
|
49
|
+
primary !== undefined &&
|
|
50
|
+
primary.workItemId !== workItemId) {
|
|
51
|
+
await appendResourceEvent(repository, resourceId, resourceDraft(resourceId, context, ResourceEventType.WorkCorrelationConflicted, {
|
|
52
|
+
workItemId,
|
|
53
|
+
existingWorkItemId: primary.workItemId,
|
|
54
|
+
}));
|
|
55
|
+
throw new Error(`Resource ${resourceId} already has a primary WorkItem correlation`);
|
|
56
|
+
}
|
|
57
|
+
await appendResourceEvent(repository, resourceId, resourceDraft(resourceId, context, ResourceEventType.WorkCorrelationEstablished, {
|
|
58
|
+
workItemId,
|
|
59
|
+
role,
|
|
60
|
+
provenance,
|
|
61
|
+
}));
|
|
62
|
+
const correlation = (await repository.load(resourceId)).resource?.correlations.find((candidate) => candidate.workItemId === workItemId && candidate.role === role);
|
|
63
|
+
if (correlation === undefined)
|
|
64
|
+
throw new Error('Resource correlation was not established');
|
|
65
|
+
return correlation;
|
|
66
|
+
}
|
|
67
|
+
async function appendResourceEvent(repository, resourceId, draft) {
|
|
68
|
+
const loaded = await repository.load(resourceId);
|
|
69
|
+
await repository.append(resourceId, loaded.sequence, [draft]);
|
|
70
|
+
}
|
|
71
|
+
function resourceDraft(resourceId, context, eventType, payload) {
|
|
72
|
+
return createEventDraft({
|
|
73
|
+
eventId: `${context.commandId}:${eventType}`,
|
|
74
|
+
eventType,
|
|
75
|
+
occurredAt: context.occurredAt,
|
|
76
|
+
correlationId: context.correlationId,
|
|
77
|
+
causationId: context.commandId,
|
|
78
|
+
actor: context.actor,
|
|
79
|
+
source: { kind: EventSourceKind.Internal, id: 'resource-service' },
|
|
80
|
+
stream: resourceStream(resourceId),
|
|
81
|
+
payload,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { brandedStringSchema, eventEnvelopeSchema, } from '../../kernel/index.js';
|
|
3
|
+
import { workItemId } from '../../work/index.js';
|
|
4
|
+
import { resourceCapability, resourceId, resourceKind, } from './identifiers.js';
|
|
5
|
+
import { ResourceStreamKind } from './streams.js';
|
|
6
|
+
import { ResourceCorrelationProvenance, ResourceCorrelationRole, } from './vocabulary.js';
|
|
7
|
+
export const ResourceEventType = {
|
|
8
|
+
ResourceDiscovered: 'resources.resource-discovered',
|
|
9
|
+
ResourceRevisionObserved: 'resources.resource-revision-observed',
|
|
10
|
+
WorkCorrelationEstablished: 'resources.work-correlation-established',
|
|
11
|
+
WorkCorrelationRetracted: 'resources.work-correlation-retracted',
|
|
12
|
+
WorkCorrelationConflicted: 'resources.work-correlation-conflicted',
|
|
13
|
+
};
|
|
14
|
+
const streamSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
kind: z.literal(ResourceStreamKind.Resource),
|
|
17
|
+
id: brandedStringSchema(resourceId),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
const revisionSchema = z.object({ revision: z.string() }).strict();
|
|
21
|
+
const workItemIdSchema = brandedStringSchema(workItemId);
|
|
22
|
+
const eventSchema = z.discriminatedUnion('eventType', [
|
|
23
|
+
eventEnvelopeSchema.extend({
|
|
24
|
+
eventType: z.literal(ResourceEventType.ResourceDiscovered),
|
|
25
|
+
stream: streamSchema,
|
|
26
|
+
payload: z
|
|
27
|
+
.object({
|
|
28
|
+
kind: brandedStringSchema(resourceKind),
|
|
29
|
+
externalKey: z.object({ adapter: z.string(), key: z.string() }).strict(),
|
|
30
|
+
capabilities: z.array(brandedStringSchema(resourceCapability)),
|
|
31
|
+
revision: z.string().optional(),
|
|
32
|
+
title: z.string().optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict(),
|
|
35
|
+
}),
|
|
36
|
+
eventEnvelopeSchema.extend({
|
|
37
|
+
eventType: z.literal(ResourceEventType.ResourceRevisionObserved),
|
|
38
|
+
stream: streamSchema,
|
|
39
|
+
payload: revisionSchema,
|
|
40
|
+
}),
|
|
41
|
+
eventEnvelopeSchema.extend({
|
|
42
|
+
eventType: z.literal(ResourceEventType.WorkCorrelationEstablished),
|
|
43
|
+
stream: streamSchema,
|
|
44
|
+
payload: z
|
|
45
|
+
.object({
|
|
46
|
+
workItemId: workItemIdSchema,
|
|
47
|
+
role: z.enum([ResourceCorrelationRole.Primary, ResourceCorrelationRole.Secondary]),
|
|
48
|
+
provenance: z.enum([
|
|
49
|
+
ResourceCorrelationProvenance.ProviderObserved,
|
|
50
|
+
ResourceCorrelationProvenance.AgentReported,
|
|
51
|
+
ResourceCorrelationProvenance.OperatorDeclared,
|
|
52
|
+
]),
|
|
53
|
+
})
|
|
54
|
+
.strict(),
|
|
55
|
+
}),
|
|
56
|
+
eventEnvelopeSchema.extend({
|
|
57
|
+
eventType: z.literal(ResourceEventType.WorkCorrelationRetracted),
|
|
58
|
+
stream: streamSchema,
|
|
59
|
+
payload: z.object({ workItemId: workItemIdSchema }).strict(),
|
|
60
|
+
}),
|
|
61
|
+
eventEnvelopeSchema.extend({
|
|
62
|
+
eventType: z.literal(ResourceEventType.WorkCorrelationConflicted),
|
|
63
|
+
stream: streamSchema,
|
|
64
|
+
payload: z
|
|
65
|
+
.object({
|
|
66
|
+
workItemId: workItemIdSchema,
|
|
67
|
+
existingWorkItemId: workItemIdSchema,
|
|
68
|
+
})
|
|
69
|
+
.strict(),
|
|
70
|
+
}),
|
|
71
|
+
]);
|
|
72
|
+
export function decodeResourceEvent(event) {
|
|
73
|
+
const result = eventSchema.safeParse(event);
|
|
74
|
+
if (!result.success)
|
|
75
|
+
throw invalidResourceEvent(event, result.error);
|
|
76
|
+
return result.data;
|
|
77
|
+
}
|
|
78
|
+
export function selectResourceEvent(event) {
|
|
79
|
+
return event.eventType.startsWith('resources.') ? decodeResourceEvent(event) : null;
|
|
80
|
+
}
|
|
81
|
+
function invalidResourceEvent(event, cause) {
|
|
82
|
+
return new Error(`Invalid Resource event ${event.eventId} at global position ${event.globalPosition} (${event.eventType}): ${cause.message}`, { cause });
|
|
83
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const resourceId = (value) => {
|
|
2
|
+
if (!/^resource-[0-9a-hjkmnp-tv-z]{26}$/.test(value))
|
|
3
|
+
throw new Error(`Invalid ResourceId: ${value}. Resource identity is minted, never derived.`);
|
|
4
|
+
return value;
|
|
5
|
+
};
|
|
6
|
+
export const resourceKind = (value) => {
|
|
7
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value))
|
|
8
|
+
throw new Error(`Invalid Resource kind: ${value}`);
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
export const resourceCapability = (value) => {
|
|
12
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value))
|
|
13
|
+
throw new Error(`Invalid Resource capability: ${value}`);
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { defineClosedVocabulary } from '../../kernel/index.js';
|
|
2
|
+
import { resourceCapability, resourceKind, } from './identifiers.js';
|
|
3
|
+
export const BuiltInResourceKind = {
|
|
4
|
+
Repository: resourceKind('repository'),
|
|
5
|
+
Issue: resourceKind('issue'),
|
|
6
|
+
PullRequest: resourceKind('pull-request'),
|
|
7
|
+
};
|
|
8
|
+
export const BuiltInResourceCapability = {
|
|
9
|
+
Commentable: resourceCapability('commentable'),
|
|
10
|
+
Reviewable: resourceCapability('reviewable'),
|
|
11
|
+
Approvable: resourceCapability('approvable'),
|
|
12
|
+
Mergeable: resourceCapability('mergeable'),
|
|
13
|
+
Revisioned: resourceCapability('revisioned'),
|
|
14
|
+
Editable: resourceCapability('editable'),
|
|
15
|
+
// Provider can report which file paths a revision changed.
|
|
16
|
+
ChangedFiles: resourceCapability('changed-files'),
|
|
17
|
+
};
|
|
18
|
+
export const ResourceCorrelationRole = defineClosedVocabulary({
|
|
19
|
+
Primary: 'primary',
|
|
20
|
+
Secondary: 'secondary',
|
|
21
|
+
});
|
|
22
|
+
export const ResourceCorrelationProvenance = defineClosedVocabulary({
|
|
23
|
+
ProviderObserved: 'provider-observed',
|
|
24
|
+
AgentReported: 'agent-reported',
|
|
25
|
+
OperatorDeclared: 'operator-declared',
|
|
26
|
+
});
|
|
27
|
+
class OpenResourceVocabularyRegistry {
|
|
28
|
+
parse;
|
|
29
|
+
label;
|
|
30
|
+
values = new Set();
|
|
31
|
+
constructor(initial, parse, label) {
|
|
32
|
+
this.parse = parse;
|
|
33
|
+
this.label = label;
|
|
34
|
+
for (const value of initial)
|
|
35
|
+
this.register(value);
|
|
36
|
+
}
|
|
37
|
+
register(value) {
|
|
38
|
+
const parsed = this.parse(value);
|
|
39
|
+
if (this.values.has(parsed))
|
|
40
|
+
throw new Error(`${this.label} ${value} is already registered`);
|
|
41
|
+
this.values.add(parsed);
|
|
42
|
+
}
|
|
43
|
+
resolve(value) {
|
|
44
|
+
const parsed = this.parse(value);
|
|
45
|
+
if (!this.values.has(parsed))
|
|
46
|
+
throw new Error(`Unknown ${this.label}: ${value}`);
|
|
47
|
+
return parsed;
|
|
48
|
+
}
|
|
49
|
+
has(value) {
|
|
50
|
+
try {
|
|
51
|
+
return this.values.has(this.parse(value));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class ResourceKindRegistry extends OpenResourceVocabularyRegistry {
|
|
59
|
+
constructor(initial = []) {
|
|
60
|
+
super(initial, resourceKind, 'Resource kind');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export class ResourceCapabilityRegistry extends OpenResourceVocabularyRegistry {
|
|
64
|
+
constructor(initial = []) {
|
|
65
|
+
super(initial, resourceCapability, 'Resource capability');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WorkStreamKind } from '../../work/index.js';
|
|
2
|
+
import { ResourceStreamKind } from '../contracts/streams.js';
|
|
3
|
+
export const resourceRepresentsWork = {
|
|
4
|
+
owner: 'resources',
|
|
5
|
+
name: 'resources.represents-work',
|
|
6
|
+
fromKind: ResourceStreamKind.Resource,
|
|
7
|
+
toKind: WorkStreamKind.WorkItem,
|
|
8
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ResourceEventType } from '../contracts/events.js';
|
|
2
|
+
export function foldResource(events) {
|
|
3
|
+
const discovered = events.find((event) => event.eventType === ResourceEventType.ResourceDiscovered);
|
|
4
|
+
if (discovered === undefined)
|
|
5
|
+
return null;
|
|
6
|
+
const resource = discoveredResource(discovered);
|
|
7
|
+
const active = new Map();
|
|
8
|
+
for (const event of events)
|
|
9
|
+
applyResourceEvent(resource, active, event);
|
|
10
|
+
return { view: resource, correlations: [...active.values()] };
|
|
11
|
+
}
|
|
12
|
+
function discoveredResource(event) {
|
|
13
|
+
const revision = event.payload.revision === undefined ? {} : { revision: event.payload.revision };
|
|
14
|
+
const title = event.payload.title === undefined ? {} : { title: event.payload.title };
|
|
15
|
+
return {
|
|
16
|
+
resourceId: event.stream.id,
|
|
17
|
+
kind: event.payload.kind,
|
|
18
|
+
externalKey: event.payload.externalKey,
|
|
19
|
+
capabilities: event.payload.capabilities,
|
|
20
|
+
...revision,
|
|
21
|
+
...title,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function applyResourceEvent(resource, active, event) {
|
|
25
|
+
switch (event.eventType) {
|
|
26
|
+
case ResourceEventType.ResourceDiscovered:
|
|
27
|
+
break;
|
|
28
|
+
case ResourceEventType.ResourceRevisionObserved:
|
|
29
|
+
Object.assign(resource, { revision: event.payload.revision });
|
|
30
|
+
break;
|
|
31
|
+
case ResourceEventType.WorkCorrelationEstablished:
|
|
32
|
+
active.set(event.payload.workItemId, {
|
|
33
|
+
resourceId: resource.resourceId,
|
|
34
|
+
workItemId: event.payload.workItemId,
|
|
35
|
+
role: event.payload.role,
|
|
36
|
+
provenance: event.payload.provenance,
|
|
37
|
+
establishedByEventId: event.eventId,
|
|
38
|
+
});
|
|
39
|
+
break;
|
|
40
|
+
case ResourceEventType.WorkCorrelationConflicted:
|
|
41
|
+
Object.assign(resource, {
|
|
42
|
+
primaryCorrelationConflict: {
|
|
43
|
+
attemptedWorkItemId: event.payload.workItemId,
|
|
44
|
+
existingWorkItemId: event.payload.existingWorkItemId,
|
|
45
|
+
eventId: event.eventId,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
case ResourceEventType.WorkCorrelationRetracted:
|
|
50
|
+
active.delete(event.payload.workItemId);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
assertNever(event);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function assertNever(value) {
|
|
57
|
+
throw new Error(`Unhandled Resource event: ${JSON.stringify(value)}`);
|
|
58
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './application/lookup-projections.js';
|
|
2
|
+
export * from './application/resource-lookup.js';
|
|
3
|
+
export * from './application/resource-projections.js';
|
|
4
|
+
export * from './application/resource-repository.js';
|
|
5
|
+
export * from './application/resource-service.js';
|
|
6
|
+
export * from './contracts/commands.js';
|
|
7
|
+
export * from './contracts/config.js';
|
|
8
|
+
export * from './contracts/events.js';
|
|
9
|
+
export * from './contracts/identifiers.js';
|
|
10
|
+
export * from './contracts/streams.js';
|
|
11
|
+
export * from './contracts/views.js';
|
|
12
|
+
export * from './contracts/vocabulary.js';
|
|
13
|
+
export * from './domain/correlation.js';
|
|
14
|
+
export * from './domain/resource.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function encodeCursor(value) {
|
|
2
|
+
if (!Number.isSafeInteger(value.position) || value.position < 0)
|
|
3
|
+
throw new Error('Invalid cursor position');
|
|
4
|
+
return `c_${btoa(JSON.stringify(value)).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '')}`;
|
|
5
|
+
}
|
|
6
|
+
export function decodeCursor(value) {
|
|
7
|
+
if (!/^c_[A-Za-z0-9_-]+$/.test(value))
|
|
8
|
+
throw new Error('Invalid cursor');
|
|
9
|
+
try {
|
|
10
|
+
const encoded = value.slice(2).replaceAll('-', '+').replaceAll('_', '/');
|
|
11
|
+
const parsed = JSON.parse(atob(encoded.padEnd(Math.ceil(encoded.length / 4) * 4, '=')));
|
|
12
|
+
if (typeof parsed !== 'object' || parsed === null || !('position' in parsed))
|
|
13
|
+
throw new Error();
|
|
14
|
+
const position = parsed.position;
|
|
15
|
+
if (!Number.isSafeInteger(position) || position < 0)
|
|
16
|
+
throw new Error();
|
|
17
|
+
return { position: position };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error('Invalid cursor');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function resourceResponse(data, asOf, position) {
|
|
24
|
+
assertUtcInstant(asOf);
|
|
25
|
+
return { data, meta: position === undefined ? { asOf } : { asOf, position } };
|
|
26
|
+
}
|
|
27
|
+
export function collectionResponse(items, asOf, page = {}, position) {
|
|
28
|
+
assertUtcInstant(asOf);
|
|
29
|
+
return {
|
|
30
|
+
items,
|
|
31
|
+
page: {
|
|
32
|
+
nextCursor: page.nextCursor ?? null,
|
|
33
|
+
hasMore: page.hasMore ?? false,
|
|
34
|
+
...(page.total === undefined ? {} : { total: page.total }),
|
|
35
|
+
},
|
|
36
|
+
meta: position === undefined ? { asOf } : { asOf, position },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function assertUtcInstant(value) {
|
|
40
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(value) ||
|
|
41
|
+
!Number.isFinite(Date.parse(value)))
|
|
42
|
+
throw new Error('Response timestamps must be valid UTC RFC 3339 instants ending in Z');
|
|
43
|
+
}
|
|
44
|
+
export function workItemPath(workItemKey) {
|
|
45
|
+
return `/api/v1/work-items/${encodeURIComponent(workItemKey)}`;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './activities.js';
|
|
2
|
+
export * from './board.js';
|
|
3
|
+
export * from './common.js';
|
|
4
|
+
export * from './control-plane.js';
|
|
5
|
+
export * from './events.js';
|
|
6
|
+
export * from './execution.js';
|
|
7
|
+
export * from './observability.js';
|
|
8
|
+
export * from './orchestration.js';
|
|
9
|
+
export * from './resources.js';
|
|
10
|
+
export * from './system.js';
|
|
11
|
+
export * from './status.js';
|
|
12
|
+
export * from './transport-values.js';
|
|
13
|
+
export * from './work.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const commandStatusShape = { accepted: true, completed: true };
|
|
2
|
+
const commandStatuses = Object.keys(commandStatusShape);
|
|
3
|
+
export const AcceptedCommandStatusValue = {
|
|
4
|
+
Accepted: commandStatuses[0],
|
|
5
|
+
Completed: commandStatuses[1],
|
|
6
|
+
};
|
|
7
|
+
const runResponseShape = { active: true };
|
|
8
|
+
export const RunResponseField = { Active: Object.keys(runResponseShape)[0] };
|
|
9
|
+
const resourceItemFieldShape = { adapter: true };
|
|
10
|
+
export const ResourceItemField = { Adapter: Object.keys(resourceItemFieldShape)[0] };
|
|
11
|
+
const boardConditionShape = {
|
|
12
|
+
ready: true,
|
|
13
|
+
active: true,
|
|
14
|
+
'needs-input': true,
|
|
15
|
+
error: true,
|
|
16
|
+
finished: true,
|
|
17
|
+
};
|
|
18
|
+
const boardConditions = Object.keys(boardConditionShape);
|
|
19
|
+
export const BoardConditionValue = {
|
|
20
|
+
Ready: boardConditions[0],
|
|
21
|
+
Active: boardConditions[1],
|
|
22
|
+
NeedsInput: boardConditions[2],
|
|
23
|
+
Error: boardConditions[3],
|
|
24
|
+
Finished: boardConditions[4],
|
|
25
|
+
};
|
|
26
|
+
const boardCardFieldShape = { stage: true };
|
|
27
|
+
export const BoardCardField = { Stage: Object.keys(boardCardFieldShape)[0] };
|
|
28
|
+
const transcriptChannelShape = { input: true, agent: true };
|
|
29
|
+
const transcriptChannels = Object.keys(transcriptChannelShape);
|
|
30
|
+
export const TranscriptChannelValue = {
|
|
31
|
+
Input: transcriptChannels[0],
|
|
32
|
+
Agent: transcriptChannels[1],
|
|
33
|
+
};
|
|
34
|
+
const transcriptGroupKindShape = { session: true, run: true };
|
|
35
|
+
const transcriptGroupKinds = Object.keys(transcriptGroupKindShape);
|
|
36
|
+
export const TranscriptGroupKindValue = {
|
|
37
|
+
Session: transcriptGroupKinds[0],
|
|
38
|
+
Run: transcriptGroupKinds[1],
|
|
39
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function toWorkItemKey(workItemId) {
|
|
2
|
+
return `wk_${btoa(workItemId).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '')}`;
|
|
3
|
+
}
|
|
4
|
+
export function fromWorkItemKey(key) {
|
|
5
|
+
if (!/^wk_[A-Za-z0-9_-]+$/.test(key))
|
|
6
|
+
throw new Error('Invalid WorkItemKey');
|
|
7
|
+
try {
|
|
8
|
+
const encoded = key.slice(3).replaceAll('-', '+').replaceAll('_', '/');
|
|
9
|
+
const value = atob(encoded.padEnd(Math.ceil(encoded.length / 4) * 4, '='));
|
|
10
|
+
if (value === '')
|
|
11
|
+
throw new Error();
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('Invalid WorkItemKey');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { problemDetails } from './problem-details.js';
|
|
3
|
+
import { BrowserRouteOutcome, routeBrowserRequest } from './router.js';
|
|
4
|
+
export function createApiHttpServer(dispatcher, assets) {
|
|
5
|
+
return createServer((request, response) => {
|
|
6
|
+
void handleRequest(dispatcher, assets, request, response);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
async function handleRequest(dispatcher, assets, request, response) {
|
|
10
|
+
try {
|
|
11
|
+
await dispatchRequest(dispatcher, assets, request, response);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
sendJson(response, errorResult(error));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function dispatchRequest(dispatcher, assets, request, response) {
|
|
18
|
+
const url = new URL(request.url ?? '/', 'http://wake.local');
|
|
19
|
+
const method = request.method ?? 'GET';
|
|
20
|
+
const head = method === 'HEAD';
|
|
21
|
+
const result = await dispatcher.dispatch(method, `${url.pathname}${url.search}`, await jsonBody(request));
|
|
22
|
+
if (result !== undefined)
|
|
23
|
+
return sendJson(response, result, head);
|
|
24
|
+
await serveWebRequest(assets, method, url.pathname, response, head);
|
|
25
|
+
}
|
|
26
|
+
async function serveWebRequest(assets, method, pathname, response, head) {
|
|
27
|
+
const asset = method === 'GET' || head ? await assets?.get(pathname) : undefined;
|
|
28
|
+
if (asset !== undefined)
|
|
29
|
+
return send(response, { status: 200, ...asset, head });
|
|
30
|
+
if (routeBrowserRequest(method, pathname) === BrowserRouteOutcome.Spa) {
|
|
31
|
+
const index = await assets?.get('/index.html');
|
|
32
|
+
if (index !== undefined)
|
|
33
|
+
return send(response, {
|
|
34
|
+
status: 200,
|
|
35
|
+
...index,
|
|
36
|
+
contentType: 'text/html; charset=utf-8',
|
|
37
|
+
head,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (pathname.startsWith('/api/'))
|
|
41
|
+
return sendJson(response, {
|
|
42
|
+
status: 404,
|
|
43
|
+
body: problemDetails(404, 'Not Found', `No route for ${pathname}`),
|
|
44
|
+
contentType: 'application/problem+json',
|
|
45
|
+
}, head);
|
|
46
|
+
return send(response, {
|
|
47
|
+
status: 404,
|
|
48
|
+
contentType: 'text/plain; charset=utf-8',
|
|
49
|
+
body: Buffer.from('Not Found'),
|
|
50
|
+
head,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function errorResult(error) {
|
|
54
|
+
if (error instanceof MalformedJsonError)
|
|
55
|
+
return {
|
|
56
|
+
status: 400,
|
|
57
|
+
body: problemDetails(400, 'Bad Request', 'The request body is not valid JSON.', {
|
|
58
|
+
code: 'malformed-json',
|
|
59
|
+
}),
|
|
60
|
+
contentType: 'application/problem+json',
|
|
61
|
+
};
|
|
62
|
+
if (isUpstreamProviderError(error))
|
|
63
|
+
return {
|
|
64
|
+
status: 502,
|
|
65
|
+
body: problemDetails(502, 'Bad Gateway', 'Wake could not complete the request because an external provider call failed (e.g. GitHub rate-limited or was unreachable). Retrying shortly usually resolves this.', { code: 'upstream-provider-error' }),
|
|
66
|
+
contentType: 'application/problem+json',
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
status: 500,
|
|
70
|
+
body: problemDetails(500, 'Internal Server Error', 'Wake could not complete the request.'),
|
|
71
|
+
contentType: 'application/problem+json',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Duck-types an octokit RequestError (or any similarly-shaped upstream HTTP
|
|
75
|
+
// client failure) by its `.status` field — the same detection already used
|
|
76
|
+
// for GitHub 404s in integrations/github/provider.ts's verifyArtifact. A
|
|
77
|
+
// synchronous command (like manual tick) that happens to run while an
|
|
78
|
+
// external provider is rate-limited or unreachable should surface as a
|
|
79
|
+
// distinguishable gateway failure, not an opaque "Internal Server Error"
|
|
80
|
+
// indistinguishable from an actual Wake bug.
|
|
81
|
+
function isUpstreamProviderError(error) {
|
|
82
|
+
return (typeof error === 'object' &&
|
|
83
|
+
error !== null &&
|
|
84
|
+
'status' in error &&
|
|
85
|
+
typeof error.status === 'number' &&
|
|
86
|
+
error.status >= 400);
|
|
87
|
+
}
|
|
88
|
+
async function jsonBody(request) {
|
|
89
|
+
if (request.method === 'GET' || request.method === 'HEAD')
|
|
90
|
+
return undefined;
|
|
91
|
+
const chunks = [];
|
|
92
|
+
for await (const chunk of request)
|
|
93
|
+
chunks.push(Buffer.from(chunk));
|
|
94
|
+
if (chunks.length === 0)
|
|
95
|
+
return undefined;
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
throw new MalformedJsonError();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class MalformedJsonError extends Error {
|
|
104
|
+
}
|
|
105
|
+
function sendJson(response, result, head = false) {
|
|
106
|
+
send(response, {
|
|
107
|
+
status: result.status,
|
|
108
|
+
contentType: result.contentType ?? 'application/json; charset=utf-8',
|
|
109
|
+
body: Buffer.from(JSON.stringify(result.body)),
|
|
110
|
+
...(result.headers === undefined ? {} : { headers: result.headers }),
|
|
111
|
+
head,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function send(response, options) {
|
|
115
|
+
response.writeHead(options.status, {
|
|
116
|
+
'content-type': options.contentType,
|
|
117
|
+
'content-length': options.body.byteLength,
|
|
118
|
+
...options.headers,
|
|
119
|
+
});
|
|
120
|
+
response.end(options.head ? undefined : options.body);
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resourceResponse as presentActivity } from '../contracts/common.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resourceResponse as presentControlPlane } from '../contracts/common.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { collectionResponse as presentEvents } from '../contracts/common.js';
|