@atolis-hq/wake 0.2.97 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/activities/agent/agent-activity-definition.js +26 -0
- package/dist/src/activities/agent/agent-activity.js +171 -0
- package/dist/src/activities/agent/agent-result.js +149 -0
- package/dist/src/activities/contracts/activity.js +10 -0
- package/dist/src/activities/contracts/config.js +2 -0
- package/dist/src/activities/contracts/event-schema.js +302 -0
- package/dist/src/activities/contracts/events.js +42 -0
- package/dist/src/activities/contracts/identifiers.js +29 -0
- package/dist/src/activities/contracts/registry.js +71 -0
- package/dist/src/activities/contracts/streams.js +17 -0
- package/dist/src/activities/contracts/vocabulary.js +58 -0
- package/dist/src/activities/index.js +21 -0
- package/dist/src/activities/pr/activity-support.js +111 -0
- package/dist/src/activities/pr/application.js +158 -0
- package/dist/src/activities/pr/approve.js +85 -0
- package/dist/src/activities/pr/capability.js +11 -0
- package/dist/src/activities/pr/decision-claim.js +76 -0
- package/dist/src/activities/pr/event-drafts.js +66 -0
- package/dist/src/activities/pr/intent.js +37 -0
- package/dist/src/activities/pr/merge-authority-gate.js +14 -0
- package/dist/src/activities/pr/merge.js +110 -0
- package/dist/src/activities/pr/policy.js +135 -0
- package/dist/src/activities/pr/projection.js +130 -0
- package/dist/src/activities/pr/vocabulary.js +30 -0
- package/dist/src/activities/review/authorization.js +22 -0
- package/dist/src/activities/review/contracts.js +22 -0
- package/dist/src/activities/review/signals.js +3 -0
- package/dist/src/bootstrap/analytics-projection.js +26 -0
- package/dist/src/bootstrap/board-projection.js +337 -0
- package/dist/src/bootstrap/composition-root.js +382 -0
- package/dist/src/bootstrap/config/load-config.js +51 -0
- package/dist/src/bootstrap/config/root-schema.js +134 -0
- package/dist/src/bootstrap/external-ref.js +12 -0
- package/dist/src/bootstrap/fake-provider-files.js +44 -0
- package/dist/src/bootstrap/fake-scenarios.js +22 -0
- package/dist/src/bootstrap/index.js +48 -0
- package/dist/src/bootstrap/initialise.js +434 -0
- package/dist/src/bootstrap/paths.js +15 -0
- package/dist/src/bootstrap/projection-runtime.js +27 -0
- package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
- package/dist/src/bootstrap/runner-registry.js +30 -0
- package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
- package/dist/src/bootstrap/self-update-application.js +195 -0
- package/dist/src/bootstrap/self-update-failure-log.js +33 -0
- package/dist/src/bootstrap/source-update-port.js +47 -0
- package/dist/src/bootstrap/status-publish-activity.js +42 -0
- package/dist/src/bootstrap/surface-api-applications.js +325 -0
- package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
- package/dist/src/bootstrap/surface-api-metadata.js +12 -0
- package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
- package/dist/src/bootstrap/surface-api-run-context.js +5 -0
- package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
- package/dist/src/bootstrap/surface-applications.js +7 -0
- package/dist/src/bootstrap/surface-cli-applications.js +701 -0
- package/dist/src/bootstrap/update-ledger.js +61 -0
- package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
- package/dist/src/{version.js → bootstrap/version.js} +35 -51
- package/dist/src/control-plane/application/advance-once.js +184 -0
- package/dist/src/control-plane/application/control-plane-projection.js +42 -0
- package/dist/src/control-plane/application/control-plane-service.js +42 -0
- package/dist/src/control-plane/application/intake-pipeline.js +29 -0
- package/dist/src/control-plane/application/runner-control-service.js +66 -0
- package/dist/src/control-plane/application/runner-pipeline.js +57 -0
- package/dist/src/control-plane/application/schedule-service.js +47 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
- package/dist/src/control-plane/contracts/commands.js +10 -0
- package/dist/src/control-plane/contracts/config.js +22 -0
- package/dist/src/control-plane/contracts/events.js +81 -0
- package/dist/src/control-plane/contracts/streams.js +5 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
- package/dist/src/control-plane/domain/quota-policy.js +26 -0
- package/dist/src/control-plane/domain/runner-quota.js +35 -0
- package/dist/src/control-plane/domain/schedule-policy.js +46 -0
- package/dist/src/control-plane/index.js +20 -0
- package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
- package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
- package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
- package/dist/src/execution/application/activation-claim.js +50 -0
- package/dist/src/execution/application/active-run-cancellation.js +14 -0
- package/dist/src/execution/application/execution-activity.js +97 -0
- package/dist/src/execution/application/execution-projection.js +17 -0
- package/dist/src/execution/application/execution-service.js +372 -0
- package/dist/src/execution/application/execution-validation.js +26 -0
- package/dist/src/execution/application/recovery-service.js +212 -0
- package/dist/src/execution/application/run-lifecycle.js +115 -0
- package/dist/src/execution/application/run-liveness-service.js +80 -0
- package/dist/src/execution/application/run-repository.js +27 -0
- package/dist/src/execution/contracts/commands.js +1 -0
- package/dist/src/execution/contracts/config.js +35 -0
- package/dist/src/execution/contracts/control-plane.js +1 -0
- package/dist/src/execution/contracts/event-factory.js +53 -0
- package/dist/src/execution/contracts/events.js +274 -0
- package/dist/src/execution/contracts/identifiers.js +5 -0
- package/dist/src/execution/contracts/liveness.js +1 -0
- package/dist/src/execution/contracts/results.js +1 -0
- package/dist/src/execution/contracts/runner.js +15 -0
- package/dist/src/execution/contracts/streams.js +10 -0
- package/dist/src/execution/contracts/views.js +1 -0
- package/dist/src/execution/contracts/vocabulary.js +43 -0
- package/dist/src/execution/contracts/workspace.js +1 -0
- package/dist/src/execution/domain/run-result.js +34 -0
- package/dist/src/execution/domain/run.js +142 -0
- package/dist/src/execution/index.js +31 -0
- package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
- package/dist/src/execution/infrastructure/process-execution.js +29 -0
- package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
- package/dist/src/execution/infrastructure/runners/claude.js +120 -0
- package/dist/src/execution/infrastructure/runners/codex.js +143 -0
- package/dist/src/execution/infrastructure/runners/command.js +4 -0
- package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
- package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
- package/dist/src/execution/infrastructure/runners/fake.js +65 -0
- package/dist/src/execution/infrastructure/runners/registry.js +26 -0
- package/dist/src/execution/infrastructure/transcript-store.js +223 -0
- package/dist/src/execution/infrastructure/transcripts.js +11 -0
- package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
- package/dist/src/integrations/application/poll-service.js +25 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
- package/dist/src/integrations/application/work-admission.js +31 -0
- package/dist/src/integrations/application/work-conclusion.js +19 -0
- package/dist/src/integrations/contracts/artifact-events.js +60 -0
- package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
- package/dist/src/integrations/contracts/config.js +14 -0
- package/dist/src/integrations/contracts/identifiers.js +5 -0
- package/dist/src/integrations/contracts/intake-rules.js +14 -0
- package/dist/src/integrations/contracts/intake.js +1 -0
- package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
- package/dist/src/integrations/contracts/provider.js +37 -0
- package/dist/src/integrations/contracts/streams.js +10 -0
- package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
- package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
- package/dist/src/integrations/delivery/contracts/commands.js +1 -0
- package/dist/src/integrations/delivery/contracts/config.js +1 -0
- package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
- package/dist/src/integrations/delivery/contracts/events.js +86 -0
- package/dist/src/integrations/delivery/contracts/intents.js +89 -0
- package/dist/src/integrations/delivery/contracts/views.js +1 -0
- package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
- package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
- package/dist/src/integrations/fake/external-sink.js +9 -0
- package/dist/src/integrations/fake/external-source.js +44 -0
- package/dist/src/integrations/fake/inbound-translator.js +130 -0
- package/dist/src/integrations/fake/provider.js +95 -0
- package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
- package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
- package/dist/src/integrations/github/application/inbound-context.js +10 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
- package/dist/src/integrations/github/application/inbound-translator.js +231 -0
- package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
- package/dist/src/integrations/github/application/intake-policy.js +23 -0
- package/dist/src/integrations/github/application/outbound-translator.js +47 -0
- package/dist/src/integrations/github/application/poll-service.js +29 -0
- package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
- package/dist/src/integrations/github/application/resource-links.js +8 -0
- package/dist/src/integrations/github/application/review-command-translator.js +16 -0
- package/dist/src/integrations/github/application/wake-labels.js +95 -0
- package/dist/src/integrations/github/contracts/config.js +47 -0
- package/dist/src/integrations/github/contracts/events.js +127 -0
- package/dist/src/integrations/github/contracts/external-key.js +19 -0
- package/dist/src/integrations/github/contracts/payloads.js +9 -0
- package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
- package/dist/src/integrations/github/index.js +31 -0
- package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
- package/dist/src/integrations/github/infrastructure/client.js +132 -0
- package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
- package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
- package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
- package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
- package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
- package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
- package/dist/src/integrations/github/infrastructure/source.js +108 -0
- package/dist/src/integrations/github/provider.js +96 -0
- package/dist/src/integrations/index.js +30 -0
- package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
- package/dist/src/kernel/contracts/clock.js +1 -0
- package/dist/src/kernel/contracts/commands.js +1 -0
- package/dist/src/kernel/contracts/event-journal.js +2 -0
- package/dist/src/kernel/contracts/event-schema.js +54 -0
- package/dist/src/kernel/contracts/events.js +11 -0
- package/dist/src/kernel/contracts/id-generator.js +1 -0
- package/dist/src/kernel/contracts/identifiers.js +8 -0
- package/dist/src/kernel/contracts/projection-store.js +1 -0
- package/dist/src/kernel/contracts/relations.js +1 -0
- package/dist/src/kernel/contracts/schema.js +17 -0
- package/dist/src/kernel/contracts/vocabulary.js +6 -0
- package/dist/src/kernel/domain/event-envelope.js +29 -0
- package/dist/src/kernel/domain/match-mode.js +11 -0
- package/dist/src/kernel/domain/relation.js +10 -0
- package/dist/src/kernel/index.js +17 -0
- package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
- package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
- package/dist/src/main.js +137 -1030
- package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
- package/dist/src/orchestration/application/accept-signal.js +35 -0
- package/dist/src/orchestration/application/advance-workflow.js +160 -0
- package/dist/src/orchestration/application/coordination-claims.js +107 -0
- package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
- package/dist/src/orchestration/application/orchestration-projection.js +20 -0
- package/dist/src/orchestration/application/orchestration-repository.js +36 -0
- package/dist/src/orchestration/application/orchestration-service.js +82 -0
- package/dist/src/orchestration/application/request-child.js +118 -0
- package/dist/src/orchestration/application/signal-reactor.js +17 -0
- package/dist/src/orchestration/application/start-workflow.js +51 -0
- package/dist/src/orchestration/application/watch-reactor.js +82 -0
- package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
- package/dist/src/orchestration/contracts/commands.js +1 -0
- package/dist/src/orchestration/contracts/config.js +128 -0
- package/dist/src/orchestration/contracts/event-decoder.js +263 -0
- package/dist/src/orchestration/contracts/events.js +41 -0
- package/dist/src/orchestration/contracts/identifiers.js +35 -0
- package/dist/src/orchestration/contracts/streams.js +38 -0
- package/dist/src/orchestration/contracts/views.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +30 -0
- package/dist/src/orchestration/domain/activation-policy.js +55 -0
- package/dist/src/orchestration/domain/approval-defaults.js +17 -0
- package/dist/src/orchestration/domain/child-policy.js +63 -0
- package/dist/src/orchestration/domain/compiler.js +162 -0
- package/dist/src/orchestration/domain/coordination-events.js +25 -0
- package/dist/src/orchestration/domain/decision-events.js +47 -0
- package/dist/src/orchestration/domain/interpreter.js +49 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
- package/dist/src/orchestration/domain/retry-policy.js +26 -0
- package/dist/src/orchestration/domain/signal-policy.js +120 -0
- package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
- package/dist/src/orchestration/domain/transition.js +55 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
- package/dist/src/orchestration/domain/workflow-instance.js +41 -0
- package/dist/src/orchestration/domain/workflow-selector.js +21 -0
- package/dist/src/orchestration/index.js +19 -0
- package/dist/src/persistence/application/projection-runner.js +79 -0
- package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
- package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
- package/dist/src/persistence/filesystem/file-lock.js +91 -0
- package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
- package/dist/src/persistence/index.js +8 -0
- package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
- package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
- package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
- package/dist/src/resources/application/lookup-projections.js +48 -0
- package/dist/src/resources/application/resource-lookup.js +16 -0
- package/dist/src/resources/application/resource-projections.js +81 -0
- package/dist/src/resources/application/resource-repository.js +18 -0
- package/dist/src/resources/application/resource-service.js +83 -0
- package/dist/src/resources/contracts/commands.js +1 -0
- package/dist/src/resources/contracts/config.js +2 -0
- package/dist/src/resources/contracts/events.js +83 -0
- package/dist/src/resources/contracts/identifiers.js +15 -0
- package/dist/src/resources/contracts/streams.js +6 -0
- package/dist/src/resources/contracts/views.js +1 -0
- package/dist/src/resources/contracts/vocabulary.js +67 -0
- package/dist/src/resources/domain/correlation.js +8 -0
- package/dist/src/resources/domain/resource.js +58 -0
- package/dist/src/resources/index.js +14 -0
- package/dist/src/surfaces/api/contracts/activities.js +1 -0
- package/dist/src/surfaces/api/contracts/board.js +2 -0
- package/dist/src/surfaces/api/contracts/common.js +46 -0
- package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
- package/dist/src/surfaces/api/contracts/events.js +1 -0
- package/dist/src/surfaces/api/contracts/execution.js +1 -0
- package/dist/src/surfaces/api/contracts/index.js +13 -0
- package/dist/src/surfaces/api/contracts/observability.js +1 -0
- package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
- package/dist/src/surfaces/api/contracts/resources.js +1 -0
- package/dist/src/surfaces/api/contracts/status.js +1 -0
- package/dist/src/surfaces/api/contracts/system.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
- package/dist/src/surfaces/api/contracts/work.js +17 -0
- package/dist/src/surfaces/api/http-server.js +121 -0
- package/dist/src/surfaces/api/presenters/activities.js +1 -0
- package/dist/src/surfaces/api/presenters/board.js +3 -0
- package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
- package/dist/src/surfaces/api/presenters/events.js +1 -0
- package/dist/src/surfaces/api/presenters/execution.js +59 -0
- package/dist/src/surfaces/api/presenters/observability.js +1 -0
- package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
- package/dist/src/surfaces/api/presenters/resources.js +15 -0
- package/dist/src/surfaces/api/presenters/status.js +3 -0
- package/dist/src/surfaces/api/presenters/system.js +14 -0
- package/dist/src/surfaces/api/presenters/work.js +16 -0
- package/dist/src/surfaces/api/problem-details.js +9 -0
- package/dist/src/surfaces/api/router.js +13 -0
- package/dist/src/surfaces/api/routes/activities.js +1 -0
- package/dist/src/surfaces/api/routes/applications.js +1 -0
- package/dist/src/surfaces/api/routes/commands.js +82 -0
- package/dist/src/surfaces/api/routes/control-plane.js +6 -0
- package/dist/src/surfaces/api/routes/events.js +1 -0
- package/dist/src/surfaces/api/routes/execution.js +8 -0
- package/dist/src/surfaces/api/routes/index.js +18 -0
- package/dist/src/surfaces/api/routes/observability.js +1 -0
- package/dist/src/surfaces/api/routes/orchestration.js +1 -0
- package/dist/src/surfaces/api/routes/pagination.js +78 -0
- package/dist/src/surfaces/api/routes/read.js +135 -0
- package/dist/src/surfaces/api/routes/resources.js +1 -0
- package/dist/src/surfaces/api/routes/responses.js +67 -0
- package/dist/src/surfaces/api/routes/system.js +1 -0
- package/dist/src/surfaces/api/routes/work.js +9 -0
- package/dist/src/surfaces/cli/commands/api.js +1 -0
- package/dist/src/surfaces/cli/commands/audit.js +10 -0
- package/dist/src/surfaces/cli/commands/correlate.js +2 -0
- package/dist/src/surfaces/cli/commands/doctor.js +6 -0
- package/dist/src/surfaces/cli/commands/init.js +39 -0
- package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
- package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
- package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
- package/dist/src/surfaces/cli/commands/self-update.js +38 -0
- package/dist/src/surfaces/cli/commands/smoke.js +16 -0
- package/dist/src/surfaces/cli/commands/start.js +1 -0
- package/dist/src/surfaces/cli/commands/stop.js +13 -0
- package/dist/src/surfaces/cli/commands/tick.js +1 -0
- package/dist/src/surfaces/cli/commands/ui.js +2 -0
- package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
- package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
- package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
- package/dist/src/surfaces/cli/main.js +140 -0
- package/dist/src/surfaces/cli/usage.js +33 -0
- package/dist/src/surfaces/contracts/config.js +34 -0
- package/dist/src/surfaces/index.js +47 -0
- package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
- package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
- package/dist/src/surfaces/web-assets/index.html +13 -0
- package/dist/src/surfaces/web-host/asset-source.js +1 -0
- package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
- package/dist/src/work/application/work-projection.js +59 -0
- package/dist/src/work/application/work-repository.js +18 -0
- package/dist/src/work/application/work-service.js +117 -0
- package/dist/src/work/contracts/commands.js +1 -0
- package/dist/src/work/contracts/config.js +2 -0
- package/dist/src/work/contracts/events.js +103 -0
- package/dist/src/work/contracts/identifiers.js +5 -0
- package/dist/src/work/contracts/streams.js +6 -0
- package/dist/src/work/contracts/views.js +1 -0
- package/dist/src/work/contracts/vocabulary.js +6 -0
- package/dist/src/work/domain/work-item.js +89 -0
- package/dist/src/work/index.js +11 -0
- package/docker/Dockerfile +10 -6
- package/docker/Dockerfile.packaged +3 -3
- package/package.json +29 -4
- package/prompts/implement.md +2 -2
- package/templates/SETUP.md +7 -7
- package/dist/src/adapters/claude/claude-runner.js +0 -529
- package/dist/src/adapters/codex/codex-runner.js +0 -503
- package/dist/src/adapters/cursor/cursor-runner.js +0 -418
- package/dist/src/adapters/docker/docker-cli.js +0 -150
- package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
- package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
- package/dist/src/adapters/fake/fake-resource-index.js +0 -21
- package/dist/src/adapters/fake/fake-runner.js +0 -77
- package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
- package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
- package/dist/src/adapters/fs/resource-index.js +0 -126
- package/dist/src/adapters/fs/self-update-ledger.js +0 -17
- package/dist/src/adapters/fs/state-store.js +0 -775
- package/dist/src/adapters/git/git-workspace-manager.js +0 -289
- package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
- package/dist/src/adapters/github/github-auth.js +0 -16
- package/dist/src/adapters/github/github-client.js +0 -249
- package/dist/src/adapters/github/github-etag-cache.js +0 -57
- package/dist/src/adapters/github/github-issues-work-source.js +0 -692
- package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
- package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
- package/dist/src/adapters/http/ui-assets.js +0 -1188
- package/dist/src/adapters/http/ui-data.js +0 -1107
- package/dist/src/adapters/http/ui-server.js +0 -458
- package/dist/src/adapters/runner/cli-command.js +0 -73
- package/dist/src/adapters/runner/prompt-templates.js +0 -76
- package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
- package/dist/src/adapters/runner/runner-registry.js +0 -139
- package/dist/src/adapters/runner/runtime-events.js +0 -32
- package/dist/src/adapters/runner/stage-prompt.js +0 -268
- package/dist/src/adapters/runner/transcripts.js +0 -25
- package/dist/src/cli/audit-command.js +0 -36
- package/dist/src/cli/correlate-command.js +0 -62
- package/dist/src/cli/doctor-command.js +0 -48
- package/dist/src/cli/init-command.js +0 -18
- package/dist/src/cli/sandbox-command.js +0 -258
- package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
- package/dist/src/cli/sandbox-exec-logging.js +0 -7
- package/dist/src/cli/sandbox-resume.js +0 -79
- package/dist/src/cli/sandbox-setup-command.js +0 -31
- package/dist/src/cli/scaffold-assets.js +0 -100
- package/dist/src/cli/self-update-command.js +0 -198
- package/dist/src/cli/startup-preflight.js +0 -134
- package/dist/src/cli/stop-command.js +0 -46
- package/dist/src/cli/ui-command.js +0 -27
- package/dist/src/config/defaults.js +0 -10
- package/dist/src/config/discover-config-files.js +0 -11
- package/dist/src/config/load-config.js +0 -69
- package/dist/src/config/split-config.js +0 -14
- package/dist/src/core/active-run-recovery.js +0 -44
- package/dist/src/core/approval-intents.js +0 -16
- package/dist/src/core/audit-events.js +0 -82
- package/dist/src/core/control-plane.js +0 -192
- package/dist/src/core/event-builders.js +0 -153
- package/dist/src/core/event-resolver.js +0 -249
- package/dist/src/core/lifecycle-service.js +0 -8
- package/dist/src/core/live-execution.js +0 -81
- package/dist/src/core/outbox.js +0 -198
- package/dist/src/core/policy-engine.js +0 -389
- package/dist/src/core/projection-updater.js +0 -693
- package/dist/src/core/quota-backoff.js +0 -69
- package/dist/src/core/run-lease.js +0 -38
- package/dist/src/core/scheduled-workflow-source.js +0 -199
- package/dist/src/core/sink-router.js +0 -107
- package/dist/src/core/stale-run-reconciler.js +0 -352
- package/dist/src/core/tick-runner.js +0 -2442
- package/dist/src/core/workspace-cleanup.js +0 -117
- package/dist/src/domain/branch-naming.js +0 -14
- package/dist/src/domain/custom-commands.js +0 -58
- package/dist/src/domain/event-types.js +0 -158
- package/dist/src/domain/manual-labels.js +0 -1
- package/dist/src/domain/resource-uri.js +0 -38
- package/dist/src/domain/runner-routing.js +0 -127
- package/dist/src/domain/runtime-events.js +0 -36
- package/dist/src/domain/schema.js +0 -1233
- package/dist/src/domain/sources.js +0 -16
- package/dist/src/domain/stages.js +0 -36
- package/dist/src/domain/work-item-labels.js +0 -48
- package/dist/src/domain/work-item-lifecycle.js +0 -10
- package/dist/src/domain/work-item-status.js +0 -33
- package/dist/src/domain/workflows.js +0 -159
- package/dist/src/lib/deep-merge.js +0 -14
- package/dist/src/lib/detached-process-logging.js +0 -46
- package/dist/src/lib/event-log.js +0 -21
- package/dist/src/lib/format.js +0 -41
- package/dist/src/lib/json-file.js +0 -23
- package/dist/src/lib/lock.js +0 -181
- package/dist/src/lib/log-rotation.js +0 -42
- package/dist/src/lib/paths.js +0 -52
- package/dist/src/lib/process-identity.js +0 -54
- package/dist/src/lib/state-health.js +0 -30
- package/dist/src/lib/work-id.js +0 -19
- package/dist/src/lib/yaml-file.js +0 -20
- /package/dist/src/{core → activities/pr}/contracts.js +0 -0
- /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'node:http';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { dirname } from 'node:path';
|
|
5
|
-
import { createLabelsEvent } from '../../core/event-builders.js';
|
|
6
|
-
import { createProjectionUpdater } from '../../core/projection-updater.js';
|
|
7
|
-
import { CORRELATION_RETRACTED_EVENT, RETRY_REQUESTED_EVENT, RUN_REQUESTED_EVENT, WORK_ITEM_DELETED_EVENT, WORK_ITEM_FROZEN_EVENT, WORK_ITEM_UNFROZEN_EVENT, } from '../../domain/event-types.js';
|
|
8
|
-
import { configuredTicketSource } from '../../domain/sources.js';
|
|
9
|
-
import { isWorkItemDeleted, isWorkItemFrozen } from '../../domain/work-item-lifecycle.js';
|
|
10
|
-
import { createEventEnvelope } from '../../lib/event-log.js';
|
|
11
|
-
import { writeJsonFile } from '../../lib/json-file.js';
|
|
12
|
-
import { labelsForWorkItem } from '../../domain/work-item-labels.js';
|
|
13
|
-
import { indexHtml } from './ui-assets.js';
|
|
14
|
-
import { buildBoard, buildConfigView, buildEventsFeed, buildHealth, buildItemDetail, buildItemTranscripts, buildMetrics, buildRuns, buildStatus, buildWorkspaces, } from './ui-data.js';
|
|
15
|
-
function sendJson(res, status, body) {
|
|
16
|
-
const payload = JSON.stringify(body, null, 2);
|
|
17
|
-
res.writeHead(status, {
|
|
18
|
-
'content-type': 'application/json; charset=utf-8',
|
|
19
|
-
'content-length': Buffer.byteLength(payload),
|
|
20
|
-
});
|
|
21
|
-
res.end(payload);
|
|
22
|
-
}
|
|
23
|
-
function extractBearerToken(req) {
|
|
24
|
-
const header = req.headers.authorization;
|
|
25
|
-
if (typeof header === 'string' && header.startsWith('Bearer ')) {
|
|
26
|
-
return header.slice('Bearer '.length);
|
|
27
|
-
}
|
|
28
|
-
const cookie = req.headers.cookie;
|
|
29
|
-
if (typeof cookie === 'string') {
|
|
30
|
-
const match = cookie
|
|
31
|
-
.split(';')
|
|
32
|
-
.map((part) => part.trim())
|
|
33
|
-
.find((part) => part.startsWith('wake_ui_token='));
|
|
34
|
-
if (match !== undefined) {
|
|
35
|
-
return match.slice('wake_ui_token='.length);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Parses `/items/<workItemKey>[/events]` and the legacy
|
|
42
|
-
* `/items/<repo-with-slashes>/<issueNumber>[/events]` form where repo itself
|
|
43
|
-
* may contain a `/` (e.g. `owner/name`), so the split can't assume a fixed arity.
|
|
44
|
-
*/
|
|
45
|
-
function parseItemPath(segments) {
|
|
46
|
-
const trailingIsEvents = segments.at(-1) === 'events';
|
|
47
|
-
const itemSegments = trailingIsEvents ? segments.slice(0, -1) : segments;
|
|
48
|
-
if (itemSegments.length === 1) {
|
|
49
|
-
const workItemKey = itemSegments[0];
|
|
50
|
-
if (workItemKey === undefined || workItemKey.length === 0)
|
|
51
|
-
return null;
|
|
52
|
-
return {
|
|
53
|
-
workItemKey,
|
|
54
|
-
...(trailingIsEvents ? { suffix: 'events' } : {}),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const numberIndex = trailingIsEvents ? segments.length - 2 : segments.length - 1;
|
|
58
|
-
const issueNumberRaw = segments[numberIndex];
|
|
59
|
-
const issueNumber = issueNumberRaw === undefined ? Number.NaN : Number(issueNumberRaw);
|
|
60
|
-
if (!Number.isInteger(issueNumber) || issueNumber <= 0 || numberIndex < 1) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const repo = segments.slice(0, numberIndex).join('/');
|
|
64
|
-
return {
|
|
65
|
-
repo,
|
|
66
|
-
issueNumber,
|
|
67
|
-
...(trailingIsEvents ? { suffix: 'events' } : {}),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async function writeTickRequest(stateStore, now, requestedBy) {
|
|
71
|
-
await writeJsonFile(stateStore.paths.tickRequestFile, {
|
|
72
|
-
requestId: randomUUID(),
|
|
73
|
-
requestedAt: now().toISOString(),
|
|
74
|
-
requestedBy,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function buildUiWorkItemEvent(input) {
|
|
78
|
-
return createEventEnvelope({
|
|
79
|
-
eventId: input.eventId,
|
|
80
|
-
workItemKey: input.item.workItemKey,
|
|
81
|
-
streamScope: 'work-item',
|
|
82
|
-
direction: 'internal',
|
|
83
|
-
sourceSystem: 'wake',
|
|
84
|
-
sourceEventType: input.sourceEventType,
|
|
85
|
-
sourceRefs: { repo: input.item.issue.repo, issueNumber: input.item.issue.number },
|
|
86
|
-
occurredAt: input.occurredAt,
|
|
87
|
-
ingestedAt: input.occurredAt,
|
|
88
|
-
trigger: 'immediate',
|
|
89
|
-
payload: { requestedBy: 'ui' },
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
async function appendLabelSyncEvent(input) {
|
|
93
|
-
const occurredAt = input.now().toISOString();
|
|
94
|
-
const labelEvent = createLabelsEvent({
|
|
95
|
-
projection: input.item,
|
|
96
|
-
runId: `${input.action}-${input.item.workItemKey}-${input.now().getTime()}`,
|
|
97
|
-
...labelsForWorkItem(input.item, input.config),
|
|
98
|
-
occurredAt,
|
|
99
|
-
});
|
|
100
|
-
const appended = await input.stateStore.appendEventEnvelope(labelEvent);
|
|
101
|
-
await input.projectionUpdater.rebuildFromEvents([appended]);
|
|
102
|
-
return labelEvent.eventId;
|
|
103
|
-
}
|
|
104
|
-
export function createUiServer(options) {
|
|
105
|
-
const now = options.now ?? (() => new Date());
|
|
106
|
-
const projectionUpdater = createProjectionUpdater({
|
|
107
|
-
stateStore: options.stateStore,
|
|
108
|
-
resourceIndex: options.resourceIndex,
|
|
109
|
-
config: options.config,
|
|
110
|
-
});
|
|
111
|
-
return createServer((req, res) => {
|
|
112
|
-
void handleRequest(req, res, options, now, projectionUpdater).catch((error) => {
|
|
113
|
-
sendJson(res, 500, { error: error instanceof Error ? error.message : String(error) });
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
async function handleRequest(req, res, options, now, projectionUpdater) {
|
|
118
|
-
const url = new URL(req.url ?? '/', 'http://internal');
|
|
119
|
-
// Whether a token is required is a bind-time decision — the caller (see
|
|
120
|
-
// ui-command.ts) only ever supplies a token when it configured a
|
|
121
|
-
// non-loopback --host, so once set it gates every request rather than
|
|
122
|
-
// trusting a per-connection remote-address check that docker's NAT/port
|
|
123
|
-
// publishing can make unreliable.
|
|
124
|
-
if (options.token !== undefined) {
|
|
125
|
-
const provided = extractBearerToken(req);
|
|
126
|
-
if (provided !== options.token) {
|
|
127
|
-
sendJson(res, 401, { error: 'missing or invalid token' });
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (!url.pathname.startsWith('/api/v1/')) {
|
|
132
|
-
if (req.method === 'GET' && (url.pathname === '/' || url.pathname === '/index.html')) {
|
|
133
|
-
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
|
134
|
-
res.end(indexHtml);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
res.writeHead(404).end('not found');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const { stateStore, resourceIndex, config } = options;
|
|
141
|
-
const segments = url.pathname
|
|
142
|
-
.slice('/api/v1/'.length)
|
|
143
|
-
.split('/')
|
|
144
|
-
.filter((part) => part.length > 0)
|
|
145
|
-
.map((s) => decodeURIComponent(s));
|
|
146
|
-
const resource = segments[0];
|
|
147
|
-
if (req.method === 'POST' &&
|
|
148
|
-
resource === 'work-items' &&
|
|
149
|
-
segments.length === 3 &&
|
|
150
|
-
(segments[2] === 'freeze' || segments[2] === 'unfreeze')) {
|
|
151
|
-
const workItemKey = segments[1] ?? '';
|
|
152
|
-
const item = await stateStore.readIssueState(workItemKey);
|
|
153
|
-
if (item === null) {
|
|
154
|
-
sendJson(res, 404, { error: 'work item not found' });
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (isWorkItemDeleted(item)) {
|
|
158
|
-
sendJson(res, 409, { error: 'work item is deleted' });
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const action = segments[2];
|
|
162
|
-
const alreadyInDesiredState = action === 'freeze' ? isWorkItemFrozen(item) : !isWorkItemFrozen(item);
|
|
163
|
-
if (alreadyInDesiredState) {
|
|
164
|
-
sendJson(res, 202, { workItemKey, changed: false });
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const occurredAt = now().toISOString();
|
|
168
|
-
const eventId = `${action}-${workItemKey}-${now().getTime()}`;
|
|
169
|
-
const event = buildUiWorkItemEvent({
|
|
170
|
-
item,
|
|
171
|
-
eventId,
|
|
172
|
-
sourceEventType: action === 'freeze' ? WORK_ITEM_FROZEN_EVENT : WORK_ITEM_UNFROZEN_EVENT,
|
|
173
|
-
occurredAt,
|
|
174
|
-
});
|
|
175
|
-
const appended = await stateStore.appendEventEnvelope(event);
|
|
176
|
-
await projectionUpdater.rebuildFromEvents([appended]);
|
|
177
|
-
const updated = (await stateStore.readIssueState(workItemKey)) ?? item;
|
|
178
|
-
const labelEventId = await appendLabelSyncEvent({
|
|
179
|
-
item: updated,
|
|
180
|
-
stateStore,
|
|
181
|
-
projectionUpdater,
|
|
182
|
-
config,
|
|
183
|
-
now,
|
|
184
|
-
action,
|
|
185
|
-
});
|
|
186
|
-
await writeTickRequest(stateStore, now, `ui:${action}`);
|
|
187
|
-
sendJson(res, 202, { workItemKey, eventId, labelEventId, changed: true });
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (req.method === 'POST' &&
|
|
191
|
-
resource === 'work-items' &&
|
|
192
|
-
segments.length === 3 &&
|
|
193
|
-
segments[2] === 'delete') {
|
|
194
|
-
const workItemKey = segments[1] ?? '';
|
|
195
|
-
const item = await stateStore.readIssueState(workItemKey);
|
|
196
|
-
if (item === null) {
|
|
197
|
-
sendJson(res, 404, { error: 'work item not found' });
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (isWorkItemDeleted(item)) {
|
|
201
|
-
sendJson(res, 202, { workItemKey, changed: false });
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const occurredAt = now().toISOString();
|
|
205
|
-
const deleteEventId = `delete-${workItemKey}-${now().getTime()}`;
|
|
206
|
-
const events = [
|
|
207
|
-
buildUiWorkItemEvent({
|
|
208
|
-
item,
|
|
209
|
-
eventId: deleteEventId,
|
|
210
|
-
sourceEventType: WORK_ITEM_DELETED_EVENT,
|
|
211
|
-
occurredAt,
|
|
212
|
-
}),
|
|
213
|
-
...item.correlatedResources.map((resourceRef) => createEventEnvelope({
|
|
214
|
-
eventId: `${deleteEventId}-retract-${resourceRef.resourceUri.replace(/[^a-z0-9]+/gi, '-')}`,
|
|
215
|
-
workItemKey,
|
|
216
|
-
streamScope: 'work-item',
|
|
217
|
-
direction: 'internal',
|
|
218
|
-
sourceSystem: 'wake',
|
|
219
|
-
sourceEventType: CORRELATION_RETRACTED_EVENT,
|
|
220
|
-
sourceRefs: {
|
|
221
|
-
repo: item.issue.repo,
|
|
222
|
-
issueNumber: item.issue.number,
|
|
223
|
-
resourceUri: resourceRef.resourceUri,
|
|
224
|
-
},
|
|
225
|
-
occurredAt,
|
|
226
|
-
ingestedAt: occurredAt,
|
|
227
|
-
trigger: 'context-only',
|
|
228
|
-
payload: { resourceUri: resourceRef.resourceUri, requestedBy: 'ui' },
|
|
229
|
-
})),
|
|
230
|
-
];
|
|
231
|
-
const appended = [];
|
|
232
|
-
for (const event of events) {
|
|
233
|
-
appended.push(await stateStore.appendEventEnvelope(event));
|
|
234
|
-
}
|
|
235
|
-
await projectionUpdater.rebuildFromEvents(appended);
|
|
236
|
-
await writeTickRequest(stateStore, now, 'ui:delete');
|
|
237
|
-
sendJson(res, 202, {
|
|
238
|
-
workItemKey,
|
|
239
|
-
deleteEventId,
|
|
240
|
-
retractedResources: item.correlatedResources.map((resourceRef) => resourceRef.resourceUri),
|
|
241
|
-
changed: true,
|
|
242
|
-
});
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (req.method === 'POST' &&
|
|
246
|
-
resource === 'work-items' &&
|
|
247
|
-
segments.length === 3 &&
|
|
248
|
-
segments[2] === 'retry') {
|
|
249
|
-
const workItemKey = segments[1] ?? '';
|
|
250
|
-
const item = await stateStore.readIssueState(workItemKey);
|
|
251
|
-
if (item === null) {
|
|
252
|
-
sendJson(res, 404, { error: 'work item not found' });
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const context = item.context;
|
|
256
|
-
if (context.lastRunSentinel !== 'FAILED') {
|
|
257
|
-
sendJson(res, 409, { error: 'work item last run is not failed' });
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
const occurredAt = now().toISOString();
|
|
261
|
-
const retryId = `retry-${workItemKey}-${now().getTime()}`;
|
|
262
|
-
const retryEvent = createEventEnvelope({
|
|
263
|
-
eventId: retryId,
|
|
264
|
-
workItemKey,
|
|
265
|
-
streamScope: 'work-item',
|
|
266
|
-
direction: 'internal',
|
|
267
|
-
sourceSystem: 'wake',
|
|
268
|
-
sourceEventType: RETRY_REQUESTED_EVENT,
|
|
269
|
-
sourceRefs: { repo: item.issue.repo, issueNumber: item.issue.number },
|
|
270
|
-
occurredAt,
|
|
271
|
-
ingestedAt: occurredAt,
|
|
272
|
-
trigger: 'immediate',
|
|
273
|
-
payload: { requestedBy: 'ui' },
|
|
274
|
-
});
|
|
275
|
-
const appended = await stateStore.appendEventEnvelope(retryEvent);
|
|
276
|
-
await projectionUpdater.rebuildFromEvents([appended]);
|
|
277
|
-
const tickRequest = {
|
|
278
|
-
requestId: randomUUID(),
|
|
279
|
-
requestedAt: now().toISOString(),
|
|
280
|
-
requestedBy: 'ui:retry',
|
|
281
|
-
};
|
|
282
|
-
await writeJsonFile(stateStore.paths.tickRequestFile, tickRequest);
|
|
283
|
-
sendJson(res, 202, { workItemKey, retryEventId: retryId });
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
if (req.method === 'POST' &&
|
|
287
|
-
resource === 'work-items' &&
|
|
288
|
-
segments.length === 3 &&
|
|
289
|
-
segments[2] === 'run') {
|
|
290
|
-
const workItemKey = segments[1] ?? '';
|
|
291
|
-
const item = await stateStore.readIssueState(workItemKey);
|
|
292
|
-
if (item === null) {
|
|
293
|
-
sendJson(res, 404, { error: 'work item not found' });
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
if (!item.issue.labels.includes('wake:scheduled-workflow')) {
|
|
297
|
-
sendJson(res, 409, { error: 'work item is not a scheduled workflow' });
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
const occurredAt = now().toISOString();
|
|
301
|
-
const runRequestId = `run-${workItemKey}-${now().getTime()}`;
|
|
302
|
-
const runRequestEvent = createEventEnvelope({
|
|
303
|
-
eventId: runRequestId,
|
|
304
|
-
workItemKey,
|
|
305
|
-
streamScope: 'work-item',
|
|
306
|
-
direction: 'internal',
|
|
307
|
-
sourceSystem: 'wake',
|
|
308
|
-
sourceEventType: RUN_REQUESTED_EVENT,
|
|
309
|
-
sourceRefs: { repo: item.issue.repo, issueNumber: item.issue.number },
|
|
310
|
-
occurredAt,
|
|
311
|
-
ingestedAt: occurredAt,
|
|
312
|
-
trigger: 'immediate',
|
|
313
|
-
payload: { requestedBy: 'ui' },
|
|
314
|
-
});
|
|
315
|
-
const appended = await stateStore.appendEventEnvelope(runRequestEvent);
|
|
316
|
-
await projectionUpdater.rebuildFromEvents([appended]);
|
|
317
|
-
const tickRequest = {
|
|
318
|
-
requestId: randomUUID(),
|
|
319
|
-
requestedAt: now().toISOString(),
|
|
320
|
-
requestedBy: 'ui:run',
|
|
321
|
-
};
|
|
322
|
-
await writeJsonFile(stateStore.paths.tickRequestFile, tickRequest);
|
|
323
|
-
sendJson(res, 202, { workItemKey, runEventId: runRequestId });
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (req.method === 'GET' &&
|
|
327
|
-
resource === 'work-items' &&
|
|
328
|
-
segments.length === 3 &&
|
|
329
|
-
segments[2] === 'transcripts') {
|
|
330
|
-
sendJson(res, 200, await buildItemTranscripts({
|
|
331
|
-
stateStore,
|
|
332
|
-
config,
|
|
333
|
-
workItemKey: segments[1] ?? '',
|
|
334
|
-
}));
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (req.method === 'POST' && resource === 'tick' && segments.length === 1) {
|
|
338
|
-
const request = {
|
|
339
|
-
requestId: randomUUID(),
|
|
340
|
-
requestedAt: now().toISOString(),
|
|
341
|
-
requestedBy: 'ui',
|
|
342
|
-
};
|
|
343
|
-
await writeJsonFile(stateStore.paths.tickRequestFile, request);
|
|
344
|
-
sendJson(res, 202, request);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (req.method === 'POST' && resource === 'pause' && segments.length === 1) {
|
|
348
|
-
await mkdir(dirname(stateStore.paths.pauseFile), { recursive: true });
|
|
349
|
-
await writeFile(stateStore.paths.pauseFile, `${now().toISOString()}\n`, 'utf8');
|
|
350
|
-
sendJson(res, 200, { paused: true });
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
if (req.method === 'DELETE' && resource === 'pause' && segments.length === 1) {
|
|
354
|
-
await rm(stateStore.paths.pauseFile, { force: true });
|
|
355
|
-
sendJson(res, 200, { paused: false });
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
if (req.method === 'POST' &&
|
|
359
|
-
resource === 'runners' &&
|
|
360
|
-
segments.length === 3 &&
|
|
361
|
-
segments[2] === 'unpause') {
|
|
362
|
-
const runnerName = segments[1];
|
|
363
|
-
const ledger = await stateStore.readLedger();
|
|
364
|
-
const existingRunners = ledger?.runners ?? {};
|
|
365
|
-
if (existingRunners[runnerName] !== undefined) {
|
|
366
|
-
await stateStore.writeLedger({
|
|
367
|
-
schemaVersion: 1,
|
|
368
|
-
runners: { ...existingRunners, [runnerName]: { failureCount: 0 } },
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
sendJson(res, 200, { runnerName, unpaused: true });
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (req.method !== 'GET') {
|
|
375
|
-
sendJson(res, 405, { error: `method not allowed for ${url.pathname}` });
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
if (resource === 'status' && segments.length === 1) {
|
|
379
|
-
sendJson(res, 200, await buildStatus({ stateStore, config, now: now() }));
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
if (resource === 'board' && segments.length === 1) {
|
|
383
|
-
sendJson(res, 200, await buildBoard({ stateStore, config, now: now() }));
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
if (resource === 'items' && segments.length >= 2) {
|
|
387
|
-
const parsed = parseItemPath(segments.slice(1));
|
|
388
|
-
if (parsed === null) {
|
|
389
|
-
sendJson(res, 400, { error: 'expected /items/<workItemKey> or /items/<repo>/<issueNumber>' });
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const itemDetailInput = 'workItemKey' in parsed
|
|
393
|
-
? { stateStore, workItemKey: parsed.workItemKey }
|
|
394
|
-
: {
|
|
395
|
-
stateStore,
|
|
396
|
-
resourceIndex,
|
|
397
|
-
provider: configuredTicketSource(config),
|
|
398
|
-
repo: parsed.repo,
|
|
399
|
-
issueNumber: parsed.issueNumber,
|
|
400
|
-
};
|
|
401
|
-
if (parsed.suffix === 'events') {
|
|
402
|
-
const detail = await buildItemDetail(itemDetailInput);
|
|
403
|
-
sendJson(res, 200, detail?.events ?? []);
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
const detail = await buildItemDetail(itemDetailInput);
|
|
407
|
-
if (detail === null) {
|
|
408
|
-
sendJson(res, 404, { error: 'item not found' });
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
sendJson(res, 200, detail);
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
if (resource === 'runs' && segments.length === 1) {
|
|
415
|
-
sendJson(res, 200, await buildRuns({
|
|
416
|
-
stateStore,
|
|
417
|
-
status: url.searchParams.get('status') ?? undefined,
|
|
418
|
-
action: url.searchParams.get('action') ?? undefined,
|
|
419
|
-
repo: url.searchParams.get('repo') ?? undefined,
|
|
420
|
-
}));
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
if (resource === 'metrics' && segments.length === 1) {
|
|
424
|
-
sendJson(res, 200, await buildMetrics({
|
|
425
|
-
stateStore,
|
|
426
|
-
config,
|
|
427
|
-
now: now(),
|
|
428
|
-
window: url.searchParams.get('window') ?? undefined,
|
|
429
|
-
metric: url.searchParams.get('metric') ?? undefined,
|
|
430
|
-
}));
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (resource === 'events' && segments.length === 1) {
|
|
434
|
-
const limitParam = url.searchParams.get('limit');
|
|
435
|
-
sendJson(res, 200, await buildEventsFeed({
|
|
436
|
-
stateStore,
|
|
437
|
-
workItemKey: url.searchParams.get('workItemKey') ?? undefined,
|
|
438
|
-
direction: url.searchParams.get('direction') ??
|
|
439
|
-
undefined,
|
|
440
|
-
type: url.searchParams.get('type') ?? undefined,
|
|
441
|
-
limit: limitParam === null ? undefined : Number(limitParam),
|
|
442
|
-
}));
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (resource === 'config' && segments.length === 1) {
|
|
446
|
-
sendJson(res, 200, await buildConfigView({ config, stateStore, now: now() }));
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
if (resource === 'health' && segments.length === 1) {
|
|
450
|
-
sendJson(res, 200, await buildHealth({ stateStore, config, now: now() }));
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (resource === 'workspaces' && segments.length === 1) {
|
|
454
|
-
sendJson(res, 200, await buildWorkspaces({ stateStore }));
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
sendJson(res, 404, { error: `unknown endpoint: ${url.pathname}` });
|
|
458
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { readProcessIdentity } from '../../lib/process-identity.js';
|
|
3
|
-
const TIMEOUT_KILL_GRACE_MS = 5_000;
|
|
4
|
-
export function runAgentCliCommand(input) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const child = spawn(input.command, input.args, {
|
|
7
|
-
cwd: input.cwd,
|
|
8
|
-
env: process.env,
|
|
9
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
10
|
-
});
|
|
11
|
-
let stdout = '';
|
|
12
|
-
let stderr = '';
|
|
13
|
-
let timedOut = false;
|
|
14
|
-
let canceled = false;
|
|
15
|
-
let killTimer;
|
|
16
|
-
let startNotification = Promise.resolve();
|
|
17
|
-
let startNotificationError;
|
|
18
|
-
if (input.onProcessStart !== undefined && child.pid !== undefined) {
|
|
19
|
-
const identity = readProcessIdentity(child.pid);
|
|
20
|
-
if (identity !== null) {
|
|
21
|
-
startNotification = input.onProcessStart(identity).catch((error) => {
|
|
22
|
-
startNotificationError = error;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const terminate = () => {
|
|
27
|
-
child.kill('SIGTERM');
|
|
28
|
-
killTimer = setTimeout(() => child.kill('SIGKILL'), TIMEOUT_KILL_GRACE_MS);
|
|
29
|
-
};
|
|
30
|
-
const timeoutTimer = input.timeoutMs === undefined
|
|
31
|
-
? undefined
|
|
32
|
-
: setTimeout(() => {
|
|
33
|
-
timedOut = true;
|
|
34
|
-
terminate();
|
|
35
|
-
}, input.timeoutMs);
|
|
36
|
-
const abortListener = () => {
|
|
37
|
-
canceled = true;
|
|
38
|
-
terminate();
|
|
39
|
-
};
|
|
40
|
-
input.cancellationSignal?.addEventListener('abort', abortListener, { once: true });
|
|
41
|
-
if (input.cancellationSignal?.aborted === true) {
|
|
42
|
-
abortListener();
|
|
43
|
-
}
|
|
44
|
-
child.stdout.on('data', (chunk) => {
|
|
45
|
-
stdout += chunk.toString();
|
|
46
|
-
});
|
|
47
|
-
child.stderr.on('data', (chunk) => {
|
|
48
|
-
stderr += chunk.toString();
|
|
49
|
-
});
|
|
50
|
-
child.on('error', (error) => {
|
|
51
|
-
clearTimeout(timeoutTimer);
|
|
52
|
-
clearTimeout(killTimer);
|
|
53
|
-
input.cancellationSignal?.removeEventListener('abort', abortListener);
|
|
54
|
-
reject(error);
|
|
55
|
-
});
|
|
56
|
-
child.on('close', async (exitCode) => {
|
|
57
|
-
clearTimeout(timeoutTimer);
|
|
58
|
-
clearTimeout(killTimer);
|
|
59
|
-
input.cancellationSignal?.removeEventListener('abort', abortListener);
|
|
60
|
-
await startNotification;
|
|
61
|
-
if (startNotificationError !== undefined) {
|
|
62
|
-
reject(startNotificationError);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
resolve({
|
|
66
|
-
stdout,
|
|
67
|
-
stderr,
|
|
68
|
-
exitCode: exitCode ?? 1,
|
|
69
|
-
timedOut: timedOut || canceled,
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import Handlebars from 'handlebars';
|
|
6
|
-
function findProjectRoot(startDir) {
|
|
7
|
-
let dir = startDir;
|
|
8
|
-
for (let depth = 0; depth < 8; depth += 1) {
|
|
9
|
-
if (existsSync(join(dir, 'package.json'))) {
|
|
10
|
-
return dir;
|
|
11
|
-
}
|
|
12
|
-
const parent = dirname(dir);
|
|
13
|
-
if (parent === dir) {
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
dir = parent;
|
|
17
|
-
}
|
|
18
|
-
throw new Error(`Could not locate project root above ${startDir}`);
|
|
19
|
-
}
|
|
20
|
-
function parseFrontmatter(raw) {
|
|
21
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
22
|
-
if (match === null) {
|
|
23
|
-
return { frontmatter: {}, body: raw };
|
|
24
|
-
}
|
|
25
|
-
const [, frontmatterBlock, body] = match;
|
|
26
|
-
const frontmatter = {};
|
|
27
|
-
for (const line of (frontmatterBlock ?? '').split(/\r?\n/)) {
|
|
28
|
-
const lineMatch = /^([\w.-]+):\s*(.*)$/.exec(line);
|
|
29
|
-
if (lineMatch === null) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const [, key, value] = lineMatch;
|
|
33
|
-
if (key !== undefined) {
|
|
34
|
-
frontmatter[key] = (value ?? '').trim();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return { frontmatter, body: body ?? '' };
|
|
38
|
-
}
|
|
39
|
-
export function promptsRoot(explicitRoot) {
|
|
40
|
-
return explicitRoot ?? join(findProjectRoot(dirname(fileURLToPath(import.meta.url))), 'prompts');
|
|
41
|
-
}
|
|
42
|
-
export async function loadPromptTemplate(stage, mode, options) {
|
|
43
|
-
const root = promptsRoot(options?.promptsRoot);
|
|
44
|
-
const combinedFilePath = join(root, `${stage}.md`);
|
|
45
|
-
const modeFilePath = join(root, `${stage}.${mode}.md`);
|
|
46
|
-
let raw;
|
|
47
|
-
try {
|
|
48
|
-
raw = await readFile(combinedFilePath, 'utf8');
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
const code = error.code;
|
|
52
|
-
if (code !== 'ENOENT') {
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
raw = await readFile(modeFilePath, 'utf8');
|
|
56
|
-
}
|
|
57
|
-
return parseFrontmatter(raw);
|
|
58
|
-
}
|
|
59
|
-
export function renderPromptTemplate(template, context) {
|
|
60
|
-
const renderContext = Object.fromEntries(Object.entries(context).map(([key, value]) => {
|
|
61
|
-
if (Array.isArray(value)) {
|
|
62
|
-
return [key, Object.assign([...value], { toString: () => JSON.stringify(value, null, 2) })];
|
|
63
|
-
}
|
|
64
|
-
if (value !== null && typeof value === 'object') {
|
|
65
|
-
return [
|
|
66
|
-
key,
|
|
67
|
-
Object.assign({ ...value }, { toString: () => JSON.stringify(value, null, 2) }),
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
return [key, value];
|
|
71
|
-
}));
|
|
72
|
-
const compiled = Handlebars.compile(template.body, {
|
|
73
|
-
noEscape: true,
|
|
74
|
-
});
|
|
75
|
-
return compiled(renderContext);
|
|
76
|
-
}
|