@atolis-hq/wake 0.2.97 → 0.3.1
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/README.md +5 -5
- 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 +436 -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/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/templates/SETUP.md +0 -115
- /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,274 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activationId, activityName, activityOrchestrationGroupId, activityWorkflowInstanceId, ExternalExecutionKind, } from '../../activities/index.js';
|
|
3
|
+
import { brandedStringSchema, eventEnvelopeSchema, offsetIsoTimestampSchema, } from '../../kernel/index.js';
|
|
4
|
+
import { runId } from './identifiers.js';
|
|
5
|
+
import { ExecutionStreamKind } from './streams.js';
|
|
6
|
+
import { ExecutionCancellationReason, ExecutionFailureCode, RunStatus, WorkspaceMode, } from './vocabulary.js';
|
|
7
|
+
export const runStartedPayloadSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
activationId: brandedStringSchema(activationId),
|
|
10
|
+
activity: brandedStringSchema(activityName),
|
|
11
|
+
stage: z.string().min(1).optional(),
|
|
12
|
+
workflowInstanceId: brandedStringSchema(activityWorkflowInstanceId),
|
|
13
|
+
orchestrationGroupId: brandedStringSchema(activityOrchestrationGroupId),
|
|
14
|
+
attempt: z.number().int().positive(),
|
|
15
|
+
startedAt: offsetIsoTimestampSchema,
|
|
16
|
+
runner: z
|
|
17
|
+
.object({
|
|
18
|
+
name: z.string().min(1),
|
|
19
|
+
model: z.string().min(1).optional(),
|
|
20
|
+
effort: z.string().min(1).optional(),
|
|
21
|
+
pool: z.string().min(1).optional(),
|
|
22
|
+
cli: z.string().min(1).optional(),
|
|
23
|
+
})
|
|
24
|
+
.strict()
|
|
25
|
+
.optional(),
|
|
26
|
+
workspace: z
|
|
27
|
+
.object({
|
|
28
|
+
mode: z.enum([WorkspaceMode.ReadOnly, WorkspaceMode.Branch]),
|
|
29
|
+
path: z.string().min(1),
|
|
30
|
+
branch: z.string().min(1).optional(),
|
|
31
|
+
})
|
|
32
|
+
.strict()
|
|
33
|
+
.optional(),
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
export const leasePayloadSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
owner: z.string().min(1),
|
|
39
|
+
acquiredAt: offsetIsoTimestampSchema,
|
|
40
|
+
expiresAt: offsetIsoTimestampSchema,
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
export const runnerResultPayloadSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
transport: z.enum([
|
|
46
|
+
RunStatus.Succeeded,
|
|
47
|
+
RunStatus.Failed,
|
|
48
|
+
RunStatus.Cancelled,
|
|
49
|
+
RunStatus.Ambiguous,
|
|
50
|
+
]),
|
|
51
|
+
// Legacy persisted events may still carry these fields; new writers never emit them.
|
|
52
|
+
output: z.string().optional(),
|
|
53
|
+
runner: z.string().min(1).optional(),
|
|
54
|
+
agent: z
|
|
55
|
+
.object({
|
|
56
|
+
outcome: z.enum(['DONE', 'REJECTED', 'BLOCKED', 'FAILED']),
|
|
57
|
+
displayBody: z.string(),
|
|
58
|
+
artifacts: z
|
|
59
|
+
.array(z
|
|
60
|
+
.object({
|
|
61
|
+
kind: z.string().min(1),
|
|
62
|
+
externalKey: z
|
|
63
|
+
.object({ adapter: z.string().min(1), key: z.string().min(1) })
|
|
64
|
+
.strict(),
|
|
65
|
+
})
|
|
66
|
+
.strict())
|
|
67
|
+
.optional(),
|
|
68
|
+
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
69
|
+
})
|
|
70
|
+
.strict()
|
|
71
|
+
.optional(),
|
|
72
|
+
})
|
|
73
|
+
.strict();
|
|
74
|
+
export const ExecutionEventType = {
|
|
75
|
+
RunStarted: 'execution.run-started',
|
|
76
|
+
RunSucceeded: 'execution.run-succeeded',
|
|
77
|
+
RunFailed: 'execution.run-failed',
|
|
78
|
+
RunLeaseClaimed: 'execution.run-lease-claimed',
|
|
79
|
+
RunLeaseRenewed: 'execution.run-lease-renewed',
|
|
80
|
+
RunExternalExecutionReported: 'execution.run-external-execution-reported',
|
|
81
|
+
RunRunnerResultReported: 'execution.run-runner-result-reported',
|
|
82
|
+
RunWorkspaceCleanupFailed: 'execution.workspace-cleanup-failed',
|
|
83
|
+
RunCancellationRequested: 'execution.run-cancellation-requested',
|
|
84
|
+
RunCancellationConfirmed: 'execution.run-cancellation-confirmed',
|
|
85
|
+
RunCancelled: 'execution.run-cancelled',
|
|
86
|
+
RunRecovered: 'execution.run-recovered',
|
|
87
|
+
RunAmbiguityObserved: 'execution.run-ambiguity-observed',
|
|
88
|
+
RunAmbiguous: 'execution.run-ambiguous',
|
|
89
|
+
ActivationClaimed: 'execution.activation-claimed',
|
|
90
|
+
ActivationReleased: 'execution.activation-released',
|
|
91
|
+
};
|
|
92
|
+
export const ExecutionEventNamespace = 'execution.';
|
|
93
|
+
const runStreamSchema = z
|
|
94
|
+
.object({
|
|
95
|
+
kind: z.literal(ExecutionStreamKind.Run),
|
|
96
|
+
id: brandedStringSchema(runId),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
const activationStreamSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
kind: z.literal(ExecutionStreamKind.Activation),
|
|
102
|
+
id: brandedStringSchema(activationId),
|
|
103
|
+
})
|
|
104
|
+
.strict();
|
|
105
|
+
const runEventSchema = z.discriminatedUnion('eventType', [
|
|
106
|
+
eventEnvelopeSchema.extend({
|
|
107
|
+
eventType: z.literal(ExecutionEventType.RunStarted),
|
|
108
|
+
stream: runStreamSchema,
|
|
109
|
+
payload: runStartedPayloadSchema,
|
|
110
|
+
}),
|
|
111
|
+
eventEnvelopeSchema.extend({
|
|
112
|
+
eventType: z.literal(ExecutionEventType.RunRunnerResultReported),
|
|
113
|
+
stream: runStreamSchema,
|
|
114
|
+
payload: runnerResultPayloadSchema,
|
|
115
|
+
}),
|
|
116
|
+
eventEnvelopeSchema.extend({
|
|
117
|
+
eventType: z.literal(ExecutionEventType.RunWorkspaceCleanupFailed),
|
|
118
|
+
stream: runStreamSchema,
|
|
119
|
+
payload: z.object({ message: z.string().min(1) }).strict(),
|
|
120
|
+
}),
|
|
121
|
+
eventEnvelopeSchema.extend({
|
|
122
|
+
eventType: z.literal(ExecutionEventType.RunCancelled),
|
|
123
|
+
stream: runStreamSchema,
|
|
124
|
+
payload: z.object({ finishedAt: offsetIsoTimestampSchema }).strict(),
|
|
125
|
+
}),
|
|
126
|
+
eventEnvelopeSchema.extend({
|
|
127
|
+
eventType: z.literal(ExecutionEventType.RunSucceeded),
|
|
128
|
+
stream: runStreamSchema,
|
|
129
|
+
payload: z
|
|
130
|
+
.object({
|
|
131
|
+
outcome: z.object({ kind: z.string().min(1), data: z.unknown().optional() }).strict(),
|
|
132
|
+
finishedAt: offsetIsoTimestampSchema,
|
|
133
|
+
})
|
|
134
|
+
.strict(),
|
|
135
|
+
}),
|
|
136
|
+
eventEnvelopeSchema.extend({
|
|
137
|
+
eventType: z.literal(ExecutionEventType.RunFailed),
|
|
138
|
+
stream: runStreamSchema,
|
|
139
|
+
payload: z
|
|
140
|
+
.object({
|
|
141
|
+
failure: z
|
|
142
|
+
.object({
|
|
143
|
+
kind: z.enum([ExecutionFailureCode.Unexpected]),
|
|
144
|
+
message: z.string(),
|
|
145
|
+
details: z
|
|
146
|
+
.object({
|
|
147
|
+
sourceKind: z.string().min(1),
|
|
148
|
+
sourceDetails: z.unknown().optional(),
|
|
149
|
+
})
|
|
150
|
+
.strict()
|
|
151
|
+
.optional(),
|
|
152
|
+
})
|
|
153
|
+
.strict(),
|
|
154
|
+
finishedAt: offsetIsoTimestampSchema,
|
|
155
|
+
})
|
|
156
|
+
.strict(),
|
|
157
|
+
}),
|
|
158
|
+
eventEnvelopeSchema.extend({
|
|
159
|
+
eventType: z.literal(ExecutionEventType.RunLeaseClaimed),
|
|
160
|
+
stream: runStreamSchema,
|
|
161
|
+
payload: leasePayloadSchema,
|
|
162
|
+
}),
|
|
163
|
+
eventEnvelopeSchema.extend({
|
|
164
|
+
eventType: z.literal(ExecutionEventType.RunLeaseRenewed),
|
|
165
|
+
stream: runStreamSchema,
|
|
166
|
+
payload: leasePayloadSchema,
|
|
167
|
+
}),
|
|
168
|
+
eventEnvelopeSchema.extend({
|
|
169
|
+
eventType: z.literal(ExecutionEventType.RunExternalExecutionReported),
|
|
170
|
+
stream: runStreamSchema,
|
|
171
|
+
payload: z
|
|
172
|
+
.object({
|
|
173
|
+
kind: z.enum([ExternalExecutionKind.Process, ExternalExecutionKind.RemoteSession]),
|
|
174
|
+
id: z.string().min(1),
|
|
175
|
+
startedAt: offsetIsoTimestampSchema,
|
|
176
|
+
})
|
|
177
|
+
.strict(),
|
|
178
|
+
}),
|
|
179
|
+
eventEnvelopeSchema.extend({
|
|
180
|
+
eventType: z.literal(ExecutionEventType.RunCancellationRequested),
|
|
181
|
+
stream: runStreamSchema,
|
|
182
|
+
payload: z
|
|
183
|
+
.object({
|
|
184
|
+
requestedAt: offsetIsoTimestampSchema,
|
|
185
|
+
reason: z.enum(Object.values(ExecutionCancellationReason)),
|
|
186
|
+
})
|
|
187
|
+
.strict(),
|
|
188
|
+
}),
|
|
189
|
+
eventEnvelopeSchema.extend({
|
|
190
|
+
eventType: z.literal(ExecutionEventType.RunCancellationConfirmed),
|
|
191
|
+
stream: runStreamSchema,
|
|
192
|
+
payload: z.object({ confirmedAt: offsetIsoTimestampSchema }).strict(),
|
|
193
|
+
}),
|
|
194
|
+
eventEnvelopeSchema.extend({
|
|
195
|
+
eventType: z.literal(ExecutionEventType.RunRecovered),
|
|
196
|
+
stream: runStreamSchema,
|
|
197
|
+
payload: z
|
|
198
|
+
.object({
|
|
199
|
+
result: runnerResultPayloadSchema,
|
|
200
|
+
outcome: z.object({ kind: z.string().min(1), data: z.unknown().optional() }).strict(),
|
|
201
|
+
finishedAt: offsetIsoTimestampSchema,
|
|
202
|
+
})
|
|
203
|
+
.strict(),
|
|
204
|
+
}),
|
|
205
|
+
eventEnvelopeSchema.extend({
|
|
206
|
+
eventType: z.literal(ExecutionEventType.RunAmbiguityObserved),
|
|
207
|
+
stream: runStreamSchema,
|
|
208
|
+
payload: z.object({ reason: z.string().min(1), attempt: z.number().int().positive() }).strict(),
|
|
209
|
+
}),
|
|
210
|
+
eventEnvelopeSchema.extend({
|
|
211
|
+
eventType: z.literal(ExecutionEventType.RunAmbiguous),
|
|
212
|
+
stream: runStreamSchema,
|
|
213
|
+
payload: z.object({ reason: z.string().min(1), finishedAt: offsetIsoTimestampSchema }).strict(),
|
|
214
|
+
}),
|
|
215
|
+
]);
|
|
216
|
+
const activationEventSchema = z.discriminatedUnion('eventType', [
|
|
217
|
+
eventEnvelopeSchema.extend({
|
|
218
|
+
eventType: z.literal(ExecutionEventType.ActivationClaimed),
|
|
219
|
+
stream: activationStreamSchema,
|
|
220
|
+
payload: z
|
|
221
|
+
.object({
|
|
222
|
+
runId: brandedStringSchema(runId),
|
|
223
|
+
owner: z.string().min(1),
|
|
224
|
+
expiresAt: offsetIsoTimestampSchema,
|
|
225
|
+
})
|
|
226
|
+
.strict(),
|
|
227
|
+
}),
|
|
228
|
+
eventEnvelopeSchema.extend({
|
|
229
|
+
eventType: z.literal(ExecutionEventType.ActivationReleased),
|
|
230
|
+
stream: activationStreamSchema,
|
|
231
|
+
payload: z.object({ runId: brandedStringSchema(runId) }).strict(),
|
|
232
|
+
}),
|
|
233
|
+
]);
|
|
234
|
+
const eventSchema = z.union([runEventSchema, activationEventSchema]);
|
|
235
|
+
export function decodeExecutionEvent(event) {
|
|
236
|
+
const result = eventSchema.safeParse(event);
|
|
237
|
+
if (!result.success)
|
|
238
|
+
throw invalidExecutionEvent(event, result.error);
|
|
239
|
+
return result.data;
|
|
240
|
+
}
|
|
241
|
+
export function decodeRunExecutionEvent(event) {
|
|
242
|
+
const result = runEventSchema.safeParse(event);
|
|
243
|
+
if (!result.success)
|
|
244
|
+
throw invalidExecutionEvent(event, result.error);
|
|
245
|
+
return result.data;
|
|
246
|
+
}
|
|
247
|
+
export function decodeActivationExecutionEvent(event) {
|
|
248
|
+
const result = activationEventSchema.safeParse(event);
|
|
249
|
+
if (!result.success)
|
|
250
|
+
throw invalidExecutionEvent(event, result.error);
|
|
251
|
+
return result.data;
|
|
252
|
+
}
|
|
253
|
+
export function selectExecutionEvent(event) {
|
|
254
|
+
return event.eventType.startsWith(ExecutionEventNamespace) ? decodeExecutionEvent(event) : null;
|
|
255
|
+
}
|
|
256
|
+
export function selectRunExecutionEvent(event) {
|
|
257
|
+
if (!event.eventType.startsWith(ExecutionEventNamespace))
|
|
258
|
+
return null;
|
|
259
|
+
if (event.stream.kind === ExecutionStreamKind.Run)
|
|
260
|
+
return decodeRunExecutionEvent(event);
|
|
261
|
+
decodeExecutionEvent(event);
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
export function selectActivationExecutionEvent(event) {
|
|
265
|
+
if (!event.eventType.startsWith(ExecutionEventNamespace))
|
|
266
|
+
return null;
|
|
267
|
+
if (event.stream.kind === ExecutionStreamKind.Activation)
|
|
268
|
+
return decodeActivationExecutionEvent(event);
|
|
269
|
+
decodeExecutionEvent(event);
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
function invalidExecutionEvent(event, cause) {
|
|
273
|
+
return new Error(`Invalid Execution event ${event.eventId} at global position ${event.globalPosition} (${event.eventType}): ${cause.message}`, { cause });
|
|
274
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// inputTokens/outputTokens/cacheReadTokens/cacheWriteTokens/costUsd are the known
|
|
2
|
+
// numeric keys agent-runner-adapter.ts writes into AgentRunResponse.metadata.
|
|
3
|
+
export function agentTokenUsage(metadata) {
|
|
4
|
+
const numeric = (key) => {
|
|
5
|
+
const value = metadata?.[key];
|
|
6
|
+
return typeof value === 'number' ? value : 0;
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
tokens: numeric('inputTokens') +
|
|
10
|
+
numeric('outputTokens') +
|
|
11
|
+
numeric('cacheReadTokens') +
|
|
12
|
+
numeric('cacheWriteTokens'),
|
|
13
|
+
costUsd: numeric('costUsd'),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const ExecutionStreamKind = { Run: 'run', Activation: 'execution-activation' };
|
|
2
|
+
export const runStream = (id) => ({
|
|
3
|
+
kind: ExecutionStreamKind.Run,
|
|
4
|
+
id,
|
|
5
|
+
});
|
|
6
|
+
export const isRunStream = (stream) => stream.kind === ExecutionStreamKind.Run;
|
|
7
|
+
export const activationStream = (id) => ({
|
|
8
|
+
kind: ExecutionStreamKind.Activation,
|
|
9
|
+
id,
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineClosedVocabulary } from '../../kernel/index.js';
|
|
2
|
+
export const RunStatus = defineClosedVocabulary({
|
|
3
|
+
Started: 'started',
|
|
4
|
+
Succeeded: 'succeeded',
|
|
5
|
+
Failed: 'failed',
|
|
6
|
+
Cancelled: 'cancelled',
|
|
7
|
+
Ambiguous: 'ambiguous',
|
|
8
|
+
});
|
|
9
|
+
export const ExecutionFailureCode = defineClosedVocabulary({
|
|
10
|
+
Unexpected: 'unexpected-execution-failure',
|
|
11
|
+
});
|
|
12
|
+
export const ExecutionCancellationReason = defineClosedVocabulary({
|
|
13
|
+
Operator: 'operator',
|
|
14
|
+
WorkCancelled: 'work-cancelled',
|
|
15
|
+
WorkClosed: 'work-closed',
|
|
16
|
+
WorkflowSuperseded: 'workflow-superseded',
|
|
17
|
+
Timeout: 'timeout',
|
|
18
|
+
Shutdown: 'shutdown',
|
|
19
|
+
Maintenance: 'maintenance',
|
|
20
|
+
});
|
|
21
|
+
export const ExternalExecutionState = defineClosedVocabulary({
|
|
22
|
+
Running: 'running',
|
|
23
|
+
Completed: 'completed',
|
|
24
|
+
Absent: 'absent',
|
|
25
|
+
Unknown: 'unknown',
|
|
26
|
+
});
|
|
27
|
+
export const WorkspaceMode = defineClosedVocabulary({
|
|
28
|
+
None: 'none',
|
|
29
|
+
ReadOnly: 'read-only',
|
|
30
|
+
Branch: 'branch',
|
|
31
|
+
});
|
|
32
|
+
const transcriptChannelShape = { input: true, agent: true };
|
|
33
|
+
const transcriptChannels = Object.keys(transcriptChannelShape);
|
|
34
|
+
export const TranscriptChannel = {
|
|
35
|
+
Input: transcriptChannels[0],
|
|
36
|
+
Agent: transcriptChannels[1],
|
|
37
|
+
};
|
|
38
|
+
const transcriptGroupKindShape = { session: true, run: true };
|
|
39
|
+
const transcriptGroupKinds = Object.keys(transcriptGroupKindShape);
|
|
40
|
+
export const TranscriptGroupKind = {
|
|
41
|
+
Session: transcriptGroupKinds[0],
|
|
42
|
+
Run: transcriptGroupKinds[1],
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ExecutionFailureCode } from '../contracts/vocabulary.js';
|
|
2
|
+
export function failureFrom(error) {
|
|
3
|
+
const source = sourceFailure(error);
|
|
4
|
+
return {
|
|
5
|
+
kind: ExecutionFailureCode.Unexpected,
|
|
6
|
+
message: source.message,
|
|
7
|
+
details: {
|
|
8
|
+
sourceKind: source.kind,
|
|
9
|
+
...(source.details === undefined ? {} : { sourceDetails: source.details }),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function sourceFailure(error) {
|
|
14
|
+
if (error instanceof Error)
|
|
15
|
+
return {
|
|
16
|
+
kind: error.name,
|
|
17
|
+
message: error.message,
|
|
18
|
+
...('details' in error ? { details: error.details } : {}),
|
|
19
|
+
};
|
|
20
|
+
if (typeof error === 'object' && error !== null) {
|
|
21
|
+
const kind = Reflect.get(error, 'kind');
|
|
22
|
+
const message = Reflect.get(error, 'message');
|
|
23
|
+
const details = Reflect.get(error, 'details');
|
|
24
|
+
return {
|
|
25
|
+
kind: typeof kind === 'string' && kind.length > 0 ? kind : 'non-error-object',
|
|
26
|
+
message: typeof message === 'string' ? message : failureValue(error),
|
|
27
|
+
...(details === undefined ? {} : { details }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return { kind: typeof error, message: failureValue(error) };
|
|
31
|
+
}
|
|
32
|
+
function failureValue(error) {
|
|
33
|
+
return typeof error === 'symbol' ? error.toString() : `${error}`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { EventActorKind } from '../../kernel/index.js';
|
|
2
|
+
import { ExecutionEventType } from '../contracts/events.js';
|
|
3
|
+
import { ExecutionFailureCode, RunStatus } from '../contracts/vocabulary.js';
|
|
4
|
+
export function foldRun(events) {
|
|
5
|
+
const started = events.find((event) => event.eventType === ExecutionEventType.RunStarted);
|
|
6
|
+
if (started === undefined)
|
|
7
|
+
return null;
|
|
8
|
+
const state = {
|
|
9
|
+
runId: started.stream.id,
|
|
10
|
+
activationId: started.payload.activationId,
|
|
11
|
+
activity: started.payload.activity,
|
|
12
|
+
...(started.payload.stage === undefined ? {} : { stage: started.payload.stage }),
|
|
13
|
+
workflowInstanceId: started.payload.workflowInstanceId,
|
|
14
|
+
orchestrationGroupId: started.payload.orchestrationGroupId,
|
|
15
|
+
attempt: started.payload.attempt,
|
|
16
|
+
status: RunStatus.Started,
|
|
17
|
+
ambiguityAttempts: 0,
|
|
18
|
+
escalated: false,
|
|
19
|
+
startedAt: started.payload.startedAt,
|
|
20
|
+
...(started.payload.runner === undefined ? {} : { runner: started.payload.runner }),
|
|
21
|
+
...(started.payload.workspace === undefined ? {} : { workspace: started.payload.workspace }),
|
|
22
|
+
};
|
|
23
|
+
for (const event of events)
|
|
24
|
+
applyRunEvent(state, event);
|
|
25
|
+
return state;
|
|
26
|
+
}
|
|
27
|
+
function applyRunEvent(state, event) {
|
|
28
|
+
if (state.status !== RunStatus.Started) {
|
|
29
|
+
if (state.status === RunStatus.Ambiguous &&
|
|
30
|
+
event.actor.kind === EventActorKind.Operator &&
|
|
31
|
+
(event.eventType === ExecutionEventType.RunSucceeded ||
|
|
32
|
+
event.eventType === ExecutionEventType.RunFailed))
|
|
33
|
+
return applyTerminalEvent(state, event);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
switch (event.eventType) {
|
|
37
|
+
case ExecutionEventType.RunStarted:
|
|
38
|
+
return;
|
|
39
|
+
case ExecutionEventType.RunSucceeded:
|
|
40
|
+
case ExecutionEventType.RunFailed:
|
|
41
|
+
case ExecutionEventType.RunCancelled:
|
|
42
|
+
return applyTerminalEvent(state, event);
|
|
43
|
+
default:
|
|
44
|
+
return applyLivenessEvent(state, event);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function applyTerminalEvent(state, event) {
|
|
48
|
+
if (event.eventType === ExecutionEventType.RunSucceeded) {
|
|
49
|
+
Object.assign(state, {
|
|
50
|
+
status: RunStatus.Succeeded,
|
|
51
|
+
finishedAt: event.payload.finishedAt,
|
|
52
|
+
outcome: event.payload.outcome,
|
|
53
|
+
escalated: false,
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (event.eventType === ExecutionEventType.RunCancelled) {
|
|
58
|
+
Object.assign(state, { status: RunStatus.Cancelled, finishedAt: event.payload.finishedAt });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
Object.assign(state, {
|
|
62
|
+
status: RunStatus.Failed,
|
|
63
|
+
finishedAt: event.payload.finishedAt,
|
|
64
|
+
failure: event.payload.failure,
|
|
65
|
+
escalated: false,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// eslint-disable-next-line complexity
|
|
69
|
+
function applyLivenessEvent(state, event) {
|
|
70
|
+
switch (event.eventType) {
|
|
71
|
+
case ExecutionEventType.RunLeaseClaimed:
|
|
72
|
+
case ExecutionEventType.RunLeaseRenewed:
|
|
73
|
+
Object.assign(state, { lease: event.payload });
|
|
74
|
+
return;
|
|
75
|
+
case ExecutionEventType.RunExternalExecutionReported:
|
|
76
|
+
Object.assign(state, { externalExecution: event.payload });
|
|
77
|
+
return;
|
|
78
|
+
case ExecutionEventType.RunWorkspaceCleanupFailed:
|
|
79
|
+
return;
|
|
80
|
+
case ExecutionEventType.RunRunnerResultReported:
|
|
81
|
+
Object.assign(state, event.payload.agent === undefined ? {} : { agent: event.payload.agent });
|
|
82
|
+
return;
|
|
83
|
+
case ExecutionEventType.RunCancellationRequested:
|
|
84
|
+
Object.assign(state, { cancellation: event.payload });
|
|
85
|
+
return;
|
|
86
|
+
case ExecutionEventType.RunCancellationConfirmed:
|
|
87
|
+
if (state.cancellation !== undefined)
|
|
88
|
+
Object.assign(state, {
|
|
89
|
+
cancellation: { ...state.cancellation, confirmedAt: event.payload.confirmedAt },
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
case ExecutionEventType.RunRecovered:
|
|
93
|
+
Object.assign(state, recoveredState(event.payload.result, event.payload.finishedAt, event.payload.outcome));
|
|
94
|
+
return;
|
|
95
|
+
case ExecutionEventType.RunAmbiguityObserved:
|
|
96
|
+
Object.assign(state, {
|
|
97
|
+
ambiguityAttempts: event.payload.attempt,
|
|
98
|
+
failure: { kind: ExecutionFailureCode.Unexpected, message: event.payload.reason },
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
case ExecutionEventType.RunAmbiguous:
|
|
102
|
+
Object.assign(state, {
|
|
103
|
+
status: RunStatus.Ambiguous,
|
|
104
|
+
finishedAt: event.payload.finishedAt,
|
|
105
|
+
failure: { kind: ExecutionFailureCode.Unexpected, message: event.payload.reason },
|
|
106
|
+
escalated: true,
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
default:
|
|
110
|
+
assertNever(event);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function recoveredState(result, finishedAt, outcome) {
|
|
114
|
+
if (result.transport === RunStatus.Succeeded)
|
|
115
|
+
return {
|
|
116
|
+
status: RunStatus.Succeeded,
|
|
117
|
+
finishedAt,
|
|
118
|
+
...(outcome === undefined ? {} : { outcome }),
|
|
119
|
+
};
|
|
120
|
+
if (result.transport === RunStatus.Cancelled)
|
|
121
|
+
return { status: RunStatus.Cancelled, finishedAt };
|
|
122
|
+
if (result.transport === RunStatus.Ambiguous)
|
|
123
|
+
return {
|
|
124
|
+
status: RunStatus.Ambiguous,
|
|
125
|
+
finishedAt,
|
|
126
|
+
failure: {
|
|
127
|
+
kind: ExecutionFailureCode.Unexpected,
|
|
128
|
+
message: result.failure?.message ?? 'Recovered execution is ambiguous',
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
status: RunStatus.Failed,
|
|
133
|
+
finishedAt,
|
|
134
|
+
failure: {
|
|
135
|
+
kind: ExecutionFailureCode.Unexpected,
|
|
136
|
+
message: result.failure?.message ?? 'Recovered execution failed',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function assertNever(value) {
|
|
141
|
+
throw new Error(`Unhandled Execution event: ${JSON.stringify(value)}`);
|
|
142
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from './application/execution-projection.js';
|
|
2
|
+
export * from './application/execution-service.js';
|
|
3
|
+
export * from './application/recovery-service.js';
|
|
4
|
+
export * from './application/run-repository.js';
|
|
5
|
+
export * from './contracts/commands.js';
|
|
6
|
+
export * from './contracts/config.js';
|
|
7
|
+
export * from './contracts/control-plane.js';
|
|
8
|
+
export * from './contracts/event-factory.js';
|
|
9
|
+
export * from './contracts/events.js';
|
|
10
|
+
export * from './contracts/identifiers.js';
|
|
11
|
+
export * from './contracts/liveness.js';
|
|
12
|
+
export * from './contracts/runner.js';
|
|
13
|
+
export * from './contracts/results.js';
|
|
14
|
+
export * from './contracts/streams.js';
|
|
15
|
+
export * from './contracts/views.js';
|
|
16
|
+
export * from './contracts/vocabulary.js';
|
|
17
|
+
export * from './contracts/workspace.js';
|
|
18
|
+
export * from './domain/run-result.js';
|
|
19
|
+
export * from './domain/run.js';
|
|
20
|
+
export * from './infrastructure/prompt-templates.js';
|
|
21
|
+
export * from './infrastructure/runners/claude.js';
|
|
22
|
+
export * from './infrastructure/runners/codex.js';
|
|
23
|
+
export * from './infrastructure/runners/command.js';
|
|
24
|
+
export * from './infrastructure/runners/cursor.js';
|
|
25
|
+
export * from './infrastructure/runners/fake.js';
|
|
26
|
+
export * from './infrastructure/runners/fake-scenarios.js';
|
|
27
|
+
export * from './infrastructure/runners/registry.js';
|
|
28
|
+
export * from './infrastructure/transcripts.js';
|
|
29
|
+
export * from './infrastructure/transcript-store.js';
|
|
30
|
+
export * from './infrastructure/workspace/fake-workspace.js';
|
|
31
|
+
export * from './infrastructure/workspace/git-workspace.js';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { RunStatus } from '../contracts/vocabulary.js';
|
|
2
|
+
export function parseAgentRunnerResponse(result) {
|
|
3
|
+
const parsed = parseResult(result.output);
|
|
4
|
+
return {
|
|
5
|
+
outcome: result.transport === RunStatus.Succeeded ? parsed.outcome : 'FAILED',
|
|
6
|
+
displayBody: result.transport === RunStatus.Succeeded
|
|
7
|
+
? parsed.displayBody
|
|
8
|
+
: result.failure?.message || parsed.displayBody || 'Runner failed without a response.',
|
|
9
|
+
metadata: metadata(result),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function parseResult(output) {
|
|
13
|
+
const direct = parseEnvelope(output);
|
|
14
|
+
if (direct !== undefined)
|
|
15
|
+
return {
|
|
16
|
+
outcome: direct.status,
|
|
17
|
+
displayBody: direct.displayBody ?? synthesized(direct.status),
|
|
18
|
+
};
|
|
19
|
+
const fence = /^```(?:wake-result[^\n]*\n|[ \t]*\n[ \t]*wake-result[ \t]*\n)([\s\S]*?)^```[ \t]*$/gm;
|
|
20
|
+
let last = null;
|
|
21
|
+
let match;
|
|
22
|
+
while ((match = fence.exec(output)) !== null)
|
|
23
|
+
last = match;
|
|
24
|
+
if (last !== null) {
|
|
25
|
+
try {
|
|
26
|
+
const json = (last[1] ?? '').replace(/\n(?:DONE|REJECTED|BLOCKED|FAILED)[ \t]*\n?$/, '');
|
|
27
|
+
const value = JSON.parse(json);
|
|
28
|
+
if (isOutcome(value.status))
|
|
29
|
+
return {
|
|
30
|
+
outcome: value.status,
|
|
31
|
+
displayBody: output.slice(0, last.index).trim() || synthesized(value.status),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// A malformed envelope intentionally falls through to the legacy sentinel rules.
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const lines = output.split('\n');
|
|
39
|
+
const lastLine = lines
|
|
40
|
+
.map((line) => line.trim())
|
|
41
|
+
.filter((line) => line.length > 0 && line !== '```')
|
|
42
|
+
.at(-1);
|
|
43
|
+
const normalized = lastLine?.replace(/^(?:\*\*|__)(.+)(?:\*\*|__)$/, '$1');
|
|
44
|
+
if (!isOutcome(normalized))
|
|
45
|
+
return {
|
|
46
|
+
outcome: output.trim().length === 0 ? 'FAILED' : 'BLOCKED',
|
|
47
|
+
displayBody: output.trim(),
|
|
48
|
+
};
|
|
49
|
+
let removed = false;
|
|
50
|
+
return {
|
|
51
|
+
outcome: normalized,
|
|
52
|
+
displayBody: lines
|
|
53
|
+
.reverse()
|
|
54
|
+
.filter((line) => {
|
|
55
|
+
if (!removed && line.trim() === lastLine) {
|
|
56
|
+
removed = true;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
})
|
|
61
|
+
.reverse()
|
|
62
|
+
.join('\n')
|
|
63
|
+
.trim(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function parseEnvelope(value) {
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(value.trim());
|
|
69
|
+
if (!isOutcome(parsed.status))
|
|
70
|
+
return undefined;
|
|
71
|
+
return {
|
|
72
|
+
status: parsed.status,
|
|
73
|
+
...(typeof parsed.displayBody === 'string' && parsed.displayBody.trim().length > 0
|
|
74
|
+
? { displayBody: parsed.displayBody }
|
|
75
|
+
: {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function isOutcome(value) {
|
|
83
|
+
return value === 'DONE' || value === 'REJECTED' || value === 'BLOCKED' || value === 'FAILED';
|
|
84
|
+
}
|
|
85
|
+
function synthesized(outcome) {
|
|
86
|
+
return {
|
|
87
|
+
DONE: 'Run completed.',
|
|
88
|
+
REJECTED: 'Run rejected - needs changes.',
|
|
89
|
+
BLOCKED: 'Run blocked - needs input.',
|
|
90
|
+
FAILED: 'Run failed.',
|
|
91
|
+
}[outcome];
|
|
92
|
+
}
|
|
93
|
+
function metadata(result) {
|
|
94
|
+
return {
|
|
95
|
+
runner: result.runner,
|
|
96
|
+
...(result.model === undefined ? {} : { model: result.model }),
|
|
97
|
+
...(result.sessionId === undefined ? {} : { sessionId: result.sessionId }),
|
|
98
|
+
...(result.tokenUsage === undefined
|
|
99
|
+
? {}
|
|
100
|
+
: {
|
|
101
|
+
inputTokens: result.tokenUsage.input,
|
|
102
|
+
outputTokens: result.tokenUsage.output,
|
|
103
|
+
...(result.tokenUsage.cacheRead === undefined
|
|
104
|
+
? {}
|
|
105
|
+
: { cacheReadTokens: result.tokenUsage.cacheRead }),
|
|
106
|
+
...(result.tokenUsage.cacheWrite === undefined
|
|
107
|
+
? {}
|
|
108
|
+
: { cacheWriteTokens: result.tokenUsage.cacheWrite }),
|
|
109
|
+
...(result.tokenUsage.costUsd === undefined
|
|
110
|
+
? {}
|
|
111
|
+
: { costUsd: result.tokenUsage.costUsd }),
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
}
|