@sema-agent/server 1.322.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-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 +546 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +455 -60
- 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 +2132 -96
- 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 +59 -3
- 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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** The whitelisted projection of core's `prompt.assembled` trace event ([998]② web observability slice A:
|
|
2
|
+
* the manifest reaches the durable run event log + turns/stream). Built FIELD-BY-FIELD at record time
|
|
3
|
+
* (never a spread — the 1.72 task_progress lesson: a future core field must not ride the durable wire raw).
|
|
4
|
+
* Carries ONLY ids/digests/counts by core's manifest contract (no prompt bodies; hashes are core-salted) —
|
|
5
|
+
* so the projection legs have zero redact burden. */
|
|
1
6
|
export interface PromptManifestRecord {
|
|
2
7
|
constitution: string;
|
|
3
8
|
blocks: Array<{
|
|
@@ -5,6 +10,8 @@ export interface PromptManifestRecord {
|
|
|
5
10
|
chars: number;
|
|
6
11
|
hash: string;
|
|
7
12
|
}>;
|
|
13
|
+
/** `contentHash`(core 1.315 [1062]①):operator 声明 section 的**非盐化**对账锚(core 已对 text 校验
|
|
14
|
+
* 后透传)——盐化 `hash` 恒在旁;端到端对账链(center 发布→manifest)经本投影,必须透传不可吞。 */
|
|
8
15
|
sections?: Array<{
|
|
9
16
|
id: string;
|
|
10
17
|
slot: string;
|
|
@@ -26,6 +33,8 @@ export interface PromptManifestRecord {
|
|
|
26
33
|
}>;
|
|
27
34
|
totalChars: number;
|
|
28
35
|
}
|
|
36
|
+
/** Whitelist one `prompt.assembled` trace event into a {@link PromptManifestRecord} (v1 face required,
|
|
37
|
+
* v2 `sections`/`tools` additive — absent stays absent). */
|
|
29
38
|
export declare function promptManifestRecordOf(e: {
|
|
30
39
|
constitution: string;
|
|
31
40
|
blocks: Array<{
|
|
@@ -54,6 +63,23 @@ export declare function promptManifestRecordOf(e: {
|
|
|
54
63
|
}>;
|
|
55
64
|
totalChars: number;
|
|
56
65
|
}): PromptManifestRecord;
|
|
66
|
+
/**
|
|
67
|
+
* [998]② per-task prompt-manifest accumulator — the `ModelUsageTracker`(budget.ts)pattern: the
|
|
68
|
+
* `prompt.assembled` tracer hook is SYNC/no-IO, so it cannot persist; it RECORDS here (registered
|
|
69
|
+
* top-level runs only — the same leak fence: sub-task manifests are never registered, never leak), and
|
|
70
|
+
* the durable run lifecycle DRAINS the pending records into `prompt_assembled` events. Two departures
|
|
71
|
+
* from the ModelUsage shape (release-review findings):
|
|
72
|
+
* - The pending value is an ordered QUEUE, not a single slot: a cascade/verify leg re-prepares under
|
|
73
|
+
* ONE taskId (core's runCascade passes the same spec taskId to every rung), and each prepare's
|
|
74
|
+
* manifest must persist — latest-wins would hide the prompt actually used by earlier billed rungs.
|
|
75
|
+
* - {@link register} returns a per-leg LEASE and {@link clear} requires it: after setSuspended makes
|
|
76
|
+
* the row claimable, a fast sibling resume can re-register the same taskId before the parked leg's
|
|
77
|
+
* finally runs (the codebase's documented B-3 window) — an unconditional clear there would silently
|
|
78
|
+
* delete the NEW leg's registration/pending manifest. Identity-guarded like the sibling
|
|
79
|
+
* inflight/steerable teardowns.
|
|
80
|
+
*/
|
|
81
|
+
/** [1301]③ — `config.assembled` 的白名单投影(core 1.346 trace:catalogVersion/fields[来源标注]/
|
|
82
|
+
* overrideReasons)。fields 已是 core 精选的观测形(digest-free、有界);32KiB 罩防未来膨胀。 */
|
|
57
83
|
export declare function configAssembledRecordOf(e: {
|
|
58
84
|
catalogVersion?: unknown;
|
|
59
85
|
fields?: unknown;
|
|
@@ -62,14 +88,25 @@ export declare function configAssembledRecordOf(e: {
|
|
|
62
88
|
}): Record<string, unknown> | undefined;
|
|
63
89
|
export declare class PromptManifestTracker {
|
|
64
90
|
private readonly byTask;
|
|
91
|
+
/** [1301]③:config.assembled 的同生命周期伴随记录(register 同门、drainConfig 同拍)。队列形
|
|
92
|
+
* (codex F2):cascade 每 rung 独立解析配置,后到覆盖会把先前已计费 rung 的生效配置抹掉——与
|
|
93
|
+
* prompt manifests 同姿势逐条保序。 */
|
|
65
94
|
private readonly configByTask;
|
|
66
95
|
private readonly active;
|
|
67
96
|
private leaseCounter;
|
|
97
|
+
/** Mark a TOP-LEVEL run active (same fence as `ModelUsageTracker.register`, budget.ts). Returns this leg's
|
|
98
|
+
* lease — pass it to {@link clear} so only the CURRENT owner can tear the slot down. */
|
|
68
99
|
register(taskId: string): number;
|
|
100
|
+
/** Queue this prepare's manifest — ONLY for a registered top-level run (else a no-op). Sync, never throws. */
|
|
69
101
|
record(taskId: string, m: PromptManifestRecord): void;
|
|
102
|
+
/** [1301]③:队一条 config.assembled 投影(同 register 门;逐条保序——cascade 每 rung 各留其形)。 */
|
|
70
103
|
recordConfig(taskId: string, rec: Record<string, unknown>): void;
|
|
104
|
+
/** Return-and-clear ALL pending config records in emission order; `undefined` when none. */
|
|
71
105
|
drainConfig(taskId: string): Array<Record<string, unknown>> | undefined;
|
|
106
|
+
/** Return-and-clear ALL pending manifests in emission order; `undefined` when none. */
|
|
72
107
|
drain(taskId: string): PromptManifestRecord[] | undefined;
|
|
108
|
+
/** Drop pending + unregister (run end / abandoned leg) — but ONLY while `lease` still owns the slot;
|
|
109
|
+
* a stale leg's teardown after a fast re-register is a no-op (the new leg owns it now). */
|
|
73
110
|
clear(taskId: string, lease: number): void;
|
|
74
111
|
}
|
|
75
112
|
//# sourceMappingURL=prompt-manifest.d.ts.map
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// design/158 N18: the prompt-manifest / config-assembled observability face moved VERBATIM out of budget.ts
|
|
2
|
+
// (lens4 §4.1 — budget.ts's name says cost/budget, but this half is wire-observability projection of core's
|
|
3
|
+
// `prompt.assembled`/`config.assembled` trace events, unrelated to spend). budget.ts re-exports all four for
|
|
4
|
+
// compat (its own createTracer still consumes promptManifestRecordOf/configAssembledRecordOf/PromptManifestTracker).
|
|
5
|
+
/** Whitelist one `prompt.assembled` trace event into a {@link PromptManifestRecord} (v1 face required,
|
|
6
|
+
* v2 `sections`/`tools` additive — absent stays absent). */
|
|
1
7
|
export function promptManifestRecordOf(e) {
|
|
2
8
|
return {
|
|
3
9
|
constitution: String(e.constitution),
|
|
@@ -11,6 +17,23 @@ export function promptManifestRecordOf(e) {
|
|
|
11
17
|
totalChars: e.totalChars,
|
|
12
18
|
};
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* [998]② per-task prompt-manifest accumulator — the `ModelUsageTracker`(budget.ts)pattern: the
|
|
22
|
+
* `prompt.assembled` tracer hook is SYNC/no-IO, so it cannot persist; it RECORDS here (registered
|
|
23
|
+
* top-level runs only — the same leak fence: sub-task manifests are never registered, never leak), and
|
|
24
|
+
* the durable run lifecycle DRAINS the pending records into `prompt_assembled` events. Two departures
|
|
25
|
+
* from the ModelUsage shape (release-review findings):
|
|
26
|
+
* - The pending value is an ordered QUEUE, not a single slot: a cascade/verify leg re-prepares under
|
|
27
|
+
* ONE taskId (core's runCascade passes the same spec taskId to every rung), and each prepare's
|
|
28
|
+
* manifest must persist — latest-wins would hide the prompt actually used by earlier billed rungs.
|
|
29
|
+
* - {@link register} returns a per-leg LEASE and {@link clear} requires it: after setSuspended makes
|
|
30
|
+
* the row claimable, a fast sibling resume can re-register the same taskId before the parked leg's
|
|
31
|
+
* finally runs (the codebase's documented B-3 window) — an unconditional clear there would silently
|
|
32
|
+
* delete the NEW leg's registration/pending manifest. Identity-guarded like the sibling
|
|
33
|
+
* inflight/steerable teardowns.
|
|
34
|
+
*/
|
|
35
|
+
/** [1301]③ — `config.assembled` 的白名单投影(core 1.346 trace:catalogVersion/fields[来源标注]/
|
|
36
|
+
* overrideReasons)。fields 已是 core 精选的观测形(digest-free、有界);32KiB 罩防未来膨胀。 */
|
|
14
37
|
export function configAssembledRecordOf(e) {
|
|
15
38
|
const rec = {
|
|
16
39
|
catalogVersion: e.catalogVersion,
|
|
@@ -20,7 +43,7 @@ export function configAssembledRecordOf(e) {
|
|
|
20
43
|
};
|
|
21
44
|
try {
|
|
22
45
|
if (JSON.stringify(rec).length > 32_768)
|
|
23
|
-
return undefined;
|
|
46
|
+
return undefined; // bounded frame — oversize dropped, never truncated半形
|
|
24
47
|
}
|
|
25
48
|
catch {
|
|
26
49
|
return undefined;
|
|
@@ -29,9 +52,14 @@ export function configAssembledRecordOf(e) {
|
|
|
29
52
|
}
|
|
30
53
|
export class PromptManifestTracker {
|
|
31
54
|
byTask = new Map();
|
|
55
|
+
/** [1301]③:config.assembled 的同生命周期伴随记录(register 同门、drainConfig 同拍)。队列形
|
|
56
|
+
* (codex F2):cascade 每 rung 独立解析配置,后到覆盖会把先前已计费 rung 的生效配置抹掉——与
|
|
57
|
+
* prompt manifests 同姿势逐条保序。 */
|
|
32
58
|
configByTask = new Map();
|
|
33
59
|
active = new Map();
|
|
34
60
|
leaseCounter = 0;
|
|
61
|
+
/** Mark a TOP-LEVEL run active (same fence as `ModelUsageTracker.register`, budget.ts). Returns this leg's
|
|
62
|
+
* lease — pass it to {@link clear} so only the CURRENT owner can tear the slot down. */
|
|
35
63
|
register(taskId) {
|
|
36
64
|
if (!taskId)
|
|
37
65
|
return 0;
|
|
@@ -39,6 +67,7 @@ export class PromptManifestTracker {
|
|
|
39
67
|
this.active.set(taskId, lease);
|
|
40
68
|
return lease;
|
|
41
69
|
}
|
|
70
|
+
/** Queue this prepare's manifest — ONLY for a registered top-level run (else a no-op). Sync, never throws. */
|
|
42
71
|
record(taskId, m) {
|
|
43
72
|
if (!taskId || !this.active.has(taskId))
|
|
44
73
|
return;
|
|
@@ -48,6 +77,7 @@ export class PromptManifestTracker {
|
|
|
48
77
|
else
|
|
49
78
|
this.byTask.set(taskId, [m]);
|
|
50
79
|
}
|
|
80
|
+
/** [1301]③:队一条 config.assembled 投影(同 register 门;逐条保序——cascade 每 rung 各留其形)。 */
|
|
51
81
|
recordConfig(taskId, rec) {
|
|
52
82
|
if (!taskId || !this.active.has(taskId))
|
|
53
83
|
return;
|
|
@@ -57,6 +87,7 @@ export class PromptManifestTracker {
|
|
|
57
87
|
else
|
|
58
88
|
this.configByTask.set(taskId, [rec]);
|
|
59
89
|
}
|
|
90
|
+
/** Return-and-clear ALL pending config records in emission order; `undefined` when none. */
|
|
60
91
|
drainConfig(taskId) {
|
|
61
92
|
const q = this.configByTask.get(taskId);
|
|
62
93
|
if (!q || q.length === 0)
|
|
@@ -64,6 +95,7 @@ export class PromptManifestTracker {
|
|
|
64
95
|
this.configByTask.delete(taskId);
|
|
65
96
|
return q;
|
|
66
97
|
}
|
|
98
|
+
/** Return-and-clear ALL pending manifests in emission order; `undefined` when none. */
|
|
67
99
|
drain(taskId) {
|
|
68
100
|
const q = this.byTask.get(taskId);
|
|
69
101
|
if (!q || q.length === 0)
|
|
@@ -71,6 +103,8 @@ export class PromptManifestTracker {
|
|
|
71
103
|
this.byTask.delete(taskId);
|
|
72
104
|
return q;
|
|
73
105
|
}
|
|
106
|
+
/** Drop pending + unregister (run end / abandoned leg) — but ONLY while `lease` still owns the slot;
|
|
107
|
+
* a stale leg's teardown after a fast re-register is a no-op (the new leg owns it now). */
|
|
74
108
|
clear(taskId, lease) {
|
|
75
109
|
if (this.active.get(taskId) !== lease)
|
|
76
110
|
return;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixed-window rate limiter, keyed by principal (falls back to client IP).
|
|
3
|
+
*
|
|
4
|
+
* In-memory and per-instance: the effective global limit is `limit × #instances`. For a hard global
|
|
5
|
+
* cap, back this with a shared store (Redis); for protecting one instance from a hot caller this is
|
|
6
|
+
* enough. `limit <= 0` disables it.
|
|
7
|
+
*/
|
|
1
8
|
export interface RateDecision {
|
|
2
9
|
allowed: boolean;
|
|
3
10
|
retryAfterSec: number;
|
|
4
11
|
remaining: number;
|
|
5
12
|
}
|
|
13
|
+
/** The surface the HTTP layer uses — satisfied by the in-memory {@link RateLimiter} (single replica)
|
|
14
|
+
* and the cross-replica {@link import("../plugins/tidb-rate-limiter.js").TiDBRateLimiter}. */
|
|
6
15
|
export interface RateGate {
|
|
7
16
|
check(key: string): RateDecision;
|
|
8
17
|
sweep(now?: number): void;
|
|
@@ -13,6 +22,7 @@ export declare class RateLimiter implements RateGate {
|
|
|
13
22
|
private readonly windows;
|
|
14
23
|
constructor(limit: number, windowMs?: number);
|
|
15
24
|
check(key: string): RateDecision;
|
|
25
|
+
/** Drop expired windows (call periodically). */
|
|
16
26
|
sweep(now?: number): void;
|
|
17
27
|
}
|
|
18
28
|
//# sourceMappingURL=rate-limit.d.ts.map
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import type { Hooks } from "@sema-agent/core";
|
|
2
2
|
import type { Logger } from "./logger.js";
|
|
3
3
|
import type { Metrics } from "./metrics.js";
|
|
4
|
+
/**
|
|
5
|
+
* ALWAYS-ON gate-deny meter (goal B4, 2026-07-08): `permission_denied_total{source}` — how often the
|
|
6
|
+
* adjudicate chain DENIES a tool call, by gate source. Deliberately SEPARATE from {@link createToolTracer}:
|
|
7
|
+
* the tracer is a default-OFF diagnostic (TOOL_TRACE=true), but deny frequency is an operational/security
|
|
8
|
+
* signal that must reach /metrics on every deployment — a spike in `source="policy"` means a task keeps
|
|
9
|
+
* asking for something the operator forbids; `source="safety"`/`"shellGate"` spikes flag risky-command
|
|
10
|
+
* pressure. main.ts composes this UNDER the tracer via composeHooks (both are void observers on the
|
|
11
|
+
* permissionDenied slot, which composeHooks double-runs deployment-first).
|
|
12
|
+
*/
|
|
4
13
|
export declare function createPermissionDeniedMeter(metrics: Pick<Metrics, "inc">): Hooks;
|
|
14
|
+
/**
|
|
15
|
+
* prove-before-scale stopgap (design/50): a no-op observer hook that logs every tool call (pre + post)
|
|
16
|
+
* to the worker log — INCLUDING resumed legs that `GET /v1/runs/:id/events` does NOT surface (the
|
|
17
|
+
* streaming-resume observability gap, service[15] API request #2). Gated by `TOOL_TRACE=true`; OFF by
|
|
18
|
+
* default (no prod noise).
|
|
19
|
+
*
|
|
20
|
+
* Why: a durable-HITL-gated coding task that keeps re-suspending is ambiguous from /events alone —
|
|
21
|
+
* could be a model restart-on-resume loop (the SAME tool re-issued each resume) or slow legit iteration.
|
|
22
|
+
* The pre-hook logs `{tool, id, arg:{path,contentLen,…}}` per call, so grepping `tool_trace` reconstructs
|
|
23
|
+
* the full sequence: a repeated `write_file path=X contentLen=Y` across resumes ⇒ restart-loop;
|
|
24
|
+
* write X → write Y → bash ⇒ iteration.
|
|
25
|
+
*
|
|
26
|
+
* Pure observation: every hook returns `undefined`, so it never rewrites args, never gates, never alters
|
|
27
|
+
* the result (and per core's hooks invariant a hook's `allow` can't bypass the policy gate anyway).
|
|
28
|
+
*/
|
|
5
29
|
export declare function createToolTracer(logger: Logger): Hooks;
|
|
6
30
|
//# sourceMappingURL=tool-trace.d.ts.map
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { redactSecrets } from "../trace/redact.js";
|
|
2
|
+
/** The gate sources core's `PermissionDeniedPayload.source` documents today. It is an OPEN enum by
|
|
3
|
+
* contract (a future "timeout" etc. must not break consumers) — unknown values fold to "other" so the
|
|
4
|
+
* Prometheus label set stays bounded no matter what core adds. */
|
|
2
5
|
const KNOWN_DENY_SOURCES = new Set(["policy", "hook", "safety", "shellGate", "planMode"]);
|
|
6
|
+
/**
|
|
7
|
+
* ALWAYS-ON gate-deny meter (goal B4, 2026-07-08): `permission_denied_total{source}` — how often the
|
|
8
|
+
* adjudicate chain DENIES a tool call, by gate source. Deliberately SEPARATE from {@link createToolTracer}:
|
|
9
|
+
* the tracer is a default-OFF diagnostic (TOOL_TRACE=true), but deny frequency is an operational/security
|
|
10
|
+
* signal that must reach /metrics on every deployment — a spike in `source="policy"` means a task keeps
|
|
11
|
+
* asking for something the operator forbids; `source="safety"`/`"shellGate"` spikes flag risky-command
|
|
12
|
+
* pressure. main.ts composes this UNDER the tracer via composeHooks (both are void observers on the
|
|
13
|
+
* permissionDenied slot, which composeHooks double-runs deployment-first).
|
|
14
|
+
*/
|
|
3
15
|
export function createPermissionDeniedMeter(metrics) {
|
|
4
16
|
return {
|
|
5
17
|
permissionDenied(payload) {
|
|
@@ -7,6 +19,21 @@ export function createPermissionDeniedMeter(metrics) {
|
|
|
7
19
|
},
|
|
8
20
|
};
|
|
9
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* prove-before-scale stopgap (design/50): a no-op observer hook that logs every tool call (pre + post)
|
|
24
|
+
* to the worker log — INCLUDING resumed legs that `GET /v1/runs/:id/events` does NOT surface (the
|
|
25
|
+
* streaming-resume observability gap, service[15] API request #2). Gated by `TOOL_TRACE=true`; OFF by
|
|
26
|
+
* default (no prod noise).
|
|
27
|
+
*
|
|
28
|
+
* Why: a durable-HITL-gated coding task that keeps re-suspending is ambiguous from /events alone —
|
|
29
|
+
* could be a model restart-on-resume loop (the SAME tool re-issued each resume) or slow legit iteration.
|
|
30
|
+
* The pre-hook logs `{tool, id, arg:{path,contentLen,…}}` per call, so grepping `tool_trace` reconstructs
|
|
31
|
+
* the full sequence: a repeated `write_file path=X contentLen=Y` across resumes ⇒ restart-loop;
|
|
32
|
+
* write X → write Y → bash ⇒ iteration.
|
|
33
|
+
*
|
|
34
|
+
* Pure observation: every hook returns `undefined`, so it never rewrites args, never gates, never alters
|
|
35
|
+
* the result (and per core's hooks invariant a hook's `allow` can't bypass the policy gate anyway).
|
|
36
|
+
*/
|
|
10
37
|
export function createToolTracer(logger) {
|
|
11
38
|
return {
|
|
12
39
|
preToolUse(toolName, input, ctx) {
|
|
@@ -23,6 +50,10 @@ export function createToolTracer(logger) {
|
|
|
23
50
|
});
|
|
24
51
|
return undefined;
|
|
25
52
|
},
|
|
53
|
+
// core 1.252 (design/134) BREAKING: postToolUse and postToolUseFailure are MUTUALLY EXCLUSIVE — an
|
|
54
|
+
// isError result now fires ONLY this callback. Without it, every failed tool call silently vanished
|
|
55
|
+
// from the trace (the exact silent-fallback class this log exists to catch). Same line shape as the
|
|
56
|
+
// success path (phase "post", isError true) so existing `tool_trace` grep workflows keep working.
|
|
26
57
|
postToolUseFailure(toolName, _input, failure, ctx) {
|
|
27
58
|
logger.info("tool_trace", {
|
|
28
59
|
phase: "post",
|
|
@@ -35,6 +66,11 @@ export function createToolTracer(logger) {
|
|
|
35
66
|
});
|
|
36
67
|
return undefined;
|
|
37
68
|
},
|
|
69
|
+
// core 1.257: the gate's DENY short-circuit never reaches postToolUse* (the call
|
|
70
|
+
// doesn't execute), so denied calls were INVISIBLE to this trace — the exact observability hole
|
|
71
|
+
// asked about. `source` = core's adjudicate-chain enum (policy/hook/safety/shellGate/planMode); the
|
|
72
|
+
// deny `reason` can quote the adjudicated args (an approver's text, a policy message), so redact+clip
|
|
73
|
+
// like every other line. Same `tool_trace` key so existing grep workflows see denies in sequence.
|
|
38
74
|
permissionDenied(payload) {
|
|
39
75
|
logger.info("tool_trace", {
|
|
40
76
|
phase: "denied",
|
|
@@ -47,11 +83,15 @@ export function createToolTracer(logger) {
|
|
|
47
83
|
},
|
|
48
84
|
};
|
|
49
85
|
}
|
|
86
|
+
/** Compact, restart-diagnosable summary: key path/command fields + content length (not full content). */
|
|
50
87
|
function summarize(input) {
|
|
51
88
|
if (!input || typeof input !== "object")
|
|
52
89
|
return { v: clip(String(input), 120) };
|
|
53
90
|
const o = input;
|
|
54
91
|
const s = {};
|
|
92
|
+
// Redact secrets BEFORE clipping: a traced `command`/`old_string` (e.g. `curl -H "Authorization: Bearer …"`,
|
|
93
|
+
// an edited .env line) can carry credentials into the worker log → its aggregation pipeline. TOOL_TRACE is a
|
|
94
|
+
// default-off diagnostic, but 120 chars is enough to hold a full token, so mask it.
|
|
55
95
|
for (const k of ["path", "file_path", "command", "cmd", "pattern", "glob", "old_string", "new_string"]) {
|
|
56
96
|
if (typeof o[k] === "string")
|
|
57
97
|
s[k] = clip(redactSecrets(o[k]), 120);
|
|
@@ -65,7 +105,7 @@ function textOf(content) {
|
|
|
65
105
|
.map((c) => (c && typeof c === "object" && typeof c.text === "string" ? c.text : ""))
|
|
66
106
|
.join("")
|
|
67
107
|
.trim();
|
|
68
|
-
return clip(redactSecrets(text), 200);
|
|
108
|
+
return clip(redactSecrets(text), 200); // tool output can echo a cat'd secret/credential — mask before logging
|
|
69
109
|
}
|
|
70
110
|
function clip(s, n) {
|
|
71
111
|
return s.length > n ? `${s.slice(0, n)}…(${s.length})` : s;
|
|
@@ -1,24 +1,131 @@
|
|
|
1
1
|
import { type WorkflowScriptRunner, type WorkflowPrimitives } from "@sema-agent/core";
|
|
2
|
+
/**
|
|
3
|
+
* Hardened Node `vm` MEMBRANE for executing UNTRUSTED (LLM-authored / user-supplied) JavaScript, ported from
|
|
4
|
+
* the reference shell-host implementation's workflow sandbox and validated against core's
|
|
5
|
+
* `assertWorkflowSandboxConformance` battery + a beyond-battery boundary probe set + a 7-lens robustness suite
|
|
6
|
+
* (s8-sandbox-robustness: ctor/proto · error/stack · async/iter · reflect/proxy/symbol · marshal-bridge ·
|
|
7
|
+
* determinism · closure/cap). Two surfaces share ONE core ({@link runHardened}) so there is a single place to
|
|
8
|
+
* audit/fix:
|
|
9
|
+
* - {@link createHardenedVmRunner} — the S8 `WorkflowScriptRunner` (TOC+TOB workflow orchestration).
|
|
10
|
+
* - {@link runInHardenedVm} — general untrusted-code exec (TOC ephemeral execution sandbox).
|
|
11
|
+
*
|
|
12
|
+
* 🔴 Why a plain `vm` is NOT a boundary (and what makes THIS one):
|
|
13
|
+
* core's `devWorkflowScriptRunner` passes host primitives DIRECTLY into the context, so
|
|
14
|
+
* `agent.constructor.constructor("return process")()` reaches the HOST `Function` (host realm = code-gen
|
|
15
|
+
* unrestricted) → boundary crossing. The membrane closes that:
|
|
16
|
+
* 1. `createContext({__proto__:null}, {codeGeneration:{strings:false,wasm:false}})` — null-proto global,
|
|
17
|
+
* no eval / new Function / wasm INSIDE the context.
|
|
18
|
+
* 2. EVERY value the script touches is CONTEXT-LOCAL — each binding is re-wrapped by a function COMPILED
|
|
19
|
+
* IN THE CONTEXT (its `.constructor.constructor` is the context's inert `Function`); a raw host
|
|
20
|
+
* function/object/error NEVER reaches the script.
|
|
21
|
+
* 3. Data crossing INTO the script (args, bridged results) is marshalled context-local via JSON-in-context.
|
|
22
|
+
* 4. ERRORS from host fns are marshalled to a CONTEXT-LOCAL `Error` (the beyond-battery leak core's
|
|
23
|
+
* battery misses).
|
|
24
|
+
* 5. Data crossing INTO a host fn (bridged args) and OUT to the host caller (the result + meta) is
|
|
25
|
+
* sterilized of the `__proto__`/`constructor`/`prototype` tampering gadget ({@link scrubProtoDeep}) —
|
|
26
|
+
* the marshal-bridge boundary-crossing case — and marshalled to plain data (never a live cross-realm object
|
|
27
|
+
* carrying getter/toJSON/then traps).
|
|
28
|
+
*
|
|
29
|
+
* 🔴 SCOPE (v1, clay 2026-06-23): this is BOUNDARY isolation (no host-code readout / unintended host execution / cross-tenant credential
|
|
30
|
+
* reach / host prototype tampering) — VALIDATED. It is NOT full RESOURCE isolation: an in-process `vm`
|
|
31
|
+
* cannot hard-cap heap, so a runaway-allocation script can OOM the shared process (a resource-exhaustion issue, NOT a data-boundary issue). v1
|
|
32
|
+
* mitigates with caps (maxAgents + a wall-clock timeout + a per-sync-chunk vm timeout) + monitoring. For HARD
|
|
33
|
+
* heap/CPU isolation use {@link import("./hardened-vm-worker-runner.js").createWorkerHardenedVmRunner} — the
|
|
34
|
+
* SAME membrane in a worker_thread (resourceLimits + terminate). Single-tenant callers (e.g. a TOC run-local)
|
|
35
|
+
* can treat the in-process model as final, like the reference shell-host implementation does.
|
|
36
|
+
*
|
|
37
|
+
* 🔴 Known IN-PROCESS cap gap (resource-exhaustion, not boundary): the sync `vm` timeout kills a SYNCHRONOUS infinite loop, and
|
|
38
|
+
* the wall-clock race kills a script that yields to the MACROTASK queue (or awaits a stuck host fn). A pure
|
|
39
|
+
* MICROTASK-starvation loop (`while (true) { await null }`) starves the host event loop, so neither the host
|
|
40
|
+
* timer nor the abort listener fires → it hangs the process. The worker-isolated runner (`terminate()`)
|
|
41
|
+
* pre-empts that — use it for genuinely-untrusted multi-tenant scripts where resource isolation matters.
|
|
42
|
+
*
|
|
43
|
+
* 🔴 Silent-hang class ([1818]§二, clay live incident 2026-07-26): a script whose promise graph can NEVER settle
|
|
44
|
+
* (an un-awaited `phase(...)` whose body returns its own promise) used to burn the full totalTimeoutMs blind
|
|
45
|
+
* and then blame the timeout. The quiescence detector in {@link runHardened} fail-fasts it with a diagnosis:
|
|
46
|
+
* inside the membrane the bridge is the ONLY async host seam, so bridge-quiescent + both queues drained +
|
|
47
|
+
* scriptPromise pending is a PROOF of deadlock, not a heuristic. Sibling hazard, same incident review: an
|
|
48
|
+
* un-awaited IN-CONTEXT rejection shares the host isolate's unhandledRejection machinery (Node default =
|
|
49
|
+
* crash the process) — contained by {@link installScriptRealmRejectionGuard} (realm-keyed: script rejections
|
|
50
|
+
* are logged, host rejections keep fail-loud).
|
|
51
|
+
*/
|
|
2
52
|
export interface HardenedVmLimits {
|
|
53
|
+
/** Wall-clock cap on the whole run (covers async loops the sync `vm` timeout can't). Default 600_000. */
|
|
3
54
|
totalTimeoutMs?: number;
|
|
55
|
+
/** Per-synchronous-chunk `vm` timeout — bounds a synchronous infinite loop before the first await. Default 5_000. */
|
|
4
56
|
syncTimeoutMs?: number;
|
|
57
|
+
/** Hard cap on `agent()` spawns across a workflow run (runaway-fan-out backstop). Default 1000. */
|
|
5
58
|
maxAgents?: number;
|
|
59
|
+
/** Max concurrent in-flight calls the in-context parallel/pipeline pools allow. Default 12. */
|
|
6
60
|
concurrency?: number;
|
|
61
|
+
/** worker_thread heap cap in MB (only honored by the worker-isolated runner — see hardened-vm-worker-runner.ts).
|
|
62
|
+
* A script exceeding it OOMs the WORKER (killed), never the shared main process. Default 128. */
|
|
7
63
|
maxHeapMb?: number;
|
|
8
64
|
}
|
|
65
|
+
/** Optional observability hook for contained script-realm rejections (e.g. wire to the deployment logger). */
|
|
9
66
|
export declare function setScriptRealmRejectionObserver(observer: (summary: string) => void): void;
|
|
10
67
|
export declare function installScriptRealmRejectionGuard(): void;
|
|
68
|
+
/**
|
|
69
|
+
* The membrane handed to a surface's `buildGlobals` callback to construct the CONTEXT-LOCAL bindings the
|
|
70
|
+
* untrusted body will see. NEVER expose a raw host function/object to the script — route it through here.
|
|
71
|
+
*/
|
|
11
72
|
export interface HardenedMembrane {
|
|
73
|
+
/** Wrap a host async fn as a CONTEXT-LOCAL fn: args are sterilized in, the result is marshalled back
|
|
74
|
+
* context-local, a host throw becomes a context-local Error. This is the only safe way to give the script
|
|
75
|
+
* a host capability. */
|
|
12
76
|
bridge(hostFn: (...args: unknown[]) => unknown): (...a: unknown[]) => Promise<unknown>;
|
|
77
|
+
/** Marshal a host DATA value into a sterilized context-local value (for non-function bindings / args). */
|
|
13
78
|
dataIn(value: unknown): unknown;
|
|
79
|
+
/** Compile + evaluate a TRUSTED expression IN the context (e.g. to define in-context orchestration sugar).
|
|
80
|
+
* The source MUST be developer-authored, never untrusted input. */
|
|
14
81
|
ctxEval(trustedSource: string): unknown;
|
|
15
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* phases=[] ROOT CAUSE + fix — the SCOPED-PHASE GATE. The old in-context `phase` was pure sugar
|
|
85
|
+
* (log a "◆ phase" line, run the body) that NEVER called the host `primitives.phase`, so core recorded ZERO
|
|
86
|
+
* phase state: terminal rows had `phases: []` and agents carried no `phase` key (exactly the storage-row
|
|
87
|
+
* autopsy — agents fine, phase accounting gone). The membrane's JSON bridge cannot carry the script's BODY
|
|
88
|
+
* function across, so the bridge is split into three JSON-safe host calls, and the body stays IN-CONTEXT:
|
|
89
|
+
* - `mark(title)` → `primitives.phase(title, undefined)` (core's bare CC-marker path);
|
|
90
|
+
* - `enter(title)` → opens core's scoped phase with a DEFERRED body (`await gate`), returns a numeric token.
|
|
91
|
+
* core pushes the phase record + sets `currentPhase` SYNCHRONOUSLY before its first await, so by the time
|
|
92
|
+
* `enter` returns, `agent()` calls made inside the VM body land with the right phase label;
|
|
93
|
+
* - `exit(token, ok, err?)` → releases the gate (ok → core closes the phase `completed`; !ok → the deferred
|
|
94
|
+
* body throws and core closes it `failed`), then awaits core's settle so the close is persisted before the
|
|
95
|
+
* VM continues.
|
|
96
|
+
* A finalized-run `phase()` (core throws) surfaces on `enter` via the settled-race; an unknown/double `exit`
|
|
97
|
+
* is idempotent. The VM wrapper rethrows the body's own error — the gate's synthetic error never reaches the
|
|
98
|
+
* script.
|
|
99
|
+
*/
|
|
16
100
|
export declare function scopedPhaseGate(phase: WorkflowPrimitives["phase"]): {
|
|
17
101
|
enter(title: string): Promise<number>;
|
|
18
102
|
exit(token: number, ok: boolean, err?: string): Promise<void>;
|
|
19
103
|
};
|
|
104
|
+
/** Build the orchestration context-local globals (agent/parallel/pipeline/phase/log/budget/args) from the
|
|
105
|
+
* host {@link WorkflowPrimitives}. agent/log/phase are host-bridged (phase via the three-verb
|
|
106
|
+
* {@link scopedPhaseGate} — the body function itself never crosses the membrane); parallel/pipeline are
|
|
107
|
+
* in-context sugar; budget is a frozen null-proto object over host accessors.
|
|
108
|
+
* Exported so the worker-isolated runner (hardened-vm-worker.ts) reuses the EXACT same surface with
|
|
109
|
+
* IPC-backed primitives — one definition of the orchestration globals, no drift. */
|
|
20
110
|
export declare function orchestrationGlobals(primitives: WorkflowPrimitives, scriptArgs: unknown, limits?: HardenedVmLimits): (m: HardenedMembrane) => Record<string, unknown>;
|
|
111
|
+
/** Build the hardened-vm S8 `WorkflowScriptRunner` (TOC+TOB workflow orchestration). `safeForUntrustedScripts`
|
|
112
|
+
* is `true` — it has passed the conformance battery + robustness suite; the S8 gate mounts `run_workflow` only for
|
|
113
|
+
* a runner that asserts this. */
|
|
21
114
|
export declare function createHardenedVmRunner(limits?: HardenedVmLimits): WorkflowScriptRunner;
|
|
115
|
+
/**
|
|
116
|
+
* General untrusted-code exec on the SAME hardened membrane — the TOC ephemeral execution sandbox. Runs
|
|
117
|
+
* `code` (an async function body that may `return`) with ONLY the safe built-ins plus whatever host
|
|
118
|
+
* capabilities the caller bridges via `bindings` (each MUST go through `m.bridge` / `m.dataIn` — never a raw
|
|
119
|
+
* host reference). Returns the marshalled (plain, sterilized) result. With no `bindings`, the code is pure
|
|
120
|
+
* computation (no host reach at all).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const out = await runInHardenedVm({
|
|
124
|
+
* code: "return await fetchJson(args.url)",
|
|
125
|
+
* bindings: (m) => ({ fetchJson: m.bridge((u) => safeFetch(String(u))), args: m.dataIn({ url }) }),
|
|
126
|
+
* limits: { totalTimeoutMs: 5000 },
|
|
127
|
+
* });
|
|
128
|
+
*/
|
|
22
129
|
export declare function runInHardenedVm(opts: {
|
|
23
130
|
code: string;
|
|
24
131
|
bindings?: (m: HardenedMembrane) => Record<string, unknown>;
|