@sema-agent/server 1.185.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/LICENSE +102 -0
- package/README.md +207 -0
- package/deploy/sema-up/README.md +145 -0
- package/deploy/sema-up/chart/Chart.yaml +11 -0
- package/deploy/sema-up/chart/templates/gitea.yaml +63 -0
- package/deploy/sema-up/chart/templates/minio.yaml +62 -0
- package/deploy/sema-up/chart/templates/namespace-sandbox.yaml +9 -0
- package/deploy/sema-up/chart/templates/pg-cluster.yaml +57 -0
- package/deploy/sema-up/chart/templates/registry.yaml +88 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +45 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +76 -0
- package/deploy/sema-up/chart/templates/server.yaml +88 -0
- package/deploy/sema-up/chart/values-full-single.yaml +9 -0
- package/deploy/sema-up/chart/values.yaml +100 -0
- package/deploy/sema-up/cluster-up.sh +432 -0
- package/deploy/sema-up/kube-up.sh +377 -0
- package/deploy/sema-up/lib/parse-machines.py +117 -0
- package/deploy/sema-up/machines.example.yaml +53 -0
- package/deploy/sema-up/preflight.sh +168 -0
- package/deploy/sema-up/sema-up.sh +758 -0
- package/deploy/sema-up/smoke.sh +100 -0
- package/deploy/sema-up/stack/compose.dataroot.yaml +16 -0
- package/deploy/sema-up/stack/compose.yaml +155 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +189 -0
- package/dist/approval.d.ts +27 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +127 -0
- package/dist/approval.js.map +1 -0
- package/dist/audit.d.ts +29 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +95 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth-bridge.d.ts +29 -0
- package/dist/auth-bridge.d.ts.map +1 -0
- package/dist/auth-bridge.js +145 -0
- package/dist/auth-bridge.js.map +1 -0
- package/dist/bake-runner/main.d.ts +20 -0
- package/dist/bake-runner/main.d.ts.map +1 -0
- package/dist/bake-runner/main.js +216 -0
- package/dist/bake-runner/main.js.map +1 -0
- package/dist/bake-runner/protocol.d.ts +49 -0
- package/dist/bake-runner/protocol.d.ts.map +1 -0
- package/dist/bake-runner/protocol.js +86 -0
- package/dist/bake-runner/protocol.js.map +1 -0
- package/dist/bake-runner/runner.d.ts +86 -0
- package/dist/bake-runner/runner.d.ts.map +1 -0
- package/dist/bake-runner/runner.js +228 -0
- package/dist/bake-runner/runner.js.map +1 -0
- package/dist/bench/l8/artifact.d.ts +62 -0
- package/dist/bench/l8/artifact.d.ts.map +1 -0
- package/dist/bench/l8/artifact.js +129 -0
- package/dist/bench/l8/artifact.js.map +1 -0
- package/dist/bench/l8/escape.d.ts +18 -0
- package/dist/bench/l8/escape.d.ts.map +1 -0
- package/dist/bench/l8/escape.js +9 -0
- package/dist/bench/l8/escape.js.map +1 -0
- package/dist/bench/l8/index.d.ts +5 -0
- package/dist/bench/l8/index.d.ts.map +1 -0
- package/dist/bench/l8/index.js +5 -0
- package/dist/bench/l8/index.js.map +1 -0
- package/dist/bench/l8/probes.d.ts +75 -0
- package/dist/bench/l8/probes.d.ts.map +1 -0
- package/dist/bench/l8/probes.js +178 -0
- package/dist/bench/l8/probes.js.map +1 -0
- package/dist/bench/l8/run-probes.d.ts +21 -0
- package/dist/bench/l8/run-probes.d.ts.map +1 -0
- package/dist/bench/l8/run-probes.js +130 -0
- package/dist/bench/l8/run-probes.js.map +1 -0
- package/dist/bench/s1/arms.d.ts +84 -0
- package/dist/bench/s1/arms.d.ts.map +1 -0
- package/dist/bench/s1/arms.js +329 -0
- package/dist/bench/s1/arms.js.map +1 -0
- package/dist/bench/s1/live-deps.d.ts +25 -0
- package/dist/bench/s1/live-deps.d.ts.map +1 -0
- package/dist/bench/s1/live-deps.js +449 -0
- package/dist/bench/s1/live-deps.js.map +1 -0
- package/dist/bench/s1/oracle.d.ts +34 -0
- package/dist/bench/s1/oracle.d.ts.map +1 -0
- package/dist/bench/s1/oracle.js +29 -0
- package/dist/bench/s1/oracle.js.map +1 -0
- package/dist/bench/s1/repair-oracle-adapter.d.ts +9 -0
- package/dist/bench/s1/repair-oracle-adapter.d.ts.map +1 -0
- package/dist/bench/s1/repair-oracle-adapter.js +27 -0
- package/dist/bench/s1/repair-oracle-adapter.js.map +1 -0
- package/dist/bench/s1/reviewer.d.ts +31 -0
- package/dist/bench/s1/reviewer.d.ts.map +1 -0
- package/dist/bench/s1/reviewer.js +26 -0
- package/dist/bench/s1/reviewer.js.map +1 -0
- package/dist/bench/s1/row.d.ts +29 -0
- package/dist/bench/s1/row.d.ts.map +1 -0
- package/dist/bench/s1/row.js +55 -0
- package/dist/bench/s1/row.js.map +1 -0
- package/dist/bench/s1/run-firm.d.ts +49 -0
- package/dist/bench/s1/run-firm.d.ts.map +1 -0
- package/dist/bench/s1/run-firm.js +291 -0
- package/dist/bench/s1/run-firm.js.map +1 -0
- package/dist/bench/s1/runner-ctx.d.ts +44 -0
- package/dist/bench/s1/runner-ctx.d.ts.map +1 -0
- package/dist/bench/s1/runner-ctx.js +59 -0
- package/dist/bench/s1/runner-ctx.js.map +1 -0
- package/dist/bench/s1/tasks.d.ts +48 -0
- package/dist/bench/s1/tasks.d.ts.map +1 -0
- package/dist/bench/s1/tasks.js +194 -0
- package/dist/bench/s1/tasks.js.map +1 -0
- package/dist/boot-reclaim.d.ts +10 -0
- package/dist/boot-reclaim.d.ts.map +1 -0
- package/dist/boot-reclaim.js +13 -0
- package/dist/boot-reclaim.js.map +1 -0
- package/dist/brain.d.ts +8 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +83 -0
- package/dist/brain.js.map +1 -0
- package/dist/budget.d.ts +25 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +107 -0
- package/dist/budget.js.map +1 -0
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.d.ts.map +1 -0
- package/dist/capabilities/builtin-tools.js +11 -0
- package/dist/capabilities/builtin-tools.js.map +1 -0
- package/dist/capabilities/code-review-council.d.ts +21 -0
- package/dist/capabilities/code-review-council.d.ts.map +1 -0
- package/dist/capabilities/code-review-council.js +113 -0
- package/dist/capabilities/code-review-council.js.map +1 -0
- package/dist/capabilities/collab-wire.d.ts +34 -0
- package/dist/capabilities/collab-wire.d.ts.map +1 -0
- package/dist/capabilities/collab-wire.js +2 -0
- package/dist/capabilities/collab-wire.js.map +1 -0
- package/dist/capabilities/collab-workflows.d.ts +40 -0
- package/dist/capabilities/collab-workflows.d.ts.map +1 -0
- package/dist/capabilities/collab-workflows.js +90 -0
- package/dist/capabilities/collab-workflows.js.map +1 -0
- package/dist/capabilities/oa-tools.d.ts +9 -0
- package/dist/capabilities/oa-tools.d.ts.map +1 -0
- package/dist/capabilities/oa-tools.js +44 -0
- package/dist/capabilities/oa-tools.js.map +1 -0
- package/dist/capabilities/prompt.d.ts +3 -0
- package/dist/capabilities/prompt.d.ts.map +1 -0
- package/dist/capabilities/prompt.js +6 -0
- package/dist/capabilities/prompt.js.map +1 -0
- package/dist/capabilities/prompts/code-review.d.ts +11 -0
- package/dist/capabilities/prompts/code-review.d.ts.map +1 -0
- package/dist/capabilities/prompts/code-review.js +39 -0
- package/dist/capabilities/prompts/code-review.js.map +1 -0
- package/dist/capabilities/prompts/identity.d.ts +2 -0
- package/dist/capabilities/prompts/identity.d.ts.map +1 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/identity.js.map +1 -0
- package/dist/capabilities/prompts/team.d.ts +6 -0
- package/dist/capabilities/prompts/team.d.ts.map +1 -0
- package/dist/capabilities/prompts/team.js +6 -0
- package/dist/capabilities/prompts/team.js.map +1 -0
- package/dist/capabilities/repo-tools.d.ts +19 -0
- package/dist/capabilities/repo-tools.d.ts.map +1 -0
- package/dist/capabilities/repo-tools.js +98 -0
- package/dist/capabilities/repo-tools.js.map +1 -0
- package/dist/capabilities/scenarios.d.ts +72 -0
- package/dist/capabilities/scenarios.d.ts.map +1 -0
- package/dist/capabilities/scenarios.js +241 -0
- package/dist/capabilities/scenarios.js.map +1 -0
- package/dist/capabilities/select-environment-tool.d.ts +22 -0
- package/dist/capabilities/select-environment-tool.d.ts.map +1 -0
- package/dist/capabilities/select-environment-tool.js +86 -0
- package/dist/capabilities/select-environment-tool.js.map +1 -0
- package/dist/capabilities/skills.d.ts +12 -0
- package/dist/capabilities/skills.d.ts.map +1 -0
- package/dist/capabilities/skills.js +50 -0
- package/dist/capabilities/skills.js.map +1 -0
- package/dist/capabilities/team.d.ts +31 -0
- package/dist/capabilities/team.d.ts.map +1 -0
- package/dist/capabilities/team.js +66 -0
- package/dist/capabilities/team.js.map +1 -0
- package/dist/config-provider.d.ts +47 -0
- package/dist/config-provider.d.ts.map +1 -0
- package/dist/config-provider.js +156 -0
- package/dist/config-provider.js.map +1 -0
- package/dist/config.d.ts +272 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +605 -0
- package/dist/config.js.map +1 -0
- package/dist/degenerate-instrument.d.ts +17 -0
- package/dist/degenerate-instrument.d.ts.map +1 -0
- package/dist/degenerate-instrument.js +113 -0
- package/dist/degenerate-instrument.js.map +1 -0
- package/dist/elicitation.d.ts +47 -0
- package/dist/elicitation.d.ts.map +1 -0
- package/dist/elicitation.js +151 -0
- package/dist/elicitation.js.map +1 -0
- package/dist/env-facts.d.ts +18 -0
- package/dist/env-facts.d.ts.map +1 -0
- package/dist/env-facts.js +26 -0
- package/dist/env-facts.js.map +1 -0
- package/dist/finance/cost-taxonomy.d.ts +34 -0
- package/dist/finance/cost-taxonomy.d.ts.map +1 -0
- package/dist/finance/cost-taxonomy.js +26 -0
- package/dist/finance/cost-taxonomy.js.map +1 -0
- package/dist/fleet/fleet-bus.d.ts +137 -0
- package/dist/fleet/fleet-bus.d.ts.map +1 -0
- package/dist/fleet/fleet-bus.js +249 -0
- package/dist/fleet/fleet-bus.js.map +1 -0
- package/dist/fleet-client.d.ts +50 -0
- package/dist/fleet-client.d.ts.map +1 -0
- package/dist/fleet-client.js +150 -0
- package/dist/fleet-client.js.map +1 -0
- package/dist/fleet-lease.d.ts +76 -0
- package/dist/fleet-lease.d.ts.map +1 -0
- package/dist/fleet-lease.js +124 -0
- package/dist/fleet-lease.js.map +1 -0
- package/dist/hooks/hook-runner.d.ts +41 -0
- package/dist/hooks/hook-runner.d.ts.map +1 -0
- package/dist/hooks/hook-runner.js +975 -0
- package/dist/hooks/hook-runner.js.map +1 -0
- package/dist/http/idempotency.d.ts +12 -0
- package/dist/http/idempotency.d.ts.map +1 -0
- package/dist/http/idempotency.js +49 -0
- package/dist/http/idempotency.js.map +1 -0
- package/dist/http/server.d.ts +185 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +4845 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/wire-gate.d.ts +3 -0
- package/dist/http/wire-gate.d.ts.map +1 -0
- package/dist/http/wire-gate.js +6 -0
- package/dist/http/wire-gate.js.map +1 -0
- package/dist/images/bake-validate.d.ts +41 -0
- package/dist/images/bake-validate.d.ts.map +1 -0
- package/dist/images/bake-validate.js +183 -0
- package/dist/images/bake-validate.js.map +1 -0
- package/dist/images/manifest.d.ts +36 -0
- package/dist/images/manifest.d.ts.map +1 -0
- package/dist/images/manifest.js +69 -0
- package/dist/images/manifest.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/key-resolver.d.ts +5 -0
- package/dist/key-resolver.d.ts.map +1 -0
- package/dist/key-resolver.js +15 -0
- package/dist/key-resolver.js.map +1 -0
- package/dist/leader/diffout.d.ts +24 -0
- package/dist/leader/diffout.d.ts.map +1 -0
- package/dist/leader/diffout.js +54 -0
- package/dist/leader/diffout.js.map +1 -0
- package/dist/leader/diffup.d.ts +14 -0
- package/dist/leader/diffup.d.ts.map +1 -0
- package/dist/leader/diffup.js +81 -0
- package/dist/leader/diffup.js.map +1 -0
- package/dist/leader/endpoint.d.ts +30 -0
- package/dist/leader/endpoint.d.ts.map +1 -0
- package/dist/leader/endpoint.js +76 -0
- package/dist/leader/endpoint.js.map +1 -0
- package/dist/leader/fanout.d.ts +46 -0
- package/dist/leader/fanout.d.ts.map +1 -0
- package/dist/leader/fanout.js +109 -0
- package/dist/leader/fanout.js.map +1 -0
- package/dist/leader/grader-env-factory.d.ts +36 -0
- package/dist/leader/grader-env-factory.d.ts.map +1 -0
- package/dist/leader/grader-env-factory.js +73 -0
- package/dist/leader/grader-env-factory.js.map +1 -0
- package/dist/leader/leader.d.ts +102 -0
- package/dist/leader/leader.d.ts.map +1 -0
- package/dist/leader/leader.js +354 -0
- package/dist/leader/leader.js.map +1 -0
- package/dist/leader/merge.d.ts +109 -0
- package/dist/leader/merge.d.ts.map +1 -0
- package/dist/leader/merge.js +184 -0
- package/dist/leader/merge.js.map +1 -0
- package/dist/leader/planner.d.ts +26 -0
- package/dist/leader/planner.d.ts.map +1 -0
- package/dist/leader/planner.js +137 -0
- package/dist/leader/planner.js.map +1 -0
- package/dist/leader/repair-oracle.d.ts +34 -0
- package/dist/leader/repair-oracle.d.ts.map +1 -0
- package/dist/leader/repair-oracle.js +83 -0
- package/dist/leader/repair-oracle.js.map +1 -0
- package/dist/leader/repair-wire.d.ts +49 -0
- package/dist/leader/repair-wire.d.ts.map +1 -0
- package/dist/leader/repair-wire.js +90 -0
- package/dist/leader/repair-wire.js.map +1 -0
- package/dist/leader/wire.d.ts +66 -0
- package/dist/leader/wire.d.ts.map +1 -0
- package/dist/leader/wire.js +452 -0
- package/dist/leader/wire.js.map +1 -0
- package/dist/lsp/e2b-bridge.d.ts +8 -0
- package/dist/lsp/e2b-bridge.d.ts.map +1 -0
- package/dist/lsp/e2b-bridge.js +71 -0
- package/dist/lsp/e2b-bridge.js.map +1 -0
- package/dist/lsp/e2b-manager.d.ts +16 -0
- package/dist/lsp/e2b-manager.d.ts.map +1 -0
- package/dist/lsp/e2b-manager.js +49 -0
- package/dist/lsp/e2b-manager.js.map +1 -0
- package/dist/lsp/lsp-frames.d.ts +2 -0
- package/dist/lsp/lsp-frames.d.ts.map +1 -0
- package/dist/lsp/lsp-frames.js +25 -0
- package/dist/lsp/lsp-frames.js.map +1 -0
- package/dist/lsp/manager.d.ts +41 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +84 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/types.d.ts +2 -0
- package/dist/lsp/types.d.ts.map +1 -0
- package/dist/lsp/types.js +2 -0
- package/dist/lsp/types.js.map +1 -0
- package/dist/lsp/ws-transport.d.ts +28 -0
- package/dist/lsp/ws-transport.d.ts.map +1 -0
- package/dist/lsp/ws-transport.js +209 -0
- package/dist/lsp/ws-transport.js.map +1 -0
- package/dist/lsp-evict.d.ts +2 -0
- package/dist/lsp-evict.d.ts.map +1 -0
- package/dist/lsp-evict.js +14 -0
- package/dist/lsp-evict.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1526 -0
- package/dist/main.js.map +1 -0
- package/dist/memory-export.d.ts +3 -0
- package/dist/memory-export.d.ts.map +1 -0
- package/dist/memory-export.js +8 -0
- package/dist/memory-export.js.map +1 -0
- package/dist/memory-sync-client.d.ts +29 -0
- package/dist/memory-sync-client.d.ts.map +1 -0
- package/dist/memory-sync-client.js +133 -0
- package/dist/memory-sync-client.js.map +1 -0
- package/dist/memory-sync.d.ts +41 -0
- package/dist/memory-sync.d.ts.map +1 -0
- package/dist/memory-sync.js +183 -0
- package/dist/memory-sync.js.map +1 -0
- package/dist/model-select.d.ts +8 -0
- package/dist/model-select.d.ts.map +1 -0
- package/dist/model-select.js +12 -0
- package/dist/model-select.js.map +1 -0
- package/dist/observability/cost-quota.d.ts +21 -0
- package/dist/observability/cost-quota.d.ts.map +1 -0
- package/dist/observability/cost-quota.js +42 -0
- package/dist/observability/cost-quota.js.map +1 -0
- package/dist/observability/logger.d.ts +9 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +35 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +76 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +263 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/observability/otel-exporter.d.ts +37 -0
- package/dist/observability/otel-exporter.d.ts.map +1 -0
- package/dist/observability/otel-exporter.js +95 -0
- package/dist/observability/otel-exporter.js.map +1 -0
- package/dist/observability/principal-context.d.ts +5 -0
- package/dist/observability/principal-context.d.ts.map +1 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/principal-context.js.map +1 -0
- package/dist/observability/rate-limit.d.ts +18 -0
- package/dist/observability/rate-limit.d.ts.map +1 -0
- package/dist/observability/rate-limit.js +30 -0
- package/dist/observability/rate-limit.js.map +1 -0
- package/dist/observability/tool-trace.d.ts +6 -0
- package/dist/observability/tool-trace.d.ts.map +1 -0
- package/dist/observability/tool-trace.js +73 -0
- package/dist/observability/tool-trace.js.map +1 -0
- package/dist/orchestration/hardened-vm-runner.d.ts +26 -0
- package/dist/orchestration/hardened-vm-runner.d.ts.map +1 -0
- package/dist/orchestration/hardened-vm-runner.js +217 -0
- package/dist/orchestration/hardened-vm-runner.js.map +1 -0
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +4 -0
- package/dist/orchestration/hardened-vm-worker-runner.d.ts.map +1 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +79 -0
- package/dist/orchestration/hardened-vm-worker-runner.js.map +1 -0
- package/dist/orchestration/hardened-vm-worker.d.ts +2 -0
- package/dist/orchestration/hardened-vm-worker.d.ts.map +1 -0
- package/dist/orchestration/hardened-vm-worker.js +80 -0
- package/dist/orchestration/hardened-vm-worker.js.map +1 -0
- package/dist/orchestration/subagent-steer.d.ts +12 -0
- package/dist/orchestration/subagent-steer.d.ts.map +1 -0
- package/dist/orchestration/subagent-steer.js +45 -0
- package/dist/orchestration/subagent-steer.js.map +1 -0
- package/dist/orchestration/workflow-agent-steer.d.ts +14 -0
- package/dist/orchestration/workflow-agent-steer.d.ts.map +1 -0
- package/dist/orchestration/workflow-agent-steer.js +41 -0
- package/dist/orchestration/workflow-agent-steer.js.map +1 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +101 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts.map +1 -0
- package/dist/orchestration/workflow-completion-inbox.js +327 -0
- package/dist/orchestration/workflow-completion-inbox.js.map +1 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +120 -0
- package/dist/orchestration/workflow-notify-journal.d.ts.map +1 -0
- package/dist/orchestration/workflow-notify-journal.js +297 -0
- package/dist/orchestration/workflow-notify-journal.js.map +1 -0
- package/dist/per-task-image.d.ts +27 -0
- package/dist/per-task-image.d.ts.map +1 -0
- package/dist/per-task-image.js +37 -0
- package/dist/per-task-image.js.map +1 -0
- package/dist/plan-cache-probe.d.ts +21 -0
- package/dist/plan-cache-probe.d.ts.map +1 -0
- package/dist/plan-cache-probe.js +79 -0
- package/dist/plan-cache-probe.js.map +1 -0
- package/dist/plugins/approval-exemption-store.d.ts +56 -0
- package/dist/plugins/approval-exemption-store.d.ts.map +1 -0
- package/dist/plugins/approval-exemption-store.js +216 -0
- package/dist/plugins/approval-exemption-store.js.map +1 -0
- package/dist/plugins/background-shell-support.d.ts +64 -0
- package/dist/plugins/background-shell-support.d.ts.map +1 -0
- package/dist/plugins/background-shell-support.js +235 -0
- package/dist/plugins/background-shell-support.js.map +1 -0
- package/dist/plugins/blob-backend.d.ts +44 -0
- package/dist/plugins/blob-backend.d.ts.map +1 -0
- package/dist/plugins/blob-backend.js +188 -0
- package/dist/plugins/blob-backend.js.map +1 -0
- package/dist/plugins/caching-session-store.d.ts +51 -0
- package/dist/plugins/caching-session-store.d.ts.map +1 -0
- package/dist/plugins/caching-session-store.js +142 -0
- package/dist/plugins/caching-session-store.js.map +1 -0
- package/dist/plugins/file-outcome-sink.d.ts +20 -0
- package/dist/plugins/file-outcome-sink.d.ts.map +1 -0
- package/dist/plugins/file-outcome-sink.js +14 -0
- package/dist/plugins/file-outcome-sink.js.map +1 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +19 -0
- package/dist/plugins/file-resume-anchor-store.d.ts.map +1 -0
- package/dist/plugins/file-resume-anchor-store.js +103 -0
- package/dist/plugins/file-resume-anchor-store.js.map +1 -0
- package/dist/plugins/file-run-store.d.ts +95 -0
- package/dist/plugins/file-run-store.d.ts.map +1 -0
- package/dist/plugins/file-run-store.js +446 -0
- package/dist/plugins/file-run-store.js.map +1 -0
- package/dist/plugins/file-workflow-journal-store.d.ts +2 -0
- package/dist/plugins/file-workflow-journal-store.d.ts.map +1 -0
- package/dist/plugins/file-workflow-journal-store.js +2 -0
- package/dist/plugins/file-workflow-journal-store.js.map +1 -0
- package/dist/plugins/host-platform.d.ts +19 -0
- package/dist/plugins/host-platform.d.ts.map +1 -0
- package/dist/plugins/host-platform.js +71 -0
- package/dist/plugins/host-platform.js.map +1 -0
- package/dist/plugins/local-checkpoint-store.d.ts +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts.map +1 -0
- package/dist/plugins/local-checkpoint-store.js +217 -0
- package/dist/plugins/local-checkpoint-store.js.map +1 -0
- package/dist/plugins/local-session-store.d.ts +69 -0
- package/dist/plugins/local-session-store.d.ts.map +1 -0
- package/dist/plugins/local-session-store.js +431 -0
- package/dist/plugins/local-session-store.js.map +1 -0
- package/dist/plugins/memory-engine-pg.d.ts +47 -0
- package/dist/plugins/memory-engine-pg.d.ts.map +1 -0
- package/dist/plugins/memory-engine-pg.js +306 -0
- package/dist/plugins/memory-engine-pg.js.map +1 -0
- package/dist/plugins/memory-engine-tidb.d.ts +40 -0
- package/dist/plugins/memory-engine-tidb.d.ts.map +1 -0
- package/dist/plugins/memory-engine-tidb.js +296 -0
- package/dist/plugins/memory-engine-tidb.js.map +1 -0
- package/dist/plugins/memory-engine-vector-util.d.ts +2 -0
- package/dist/plugins/memory-engine-vector-util.d.ts.map +1 -0
- package/dist/plugins/memory-engine-vector-util.js +2 -0
- package/dist/plugins/memory-engine-vector-util.js.map +1 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +12 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts.map +1 -0
- package/dist/plugins/memory-resume-anchor-store.js +31 -0
- package/dist/plugins/memory-resume-anchor-store.js.map +1 -0
- package/dist/plugins/memory-run-store.d.ts +75 -0
- package/dist/plugins/memory-run-store.d.ts.map +1 -0
- package/dist/plugins/memory-run-store.js +267 -0
- package/dist/plugins/memory-run-store.js.map +1 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +78 -0
- package/dist/plugins/memory-sync-store-pg.d.ts.map +1 -0
- package/dist/plugins/memory-sync-store-pg.js +152 -0
- package/dist/plugins/memory-sync-store-pg.js.map +1 -0
- package/dist/plugins/memory-sync-store-tidb.d.ts +32 -0
- package/dist/plugins/memory-sync-store-tidb.d.ts.map +1 -0
- package/dist/plugins/memory-sync-store-tidb.js +146 -0
- package/dist/plugins/memory-sync-store-tidb.js.map +1 -0
- package/dist/plugins/pg-approval-store.d.ts +28 -0
- package/dist/plugins/pg-approval-store.d.ts.map +1 -0
- package/dist/plugins/pg-approval-store.js +107 -0
- package/dist/plugins/pg-approval-store.js.map +1 -0
- package/dist/plugins/pg-breaker-state.d.ts +20 -0
- package/dist/plugins/pg-breaker-state.d.ts.map +1 -0
- package/dist/plugins/pg-breaker-state.js +89 -0
- package/dist/plugins/pg-breaker-state.js.map +1 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +34 -0
- package/dist/plugins/pg-checkpoint-store.d.ts.map +1 -0
- package/dist/plugins/pg-checkpoint-store.js +193 -0
- package/dist/plugins/pg-checkpoint-store.js.map +1 -0
- package/dist/plugins/pg-cost-quota.d.ts +18 -0
- package/dist/plugins/pg-cost-quota.d.ts.map +1 -0
- package/dist/plugins/pg-cost-quota.js +189 -0
- package/dist/plugins/pg-cost-quota.js.map +1 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +26 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts.map +1 -0
- package/dist/plugins/pg-file-snapshot-store.js +181 -0
- package/dist/plugins/pg-file-snapshot-store.js.map +1 -0
- package/dist/plugins/pg-image-bake.d.ts +42 -0
- package/dist/plugins/pg-image-bake.d.ts.map +1 -0
- package/dist/plugins/pg-image-bake.js +471 -0
- package/dist/plugins/pg-image-bake.js.map +1 -0
- package/dist/plugins/pg-image-index.d.ts +23 -0
- package/dist/plugins/pg-image-index.d.ts.map +1 -0
- package/dist/plugins/pg-image-index.js +252 -0
- package/dist/plugins/pg-image-index.js.map +1 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +23 -0
- package/dist/plugins/pg-outcome-ledger.d.ts.map +1 -0
- package/dist/plugins/pg-outcome-ledger.js +102 -0
- package/dist/plugins/pg-outcome-ledger.js.map +1 -0
- package/dist/plugins/pg-pool.d.ts +7 -0
- package/dist/plugins/pg-pool.d.ts.map +1 -0
- package/dist/plugins/pg-pool.js +233 -0
- package/dist/plugins/pg-pool.js.map +1 -0
- package/dist/plugins/pg-rate-limiter.d.ts +49 -0
- package/dist/plugins/pg-rate-limiter.d.ts.map +1 -0
- package/dist/plugins/pg-rate-limiter.js +193 -0
- package/dist/plugins/pg-rate-limiter.js.map +1 -0
- package/dist/plugins/pg-resume-anchor-store.d.ts +14 -0
- package/dist/plugins/pg-resume-anchor-store.d.ts.map +1 -0
- package/dist/plugins/pg-resume-anchor-store.js +23 -0
- package/dist/plugins/pg-resume-anchor-store.js.map +1 -0
- package/dist/plugins/pg-run-store.d.ts +76 -0
- package/dist/plugins/pg-run-store.d.ts.map +1 -0
- package/dist/plugins/pg-run-store.js +301 -0
- package/dist/plugins/pg-run-store.js.map +1 -0
- package/dist/plugins/pg-session-policy-store.d.ts +12 -0
- package/dist/plugins/pg-session-policy-store.d.ts.map +1 -0
- package/dist/plugins/pg-session-policy-store.js +88 -0
- package/dist/plugins/pg-session-policy-store.js.map +1 -0
- package/dist/plugins/pg-session-storage.d.ts +59 -0
- package/dist/plugins/pg-session-storage.d.ts.map +1 -0
- package/dist/plugins/pg-session-storage.js +484 -0
- package/dist/plugins/pg-session-storage.js.map +1 -0
- package/dist/plugins/pg-session-store.d.ts +2 -0
- package/dist/plugins/pg-session-store.d.ts.map +1 -0
- package/dist/plugins/pg-session-store.js +2 -0
- package/dist/plugins/pg-session-store.js.map +1 -0
- package/dist/plugins/pg-tool-result-store.d.ts +16 -0
- package/dist/plugins/pg-tool-result-store.d.ts.map +1 -0
- package/dist/plugins/pg-tool-result-store.js +52 -0
- package/dist/plugins/pg-tool-result-store.js.map +1 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +11 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts.map +1 -0
- package/dist/plugins/pg-workflow-journal-store.js +28 -0
- package/dist/plugins/pg-workflow-journal-store.js.map +1 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +55 -0
- package/dist/plugins/pg-workflow-run-store.d.ts.map +1 -0
- package/dist/plugins/pg-workflow-run-store.js +216 -0
- package/dist/plugins/pg-workflow-run-store.js.map +1 -0
- package/dist/plugins/remote-env-adb.d.ts +119 -0
- package/dist/plugins/remote-env-adb.d.ts.map +1 -0
- package/dist/plugins/remote-env-adb.js +502 -0
- package/dist/plugins/remote-env-adb.js.map +1 -0
- package/dist/plugins/remote-env-e2b.d.ts +162 -0
- package/dist/plugins/remote-env-e2b.d.ts.map +1 -0
- package/dist/plugins/remote-env-e2b.js +931 -0
- package/dist/plugins/remote-env-e2b.js.map +1 -0
- package/dist/plugins/remote-env-host.d.ts +141 -0
- package/dist/plugins/remote-env-host.d.ts.map +1 -0
- package/dist/plugins/remote-env-host.js +868 -0
- package/dist/plugins/remote-env-host.js.map +1 -0
- package/dist/plugins/remote-env-k8s.d.ts +209 -0
- package/dist/plugins/remote-env-k8s.d.ts.map +1 -0
- package/dist/plugins/remote-env-k8s.js +1206 -0
- package/dist/plugins/remote-env-k8s.js.map +1 -0
- package/dist/plugins/remote-env-local-docker.d.ts +124 -0
- package/dist/plugins/remote-env-local-docker.d.ts.map +1 -0
- package/dist/plugins/remote-env-local-docker.js +597 -0
- package/dist/plugins/remote-env-local-docker.js.map +1 -0
- package/dist/plugins/remote-env-ssh.d.ts +122 -0
- package/dist/plugins/remote-env-ssh.d.ts.map +1 -0
- package/dist/plugins/remote-env-ssh.js +511 -0
- package/dist/plugins/remote-env-ssh.js.map +1 -0
- package/dist/plugins/remote-shell.d.ts +7 -0
- package/dist/plugins/remote-shell.d.ts.map +1 -0
- package/dist/plugins/remote-shell.js +25 -0
- package/dist/plugins/remote-shell.js.map +1 -0
- package/dist/plugins/s3-presign.d.ts +13 -0
- package/dist/plugins/s3-presign.d.ts.map +1 -0
- package/dist/plugins/s3-presign.js +55 -0
- package/dist/plugins/s3-presign.js.map +1 -0
- package/dist/plugins/scheduler-support.d.ts +39 -0
- package/dist/plugins/scheduler-support.d.ts.map +1 -0
- package/dist/plugins/scheduler-support.js +141 -0
- package/dist/plugins/scheduler-support.js.map +1 -0
- package/dist/plugins/session-store.d.ts +7 -0
- package/dist/plugins/session-store.d.ts.map +1 -0
- package/dist/plugins/session-store.js +14 -0
- package/dist/plugins/session-store.js.map +1 -0
- package/dist/plugins/store-backend.d.ts +88 -0
- package/dist/plugins/store-backend.d.ts.map +1 -0
- package/dist/plugins/store-backend.js +197 -0
- package/dist/plugins/store-backend.js.map +1 -0
- package/dist/plugins/tidb-approval-store.d.ts +39 -0
- package/dist/plugins/tidb-approval-store.d.ts.map +1 -0
- package/dist/plugins/tidb-approval-store.js +81 -0
- package/dist/plugins/tidb-approval-store.js.map +1 -0
- package/dist/plugins/tidb-breaker-state.d.ts +18 -0
- package/dist/plugins/tidb-breaker-state.d.ts.map +1 -0
- package/dist/plugins/tidb-breaker-state.js +75 -0
- package/dist/plugins/tidb-breaker-state.js.map +1 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +50 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts.map +1 -0
- package/dist/plugins/tidb-checkpoint-store.js +196 -0
- package/dist/plugins/tidb-checkpoint-store.js.map +1 -0
- package/dist/plugins/tidb-cost-quota.d.ts +16 -0
- package/dist/plugins/tidb-cost-quota.d.ts.map +1 -0
- package/dist/plugins/tidb-cost-quota.js +34 -0
- package/dist/plugins/tidb-cost-quota.js.map +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +26 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts.map +1 -0
- package/dist/plugins/tidb-file-snapshot-store.js +183 -0
- package/dist/plugins/tidb-file-snapshot-store.js.map +1 -0
- package/dist/plugins/tidb-image-bake.d.ts +102 -0
- package/dist/plugins/tidb-image-bake.d.ts.map +1 -0
- package/dist/plugins/tidb-image-bake.js +400 -0
- package/dist/plugins/tidb-image-bake.js.map +1 -0
- package/dist/plugins/tidb-image-index.d.ts +71 -0
- package/dist/plugins/tidb-image-index.d.ts.map +1 -0
- package/dist/plugins/tidb-image-index.js +192 -0
- package/dist/plugins/tidb-image-index.js.map +1 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +58 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts.map +1 -0
- package/dist/plugins/tidb-outcome-ledger.js +98 -0
- package/dist/plugins/tidb-outcome-ledger.js.map +1 -0
- package/dist/plugins/tidb-pool.d.ts +11 -0
- package/dist/plugins/tidb-pool.d.ts.map +1 -0
- package/dist/plugins/tidb-pool.js +485 -0
- package/dist/plugins/tidb-pool.js.map +1 -0
- package/dist/plugins/tidb-rate-limiter.d.ts +15 -0
- package/dist/plugins/tidb-rate-limiter.d.ts.map +1 -0
- package/dist/plugins/tidb-rate-limiter.js +34 -0
- package/dist/plugins/tidb-rate-limiter.js.map +1 -0
- package/dist/plugins/tidb-resume-anchor-store.d.ts +14 -0
- package/dist/plugins/tidb-resume-anchor-store.d.ts.map +1 -0
- package/dist/plugins/tidb-resume-anchor-store.js +23 -0
- package/dist/plugins/tidb-resume-anchor-store.js.map +1 -0
- package/dist/plugins/tidb-run-store.d.ts +107 -0
- package/dist/plugins/tidb-run-store.d.ts.map +1 -0
- package/dist/plugins/tidb-run-store.js +321 -0
- package/dist/plugins/tidb-run-store.js.map +1 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +12 -0
- package/dist/plugins/tidb-session-policy-store.d.ts.map +1 -0
- package/dist/plugins/tidb-session-policy-store.js +88 -0
- package/dist/plugins/tidb-session-policy-store.js.map +1 -0
- package/dist/plugins/tidb-session-storage.d.ts +15 -0
- package/dist/plugins/tidb-session-storage.d.ts.map +1 -0
- package/dist/plugins/tidb-session-storage.js +101 -0
- package/dist/plugins/tidb-session-storage.js.map +1 -0
- package/dist/plugins/tidb-session-store.d.ts +46 -0
- package/dist/plugins/tidb-session-store.d.ts.map +1 -0
- package/dist/plugins/tidb-session-store.js +360 -0
- package/dist/plugins/tidb-session-store.js.map +1 -0
- package/dist/plugins/tidb-tool-result-store.d.ts +15 -0
- package/dist/plugins/tidb-tool-result-store.d.ts.map +1 -0
- package/dist/plugins/tidb-tool-result-store.js +41 -0
- package/dist/plugins/tidb-tool-result-store.js.map +1 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +11 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts.map +1 -0
- package/dist/plugins/tidb-workflow-journal-store.js +28 -0
- package/dist/plugins/tidb-workflow-journal-store.js.map +1 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +61 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts.map +1 -0
- package/dist/plugins/tidb-workflow-run-store.js +227 -0
- package/dist/plugins/tidb-workflow-run-store.js.map +1 -0
- package/dist/plugins/web-search.d.ts +27 -0
- package/dist/plugins/web-search.d.ts.map +1 -0
- package/dist/plugins/web-search.js +143 -0
- package/dist/plugins/web-search.js.map +1 -0
- package/dist/plugins/workflow-journal-limits.d.ts +2 -0
- package/dist/plugins/workflow-journal-limits.d.ts.map +1 -0
- package/dist/plugins/workflow-journal-limits.js +2 -0
- package/dist/plugins/workflow-journal-limits.js.map +1 -0
- package/dist/plugins/worktree-isolation.d.ts +16 -0
- package/dist/plugins/worktree-isolation.d.ts.map +1 -0
- package/dist/plugins/worktree-isolation.js +55 -0
- package/dist/plugins/worktree-isolation.js.map +1 -0
- package/dist/plugins/write-behind-counter.d.ts +43 -0
- package/dist/plugins/write-behind-counter.d.ts.map +1 -0
- package/dist/plugins/write-behind-counter.js +144 -0
- package/dist/plugins/write-behind-counter.js.map +1 -0
- package/dist/project-memory.d.ts +14 -0
- package/dist/project-memory.d.ts.map +1 -0
- package/dist/project-memory.js +96 -0
- package/dist/project-memory.js.map +1 -0
- package/dist/question.d.ts +42 -0
- package/dist/question.d.ts.map +1 -0
- package/dist/question.js +140 -0
- package/dist/question.js.map +1 -0
- package/dist/resource-suspend.d.ts +11 -0
- package/dist/resource-suspend.d.ts.map +1 -0
- package/dist/resource-suspend.js +6 -0
- package/dist/resource-suspend.js.map +1 -0
- package/dist/router/route-orchestration.d.ts +31 -0
- package/dist/router/route-orchestration.d.ts.map +1 -0
- package/dist/router/route-orchestration.js +49 -0
- package/dist/router/route-orchestration.js.map +1 -0
- package/dist/run-local.d.ts +26 -0
- package/dist/run-local.d.ts.map +1 -0
- package/dist/run-local.js +337 -0
- package/dist/run-local.js.map +1 -0
- package/dist/runs.d.ts +39 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +392 -0
- package/dist/runs.js.map +1 -0
- package/dist/runtime-caps-resolver.d.ts +32 -0
- package/dist/runtime-caps-resolver.d.ts.map +1 -0
- package/dist/runtime-caps-resolver.js +134 -0
- package/dist/runtime-caps-resolver.js.map +1 -0
- package/dist/runtime-governance.d.ts +18 -0
- package/dist/runtime-governance.d.ts.map +1 -0
- package/dist/runtime-governance.js +103 -0
- package/dist/runtime-governance.js.map +1 -0
- package/dist/sandbox-pkg-source.d.ts +11 -0
- package/dist/sandbox-pkg-source.d.ts.map +1 -0
- package/dist/sandbox-pkg-source.js +56 -0
- package/dist/sandbox-pkg-source.js.map +1 -0
- package/dist/sealed-key.d.ts +29 -0
- package/dist/sealed-key.d.ts.map +1 -0
- package/dist/sealed-key.js +122 -0
- package/dist/sealed-key.js.map +1 -0
- package/dist/security.d.ts +153 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +292 -0
- package/dist/security.js.map +1 -0
- package/dist/sema-registry.d.ts +187 -0
- package/dist/sema-registry.d.ts.map +1 -0
- package/dist/sema-registry.js +456 -0
- package/dist/sema-registry.js.map +1 -0
- package/dist/session-sync.d.ts +96 -0
- package/dist/session-sync.d.ts.map +1 -0
- package/dist/session-sync.js +181 -0
- package/dist/session-sync.js.map +1 -0
- package/dist/session-titler.d.ts +30 -0
- package/dist/session-titler.d.ts.map +1 -0
- package/dist/session-titler.js +77 -0
- package/dist/session-titler.js.map +1 -0
- package/dist/spec-fields.d.ts +5 -0
- package/dist/spec-fields.d.ts.map +1 -0
- package/dist/spec-fields.js +43 -0
- package/dist/spec-fields.js.map +1 -0
- package/dist/task-cwd.d.ts +15 -0
- package/dist/task-cwd.d.ts.map +1 -0
- package/dist/task-cwd.js +33 -0
- package/dist/task-cwd.js.map +1 -0
- package/dist/task-mcp.d.ts +20 -0
- package/dist/task-mcp.d.ts.map +1 -0
- package/dist/task-mcp.js +93 -0
- package/dist/task-mcp.js.map +1 -0
- package/dist/task-settings.d.ts +36 -0
- package/dist/task-settings.d.ts.map +1 -0
- package/dist/task-settings.js +141 -0
- package/dist/task-settings.js.map +1 -0
- package/dist/task-workflow.d.ts +25 -0
- package/dist/task-workflow.d.ts.map +1 -0
- package/dist/task-workflow.js +43 -0
- package/dist/task-workflow.js.map +1 -0
- package/dist/trace/artifacts.d.ts +17 -0
- package/dist/trace/artifacts.d.ts.map +1 -0
- package/dist/trace/artifacts.js +65 -0
- package/dist/trace/artifacts.js.map +1 -0
- package/dist/trace/project.d.ts +170 -0
- package/dist/trace/project.d.ts.map +1 -0
- package/dist/trace/project.js +239 -0
- package/dist/trace/project.js.map +1 -0
- package/dist/trace/redact.d.ts +5 -0
- package/dist/trace/redact.d.ts.map +1 -0
- package/dist/trace/redact.js +83 -0
- package/dist/trace/redact.js.map +1 -0
- package/dist/usage-analytics.d.ts +36 -0
- package/dist/usage-analytics.d.ts.map +1 -0
- package/dist/usage-analytics.js +89 -0
- package/dist/usage-analytics.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { runRepairLoop, delimitUntrusted, } from "@sema-agent/core";
|
|
2
|
+
import { mkRepairOracle } from "./repair-oracle.js";
|
|
3
|
+
function statusForTerminal(t) {
|
|
4
|
+
return t === "fixed" || t === "candidate_only" ? "completed" : "failed";
|
|
5
|
+
}
|
|
6
|
+
export async function runRepairLoopForLeader(solo, implSpec, cfg) {
|
|
7
|
+
try {
|
|
8
|
+
return await runRepairLoopForLeaderInner(solo, implSpec, cfg);
|
|
9
|
+
}
|
|
10
|
+
finally {
|
|
11
|
+
if (cfg.graderDestroy)
|
|
12
|
+
await cfg.graderDestroy().catch(() => { });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
16
|
+
const base = { workerId: solo.workerId, sessionId: solo.sessionId, branch: solo.branch, baseSha: solo.baseSha };
|
|
17
|
+
let graded;
|
|
18
|
+
const oracle = mkRepairOracle({
|
|
19
|
+
pullWorkerDiff: cfg.pullWorkerDiff,
|
|
20
|
+
graderWriteFile: cfg.grader.writeFile,
|
|
21
|
+
graderRepoDir: cfg.grader.repoDir,
|
|
22
|
+
integBase: cfg.grader.integBase,
|
|
23
|
+
oracleSteps: cfg.oracleSteps,
|
|
24
|
+
passTier: cfg.passTier,
|
|
25
|
+
...(cfg.oraclePaths ? { oraclePaths: cfg.oraclePaths } : {}),
|
|
26
|
+
onGraded: (info) => { graded = { diff: info.diff, hash: info.hash }; },
|
|
27
|
+
...(cfg.flakyK !== undefined ? { flakyK: cfg.flakyK } : {}),
|
|
28
|
+
...(cfg.l3 ? { l3: cfg.l3 } : {}),
|
|
29
|
+
...(cfg.log ? { log: cfg.log } : {}),
|
|
30
|
+
});
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
result = await runRepairLoop(cfg.runner, implSpec, {
|
|
34
|
+
oracle,
|
|
35
|
+
graderEnv: cfg.grader.env,
|
|
36
|
+
...(cfg.workerEnv ? { workerEnv: cfg.workerEnv } : {}),
|
|
37
|
+
maxAttempts: cfg.maxAttempts,
|
|
38
|
+
...(cfg.resumeBundle ? { resumeBundle: cfg.resumeBundle } : {}),
|
|
39
|
+
...(cfg.costCeilingMicroUsd !== undefined ? { costCeilingMicroUsd: cfg.costCeilingMicroUsd } : {}),
|
|
40
|
+
...(cfg.totalTimeoutMs !== undefined ? { totalTimeoutMs: cfg.totalTimeoutMs } : {}),
|
|
41
|
+
...(cfg.onAttempt
|
|
42
|
+
? { onAttempt: (i) => cfg.onAttempt({ attempt: i.attempt, terminal: i.terminal, oracleTier: i.oracle.tier, passed: i.oracle.passed, flaky: i.oracle.flaky }) }
|
|
43
|
+
: {}),
|
|
44
|
+
onWarn: (e) => cfg.log?.("repair_loop_warn", { warning: e.message }),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
cfg.log?.("repair_loop_threw", { error: e instanceof Error ? e.message : String(e) });
|
|
49
|
+
return { report: { ...base, status: "failed", error: e instanceof Error ? e.message : String(e) }, result: undefined };
|
|
50
|
+
}
|
|
51
|
+
const terminal = result.terminal;
|
|
52
|
+
const report = {
|
|
53
|
+
...base,
|
|
54
|
+
status: statusForTerminal(terminal),
|
|
55
|
+
repairTerminal: terminal,
|
|
56
|
+
...(result.stats ? { stats: result.stats } : {}),
|
|
57
|
+
...(result.errorMessage ? { error: result.errorMessage } : {}),
|
|
58
|
+
};
|
|
59
|
+
let candidatePatch;
|
|
60
|
+
if (terminal !== "oracle.unprotected" && terminal !== "fixed") {
|
|
61
|
+
const g = graded ??
|
|
62
|
+
(await (async () => {
|
|
63
|
+
const d = await cfg.pullWorkerDiff().catch((e) => ({ ok: false, error: e instanceof Error ? e.message : String(e) }));
|
|
64
|
+
return d.ok && d.patch.trim() !== "" ? { diff: d.patch, hash: "" } : undefined;
|
|
65
|
+
})());
|
|
66
|
+
if (g && g.diff.trim() !== "") {
|
|
67
|
+
const reason = result.verification?.findings?.[0] ?? `repair loop terminal: ${terminal}`;
|
|
68
|
+
candidatePatch = {
|
|
69
|
+
patch: delimitUntrusted("CANDIDATE PATCH (untrusted worker code)", g.diff),
|
|
70
|
+
tier: cfg.passTier,
|
|
71
|
+
reason,
|
|
72
|
+
...(g.hash ? { gradedHash: g.hash } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
cfg.log?.("repair_loop_outcome", { terminal, status: report.status, hasCandidate: candidatePatch !== undefined });
|
|
77
|
+
return { report, result, ...(candidatePatch ? { candidatePatch } : {}) };
|
|
78
|
+
}
|
|
79
|
+
export function attachRepairLoopDeps(deps, resolve) {
|
|
80
|
+
if (!resolve)
|
|
81
|
+
return;
|
|
82
|
+
deps.repairLoop = {
|
|
83
|
+
run: async (solo, sub) => {
|
|
84
|
+
const cfg = await resolve(solo, sub);
|
|
85
|
+
const implSpec = { ...sub.spec, sessionId: solo.sessionId };
|
|
86
|
+
return runRepairLoopForLeader(solo, implSpec, cfg);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=repair-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-wire.js","sourceRoot":"","sources":["../../src/leader/repair-wire.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,aAAa,EACb,gBAAgB,GASjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAmB,MAAM,oBAAoB,CAAC;AAmErE,SAAS,iBAAiB,CAAC,CAAiB;IAC1C,OAAO,CAAC,KAAK,OAAO,IAAI,CA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C,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,KAAK,SAAS,EAAE,CAAC,CAAC;IAClH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3E,CAAC;AAaD,MAAM,UAAU,oBAAoB,CAClC,IAAgB,EAChB,OAA4F;IAE5F,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC,UAAU,GAAG;QAChB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;YAIvB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACrC,MAAM,QAAQ,GAAa,EAAE,GAAI,GAAG,CAAC,IAA+C,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAc,CAAC;YAC9H,OAAO,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Brain, type Model, type ModelRoles, type ModelPricing, type TaskSpec, type ExecutionEnvFactory, type RemoteExecutionEnv, type ToolResultStore, type SessionStore } from "@sema-agent/core";
|
|
2
|
+
import type { CheckpointStoreFull } from "../plugins/store-backend.js";
|
|
3
|
+
import { type LeaderResult } from "./leader.js";
|
|
4
|
+
import type { LeaderRequestBody } from "./endpoint.js";
|
|
5
|
+
export interface LeaderWireConfig {
|
|
6
|
+
e2bApiKey?: string;
|
|
7
|
+
envFactory?: ExecutionEnvFactory;
|
|
8
|
+
durable?: {
|
|
9
|
+
checkpointStore: CheckpointStoreFull;
|
|
10
|
+
requireApproval: string[];
|
|
11
|
+
deny?: string[];
|
|
12
|
+
ttlMs?: number;
|
|
13
|
+
autoBudget?: number;
|
|
14
|
+
neverAuto?: string[];
|
|
15
|
+
};
|
|
16
|
+
toolResultStore?: ToolResultStore;
|
|
17
|
+
sessionStore?: SessionStore;
|
|
18
|
+
brain: Brain;
|
|
19
|
+
models: Record<string, Model>;
|
|
20
|
+
roles: ModelRoles;
|
|
21
|
+
pricing: Record<string, ModelPricing>;
|
|
22
|
+
workspace?: string;
|
|
23
|
+
git?: {
|
|
24
|
+
name: string;
|
|
25
|
+
email: string;
|
|
26
|
+
};
|
|
27
|
+
fanoutEnabled?: boolean;
|
|
28
|
+
routerModel?: string;
|
|
29
|
+
repairRounds?: number;
|
|
30
|
+
conflictRounds?: number;
|
|
31
|
+
s3?: {
|
|
32
|
+
endpoint: string;
|
|
33
|
+
bucket: string;
|
|
34
|
+
accessKey: string;
|
|
35
|
+
secretKey: string;
|
|
36
|
+
region?: string;
|
|
37
|
+
keyPrefix?: string;
|
|
38
|
+
};
|
|
39
|
+
logger?: {
|
|
40
|
+
warn?: (m: string, x?: Record<string, unknown>) => void;
|
|
41
|
+
info?: (m: string, x?: Record<string, unknown>) => void;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
type WireEnv = Pick<RemoteExecutionEnv, "exec" | "writeFile">;
|
|
45
|
+
export declare function stageWorkerEnv(env: WireEnv, opts: {
|
|
46
|
+
seedCmd: string;
|
|
47
|
+
repo: string;
|
|
48
|
+
branch: string;
|
|
49
|
+
uploadScriptPath: string;
|
|
50
|
+
uploadScript: string;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
export declare function leaderResourceConfig(env?: NodeJS.ProcessEnv): {
|
|
53
|
+
leaderTimeoutMs: number;
|
|
54
|
+
workerMaxTurns: number;
|
|
55
|
+
workerBudgetUsd: number;
|
|
56
|
+
workerLimits: Partial<TaskSpec>;
|
|
57
|
+
presignTtlSec: number;
|
|
58
|
+
resourceSuspend?: {
|
|
59
|
+
totalBudgetUsd: number;
|
|
60
|
+
sliceMaxCostUsd: number;
|
|
61
|
+
maxSuspends: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare function buildLeaderRunner(cfg: LeaderWireConfig): (body: LeaderRequestBody) => Promise<LeaderResult>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/leader/wire.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAC5H,KAAK,eAAe,EAAE,KAAK,YAAY,EACxC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAIvE,OAAO,EAA4E,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAK1H,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAYvD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IAKjC,OAAO,CAAC,EAAE;QAAE,eAAe,EAAE,mBAAmB,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAK1J,eAAe,CAAC,EAAE,eAA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,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACtG,OAAO,CAAC,IAAI,CAAC,CAoBf;AAUD,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG;IAC1E,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IAMtB,eAAe,CAAC,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5F,CAwBA;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,YAAY,CAAC,CAkhB3G"}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { Runner, combinePolicies, createDurableQuestionPolicy, QUESTION_AWAITS_RESUME, delimitUntrusted, } from "@sema-agent/core";
|
|
6
|
+
import { RemoteContainerExecutionEnv } from "../plugins/remote-env-e2b.js";
|
|
7
|
+
import { createDurableAskPolicy } from "../approval.js";
|
|
8
|
+
import { presignS3Url } from "../plugins/s3-presign.js";
|
|
9
|
+
import { buildUploadScript, uploadStepSuffix, fetchUploadedDiff, withStaging } from "./diffup.js";
|
|
10
|
+
import { pullDiff, safeRev } from "./diffout.js";
|
|
11
|
+
import { runLeaderTask } from "./leader.js";
|
|
12
|
+
import { attachRepairLoopDeps } from "./repair-wire.js";
|
|
13
|
+
import { routePlanWithFallback, validateSubtasks } from "./planner.js";
|
|
14
|
+
const REPAIR_LOOP_WIRED = true;
|
|
15
|
+
const sh = (env) => async (cmd) => {
|
|
16
|
+
const r = await env.exec(`bash -lc ${JSON.stringify(cmd)}`);
|
|
17
|
+
if (!r.ok)
|
|
18
|
+
throw new Error(`exec transport: ${r.error.message}`);
|
|
19
|
+
if (r.value.exitCode !== 0)
|
|
20
|
+
throw new Error(`exit ${r.value.exitCode}: ${r.value.stderr}`);
|
|
21
|
+
return r.value.stdout.trim();
|
|
22
|
+
};
|
|
23
|
+
const asIntegrationEnv = (env) => ({
|
|
24
|
+
exec: async (cmd, opts) => {
|
|
25
|
+
const r = await env.exec(cmd, opts?.cwd ? { cwd: opts.cwd } : undefined);
|
|
26
|
+
return r.ok ? r.value : { exitCode: -1, stdout: "", stderr: r.error.message };
|
|
27
|
+
},
|
|
28
|
+
writeFile: async (p, c) => { const r = await env.writeFile(p, c); if (!r.ok)
|
|
29
|
+
throw r.error; },
|
|
30
|
+
});
|
|
31
|
+
export async function stageWorkerEnv(env, opts) {
|
|
32
|
+
const { seedCmd, repo, branch, uploadScriptPath, uploadScript } = opts;
|
|
33
|
+
const probe = await env.exec(`bash -lc ${JSON.stringify(`if [ -f ${uploadScriptPath} ]; then exit 0; fi; ` +
|
|
34
|
+
`cd ${repo} 2>/dev/null && git rev-parse --verify --quiet refs/heads/${branch} >/dev/null && exit 0; ` +
|
|
35
|
+
`exit 1`)}`);
|
|
36
|
+
if (probe.ok && probe.value.exitCode === 0)
|
|
37
|
+
return;
|
|
38
|
+
await sh(env)(`${seedCmd}; cd ${repo}; git checkout -q -b ${branch}`);
|
|
39
|
+
const wr = await env.writeFile(uploadScriptPath, uploadScript);
|
|
40
|
+
if (!wr.ok)
|
|
41
|
+
throw new Error(`upload-script staging failed: ${wr.error.message}`);
|
|
42
|
+
}
|
|
43
|
+
export function leaderResourceConfig(env = process.env) {
|
|
44
|
+
const leaderTimeoutMs = Math.max(600_000, Math.floor(Number(env.LEADER_TIMEOUT_MS ?? "0")) || 86_400_000);
|
|
45
|
+
const workerMaxTurns = Math.floor(Number(env.LEADER_WORKER_MAX_TURNS ?? "0")) || 10_000;
|
|
46
|
+
const workerBudgetUsd = Number(env.LEADER_WORKER_BUDGET_USD ?? "0") || 100;
|
|
47
|
+
const resourceSuspendOn = String(env.LEADER_RESOURCE_SUSPEND ?? "").toLowerCase() === "true";
|
|
48
|
+
const sliceMaxCostUsd = Number(env.LEADER_WORKER_SLICE_BUDGET_USD ?? "0") || Math.max(1, workerBudgetUsd / 4);
|
|
49
|
+
return {
|
|
50
|
+
leaderTimeoutMs,
|
|
51
|
+
workerMaxTurns,
|
|
52
|
+
workerBudgetUsd,
|
|
53
|
+
workerLimits: { limits: { maxTurns: workerMaxTurns, timeoutSec: Math.floor(leaderTimeoutMs / 1000) }, maxCostUsd: workerBudgetUsd },
|
|
54
|
+
presignTtlSec: Math.ceil(leaderTimeoutMs / 1000) + 600,
|
|
55
|
+
...(resourceSuspendOn
|
|
56
|
+
? {
|
|
57
|
+
resourceSuspend: {
|
|
58
|
+
totalBudgetUsd: workerBudgetUsd,
|
|
59
|
+
sliceMaxCostUsd,
|
|
60
|
+
maxSuspends: Math.max(20, Math.ceil(workerBudgetUsd / sliceMaxCostUsd) * 2 + 10),
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
: {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function buildLeaderRunner(cfg) {
|
|
67
|
+
const W = cfg.workspace ?? "/home/user";
|
|
68
|
+
const repo = `${W}/repo`;
|
|
69
|
+
const ident = cfg.git ?? { name: "leader", email: "leader@local" };
|
|
70
|
+
const { leaderTimeoutMs, workerLimits, presignTtlSec, resourceSuspend: resourceCfg } = leaderResourceConfig();
|
|
71
|
+
const repairRounds = Math.max(0, Math.floor(Number(process.env.LEADER_REPAIR_ROUNDS ?? cfg.repairRounds ?? 0)) || 0);
|
|
72
|
+
const repairBudgetUsd = Number(process.env.LEADER_REPAIR_BUDGET_USD ?? "4") || 4;
|
|
73
|
+
const conflictRounds = Math.max(0, Math.floor(Number(process.env.LEADER_CONFLICT_ROUNDS ?? cfg.conflictRounds ?? 0)) || 0);
|
|
74
|
+
const repairLoopOn = String(process.env.LEADER_REPAIR_LOOP ?? "").toLowerCase() === "true";
|
|
75
|
+
const measureGatesOn = String(process.env.LEADER_MEASURE_GATES ?? "").toLowerCase() === "true";
|
|
76
|
+
const repairLoopAttempts = Math.min(3, Math.max(2, Math.floor(Number(process.env.LEADER_REPAIR_LOOP_ATTEMPTS ?? "2")) || 2));
|
|
77
|
+
const oracleFlakyK = Math.max(1, Math.floor(Number(process.env.LEADER_ORACLE_FLAKY_K ?? "2")) || 2);
|
|
78
|
+
const mkRepair = (rawEnv, repoDir, oracleFiles) => {
|
|
79
|
+
if (repairRounds <= 0)
|
|
80
|
+
return undefined;
|
|
81
|
+
return {
|
|
82
|
+
maxRounds: repairRounds,
|
|
83
|
+
run: async ({ round, errorText, testCmd }) => {
|
|
84
|
+
for (const f of oracleFiles) {
|
|
85
|
+
await rawEnv.remove(f.path).catch(() => { });
|
|
86
|
+
const ex = await rawEnv.exists(f.path);
|
|
87
|
+
if (ex.ok && ex.value)
|
|
88
|
+
throw new Error(`oracle still present after remove (${f.path}) — refusing repair (measurement integrity)`);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const runner = new Runner({ brain: cfg.brain, models: cfg.models, roles: cfg.roles, pricing: cfg.pricing, executionEnv: rawEnv, rootPath: repoDir });
|
|
92
|
+
const objective = [
|
|
93
|
+
`The integrated project at ${repoDir} fails its build/test. Make the MINIMAL change to the working tree so this command exits 0 (cd into the repo and run it yourself to confirm):`,
|
|
94
|
+
` ${testCmd}`,
|
|
95
|
+
`Several agents each ported a DISJOINT module group; the failure is almost certainly a cross-module integration mismatch (a shared interface, a missing/renamed symbol, a type/signature disagreement between two groups). Read the failing files, fix the smallest set of files, and re-run the command to verify it passes.`,
|
|
96
|
+
`HARD RULES: do NOT git commit or git push; do NOT modify build configuration (gradle.properties / AGP / dependency versions / settings); do NOT add build-tooling files; do NOT call AskUserQuestion — decide autonomously. Preserve the ported semantics — fix the integration, never delete behavior just to make it pass.`,
|
|
97
|
+
``,
|
|
98
|
+
delimitUntrusted("FAILING OUTPUT (untrusted)", errorText),
|
|
99
|
+
].join("\n");
|
|
100
|
+
const res = await runner
|
|
101
|
+
.runTaskStream({
|
|
102
|
+
objective,
|
|
103
|
+
sessionId: `leader-repair-${Date.now()}-${round}`,
|
|
104
|
+
maxCostUsd: repairBudgetUsd,
|
|
105
|
+
limits: { timeoutSec: Math.max(300, Math.floor(leaderTimeoutMs / 1000 / 2)) },
|
|
106
|
+
})
|
|
107
|
+
.result();
|
|
108
|
+
if (res.status !== "completed")
|
|
109
|
+
throw new Error(`repair round ${round} did not complete (status=${res.status})`);
|
|
110
|
+
return { costUsd: res.stats?.costUsd, note: res.result?.slice(0, 200) };
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
for (const f of oracleFiles) {
|
|
114
|
+
const wr = await rawEnv.writeFile(f.path, f.content);
|
|
115
|
+
if (!wr.ok)
|
|
116
|
+
throw wr.error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const mkConflictResolver = (rawEnv, repoDir, oracleFiles) => {
|
|
123
|
+
if (conflictRounds <= 0)
|
|
124
|
+
return undefined;
|
|
125
|
+
return {
|
|
126
|
+
maxRounds: conflictRounds,
|
|
127
|
+
run: async ({ round, workerId, conflictText, patch }) => {
|
|
128
|
+
for (const f of oracleFiles) {
|
|
129
|
+
await rawEnv.remove(f.path).catch(() => { });
|
|
130
|
+
const ex = await rawEnv.exists(f.path);
|
|
131
|
+
if (ex.ok && ex.value)
|
|
132
|
+
throw new Error(`oracle still present after remove (${f.path}) — refusing conflict-resolve (measurement integrity)`);
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const runner = new Runner({ brain: cfg.brain, models: cfg.models, roles: cfg.roles, pricing: cfg.pricing, executionEnv: rawEnv, rootPath: repoDir });
|
|
136
|
+
const objective = [
|
|
137
|
+
`A parallel worker '${workerId}' ported a module on its own branch, but applying its patch onto the already-integrated tree at ${repoDir} produced a MERGE CONFLICT (git apply --3way). The OTHER workers' patches already applied cleanly — integrate THIS worker's changes too, resolving the overlap.`,
|
|
138
|
+
`Resolve EVERY conflict in the working tree: open each file containing conflict markers (<<<<<<< / ======= / >>>>>>>) and merge BOTH sides' real intent (keep both workers' behaviour — never drop one side just to make it apply). Then apply any rejected hunks recorded in *.rej files by hand, and DELETE every *.rej and *.orig file.`,
|
|
139
|
+
`When done, NO conflict markers and NO *.rej files may remain under ${repoDir}. Verify yourself before finishing: grep -rIlE '^(<<<<<<<|>>>>>>>)' . ; find . -name '*.rej' — BOTH must print nothing.`,
|
|
140
|
+
`HARD RULES: do NOT git commit / git add / git push (the coordinator squashes at the end); do NOT modify build configuration; do NOT call AskUserQuestion — decide autonomously. Preserve both sides' ported semantics.`,
|
|
141
|
+
``,
|
|
142
|
+
delimitUntrusted("CONFLICTING WORKER PATCH (untrusted)", patch.slice(0, 6000)),
|
|
143
|
+
delimitUntrusted("CONFLICT DETAILS (untrusted)", conflictText),
|
|
144
|
+
].join("\n");
|
|
145
|
+
const res = await runner
|
|
146
|
+
.runTaskStream({
|
|
147
|
+
objective,
|
|
148
|
+
sessionId: `leader-conflict-${Date.now()}-${round}`,
|
|
149
|
+
maxCostUsd: repairBudgetUsd,
|
|
150
|
+
limits: { timeoutSec: Math.max(300, Math.floor(leaderTimeoutMs / 1000 / 2)) },
|
|
151
|
+
})
|
|
152
|
+
.result();
|
|
153
|
+
if (res.status !== "completed")
|
|
154
|
+
throw new Error(`conflict-resolve round ${round} did not complete (status=${res.status})`);
|
|
155
|
+
return { costUsd: res.stats?.costUsd, note: res.result?.slice(0, 200) };
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
for (const f of oracleFiles) {
|
|
159
|
+
const wr = await rawEnv.writeFile(f.path, f.content);
|
|
160
|
+
if (!wr.ok)
|
|
161
|
+
throw wr.error;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
return async (raw) => {
|
|
168
|
+
const body = raw;
|
|
169
|
+
if (!body.objective || !body.durableRemote || !body.testCmd || !body.seedCmd || !body.baseSha) {
|
|
170
|
+
return { ok: false, reports: [], cancelled: false, error: "request must provide objective, durableRemote, baseSha, testCmd, seedCmd" };
|
|
171
|
+
}
|
|
172
|
+
if (!/^(?:https?|git|ssh):\/\/[^\s]+$/i.test(body.durableRemote) && !/^[\w.-]+@[\w.-]+:[^\s]+$/.test(body.durableRemote)) {
|
|
173
|
+
return { ok: false, reports: [], cancelled: false, error: "durableRemote must be an http(s)/git/ssh URL or user@host:path (no ext::/file:// transport helpers)" };
|
|
174
|
+
}
|
|
175
|
+
if (!safeRev(body.baseSha)) {
|
|
176
|
+
return { ok: false, reports: [], cancelled: false, error: "baseSha must be a plain git rev (sha/branch token)" };
|
|
177
|
+
}
|
|
178
|
+
const injectOracles = async (env) => {
|
|
179
|
+
const ofs = body.oracleFiles ?? [];
|
|
180
|
+
if (ofs.length === 0)
|
|
181
|
+
return;
|
|
182
|
+
for (const f of ofs) {
|
|
183
|
+
const wr = await env.writeFile(f.path, f.content);
|
|
184
|
+
if (!wr.ok)
|
|
185
|
+
throw wr.error;
|
|
186
|
+
}
|
|
187
|
+
const anchor = (p) => "/" + (/^[#!]/.test(p) ? "\\" + p : p);
|
|
188
|
+
const rel = ofs.map((f) => anchor(f.path.startsWith(`${repo}/`) ? f.path.slice(repo.length + 1) : f.path)).join("\n");
|
|
189
|
+
const cur = await env.exec(`bash -lc ${JSON.stringify(`cat ${repo}/.git/info/exclude 2>/dev/null || true`)}`);
|
|
190
|
+
const existing = cur.ok ? cur.value.stdout.replace(/\n*$/, "") : "";
|
|
191
|
+
const ex = await env.writeFile(`${repo}/.git/info/exclude`, `${existing}\n${rel}\n`);
|
|
192
|
+
if (!ex.ok)
|
|
193
|
+
throw ex.error;
|
|
194
|
+
};
|
|
195
|
+
const deps = {
|
|
196
|
+
plan: async () => {
|
|
197
|
+
if (Array.isArray(body.subtasks) && body.subtasks.length > 0) {
|
|
198
|
+
return validateSubtasks(body.subtasks);
|
|
199
|
+
}
|
|
200
|
+
const planRunner = new Runner({ brain: cfg.brain, models: cfg.models, roles: cfg.roles, pricing: cfg.pricing });
|
|
201
|
+
const runRoute = async (prompt) => {
|
|
202
|
+
const res = await planRunner.runTaskStream({
|
|
203
|
+
objective: prompt,
|
|
204
|
+
sessionId: `leader-route-${Date.now()}`,
|
|
205
|
+
...(cfg.routerModel ? { model: cfg.routerModel } : {}),
|
|
206
|
+
}).result();
|
|
207
|
+
return res.result ?? "";
|
|
208
|
+
};
|
|
209
|
+
const { subs, collapsed, rawSample } = await routePlanWithFallback(body.objective, runRoute, {
|
|
210
|
+
...(body.planContext ? { context: body.planContext } : {}),
|
|
211
|
+
...(cfg.fanoutEnabled === false ? { fanoutEnabled: false } : {}),
|
|
212
|
+
});
|
|
213
|
+
if (collapsed)
|
|
214
|
+
cfg.logger?.warn?.("plan_collapsed_to_single", { reason: collapsed, ...(rawSample ? { rawSample } : {}) });
|
|
215
|
+
return subs;
|
|
216
|
+
},
|
|
217
|
+
provisionWorker: async (sub) => {
|
|
218
|
+
const sessionId = `leader-${sub.workerId}-${Date.now()}`;
|
|
219
|
+
let durableSpec = {};
|
|
220
|
+
if (cfg.durable) {
|
|
221
|
+
const d = cfg.durable;
|
|
222
|
+
durableSpec = {
|
|
223
|
+
toolPolicy: combinePolicies(createDurableQuestionPolicy(), createDurableAskPolicy({ requireApproval: d.requireApproval, ...(d.deny ? { deny: d.deny } : {}), ...(d.autoBudget ? { autoBudget: d.autoBudget } : {}), ...(d.neverAuto ? { neverAuto: d.neverAuto } : {}) })),
|
|
224
|
+
checkpointStore: d.checkpointStore,
|
|
225
|
+
durableApproval: { scope: "_leader", ...(d.ttlMs ? { ttlMs: d.ttlMs } : {}) },
|
|
226
|
+
onQuestion: QUESTION_AWAITS_RESUME,
|
|
227
|
+
};
|
|
228
|
+
await d.checkpointStore.putCtx(sessionId, { body: { objective: sub.spec.objective } }).catch((e) => {
|
|
229
|
+
cfg.logger?.warn?.("leader_putctx_failed", { workerId: sub.workerId, err: String(e) });
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
let resourceSpec = {};
|
|
233
|
+
const repairLoopActive = repairLoopOn && REPAIR_LOOP_WIRED;
|
|
234
|
+
if (repairLoopActive && resourceCfg) {
|
|
235
|
+
cfg.logger?.warn?.("leader_resource_suspend_disabled_for_repair_loop", { workerId: sub.workerId, reason: "LEADER_REPAIR_LOOP active — resource-suspend mutually exclusive with the repair loop (§10.5)" });
|
|
236
|
+
}
|
|
237
|
+
if (resourceCfg && !repairLoopActive && cfg.durable && cfg.toolResultStore && cfg.sessionStore) {
|
|
238
|
+
resourceSpec = {
|
|
239
|
+
checkpointStore: cfg.durable.checkpointStore,
|
|
240
|
+
resourceSuspend: { scope: `_leader-resource-${sub.workerId}`, totalBudgetUsd: resourceCfg.totalBudgetUsd },
|
|
241
|
+
maxCostUsd: resourceCfg.sliceMaxCostUsd,
|
|
242
|
+
maxSuspends: resourceCfg.maxSuspends,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
else if (resourceCfg && !repairLoopActive) {
|
|
246
|
+
cfg.logger?.warn?.("leader_resource_suspend_inactive", {
|
|
247
|
+
workerId: sub.workerId,
|
|
248
|
+
reason: !cfg.durable
|
|
249
|
+
? "no durable checkpoint store"
|
|
250
|
+
: !cfg.toolResultStore
|
|
251
|
+
? "no durable tool-result store"
|
|
252
|
+
: "no durable session store",
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const keepCtxWarm = (runner) => {
|
|
256
|
+
const d = cfg.durable;
|
|
257
|
+
if (!d)
|
|
258
|
+
return runner;
|
|
259
|
+
const orig = runner.runTaskStream.bind(runner);
|
|
260
|
+
runner.runTaskStream = (spec, resume) => {
|
|
261
|
+
const stream = orig(spec, resume);
|
|
262
|
+
const iv = setInterval(() => {
|
|
263
|
+
void d.checkpointStore.putCtx(sessionId, { body: { objective: sub.spec.objective } }).catch(() => { });
|
|
264
|
+
}, 45_000);
|
|
265
|
+
iv.unref?.();
|
|
266
|
+
void stream.result().then(() => clearInterval(iv), () => clearInterval(iv));
|
|
267
|
+
return stream;
|
|
268
|
+
};
|
|
269
|
+
return runner;
|
|
270
|
+
};
|
|
271
|
+
if (cfg.s3 && cfg.envFactory) {
|
|
272
|
+
const s3 = cfg.s3;
|
|
273
|
+
const envFactory = cfg.envFactory;
|
|
274
|
+
const baseSha = body.baseSha;
|
|
275
|
+
const seedCmd = body.seedCmd;
|
|
276
|
+
const key = `${s3.keyPrefix ?? "leader-diff"}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}/${sub.workerId}.patch`;
|
|
277
|
+
const ttl = presignTtlSec;
|
|
278
|
+
const base = { endpoint: s3.endpoint, bucket: s3.bucket, accessKey: s3.accessKey, secretKey: s3.secretKey, ...(s3.region ? { region: s3.region } : {}), key, expiresSec: ttl };
|
|
279
|
+
const putUrl = presignS3Url({ ...base, method: "PUT" });
|
|
280
|
+
const getUrl = presignS3Url({ ...base, method: "GET" });
|
|
281
|
+
const script = buildUploadScript({ repoDir: repo, baseSha, putUrl, workDir: W });
|
|
282
|
+
const stage = async (env) => {
|
|
283
|
+
await stageWorkerEnv(env, { seedCmd, repo, branch: sub.branch, uploadScriptPath: `${W}/.leader-upload.sh`, uploadScript: script });
|
|
284
|
+
void sh(env)(`nohup sh -c 'while true; do sleep 90; sh ${W}/.leader-upload.sh >/dev/null 2>&1 || true; done' </dev/null >/dev/null 2>&1 &`).catch(() => { });
|
|
285
|
+
};
|
|
286
|
+
return {
|
|
287
|
+
workerId: sub.workerId, sessionId, branch: sub.branch,
|
|
288
|
+
baseSha,
|
|
289
|
+
runner: keepCtxWarm(new Runner({
|
|
290
|
+
brain: cfg.brain, models: cfg.models, roles: cfg.roles, pricing: cfg.pricing,
|
|
291
|
+
...(cfg.toolResultStore ? { toolResultStore: cfg.toolResultStore } : {}),
|
|
292
|
+
...(cfg.sessionStore ? { sessionStore: cfg.sessionStore } : {}),
|
|
293
|
+
executionEnvFactory: (ctx) => withStaging(envFactory(ctx), stage, async (e) => {
|
|
294
|
+
await sh(e)(`cd ${repo} && git add -A && git -c user.name='leader-belt' -c user.email='belt@leader' commit -qm 'belt: auto-commit uncommitted worker output' || true; sh ${W}/.leader-upload.sh`);
|
|
295
|
+
}),
|
|
296
|
+
})),
|
|
297
|
+
fetchDiff: () => fetchUploadedDiff(getUrl),
|
|
298
|
+
spec: { ...workerLimits, ...sub.spec, ...durableSpec, ...resourceSpec, objective: `${sub.spec.objective}${uploadStepSuffix(W)}` },
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (!cfg.e2bApiKey)
|
|
302
|
+
throw new Error("leader wire: no envFactory+s3 (factory mode) and no e2bApiKey (static mode)");
|
|
303
|
+
const env = new RemoteContainerExecutionEnv({ apiKey: cfg.e2bApiKey, timeoutMs: leaderTimeoutMs });
|
|
304
|
+
if (!(await env.connect()).ok)
|
|
305
|
+
throw new Error(`connect failed for ${sub.workerId}`);
|
|
306
|
+
await sh(env)(`${body.seedCmd}; cd ${repo}; git checkout -q -b ${sub.branch}`);
|
|
307
|
+
const baseSha = await sh(env)(`cd ${repo} && git rev-parse HEAD`);
|
|
308
|
+
return {
|
|
309
|
+
workerId: sub.workerId, sessionId, branch: sub.branch, baseSha,
|
|
310
|
+
runner: keepCtxWarm(new Runner({ brain: cfg.brain, models: cfg.models, roles: cfg.roles, pricing: cfg.pricing, ...(cfg.toolResultStore ? { toolResultStore: cfg.toolResultStore } : {}), ...(cfg.sessionStore ? { sessionStore: cfg.sessionStore } : {}), executionEnv: env })),
|
|
311
|
+
diffEnv: env,
|
|
312
|
+
destroy: () => env.destroy().then(() => { }),
|
|
313
|
+
spec: { ...workerLimits, ...sub.spec, ...durableSpec, ...resourceSpec },
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
provisionIntegrationSandbox: async () => {
|
|
317
|
+
if (cfg.envFactory) {
|
|
318
|
+
const env = cfg.envFactory({ sessionId: `leader-integ-${Date.now()}` });
|
|
319
|
+
try {
|
|
320
|
+
await sh(env)(body.seedCmd);
|
|
321
|
+
await injectOracles(env);
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
await Promise.resolve(env.destroy()).catch(() => { });
|
|
325
|
+
throw e;
|
|
326
|
+
}
|
|
327
|
+
return { env: asIntegrationEnv(env), destroy: () => Promise.resolve(env.destroy()).then(() => { }), ...(mkRepair(env, repo, body.oracleFiles ?? []) ? { repair: mkRepair(env, repo, body.oracleFiles ?? []) } : {}), ...(mkConflictResolver(env, repo, body.oracleFiles ?? []) ? { conflictResolver: mkConflictResolver(env, repo, body.oracleFiles ?? []) } : {}) };
|
|
328
|
+
}
|
|
329
|
+
if (!cfg.e2bApiKey)
|
|
330
|
+
throw new Error("leader wire: no envFactory and no e2bApiKey");
|
|
331
|
+
const env = new RemoteContainerExecutionEnv({ apiKey: cfg.e2bApiKey, timeoutMs: leaderTimeoutMs });
|
|
332
|
+
if (!(await env.connect()).ok) {
|
|
333
|
+
await env.destroy().catch(() => { });
|
|
334
|
+
throw new Error("integ connect failed");
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
await sh(env)(body.seedCmd);
|
|
338
|
+
await injectOracles(env);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
await env.destroy().catch(() => { });
|
|
342
|
+
throw e;
|
|
343
|
+
}
|
|
344
|
+
return { env: asIntegrationEnv(env), destroy: () => env.destroy().then(() => { }), ...(mkRepair(env, repo, body.oracleFiles ?? []) ? { repair: mkRepair(env, repo, body.oracleFiles ?? []) } : {}), ...(mkConflictResolver(env, repo, body.oracleFiles ?? []) ? { conflictResolver: mkConflictResolver(env, repo, body.oracleFiles ?? []) } : {}) };
|
|
345
|
+
},
|
|
346
|
+
push: async (integratedPatch, baseSha) => {
|
|
347
|
+
const dir = mkdtempSync(join(tmpdir(), "leader-coord-"));
|
|
348
|
+
const gitEnv = { ...process.env, LC_ALL: "C" };
|
|
349
|
+
try {
|
|
350
|
+
execFileSync("git", ["clone", "-q", body.durableRemote, dir], { env: gitEnv });
|
|
351
|
+
execFileSync("git", ["-C", dir, "config", "user.name", ident.name]);
|
|
352
|
+
execFileSync("git", ["-C", dir, "config", "user.email", ident.email]);
|
|
353
|
+
writeFileSync(join(dir, ".leader.patch"), integratedPatch);
|
|
354
|
+
execFileSync("git", ["-C", dir, "am", "--3way", ".leader.patch"], { env: gitEnv });
|
|
355
|
+
rmSync(join(dir, ".leader.patch"));
|
|
356
|
+
const ref = body.targetRef ?? "refs/heads/main";
|
|
357
|
+
const ls = execFileSync("git", ["-C", dir, "ls-remote", "--refs", "origin", ref], { encoding: "utf8", env: gitEnv });
|
|
358
|
+
const exists = ls.split("\n").some((l) => l.split("\t")[1] === ref);
|
|
359
|
+
if (exists) {
|
|
360
|
+
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:${baseSha}`, "origin", `HEAD:${ref}`], { env: gitEnv });
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:`, "origin", `HEAD:${ref}`], { env: gitEnv });
|
|
364
|
+
}
|
|
365
|
+
return { ok: true, ref };
|
|
366
|
+
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
369
|
+
return { ok: false, raced: /stale info|force-with-lease|\[rejected\]|non-fast-forward/.test(msg), error: msg };
|
|
370
|
+
}
|
|
371
|
+
finally {
|
|
372
|
+
rmSync(dir, { recursive: true, force: true });
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
testCmd: body.testCmd,
|
|
376
|
+
repoDir: repo, workerRepoDir: repo,
|
|
377
|
+
timeoutMs: leaderTimeoutMs, maxConcurrency: 4,
|
|
378
|
+
replan: { ...(process.env.LEADER_BUDGET_USD ? { budgetUsd: Number(process.env.LEADER_BUDGET_USD) } : {}) },
|
|
379
|
+
...(measureGatesOn
|
|
380
|
+
? { mergeGates: { measureGates: true, ...((body.oracleFiles?.length ?? 0) > 0 ? { strongOracleSeeded: true } : {}) } }
|
|
381
|
+
: {}),
|
|
382
|
+
...(cfg.logger ? { logger: cfg.logger } : {}),
|
|
383
|
+
};
|
|
384
|
+
const resolveRepair = async (solo, _sub) => {
|
|
385
|
+
let env;
|
|
386
|
+
if (cfg.envFactory) {
|
|
387
|
+
env = cfg.envFactory({ sessionId: `leader-grader-${Date.now()}` });
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
if (!cfg.e2bApiKey)
|
|
391
|
+
throw new Error("leader wire: repair-loop grader needs an envFactory or e2bApiKey");
|
|
392
|
+
const e2b = new RemoteContainerExecutionEnv({ apiKey: cfg.e2bApiKey, timeoutMs: leaderTimeoutMs });
|
|
393
|
+
if (!(await e2b.connect()).ok) {
|
|
394
|
+
await e2b.destroy().catch(() => { });
|
|
395
|
+
throw new Error("repair-loop grader connect failed");
|
|
396
|
+
}
|
|
397
|
+
env = e2b;
|
|
398
|
+
}
|
|
399
|
+
let integBase;
|
|
400
|
+
try {
|
|
401
|
+
await sh(env)(body.seedCmd);
|
|
402
|
+
await injectOracles(env);
|
|
403
|
+
integBase = await sh(env)(`cd ${repo} && git rev-parse HEAD`);
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
await Promise.resolve(env.destroy()).catch(() => { });
|
|
407
|
+
throw e;
|
|
408
|
+
}
|
|
409
|
+
const grader = {
|
|
410
|
+
env: env,
|
|
411
|
+
writeFile: async (p, c) => { const r = await env.writeFile(p, c); if (!r.ok)
|
|
412
|
+
throw r.error; },
|
|
413
|
+
repoDir: repo,
|
|
414
|
+
integBase,
|
|
415
|
+
};
|
|
416
|
+
const workerRepoDir = repo;
|
|
417
|
+
const pullWorkerDiff = solo.fetchDiff
|
|
418
|
+
?
|
|
419
|
+
solo.fetchDiff
|
|
420
|
+
: async () => {
|
|
421
|
+
const wenv = solo.diffEnv;
|
|
422
|
+
await wenv
|
|
423
|
+
.exec(`bash -lc ${JSON.stringify(`cd ${repo} && git add -A && (git diff --cached --quiet || git -c user.email=w@w.co -c user.name=worker commit -q -m repair-wip)`)}`)
|
|
424
|
+
.catch(() => { });
|
|
425
|
+
return pullDiff(solo.diffEnv, solo.baseSha, { ref: solo.branch, ...(workerRepoDir ? { cwd: workerRepoDir } : {}) });
|
|
426
|
+
};
|
|
427
|
+
const oracleSteps = [{ command: body.testCmd, cwd: repo, label: "oracle-test" }];
|
|
428
|
+
const oracleFiles = body.oracleFiles ?? [];
|
|
429
|
+
const passTier = oracleFiles.length > 0 ? "trusted_hidden" : "property_harness_weak";
|
|
430
|
+
if (solo.fetchDiff)
|
|
431
|
+
cfg.logger?.info?.("repair_loop_factory_lane_isolation", { workerId: solo.workerId, reason: "identity check intentionally skipped — isolation by independent grader sandbox construction (§10.2)" });
|
|
432
|
+
return {
|
|
433
|
+
runner: solo.runner,
|
|
434
|
+
grader,
|
|
435
|
+
graderDestroy: () => Promise.resolve(env.destroy()).then(() => { }),
|
|
436
|
+
pullWorkerDiff,
|
|
437
|
+
oracleSteps,
|
|
438
|
+
passTier,
|
|
439
|
+
...(oracleFiles.length > 0 ? { oracleFiles, oraclePaths: oracleFiles.map((f) => f.path) } : {}),
|
|
440
|
+
maxAttempts: repairLoopAttempts,
|
|
441
|
+
flakyK: oracleFlakyK,
|
|
442
|
+
...(!solo.fetchDiff && solo.diffEnv ? { workerEnv: solo.diffEnv } : {}),
|
|
443
|
+
log: (event, x) => event.includes("fail") || event.includes("warn") || event.includes("threw")
|
|
444
|
+
? cfg.logger?.warn?.(event, x)
|
|
445
|
+
: cfg.logger?.info?.(event, x),
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
attachRepairLoopDeps(deps, repairLoopOn ? resolveRepair : undefined);
|
|
449
|
+
return runLeaderTask(body.objective, body.baseSha, deps);
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=wire.js.map
|