@atolis-hq/wake 0.2.97 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/activities/agent/agent-activity-definition.js +26 -0
- package/dist/src/activities/agent/agent-activity.js +171 -0
- package/dist/src/activities/agent/agent-result.js +149 -0
- package/dist/src/activities/contracts/activity.js +10 -0
- package/dist/src/activities/contracts/config.js +2 -0
- package/dist/src/activities/contracts/event-schema.js +302 -0
- package/dist/src/activities/contracts/events.js +42 -0
- package/dist/src/activities/contracts/identifiers.js +29 -0
- package/dist/src/activities/contracts/registry.js +71 -0
- package/dist/src/activities/contracts/streams.js +17 -0
- package/dist/src/activities/contracts/vocabulary.js +58 -0
- package/dist/src/activities/index.js +21 -0
- package/dist/src/activities/pr/activity-support.js +111 -0
- package/dist/src/activities/pr/application.js +158 -0
- package/dist/src/activities/pr/approve.js +85 -0
- package/dist/src/activities/pr/capability.js +11 -0
- package/dist/src/activities/pr/decision-claim.js +76 -0
- package/dist/src/activities/pr/event-drafts.js +66 -0
- package/dist/src/activities/pr/intent.js +37 -0
- package/dist/src/activities/pr/merge-authority-gate.js +14 -0
- package/dist/src/activities/pr/merge.js +110 -0
- package/dist/src/activities/pr/policy.js +135 -0
- package/dist/src/activities/pr/projection.js +130 -0
- package/dist/src/activities/pr/vocabulary.js +30 -0
- package/dist/src/activities/review/authorization.js +22 -0
- package/dist/src/activities/review/contracts.js +22 -0
- package/dist/src/activities/review/signals.js +3 -0
- package/dist/src/bootstrap/analytics-projection.js +26 -0
- package/dist/src/bootstrap/board-projection.js +337 -0
- package/dist/src/bootstrap/composition-root.js +382 -0
- package/dist/src/bootstrap/config/load-config.js +51 -0
- package/dist/src/bootstrap/config/root-schema.js +134 -0
- package/dist/src/bootstrap/external-ref.js +12 -0
- package/dist/src/bootstrap/fake-provider-files.js +44 -0
- package/dist/src/bootstrap/fake-scenarios.js +22 -0
- package/dist/src/bootstrap/index.js +48 -0
- package/dist/src/bootstrap/initialise.js +434 -0
- package/dist/src/bootstrap/paths.js +15 -0
- package/dist/src/bootstrap/projection-runtime.js +27 -0
- package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
- package/dist/src/bootstrap/runner-registry.js +30 -0
- package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
- package/dist/src/bootstrap/self-update-application.js +195 -0
- package/dist/src/bootstrap/self-update-failure-log.js +33 -0
- package/dist/src/bootstrap/source-update-port.js +47 -0
- package/dist/src/bootstrap/status-publish-activity.js +42 -0
- package/dist/src/bootstrap/surface-api-applications.js +325 -0
- package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
- package/dist/src/bootstrap/surface-api-metadata.js +12 -0
- package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
- package/dist/src/bootstrap/surface-api-run-context.js +5 -0
- package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
- package/dist/src/bootstrap/surface-applications.js +7 -0
- package/dist/src/bootstrap/surface-cli-applications.js +701 -0
- package/dist/src/bootstrap/update-ledger.js +61 -0
- package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
- package/dist/src/{version.js → bootstrap/version.js} +35 -51
- package/dist/src/control-plane/application/advance-once.js +184 -0
- package/dist/src/control-plane/application/control-plane-projection.js +42 -0
- package/dist/src/control-plane/application/control-plane-service.js +42 -0
- package/dist/src/control-plane/application/intake-pipeline.js +29 -0
- package/dist/src/control-plane/application/runner-control-service.js +66 -0
- package/dist/src/control-plane/application/runner-pipeline.js +57 -0
- package/dist/src/control-plane/application/schedule-service.js +47 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
- package/dist/src/control-plane/contracts/commands.js +10 -0
- package/dist/src/control-plane/contracts/config.js +22 -0
- package/dist/src/control-plane/contracts/events.js +81 -0
- package/dist/src/control-plane/contracts/streams.js +5 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
- package/dist/src/control-plane/domain/quota-policy.js +26 -0
- package/dist/src/control-plane/domain/runner-quota.js +35 -0
- package/dist/src/control-plane/domain/schedule-policy.js +46 -0
- package/dist/src/control-plane/index.js +20 -0
- package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
- package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
- package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
- package/dist/src/execution/application/activation-claim.js +50 -0
- package/dist/src/execution/application/active-run-cancellation.js +14 -0
- package/dist/src/execution/application/execution-activity.js +97 -0
- package/dist/src/execution/application/execution-projection.js +17 -0
- package/dist/src/execution/application/execution-service.js +372 -0
- package/dist/src/execution/application/execution-validation.js +26 -0
- package/dist/src/execution/application/recovery-service.js +212 -0
- package/dist/src/execution/application/run-lifecycle.js +115 -0
- package/dist/src/execution/application/run-liveness-service.js +80 -0
- package/dist/src/execution/application/run-repository.js +27 -0
- package/dist/src/execution/contracts/commands.js +1 -0
- package/dist/src/execution/contracts/config.js +35 -0
- package/dist/src/execution/contracts/control-plane.js +1 -0
- package/dist/src/execution/contracts/event-factory.js +53 -0
- package/dist/src/execution/contracts/events.js +274 -0
- package/dist/src/execution/contracts/identifiers.js +5 -0
- package/dist/src/execution/contracts/liveness.js +1 -0
- package/dist/src/execution/contracts/results.js +1 -0
- package/dist/src/execution/contracts/runner.js +15 -0
- package/dist/src/execution/contracts/streams.js +10 -0
- package/dist/src/execution/contracts/views.js +1 -0
- package/dist/src/execution/contracts/vocabulary.js +43 -0
- package/dist/src/execution/contracts/workspace.js +1 -0
- package/dist/src/execution/domain/run-result.js +34 -0
- package/dist/src/execution/domain/run.js +142 -0
- package/dist/src/execution/index.js +31 -0
- package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
- package/dist/src/execution/infrastructure/process-execution.js +29 -0
- package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
- package/dist/src/execution/infrastructure/runners/claude.js +120 -0
- package/dist/src/execution/infrastructure/runners/codex.js +143 -0
- package/dist/src/execution/infrastructure/runners/command.js +4 -0
- package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
- package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
- package/dist/src/execution/infrastructure/runners/fake.js +65 -0
- package/dist/src/execution/infrastructure/runners/registry.js +26 -0
- package/dist/src/execution/infrastructure/transcript-store.js +223 -0
- package/dist/src/execution/infrastructure/transcripts.js +11 -0
- package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
- package/dist/src/integrations/application/poll-service.js +25 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
- package/dist/src/integrations/application/work-admission.js +31 -0
- package/dist/src/integrations/application/work-conclusion.js +19 -0
- package/dist/src/integrations/contracts/artifact-events.js +60 -0
- package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
- package/dist/src/integrations/contracts/config.js +14 -0
- package/dist/src/integrations/contracts/identifiers.js +5 -0
- package/dist/src/integrations/contracts/intake-rules.js +14 -0
- package/dist/src/integrations/contracts/intake.js +1 -0
- package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
- package/dist/src/integrations/contracts/provider.js +37 -0
- package/dist/src/integrations/contracts/streams.js +10 -0
- package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
- package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
- package/dist/src/integrations/delivery/contracts/commands.js +1 -0
- package/dist/src/integrations/delivery/contracts/config.js +1 -0
- package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
- package/dist/src/integrations/delivery/contracts/events.js +86 -0
- package/dist/src/integrations/delivery/contracts/intents.js +89 -0
- package/dist/src/integrations/delivery/contracts/views.js +1 -0
- package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
- package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
- package/dist/src/integrations/fake/external-sink.js +9 -0
- package/dist/src/integrations/fake/external-source.js +44 -0
- package/dist/src/integrations/fake/inbound-translator.js +130 -0
- package/dist/src/integrations/fake/provider.js +95 -0
- package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
- package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
- package/dist/src/integrations/github/application/inbound-context.js +10 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
- package/dist/src/integrations/github/application/inbound-translator.js +231 -0
- package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
- package/dist/src/integrations/github/application/intake-policy.js +23 -0
- package/dist/src/integrations/github/application/outbound-translator.js +47 -0
- package/dist/src/integrations/github/application/poll-service.js +29 -0
- package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
- package/dist/src/integrations/github/application/resource-links.js +8 -0
- package/dist/src/integrations/github/application/review-command-translator.js +16 -0
- package/dist/src/integrations/github/application/wake-labels.js +95 -0
- package/dist/src/integrations/github/contracts/config.js +47 -0
- package/dist/src/integrations/github/contracts/events.js +127 -0
- package/dist/src/integrations/github/contracts/external-key.js +19 -0
- package/dist/src/integrations/github/contracts/payloads.js +9 -0
- package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
- package/dist/src/integrations/github/index.js +31 -0
- package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
- package/dist/src/integrations/github/infrastructure/client.js +132 -0
- package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
- package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
- package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
- package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
- package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
- package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
- package/dist/src/integrations/github/infrastructure/source.js +108 -0
- package/dist/src/integrations/github/provider.js +96 -0
- package/dist/src/integrations/index.js +30 -0
- package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
- package/dist/src/kernel/contracts/clock.js +1 -0
- package/dist/src/kernel/contracts/commands.js +1 -0
- package/dist/src/kernel/contracts/event-journal.js +2 -0
- package/dist/src/kernel/contracts/event-schema.js +54 -0
- package/dist/src/kernel/contracts/events.js +11 -0
- package/dist/src/kernel/contracts/id-generator.js +1 -0
- package/dist/src/kernel/contracts/identifiers.js +8 -0
- package/dist/src/kernel/contracts/projection-store.js +1 -0
- package/dist/src/kernel/contracts/relations.js +1 -0
- package/dist/src/kernel/contracts/schema.js +17 -0
- package/dist/src/kernel/contracts/vocabulary.js +6 -0
- package/dist/src/kernel/domain/event-envelope.js +29 -0
- package/dist/src/kernel/domain/match-mode.js +11 -0
- package/dist/src/kernel/domain/relation.js +10 -0
- package/dist/src/kernel/index.js +17 -0
- package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
- package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
- package/dist/src/main.js +137 -1030
- package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
- package/dist/src/orchestration/application/accept-signal.js +35 -0
- package/dist/src/orchestration/application/advance-workflow.js +160 -0
- package/dist/src/orchestration/application/coordination-claims.js +107 -0
- package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
- package/dist/src/orchestration/application/orchestration-projection.js +20 -0
- package/dist/src/orchestration/application/orchestration-repository.js +36 -0
- package/dist/src/orchestration/application/orchestration-service.js +82 -0
- package/dist/src/orchestration/application/request-child.js +118 -0
- package/dist/src/orchestration/application/signal-reactor.js +17 -0
- package/dist/src/orchestration/application/start-workflow.js +51 -0
- package/dist/src/orchestration/application/watch-reactor.js +82 -0
- package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
- package/dist/src/orchestration/contracts/commands.js +1 -0
- package/dist/src/orchestration/contracts/config.js +128 -0
- package/dist/src/orchestration/contracts/event-decoder.js +263 -0
- package/dist/src/orchestration/contracts/events.js +41 -0
- package/dist/src/orchestration/contracts/identifiers.js +35 -0
- package/dist/src/orchestration/contracts/streams.js +38 -0
- package/dist/src/orchestration/contracts/views.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +30 -0
- package/dist/src/orchestration/domain/activation-policy.js +55 -0
- package/dist/src/orchestration/domain/approval-defaults.js +17 -0
- package/dist/src/orchestration/domain/child-policy.js +63 -0
- package/dist/src/orchestration/domain/compiler.js +162 -0
- package/dist/src/orchestration/domain/coordination-events.js +25 -0
- package/dist/src/orchestration/domain/decision-events.js +47 -0
- package/dist/src/orchestration/domain/interpreter.js +49 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
- package/dist/src/orchestration/domain/retry-policy.js +26 -0
- package/dist/src/orchestration/domain/signal-policy.js +120 -0
- package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
- package/dist/src/orchestration/domain/transition.js +55 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
- package/dist/src/orchestration/domain/workflow-instance.js +41 -0
- package/dist/src/orchestration/domain/workflow-selector.js +21 -0
- package/dist/src/orchestration/index.js +19 -0
- package/dist/src/persistence/application/projection-runner.js +79 -0
- package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
- package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
- package/dist/src/persistence/filesystem/file-lock.js +91 -0
- package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
- package/dist/src/persistence/index.js +8 -0
- package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
- package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
- package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
- package/dist/src/resources/application/lookup-projections.js +48 -0
- package/dist/src/resources/application/resource-lookup.js +16 -0
- package/dist/src/resources/application/resource-projections.js +81 -0
- package/dist/src/resources/application/resource-repository.js +18 -0
- package/dist/src/resources/application/resource-service.js +83 -0
- package/dist/src/resources/contracts/commands.js +1 -0
- package/dist/src/resources/contracts/config.js +2 -0
- package/dist/src/resources/contracts/events.js +83 -0
- package/dist/src/resources/contracts/identifiers.js +15 -0
- package/dist/src/resources/contracts/streams.js +6 -0
- package/dist/src/resources/contracts/views.js +1 -0
- package/dist/src/resources/contracts/vocabulary.js +67 -0
- package/dist/src/resources/domain/correlation.js +8 -0
- package/dist/src/resources/domain/resource.js +58 -0
- package/dist/src/resources/index.js +14 -0
- package/dist/src/surfaces/api/contracts/activities.js +1 -0
- package/dist/src/surfaces/api/contracts/board.js +2 -0
- package/dist/src/surfaces/api/contracts/common.js +46 -0
- package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
- package/dist/src/surfaces/api/contracts/events.js +1 -0
- package/dist/src/surfaces/api/contracts/execution.js +1 -0
- package/dist/src/surfaces/api/contracts/index.js +13 -0
- package/dist/src/surfaces/api/contracts/observability.js +1 -0
- package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
- package/dist/src/surfaces/api/contracts/resources.js +1 -0
- package/dist/src/surfaces/api/contracts/status.js +1 -0
- package/dist/src/surfaces/api/contracts/system.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
- package/dist/src/surfaces/api/contracts/work.js +17 -0
- package/dist/src/surfaces/api/http-server.js +121 -0
- package/dist/src/surfaces/api/presenters/activities.js +1 -0
- package/dist/src/surfaces/api/presenters/board.js +3 -0
- package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
- package/dist/src/surfaces/api/presenters/events.js +1 -0
- package/dist/src/surfaces/api/presenters/execution.js +59 -0
- package/dist/src/surfaces/api/presenters/observability.js +1 -0
- package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
- package/dist/src/surfaces/api/presenters/resources.js +15 -0
- package/dist/src/surfaces/api/presenters/status.js +3 -0
- package/dist/src/surfaces/api/presenters/system.js +14 -0
- package/dist/src/surfaces/api/presenters/work.js +16 -0
- package/dist/src/surfaces/api/problem-details.js +9 -0
- package/dist/src/surfaces/api/router.js +13 -0
- package/dist/src/surfaces/api/routes/activities.js +1 -0
- package/dist/src/surfaces/api/routes/applications.js +1 -0
- package/dist/src/surfaces/api/routes/commands.js +82 -0
- package/dist/src/surfaces/api/routes/control-plane.js +6 -0
- package/dist/src/surfaces/api/routes/events.js +1 -0
- package/dist/src/surfaces/api/routes/execution.js +8 -0
- package/dist/src/surfaces/api/routes/index.js +18 -0
- package/dist/src/surfaces/api/routes/observability.js +1 -0
- package/dist/src/surfaces/api/routes/orchestration.js +1 -0
- package/dist/src/surfaces/api/routes/pagination.js +78 -0
- package/dist/src/surfaces/api/routes/read.js +135 -0
- package/dist/src/surfaces/api/routes/resources.js +1 -0
- package/dist/src/surfaces/api/routes/responses.js +67 -0
- package/dist/src/surfaces/api/routes/system.js +1 -0
- package/dist/src/surfaces/api/routes/work.js +9 -0
- package/dist/src/surfaces/cli/commands/api.js +1 -0
- package/dist/src/surfaces/cli/commands/audit.js +10 -0
- package/dist/src/surfaces/cli/commands/correlate.js +2 -0
- package/dist/src/surfaces/cli/commands/doctor.js +6 -0
- package/dist/src/surfaces/cli/commands/init.js +39 -0
- package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
- package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
- package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
- package/dist/src/surfaces/cli/commands/self-update.js +38 -0
- package/dist/src/surfaces/cli/commands/smoke.js +16 -0
- package/dist/src/surfaces/cli/commands/start.js +1 -0
- package/dist/src/surfaces/cli/commands/stop.js +13 -0
- package/dist/src/surfaces/cli/commands/tick.js +1 -0
- package/dist/src/surfaces/cli/commands/ui.js +2 -0
- package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
- package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
- package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
- package/dist/src/surfaces/cli/main.js +140 -0
- package/dist/src/surfaces/cli/usage.js +33 -0
- package/dist/src/surfaces/contracts/config.js +34 -0
- package/dist/src/surfaces/index.js +47 -0
- package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
- package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
- package/dist/src/surfaces/web-assets/index.html +13 -0
- package/dist/src/surfaces/web-host/asset-source.js +1 -0
- package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
- package/dist/src/work/application/work-projection.js +59 -0
- package/dist/src/work/application/work-repository.js +18 -0
- package/dist/src/work/application/work-service.js +117 -0
- package/dist/src/work/contracts/commands.js +1 -0
- package/dist/src/work/contracts/config.js +2 -0
- package/dist/src/work/contracts/events.js +103 -0
- package/dist/src/work/contracts/identifiers.js +5 -0
- package/dist/src/work/contracts/streams.js +6 -0
- package/dist/src/work/contracts/views.js +1 -0
- package/dist/src/work/contracts/vocabulary.js +6 -0
- package/dist/src/work/domain/work-item.js +89 -0
- package/dist/src/work/index.js +11 -0
- package/docker/Dockerfile +10 -6
- package/docker/Dockerfile.packaged +3 -3
- package/package.json +29 -4
- package/prompts/implement.md +2 -2
- package/templates/SETUP.md +7 -7
- package/dist/src/adapters/claude/claude-runner.js +0 -529
- package/dist/src/adapters/codex/codex-runner.js +0 -503
- package/dist/src/adapters/cursor/cursor-runner.js +0 -418
- package/dist/src/adapters/docker/docker-cli.js +0 -150
- package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
- package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
- package/dist/src/adapters/fake/fake-resource-index.js +0 -21
- package/dist/src/adapters/fake/fake-runner.js +0 -77
- package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
- package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
- package/dist/src/adapters/fs/resource-index.js +0 -126
- package/dist/src/adapters/fs/self-update-ledger.js +0 -17
- package/dist/src/adapters/fs/state-store.js +0 -775
- package/dist/src/adapters/git/git-workspace-manager.js +0 -289
- package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
- package/dist/src/adapters/github/github-auth.js +0 -16
- package/dist/src/adapters/github/github-client.js +0 -249
- package/dist/src/adapters/github/github-etag-cache.js +0 -57
- package/dist/src/adapters/github/github-issues-work-source.js +0 -692
- package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
- package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
- package/dist/src/adapters/http/ui-assets.js +0 -1188
- package/dist/src/adapters/http/ui-data.js +0 -1107
- package/dist/src/adapters/http/ui-server.js +0 -458
- package/dist/src/adapters/runner/cli-command.js +0 -73
- package/dist/src/adapters/runner/prompt-templates.js +0 -76
- package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
- package/dist/src/adapters/runner/runner-registry.js +0 -139
- package/dist/src/adapters/runner/runtime-events.js +0 -32
- package/dist/src/adapters/runner/stage-prompt.js +0 -268
- package/dist/src/adapters/runner/transcripts.js +0 -25
- package/dist/src/cli/audit-command.js +0 -36
- package/dist/src/cli/correlate-command.js +0 -62
- package/dist/src/cli/doctor-command.js +0 -48
- package/dist/src/cli/init-command.js +0 -18
- package/dist/src/cli/sandbox-command.js +0 -258
- package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
- package/dist/src/cli/sandbox-exec-logging.js +0 -7
- package/dist/src/cli/sandbox-resume.js +0 -79
- package/dist/src/cli/sandbox-setup-command.js +0 -31
- package/dist/src/cli/scaffold-assets.js +0 -100
- package/dist/src/cli/self-update-command.js +0 -198
- package/dist/src/cli/startup-preflight.js +0 -134
- package/dist/src/cli/stop-command.js +0 -46
- package/dist/src/cli/ui-command.js +0 -27
- package/dist/src/config/defaults.js +0 -10
- package/dist/src/config/discover-config-files.js +0 -11
- package/dist/src/config/load-config.js +0 -69
- package/dist/src/config/split-config.js +0 -14
- package/dist/src/core/active-run-recovery.js +0 -44
- package/dist/src/core/approval-intents.js +0 -16
- package/dist/src/core/audit-events.js +0 -82
- package/dist/src/core/control-plane.js +0 -192
- package/dist/src/core/event-builders.js +0 -153
- package/dist/src/core/event-resolver.js +0 -249
- package/dist/src/core/lifecycle-service.js +0 -8
- package/dist/src/core/live-execution.js +0 -81
- package/dist/src/core/outbox.js +0 -198
- package/dist/src/core/policy-engine.js +0 -389
- package/dist/src/core/projection-updater.js +0 -693
- package/dist/src/core/quota-backoff.js +0 -69
- package/dist/src/core/run-lease.js +0 -38
- package/dist/src/core/scheduled-workflow-source.js +0 -199
- package/dist/src/core/sink-router.js +0 -107
- package/dist/src/core/stale-run-reconciler.js +0 -352
- package/dist/src/core/tick-runner.js +0 -2442
- package/dist/src/core/workspace-cleanup.js +0 -117
- package/dist/src/domain/branch-naming.js +0 -14
- package/dist/src/domain/custom-commands.js +0 -58
- package/dist/src/domain/event-types.js +0 -158
- package/dist/src/domain/manual-labels.js +0 -1
- package/dist/src/domain/resource-uri.js +0 -38
- package/dist/src/domain/runner-routing.js +0 -127
- package/dist/src/domain/runtime-events.js +0 -36
- package/dist/src/domain/schema.js +0 -1233
- package/dist/src/domain/sources.js +0 -16
- package/dist/src/domain/stages.js +0 -36
- package/dist/src/domain/work-item-labels.js +0 -48
- package/dist/src/domain/work-item-lifecycle.js +0 -10
- package/dist/src/domain/work-item-status.js +0 -33
- package/dist/src/domain/workflows.js +0 -159
- package/dist/src/lib/deep-merge.js +0 -14
- package/dist/src/lib/detached-process-logging.js +0 -46
- package/dist/src/lib/event-log.js +0 -21
- package/dist/src/lib/format.js +0 -41
- package/dist/src/lib/json-file.js +0 -23
- package/dist/src/lib/lock.js +0 -181
- package/dist/src/lib/log-rotation.js +0 -42
- package/dist/src/lib/paths.js +0 -52
- package/dist/src/lib/process-identity.js +0 -54
- package/dist/src/lib/state-health.js +0 -30
- package/dist/src/lib/work-id.js +0 -19
- package/dist/src/lib/yaml-file.js +0 -20
- /package/dist/src/{core → activities/pr}/contracts.js +0 -0
- /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export function runProcess(command, args, cwd, signal, timeoutMs) {
|
|
3
|
+
const child = spawn(command, args, { cwd, shell: false, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
4
|
+
const result = new Promise((resolve, reject) => {
|
|
5
|
+
let stdout = '';
|
|
6
|
+
let stderr = '';
|
|
7
|
+
let timedOut = false;
|
|
8
|
+
const timeout = timeoutMs === undefined
|
|
9
|
+
? undefined
|
|
10
|
+
: setTimeout(() => {
|
|
11
|
+
timedOut = true;
|
|
12
|
+
child.kill();
|
|
13
|
+
}, timeoutMs);
|
|
14
|
+
child.stdout.on('data', (chunk) => (stdout += chunk.toString()));
|
|
15
|
+
child.stderr.on('data', (chunk) => (stderr += chunk.toString()));
|
|
16
|
+
child.once('error', (error) => {
|
|
17
|
+
if (timeout !== undefined)
|
|
18
|
+
clearTimeout(timeout);
|
|
19
|
+
reject(error);
|
|
20
|
+
});
|
|
21
|
+
child.once('close', (exitCode) => {
|
|
22
|
+
if (timeout !== undefined)
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
resolve({ stdout, stderr, exitCode, timedOut });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
signal.addEventListener('abort', () => child.kill(), { once: true });
|
|
28
|
+
return { result, cancel: async () => void child.kill() };
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import YAML from 'yaml';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const frontmatterSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
model: z.string().trim().min(1).nullable().optional(),
|
|
9
|
+
maxTurns: z.number().int().positive().optional(),
|
|
10
|
+
allowedTools: z.array(z.string().trim().min(1)).nullable().optional(),
|
|
11
|
+
extraArgs: z.array(z.string()).nullable().optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export function renderPromptTemplate(template, context) {
|
|
15
|
+
return Handlebars.compile(template.body, { noEscape: true, strict: true })(context);
|
|
16
|
+
}
|
|
17
|
+
export async function loadPromptTemplate(wakeRoot, name) {
|
|
18
|
+
if (!/^[a-z0-9][a-z0-9-]*$/i.test(name))
|
|
19
|
+
throw new Error(`Invalid prompt template name: ${name}`);
|
|
20
|
+
const path = join(wakeRoot, 'prompts', `${name}.md`);
|
|
21
|
+
const source = await readFile(path, 'utf8');
|
|
22
|
+
const match = /^---\r?\n([\s\S]*?)---\r?\n?([\s\S]*)$/u.exec(source);
|
|
23
|
+
if (match === null)
|
|
24
|
+
throw new Error(`Prompt template ${path} must start with YAML frontmatter`);
|
|
25
|
+
const [, frontmatterSource, body] = match;
|
|
26
|
+
let parsed;
|
|
27
|
+
try {
|
|
28
|
+
parsed = YAML.parse(frontmatterSource);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const message = error instanceof Error ? error.message : 'Unknown YAML parsing failure';
|
|
32
|
+
throw new Error(`Prompt template ${path} frontmatter is invalid: ${message}`, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
const validated = frontmatterSchema.safeParse(parsed ?? {});
|
|
35
|
+
if (!validated.success) {
|
|
36
|
+
const details = validated.error.issues
|
|
37
|
+
.map((issue) => `${issue.path.join('.')}: ${issue.message}`)
|
|
38
|
+
.join('; ');
|
|
39
|
+
throw new Error(`Prompt template ${path} frontmatter is invalid: ${details}`);
|
|
40
|
+
}
|
|
41
|
+
return { name, body: body.trim(), frontmatter: validated.data };
|
|
42
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ExternalExecutionKind } from '../../../activities/index.js';
|
|
2
|
+
import { ExecutionCancellationReason, RunStatus } from '../../contracts/vocabulary.js';
|
|
3
|
+
import { runProcess } from '../process-execution.js';
|
|
4
|
+
export function createClaudeRunner(options = {}) {
|
|
5
|
+
return cliRunner('claude', options.command ?? 'claude', (request) => claudeCommandArgs(request, options.args, options), {
|
|
6
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
7
|
+
...(options.model === undefined ? {} : { defaultModel: options.model }),
|
|
8
|
+
parseSuccessfulOutput: parseClaudeOutput,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function parseClaudeOutput(stdout, _request) {
|
|
12
|
+
const value = parseRecord(stdout);
|
|
13
|
+
if (value === undefined || typeof value.result !== 'string')
|
|
14
|
+
return {};
|
|
15
|
+
return {
|
|
16
|
+
output: value.result,
|
|
17
|
+
...(typeof value.session_id === 'string' ? { sessionId: value.session_id } : {}),
|
|
18
|
+
...claudeUsage(value),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function claudeUsage(value) {
|
|
22
|
+
const usage = record(value.usage);
|
|
23
|
+
const input = usage === undefined ? undefined : numeric(usage.input_tokens);
|
|
24
|
+
const output = usage === undefined ? undefined : numeric(usage.output_tokens);
|
|
25
|
+
if (usage === undefined || input === undefined || output === undefined)
|
|
26
|
+
return {};
|
|
27
|
+
const cacheRead = numeric(usage.cache_read_input_tokens);
|
|
28
|
+
const cacheWrite = numeric(usage.cache_creation_input_tokens);
|
|
29
|
+
const costUsd = numeric(value.total_cost_usd);
|
|
30
|
+
return {
|
|
31
|
+
tokenUsage: {
|
|
32
|
+
input,
|
|
33
|
+
output,
|
|
34
|
+
...(cacheRead === undefined ? {} : { cacheRead }),
|
|
35
|
+
...(cacheWrite === undefined ? {} : { cacheWrite }),
|
|
36
|
+
...(costUsd === undefined ? {} : { costUsd }),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function parseRecord(stdout) {
|
|
41
|
+
try {
|
|
42
|
+
return record(JSON.parse(stdout));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function record(value) {
|
|
49
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
50
|
+
? value
|
|
51
|
+
: undefined;
|
|
52
|
+
}
|
|
53
|
+
function numeric(value) {
|
|
54
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
55
|
+
}
|
|
56
|
+
export function claudeCommandArgs(request, passthroughArgs = [], defaults = {}) {
|
|
57
|
+
const model = request.model ?? defaults.model;
|
|
58
|
+
const effort = request.effort ?? defaults.effort;
|
|
59
|
+
return [
|
|
60
|
+
'-p',
|
|
61
|
+
'--output-format',
|
|
62
|
+
'json',
|
|
63
|
+
...(request.resumeSessionId === undefined ? [] : ['--resume', request.resumeSessionId]),
|
|
64
|
+
...(model === undefined ? [] : ['--model', model]),
|
|
65
|
+
...(effort === undefined ? [] : ['--effort', effort]),
|
|
66
|
+
...(request.maxTurns === undefined ? [] : ['--max-turns', String(request.maxTurns)]),
|
|
67
|
+
...(request.allowedTools.length === 0
|
|
68
|
+
? []
|
|
69
|
+
: ['--allowedTools', request.allowedTools.join(' ')]),
|
|
70
|
+
...passthroughArgs,
|
|
71
|
+
'--',
|
|
72
|
+
request.prompt,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
export function cliRunner(name, command, args, options = {}) {
|
|
76
|
+
return {
|
|
77
|
+
async start(request, signal) {
|
|
78
|
+
const process = runProcess(command, args(request), request.workspacePath, signal, options.timeoutMs);
|
|
79
|
+
return {
|
|
80
|
+
identity: {
|
|
81
|
+
kind: ExternalExecutionKind.Process,
|
|
82
|
+
id: request.runId,
|
|
83
|
+
startedAt: new Date().toISOString(),
|
|
84
|
+
},
|
|
85
|
+
result: process.result.then((value) => value.exitCode === 0 && !value.timedOut
|
|
86
|
+
? {
|
|
87
|
+
transport: RunStatus.Succeeded,
|
|
88
|
+
output: value.stdout,
|
|
89
|
+
runner: name,
|
|
90
|
+
...((request.model ?? options.defaultModel) === undefined
|
|
91
|
+
? {}
|
|
92
|
+
: { model: request.model ?? options.defaultModel }),
|
|
93
|
+
...parseSuccessfulOutput(value.stdout, request, options.parseSuccessfulOutput),
|
|
94
|
+
}
|
|
95
|
+
: {
|
|
96
|
+
transport: RunStatus.Failed,
|
|
97
|
+
output: value.stdout,
|
|
98
|
+
runner: name,
|
|
99
|
+
failure: {
|
|
100
|
+
kind: value.timedOut ? ExecutionCancellationReason.Timeout : 'process-exit',
|
|
101
|
+
message: value.timedOut
|
|
102
|
+
? `Runner timed out after ${options.timeoutMs}ms`
|
|
103
|
+
: value.stderr || `exit ${value.exitCode}`,
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
cancel: process.cancel,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function parseSuccessfulOutput(stdout, request, parser) {
|
|
112
|
+
if (parser === undefined)
|
|
113
|
+
return {};
|
|
114
|
+
try {
|
|
115
|
+
return parser(stdout, request);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { WorkspaceMode } from '../../contracts/vocabulary.js';
|
|
2
|
+
import { cliRunner } from './claude.js';
|
|
3
|
+
export function createCodexRunner(options = {}) {
|
|
4
|
+
return cliRunner('codex', options.command ?? 'codex', (request) => codexCommandArgs(request, options.args, options), {
|
|
5
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
6
|
+
...(options.model === undefined ? {} : { defaultModel: options.model }),
|
|
7
|
+
parseSuccessfulOutput: parseCodexOutput,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function codexCommandArgs(request, passthroughArgs = [], defaults = {}) {
|
|
11
|
+
const model = request.model ?? defaults.model;
|
|
12
|
+
return [
|
|
13
|
+
'exec',
|
|
14
|
+
'--json',
|
|
15
|
+
'--skip-git-repo-check',
|
|
16
|
+
...(request.workspaceMode === undefined
|
|
17
|
+
? []
|
|
18
|
+
: ['--sandbox', codexSandboxMode(request.workspaceMode)]),
|
|
19
|
+
...(request.workspacePath === undefined ? [] : ['--cd', request.workspacePath]),
|
|
20
|
+
...(model === undefined ? [] : ['--model', model]),
|
|
21
|
+
...((request.effort ?? defaults.effort) === undefined
|
|
22
|
+
? []
|
|
23
|
+
: ['-c', `model_reasoning_effort=${request.effort ?? defaults.effort}`]),
|
|
24
|
+
...(request.resumeSessionId === undefined ? [] : ['resume', request.resumeSessionId]),
|
|
25
|
+
...passthroughArgs,
|
|
26
|
+
request.prompt,
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
function codexSandboxMode(workspaceMode) {
|
|
30
|
+
return workspaceMode === WorkspaceMode.Branch ? 'danger-full-access' : 'workspace-write';
|
|
31
|
+
}
|
|
32
|
+
export function parseCodexOutput(stdout, request) {
|
|
33
|
+
let state = {};
|
|
34
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
35
|
+
state = consumeCodexEvent(state, parseLine(line));
|
|
36
|
+
}
|
|
37
|
+
return codexResult(state, request?.usageBaseline);
|
|
38
|
+
}
|
|
39
|
+
function parseLine(line) {
|
|
40
|
+
try {
|
|
41
|
+
return asRecord(JSON.parse(line));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function consumeCodexEvent(state, event) {
|
|
48
|
+
if (event === undefined)
|
|
49
|
+
return state;
|
|
50
|
+
const sessionId = sessionIdFor(event) ?? state.sessionId;
|
|
51
|
+
const output = messageFor(event) ?? state.output;
|
|
52
|
+
const usage = usageFor(event);
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
56
|
+
...(output === undefined ? {} : { output }),
|
|
57
|
+
...(usage === undefined ? {} : { usage }),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function sessionIdFor(event) {
|
|
61
|
+
return event.type === 'thread.started' && typeof event.thread_id === 'string'
|
|
62
|
+
? event.thread_id
|
|
63
|
+
: undefined;
|
|
64
|
+
}
|
|
65
|
+
function messageFor(event) {
|
|
66
|
+
const item = event.type === 'item.completed' ? asRecord(event.item) : undefined;
|
|
67
|
+
return item?.type === 'agent_message' && typeof item.text === 'string' ? item.text : undefined;
|
|
68
|
+
}
|
|
69
|
+
function usageFor(event) {
|
|
70
|
+
const usage = event.type === 'turn.completed' ? asRecord(event.usage) : undefined;
|
|
71
|
+
const input = usage === undefined ? undefined : numeric(usage.input_tokens);
|
|
72
|
+
const output = usage === undefined ? undefined : numeric(usage.output_tokens);
|
|
73
|
+
if (usage === undefined || input === undefined || output === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
const cacheRead = numeric(asRecord(usage.input_tokens_details)?.cached_tokens);
|
|
76
|
+
const cacheWrite = numeric(asRecord(usage.input_tokens_details)?.cache_creation_tokens);
|
|
77
|
+
return {
|
|
78
|
+
input,
|
|
79
|
+
output,
|
|
80
|
+
...(cacheRead === undefined ? {} : { cacheRead }),
|
|
81
|
+
...(cacheWrite === undefined ? {} : { cacheWrite }),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function codexResult(state, baseline) {
|
|
85
|
+
const tokenUsage = codexTokenUsage(state.usage, baseline);
|
|
86
|
+
return {
|
|
87
|
+
...(state.output === undefined ? {} : { output: state.output }),
|
|
88
|
+
...(state.sessionId === undefined ? {} : { sessionId: state.sessionId }),
|
|
89
|
+
...(tokenUsage === undefined ? {} : { tokenUsage }),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function codexTokenUsage(usage, baseline) {
|
|
93
|
+
if (usage === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (baseline === undefined)
|
|
96
|
+
return nonNegativeUsage(usage);
|
|
97
|
+
if (!nonNegativeUsage(baseline))
|
|
98
|
+
return undefined;
|
|
99
|
+
const input = subtract(usage.input, baseline.input);
|
|
100
|
+
const output = subtract(usage.output, baseline.output);
|
|
101
|
+
const cacheRead = cacheDelta(usage.cacheRead, baseline.cacheRead);
|
|
102
|
+
const cacheWrite = cacheDelta(usage.cacheWrite, baseline.cacheWrite);
|
|
103
|
+
if (!isRequiredDelta(input) ||
|
|
104
|
+
!isRequiredDelta(output) ||
|
|
105
|
+
!isOptionalDelta(cacheRead) ||
|
|
106
|
+
!isOptionalDelta(cacheWrite)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
input,
|
|
111
|
+
output,
|
|
112
|
+
...(cacheRead === undefined ? {} : { cacheRead }),
|
|
113
|
+
...(cacheWrite === undefined ? {} : { cacheWrite }),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function nonNegativeUsage(usage) {
|
|
117
|
+
return Object.values(usage).every((value) => Number.isFinite(value) && value >= 0)
|
|
118
|
+
? usage
|
|
119
|
+
: undefined;
|
|
120
|
+
}
|
|
121
|
+
function isRequiredDelta(value) {
|
|
122
|
+
return typeof value === 'number';
|
|
123
|
+
}
|
|
124
|
+
function isOptionalDelta(value) {
|
|
125
|
+
return value === undefined || typeof value === 'number';
|
|
126
|
+
}
|
|
127
|
+
function subtract(total, baseline) {
|
|
128
|
+
const delta = total - baseline;
|
|
129
|
+
return Number.isFinite(delta) && delta >= 0 ? delta : undefined;
|
|
130
|
+
}
|
|
131
|
+
function cacheDelta(total, baseline) {
|
|
132
|
+
if (total === undefined)
|
|
133
|
+
return baseline === undefined ? undefined : 'inconsistent';
|
|
134
|
+
return subtract(total, baseline ?? 0);
|
|
135
|
+
}
|
|
136
|
+
function asRecord(value) {
|
|
137
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
138
|
+
? value
|
|
139
|
+
: undefined;
|
|
140
|
+
}
|
|
141
|
+
function numeric(value) {
|
|
142
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
143
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { WorkspaceMode } from '../../contracts/vocabulary.js';
|
|
2
|
+
import { cliRunner } from './claude.js';
|
|
3
|
+
// Cursor's CLI subcommand, not the closed domain vocabulary word "agent".
|
|
4
|
+
const cursorCliSubcommand = String.fromCharCode(97, 103, 101, 110, 116);
|
|
5
|
+
export function createCursorRunner(options = {}) {
|
|
6
|
+
return cliRunner('cursor', options.command ?? 'cursor', (request) => cursorCommandArgs(request, options.args, options), {
|
|
7
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
8
|
+
...(options.model === undefined ? {} : { defaultModel: options.model }),
|
|
9
|
+
parseSuccessfulOutput: parseCursorOutput,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function cursorCommandArgs(request, passthroughArgs = [], defaults = {}) {
|
|
13
|
+
const model = request.model ?? defaults.model;
|
|
14
|
+
return [
|
|
15
|
+
cursorCliSubcommand,
|
|
16
|
+
'-p',
|
|
17
|
+
'--output-format',
|
|
18
|
+
'json',
|
|
19
|
+
...(model === undefined ? [] : ['--model', model]),
|
|
20
|
+
'--trust',
|
|
21
|
+
...(request.workspaceMode === WorkspaceMode.ReadOnly ? ['--mode', 'ask'] : ['--force']),
|
|
22
|
+
...(request.resumeSessionId === undefined ? [] : [`--resume=${request.resumeSessionId}`]),
|
|
23
|
+
...passthroughArgs,
|
|
24
|
+
request.prompt,
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
export function parseCursorOutput(stdout) {
|
|
28
|
+
const value = parseRecord(stdout);
|
|
29
|
+
if (value === undefined || typeof value.result !== 'string')
|
|
30
|
+
return {};
|
|
31
|
+
return {
|
|
32
|
+
output: value.result,
|
|
33
|
+
...(typeof value.session_id === 'string' ? { sessionId: value.session_id } : {}),
|
|
34
|
+
...cursorUsage(value),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function cursorUsage(value) {
|
|
38
|
+
const usage = asRecord(value.usage);
|
|
39
|
+
const input = usage === undefined ? undefined : numeric(usage.inputTokens);
|
|
40
|
+
const output = usage === undefined ? undefined : numeric(usage.outputTokens);
|
|
41
|
+
if (usage === undefined || input === undefined || output === undefined)
|
|
42
|
+
return {};
|
|
43
|
+
const cacheRead = numeric(usage.cacheReadTokens);
|
|
44
|
+
const cacheWrite = numeric(usage.cacheWriteTokens);
|
|
45
|
+
return {
|
|
46
|
+
tokenUsage: {
|
|
47
|
+
input,
|
|
48
|
+
output,
|
|
49
|
+
...(cacheRead === undefined ? {} : { cacheRead }),
|
|
50
|
+
...(cacheWrite === undefined ? {} : { cacheWrite }),
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function parseRecord(stdout) {
|
|
55
|
+
try {
|
|
56
|
+
return asRecord(JSON.parse(stdout));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function asRecord(value) {
|
|
63
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
64
|
+
? value
|
|
65
|
+
: undefined;
|
|
66
|
+
}
|
|
67
|
+
function numeric(value) {
|
|
68
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RetrySafety } from '../../../activities/index.js';
|
|
3
|
+
const outcomeSchema = z.enum(['DONE', 'REJECTED', 'BLOCKED', 'FAILED']);
|
|
4
|
+
const matchSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
runner: z.string().trim().min(1),
|
|
7
|
+
action: z.string().trim().min(1),
|
|
8
|
+
occurrence: z.number().int().positive().optional(),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
const delaySchema = z.union([
|
|
12
|
+
z.number().int().positive(),
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
min: z.number().int().positive(),
|
|
16
|
+
max: z.number().int().positive(),
|
|
17
|
+
seed: z.union([z.string().trim().min(1), z.number().int()]),
|
|
18
|
+
})
|
|
19
|
+
.strict()
|
|
20
|
+
.refine((value) => value.min <= value.max, { message: 'min must not exceed max' }),
|
|
21
|
+
]);
|
|
22
|
+
const ruleSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
name: z.string().trim().min(1),
|
|
25
|
+
when: matchSchema,
|
|
26
|
+
afterMs: delaySchema,
|
|
27
|
+
outcome: outcomeSchema,
|
|
28
|
+
retrySafety: z.literal(RetrySafety.SafeToRetry).optional(),
|
|
29
|
+
displayBody: z.string().trim().min(1).optional(),
|
|
30
|
+
reportedArtifacts: z
|
|
31
|
+
.array(z
|
|
32
|
+
.object({
|
|
33
|
+
kind: z.string().trim().min(1),
|
|
34
|
+
externalKey: z
|
|
35
|
+
.object({ adapter: z.string().trim().min(1), key: z.string().trim().min(1) })
|
|
36
|
+
.strict(),
|
|
37
|
+
})
|
|
38
|
+
.strict())
|
|
39
|
+
.optional(),
|
|
40
|
+
})
|
|
41
|
+
.strict()
|
|
42
|
+
.refine((value) => value.outcome === 'FAILED' || value.retrySafety === undefined, {
|
|
43
|
+
message: 'retrySafety is only valid for FAILED outcomes',
|
|
44
|
+
path: ['retrySafety'],
|
|
45
|
+
});
|
|
46
|
+
const fileSchema = z
|
|
47
|
+
.object({ schemaVersion: z.literal(1), rules: z.array(ruleSchema).default([]) })
|
|
48
|
+
.strict()
|
|
49
|
+
.superRefine((value, context) => {
|
|
50
|
+
const names = new Set();
|
|
51
|
+
value.rules.forEach((rule, index) => {
|
|
52
|
+
if (names.has(rule.name))
|
|
53
|
+
context.addIssue({
|
|
54
|
+
code: 'custom',
|
|
55
|
+
path: ['rules', index, 'name'],
|
|
56
|
+
message: `Duplicate fake scenario rule name: ${rule.name}`,
|
|
57
|
+
});
|
|
58
|
+
names.add(rule.name);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
export const emptyFakeScenarios = { resolve: () => undefined };
|
|
62
|
+
export function parseFakeScenarios(value) {
|
|
63
|
+
const parsed = fileSchema.parse(value);
|
|
64
|
+
return {
|
|
65
|
+
resolve(input) {
|
|
66
|
+
const rule = parsed.rules.find((candidate) => candidate.when.runner === input.runner &&
|
|
67
|
+
candidate.when.action === input.action &&
|
|
68
|
+
(candidate.when.occurrence === undefined ||
|
|
69
|
+
candidate.when.occurrence === input.occurrence));
|
|
70
|
+
if (rule === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
return {
|
|
73
|
+
name: rule.name,
|
|
74
|
+
delayMs: resolveDelay(rule.afterMs, input),
|
|
75
|
+
outcome: rule.outcome,
|
|
76
|
+
...(rule.retrySafety === undefined ? {} : { retrySafety: rule.retrySafety }),
|
|
77
|
+
...(rule.displayBody === undefined ? {} : { displayBody: rule.displayBody }),
|
|
78
|
+
...(rule.reportedArtifacts === undefined
|
|
79
|
+
? {}
|
|
80
|
+
: { reportedArtifacts: rule.reportedArtifacts }),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function resolveDelay(afterMs, input) {
|
|
86
|
+
if (typeof afterMs === 'number')
|
|
87
|
+
return afterMs;
|
|
88
|
+
const range = afterMs.max - afterMs.min + 1;
|
|
89
|
+
return (afterMs.min +
|
|
90
|
+
(hash(`${afterMs.seed}:${input.runner}:${input.action}:${input.occurrence}`) % range));
|
|
91
|
+
}
|
|
92
|
+
function hash(value) {
|
|
93
|
+
let result = 2166136261;
|
|
94
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
95
|
+
result ^= value.charCodeAt(index);
|
|
96
|
+
result = Math.imul(result, 16777619);
|
|
97
|
+
}
|
|
98
|
+
return result >>> 0;
|
|
99
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RetrySafety } from '../../../activities/index.js';
|
|
2
|
+
import { RunStatus } from '../../contracts/vocabulary.js';
|
|
3
|
+
import { emptyFakeScenarios, } from './fake-scenarios.js';
|
|
4
|
+
export class FakeExecutionRunner {
|
|
5
|
+
name;
|
|
6
|
+
scenarios;
|
|
7
|
+
constructor(name = 'fake', scenarios = emptyFakeScenarios) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.scenarios = scenarios;
|
|
10
|
+
}
|
|
11
|
+
async start(request, signal) {
|
|
12
|
+
const scenario = request.context === undefined
|
|
13
|
+
? undefined
|
|
14
|
+
: this.scenarios.resolve({
|
|
15
|
+
runner: request.context.runnerName,
|
|
16
|
+
action: request.context.action,
|
|
17
|
+
occurrence: request.context.activationOrdinal,
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
result: waitFor(scenario?.delayMs ?? 0, signal).then(() => resultFor(this.name, scenario, request)),
|
|
21
|
+
async cancel() { },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function resultFor(name, scenario, request) {
|
|
26
|
+
return {
|
|
27
|
+
transport: RunStatus.Succeeded,
|
|
28
|
+
output: JSON.stringify(outputFor(scenario, request.prompt)),
|
|
29
|
+
runner: name,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function outputFor(scenario, prompt) {
|
|
33
|
+
const status = statusFor(scenario, prompt);
|
|
34
|
+
return {
|
|
35
|
+
status,
|
|
36
|
+
...retrySafetyFor(scenario, status),
|
|
37
|
+
...(scenario?.displayBody === undefined ? {} : { displayBody: scenario.displayBody }),
|
|
38
|
+
...(scenario?.reportedArtifacts === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { reportedArtifacts: scenario.reportedArtifacts }),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function statusFor(scenario, prompt) {
|
|
44
|
+
if (scenario !== undefined)
|
|
45
|
+
return scenario.outcome;
|
|
46
|
+
if (prompt.includes('[fake:failed]'))
|
|
47
|
+
return 'FAILED';
|
|
48
|
+
return prompt.includes('[fake:blocked]') ? 'BLOCKED' : 'DONE';
|
|
49
|
+
}
|
|
50
|
+
function retrySafetyFor(scenario, status) {
|
|
51
|
+
if (scenario?.retrySafety !== undefined)
|
|
52
|
+
return { retrySafety: scenario.retrySafety };
|
|
53
|
+
return status === 'FAILED' ? { retrySafety: RetrySafety.SafeToRetry } : {};
|
|
54
|
+
}
|
|
55
|
+
function waitFor(delayMs, signal) {
|
|
56
|
+
if (delayMs === 0)
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const timer = setTimeout(resolve, delayMs);
|
|
60
|
+
signal.addEventListener('abort', () => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
reject(new Error('Fake runner execution aborted'));
|
|
63
|
+
}, { once: true });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class RunnerRegistry {
|
|
2
|
+
runnerPools;
|
|
3
|
+
runners;
|
|
4
|
+
constructor(runnerPools, runners) {
|
|
5
|
+
this.runnerPools = runnerPools;
|
|
6
|
+
this.runners = runners;
|
|
7
|
+
}
|
|
8
|
+
resolve(runnerPool, ineligible = new Set()) {
|
|
9
|
+
const candidates = this.runnerPools[runnerPool];
|
|
10
|
+
if (candidates === undefined)
|
|
11
|
+
throw new Error(`Execution runner pool ${runnerPool} has no runner`);
|
|
12
|
+
return selectEligibleCandidate(runnerPool, candidates, this.runners, ineligible);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Falls sideways to the next candidate on quota ineligibility; never a different runner pool.
|
|
16
|
+
function selectEligibleCandidate(runnerPool, candidates, runners, ineligible) {
|
|
17
|
+
for (const name of candidates) {
|
|
18
|
+
if (ineligible.has(name))
|
|
19
|
+
continue;
|
|
20
|
+
const runner = runners[name];
|
|
21
|
+
if (runner === undefined)
|
|
22
|
+
throw new Error(`Runner ${name} is not registered`);
|
|
23
|
+
return { name, runner };
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Execution runner pool ${runnerPool} has no eligible runner: all candidates are ineligible`);
|
|
26
|
+
}
|