@revisium/orchestrator 0.0.0 → 0.1.0-alpha.10
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 +202 -1
- package/control-plane/bootstrap.config.json +104 -2
- package/control-plane/default-playbook/catalog/pipelines.json +657 -0
- package/control-plane/default-playbook/catalog/roles.json +65 -0
- package/control-plane/default-playbook/package.json +5 -0
- package/control-plane/default-playbook/playbook.json +13 -0
- package/control-plane/default-playbook/prompts/analyst.md +29 -0
- package/control-plane/default-playbook/prompts/developer.md +26 -0
- package/control-plane/default-playbook/prompts/integrator.md +20 -0
- package/control-plane/default-playbook/prompts/orchestrator.md +23 -0
- package/control-plane/default-playbook/prompts/reviewer.md +28 -0
- package/control-plane/default-playbook/prompts/triager.md +51 -0
- package/control-plane/default-playbook/prompts/watcher.md +24 -0
- package/dist/api/graphql-api/filters/agent-observability-exception.filter.js +24 -0
- package/dist/api/graphql-api/filters/agent-observability-exception.filter.js.map +1 -0
- package/dist/api/graphql-api/filters/graphql-validation-exception.filter.js +36 -0
- package/dist/api/graphql-api/filters/graphql-validation-exception.filter.js.map +1 -0
- package/dist/api/graphql-api/graphql-api.module.js +77 -0
- package/dist/api/graphql-api/graphql-api.module.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-bridge.service.js +296 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-bridge.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-mappers.js +64 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-mappers.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/constants.js +11 -0
- package/dist/api/graphql-api/graphql-ws/constants.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js +32 -0
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js +101 -0
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js +115 -0
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/subscription-mappers.js +85 -0
- package/dist/api/graphql-api/graphql-ws/subscription-mappers.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/ws.js +22 -0
- package/dist/api/graphql-api/graphql-ws/ws.js.map +1 -0
- package/dist/api/graphql-api/inbox/inbox-subscription.resolver.js +56 -0
- package/dist/api/graphql-api/inbox/inbox-subscription.resolver.js.map +1 -0
- package/dist/api/graphql-api/inbox/inbox.resolver.js +125 -0
- package/dist/api/graphql-api/inbox/inbox.resolver.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/answer-question.input.js +33 -0
- package/dist/api/graphql-api/inbox/inputs/answer-question.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/gate-decision.input.js +27 -0
- package/dist/api/graphql-api/inbox/inputs/gate-decision.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/list-inbox.input.js +28 -0
- package/dist/api/graphql-api/inbox/inputs/list-inbox.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/resolve-inbox-item.input.js +38 -0
- package/dist/api/graphql-api/inbox/inputs/resolve-inbox-item.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/gate-risk.model.js +53 -0
- package/dist/api/graphql-api/inbox/model/gate-risk.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-connection.model.js +16 -0
- package/dist/api/graphql-api/inbox/model/inbox-connection.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-item.model.js +88 -0
- package/dist/api/graphql-api/inbox/model/inbox-item.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-resolution.model.js +48 -0
- package/dist/api/graphql-api/inbox/model/inbox-resolution.model.js.map +1 -0
- package/dist/api/graphql-api/method/inputs/list-method.input.js +15 -0
- package/dist/api/graphql-api/method/inputs/list-method.input.js.map +1 -0
- package/dist/api/graphql-api/method/method.resolver.js +90 -0
- package/dist/api/graphql-api/method/method.resolver.js.map +1 -0
- package/dist/api/graphql-api/method/model/alternative-role-group.model.js +32 -0
- package/dist/api/graphql-api/method/model/alternative-role-group.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/pipeline-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/pipeline-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/pipeline.model.js +69 -0
- package/dist/api/graphql-api/method/model/pipeline.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/playbook-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/playbook-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/playbook.model.js +47 -0
- package/dist/api/graphql-api/method/model/playbook.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/role-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/role-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/role.model.js +98 -0
- package/dist/api/graphql-api/method/model/role.model.js.map +1 -0
- package/dist/api/graphql-api/pr/inputs/pr-readiness.input.js +52 -0
- package/dist/api/graphql-api/pr/inputs/pr-readiness.input.js.map +1 -0
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js +403 -0
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js.map +1 -0
- package/dist/api/graphql-api/pr/pr.resolver.js +76 -0
- package/dist/api/graphql-api/pr/pr.resolver.js.map +1 -0
- package/dist/api/graphql-api/registerGraphqlEnums.js +9 -0
- package/dist/api/graphql-api/registerGraphqlEnums.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/create-run.input.js +63 -0
- package/dist/api/graphql-api/runs/inputs/create-run.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-agent-log.input.js +48 -0
- package/dist/api/graphql-api/runs/inputs/get-agent-log.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-run-attempts.input.js +32 -0
- package/dist/api/graphql-api/runs/inputs/get-run-attempts.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-run-events.input.js +28 -0
- package/dist/api/graphql-api/runs/inputs/get-run-events.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/list-runs.input.js +23 -0
- package/dist/api/graphql-api/runs/inputs/list-runs.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/simulate-route.input.js +43 -0
- package/dist/api/graphql-api/runs/inputs/simulate-route.input.js.map +1 -0
- package/dist/api/graphql-api/runs/model/agent-activity.model.js +367 -0
- package/dist/api/graphql-api/runs/model/agent-activity.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/create-run-result.model.js +53 -0
- package/dist/api/graphql-api/runs/model/create-run-result.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-attempt.model.js +114 -0
- package/dist/api/graphql-api/runs/model/run-attempt.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-connection.model.js +16 -0
- package/dist/api/graphql-api/runs/model/run-connection.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-cost.model.js +67 -0
- package/dist/api/graphql-api/runs/model/run-cost.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-digest.model.js +41 -0
- package/dist/api/graphql-api/runs/model/run-digest.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-event-connection.model.js +16 -0
- package/dist/api/graphql-api/runs/model/run-event-connection.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-event.model.js +58 -0
- package/dist/api/graphql-api/runs/model/run-event.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-progress.model.js +33 -0
- package/dist/api/graphql-api/runs/model/run-progress.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-workflow.model.js +287 -0
- package/dist/api/graphql-api/runs/model/run-workflow.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run.model.js +57 -0
- package/dist/api/graphql-api/runs/model/run.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/usage.model.js +32 -0
- package/dist/api/graphql-api/runs/model/usage.model.js.map +1 -0
- package/dist/api/graphql-api/runs/run-digest.resolver.js +40 -0
- package/dist/api/graphql-api/runs/run-digest.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/run-events.resolver.js +45 -0
- package/dist/api/graphql-api/runs/run-events.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/run-progress.resolver.js +53 -0
- package/dist/api/graphql-api/runs/run-progress.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/runs-subscription.resolver.js +124 -0
- package/dist/api/graphql-api/runs/runs-subscription.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/runs.resolver.js +165 -0
- package/dist/api/graphql-api/runs/runs.resolver.js.map +1 -0
- package/dist/api/graphql-api/share/graphql-param-types.js +6 -0
- package/dist/api/graphql-api/share/graphql-param-types.js.map +1 -0
- package/dist/api/graphql-api/share/inputs/connection.input.js +27 -0
- package/dist/api/graphql-api/share/inputs/connection.input.js.map +1 -0
- package/dist/api/graphql-api/share/inputs/run-subscription.input.js +22 -0
- package/dist/api/graphql-api/share/inputs/run-subscription.input.js.map +1 -0
- package/dist/api/graphql-api/share/model/paginated.model.js +75 -0
- package/dist/api/graphql-api/share/model/paginated.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/daemon-status.model.js +47 -0
- package/dist/api/graphql-api/system/model/daemon-status.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/doctor-result.model.js +33 -0
- package/dist/api/graphql-api/system/model/doctor-result.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/project.model.js +37 -0
- package/dist/api/graphql-api/system/model/project.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/repository-context.model.js +70 -0
- package/dist/api/graphql-api/system/model/repository-context.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/repository-validation.model.js +62 -0
- package/dist/api/graphql-api/system/model/repository-validation.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/system-status.model.js +29 -0
- package/dist/api/graphql-api/system/model/system-status.model.js.map +1 -0
- package/dist/api/graphql-api/system/system.resolver.js +83 -0
- package/dist/api/graphql-api/system/system.resolver.js.map +1 -0
- package/dist/cli/commands/doctor-report.js +70 -0
- package/dist/cli/commands/doctor-report.js.map +1 -0
- package/dist/cli/commands/lifecycle.js +463 -0
- package/dist/cli/commands/lifecycle.js.map +1 -0
- package/dist/cli/commands/mcp.js +53 -8
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/process-tree.js +87 -0
- package/dist/cli/commands/process-tree.js.map +1 -0
- package/dist/cli/commands/revisium-helpers.js +2 -2
- package/dist/cli/commands/rogue-reaper.js +63 -0
- package/dist/cli/commands/rogue-reaper.js.map +1 -0
- package/dist/cli/index.js +5 -29
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/program.js +7 -23
- package/dist/cli/program.js.map +1 -1
- package/dist/config.js +79 -1
- package/dist/config.js.map +1 -1
- package/dist/control-plane/bootstrap.js +101 -0
- package/dist/control-plane/bootstrap.js.map +1 -0
- package/dist/control-plane/change-notifications.js +35 -0
- package/dist/control-plane/change-notifications.js.map +1 -0
- package/dist/control-plane/client-transport.js +74 -41
- package/dist/control-plane/client-transport.js.map +1 -1
- package/dist/control-plane/data-access.js +13 -5
- package/dist/control-plane/data-access.js.map +1 -1
- package/dist/control-plane/definitions.js +1 -1
- package/dist/control-plane/definitions.js.map +1 -1
- package/dist/control-plane/inbox.js +5 -31
- package/dist/control-plane/inbox.js.map +1 -1
- package/dist/control-plane/index.js +1 -1
- package/dist/control-plane/index.js.map +1 -1
- package/dist/control-plane/json-fields.js +2 -0
- package/dist/control-plane/json-fields.js.map +1 -1
- package/dist/control-plane/resolve-cwd.js +76 -8
- package/dist/control-plane/resolve-cwd.js.map +1 -1
- package/dist/control-plane/schema-migration.js +82 -0
- package/dist/control-plane/schema-migration.js.map +1 -0
- package/dist/control-plane/seed-default-playbook.js +141 -0
- package/dist/control-plane/seed-default-playbook.js.map +1 -0
- package/dist/control-plane/steps.js +15 -349
- package/dist/control-plane/steps.js.map +1 -1
- package/dist/control-plane/tables.js +1 -0
- package/dist/control-plane/tables.js.map +1 -1
- package/dist/e2e/kit/agents.js +148 -0
- package/dist/e2e/kit/agents.js.map +1 -0
- package/dist/e2e/kit/assertions.js +163 -0
- package/dist/e2e/kit/assertions.js.map +1 -0
- package/dist/e2e/kit/crash.js +44 -0
- package/dist/e2e/kit/crash.js.map +1 -0
- package/dist/e2e/kit/drive.js +45 -0
- package/dist/e2e/kit/drive.js.map +1 -0
- package/dist/e2e/kit/env.js +16 -0
- package/dist/e2e/kit/env.js.map +1 -0
- package/dist/e2e/kit/fake-integrator.js +57 -0
- package/dist/e2e/kit/fake-integrator.js.map +1 -0
- package/dist/e2e/kit/gh-emulator.js +213 -0
- package/dist/e2e/kit/gh-emulator.js.map +1 -0
- package/dist/e2e/kit/git-target-repo.js +115 -0
- package/dist/e2e/kit/git-target-repo.js.map +1 -0
- package/dist/e2e/kit/harness.js +72 -0
- package/dist/e2e/kit/harness.js.map +1 -0
- package/dist/e2e/kit/index.js +14 -0
- package/dist/e2e/kit/index.js.map +1 -0
- package/dist/e2e/kit/mcp.js +32 -0
- package/dist/e2e/kit/mcp.js.map +1 -0
- package/dist/e2e/kit/scenarios.js +196 -0
- package/dist/e2e/kit/scenarios.js.map +1 -0
- package/dist/e2e/recovery-crash-child.js +29 -0
- package/dist/e2e/recovery-crash-child.js.map +1 -0
- package/dist/e2e/recovery-dd-crash-child.js +43 -0
- package/dist/e2e/recovery-dd-crash-child.js.map +1 -0
- package/dist/engine/dbos.module.js +2 -1
- package/dist/engine/dbos.module.js.map +1 -1
- package/dist/engine/dbos.service.js +89 -18
- package/dist/engine/dbos.service.js.map +1 -1
- package/dist/engine/ensure-postgres.js +18 -4
- package/dist/engine/ensure-postgres.js.map +1 -1
- package/dist/features/inbox/commands/handlers/inbox-command.handlers.js +80 -0
- package/dist/features/inbox/commands/handlers/inbox-command.handlers.js.map +1 -0
- package/dist/features/inbox/commands/impl/answer-question.command.js +7 -0
- package/dist/features/inbox/commands/impl/answer-question.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/approve-gate.command.js +7 -0
- package/dist/features/inbox/commands/impl/approve-gate.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/reject-gate.command.js +7 -0
- package/dist/features/inbox/commands/impl/reject-gate.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/resolve-inbox-item.command.js +7 -0
- package/dist/features/inbox/commands/impl/resolve-inbox-item.command.js.map +1 -0
- package/dist/features/inbox/commands/index.js +8 -0
- package/dist/features/inbox/commands/index.js.map +1 -0
- package/dist/features/inbox/inbox-api.module.js +23 -0
- package/dist/features/inbox/inbox-api.module.js.map +1 -0
- package/dist/features/inbox/inbox-api.service.js +63 -0
- package/dist/features/inbox/inbox-api.service.js.map +1 -0
- package/dist/features/inbox/queries/handlers/inbox-query.handlers.js +111 -0
- package/dist/features/inbox/queries/handlers/inbox-query.handlers.js.map +1 -0
- package/dist/features/inbox/queries/impl/get-inbox-item.query.js +7 -0
- package/dist/features/inbox/queries/impl/get-inbox-item.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/get-pending-decisions.query.js +7 -0
- package/dist/features/inbox/queries/impl/get-pending-decisions.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/list-inbox.query.js +7 -0
- package/dist/features/inbox/queries/impl/list-inbox.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/summarize-gate-risk.query.js +7 -0
- package/dist/features/inbox/queries/impl/summarize-gate-risk.query.js.map +1 -0
- package/dist/features/inbox/queries/index.js +8 -0
- package/dist/features/inbox/queries/index.js.map +1 -0
- package/dist/features/method/commands/index.js +2 -0
- package/dist/features/method/commands/index.js.map +1 -0
- package/dist/features/method/method-api.module.js +23 -0
- package/dist/features/method/method-api.module.js.map +1 -0
- package/dist/features/method/method-api.service.js +47 -0
- package/dist/features/method/method-api.service.js.map +1 -0
- package/dist/features/method/queries/handlers/method-query.handlers.js +115 -0
- package/dist/features/method/queries/handlers/method-query.handlers.js.map +1 -0
- package/dist/features/method/queries/impl/get-pipeline.query.js +7 -0
- package/dist/features/method/queries/impl/get-pipeline.query.js.map +1 -0
- package/dist/features/method/queries/impl/get-role.query.js +7 -0
- package/dist/features/method/queries/impl/get-role.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-pipelines.query.js +7 -0
- package/dist/features/method/queries/impl/list-pipelines.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-playbooks.query.js +7 -0
- package/dist/features/method/queries/impl/list-playbooks.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-roles.query.js +7 -0
- package/dist/features/method/queries/impl/list-roles.query.js.map +1 -0
- package/dist/features/method/queries/index.js +9 -0
- package/dist/features/method/queries/index.js.map +1 -0
- package/dist/features/pr/commands/index.js +2 -0
- package/dist/features/pr/commands/index.js.map +1 -0
- package/dist/features/pr/pr-api.module.js +23 -0
- package/dist/features/pr/pr-api.module.js.map +1 -0
- package/dist/features/pr/pr-api.service.js +35 -0
- package/dist/features/pr/pr-api.service.js.map +1 -0
- package/dist/features/pr/queries/handlers/pr-query.handlers.js +48 -0
- package/dist/features/pr/queries/handlers/pr-query.handlers.js.map +1 -0
- package/dist/features/pr/queries/impl/get-pr-readiness.query.js +7 -0
- package/dist/features/pr/queries/impl/get-pr-readiness.query.js.map +1 -0
- package/dist/features/pr/queries/impl/list-pr-feedback.query.js +7 -0
- package/dist/features/pr/queries/impl/list-pr-feedback.query.js.map +1 -0
- package/dist/features/pr/queries/index.js +3 -0
- package/dist/features/pr/queries/index.js.map +1 -0
- package/dist/features/runs/commands/handlers/runs-command.handlers.js +32 -0
- package/dist/features/runs/commands/handlers/runs-command.handlers.js.map +1 -0
- package/dist/features/runs/commands/impl/create-run.command.js +7 -0
- package/dist/features/runs/commands/impl/create-run.command.js.map +1 -0
- package/dist/features/runs/commands/index.js +3 -0
- package/dist/features/runs/commands/index.js.map +1 -0
- package/dist/features/runs/queries/handlers/runs-query.handlers.js +359 -0
- package/dist/features/runs/queries/handlers/runs-query.handlers.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-activity.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-activity.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-attempts.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-attempts.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-log.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-log.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-attempts.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-attempts.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-digest.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-digest.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-events.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-events.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-progress.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-progress.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-workflow.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-workflow.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run.query.js.map +1 -0
- package/dist/features/runs/queries/impl/list-runs.query.js +7 -0
- package/dist/features/runs/queries/impl/list-runs.query.js.map +1 -0
- package/dist/features/runs/queries/impl/simulate-route.query.js +7 -0
- package/dist/features/runs/queries/impl/simulate-route.query.js.map +1 -0
- package/dist/features/runs/queries/index.js +15 -0
- package/dist/features/runs/queries/index.js.map +1 -0
- package/dist/features/runs/runs-api.module.js +23 -0
- package/dist/features/runs/runs-api.module.js.map +1 -0
- package/dist/features/runs/runs-api.service.js +79 -0
- package/dist/features/runs/runs-api.service.js.map +1 -0
- package/dist/features/shared/connection.js +39 -0
- package/dist/features/shared/connection.js.map +1 -0
- package/dist/features/system/commands/index.js +2 -0
- package/dist/features/system/commands/index.js.map +1 -0
- package/dist/features/system/queries/handlers/system-query.handlers.js +96 -0
- package/dist/features/system/queries/handlers/system-query.handlers.js.map +1 -0
- package/dist/features/system/queries/impl/doctor.query.js +4 -0
- package/dist/features/system/queries/impl/doctor.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-project.query.js +4 -0
- package/dist/features/system/queries/impl/get-project.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-repository-context.query.js +7 -0
- package/dist/features/system/queries/impl/get-repository-context.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-status.query.js +4 -0
- package/dist/features/system/queries/impl/get-status.query.js.map +1 -0
- package/dist/features/system/queries/impl/validate-repository.query.js +7 -0
- package/dist/features/system/queries/impl/validate-repository.query.js.map +1 -0
- package/dist/features/system/queries/index.js +9 -0
- package/dist/features/system/queries/index.js.map +1 -0
- package/dist/features/system/system-api.module.js +23 -0
- package/dist/features/system/system-api.module.js.map +1 -0
- package/dist/features/system/system-api.service.js +47 -0
- package/dist/features/system/system-api.service.js.map +1 -0
- package/dist/host/daemon.js +99 -0
- package/dist/host/daemon.js.map +1 -0
- package/dist/host/dbos-identity.js +42 -0
- package/dist/host/dbos-identity.js.map +1 -0
- package/dist/host/ensure-host.js +120 -0
- package/dist/host/ensure-host.js.map +1 -0
- package/dist/host/host-runtime.js +90 -0
- package/dist/host/host-runtime.js.map +1 -0
- package/dist/host/host.lifecycle.js +16 -3
- package/dist/host/host.lifecycle.js.map +1 -1
- package/dist/host/queue-ownership.js +70 -0
- package/dist/host/queue-ownership.js.map +1 -0
- package/dist/host/queue-poller-census.js +47 -0
- package/dist/host/queue-poller-census.js.map +1 -0
- package/dist/http/graphql-host.js +56 -0
- package/dist/http/graphql-host.js.map +1 -0
- package/dist/{mcp/mcp.module.js → http/graphql-host.module.js} +12 -10
- package/dist/http/graphql-host.module.js.map +1 -0
- package/dist/infrastructure/metrics/graphql/graphql-metrics.js +91 -0
- package/dist/infrastructure/metrics/graphql/graphql-metrics.js.map +1 -0
- package/dist/mcp/mcp-capabilities.js +9 -1
- package/dist/mcp/mcp-capabilities.js.map +1 -1
- package/dist/mcp/mcp-facade.service.js +68 -5
- package/dist/mcp/mcp-facade.service.js.map +1 -1
- package/dist/mcp/mcp-http.service.js +95 -0
- package/dist/mcp/mcp-http.service.js.map +1 -0
- package/dist/mcp/mcp-tools.js +93 -7
- package/dist/mcp/mcp-tools.js.map +1 -1
- package/dist/observability/agent-activity-reporter.js +185 -0
- package/dist/observability/agent-activity-reporter.js.map +1 -0
- package/dist/observability/agent-observability.service.js +1142 -0
- package/dist/observability/agent-observability.service.js.map +1 -0
- package/dist/observability/index.js +4 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/types.js +11 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pipeline/await-human.js +8 -4
- package/dist/pipeline/await-human.js.map +1 -1
- package/dist/pipeline/data-driven-task.workflow.js +667 -0
- package/dist/pipeline/data-driven-task.workflow.js.map +1 -0
- package/dist/pipeline/data-driven-template.js +57 -0
- package/dist/pipeline/data-driven-template.js.map +1 -0
- package/dist/pipeline/pipeline.module.js +2 -2
- package/dist/pipeline/pipeline.module.js.map +1 -1
- package/dist/pipeline/pipeline.service.js +412 -0
- package/dist/pipeline/pipeline.service.js.map +1 -0
- package/dist/pipeline/route-contract.js +82 -0
- package/dist/pipeline/route-contract.js.map +1 -0
- package/dist/pipeline-core/index.js +16 -0
- package/dist/pipeline-core/index.js.map +1 -0
- package/dist/pipeline-core/interpret.js +353 -0
- package/dist/pipeline-core/interpret.js.map +1 -0
- package/dist/pipeline-core/kit/assertions.js +61 -0
- package/dist/pipeline-core/kit/assertions.js.map +1 -0
- package/dist/pipeline-core/kit/builders.js +138 -0
- package/dist/pipeline-core/kit/builders.js.map +1 -0
- package/dist/pipeline-core/kit/drive.js +96 -0
- package/dist/pipeline-core/kit/drive.js.map +1 -0
- package/dist/pipeline-core/kit/fixtures.js +342 -0
- package/dist/pipeline-core/kit/fixtures.js.map +1 -0
- package/dist/pipeline-core/kit/index.js +13 -0
- package/dist/pipeline-core/kit/index.js.map +1 -0
- package/dist/pipeline-core/types.js +134 -0
- package/dist/pipeline-core/types.js.map +1 -0
- package/dist/pipeline-core/validate-capability.js +23 -0
- package/dist/pipeline-core/validate-capability.js.map +1 -0
- package/dist/pipeline-core/validate-conflicts.js +37 -0
- package/dist/pipeline-core/validate-conflicts.js.map +1 -0
- package/dist/pipeline-core/validate-dataflow.js +212 -0
- package/dist/pipeline-core/validate-dataflow.js.map +1 -0
- package/dist/pipeline-core/validate-diff.js +158 -0
- package/dist/pipeline-core/validate-diff.js.map +1 -0
- package/dist/pipeline-core/validate-edges.js +44 -0
- package/dist/pipeline-core/validate-edges.js.map +1 -0
- package/dist/pipeline-core/validate-graph.js +123 -0
- package/dist/pipeline-core/validate-graph.js.map +1 -0
- package/dist/pipeline-core/validate-loops.js +226 -0
- package/dist/pipeline-core/validate-loops.js.map +1 -0
- package/dist/pipeline-core/validate-parallel.js +132 -0
- package/dist/pipeline-core/validate-parallel.js.map +1 -0
- package/dist/pipeline-core/validate-sink.js +27 -0
- package/dist/pipeline-core/validate-sink.js.map +1 -0
- package/dist/pipeline-core/validate-topology.js +140 -0
- package/dist/pipeline-core/validate-topology.js.map +1 -0
- package/dist/pipeline-core/validate-verdict.js +72 -0
- package/dist/pipeline-core/validate-verdict.js.map +1 -0
- package/dist/pipeline-core/validate.js +119 -0
- package/dist/pipeline-core/validate.js.map +1 -0
- package/dist/playbook/catalog-loader.js +14 -1
- package/dist/playbook/catalog-loader.js.map +1 -1
- package/dist/playbook/import-mapper.js +14 -38
- package/dist/playbook/import-mapper.js.map +1 -1
- package/dist/playbook/manifest.js +1 -1
- package/dist/revisium/playbooks.service.js +107 -19
- package/dist/revisium/playbooks.service.js.map +1 -1
- package/dist/revisium/roles.service.js +1 -1
- package/dist/revisium/roles.service.js.map +1 -1
- package/dist/revisium/run.service.js +55 -8
- package/dist/revisium/run.service.js.map +1 -1
- package/dist/run/append-event.js +24 -1
- package/dist/run/append-event.js.map +1 -1
- package/dist/run/block-run.js +17 -0
- package/dist/run/block-run.js.map +1 -0
- package/dist/run/complete-run.js +18 -0
- package/dist/run/complete-run.js.map +1 -0
- package/dist/run/create-run.js +33 -36
- package/dist/run/create-run.js.map +1 -1
- package/dist/run/inspect-run.js +31 -30
- package/dist/run/inspect-run.js.map +1 -1
- package/dist/run/run-outputs.js +88 -0
- package/dist/run/run-outputs.js.map +1 -0
- package/dist/run/terminal-run-status.js +66 -7
- package/dist/run/terminal-run-status.js.map +1 -1
- package/dist/runners/claude-code.service.js +5 -0
- package/dist/runners/claude-code.service.js.map +1 -1
- package/dist/runners/codex.service.js +51 -0
- package/dist/runners/codex.service.js.map +1 -0
- package/dist/runners/integrator-branch-naming.js +39 -0
- package/dist/runners/integrator-branch-naming.js.map +1 -0
- package/dist/runners/integrator-git.js +84 -0
- package/dist/runners/integrator-git.js.map +1 -0
- package/dist/runners/integrator-remote.js +34 -0
- package/dist/runners/integrator-remote.js.map +1 -0
- package/dist/runners/integrator-types.js +9 -0
- package/dist/runners/integrator-types.js.map +1 -0
- package/dist/runners/integrator.js +327 -147
- package/dist/runners/integrator.js.map +1 -1
- package/dist/runners/runner.module.js +7 -3
- package/dist/runners/runner.module.js.map +1 -1
- package/dist/runners/worktree.service.js +63 -0
- package/dist/runners/worktree.service.js.map +1 -0
- package/dist/smoke/cli.js +47 -0
- package/dist/smoke/cli.js.map +1 -0
- package/dist/smoke/isolation.js +113 -0
- package/dist/smoke/isolation.js.map +1 -0
- package/dist/task-control-plane/run-watch.service.js +281 -0
- package/dist/task-control-plane/run-watch.service.js.map +1 -0
- package/dist/task-control-plane/task-control-plane-api.service.js +569 -23
- package/dist/task-control-plane/task-control-plane-api.service.js.map +1 -1
- package/dist/task-control-plane/task-control-plane.module.js +22 -3
- package/dist/task-control-plane/task-control-plane.module.js.map +1 -1
- package/dist/worker/artifact-store.js +116 -0
- package/dist/worker/artifact-store.js.map +1 -0
- package/dist/worker/build-context.js +169 -2
- package/dist/worker/build-context.js.map +1 -1
- package/dist/worker/claude-code-runner.js +159 -68
- package/dist/worker/claude-code-runner.js.map +1 -1
- package/dist/worker/codex-runner.js +474 -0
- package/dist/worker/codex-runner.js.map +1 -0
- package/dist/worker/git-worktree-manager.js +129 -65
- package/dist/worker/git-worktree-manager.js.map +1 -1
- package/dist/worker/process-executor.js +23 -2
- package/dist/worker/process-executor.js.map +1 -1
- package/dist/worker/result-envelope.js +115 -57
- package/dist/worker/result-envelope.js.map +1 -1
- package/dist/worker/runner-common.js +106 -0
- package/dist/worker/runner-common.js.map +1 -0
- package/dist/worker/runner-dispatch.js +4 -1
- package/dist/worker/runner-dispatch.js.map +1 -1
- package/dist/worker/runner.js +11 -1
- package/dist/worker/runner.js.map +1 -1
- package/dist/worker/stub-runner.js +7 -45
- package/dist/worker/stub-runner.js.map +1 -1
- package/package.json +32 -7
- package/dist/app.module.js +0 -28
- package/dist/app.module.js.map +0 -1
- package/dist/cli/commands/bootstrap.js +0 -39
- package/dist/cli/commands/bootstrap.js.map +0 -1
- package/dist/cli/commands/dev.js +0 -143
- package/dist/cli/commands/dev.js.map +0 -1
- package/dist/cli/commands/inbox.js +0 -288
- package/dist/cli/commands/inbox.js.map +0 -1
- package/dist/cli/commands/playbook.js +0 -74
- package/dist/cli/commands/playbook.js.map +0 -1
- package/dist/cli/commands/poll-workflow-state.js +0 -144
- package/dist/cli/commands/poll-workflow-state.js.map +0 -1
- package/dist/cli/commands/revisium-context.js +0 -23
- package/dist/cli/commands/revisium-context.js.map +0 -1
- package/dist/cli/commands/revisium.js +0 -89
- package/dist/cli/commands/revisium.js.map +0 -1
- package/dist/cli/commands/run.js +0 -426
- package/dist/cli/commands/run.js.map +0 -1
- package/dist/cli/commands/work.js +0 -149
- package/dist/cli/commands/work.js.map +0 -1
- package/dist/cli/live-guard.js +0 -49
- package/dist/cli/live-guard.js.map +0 -1
- package/dist/cli/needs-host.js +0 -78
- package/dist/cli/needs-host.js.map +0 -1
- package/dist/mcp/mcp-stdio.service.js +0 -48
- package/dist/mcp/mcp-stdio.service.js.map +0 -1
- package/dist/mcp/mcp.module.js.map +0 -1
- package/dist/pipeline/develop-task.workflow.js +0 -497
- package/dist/pipeline/develop-task.workflow.js.map +0 -1
- package/dist/worker/loop.js +0 -122
- package/dist/worker/loop.js.map +0 -1
- package/dist/worker/script-runner.js +0 -28
- package/dist/worker/script-runner.js.map +0 -1
- package/dist/worker/worker-id.js +0 -18
- package/dist/worker/worker-id.js.map +0 -1
- package/dist/worker/worktree-manager.js +0 -7
- package/dist/worker/worktree-manager.js.map +0 -1
|
@@ -1,84 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git-worktree-manager.ts — per-RUN git worktree lifecycle (plan 0017).
|
|
3
|
+
*
|
|
4
|
+
* DBOS-SEALED: zero @dbos-inc imports. Create/release are registered as memoized DBOS steps in
|
|
5
|
+
* PipelineService; this module is pure git side effects + deterministic paths.
|
|
6
|
+
*
|
|
7
|
+
* Each LIVE run gets ONE isolated worktree at `<dataDir>/worktrees/<runId>`, checked out on the run's
|
|
8
|
+
* feature branch (the SAME `feat/<taskId>-<slug>` the integrator computes) off a freshly-fetched
|
|
9
|
+
* `origin/<base>`. The developer (and rework) steps + the integrator all resolve their cwd to it
|
|
10
|
+
* (see resolveRunCwd), so the user's base checkout is never mutated and concurrent runs on one repo
|
|
11
|
+
* cannot collide. The durable artifact is the pushed branch; the worktree is execution scratch.
|
|
12
|
+
*
|
|
13
|
+
* Replay-safety: `createRunWorktree` is create-IF-ABSENT (a no-op returning the existing path when the
|
|
14
|
+
* worktree is already valid), so a DBOS replay / crash-recovery re-entry never errors and preserves
|
|
15
|
+
* in-flight uncommitted developer work. `releaseRunWorktree` is best-effort and no-ops if absent.
|
|
16
|
+
*/
|
|
1
17
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { existsSync,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
18
|
+
import { existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync, } from 'node:fs';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
import { worktreePathFor, worktreeMarkerFor, isWorktreeDir, } from '../control-plane/resolve-cwd.js';
|
|
21
|
+
import { resolveExecutable } from '../runners/integrator.js';
|
|
22
|
+
const GIT_TIMEOUT_MS = 60_000;
|
|
23
|
+
// Resolve `git` to an ABSOLUTE path once (mirrors the integrator's defaultExecGit): execFileSync is
|
|
24
|
+
// never handed a bare command name resolved against a mutable PATH at spawn time.
|
|
25
|
+
let _gitAbsPath;
|
|
26
|
+
function gitAbsPath() {
|
|
27
|
+
if (_gitAbsPath === undefined)
|
|
28
|
+
_gitAbsPath = resolveExecutable('git');
|
|
29
|
+
return _gitAbsPath;
|
|
6
30
|
}
|
|
7
|
-
|
|
8
|
-
|
|
31
|
+
/** Default git executor — runs the absolute `git` binary in `cwd`. */
|
|
32
|
+
function defaultExecGit(args, cwd) {
|
|
33
|
+
return execFileSync(gitAbsPath(), args, { encoding: 'utf8', cwd, timeout: GIT_TIMEOUT_MS });
|
|
9
34
|
}
|
|
10
|
-
|
|
11
|
-
|
|
35
|
+
const INSTALL_TIMEOUT_MS = 300_000;
|
|
36
|
+
/** Default pnpm install executor — runs the absolute `pnpm` binary. Throws if pnpm is unavailable
|
|
37
|
+
* (the caller treats a throw as "fall back to the node_modules symlink"). */
|
|
38
|
+
function defaultExecInstall(args, cwd) {
|
|
39
|
+
execFileSync(resolveExecutable('pnpm'), args, { cwd, timeout: INSTALL_TIMEOUT_MS, stdio: 'ignore' });
|
|
12
40
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Provision the worktree's dependencies so the developer/tests can build & run.
|
|
43
|
+
*
|
|
44
|
+
* Why pnpm gets a real install (not the symlink): pnpm's `node_modules` is a virtual store of symlinks
|
|
45
|
+
* into `node_modules/.pnpm` wired to the project layout; symlinking the base's `node_modules` into a
|
|
46
|
+
* worktree at a different path shares a MUTABLE tree across runs (one install/postinstall leaks into
|
|
47
|
+
* the base and parallel runs). A `pnpm install --frozen-lockfile` in the worktree is cheap (hard-links
|
|
48
|
+
* from the global content-addressed store, no re-download) and yields a correct, ISOLATED tree from the
|
|
49
|
+
* committed `pnpm-lock.yaml`. Non-pnpm repos keep the best-effort base-`node_modules` symlink.
|
|
50
|
+
*/
|
|
51
|
+
function provisionDeps(worktreePath, baseRepoCwd, execInstall) {
|
|
52
|
+
if (existsSync(join(worktreePath, 'pnpm-lock.yaml'))) {
|
|
53
|
+
try {
|
|
54
|
+
execInstall(['install', '--frozen-lockfile'], worktreePath);
|
|
55
|
+
return; // isolated install succeeded — do NOT also symlink
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// pnpm unavailable / install failed — fall through to the symlink fallback below
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const baseModules = join(baseRepoCwd, 'node_modules');
|
|
63
|
+
const wtModules = join(worktreePath, 'node_modules');
|
|
64
|
+
if (existsSync(baseModules) && !existsSync(wtModules)) {
|
|
65
|
+
symlinkSync(baseModules, wtModules, 'dir');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// ignore — the developer simply runs without provisioned node_modules
|
|
70
|
+
}
|
|
20
71
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Create the run's isolated worktree if absent (idempotent). Returns its path.
|
|
74
|
+
*
|
|
75
|
+
* 1. If a valid worktree already exists at the deterministic path → write the live marker and return
|
|
76
|
+
* it (replay / recovery: never clobber in-flight developer work).
|
|
77
|
+
* 2. Else: fetch `origin/<base>`, then `git worktree add -B <branch> <path> origin/<base>` (create-or-
|
|
78
|
+
* reset the feature branch and check it out in the new worktree).
|
|
79
|
+
* 3. Provision deps (provisionDeps): `pnpm install --frozen-lockfile` for a pnpm repo, else a
|
|
80
|
+
* best-effort base-`node_modules` symlink — so the developer can build/test in the isolated tree.
|
|
81
|
+
* 4. Write the `<runId>.live` marker (fail-loud signal for the resolver).
|
|
82
|
+
*/
|
|
83
|
+
export function createRunWorktree(opts) {
|
|
84
|
+
const { runId, baseRepoCwd, base, branch, dataDir } = opts;
|
|
85
|
+
const execGit = opts.execGit ?? defaultExecGit;
|
|
86
|
+
const execInstall = opts.execInstall ?? defaultExecInstall;
|
|
87
|
+
const worktreePath = worktreePathFor(dataDir, runId);
|
|
88
|
+
if (isWorktreeDir(worktreePath)) {
|
|
89
|
+
writeMarker(dataDir, runId);
|
|
90
|
+
return { worktreePath };
|
|
24
91
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
92
|
+
mkdirSync(dirname(worktreePath), { recursive: true });
|
|
93
|
+
// Fetch the base so the worktree is cut from fresh origin/<base>.
|
|
94
|
+
execGit(['fetch', 'origin', base], baseRepoCwd);
|
|
95
|
+
// -B: create-or-reset <branch> at origin/<base> and check it out in the new linked worktree.
|
|
96
|
+
execGit(['worktree', 'add', '-B', branch, worktreePath, `origin/${base}`], baseRepoCwd);
|
|
97
|
+
// Provision dependencies (pnpm install for a pnpm repo, else node_modules symlink) — best-effort.
|
|
98
|
+
provisionDeps(worktreePath, baseRepoCwd, execInstall);
|
|
99
|
+
writeMarker(dataDir, runId);
|
|
100
|
+
return { worktreePath };
|
|
30
101
|
}
|
|
31
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Release the run's worktree (best-effort, idempotent). Removes the linked worktree + prunes stale
|
|
104
|
+
* administrative entries + drops the live marker. No-ops if the worktree is already gone. Called only
|
|
105
|
+
* at a TERMINAL state — never while parked at a gate (the workflow stays alive across `recv`, so the
|
|
106
|
+
* lifecycle `finally` does not run during a park).
|
|
107
|
+
*/
|
|
108
|
+
export function releaseRunWorktree(opts) {
|
|
109
|
+
const { runId, baseRepoCwd, dataDir } = opts;
|
|
110
|
+
const execGit = opts.execGit ?? defaultExecGit;
|
|
111
|
+
const worktreePath = worktreePathFor(dataDir, runId);
|
|
32
112
|
try {
|
|
33
|
-
|
|
113
|
+
if (existsSync(worktreePath)) {
|
|
114
|
+
execGit(['worktree', 'remove', '--force', worktreePath], baseRepoCwd);
|
|
115
|
+
}
|
|
34
116
|
}
|
|
35
117
|
catch {
|
|
36
|
-
//
|
|
118
|
+
// ignore — fall through to a best-effort dir removal, then prune the admin entry
|
|
37
119
|
}
|
|
38
|
-
}
|
|
39
|
-
function pruneWorktrees(gitRoot) {
|
|
40
120
|
try {
|
|
41
|
-
|
|
121
|
+
if (existsSync(worktreePath))
|
|
122
|
+
rmSync(worktreePath, { recursive: true, force: true });
|
|
42
123
|
}
|
|
43
124
|
catch {
|
|
44
|
-
|
|
125
|
+
// ignore
|
|
45
126
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const worktreePath = join(gitRoot, '.worktrees', stepId);
|
|
51
|
-
await this.release(worktreePath);
|
|
52
|
-
git(['worktree', 'add', '-b', branchName(stepId), worktreePath, 'HEAD'], gitRoot);
|
|
53
|
-
const sourceNodeModules = join(gitRoot, 'node_modules');
|
|
54
|
-
const targetNodeModules = join(worktreePath, 'node_modules');
|
|
55
|
-
if (existsSync(sourceNodeModules)) {
|
|
56
|
-
if (existsSync(targetNodeModules) || lstatSync(targetNodeModules, { throwIfNoEntry: false }) !== undefined) {
|
|
57
|
-
rmSync(targetNodeModules, { recursive: true, force: true });
|
|
58
|
-
}
|
|
59
|
-
symlinkSync(sourceNodeModules, targetNodeModules, 'dir');
|
|
60
|
-
}
|
|
61
|
-
return worktreePath;
|
|
127
|
+
// Prune AFTER any manual removal so the `.git/worktrees/<id>` admin entry is cleaned in both the
|
|
128
|
+
// `git worktree remove` path and the manual-rm fallback path.
|
|
129
|
+
try {
|
|
130
|
+
execGit(['worktree', 'prune'], baseRepoCwd);
|
|
62
131
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
git(['worktree', 'remove', '--force', worktreePath], gitRoot);
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
console.warn(`Warning: git worktree remove failed for ${worktreePath}; deleting directory directly`);
|
|
73
|
-
rmSync(worktreePath, { recursive: true, force: true });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (existsSync(worktreePath)) {
|
|
77
|
-
console.warn(`Warning: worktree path still exists after git removal: ${worktreePath}; deleting directory directly`);
|
|
78
|
-
rmSync(worktreePath, { recursive: true, force: true });
|
|
79
|
-
}
|
|
80
|
-
pruneWorktrees(gitRoot);
|
|
81
|
-
deleteBranchIfPresent(gitRoot, stepIdFromWorktreePath(worktreePath));
|
|
132
|
+
catch {
|
|
133
|
+
// ignore — prune is housekeeping only
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
rmSync(worktreeMarkerFor(dataDir, runId), { force: true });
|
|
82
137
|
}
|
|
138
|
+
catch {
|
|
139
|
+
// ignore
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// The live marker is the signal that makes resolveRunCwd FAIL LOUD on a lost worktree. If it cannot be
|
|
143
|
+
// written we must NOT proceed silently (a later lost worktree would then fall back to the shared base
|
|
144
|
+
// checkout, masking the isolation failure) — throw so the create step fails and the run surfaces it.
|
|
145
|
+
function writeMarker(dataDir, runId) {
|
|
146
|
+
writeFileSync(worktreeMarkerFor(dataDir, runId), `${runId}\n`, 'utf8');
|
|
83
147
|
}
|
|
84
148
|
//# sourceMappingURL=git-worktree-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-worktree-manager.js","sourceRoot":"","sources":["../../src/worker/git-worktree-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"git-worktree-manager.js","sourceRo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M,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,sGAAsG;AACtG,qGAAqG;AACrG,SAAS,WAAW,CAAC,OAAe,EAAE,KAAa;IACjD,aAAa,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,MAAM,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -29,10 +29,31 @@ export const spawnExecutor = (req) => new Promise((resolve, reject) => {
|
|
|
29
29
|
let stderr = '';
|
|
30
30
|
let timedOut = false;
|
|
31
31
|
let settled = false;
|
|
32
|
+
if (child.pid !== undefined)
|
|
33
|
+
req.onSpawn?.(child.pid);
|
|
32
34
|
child.stdout?.setEncoding('utf8');
|
|
33
35
|
child.stderr?.setEncoding('utf8');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
// Guard the sink callbacks: a throw here (e.g. a failed artifact write) would otherwise
|
|
37
|
+
// escape the stream 'data' handler as an uncaughtException and crash the worker. The
|
|
38
|
+
// in-memory capture above is unaffected, so the result envelope is still collected.
|
|
39
|
+
child.stdout?.on('data', (chunk) => {
|
|
40
|
+
stdout += chunk;
|
|
41
|
+
try {
|
|
42
|
+
req.onStdoutChunk?.(chunk);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.warn(`Warning: onStdoutChunk sink failed: ${String(err)}`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
child.stderr?.on('data', (chunk) => {
|
|
49
|
+
stderr += chunk;
|
|
50
|
+
try {
|
|
51
|
+
req.onStderrChunk?.(chunk);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.warn(`Warning: onStderrChunk sink failed: ${String(err)}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
36
57
|
const timer = setTimeout(() => {
|
|
37
58
|
timedOut = true;
|
|
38
59
|
killGroup(child);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-executor.js","sourceRoot":"","sources":["../../src/worker/process-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"process-executor.js","sourceRoot":"","sources":["../../src/worker/process-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AA2B9D,8FAA8F;AAC9F,kGAAkG;AAClG,gGAAgG;AAChG,SAAS,SAAS,CAAC,KAAmB;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAoB,CAAC,GAAG,EAAE,EAAE,CACpD,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE;QACzC,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG;QAC3D,yFAAyF;QACzF,2FAA2F;QAC3F,QAAQ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
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
// The only supported agent result channel: the Claude CLI `--json-schema` constrains the final
|
|
2
|
+
// message and returns it as the transport `structured_output` field. The engine routes only on the
|
|
3
|
+
// top-level `verdict` from that structured object; prose output is never parsed for routing.
|
|
4
|
+
export const AGENT_RESULT_SCHEMA = JSON.stringify({
|
|
5
|
+
type: 'object',
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
verdict: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
minLength: 1,
|
|
11
|
+
description: 'the single routing token, lowercase, e.g. approved | changes_requested | blocker | clean | dirty',
|
|
12
|
+
},
|
|
13
|
+
output: { type: 'string', description: 'a short summary, or the artifact (e.g. the plan) the next step consumes' },
|
|
14
|
+
artifacts: { description: 'optional JSON artifacts, e.g. { "planPath": "docs/plans/00xx.md" }' },
|
|
15
|
+
nextSteps: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
description: 'optional follow-up work items; use [] when there is no follow-up work',
|
|
18
|
+
items: { type: 'object' },
|
|
19
|
+
},
|
|
20
|
+
needsHuman: { type: 'boolean', description: 'true only if you are blocked and a human must intervene' },
|
|
21
|
+
lesson: { type: 'string', description: 'optional one-line note for a future attempt' },
|
|
22
|
+
},
|
|
23
|
+
required: ['verdict', 'output'],
|
|
24
|
+
});
|
|
25
|
+
/** Short prompt note paired with `--json-schema`; the CLI returns the result as `structured_output`. */
|
|
26
|
+
export const STRUCTURED_RESULT_NOTE = `
|
|
27
|
+
Return your final answer as JSON matching the provided output schema:
|
|
28
|
+
- "verdict": the single routing token for your role (lowercase; e.g. approved | changes_requested | blocker | clean | dirty).
|
|
29
|
+
- "output": a short summary, or — if you produce an artifact for a later step (e.g. an implementation plan) — that artifact.
|
|
30
|
+
- "nextSteps": [] unless you are explicitly creating legacy follow-up steps.
|
|
31
|
+
Set "needsHuman": true only if you are blocked and a human must intervene.
|
|
28
32
|
`;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
/** Build the AgentResult from the required structured_output object (the --json-schema path). */
|
|
34
|
+
export function agentResultFromStructured(structured) {
|
|
35
|
+
if (structured === undefined) {
|
|
36
|
+
throw new TypeError('agent structured result missing structured_output');
|
|
37
|
+
}
|
|
38
|
+
if (structured === null || typeof structured !== 'object' || Array.isArray(structured)) {
|
|
39
|
+
throw new TypeError('agent structured result must be an object');
|
|
40
|
+
}
|
|
41
|
+
const o = structured;
|
|
42
|
+
if (typeof o.verdict !== 'string' || o.verdict.trim().length === 0) {
|
|
43
|
+
throw new TypeError('agent structured result missing required top-level verdict');
|
|
44
|
+
}
|
|
45
|
+
if (typeof o.output !== 'string') {
|
|
46
|
+
throw new TypeError('agent structured result missing required string output');
|
|
47
|
+
}
|
|
48
|
+
if ('needsHuman' in o && typeof o.needsHuman !== 'boolean') {
|
|
49
|
+
throw new TypeError('agent structured result needsHuman must be a boolean when present');
|
|
50
|
+
}
|
|
51
|
+
if ('lesson' in o && o.lesson !== null && typeof o.lesson !== 'string') {
|
|
52
|
+
throw new TypeError('agent structured result lesson must be a string when present');
|
|
53
|
+
}
|
|
54
|
+
if ('nextSteps' in o && !Array.isArray(o.nextSteps)) {
|
|
55
|
+
throw new TypeError('agent structured result nextSteps must be an array when present');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
output: o.output,
|
|
59
|
+
verdict: o.verdict,
|
|
60
|
+
artifacts: o.artifacts,
|
|
61
|
+
nextSteps: Array.isArray(o.nextSteps) ? o.nextSteps : [],
|
|
62
|
+
needsHuman: o.needsHuman === true,
|
|
63
|
+
lesson: typeof o.lesson === 'string' ? o.lesson : undefined,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
33
66
|
function readNumber(value) {
|
|
34
67
|
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
35
68
|
}
|
|
@@ -40,6 +73,9 @@ function readFinalText(obj) {
|
|
|
40
73
|
return obj.text;
|
|
41
74
|
return '';
|
|
42
75
|
}
|
|
76
|
+
function readNonEmptyString(value) {
|
|
77
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
78
|
+
}
|
|
43
79
|
// Layer A. Parse defensively; field names are read only inside this module, so a CLI drift is a
|
|
44
80
|
// one-file change. Throws only when stdout is not parseable JSON.
|
|
45
81
|
export function parseTransportEnvelope(stdout) {
|
|
@@ -60,38 +96,60 @@ export function parseTransportEnvelope(stdout) {
|
|
|
60
96
|
return {
|
|
61
97
|
text: readFinalText(obj),
|
|
62
98
|
isError: Boolean(obj.is_error),
|
|
99
|
+
permissionDenials: obj.permission_denials,
|
|
100
|
+
terminalReason: readNonEmptyString(obj.terminal_reason),
|
|
101
|
+
sessionId: readNonEmptyString(obj.session_id),
|
|
63
102
|
costUsd: readNumber(obj.total_cost_usd) ?? readNumber(obj.cost_usd),
|
|
64
103
|
inputTokens: readNumber(usage?.input_tokens),
|
|
65
104
|
outputTokens: readNumber(usage?.output_tokens),
|
|
105
|
+
structuredOutput: obj.structured_output,
|
|
66
106
|
};
|
|
67
107
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Reduce the runner's stdout to the single terminal `result` JSON object, then hand it to
|
|
110
|
+
* parseTransportEnvelope. Handles BOTH shapes:
|
|
111
|
+
* - legacy `--output-format json` → the whole stdout is one `{...}` object;
|
|
112
|
+
* - `--output-format stream-json` → a JSONL stream (system/assistant/user/… lines) whose LAST
|
|
113
|
+
* line is `{"type":"result",...}`.
|
|
114
|
+
* Confirmed by experiment (2026-06-23): under stream-json the terminal result still carries
|
|
115
|
+
* `structured_output`, `usage`, and `total_cost_usd`, so verdict/cost extraction is unchanged.
|
|
116
|
+
* Throws when no result object is present (the runner maps that to a lesson-bearing failure).
|
|
117
|
+
*/
|
|
118
|
+
export function extractTerminalResult(stdout) {
|
|
119
|
+
const trimmed = stdout.trim();
|
|
120
|
+
if (trimmed === '')
|
|
121
|
+
throw new Error('claude -p produced no output (no result envelope)');
|
|
122
|
+
// Legacy single-object form: the whole stdout parses as one object. Accept only a terminal
|
|
123
|
+
// result (`type` 'result' or absent — the legacy `--output-format json` blob is `type:'result'`);
|
|
124
|
+
// a lone non-result stream event (e.g. `{"type":"assistant",…}`) must fall through so the JSONL
|
|
125
|
+
// scan reports the clear "no result event" error rather than failing later on a missing result.
|
|
78
126
|
try {
|
|
79
|
-
|
|
127
|
+
const whole = JSON.parse(trimmed);
|
|
128
|
+
if (whole !== null && typeof whole === 'object' && !Array.isArray(whole)) {
|
|
129
|
+
const type = whole.type;
|
|
130
|
+
if (type === undefined || type === 'result')
|
|
131
|
+
return trimmed;
|
|
132
|
+
}
|
|
80
133
|
}
|
|
81
134
|
catch {
|
|
82
|
-
|
|
135
|
+
// Not a single object → fall through to the JSONL scan.
|
|
83
136
|
}
|
|
84
|
-
|
|
85
|
-
|
|
137
|
+
// stream-json: the terminal result is the LAST line with `"type":"result"`.
|
|
138
|
+
const lines = trimmed.split(/\r?\n/);
|
|
139
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
140
|
+
const line = lines[i].trim();
|
|
141
|
+
if (line === '')
|
|
142
|
+
continue;
|
|
143
|
+
try {
|
|
144
|
+
const obj = JSON.parse(line);
|
|
145
|
+
if (obj !== null && typeof obj === 'object' && obj.type === 'result')
|
|
146
|
+
return line;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// skip a partial/non-JSON line
|
|
150
|
+
}
|
|
86
151
|
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
output: obj.output,
|
|
90
|
-
artifacts: obj.artifacts,
|
|
91
|
-
nextSteps: Array.isArray(obj.nextSteps) ? obj.nextSteps : [],
|
|
92
|
-
needsHuman: Boolean(obj.needsHuman),
|
|
93
|
-
lesson: typeof obj.lesson === 'string' ? obj.lesson : undefined,
|
|
94
|
-
};
|
|
152
|
+
throw new Error('claude -p stream contained no result event (transport envelope)');
|
|
95
153
|
}
|
|
96
154
|
// Map each raw nextSteps entry to NewStepSpec. Require role/kind/input; default taskId and
|
|
97
155
|
// modelProfile from the current step so the agent never needs to know IDs. Throw a lesson-bearing
|
|
@@ -99,17 +157,17 @@ export function extractAgentResult(text) {
|
|
|
99
157
|
export function normalizeNextSteps(raw, step) {
|
|
100
158
|
return raw.map((entry, i) => {
|
|
101
159
|
if (entry === null || typeof entry !== 'object') {
|
|
102
|
-
throw new Error(`
|
|
160
|
+
throw new Error(`agent result nextSteps[${i}] is not an object`);
|
|
103
161
|
}
|
|
104
162
|
const e = entry;
|
|
105
163
|
if (typeof e.role !== 'string' || e.role.length === 0) {
|
|
106
|
-
throw new Error(`
|
|
164
|
+
throw new Error(`agent result nextSteps[${i}] missing required "role"`);
|
|
107
165
|
}
|
|
108
166
|
if (typeof e.kind !== 'string' || e.kind.length === 0) {
|
|
109
|
-
throw new Error(`
|
|
167
|
+
throw new Error(`agent result nextSteps[${i}] missing required "kind"`);
|
|
110
168
|
}
|
|
111
169
|
if (!('input' in e)) {
|
|
112
|
-
throw new Error(`
|
|
170
|
+
throw new Error(`agent result nextSteps[${i}] missing required "input"`);
|
|
113
171
|
}
|
|
114
172
|
const spec = {
|
|
115
173
|
taskId: typeof e.taskId === 'string' && e.taskId.length > 0 ? e.taskId : step.taskId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-envelope.js","sourceRoot":"","sources":["../../src/worker/result-envelope.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"result-envelope.js","sourceRoot":"","sources":["../../src/worker/result-envelope.ts"],"names":[],"mappings":"AAGA,+FAA+F;AAC/F,mGAAmG;AACnG,6FAA6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,IAAI,EAAE,QAAQ;I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