@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,56 @@
|
|
|
1
|
+
export const createEtagCache = () => new Map();
|
|
2
|
+
export async function fetchWithEtag(input) {
|
|
3
|
+
const cached = input.cache.get(input.key);
|
|
4
|
+
try {
|
|
5
|
+
const response = await input.request(cached === undefined ? undefined : { 'if-none-match': cached.etag });
|
|
6
|
+
if (response.etag !== undefined)
|
|
7
|
+
input.cache.set(input.key, { etag: response.etag, data: response.data });
|
|
8
|
+
return response.data;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (status(error) === 304 && cached !== undefined)
|
|
12
|
+
return cached.data;
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function fetchPaginatedWithEtag(input) {
|
|
17
|
+
const cached = input.cache.get(input.key);
|
|
18
|
+
const values = [];
|
|
19
|
+
let pages = 0;
|
|
20
|
+
let etag;
|
|
21
|
+
try {
|
|
22
|
+
for await (const page of input.pages(cached === undefined ? undefined : { 'if-none-match': cached.etag })) {
|
|
23
|
+
pages += 1;
|
|
24
|
+
etag = page.headers?.etag;
|
|
25
|
+
values.push(...page.data);
|
|
26
|
+
if (reachedLimit(values.length, input.maxResults))
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const notModified = cached !== undefined && status(error) === 304;
|
|
32
|
+
if (!notModified)
|
|
33
|
+
throw error;
|
|
34
|
+
return truncate(cached.data, input.maxResults);
|
|
35
|
+
}
|
|
36
|
+
const data = truncate(values, input.maxResults);
|
|
37
|
+
if (pages <= 1 && etag !== undefined)
|
|
38
|
+
input.cache.set(input.key, { etag, data });
|
|
39
|
+
else
|
|
40
|
+
input.cache.delete(input.key);
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
function reachedLimit(count, maxResults) {
|
|
44
|
+
return maxResults !== undefined && count >= maxResults;
|
|
45
|
+
}
|
|
46
|
+
function truncate(values, maxResults) {
|
|
47
|
+
return maxResults === undefined ? values : values.slice(0, maxResults);
|
|
48
|
+
}
|
|
49
|
+
function status(error) {
|
|
50
|
+
return typeof error === 'object' &&
|
|
51
|
+
error !== null &&
|
|
52
|
+
'status' in error &&
|
|
53
|
+
typeof error.status === 'number'
|
|
54
|
+
? error.status
|
|
55
|
+
: undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
/** Resolves the credential held by the GitHub CLI inside the Wake sandbox. */
|
|
3
|
+
export function resolveGitHubCliToken(run = runGhAuthToken) {
|
|
4
|
+
try {
|
|
5
|
+
const token = run('gh', ['auth', 'token']).trim();
|
|
6
|
+
if (token.length > 0)
|
|
7
|
+
return token;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
// The common cause is an unauthenticated or unavailable GitHub CLI.
|
|
11
|
+
}
|
|
12
|
+
throw new Error('GitHub authentication is unavailable. Run `wake sandbox setup` and complete `gh auth login`.');
|
|
13
|
+
}
|
|
14
|
+
function runGhAuthToken(command, arguments_) {
|
|
15
|
+
return execFileSync(command, arguments_, {
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PullRequestState, ReviewActorKind } from '../../../activities/index.js';
|
|
2
|
+
import { createEventDraft, EventActorKind, EventSourceKind } from '../../../kernel/index.js';
|
|
3
|
+
import { ExternalWorkOutcome } from '../../contracts/outcome-vocabulary.js';
|
|
4
|
+
import { integrationStream } from '../../contracts/streams.js';
|
|
5
|
+
import { GitHubEventType } from '../contracts/events.js';
|
|
6
|
+
import { formatGitHubResourceKey } from '../contracts/external-key.js';
|
|
7
|
+
import { gitHubAssigneeLogins, gitHubLabelNames, } from '../contracts/payloads.js';
|
|
8
|
+
import { GitHubAdapter, UnknownGitHubIdentity } from '../contracts/vocabulary.js';
|
|
9
|
+
import { gitHubContentFingerprint, withoutWakeMarkers } from './content-fingerprint.js';
|
|
10
|
+
export function issueObservation(input) {
|
|
11
|
+
const key = formatGitHubResourceKey({
|
|
12
|
+
...parseRepository(input.repository),
|
|
13
|
+
number: input.issue.number,
|
|
14
|
+
});
|
|
15
|
+
const actor = {
|
|
16
|
+
id: input.issue.user?.login ?? UnknownGitHubIdentity,
|
|
17
|
+
kind: input.issue.user?.type === 'Bot' ? ReviewActorKind.Bot : ReviewActorKind.Human,
|
|
18
|
+
};
|
|
19
|
+
const labels = gitHubLabelNames(input.issue);
|
|
20
|
+
const assignees = gitHubAssigneeLogins(input.issue);
|
|
21
|
+
const outcome = issueOutcome(input.issue);
|
|
22
|
+
// Wake's own status/stage/workflow labels are excluded here so republishing them
|
|
23
|
+
// never looks like an external change and re-triggers discovery.
|
|
24
|
+
const fingerprint = gitHubContentFingerprint({
|
|
25
|
+
title: input.issue.title,
|
|
26
|
+
body: input.issue.body ?? '',
|
|
27
|
+
state: input.issue.state,
|
|
28
|
+
outcome,
|
|
29
|
+
actor,
|
|
30
|
+
labels: withoutWakeMarkers(labels),
|
|
31
|
+
assignees: [...assignees].sort(),
|
|
32
|
+
});
|
|
33
|
+
return createEventDraft({
|
|
34
|
+
eventId: `github:issue:${key}:${fingerprint}`,
|
|
35
|
+
eventType: GitHubEventType.WorkObserved,
|
|
36
|
+
occurredAt: input.issue.updated_at,
|
|
37
|
+
correlationId: `github:${key}`,
|
|
38
|
+
causationId: `github:${key}:${fingerprint}`,
|
|
39
|
+
actor: { kind: EventActorKind.Integration, id: 'github' },
|
|
40
|
+
source: { kind: EventSourceKind.Adapter, id: input.adapter ?? GitHubAdapter },
|
|
41
|
+
stream: integrationStream(input.adapter ?? GitHubAdapter),
|
|
42
|
+
payload: {
|
|
43
|
+
externalKey: key,
|
|
44
|
+
kind: 'issue',
|
|
45
|
+
title: input.issue.title,
|
|
46
|
+
body: input.issue.body ?? '',
|
|
47
|
+
state: input.issue.state,
|
|
48
|
+
outcome,
|
|
49
|
+
revision: fingerprint,
|
|
50
|
+
actor,
|
|
51
|
+
labels,
|
|
52
|
+
assignees,
|
|
53
|
+
raw: { number: input.issue.number },
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function issueOutcome(issue) {
|
|
58
|
+
if (issue.state !== PullRequestState.Closed)
|
|
59
|
+
return undefined;
|
|
60
|
+
return issue.state_reason === 'not_planned'
|
|
61
|
+
? ExternalWorkOutcome.Cancelled
|
|
62
|
+
: ExternalWorkOutcome.Completed;
|
|
63
|
+
}
|
|
64
|
+
function parseRepository(repository) {
|
|
65
|
+
const [owner, repo, ...extra] = repository.split('/');
|
|
66
|
+
if (owner === undefined || repo === undefined || extra.length > 0)
|
|
67
|
+
throw new Error(`Invalid GitHub repository: ${repository}`);
|
|
68
|
+
return { owner, repo };
|
|
69
|
+
}
|
|
70
|
+
export function issueCommentObservation(input) {
|
|
71
|
+
const body = input.comment.body?.trim();
|
|
72
|
+
if (body === undefined || body.length === 0)
|
|
73
|
+
return null;
|
|
74
|
+
const key = formatGitHubResourceKey({
|
|
75
|
+
...parseRepository(input.repository),
|
|
76
|
+
number: input.issue.number,
|
|
77
|
+
});
|
|
78
|
+
const location = commentLocation(input.comment);
|
|
79
|
+
return createEventDraft({
|
|
80
|
+
eventId: `github:issue-comment:${key}:${input.comment.id}:${input.comment.updated_at}`,
|
|
81
|
+
eventType: GitHubEventType.CommentObserved,
|
|
82
|
+
occurredAt: input.comment.updated_at,
|
|
83
|
+
correlationId: `github:${key}`,
|
|
84
|
+
causationId: `github:issue-comment:${input.comment.id}`,
|
|
85
|
+
actor: { kind: EventActorKind.Integration, id: 'github' },
|
|
86
|
+
source: { kind: EventSourceKind.Adapter, id: input.adapter ?? GitHubAdapter },
|
|
87
|
+
stream: integrationStream(input.adapter ?? GitHubAdapter),
|
|
88
|
+
payload: {
|
|
89
|
+
reviewKind: 'issue',
|
|
90
|
+
externalKey: key,
|
|
91
|
+
body,
|
|
92
|
+
revision: input.comment.updated_at,
|
|
93
|
+
...(location === undefined ? {} : { location }),
|
|
94
|
+
actor: {
|
|
95
|
+
id: input.comment.user?.login ?? UnknownGitHubIdentity,
|
|
96
|
+
kind: input.comment.user?.type === 'Bot' ? ReviewActorKind.Bot : ReviewActorKind.Human,
|
|
97
|
+
},
|
|
98
|
+
raw: { id: input.comment.id },
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function commentLocation(comment) {
|
|
103
|
+
if (comment.path === undefined ||
|
|
104
|
+
comment.line === undefined ||
|
|
105
|
+
comment.line === null ||
|
|
106
|
+
comment.side === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
return { path: comment.path, line: comment.line, side: comment.side };
|
|
109
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { PullRequestCheckState, PullRequestState, ReviewActorKind, } from '../../../activities/index.js';
|
|
3
|
+
import { createEventDraft, EventActorKind, EventSourceKind } from '../../../kernel/index.js';
|
|
4
|
+
import { integrationStream } from '../../contracts/streams.js';
|
|
5
|
+
import { GitHubEventType } from '../contracts/events.js';
|
|
6
|
+
import { formatGitHubResourceKey } from '../contracts/external-key.js';
|
|
7
|
+
import { gitHubAssigneeLogins, gitHubLabelNames, } from '../contracts/payloads.js';
|
|
8
|
+
import { GitHubAdapter, GitHubCheckRunStatus, UnknownGitHubIdentity, UnknownGitHubRevision, } from '../contracts/vocabulary.js';
|
|
9
|
+
import { withoutWakeMarkers } from './content-fingerprint.js';
|
|
10
|
+
export function createGitHubPullRequestSource(input) {
|
|
11
|
+
const { owner, repo } = parseRepository(input.repository);
|
|
12
|
+
return {
|
|
13
|
+
async poll(signal) {
|
|
14
|
+
signal.throwIfAborted();
|
|
15
|
+
const pullRequests = await input.client.listPullRequests(owner, repo, input.maxResults);
|
|
16
|
+
return mapConcurrent(pullRequests, input.maxConcurrency ?? 4, async (pullRequest) => {
|
|
17
|
+
signal.throwIfAborted();
|
|
18
|
+
const headRevision = fallback(pullRequest.head?.sha, pullRequest.updated_at);
|
|
19
|
+
const evidence = await readCheckEvidence(input.client, owner, repo, headRevision);
|
|
20
|
+
return pullRequestObservation({
|
|
21
|
+
repository: input.repository,
|
|
22
|
+
pullRequest,
|
|
23
|
+
evidence,
|
|
24
|
+
...(input.adapter === undefined ? {} : { adapter: input.adapter }),
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function pullRequestObservation(input) {
|
|
31
|
+
const pullRequest = input.pullRequest;
|
|
32
|
+
const key = formatGitHubResourceKey({
|
|
33
|
+
...parseRepository(input.repository),
|
|
34
|
+
number: pullRequest.number,
|
|
35
|
+
});
|
|
36
|
+
const revision = fallback(pullRequest.head?.sha, pullRequest.updated_at);
|
|
37
|
+
const checks = input.evidence.available
|
|
38
|
+
? normalizeCheckEvidence(input.evidence.checkRuns, input.evidence.statuses)
|
|
39
|
+
: PullRequestCheckState.Unknown;
|
|
40
|
+
const payload = {
|
|
41
|
+
externalKey: key,
|
|
42
|
+
kind: 'pull-request',
|
|
43
|
+
title: pullRequest.title,
|
|
44
|
+
body: fallback(pullRequest.body, ''),
|
|
45
|
+
state: pullRequestState(pullRequest),
|
|
46
|
+
revision,
|
|
47
|
+
headRevision: revision,
|
|
48
|
+
baseRevision: fallback(pullRequest.base?.sha, UnknownGitHubRevision),
|
|
49
|
+
checks,
|
|
50
|
+
actor: {
|
|
51
|
+
id: fallback(pullRequest.user?.login, UnknownGitHubIdentity),
|
|
52
|
+
kind: actorKind(pullRequest.user?.type),
|
|
53
|
+
},
|
|
54
|
+
labels: gitHubLabelNames(pullRequest),
|
|
55
|
+
assignees: gitHubAssigneeLogins(pullRequest),
|
|
56
|
+
raw: { number: pullRequest.number },
|
|
57
|
+
};
|
|
58
|
+
const fingerprint = evidenceFingerprint(payload, input.evidence);
|
|
59
|
+
return createEventDraft({
|
|
60
|
+
eventId: `github:pr:${key}:${fingerprint}`,
|
|
61
|
+
eventType: GitHubEventType.WorkObserved,
|
|
62
|
+
occurredAt: pullRequest.updated_at,
|
|
63
|
+
correlationId: `github:${key}`,
|
|
64
|
+
causationId: `github:${key}:${fingerprint}`,
|
|
65
|
+
actor: { kind: EventActorKind.Integration, id: 'github' },
|
|
66
|
+
source: { kind: EventSourceKind.Adapter, id: input.adapter ?? GitHubAdapter },
|
|
67
|
+
stream: integrationStream(input.adapter ?? GitHubAdapter),
|
|
68
|
+
payload,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function normalizeCheckEvidence(checkRuns, statuses) {
|
|
72
|
+
const states = [
|
|
73
|
+
...checkRuns.map(checkRunState),
|
|
74
|
+
...statuses.map((status) => commitStatusState(status.state)),
|
|
75
|
+
];
|
|
76
|
+
if (states.includes(PullRequestCheckState.Failing))
|
|
77
|
+
return PullRequestCheckState.Failing;
|
|
78
|
+
if (states.includes(PullRequestCheckState.Pending))
|
|
79
|
+
return PullRequestCheckState.Pending;
|
|
80
|
+
if (states.includes(PullRequestCheckState.Passing))
|
|
81
|
+
return PullRequestCheckState.Passing;
|
|
82
|
+
return PullRequestCheckState.Unknown;
|
|
83
|
+
}
|
|
84
|
+
async function readCheckEvidence(client, owner, repo, headRevision) {
|
|
85
|
+
try {
|
|
86
|
+
const [checkRuns, statuses] = await Promise.all([
|
|
87
|
+
client.listCheckRunsForRef(owner, repo, headRevision),
|
|
88
|
+
client.getCombinedStatusForRef(owner, repo, headRevision),
|
|
89
|
+
]);
|
|
90
|
+
return { available: true, checkRuns, statuses };
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return { available: false, checkRuns: [], statuses: [] };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function mapConcurrent(values, concurrency, transform) {
|
|
97
|
+
const output = new Array(values.length);
|
|
98
|
+
let nextIndex = 0;
|
|
99
|
+
async function worker() {
|
|
100
|
+
while (nextIndex < values.length) {
|
|
101
|
+
const index = nextIndex;
|
|
102
|
+
nextIndex += 1;
|
|
103
|
+
output[index] = await transform(values[index]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const workerCount = Math.min(Math.max(1, concurrency), values.length);
|
|
107
|
+
await Promise.all(Array.from({ length: workerCount }, worker));
|
|
108
|
+
return output;
|
|
109
|
+
}
|
|
110
|
+
function evidenceFingerprint(payload, evidence) {
|
|
111
|
+
const providerEvidence = {
|
|
112
|
+
available: evidence.available,
|
|
113
|
+
checkRuns: evidence.checkRuns.map(checkRunIdentity).sort(compareJson),
|
|
114
|
+
statuses: evidence.statuses.map(statusIdentity).sort(compareJson),
|
|
115
|
+
};
|
|
116
|
+
// Wake's own status/stage/workflow labels are excluded so republishing them
|
|
117
|
+
// never looks like an external change and re-triggers a WorkObserved event.
|
|
118
|
+
const fingerprintPayload = { ...payload, labels: withoutWakeMarkers(payload.labels) };
|
|
119
|
+
return createHash('sha256')
|
|
120
|
+
.update(JSON.stringify({ payload: fingerprintPayload, providerEvidence }))
|
|
121
|
+
.digest('hex');
|
|
122
|
+
}
|
|
123
|
+
function checkRunIdentity(checkRun) {
|
|
124
|
+
return {
|
|
125
|
+
id: checkRun.id ?? null,
|
|
126
|
+
name: checkRun.name ?? null,
|
|
127
|
+
status: checkRun.status ?? null,
|
|
128
|
+
conclusion: checkRun.conclusion ?? null,
|
|
129
|
+
startedAt: checkRun.started_at ?? null,
|
|
130
|
+
completedAt: checkRun.completed_at ?? null,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function statusIdentity(status) {
|
|
134
|
+
return {
|
|
135
|
+
id: status.id ?? null,
|
|
136
|
+
context: status.context ?? null,
|
|
137
|
+
state: status.state ?? null,
|
|
138
|
+
createdAt: status.created_at ?? null,
|
|
139
|
+
updatedAt: status.updated_at ?? null,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function compareJson(left, right) {
|
|
143
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
144
|
+
}
|
|
145
|
+
function checkRunState(checkRun) {
|
|
146
|
+
if (checkRun.status !== GitHubCheckRunStatus.Completed)
|
|
147
|
+
return PullRequestCheckState.Pending;
|
|
148
|
+
if (checkRun.conclusion === null || checkRun.conclusion === undefined)
|
|
149
|
+
return PullRequestCheckState.Pending;
|
|
150
|
+
return passingConclusions.has(checkRun.conclusion)
|
|
151
|
+
? PullRequestCheckState.Passing
|
|
152
|
+
: PullRequestCheckState.Failing;
|
|
153
|
+
}
|
|
154
|
+
function commitStatusState(state) {
|
|
155
|
+
if (state === GitHubCommitStatusState.Failure || state === GitHubCommitStatusState.Error)
|
|
156
|
+
return PullRequestCheckState.Failing;
|
|
157
|
+
if (state === GitHubCommitStatusState.Pending)
|
|
158
|
+
return PullRequestCheckState.Pending;
|
|
159
|
+
return state === GitHubCommitStatusState.Success
|
|
160
|
+
? PullRequestCheckState.Passing
|
|
161
|
+
: PullRequestCheckState.Unknown;
|
|
162
|
+
}
|
|
163
|
+
function pullRequestState(pullRequest) {
|
|
164
|
+
if (pullRequest.merged_at !== null && pullRequest.merged_at !== undefined)
|
|
165
|
+
return PullRequestState.Merged;
|
|
166
|
+
return pullRequest.state;
|
|
167
|
+
}
|
|
168
|
+
function parseRepository(repository) {
|
|
169
|
+
const [owner, repo, ...extra] = repository.split('/');
|
|
170
|
+
if (owner === undefined || repo === undefined || extra.length > 0)
|
|
171
|
+
throw new Error(`Invalid GitHub repository: ${repository}`);
|
|
172
|
+
return { owner, repo };
|
|
173
|
+
}
|
|
174
|
+
function fallback(value, defaultValue) {
|
|
175
|
+
return value === null || value === undefined ? defaultValue : value;
|
|
176
|
+
}
|
|
177
|
+
function actorKind(type) {
|
|
178
|
+
return type === 'Bot' ? ReviewActorKind.Bot : ReviewActorKind.Human;
|
|
179
|
+
}
|
|
180
|
+
const passingConclusions = new Set(['success', 'neutral', 'skipped']);
|
|
181
|
+
const GitHubCommitStatusState = {
|
|
182
|
+
Error: 'error',
|
|
183
|
+
Failure: 'failure',
|
|
184
|
+
Pending: PullRequestCheckState.Pending,
|
|
185
|
+
Success: 'success',
|
|
186
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReviewActorKind, ReviewerAuthorizationSource } from '../../../activities/index.js';
|
|
2
|
+
import { createEventDraft, EventActorKind, EventSourceKind } from '../../../kernel/index.js';
|
|
3
|
+
import { integrationStream } from '../../contracts/streams.js';
|
|
4
|
+
import { GitHubEventType } from '../contracts/events.js';
|
|
5
|
+
import { formatGitHubResourceKey } from '../contracts/external-key.js';
|
|
6
|
+
import { GitHubAdapter, GitHubReviewState, UnknownGitHubIdentity, } from '../contracts/vocabulary.js';
|
|
7
|
+
export function githubReviewObservation(input) {
|
|
8
|
+
const body = input.review.body?.trim();
|
|
9
|
+
const command = reviewCommand(input.review.state);
|
|
10
|
+
const actorId = input.review.user?.login ?? UnknownGitHubIdentity;
|
|
11
|
+
const key = formatGitHubResourceKey({
|
|
12
|
+
...parseRepository(input.repository),
|
|
13
|
+
number: input.pullRequest.number,
|
|
14
|
+
});
|
|
15
|
+
const draft = (eventId, content) => createEventDraft({
|
|
16
|
+
eventId,
|
|
17
|
+
eventType: GitHubEventType.CommentObserved,
|
|
18
|
+
occurredAt: input.review.submitted_at,
|
|
19
|
+
correlationId: `github:${key}`,
|
|
20
|
+
causationId: `github:review:${input.review.id}`,
|
|
21
|
+
actor: { kind: EventActorKind.Integration, id: 'github' },
|
|
22
|
+
source: { kind: EventSourceKind.Adapter, id: 'github' },
|
|
23
|
+
stream: integrationStream(GitHubAdapter),
|
|
24
|
+
payload: {
|
|
25
|
+
externalKey: key,
|
|
26
|
+
reviewKind: 'formal',
|
|
27
|
+
body: content,
|
|
28
|
+
revision: input.review.commit_id,
|
|
29
|
+
actor: {
|
|
30
|
+
id: actorId,
|
|
31
|
+
kind: input.review.user?.type === 'Bot' ? ReviewActorKind.Bot : ReviewActorKind.Human,
|
|
32
|
+
},
|
|
33
|
+
resourceAuthorId: input.pullRequest.user?.login ?? UnknownGitHubIdentity,
|
|
34
|
+
authorization: configuredAuthorization(actorId, input.authorizedReviewers),
|
|
35
|
+
raw: { reviewId: input.review.id, state: input.review.state },
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return [
|
|
39
|
+
...(body === undefined || body.length === 0
|
|
40
|
+
? []
|
|
41
|
+
: [
|
|
42
|
+
draft(`github:review-feedback:${key}:${input.review.id}:${input.review.commit_id}`, body),
|
|
43
|
+
]),
|
|
44
|
+
...(command === null
|
|
45
|
+
? []
|
|
46
|
+
: [
|
|
47
|
+
draft(`github:review:${key}:${input.review.id}:${input.review.state}:${input.review.commit_id}`, command),
|
|
48
|
+
]),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
function parseRepository(repository) {
|
|
52
|
+
const [owner, repo, ...extra] = repository.split('/');
|
|
53
|
+
if (owner === undefined || repo === undefined || extra.length > 0)
|
|
54
|
+
throw new Error(`Invalid GitHub repository: ${repository}`);
|
|
55
|
+
return { owner, repo };
|
|
56
|
+
}
|
|
57
|
+
function configuredAuthorization(actorId, reviewers) {
|
|
58
|
+
const reviewerId = reviewers.find((reviewer) => sameIdentity(reviewer, actorId));
|
|
59
|
+
return reviewerId === undefined
|
|
60
|
+
? { source: ReviewerAuthorizationSource.None }
|
|
61
|
+
: { source: ReviewerAuthorizationSource.ConfiguredReviewer, reviewerId };
|
|
62
|
+
}
|
|
63
|
+
function reviewCommand(state) {
|
|
64
|
+
if (state === GitHubReviewState.Approved)
|
|
65
|
+
return '/accepted';
|
|
66
|
+
return state === GitHubReviewState.ChangesRequested ? '/changes' : null;
|
|
67
|
+
}
|
|
68
|
+
function sameIdentity(left, right) {
|
|
69
|
+
return left.toLowerCase() === right.toLowerCase();
|
|
70
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { GitHubEventType } from '../contracts/events.js';
|
|
2
|
+
import { issueCommentObservation, issueObservation } from './issue-source.js';
|
|
3
|
+
import { createGitHubPullRequestSource } from './pr-source.js';
|
|
4
|
+
import { githubReviewObservation } from './review-source.js';
|
|
5
|
+
export function createGitHubSource(config, client, adapter) {
|
|
6
|
+
let nextPollAt = 0;
|
|
7
|
+
// Draft eventIds are already content fingerprints (see issue-source.ts/pr-source.ts),
|
|
8
|
+
// so the journal itself is idempotent per item. This cache only avoids re-appending
|
|
9
|
+
// (and re-triggering downstream translation) an unchanged item on every poll within
|
|
10
|
+
// a single process lifetime — it's a perf optimization, not a correctness dependency,
|
|
11
|
+
// so it's safe for it to reset on restart.
|
|
12
|
+
const lastEventIds = new Map();
|
|
13
|
+
return {
|
|
14
|
+
async poll(signal) {
|
|
15
|
+
if (Date.now() < nextPollAt)
|
|
16
|
+
return [];
|
|
17
|
+
nextPollAt = Date.now() + config.polling.lookbackMs;
|
|
18
|
+
const perRepository = await Promise.all(config.repositories.map(({ owner, repo }) => pollRepository({ client, config, adapter, signal, owner, repo })));
|
|
19
|
+
return perRepository.flat().filter((draft) => {
|
|
20
|
+
if (draft.eventType !== GitHubEventType.WorkObserved)
|
|
21
|
+
return true;
|
|
22
|
+
const prior = lastEventIds.get(draft.payload.externalKey);
|
|
23
|
+
lastEventIds.set(draft.payload.externalKey, draft.eventId);
|
|
24
|
+
return prior !== draft.eventId;
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function pollRepository(input) {
|
|
30
|
+
const { client, config, adapter, signal, owner, repo } = input;
|
|
31
|
+
const context = {
|
|
32
|
+
client,
|
|
33
|
+
config,
|
|
34
|
+
adapter,
|
|
35
|
+
owner,
|
|
36
|
+
repo,
|
|
37
|
+
repository: `${owner}/${repo}`,
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
const pullRequestPayloads = await client.listPullRequests(owner, repo, config.polling.maxPerRepo);
|
|
41
|
+
const [issues, pullRequests, reviews, reviewComments] = await Promise.all([
|
|
42
|
+
client.listIssues(owner, repo, config.polling.maxPerRepo),
|
|
43
|
+
createGitHubPullRequestSource({
|
|
44
|
+
client: { ...client, listPullRequests: async () => pullRequestPayloads },
|
|
45
|
+
repository: context.repository,
|
|
46
|
+
maxResults: config.polling.maxPerRepo,
|
|
47
|
+
...(adapter === undefined ? {} : { adapter }),
|
|
48
|
+
}).poll(signal),
|
|
49
|
+
reviewEventsFor(context, pullRequestPayloads),
|
|
50
|
+
reviewCommentEventsFor(context, pullRequestPayloads),
|
|
51
|
+
]);
|
|
52
|
+
const issueComments = await issueCommentEventsFor(context, issues);
|
|
53
|
+
return [
|
|
54
|
+
...issues
|
|
55
|
+
.filter((issue) => issue.pull_request === undefined)
|
|
56
|
+
.map((issue) => issueObservation({
|
|
57
|
+
repository: context.repository,
|
|
58
|
+
issue,
|
|
59
|
+
...(adapter === undefined ? {} : { adapter }),
|
|
60
|
+
})),
|
|
61
|
+
...pullRequests,
|
|
62
|
+
...reviews,
|
|
63
|
+
...reviewComments,
|
|
64
|
+
...issueComments,
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function reviewCommentEventsFor(context, pullRequests) {
|
|
72
|
+
if (context.client.listReviewComments === undefined)
|
|
73
|
+
return [];
|
|
74
|
+
const items = await Promise.all(pullRequests.map(async (pullRequest) => (await context.client.listReviewComments(context.owner, context.repo, pullRequest.number, context.config.polling.commentPageSize)).flatMap((comment) => {
|
|
75
|
+
const event = issueCommentObservation({
|
|
76
|
+
repository: context.repository,
|
|
77
|
+
issue: pullRequest,
|
|
78
|
+
comment,
|
|
79
|
+
...(context.adapter === undefined ? {} : { adapter: context.adapter }),
|
|
80
|
+
});
|
|
81
|
+
return event === null ? [] : [event];
|
|
82
|
+
})));
|
|
83
|
+
return items.flat();
|
|
84
|
+
}
|
|
85
|
+
async function reviewEventsFor(context, pullRequestPayloads) {
|
|
86
|
+
const items = await Promise.all(pullRequestPayloads.map(async (pullRequest) => {
|
|
87
|
+
const reviewEvents = await context.client.listReviews(context.owner, context.repo, pullRequest.number, context.config.polling.commentPageSize);
|
|
88
|
+
return reviewEvents.flatMap((review) => githubReviewObservation({
|
|
89
|
+
repository: context.repository,
|
|
90
|
+
pullRequest,
|
|
91
|
+
review,
|
|
92
|
+
authorizedReviewers: [],
|
|
93
|
+
}));
|
|
94
|
+
}));
|
|
95
|
+
return items.flat();
|
|
96
|
+
}
|
|
97
|
+
async function issueCommentEventsFor(context, issues) {
|
|
98
|
+
const items = await Promise.all(issues.map(async (issue) => (await context.client.listIssueComments(context.owner, context.repo, issue.number, context.config.polling.commentPageSize)).flatMap((comment) => {
|
|
99
|
+
const event = issueCommentObservation({
|
|
100
|
+
repository: context.repository,
|
|
101
|
+
issue,
|
|
102
|
+
comment,
|
|
103
|
+
...(context.adapter === undefined ? {} : { adapter: context.adapter }),
|
|
104
|
+
});
|
|
105
|
+
return event === null ? [] : [event];
|
|
106
|
+
})));
|
|
107
|
+
return items.flat();
|
|
108
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BuiltInResourceCapability, resourceId, resourceKind } from '../../resources/index.js';
|
|
2
|
+
import { ArtifactVerificationResult } from '../contracts/artifact-vocabulary.js';
|
|
3
|
+
import { InboundTranslator } from './application/inbound-translator.js';
|
|
4
|
+
import { translateGitHubOutbound } from './application/outbound-translator.js';
|
|
5
|
+
import { createGitHubWakeLabelReconciler } from './application/wake-labels.js';
|
|
6
|
+
import { gitHubConfigSchema } from './contracts/config.js';
|
|
7
|
+
import { GitHubEventType } from './contracts/events.js';
|
|
8
|
+
import { createGitHubClient } from './infrastructure/client.js';
|
|
9
|
+
import { createGitHubDelivery } from './infrastructure/delivery.js';
|
|
10
|
+
import { resolveGitHubCliToken } from './infrastructure/gh-auth.js';
|
|
11
|
+
import { createGitHubSource } from './infrastructure/source.js';
|
|
12
|
+
export const gitHubProviderDefinition = {
|
|
13
|
+
provider: 'github',
|
|
14
|
+
eventTypes: Object.values(GitHubEventType),
|
|
15
|
+
parseConfig(value) {
|
|
16
|
+
return gitHubConfigSchema.parse(value);
|
|
17
|
+
},
|
|
18
|
+
create({ adapter, config, services }) {
|
|
19
|
+
if (services === undefined)
|
|
20
|
+
throw new Error('GitHub provider requires composed services');
|
|
21
|
+
const client = createGitHubClient(config.token ?? resolveGitHubCliToken());
|
|
22
|
+
return {
|
|
23
|
+
adapter,
|
|
24
|
+
eventTypes: Object.values(GitHubEventType),
|
|
25
|
+
source: createGitHubSource(config, client, adapter),
|
|
26
|
+
maintenance: createGitHubWakeLabelReconciler({
|
|
27
|
+
orchestration: services.orchestration,
|
|
28
|
+
resources: services.resources,
|
|
29
|
+
work: services.work,
|
|
30
|
+
getLabels: client.getIssueLabels,
|
|
31
|
+
setLabels: client.setIssueLabels,
|
|
32
|
+
}),
|
|
33
|
+
delivery: createGitHubDelivery(async (intent, idempotencyKey) => {
|
|
34
|
+
const resource = await services.resources.get(resourceId(intent.resourceId));
|
|
35
|
+
if (resource === null)
|
|
36
|
+
throw new Error(`GitHub resource ${intent.resourceId} is unavailable`);
|
|
37
|
+
return client.deliver({ ...translateGitHubOutbound(resource, intent), idempotencyKey });
|
|
38
|
+
}),
|
|
39
|
+
verifyArtifact: async (kind, externalKey, context) => {
|
|
40
|
+
if (kind !== resourceKind('pull-request'))
|
|
41
|
+
return ArtifactVerificationResult.NotFound;
|
|
42
|
+
const parsed = parsePullRequestKey(externalKey.key);
|
|
43
|
+
if (parsed === null)
|
|
44
|
+
return ArtifactVerificationResult.NotFound;
|
|
45
|
+
try {
|
|
46
|
+
const pullRequest = await client.getPullRequest(parsed.owner, parsed.repo, parsed.number);
|
|
47
|
+
if (pullRequest.head.ref !== context.workspaceBranch)
|
|
48
|
+
return ArtifactVerificationResult.NotFound;
|
|
49
|
+
return {
|
|
50
|
+
kind,
|
|
51
|
+
externalKey,
|
|
52
|
+
capabilities: [
|
|
53
|
+
BuiltInResourceCapability.Reviewable,
|
|
54
|
+
BuiltInResourceCapability.Approvable,
|
|
55
|
+
BuiltInResourceCapability.Mergeable,
|
|
56
|
+
BuiltInResourceCapability.Revisioned,
|
|
57
|
+
],
|
|
58
|
+
...(pullRequest.head.sha === undefined ? {} : { revision: pullRequest.head.sha }),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (typeof error === 'object' &&
|
|
63
|
+
error !== null &&
|
|
64
|
+
'status' in error &&
|
|
65
|
+
error.status === 404)
|
|
66
|
+
return ArtifactVerificationResult.NotFound;
|
|
67
|
+
return ArtifactVerificationResult.Ambiguous;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
inbound: new InboundTranslator(services.journal, services.checkpoints, services.work, services.resources, {
|
|
71
|
+
pullRequests: services.pullRequests,
|
|
72
|
+
ids: services.ids,
|
|
73
|
+
lookup: services.resourceLookup,
|
|
74
|
+
adapter,
|
|
75
|
+
orchestration: services.orchestration,
|
|
76
|
+
runs: services.runs,
|
|
77
|
+
routing: services.routing,
|
|
78
|
+
intake: config.intake,
|
|
79
|
+
conclusion: services.conclusion,
|
|
80
|
+
}),
|
|
81
|
+
checkConnectivity: async () => {
|
|
82
|
+
await client.authenticatedLogin();
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
function parsePullRequestKey(key) {
|
|
88
|
+
const match = /^(?<owner>[^/]+)\/(?<repo>[^#]+)#(?<number>[1-9]\d*)$/.exec(key);
|
|
89
|
+
if (match?.groups === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
return {
|
|
92
|
+
owner: match.groups.owner,
|
|
93
|
+
repo: match.groups.repo,
|
|
94
|
+
number: Number(match.groups.number),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from '../kernel/index.js';
|
|
2
|
+
export * from './application/poll-service.js';
|
|
3
|
+
export * from './application/work-admission.js';
|
|
4
|
+
export * from './application/work-conclusion.js';
|
|
5
|
+
export * from './application/artifact-registration-reactor.js';
|
|
6
|
+
export * from './application/agent-run-publication-reactor.js';
|
|
7
|
+
export * from './application/terminal-agent-run-report.js';
|
|
8
|
+
export * from './contracts/config.js';
|
|
9
|
+
export * from './contracts/artifact-events.js';
|
|
10
|
+
export * from './contracts/artifact-vocabulary.js';
|
|
11
|
+
export * from './contracts/outcome-vocabulary.js';
|
|
12
|
+
export * from './contracts/identifiers.js';
|
|
13
|
+
export * from './contracts/intake-rules.js';
|
|
14
|
+
export * from './contracts/intake.js';
|
|
15
|
+
export * from './contracts/provider.js';
|
|
16
|
+
export * from './contracts/streams.js';
|
|
17
|
+
export * from './delivery/application/delivery-outcome-reactor.js';
|
|
18
|
+
export * from './delivery/application/delivery-projector.js';
|
|
19
|
+
export * from './delivery/application/delivery-service.js';
|
|
20
|
+
export * from './delivery/contracts/commands.js';
|
|
21
|
+
export * from './delivery/contracts/config.js';
|
|
22
|
+
export * from './delivery/contracts/event-factory.js';
|
|
23
|
+
export * from './delivery/contracts/events.js';
|
|
24
|
+
export * from './delivery/contracts/intents.js';
|
|
25
|
+
export * from './delivery/contracts/views.js';
|
|
26
|
+
export * from './delivery/contracts/vocabulary.js';
|
|
27
|
+
export * from './fake/durable-delivery-provider.js';
|
|
28
|
+
export * from './fake/external-sink.js';
|
|
29
|
+
export * from './fake/external-source.js';
|
|
30
|
+
export * from './fake/provider.js';
|