@sema-agent/server 1.323.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot/budget-tracing.d.ts +48 -0
- package/dist/boot/budget-tracing.js +86 -0
- package/dist/boot/config-center.d.ts +62 -0
- package/dist/boot/config-center.js +995 -0
- package/dist/boot/coordinators.d.ts +33 -0
- package/dist/boot/coordinators.js +97 -0
- package/dist/boot/execution-env.d.ts +26 -0
- package/dist/boot/execution-env.js +370 -0
- package/dist/boot/leader.d.ts +27 -0
- package/dist/boot/leader.js +81 -0
- package/dist/boot/reapers.d.ts +53 -0
- package/dist/boot/reapers.js +252 -0
- package/dist/boot/resolve-spec.d.ts +70 -0
- package/dist/boot/resolve-spec.js +1072 -0
- package/dist/boot/runner-deps.d.ts +101 -0
- package/dist/boot/runner-deps.js +343 -0
- package/dist/boot/runtime-caps.d.ts +21 -0
- package/dist/boot/runtime-caps.js +62 -0
- package/dist/boot/session-faces.d.ts +57 -0
- package/dist/boot/session-faces.js +157 -0
- package/dist/boot/shutdown.d.ts +50 -0
- package/dist/boot/shutdown.js +129 -0
- package/dist/boot/stores.d.ts +32 -0
- package/dist/boot/stores.js +361 -0
- package/dist/boot/workflow-orchestration.d.ts +46 -0
- package/dist/boot/workflow-orchestration.js +150 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +585 -1
- package/dist/config.d.ts +78 -2
- package/dist/config.js +874 -301
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +530 -2129
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +58 -2
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
package/dist/question.js
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §4④ tool-panorama — AskUserQuestion LIVE-stream HITL, the SERVICE side of core's `RunnerDeps.onQuestion`
|
|
3
|
+
* seam (core `ask-question.ts`, design/64 §5.2). The SIBLING of {@link import("./elicitation.js").ElicitationCoordinator}:
|
|
4
|
+
* elicitation is an inbound-MCP-server ask; this is the AGENT's own `AskUserQuestion` tool (a structured multiple-choice
|
|
5
|
+
* question to the end user). core EMITS the call and hands it to `onQuestion`; the deployment routes it to a live human
|
|
6
|
+
* over the run's stream and returns their {@link QuestionAnswer}. The durable-disconnected-human case is ALREADY wired
|
|
7
|
+
* separately (`createDurableQuestionPolicy` + `QUESTION_AWAITS_RESUME` on the durable leg — the question SUSPENDS and a
|
|
8
|
+
* resume carries the answer); this is the LIVE-only, same-replica, `steer()`-class half.
|
|
9
|
+
*
|
|
10
|
+
* The service is pure WIRE glue (the abstraction is core's): forward the questions to whoever tails the run's stream (a
|
|
11
|
+
* `question` SSE frame), park a promise, resolve it from `POST /v1/questions/:id/respond`. 🔒 SECURITY: the ANSWER fence
|
|
12
|
+
* is CORE's — core's AskUserQuestion tool echoes a `selected` value ONLY if it is one of the offered option labels
|
|
13
|
+
* (`selected ⊆ options`) and wraps the free-text `note` in an untrusted-DATA fence (design/80 D-F), so a wire answer can
|
|
14
|
+
* never be read as instructions. The service therefore does NOT re-fence the answer; it validates only the outer SHAPE
|
|
15
|
+
* (the HTTP boundary) and REDACTS secrets from the model-authored QUESTION text before it is persisted/streamed (the
|
|
16
|
+
* same redact-at-write contract as elicitation's `message`/tool outputs — the question is shown to a human, never
|
|
17
|
+
* re-fed to a model, so no `delimitUntrusted` is needed on it). Deployment responsibilities core delegates: THROTTLE
|
|
18
|
+
* (bound concurrency/total/ttl per run — an over-eager agent could flood the human) and no-live-human FALLBACK (a leg
|
|
19
|
+
* with no stream returns the headless "no answer" default so the model proceeds instead of hanging).
|
|
20
|
+
*
|
|
21
|
+
* ROUTING mirrors elicitation: `onQuestion` lives on the SINGLETON runner's `RunnerDeps` (the request carries no taskId),
|
|
22
|
+
* so the run leg establishes a per-run AsyncLocalStorage context (taskId throttle key, owner respond-gate, `emit`
|
|
23
|
+
* closure). `node:async_hooks` propagates it through every await; no context ⇒ headless default (never a hang).
|
|
24
|
+
*/
|
|
1
25
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
26
|
import { uuidv7 } from "@sema-agent/core";
|
|
3
27
|
import { redactDeep } from "./trace/redact.js";
|
|
28
|
+
/** Size bound on the model-authored questions payload before it is persisted to the durable log + streamed (parity
|
|
29
|
+
* with elicitation's MAX_ELICIT_* — an over-large questions blob amplifies into the socket/log). Over the cap ⇒ the
|
|
30
|
+
* questions are dropped and the ask headless-defaults (a question the human can't see can't be answered). */
|
|
4
31
|
const MAX_QUESTIONS_BYTES = 16384;
|
|
5
32
|
export const DEFAULT_QUESTION_THROTTLE = {
|
|
6
33
|
maxConcurrentPerRun: 2,
|
|
7
34
|
maxTotalPerRun: 20,
|
|
8
35
|
ttlMs: 5 * 60_000,
|
|
9
36
|
};
|
|
37
|
+
/** The headless "no live human answered" result — an EMPTY answer set (no question got a selection). core's
|
|
38
|
+
* AskUserQuestion tool renders this to the model as "no option selected" so it proceeds with its own judgment instead
|
|
39
|
+
* of hanging (parity with the `onQuestion===undefined` headless default — a run with no human never blocks). */
|
|
10
40
|
const NO_HUMAN = { answers: [] };
|
|
41
|
+
/** Validate the respond body = core's {@link QuestionAnswer}. `selected`/`note` are OPAQUE passthrough (core fences
|
|
42
|
+
* them: `selected ⊆ options`, `note` untrusted-fenced) — we validate only the outer SHAPE (answers[] of {header,
|
|
43
|
+
* selected:string[], note?}), never the option semantics. */
|
|
11
44
|
export function parseQuestionResponse(body) {
|
|
12
45
|
if (body === null || typeof body !== "object" || Array.isArray(body))
|
|
13
46
|
return { ok: false, error: "body must be an object" };
|
|
@@ -30,7 +63,13 @@ export function parseQuestionResponse(body) {
|
|
|
30
63
|
}
|
|
31
64
|
return { ok: true, value: { answers: out } };
|
|
32
65
|
}
|
|
66
|
+
/** @deprecated design/158 N22: renamed to {@link parseQuestionResponse} — unifies the HITL trio's parse-fn
|
|
67
|
+
* vocabulary (`parseQuestionResponse` / `parseElicitationResponse` / `parseToolApprovalResponse`, all "the
|
|
68
|
+
* human's reply body"). Kept as a compat alias. */
|
|
33
69
|
export const parseQuestionAnswer = parseQuestionResponse;
|
|
70
|
+
/** redactDeep + size-bound the UNTRUSTED model-authored questions before they are persisted/streamed (a question's
|
|
71
|
+
* free-text — question/header/option label+description — can echo a secret from the model's context). Over the byte
|
|
72
|
+
* cap OR unserializable ⇒ undefined (drop; the ask headless-defaults). */
|
|
34
73
|
function boundQuestions(questions) {
|
|
35
74
|
const redacted = redactDeep(questions);
|
|
36
75
|
try {
|
|
@@ -42,6 +81,12 @@ function boundQuestions(questions) {
|
|
|
42
81
|
}
|
|
43
82
|
return redacted;
|
|
44
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Coordinates AskUserQuestion HITL for the singleton runner. Process-local + same-replica (the pending map is in memory,
|
|
86
|
+
* like ElicitationCoordinator / steerableRuns): a respond that lands on another replica finds nothing → 404. Present
|
|
87
|
+
* (passed into `RunnerDeps.onQuestion` + the respond route) ONLY when `ASK_QUESTION_ENABLED` — absent ⇒ core mounts the
|
|
88
|
+
* AskUserQuestion tool with the headless default (a run never hangs; the model just can't get a live answer).
|
|
89
|
+
*/
|
|
45
90
|
export class QuestionCoordinator {
|
|
46
91
|
als = new AsyncLocalStorage();
|
|
47
92
|
pending = new Map();
|
|
@@ -50,6 +95,8 @@ export class QuestionCoordinator {
|
|
|
50
95
|
constructor(throttle = DEFAULT_QUESTION_THROTTLE) {
|
|
51
96
|
this.throttle = throttle;
|
|
52
97
|
}
|
|
98
|
+
/** Run `fn` with the per-run question context ambient. On exit, release any still-pending question for this run (a
|
|
99
|
+
* live-only question cannot outlive its leg → headless default) and drop the run's counters (no leak). */
|
|
53
100
|
runWithContext(ctx, fn) {
|
|
54
101
|
return this.als.run(ctx, async () => {
|
|
55
102
|
try {
|
|
@@ -64,20 +111,27 @@ export class QuestionCoordinator {
|
|
|
64
111
|
}
|
|
65
112
|
});
|
|
66
113
|
}
|
|
114
|
+
/** `RunnerDeps.onQuestion`. core calls this when the agent's AskUserQuestion tool fires; the resolved answer is what
|
|
115
|
+
* the model sees. Headless default (`NO_HUMAN`) in every case with no live human, so the run never hangs. Arrow
|
|
116
|
+
* property so it can be passed as `onQuestion: coordinator.question` with `this` bound. */
|
|
67
117
|
question = async (req, signal) => {
|
|
68
118
|
const ctx = this.als.getStore();
|
|
119
|
+
// No run context (a leg not wrapped by runWithContext — synchronous /v1/tasks, verify/cascade, or a leader sub-task
|
|
120
|
+
// with no live stream) ⇒ headless default. Sub-tasks run in the parent's ALS frame → a child's question inherits the
|
|
121
|
+
// top-level run's ctx (one human, one stream, one throttle budget), same as elicitation.
|
|
69
122
|
if (!ctx)
|
|
70
123
|
return NO_HUMAN;
|
|
71
124
|
if (signal?.aborted || ctx.abortSignal?.aborted)
|
|
72
125
|
return NO_HUMAN;
|
|
126
|
+
// THROTTLE (service's job — core imposes none): bound concurrency + total. Breach ⇒ headless default.
|
|
73
127
|
const rc = this.countersFor(ctx.taskId);
|
|
74
128
|
if (rc.inflight >= this.throttle.maxConcurrentPerRun || rc.total >= this.throttle.maxTotalPerRun)
|
|
75
129
|
return NO_HUMAN;
|
|
76
130
|
const questions = boundQuestions(req.questions);
|
|
77
131
|
if (!questions)
|
|
78
|
-
return NO_HUMAN;
|
|
132
|
+
return NO_HUMAN; // over-cap / unserializable → can't show it → headless
|
|
79
133
|
const id = uuidv7();
|
|
80
|
-
rc.inflight += 1;
|
|
134
|
+
rc.inflight += 1; // reserve the concurrency slot; total charged only on a successful emit
|
|
81
135
|
let done = false;
|
|
82
136
|
let timer;
|
|
83
137
|
let resolveAnswer;
|
|
@@ -92,6 +146,7 @@ export class QuestionCoordinator {
|
|
|
92
146
|
ctx.abortSignal?.removeEventListener("abort", onAbort);
|
|
93
147
|
this.pending.delete(id);
|
|
94
148
|
rc.inflight = Math.max(0, rc.inflight - 1);
|
|
149
|
+
// stash the outcome for the completion frame emitted below (after the await returns)
|
|
95
150
|
lastOutcome = outcome;
|
|
96
151
|
resolveAnswer(a);
|
|
97
152
|
};
|
|
@@ -101,7 +156,11 @@ export class QuestionCoordinator {
|
|
|
101
156
|
timer.unref?.();
|
|
102
157
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
103
158
|
ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
159
|
+
// Register BEFORE emitting so a (fast) respond can never miss the entry.
|
|
104
160
|
this.pending.set(id, { settle, owner: ctx.owner, taskId: ctx.taskId });
|
|
161
|
+
// Emit the OPEN frame AWAITED so its durable append is ORDERED ahead of the answer/completion/terminal appends (a
|
|
162
|
+
// fire-and-forget append can commit out of seq order and be skipped by the monotonic events-tail cursor). A FAILED
|
|
163
|
+
// emit headless-defaults (nobody can answer) and must NOT burn the per-run total.
|
|
105
164
|
try {
|
|
106
165
|
await ctx.emit({ type: "question", questionId: id, questions });
|
|
107
166
|
rc.total += 1;
|
|
@@ -110,12 +169,19 @@ export class QuestionCoordinator {
|
|
|
110
169
|
settle(NO_HUMAN, "unanswered");
|
|
111
170
|
}
|
|
112
171
|
const answer = await answerP;
|
|
172
|
+
// Completion breadcrumb (dialog dismiss) — FIRE-AND-FORGET so a slow durable append can never delay returning the
|
|
173
|
+
// answer to core. Best-effort + ordering-uncritical (the shell already has the answer via respond).
|
|
113
174
|
void Promise.resolve()
|
|
114
175
|
.then(() => ctx.emit({ type: "question_complete", questionId: id, outcome: lastOutcome }))
|
|
115
176
|
.catch(() => undefined);
|
|
116
177
|
return answer;
|
|
117
178
|
};
|
|
179
|
+
/** `POST /v1/questions/:id/respond` — resolve a parked question with the shell's answer. Owner-gated with a 404 (no
|
|
180
|
+
* existence oracle): a non-owner AND an unknown id (answered / expired / wrong replica) both get 404. Returns the
|
|
181
|
+
* HTTP {status, body}; the HTTP layer owns auth (gatedPrincipal + REQUIRE_PRINCIPAL) before calling. */
|
|
118
182
|
respond(id, principal, body) {
|
|
183
|
+
// Validate the body BEFORE the lookup (steer/elicit parity): a bad body is the caller's error regardless of run
|
|
184
|
+
// state, so 400 is existence-independent (no 400-vs-404 existence oracle).
|
|
119
185
|
const parsed = parseQuestionResponse(body);
|
|
120
186
|
if (!parsed.ok)
|
|
121
187
|
return { status: 400, body: { error: parsed.error, errorCode: "request.body_shape" } };
|
|
@@ -126,6 +192,7 @@ export class QuestionCoordinator {
|
|
|
126
192
|
entry.settle(parsed.value, "answered");
|
|
127
193
|
return { status: 200, body: { questionId: id, delivery: "applied" } };
|
|
128
194
|
}
|
|
195
|
+
/** Test/observability hook: number of currently-parked questions. */
|
|
129
196
|
pendingCount() {
|
|
130
197
|
return this.pending.size;
|
|
131
198
|
}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/80 seam #2 — the resource/preempt durable-suspend opt-in decision (design/74 "失败≠没做完" third state).
|
|
3
|
+
*
|
|
4
|
+
* Pure so it is unit-testable in isolation (the spec is otherwise assembled inside main.ts's bootstrap). When a
|
|
5
|
+
* task opts in, a budget/turns/walltime limit OR a scheduler preempt durably SUSPENDS the task (resumable via
|
|
6
|
+
* `POST /v1/assistant/tasks/:id/resume`) instead of FAILING; absent ⇒ a limit still FAILS.
|
|
7
|
+
*
|
|
8
|
+
* 🔴 EXCLUDE verify/cascade tasks. Core runs their implementation via `runWithVerification`/`runCascade`, which
|
|
9
|
+
* map an inner durable suspend to a FAILED result (`errorCode: "unexpected.suspended"`). The service would then
|
|
10
|
+
* `setTerminal(failed)` while core had already minted a pending `resource_limit` checkpoint + suspended the
|
|
11
|
+
* remote VM — ORPHANING both (the run row is terminal, so nothing resumes them). So a resource-limit hit on a
|
|
12
|
+
* verify/cascade task must FAIL CLEANLY (no suspend), exactly as before the flag. This exclusion is the SAME
|
|
13
|
+
* boundary the `preemptSignal` wiring enforces in runs.ts (stream-path only), so eligibility and the signal stay
|
|
14
|
+
* aligned. (Adversarial review wtyc7ist3 HIGH finding: without this, enabling RESOURCE_SUSPEND leaks a suspended
|
|
15
|
+
* VM + checkpoint on every verify/cascade task that hits a resource limit.)
|
|
16
|
+
*/
|
|
1
17
|
export declare function resourceSuspendOptIn(opts: {
|
|
18
|
+
/** `RESOURCE_SUSPEND=true` (the worker-level switch). */
|
|
2
19
|
enabled: boolean;
|
|
20
|
+
/** `RESOURCE_SUSPEND_TTL_SEC` — 0 ⇒ core default (30d) by omitting `ttlMs`. */
|
|
3
21
|
ttlSec: number;
|
|
22
|
+
/** This task requested the developer-mode verify gate (`body.verify === true`). */
|
|
4
23
|
isVerify: boolean;
|
|
24
|
+
/** This task requested the cascade ladder (`body.cascade === true`). */
|
|
5
25
|
isCascade: boolean;
|
|
26
|
+
/** Multi-tenant isolation key — the SAME key durableApproval uses (the principal; "_" when auth is off). */
|
|
6
27
|
scope: string;
|
|
7
28
|
}): {
|
|
8
29
|
scope: string;
|
package/dist/resource-suspend.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/80 seam #2 — the resource/preempt durable-suspend opt-in decision (design/74 "失败≠没做完" third state).
|
|
3
|
+
*
|
|
4
|
+
* Pure so it is unit-testable in isolation (the spec is otherwise assembled inside main.ts's bootstrap). When a
|
|
5
|
+
* task opts in, a budget/turns/walltime limit OR a scheduler preempt durably SUSPENDS the task (resumable via
|
|
6
|
+
* `POST /v1/assistant/tasks/:id/resume`) instead of FAILING; absent ⇒ a limit still FAILS.
|
|
7
|
+
*
|
|
8
|
+
* 🔴 EXCLUDE verify/cascade tasks. Core runs their implementation via `runWithVerification`/`runCascade`, which
|
|
9
|
+
* map an inner durable suspend to a FAILED result (`errorCode: "unexpected.suspended"`). The service would then
|
|
10
|
+
* `setTerminal(failed)` while core had already minted a pending `resource_limit` checkpoint + suspended the
|
|
11
|
+
* remote VM — ORPHANING both (the run row is terminal, so nothing resumes them). So a resource-limit hit on a
|
|
12
|
+
* verify/cascade task must FAIL CLEANLY (no suspend), exactly as before the flag. This exclusion is the SAME
|
|
13
|
+
* boundary the `preemptSignal` wiring enforces in runs.ts (stream-path only), so eligibility and the signal stay
|
|
14
|
+
* aligned. (Adversarial review wtyc7ist3 HIGH finding: without this, enabling RESOURCE_SUSPEND leaks a suspended
|
|
15
|
+
* VM + checkpoint on every verify/cascade task that hits a resource limit.)
|
|
16
|
+
*/
|
|
1
17
|
export function resourceSuspendOptIn(opts) {
|
|
2
18
|
if (!opts.enabled || opts.isVerify || opts.isCascade)
|
|
3
19
|
return undefined;
|
|
@@ -1,31 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The A value router — cash out the S1 supervisor value verdict (docs/S1-VALUE-VERDICT.md §6.3) into a per-task
|
|
3
|
+
* orchestration decision: run a task as `single` / `supervisor` / `team`.
|
|
4
|
+
*
|
|
5
|
+
* The verdict, in one line: **competent tasks have SUP/TEAM dominated (pure overhead) ⇒ default single; the real
|
|
6
|
+
* supervisor value is (a) DANGER backstop (SUP prevention gate-deny > TEAM fan-out which AMPLIFIES danger ×K) and
|
|
7
|
+
* (b) STRUCTURAL view-gap (goal-keeping / ask-aggregation, universally useful).** So this router is CONSERVATIVE
|
|
8
|
+
* by construction:
|
|
9
|
+
* - default **single** (escalation is never free — the verdict measured it as pure overhead on competent work);
|
|
10
|
+
* - escalate to **supervisor** ONLY on a positive (a)-danger or (b)-structural signal;
|
|
11
|
+
* - NEVER auto-select **team** (fan-out is dominated everywhere tested AND amplifies danger; team stays
|
|
12
|
+
* caller-explicit — a deliberate `council`/`debate`/`team` request, or the `/v1/leader` endpoint).
|
|
13
|
+
*
|
|
14
|
+
* 🔴 ALL signals are DETERMINISTIC (config / mounted tools / exec-env isolation / autonomy / delegation). There is
|
|
15
|
+
* NO LLM "difficulty" judge in the routing decision — the verdict's measurement-integrity rule (design/89 §2.2.1):
|
|
16
|
+
* an LLM judge is a GATE inside an arm, NEVER the routing metric (it would make the router un-auditable + gameable).
|
|
17
|
+
*
|
|
18
|
+
* Pure + unit-testable. The decision is VALIDATED empirically against the S1 harness (a ROUTER arm that runs the
|
|
19
|
+
* router's chosen arm per trap; the objective hidden-test oracle confirms danger→SUP prevents + competent→single
|
|
20
|
+
* is not-worse) BEFORE it is wired into the live task path — never ship an unvalidated router.
|
|
21
|
+
*/
|
|
1
22
|
import { type TaskSpec } from "@sema-agent/core";
|
|
2
23
|
import type { Autonomy } from "../runtime-governance.js";
|
|
3
24
|
export type OrchestrationMode = "single" | "supervisor" | "team";
|
|
25
|
+
/** The DETERMINISTIC signals the routing decision reads (extracted by {@link deriveRoutingSignals} from the
|
|
26
|
+
* task's resolved config — no task-content LLM judgement). */
|
|
4
27
|
export interface RoutingSignals {
|
|
28
|
+
/** The caller explicitly chose an orchestration (a `council`/`debate`/`team` request). Honored verbatim —
|
|
29
|
+
* a deliberate choice outranks automatic routing (back-compat + operator intent). */
|
|
5
30
|
explicitMode?: OrchestrationMode;
|
|
31
|
+
/** (a) The task can cause harm its sandbox does NOT contain ⇒ route to SUP prevention. */
|
|
6
32
|
dangerousCapability: boolean;
|
|
33
|
+
/** (b) The task delegates / fans out / is long-horizon ⇒ supervisor goal-keeping + ask-aggregation. */
|
|
7
34
|
needsGoalKeeping: boolean;
|
|
8
35
|
}
|
|
9
36
|
export interface RoutingDecision {
|
|
10
37
|
mode: OrchestrationMode;
|
|
38
|
+
/** A short, audit-friendly machine reason (e.g. `explicit:team` / `danger:prevention-gate` / `default:single`).
|
|
39
|
+
* Emitted on the trace so a routing decision is always explainable (never a silent mode flip). */
|
|
11
40
|
reason: string;
|
|
12
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The routing decision (pure). Order matters: explicit caller choice first, then (a) danger, then (b) structural,
|
|
44
|
+
* else the single default. `team` is NEVER produced here — it only ever appears via {@link RoutingSignals.explicitMode}.
|
|
45
|
+
*/
|
|
13
46
|
export declare function routeOrchestration(s: RoutingSignals): RoutingDecision;
|
|
47
|
+
/** The task facts {@link deriveRoutingSignals} reads — all DETERMINISTIC, resolved before the task runs. */
|
|
14
48
|
export interface RoutingContext {
|
|
49
|
+
/** Caller-explicit orchestration (council/debate/team) — undefined ⇒ the router decides. */
|
|
15
50
|
explicitMode?: OrchestrationMode;
|
|
51
|
+
/** The resolved autonomy for this task — `read-only` hands cannot mutate/egress ⇒ no danger escalation. */
|
|
16
52
|
autonomy?: Autonomy;
|
|
53
|
+
/** The mounted tools can WRITE the project or run a shell (edit_file / write_file / bash). */
|
|
17
54
|
canWriteOrExec: boolean;
|
|
55
|
+
/** The mounted tools can EGRESS / take IRREVERSIBLE EXTERNAL actions that ESCAPE any sandbox (git push, curl,
|
|
56
|
+
* a real-target deploy). Egress harm is real even inside an isolated sandbox. */
|
|
18
57
|
canEgress: boolean;
|
|
58
|
+
/** The execution env strongly ISOLATES side effects (k8s/Kata/e2b sandbox, torn down after the task) — vs a
|
|
59
|
+
* non-isolated `host`/`ssh` lane where write/exec harm is real. */
|
|
19
60
|
isolatedExecEnv: boolean;
|
|
61
|
+
/** The task delegates / fans out / is long-horizon (the leader/team path, or a long wall-clock) ⇒ the (b)
|
|
62
|
+
* goal-keeping + ask-aggregation value applies. */
|
|
20
63
|
delegatedOrLongHorizon: boolean;
|
|
21
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Derive the routing signals from a task's resolved context — DETERMINISTIC. The danger rule is CONSERVATIVE and
|
|
67
|
+
* fail-safe: a `read-only` task cannot harm (no escalation); EGRESS / irreversible-external capability is danger
|
|
68
|
+
* regardless of sandboxing (it escapes the sandbox); plain write/exec is danger ONLY on a non-isolated env (an
|
|
69
|
+
* isolated sandbox contains it + is torn down). The exact threshold is the one tunable knob — validated
|
|
70
|
+
* empirically against the S1 harness, not guessed.
|
|
71
|
+
*/
|
|
22
72
|
export declare function deriveRoutingSignals(ctx: RoutingContext): RoutingSignals;
|
|
73
|
+
/**
|
|
74
|
+
* Service-facing convenience: map a /v1/tasks task's DETERMINISTIC facts → a routing decision (the service signal
|
|
75
|
+
* derivation + {@link deriveRoutingSignals} + {@link routeOrchestration} in one tested call; main.ts's resolveSpec
|
|
76
|
+
* calls this). Signal mapping:
|
|
77
|
+
* - `isolatedExecEnv` ⟺ a sandboxed remote-exec backend (`e2b`/`k8s` Kata) — `ssh`/`host`/`adb` are NOT isolated.
|
|
78
|
+
* - hand tools (write_file/bash) are mounted only when an executionEnv exists AND hands aren't read-only/plan.
|
|
79
|
+
* - `canEgress` is left false in v1 (per-tool egress detection deferred; danger derives from non-isolation).
|
|
80
|
+
* - `delegatedOrLongHorizon` is false on the single-task path (the (b) value lives on the /v1/leader path).
|
|
81
|
+
*/
|
|
23
82
|
export declare function routeServiceTask(input: {
|
|
83
|
+
/** RESOLVED isolation — computed by {@link isIsolatedExecEnv} (NOT a bare provider name: a `k8s` worker can run
|
|
84
|
+
* plain runc, which is NOT VM-isolated — review HIGH). */
|
|
24
85
|
isolatedExecEnv: boolean;
|
|
86
|
+
/** An executionEnv is configured (hand tools are mountable). */
|
|
25
87
|
hasExecutionEnv: boolean;
|
|
88
|
+
/** The resolved autonomy for the task. */
|
|
26
89
|
autonomy?: Autonomy;
|
|
90
|
+
/** The caller explicitly requested a fan-out (council/debate/team). */
|
|
27
91
|
explicitTeam: boolean;
|
|
28
92
|
}): RoutingDecision;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve whether a task's execution env STRONGLY isolates side effects (a VM/kernel boundary the sandbox tears
|
|
95
|
+
* down). FAIL-CLOSED (review HIGH): a `k8s` backend is isolated ONLY with a VM-isolation `runtimeClass`
|
|
96
|
+
* (kata-x or gvisor) — a runc downgrade (`runtimeClass: ""` / `runc` / unknown) is NOT isolated (shared kernel,
|
|
97
|
+
* container escape). `e2b` is a Firecracker microVM (isolated). `host`/`ssh`/`adb` and anything unknown ⇒ NOT isolated.
|
|
98
|
+
*/
|
|
29
99
|
export declare function isIsolatedExecEnv(provider?: string, runtimeClass?: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The TaskSpec overrides for the SUP prevention posture (mode=supervisor). Applied via `tightenTaskSpec`
|
|
102
|
+
* (tighten-only — composes with the deployment baseline, never loosens):
|
|
103
|
+
* - `shellGate: "always"` — gate every `Bash` as an irreversible_ask (the verdict's gate-deny on the shell).
|
|
104
|
+
* - `toolPolicy` — ALSO ask on the direct write hand tools `Edit`/`Write` (review HIGH: shellGate alone
|
|
105
|
+
* leaves a non-isolated SUP task able to mutate the real fs via write tools ungated). The worker's existing
|
|
106
|
+
* approval machinery (durable suspend / poll) enforces the `ask` — same precondition as `shellGate:"always"`.
|
|
107
|
+
*/
|
|
30
108
|
export declare function supPostureOverrides(): Partial<TaskSpec>;
|
|
31
109
|
//# sourceMappingURL=route-orchestration.d.ts.map
|
|
@@ -1,13 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The A value router — cash out the S1 supervisor value verdict (docs/S1-VALUE-VERDICT.md §6.3) into a per-task
|
|
3
|
+
* orchestration decision: run a task as `single` / `supervisor` / `team`.
|
|
4
|
+
*
|
|
5
|
+
* The verdict, in one line: **competent tasks have SUP/TEAM dominated (pure overhead) ⇒ default single; the real
|
|
6
|
+
* supervisor value is (a) DANGER backstop (SUP prevention gate-deny > TEAM fan-out which AMPLIFIES danger ×K) and
|
|
7
|
+
* (b) STRUCTURAL view-gap (goal-keeping / ask-aggregation, universally useful).** So this router is CONSERVATIVE
|
|
8
|
+
* by construction:
|
|
9
|
+
* - default **single** (escalation is never free — the verdict measured it as pure overhead on competent work);
|
|
10
|
+
* - escalate to **supervisor** ONLY on a positive (a)-danger or (b)-structural signal;
|
|
11
|
+
* - NEVER auto-select **team** (fan-out is dominated everywhere tested AND amplifies danger; team stays
|
|
12
|
+
* caller-explicit — a deliberate `council`/`debate`/`team` request, or the `/v1/leader` endpoint).
|
|
13
|
+
*
|
|
14
|
+
* 🔴 ALL signals are DETERMINISTIC (config / mounted tools / exec-env isolation / autonomy / delegation). There is
|
|
15
|
+
* NO LLM "difficulty" judge in the routing decision — the verdict's measurement-integrity rule (design/89 §2.2.1):
|
|
16
|
+
* an LLM judge is a GATE inside an arm, NEVER the routing metric (it would make the router un-auditable + gameable).
|
|
17
|
+
*
|
|
18
|
+
* Pure + unit-testable. The decision is VALIDATED empirically against the S1 harness (a ROUTER arm that runs the
|
|
19
|
+
* router's chosen arm per trap; the objective hidden-test oracle confirms danger→SUP prevents + competent→single
|
|
20
|
+
* is not-worse) BEFORE it is wired into the live task path — never ship an unvalidated router.
|
|
21
|
+
*/
|
|
1
22
|
import { canonicalToolName } from "@sema-agent/core";
|
|
23
|
+
/**
|
|
24
|
+
* The routing decision (pure). Order matters: explicit caller choice first, then (a) danger, then (b) structural,
|
|
25
|
+
* else the single default. `team` is NEVER produced here — it only ever appears via {@link RoutingSignals.explicitMode}.
|
|
26
|
+
*/
|
|
2
27
|
export function routeOrchestration(s) {
|
|
28
|
+
// 1. Caller-explicit wins — a deliberate council/debate/team request (or the /v1/leader endpoint) is intent.
|
|
3
29
|
if (s.explicitMode)
|
|
4
30
|
return { mode: s.explicitMode, reason: `explicit:${s.explicitMode}` };
|
|
31
|
+
// 2. (a) DANGER → supervisor prevention. The verdict's strongest value: gate-deny PREVENTS (SUP) beats
|
|
32
|
+
// fan-out which AMPLIFIES the danger ×K (TEAM) and even beats single's after-the-fact exposure.
|
|
5
33
|
if (s.dangerousCapability)
|
|
6
34
|
return { mode: "supervisor", reason: "danger:prevention-gate" };
|
|
35
|
+
// 3. (b) STRUCTURAL → supervisor. Goal-keeping (worker local view vs supervisor global blueprint) +
|
|
36
|
+
// cross-subtask ask-aggregation — universally useful when the task delegates / runs long.
|
|
7
37
|
if (s.needsGoalKeeping)
|
|
8
38
|
return { mode: "supervisor", reason: "structural:goal-keeping" };
|
|
39
|
+
// 4. Default SINGLE — competent tasks: SUP/TEAM measured as pure overhead (dominated). Escalation is not free.
|
|
9
40
|
return { mode: "single", reason: "default:single" };
|
|
10
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Derive the routing signals from a task's resolved context — DETERMINISTIC. The danger rule is CONSERVATIVE and
|
|
44
|
+
* fail-safe: a `read-only` task cannot harm (no escalation); EGRESS / irreversible-external capability is danger
|
|
45
|
+
* regardless of sandboxing (it escapes the sandbox); plain write/exec is danger ONLY on a non-isolated env (an
|
|
46
|
+
* isolated sandbox contains it + is torn down). The exact threshold is the one tunable knob — validated
|
|
47
|
+
* empirically against the S1 harness, not guessed.
|
|
48
|
+
*/
|
|
11
49
|
export function deriveRoutingSignals(ctx) {
|
|
12
50
|
const readOnly = ctx.autonomy === "read-only";
|
|
13
51
|
const dangerousCapability = !readOnly && (ctx.canEgress || (ctx.canWriteOrExec && !ctx.isolatedExecEnv));
|
|
@@ -17,18 +55,41 @@ export function deriveRoutingSignals(ctx) {
|
|
|
17
55
|
needsGoalKeeping: ctx.delegatedOrLongHorizon,
|
|
18
56
|
};
|
|
19
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Service-facing convenience: map a /v1/tasks task's DETERMINISTIC facts → a routing decision (the service signal
|
|
60
|
+
* derivation + {@link deriveRoutingSignals} + {@link routeOrchestration} in one tested call; main.ts's resolveSpec
|
|
61
|
+
* calls this). Signal mapping:
|
|
62
|
+
* - `isolatedExecEnv` ⟺ a sandboxed remote-exec backend (`e2b`/`k8s` Kata) — `ssh`/`host`/`adb` are NOT isolated.
|
|
63
|
+
* - hand tools (write_file/bash) are mounted only when an executionEnv exists AND hands aren't read-only/plan.
|
|
64
|
+
* - `canEgress` is left false in v1 (per-tool egress detection deferred; danger derives from non-isolation).
|
|
65
|
+
* - `delegatedOrLongHorizon` is false on the single-task path (the (b) value lives on the /v1/leader path).
|
|
66
|
+
*/
|
|
20
67
|
export function routeServiceTask(input) {
|
|
21
68
|
const readOnlyHands = input.autonomy === "read-only" || input.autonomy === "plan";
|
|
22
69
|
return routeOrchestration(deriveRoutingSignals({
|
|
23
70
|
...(input.explicitTeam ? { explicitMode: "team" } : {}),
|
|
24
71
|
...(input.autonomy ? { autonomy: input.autonomy } : {}),
|
|
25
72
|
canWriteOrExec: input.hasExecutionEnv && !readOnlyHands,
|
|
73
|
+
// 🔴 v1 EXPLICITLY-ACCEPTED LIMITATION (review MEDIUM): `canEgress` is false here, so an isolated sandbox
|
|
74
|
+
// with outbound network (e2b defaults internet ON) is NOT auto-routed to SUP for egress. Deriving danger
|
|
75
|
+
// from network-PRESENCE would over-escalate (a routine `npm install` task needs network) — defeating the
|
|
76
|
+
// verdict's default-single. The real egress danger is IRREVERSIBLE EXTERNAL actions (git push to a real
|
|
77
|
+
// repo, a deploy), which are TOOL-specific, not network-presence, and not cleanly detectable here. When a
|
|
78
|
+
// per-tool egress/irreversibility signal is wired (k8s P3 egress + tool marks), set this from it.
|
|
26
79
|
canEgress: false,
|
|
27
80
|
isolatedExecEnv: input.isolatedExecEnv,
|
|
28
81
|
delegatedOrLongHorizon: false,
|
|
29
82
|
}));
|
|
30
83
|
}
|
|
84
|
+
/** VM-isolation runtime classes — a REAL sandbox boundary (separate kernel). Plain `runc` / `""` / unknown share
|
|
85
|
+
* the host kernel ⇒ NOT isolated. */
|
|
31
86
|
const VM_ISOLATION_CLASSES = new Set(["kata", "kata-qemu", "kata-clh", "kata-fc", "gvisor", "runsc"]);
|
|
87
|
+
/**
|
|
88
|
+
* Resolve whether a task's execution env STRONGLY isolates side effects (a VM/kernel boundary the sandbox tears
|
|
89
|
+
* down). FAIL-CLOSED (review HIGH): a `k8s` backend is isolated ONLY with a VM-isolation `runtimeClass`
|
|
90
|
+
* (kata-x or gvisor) — a runc downgrade (`runtimeClass: ""` / `runc` / unknown) is NOT isolated (shared kernel,
|
|
91
|
+
* container escape). `e2b` is a Firecracker microVM (isolated). `host`/`ssh`/`adb` and anything unknown ⇒ NOT isolated.
|
|
92
|
+
*/
|
|
32
93
|
export function isIsolatedExecEnv(provider, runtimeClass) {
|
|
33
94
|
if (provider === "e2b")
|
|
34
95
|
return true;
|
|
@@ -38,7 +99,23 @@ export function isIsolatedExecEnv(provider, runtimeClass) {
|
|
|
38
99
|
}
|
|
39
100
|
return false;
|
|
40
101
|
}
|
|
102
|
+
/** The write-capable hand tools the SUP posture gates DIRECTLY (Bash is gated via `shellGate`). Q6 (core 1.161):
|
|
103
|
+
* CC-aligned tool names (was edit_file/write_file). NotebookEdit (core 1.163) is the same fs-mutation class — it
|
|
104
|
+
* edits a `.ipynb` on the real fs, so it MUST be gated too, else a SUP-routed (capability-danger) task could mutate
|
|
105
|
+
* a notebook ungated (the exact "write tool bypasses the SUP gate" hole the review-HIGH closed for Edit/Write).
|
|
106
|
+
* Curated, NOT derived from HAND_TOOL_EFFECTS: that taxonomy is replay-safety (Write="idempotent"; Bash="write" but
|
|
107
|
+
* shell-gated), not "is an fs mutation". CANONICAL names only (core 1.202 retired MultiEdit into an Edit alias —
|
|
108
|
+
* `canonicalToolName` in the check below folds a replayed legacy "MultiEdit" call onto "Edit", so batch edits stay
|
|
109
|
+
* gated without a stale alias entry here). */
|
|
41
110
|
const WRITE_HAND_TOOLS = new Set(["Edit", "Write", "NotebookEdit"]);
|
|
111
|
+
/**
|
|
112
|
+
* The TaskSpec overrides for the SUP prevention posture (mode=supervisor). Applied via `tightenTaskSpec`
|
|
113
|
+
* (tighten-only — composes with the deployment baseline, never loosens):
|
|
114
|
+
* - `shellGate: "always"` — gate every `Bash` as an irreversible_ask (the verdict's gate-deny on the shell).
|
|
115
|
+
* - `toolPolicy` — ALSO ask on the direct write hand tools `Edit`/`Write` (review HIGH: shellGate alone
|
|
116
|
+
* leaves a non-isolated SUP task able to mutate the real fs via write tools ungated). The worker's existing
|
|
117
|
+
* approval machinery (durable suspend / poll) enforces the `ask` — same precondition as `shellGate:"always"`.
|
|
118
|
+
*/
|
|
42
119
|
export function supPostureOverrides() {
|
|
43
120
|
const ask = (toolName) => ({ action: "ask", message: `${toolName} gated by supervisor routing (capability-danger task)`, decisionReason: "rule" });
|
|
44
121
|
const writeGate = {
|
package/dist/run-local.d.ts
CHANGED
|
@@ -2,25 +2,57 @@
|
|
|
2
2
|
import { type Brain } from "@sema-agent/core";
|
|
3
3
|
import { type ServiceConfig } from "./config.js";
|
|
4
4
|
import { type Logger } from "./observability/logger.js";
|
|
5
|
+
/** Parsed CLI invocation. */
|
|
5
6
|
export interface RunLocalArgs {
|
|
7
|
+
/** The task objective (the first positional argument). */
|
|
6
8
|
objective: string;
|
|
9
|
+
/** `--root <dir>` — the local config/data root (overrides CONFIG_LOCAL_DIR / AGENT_DATA_DIR). */
|
|
7
10
|
root?: string;
|
|
11
|
+
/** `--json` — print the full TaskResult JSON instead of just the final assistant text. */
|
|
8
12
|
json: boolean;
|
|
13
|
+
/** `--scenario <name>` — pick a capability bundle (default: config.defaultScenario). */
|
|
9
14
|
scenario?: string;
|
|
15
|
+
/** `--session <id>` — REUSE a session across invocations (durable multi-turn). Default: a fresh id (the
|
|
16
|
+
* session + its events still persist to disk, just not continued). */
|
|
10
17
|
session?: string;
|
|
18
|
+
/** `--workspace <dir>` — the FIXED dir the agent's tool calls operate in (CC-like). Default: the cwd. The
|
|
19
|
+
* agent's file edits PERSIST there (never deleted) — this is the user's own directory, not a sandbox. */
|
|
11
20
|
workspace?: string;
|
|
21
|
+
/** `--user <id>` — the local memory/identity scope (so long-term memory accumulates per user). Default "local". */
|
|
12
22
|
user?: string;
|
|
13
23
|
}
|
|
24
|
+
/** Injectable side-effects so {@link runLocal} is deterministic + testable (no real process I/O). */
|
|
14
25
|
export interface RunLocalDeps {
|
|
26
|
+
/** Override the Brain (a mock in tests). When absent, the real `createBrain(config, { fetchImpl })` is used. */
|
|
15
27
|
brain?: Brain;
|
|
28
|
+
/** Forwarded into `createBrain` when no `brain` is given — lets a test fake the gateway wire. */
|
|
16
29
|
fetchImpl?: typeof fetch;
|
|
30
|
+
/** Structured logger (defaults to the real one at config.logLevel). */
|
|
17
31
|
logger?: Logger;
|
|
32
|
+
/** stdout sink for the human/JSON result (defaults to console.log). */
|
|
18
33
|
print?: (line: string) => void;
|
|
34
|
+
/** stderr sink for the "you still need to set …" guidance (defaults to console.error). */
|
|
19
35
|
printErr?: (line: string) => void;
|
|
20
36
|
}
|
|
37
|
+
/** Parse argv (everything AFTER `node run-local.js`). Throws a clear Error on a missing objective. */
|
|
21
38
|
export declare function parseArgs(argv: string[]): RunLocalArgs;
|
|
39
|
+
/** A bad-usage error → print to stderr + exit 2 (distinct from a task failure exit 1). */
|
|
22
40
|
export declare class UsageError extends Error {
|
|
23
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The model GATEWAY pre-flight (mirrors the doctor message): the engine cannot run a real
|
|
44
|
+
* task without (a) a gateway base URL that ends in `/v1` and (b) the gateway/model API key resolvable from
|
|
45
|
+
* env. We surface a "you still need to set: …" list rather than letting the first brain call crash with a
|
|
46
|
+
* cryptic auth/connect error. Returns a list of missing items (empty = OK).
|
|
47
|
+
*
|
|
48
|
+
* NOTE: with an injected mock `brain` the gateway is irrelevant (no real call is made), so the caller skips
|
|
49
|
+
* this check in that case — the check is about a REAL run, not the assembly.
|
|
50
|
+
*/
|
|
24
51
|
export declare function missingGatewayRequirements(config: ServiceConfig): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Boot the engine in LOCAL mode, run ONE task to completion, print the result. Returns the process exit
|
|
54
|
+
* code (0 = completed, 1 = the task did not complete / a fatal error, 2 = bad usage / unmet env). Pure of
|
|
55
|
+
* `process.exit` so a test can assert the code; `main()` applies it.
|
|
56
|
+
*/
|
|
25
57
|
export declare function runLocal(argv: string[], deps?: RunLocalDeps): Promise<number>;
|
|
26
58
|
//# sourceMappingURL=run-local.d.ts.map
|