@sema-agent/server 1.323.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 +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
|
@@ -1,13 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory, TTL'd dedup cache keyed by an opaque string (an Idempotency-Key).
|
|
3
|
+
*
|
|
4
|
+
* - `run(key, produce, shouldCache?)` invokes `produce` at most once per key — concurrent and retried calls
|
|
5
|
+
* with the same key await the same promise — and retains a CACHEABLE resolution for `ttlMs` so a later retry
|
|
6
|
+
* replays it. A rejection (a thrown error billed nothing) or a caller-marked un-cacheable resolution (e.g. a
|
|
7
|
+
* transient 409) is evicted so a genuine retry re-runs.
|
|
8
|
+
* - `peek(key)` returns the cached (in-flight or settled) promise without producing — letting a caller
|
|
9
|
+
* short-circuit a retry BEFORE side gates (rate/quota), so the retry gets the same response, not a fresh 429.
|
|
10
|
+
* An SSE stream wraps its live run in `run()` so the in-flight promise is stored too; a retry then peeks it.
|
|
11
|
+
*
|
|
12
|
+
* Per-entry TTL is enforced on access (O(1)); abandoned keys are reclaimed by a sweep that runs only once the
|
|
13
|
+
* map grows past a threshold (no O(n) scan on the hot path). Single-threaded event-loop semantics: each HTTP
|
|
14
|
+
* request is its own task, so there is no get→set race within a tick.
|
|
15
|
+
*
|
|
16
|
+
* (Caller context: the sema-registry review gateway mints/echoes the Idempotency-Key and routes a given key to
|
|
17
|
+
* the same worker, so this PER-POD cache is the worker-side backstop against a retried submission re-running —
|
|
18
|
+
* and re-billing. Cross-pod / cross-restart exactly-once needs store-backing; the durable async /v1/runs path
|
|
19
|
+
* is the alternative for long tasks.)
|
|
20
|
+
*/
|
|
1
21
|
export declare class IdempotencyCache<T> {
|
|
2
22
|
private readonly ttlMs;
|
|
3
23
|
private readonly sweepThreshold;
|
|
4
24
|
private readonly entries;
|
|
5
25
|
constructor(ttlMs?: number, sweepThreshold?: number);
|
|
26
|
+
/** Live (un-expired) cached promise for a key, or undefined — without producing. */
|
|
6
27
|
peek(key: string): Promise<T> | undefined;
|
|
7
28
|
run(key: string | undefined, produce: () => Promise<T>, shouldCache?: (value: T) => boolean): Promise<T>;
|
|
8
29
|
get size(): number;
|
|
30
|
+
/** Return the cached promise if present AND within the TTL; drop it and return undefined if expired. */
|
|
9
31
|
private live;
|
|
32
|
+
/** Reclaim expired entries only once the map is large — avoids an O(n) scan on every call (council). */
|
|
10
33
|
private maybeSweep;
|
|
11
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Namespace an Idempotency-Key by the authenticated identity (BL-3). The dedup cache is one per process; keying
|
|
37
|
+
* it on the RAW client header let a different tenant (or anonymous caller) replaying the same key receive the
|
|
38
|
+
* FIRST caller's response and skip the rate/quota gates. Folding the credential-derived `source` + the
|
|
39
|
+
* `principal` into the key scopes a replay to the SAME caller only — cross-tenant collisions become cache
|
|
40
|
+
* misses (re-run, correctly attributed). `\x1f` (unit separator) can't occur in an HTTP header value, so the
|
|
41
|
+
* three fields can't be confused. undefined raw key → undefined (no dedup, unchanged).
|
|
42
|
+
*/
|
|
12
43
|
export declare function scopedIdempotencyKey(raw: string | undefined, source: string | null, principal: string | undefined): string | undefined;
|
|
13
44
|
//# sourceMappingURL=idempotency.d.ts.map
|
package/dist/http/idempotency.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory, TTL'd dedup cache keyed by an opaque string (an Idempotency-Key).
|
|
3
|
+
*
|
|
4
|
+
* - `run(key, produce, shouldCache?)` invokes `produce` at most once per key — concurrent and retried calls
|
|
5
|
+
* with the same key await the same promise — and retains a CACHEABLE resolution for `ttlMs` so a later retry
|
|
6
|
+
* replays it. A rejection (a thrown error billed nothing) or a caller-marked un-cacheable resolution (e.g. a
|
|
7
|
+
* transient 409) is evicted so a genuine retry re-runs.
|
|
8
|
+
* - `peek(key)` returns the cached (in-flight or settled) promise without producing — letting a caller
|
|
9
|
+
* short-circuit a retry BEFORE side gates (rate/quota), so the retry gets the same response, not a fresh 429.
|
|
10
|
+
* An SSE stream wraps its live run in `run()` so the in-flight promise is stored too; a retry then peeks it.
|
|
11
|
+
*
|
|
12
|
+
* Per-entry TTL is enforced on access (O(1)); abandoned keys are reclaimed by a sweep that runs only once the
|
|
13
|
+
* map grows past a threshold (no O(n) scan on the hot path). Single-threaded event-loop semantics: each HTTP
|
|
14
|
+
* request is its own task, so there is no get→set race within a tick.
|
|
15
|
+
*
|
|
16
|
+
* (Caller context: the sema-registry review gateway mints/echoes the Idempotency-Key and routes a given key to
|
|
17
|
+
* the same worker, so this PER-POD cache is the worker-side backstop against a retried submission re-running —
|
|
18
|
+
* and re-billing. Cross-pod / cross-restart exactly-once needs store-backing; the durable async /v1/runs path
|
|
19
|
+
* is the alternative for long tasks.)
|
|
20
|
+
*/
|
|
1
21
|
export class IdempotencyCache {
|
|
2
22
|
ttlMs;
|
|
3
23
|
sweepThreshold;
|
|
@@ -6,6 +26,7 @@ export class IdempotencyCache {
|
|
|
6
26
|
this.ttlMs = ttlMs;
|
|
7
27
|
this.sweepThreshold = sweepThreshold;
|
|
8
28
|
}
|
|
29
|
+
/** Live (un-expired) cached promise for a key, or undefined — without producing. */
|
|
9
30
|
peek(key) {
|
|
10
31
|
return this.live(key);
|
|
11
32
|
}
|
|
@@ -18,6 +39,9 @@ export class IdempotencyCache {
|
|
|
18
39
|
return hit;
|
|
19
40
|
const promise = produce();
|
|
20
41
|
this.entries.set(key, { at: Date.now(), promise });
|
|
42
|
+
// Evict on rejection (retry must re-run) and on a caller-marked un-cacheable resolution; keep only a
|
|
43
|
+
// cacheable success for the TTL. Handlers also avert an unhandled-rejection on the cached copy; the returned
|
|
44
|
+
// promise is the same object the caller awaits, so errors still surface to the caller.
|
|
21
45
|
promise.then((value) => {
|
|
22
46
|
if (!shouldCache(value))
|
|
23
47
|
this.entries.delete(key);
|
|
@@ -27,6 +51,7 @@ export class IdempotencyCache {
|
|
|
27
51
|
get size() {
|
|
28
52
|
return this.entries.size;
|
|
29
53
|
}
|
|
54
|
+
/** Return the cached promise if present AND within the TTL; drop it and return undefined if expired. */
|
|
30
55
|
live(key) {
|
|
31
56
|
const hit = this.entries.get(key);
|
|
32
57
|
if (!hit)
|
|
@@ -37,6 +62,7 @@ export class IdempotencyCache {
|
|
|
37
62
|
}
|
|
38
63
|
return hit.promise;
|
|
39
64
|
}
|
|
65
|
+
/** Reclaim expired entries only once the map is large — avoids an O(n) scan on every call (council). */
|
|
40
66
|
maybeSweep() {
|
|
41
67
|
if (this.entries.size < this.sweepThreshold)
|
|
42
68
|
return;
|
|
@@ -46,6 +72,14 @@ export class IdempotencyCache {
|
|
|
46
72
|
this.entries.delete(k);
|
|
47
73
|
}
|
|
48
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Namespace an Idempotency-Key by the authenticated identity (BL-3). The dedup cache is one per process; keying
|
|
77
|
+
* it on the RAW client header let a different tenant (or anonymous caller) replaying the same key receive the
|
|
78
|
+
* FIRST caller's response and skip the rate/quota gates. Folding the credential-derived `source` + the
|
|
79
|
+
* `principal` into the key scopes a replay to the SAME caller only — cross-tenant collisions become cache
|
|
80
|
+
* misses (re-run, correctly attributed). `\x1f` (unit separator) can't occur in an HTTP header value, so the
|
|
81
|
+
* three fields can't be confused. undefined raw key → undefined (no dedup, unchanged).
|
|
82
|
+
*/
|
|
49
83
|
export function scopedIdempotencyKey(raw, source, principal) {
|
|
50
84
|
return raw ? `${source ?? ""}\x1f${principal ?? ""}\x1f${raw}` : undefined;
|
|
51
85
|
}
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import type { IncomingMessage } from "node:http";
|
|
2
2
|
import type { ServiceConfig } from "../config-types.js";
|
|
3
|
+
/** Coerce a possibly-repeated request header to a single string (or undefined). */
|
|
3
4
|
export declare function headerStr(v: string | string[] | undefined): string | undefined;
|
|
4
5
|
export declare function safeEqual(a: string, b: string): boolean;
|
|
5
6
|
export declare function authorized(req: IncomingMessage, token: string): boolean;
|
|
7
|
+
/** Which SYSTEM credential authenticated this request (clay 2026-06-12: source must be credential-DERIVED,
|
|
8
|
+
* never self-declared). Returns the system name for a SERVICE_AUTH_TOKENS match; null for the legacy single
|
|
9
|
+
* SERVICE_AUTH_TOKEN (authenticated, no system identity); undefined = no valid service credential. */
|
|
6
10
|
export declare function systemFor(req: IncomingMessage, config: ServiceConfig): string | null | undefined;
|
|
11
|
+
/** "presented credentials must verify":Authorization 带 Bearer/token scheme 且三路全验不过 → true。
|
|
12
|
+
* 其他 scheme(Basic 等,非我方凭证空间)不管——由原有门语义处置,避免误伤未知代理注头。 */
|
|
7
13
|
export declare function bearerPresentedButUnverified(req: IncomingMessage, config: ServiceConfig): boolean;
|
|
8
14
|
export declare function gatedPrincipal(req: IncomingMessage, config: ServiceConfig): string | undefined;
|
|
15
|
+
/** The EXPLICIT operator gate (IMAGE-API-DESIGN.md §P2.4a MUST-FIX) — NOT the bare `isOperator` (whose empty-list
|
|
16
|
+
* "true-for-all" is a world-writable RCE door the instant OPERATOR_PRINCIPALS is empty). Requires a non-empty
|
|
17
|
+
* operator set AND a present principal IN it. The same form the preempt/resume endpoints already use. */
|
|
9
18
|
export declare function explicitOperatorOk(principal: string | undefined, operatorPrincipals: readonly string[]): boolean;
|
|
19
|
+
/** May `principal` act as an OPERATOR on the F4 approval queue? Empty `operatorPrincipals` = legacy
|
|
20
|
+
* behavior (the shared service token IS the operator boundary → everyone authenticated is an operator).
|
|
21
|
+
* Otherwise only listed principals are operators. */
|
|
10
22
|
export declare function isOperator(principal: string | undefined, operatorPrincipals: readonly string[]): boolean;
|
|
23
|
+
/** Operator check WITHOUT the empty-list "everyone is an operator" legacy fallback — an EMPTY `operatorPrincipals`
|
|
24
|
+
* yields `false` (no one is an operator). Use this where empty-operators-means-all would be a SECURITY hole rather
|
|
25
|
+
* than a back-compat convenience: image VISIBILITY scoping (a tenant-scoped image must not leak to every caller
|
|
26
|
+
* just because OPERATOR_PRINCIPALS is unset). Adversarial-review HIGH: `isOperator([], p)=true` made
|
|
27
|
+
* `latestPublished(..., {operator:true})` bypass tenant visibility for any caller on an operator-less deployment. */
|
|
11
28
|
export declare function explicitOperator(principal: string | undefined, operatorPrincipals: readonly string[]): boolean;
|
|
12
29
|
//# sourceMappingURL=principal-gate.d.ts.map
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 seam — credential/identity primitives, extracted VERBATIM out of `http/server.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Every per-domain route module needs `gatedPrincipal` (80 call sites in the old monolith), which pulls in
|
|
5
|
+
* `bearerPresentedButUnverified` → `systemFor` → `authorized` → `safeEqual`. They live here (a leaf that only
|
|
6
|
+
* depends on `node:*`, `../security.js` and the config TYPE) so `http/routes/*` never value-imports `server.ts`.
|
|
7
|
+
*
|
|
8
|
+
* Pure move: bodies are byte-identical to `server.ts:682/693/9310/9779/9789/9796`.
|
|
9
|
+
*/
|
|
1
10
|
import { timingSafeEqual } from "node:crypto";
|
|
2
11
|
import { verifiedPrincipal, ssoVerifiedPrincipal } from "../security.js";
|
|
12
|
+
/** Coerce a possibly-repeated request header to a single string (or undefined). */
|
|
3
13
|
export function headerStr(v) {
|
|
4
14
|
return Array.isArray(v) ? v[0] : v;
|
|
5
15
|
}
|
|
@@ -10,8 +20,13 @@ export function safeEqual(a, b) {
|
|
|
10
20
|
}
|
|
11
21
|
export function authorized(req, token) {
|
|
12
22
|
const h = req.headers.authorization ?? "";
|
|
23
|
+
// Constant-time compare so the service token can't be recovered byte-by-byte via response-timing (a plain
|
|
24
|
+
// `===` short-circuits on the first mismatching char). Length is allowed to leak (standard for this pattern).
|
|
13
25
|
return safeEqual(h, `Bearer ${token}`) || safeEqual(h, `token ${token}`);
|
|
14
26
|
}
|
|
27
|
+
/** Which SYSTEM credential authenticated this request (clay 2026-06-12: source must be credential-DERIVED,
|
|
28
|
+
* never self-declared). Returns the system name for a SERVICE_AUTH_TOKENS match; null for the legacy single
|
|
29
|
+
* SERVICE_AUTH_TOKEN (authenticated, no system identity); undefined = no valid service credential. */
|
|
15
30
|
export function systemFor(req, config) {
|
|
16
31
|
for (const [tok, system] of Object.entries(config.authTokens ?? {})) {
|
|
17
32
|
if (authorized(req, tok))
|
|
@@ -21,31 +36,48 @@ export function systemFor(req, config) {
|
|
|
21
36
|
return null;
|
|
22
37
|
return undefined;
|
|
23
38
|
}
|
|
39
|
+
/** "presented credentials must verify":Authorization 带 Bearer/token scheme 且三路全验不过 → true。
|
|
40
|
+
* 其他 scheme(Basic 等,非我方凭证空间)不管——由原有门语义处置,避免误伤未知代理注头。 */
|
|
24
41
|
export function bearerPresentedButUnverified(req, config) {
|
|
25
42
|
const h = req.headers.authorization;
|
|
26
43
|
if (typeof h !== "string" || !/^(Bearer|token) /i.test(h))
|
|
27
44
|
return false;
|
|
28
45
|
if (ssoVerifiedPrincipal(req))
|
|
29
|
-
return false;
|
|
46
|
+
return false; // registry JWT 已在入口预认证验过(签名真源)
|
|
30
47
|
if (systemFor(req, config) !== undefined)
|
|
31
|
-
return false;
|
|
48
|
+
return false; // service token(单一或 per-system)
|
|
32
49
|
if (config.traceToken && authorized(req, config.traceToken))
|
|
33
|
-
return false;
|
|
50
|
+
return false; // 只读 trace 凭证
|
|
34
51
|
return true;
|
|
35
52
|
}
|
|
36
53
|
export function gatedPrincipal(req, config) {
|
|
54
|
+
// 实测抓获的软鉴权:出示了 Bearer/token 凭证但验不过任何已知凭证(service token 单/多、
|
|
55
|
+
// traceToken、registry SSO-JWT)⇒ 无可信身份,绝不回退 spoofable principal 头——此前伪造凭证被静默忽略、
|
|
56
|
+
// 拿 principal 头的 owner 视图(200 空列表),会把轮换错配掩蔽成假健康。未出示凭证(纯 BFF 头姿势)不受
|
|
57
|
+
// 影响;POST 面在全局门后调用=凭证已验,语义不变。
|
|
37
58
|
if (bearerPresentedButUnverified(req, config))
|
|
38
59
|
return undefined;
|
|
39
60
|
return verifiedPrincipal(req, config);
|
|
40
61
|
}
|
|
62
|
+
/** The EXPLICIT operator gate (IMAGE-API-DESIGN.md §P2.4a MUST-FIX) — NOT the bare `isOperator` (whose empty-list
|
|
63
|
+
* "true-for-all" is a world-writable RCE door the instant OPERATOR_PRINCIPALS is empty). Requires a non-empty
|
|
64
|
+
* operator set AND a present principal IN it. The same form the preempt/resume endpoints already use. */
|
|
41
65
|
export function explicitOperatorOk(principal, operatorPrincipals) {
|
|
42
66
|
return operatorPrincipals.length > 0 && principal !== undefined && operatorPrincipals.includes(principal);
|
|
43
67
|
}
|
|
68
|
+
/** May `principal` act as an OPERATOR on the F4 approval queue? Empty `operatorPrincipals` = legacy
|
|
69
|
+
* behavior (the shared service token IS the operator boundary → everyone authenticated is an operator).
|
|
70
|
+
* Otherwise only listed principals are operators. */
|
|
44
71
|
export function isOperator(principal, operatorPrincipals) {
|
|
45
72
|
if (operatorPrincipals.length === 0)
|
|
46
73
|
return true;
|
|
47
74
|
return principal !== undefined && operatorPrincipals.includes(principal);
|
|
48
75
|
}
|
|
76
|
+
/** Operator check WITHOUT the empty-list "everyone is an operator" legacy fallback — an EMPTY `operatorPrincipals`
|
|
77
|
+
* yields `false` (no one is an operator). Use this where empty-operators-means-all would be a SECURITY hole rather
|
|
78
|
+
* than a back-compat convenience: image VISIBILITY scoping (a tenant-scoped image must not leak to every caller
|
|
79
|
+
* just because OPERATOR_PRINCIPALS is unset). Adversarial-review HIGH: `isOperator([], p)=true` made
|
|
80
|
+
* `latestPublished(..., {operator:true})` bypass tenant visibility for any caller on an operator-less deployment. */
|
|
49
81
|
export function explicitOperator(principal, operatorPrincipals) {
|
|
50
82
|
return operatorPrincipals.length > 0 && principal !== undefined && operatorPrincipals.includes(principal);
|
|
51
83
|
}
|
package/dist/http/route-ctx.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 — 路由域装配缝(`handle()` 按路由域拆多文件 + 装配器)。
|
|
3
|
+
*
|
|
4
|
+
* `createHttpServer` 建**一次** `RouteCtxBase`(deps/registry/helpers/local 四格),`handle()` 每请求把它
|
|
5
|
+
* 加上一格 `req`(每请求局部量)交给按序尝试的域表。域模块只从这里取自己那份窄切片,**在函数首行解构**
|
|
6
|
+
* (`const { deps } = ctx;` / `const { readJson } = ctx.helpers;`)——于是搬过去的路由体逐字不变。
|
|
7
|
+
*
|
|
8
|
+
* 「已处理」语义:域入口 `handle<Domain>(req, res, url, ctx): Promise<boolean>`,true=本域已应答(调用方
|
|
9
|
+
* 立即 return),false=没匹配上、继续下一个域。实现姿势见 routes/*.ts:路由体原样放进一个返回 void 的
|
|
10
|
+
* 内层函数,函数尾把 `miss.fell = true`——原来的每一个裸 `return;` 于是天然等价于「已处理」,一处都不用改写
|
|
11
|
+
* (嵌套闭包里的 `return;` 语义也原样保住)。
|
|
12
|
+
*
|
|
13
|
+
* 分层:routes/* 只许值 import http/ 的叶子(send.ts / principal-gate.ts / route-ctx.ts / tar.ts …)与 src 下
|
|
14
|
+
* 的普通模块,**绝不可值 import server.ts**——那条边会闭合运行时装载环(test/module-cycle-gate.test.ts)。
|
|
15
|
+
* 本文件对 server.ts 的引用一律 `import type`(tsc 擦除,非装载边)。
|
|
16
|
+
*/
|
|
1
17
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
18
|
import type { TaskStream, TaskSpec, TaskResult, QuestionAnswer, CheckpointToken, ResumeOutcome } from "@sema-agent/core";
|
|
3
19
|
import type { FlatServiceDeps, RequestAuth } from "./server.js";
|
|
@@ -6,6 +22,7 @@ import type { IdempotencyCache } from "./idempotency.js";
|
|
|
6
22
|
import type { ImagesLocal } from "./routes/images.js";
|
|
7
23
|
import type { SessionsLocal } from "./routes/sessions.js";
|
|
8
24
|
import type { SessionSyncLocal } from "./routes/session-sync.js";
|
|
25
|
+
/** 跨域可变状态 = lens1 §C2 实测的那 8 条「运行期登记簿」,一个对象。 */
|
|
9
26
|
export interface RunRegistry {
|
|
10
27
|
idemCache: IdempotencyCache<{
|
|
11
28
|
status: number;
|
|
@@ -16,11 +33,13 @@ export interface RunRegistry {
|
|
|
16
33
|
cancelledViaVerb: Set<string>;
|
|
17
34
|
steerableRuns: Map<string, TaskStream>;
|
|
18
35
|
wakeParkMints: Map<string, Promise<void>>;
|
|
36
|
+
/** 裸 number 的登记簿(`let` 拆不出闭包)—— 装进盒子才能跨模块自增/自减。 */
|
|
19
37
|
counters: {
|
|
20
38
|
uncountedBillableInflight: number;
|
|
21
39
|
admittedInflight: number;
|
|
22
40
|
};
|
|
23
41
|
}
|
|
42
|
+
/** 跨 ≥5 域的无状态助手(依赖只有 deps/config),外加同族的体读取器与 owner 门。 */
|
|
24
43
|
export interface RouteHelpers {
|
|
25
44
|
readJson(req: IncomingMessage): Promise<unknown>;
|
|
26
45
|
readRawBody(req: IncomingMessage, max: number): Promise<Buffer>;
|
|
@@ -42,17 +61,27 @@ export interface RouteHelpers {
|
|
|
42
61
|
sessionId: string | null;
|
|
43
62
|
}, face: string, notFoundError?: string): boolean;
|
|
44
63
|
}
|
|
64
|
+
/** 单域独占状态(lens1 实测 12 条)——不进 registry,跟着各自的域模块走;每个 server 实例一份
|
|
65
|
+
* (模块级会把 rate-limiter / 缓存跨实例串味,测试里一个进程建几十个 server)。 */
|
|
45
66
|
export interface RouteLocals {
|
|
46
67
|
images: ImagesLocal;
|
|
47
68
|
sessions: SessionsLocal;
|
|
48
69
|
sessionSync: SessionSyncLocal;
|
|
49
70
|
}
|
|
71
|
+
/** 每请求局部量里**跨域**的那几个(lens1 §C2:record 的日志闩 + tasks/stream 写、prelude 读的两个)。 */
|
|
50
72
|
export interface RouteRequestState {
|
|
51
73
|
streamTaskId: string | undefined;
|
|
52
74
|
streamDetached: boolean;
|
|
75
|
+
/** 凭证派生的调用方系统身份(`source`)。handle() 的鉴权门是**唯一**赋值点,域模块只读。 */
|
|
53
76
|
source: string | null;
|
|
54
77
|
}
|
|
78
|
+
/** 提交/续跑「腿」= 跨域共享的**有状态**长流程(不像 {@link RouteHelpers} 那样只依赖 deps/config:它们要写
|
|
79
|
+
* run log、发 fleet 帧、走 markResuming CAS、驱动模型)。A9 上批的停点就在这里——tasks/runs 两域共用
|
|
80
|
+
* `prepareSpec`,approvals/assistant/notify-wake 三域共用 resume 家族,把它们跟着任一域搬都会造出
|
|
81
|
+
* routes/* 互相值 import 的第二条环。做法:留在 `createHttpServer` 闭包里(实现逐字不动),只把**函数引用**
|
|
82
|
+
* 装进这一格,域模块经 `ctx.legs.*` 调用。类型化 ⇒ 腿的形漂了是编译红,不是运行时静默 404。 */
|
|
55
83
|
export interface RouteLegs {
|
|
84
|
+
/** POST /v1/tasks · /v1/tasks/stream · /v1/runs 的共同前段:读体 → 校验 → resolveSpec。null = 已应答(400/…)。 */
|
|
56
85
|
prepareSpec(req: IncomingMessage, res: ServerResponse): Promise<{
|
|
57
86
|
spec: TaskSpec;
|
|
58
87
|
auth?: RequestAuth;
|
|
@@ -64,11 +93,14 @@ export interface RouteLegs {
|
|
|
64
93
|
jobId?: string;
|
|
65
94
|
body: TaskRequestBody;
|
|
66
95
|
} | null>;
|
|
96
|
+
/** 同步腿的终局记账(计费/配额/指标),tasks 域用。 */
|
|
67
97
|
finalizeTaskResult(result: TaskResult, principal: string | undefined, objective: string, sessionId: string | undefined): void;
|
|
98
|
+
/** approvals 决策腿:session → pending checkpoint → markResuming CAS → 驱动续跑。 */
|
|
68
99
|
resumeCheckpoint(sessionId: string, decision: "approve" | "deny", reason: string | undefined, req?: IncomingMessage, answer?: QuestionAnswer, binding?: DecideBinding, onResumeCommitted?: (overrideSessionId?: string) => Promise<void>): Promise<{
|
|
69
100
|
status: number;
|
|
70
101
|
body: object;
|
|
71
102
|
}>;
|
|
103
|
+
/** 全 resume 家族的共同下半场(lease admission + 写 run log + fleet 发布)。 */
|
|
72
104
|
driveResumeIntoRunLog(args: {
|
|
73
105
|
token: CheckpointToken;
|
|
74
106
|
sessionId: string;
|
|
@@ -86,14 +118,17 @@ export interface RouteLegs {
|
|
|
86
118
|
status: number;
|
|
87
119
|
body: object;
|
|
88
120
|
}>;
|
|
121
|
+
/** assistant 抢占腿的复位(gate-kind 守卫 + 驱动)。 */
|
|
89
122
|
resumePreempted(sessionId: string, req: IncomingMessage | undefined): Promise<{
|
|
90
123
|
status: number;
|
|
91
124
|
body: object;
|
|
92
125
|
}>;
|
|
126
|
+
/** notify-wake 域:唤醒一条 parked checkpoint。 */
|
|
93
127
|
resumeWake(sessionId: string, message: string | undefined, caller: string | undefined, req: IncomingMessage | undefined): Promise<{
|
|
94
128
|
status: number;
|
|
95
129
|
body: object;
|
|
96
130
|
}>;
|
|
131
|
+
/** assistant plan_review 三态腿。 */
|
|
97
132
|
resumePlanReview(sessionId: string, decision: "approve" | "edit" | "reject", editedPlan: string | undefined, reason: string | undefined, req: IncomingMessage | undefined): Promise<{
|
|
98
133
|
status: number;
|
|
99
134
|
body: object;
|
|
@@ -110,6 +145,7 @@ export interface RouteCtx extends RouteCtxBase {
|
|
|
110
145
|
req: RouteRequestState;
|
|
111
146
|
}
|
|
112
147
|
export type RouteHandler = (req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx) => Promise<boolean>;
|
|
148
|
+
/** 域实现的收尾闩:见文件头「已处理」语义。 */
|
|
113
149
|
export interface RouteMiss {
|
|
114
150
|
fell: boolean;
|
|
115
151
|
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— 人在环审批面(durable F4 + legacy)与 assistant-scheduler 三动词。
|
|
3
|
+
*
|
|
4
|
+
* 路由(前缀 `/v1/approvals` 与 `/v1/assistant`):
|
|
5
|
+
* · durable 腿(接了 checkpointStore 时优先):list / stream(SSE 原生推送)/ decide|answer / preempt /
|
|
6
|
+
* resume / plan_review;
|
|
7
|
+
* · legacy 腿(仅 approvalStore):list / by-id / decide —— 直连门部署下**必须**打不到(fail closed)。
|
|
8
|
+
*
|
|
9
|
+
* 所有会**烧模型**的续跑都经 `ctx.legs.*`(resumeCheckpoint / resumePreempted / resumePlanReview)走 resume
|
|
10
|
+
* 家族的同一条腿:lease admission、markResuming CAS、写 run log、发 fleet 帧都在腿里,本域只做入站鉴权/形状门。
|
|
11
|
+
* 本域零可变状态(抢占登记簿 `preemptableRuns` 属跨域 registry)。
|
|
12
|
+
*/
|
|
1
13
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
14
|
import type { QuestionAnswer } from "@sema-agent/core";
|
|
3
15
|
import type { CheckpointStoreFull } from "../../plugins/store-backend.js";
|
|
@@ -5,7 +17,20 @@ import type { RouteCtx } from "../route-ctx.js";
|
|
|
5
17
|
export declare const ASSISTANT_PREEMPT_RE: RegExp;
|
|
6
18
|
export declare const ASSISTANT_RESUME_RE: RegExp;
|
|
7
19
|
export declare const ASSISTANT_PLAN_REVIEW_RE: RegExp;
|
|
20
|
+
/** Structural check for an operator-supplied QuestionAnswer (durable ask resume, TC-5.4). Strict on the
|
|
21
|
+
* load-bearing shape — `answers[]` non-empty, each `{header: string, selected: string[], note?: string}` —
|
|
22
|
+
* so a typo'd payload fails the request instead of resuming the task with an answer the tool can't use. */
|
|
8
23
|
export declare function isQuestionAnswer(v: unknown): v is QuestionAnswer;
|
|
9
24
|
export declare function handleApprovalsAssistant(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* GET /v1/approvals/stream (design/80 native push): SSE — pushes pending-approval deltas so the portal
|
|
27
|
+
* SUBSCRIBES ONCE instead of polling GET /v1/approvals every ~10s (better UX: near-real-time + no client poll
|
|
28
|
+
* loop). Polls listPending(scope) and diffs against the prior snapshot: `pending` for a new suspend, `resolved`
|
|
29
|
+
* for a decided/expired/gone one. Cross-replica BY CONSTRUCTION — the poll reads the SHARED checkpoint table,
|
|
30
|
+
* so a suspend on ANY replica is seen by an operator streaming on a DIFFERENT replica. A transient DB blip
|
|
31
|
+
* heartbeats + retries (never kills the stream); a 15-min cap + req-close end it (parity with streamTaskTrace).
|
|
32
|
+
* Poll-granularity caveat: a pending that resolves AND re-suspends on the same (session,toolCallId) within one
|
|
33
|
+
* interval shows no delta — acceptable (the live snapshot is always eventually correct; no decision is missed).
|
|
34
|
+
*/
|
|
10
35
|
export declare function streamApprovals(req: IncomingMessage, res: ServerResponse, cs: Pick<CheckpointStoreFull, "listPending">, scope: string | undefined, pollMs?: number): Promise<void>;
|
|
11
36
|
//# sourceMappingURL=approvals-assistant.d.ts.map
|