@sema-agent/server 1.323.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot/budget-tracing.d.ts +48 -0
- package/dist/boot/budget-tracing.js +86 -0
- package/dist/boot/config-center.d.ts +62 -0
- package/dist/boot/config-center.js +995 -0
- package/dist/boot/coordinators.d.ts +33 -0
- package/dist/boot/coordinators.js +97 -0
- package/dist/boot/execution-env.d.ts +26 -0
- package/dist/boot/execution-env.js +370 -0
- package/dist/boot/leader.d.ts +27 -0
- package/dist/boot/leader.js +81 -0
- package/dist/boot/reapers.d.ts +53 -0
- package/dist/boot/reapers.js +252 -0
- package/dist/boot/resolve-spec.d.ts +70 -0
- package/dist/boot/resolve-spec.js +1072 -0
- package/dist/boot/runner-deps.d.ts +101 -0
- package/dist/boot/runner-deps.js +343 -0
- package/dist/boot/runtime-caps.d.ts +21 -0
- package/dist/boot/runtime-caps.js +62 -0
- package/dist/boot/session-faces.d.ts +57 -0
- package/dist/boot/session-faces.js +157 -0
- package/dist/boot/shutdown.d.ts +50 -0
- package/dist/boot/shutdown.js +129 -0
- package/dist/boot/stores.d.ts +32 -0
- package/dist/boot/stores.js +361 -0
- package/dist/boot/workflow-orchestration.d.ts +46 -0
- package/dist/boot/workflow-orchestration.js +150 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +585 -1
- package/dist/config.d.ts +78 -2
- package/dist/config.js +874 -301
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +530 -2129
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +58 -2
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— v2 leader 端点(design/50)。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`POST /v1/leader`(异步,形同 `/v1/runs`)· `GET /v1/leader/:id`。整域由 `deps.leaderEndpoint`
|
|
5
|
+
* 的存在与否开关;身份层与 `/v1/runs` 同款(BL-4:此前整条路绕过 authorize/requirePrincipal 且不记 owner,
|
|
6
|
+
* 任何持服务令牌者能提交/读任意租户的 leader run),owner 用 crypto 验证过的 `gatedPrincipal`。本域零可变状态。
|
|
7
|
+
*/
|
|
1
8
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
9
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
10
|
export declare function handleLeader(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -5,13 +5,23 @@ export async function handleLeader(req, res, url, ctx) {
|
|
|
5
5
|
await handleLeaderBody(req, res, url, ctx, miss);
|
|
6
6
|
return !miss.fell;
|
|
7
7
|
}
|
|
8
|
+
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。
|
|
9
|
+
* 注意本域的落空语义:`deps.leaderEndpoint` 在但 URL 不匹配、或 endpoint 返回 undefined,都要**继续**
|
|
10
|
+
* 往下走(原文的 if 块不 return),故只有真的应答过才算已处理——由末尾的 `miss.fell` 如实表达。 */
|
|
8
11
|
async function handleLeaderBody(req, res, url, ctx, miss) {
|
|
9
12
|
const { deps } = ctx;
|
|
10
13
|
const { readJson, rateLimited, quotaExceeded, leaseDenied } = ctx.helpers;
|
|
14
|
+
// v2 leader endpoint (design/50): POST /v1/leader (async, like /v1/runs) + GET /v1/leader/:id.
|
|
11
15
|
if (deps.leaderEndpoint) {
|
|
12
16
|
const isLeaderPost = req.method === "POST" && url === "/v1/leader";
|
|
13
17
|
const isLeaderGet = req.method === "GET" && /^\/v1\/leader\/[^/]+$/.test(url);
|
|
14
18
|
if (isLeaderPost || isLeaderGet) {
|
|
19
|
+
// BL-4: gate the leader route through the SAME identity layer as /v1/runs — previously it skipped
|
|
20
|
+
// authorize/requirePrincipal entirely and recorded no owner, so any service-token holder could submit
|
|
21
|
+
// and read ANY tenant's leader run. Enforce requirePrincipal (401 before any work), then pass the
|
|
22
|
+
// resolved principal so the endpoint records it as the run owner (POST) and 404s non-owners (GET).
|
|
23
|
+
// 🔴 F-fix: VERIFIED identity (gatedPrincipal) for the leader-run owner — a spoofable header would let a
|
|
24
|
+
// direct-door caller submit/read another tenant's leader run (the recorded owner gates the GET 404).
|
|
15
25
|
if (deps.config.requirePrincipal && !gatedPrincipal(req, deps.config)) {
|
|
16
26
|
sendError(res, 401, "auth.principal_required", `missing principal header '${deps.config.principalHeader}'`);
|
|
17
27
|
return;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— memory 导出/同步 + 只读策略面。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`GET /v1/memory/export`、`POST /v1/memory/sync/:scope`、`GET /v1/policy`。
|
|
5
|
+
* owner 门 = 「本人 user scope 或显式 operator」,越界一律 404(零存在性 oracle)。本域零可变状态。
|
|
6
|
+
*/
|
|
1
7
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
8
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
9
|
export declare function handleMemoryPolicy(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -7,11 +7,25 @@ export async function handleMemoryPolicy(req, res, url, ctx) {
|
|
|
7
7
|
await handleMemoryPolicyBody(req, res, url, ctx, miss);
|
|
8
8
|
return !miss.fell;
|
|
9
9
|
}
|
|
10
|
+
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
|
|
11
|
+
* 的语义原样 =「本域已应答」;走到函数尾才是「没匹配上」,置 `miss.fell` 交回装配器继续下一个域。
|
|
12
|
+
* 跨域的东西(deps / 助手 / 单域状态)一律在首行解构出来,于是下面每一行都逐字不变。 */
|
|
10
13
|
async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
11
14
|
const { deps } = ctx;
|
|
12
15
|
const { readJson } = ctx.helpers;
|
|
16
|
+
// 142-S5 §1.4 — GET /v1/memory/export?scope=<key>: per-scope memory export (传输中立包=条目全量数组;
|
|
17
|
+
// C-additive 落点). After the global service-credential gate (a credential/SSO-JWT is already
|
|
18
|
+
// verified); the OWNER gate here is the tenant boundary: the verified principal may export exactly its OWN
|
|
19
|
+
// user disk (`scope === formatUserScope(principal)` — core's mint, byte-identical to memoryScopeFor's) or be
|
|
20
|
+
// an explicit operator (explicitOperatorOk, ops/migration face). Anything else = 404, NEVER 403 (zero
|
|
21
|
+
// existence oracle, run/trace owner-gate parity). org:*/userproj:* membership waits for the S3 登记簿
|
|
22
|
+
// (design §1.4) — until then those keys are operator-only by construction. proj:* keys of repo-backed
|
|
23
|
+
// projects never live in this DB (铁律: git is their authority) — an owner asking for one just gets
|
|
24
|
+
// an empty set, honestly.
|
|
13
25
|
if (url === "/v1/memory/export" && req.method === "GET") {
|
|
14
|
-
|
|
26
|
+
// Auth BEFORE availability (501-before-auth precedent): the backend posture must not oracle
|
|
27
|
+
// to a caller who couldn't read anything anyway.
|
|
28
|
+
const principal = gatedPrincipal(req, deps.config); // direct-door safe: verified identity, never the spoofable header
|
|
15
29
|
if (!principal) {
|
|
16
30
|
sendError(res, 401, "auth.unauthorized", "unauthorized");
|
|
17
31
|
return;
|
|
@@ -20,13 +34,13 @@ async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
|
20
34
|
sendError(res, 501, "capability.memory_store_required", "memory export requires a DB memory backend (MEMORY_ENGINE_BACKEND=pg|tidb)");
|
|
21
35
|
return;
|
|
22
36
|
}
|
|
23
|
-
const scope = new URL(req.url ?? "", "http://x").searchParams.get("scope");
|
|
37
|
+
const scope = new URL(req.url ?? "", "http://x").searchParams.get("scope"); // route-level `url` is query-stripped
|
|
24
38
|
if (!scope) {
|
|
25
39
|
sendError(res, 400, "request.query_invalid", "missing ?scope=<key>");
|
|
26
40
|
return;
|
|
27
41
|
}
|
|
28
42
|
if (scope !== formatUserScope(principal) && !explicitOperatorOk(principal, deps.config.operatorPrincipals)) {
|
|
29
|
-
sendError(res, 404, "not_found.memory_scope", "not found");
|
|
43
|
+
sendError(res, 404, "not_found.memory_scope", "not found"); // owner gate: no existence oracle
|
|
30
44
|
return;
|
|
31
45
|
}
|
|
32
46
|
try {
|
|
@@ -39,8 +53,14 @@ async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
|
39
53
|
}
|
|
40
54
|
return;
|
|
41
55
|
}
|
|
56
|
+
// 142-S2.5 — POST /v1/memory/sync/:scope: the central-side sync face(设计 §2.5;裁定
|
|
57
|
+
// plan 随数据走——reconcile/nextSyncBaseline 是 core 纯函数,由持数据的本 server 在 performMemorySync
|
|
58
|
+
// (memory-sync.ts) 里直接调用;此处只持 HTTP 半场). Gate ORDER mirrors the export face verbatim:
|
|
59
|
+
// auth (401) → backend posture (501, file 形态诚实拒绝——单用户 file 面自己就是 TOC 侧,没有中心
|
|
60
|
+
// 权威半场可服务) → owner gate (404 zero-oracle: verified principal 的 user 盘逐字匹配,或 explicit
|
|
61
|
+
// operator;org:/userproj: 键在 S3 登记簿前 = operator-only by construction) → 验型 (422 typed)。
|
|
42
62
|
if (req.method === "POST" && url.startsWith("/v1/memory/sync/")) {
|
|
43
|
-
const principal = gatedPrincipal(req, deps.config);
|
|
63
|
+
const principal = gatedPrincipal(req, deps.config); // direct-door safe: verified identity, never the spoofable header
|
|
44
64
|
if (!principal) {
|
|
45
65
|
sendError(res, 401, "auth.unauthorized", "unauthorized");
|
|
46
66
|
return;
|
|
@@ -49,6 +69,8 @@ async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
|
49
69
|
sendError(res, 501, "capability.memory_store_required", "memory sync requires a DB memory backend (MEMORY_ENGINE_BACKEND=pg|tidb)");
|
|
50
70
|
return;
|
|
51
71
|
}
|
|
72
|
+
// :scope rides the path percent-encoded (scope keys carry `:`/`@`/`/`); route-level `url` is
|
|
73
|
+
// query-stripped but NOT decoded. A malformed escape is a client error, typed 400.
|
|
52
74
|
let scope;
|
|
53
75
|
try {
|
|
54
76
|
scope = decodeURIComponent(url.slice("/v1/memory/sync/".length));
|
|
@@ -62,10 +84,10 @@ async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
|
62
84
|
return;
|
|
63
85
|
}
|
|
64
86
|
if (scope !== formatUserScope(principal) && !explicitOperatorOk(principal, deps.config.operatorPrincipals)) {
|
|
65
|
-
sendError(res, 404, "not_found.memory_scope", "not found");
|
|
87
|
+
sendError(res, 404, "not_found.memory_scope", "not found"); // owner gate: no existence oracle (export-face parity)
|
|
66
88
|
return;
|
|
67
89
|
}
|
|
68
|
-
const body = await readJson(req);
|
|
90
|
+
const body = await readJson(req); // 413/400 (oversize / bad JSON) via the typed top-level catch — auth already done
|
|
69
91
|
const parsed = parseMemorySyncRequest(body, scope);
|
|
70
92
|
if (!parsed.ok) {
|
|
71
93
|
sendError(res, 422, "memory_sync_invalid_body", parsed.error, { code: "memory_sync_invalid_body" });
|
|
@@ -76,12 +98,22 @@ async function handleMemoryPolicyBody(req, res, url, ctx, miss) {
|
|
|
76
98
|
sendJson(res, 200, out);
|
|
77
99
|
}
|
|
78
100
|
catch (err) {
|
|
101
|
+
// applyPatches 可能已落库而 putCursor 失败——500 是诚实信号:客户端按同一 baseRevs 重放即
|
|
102
|
+
// 幂等自愈(identical revs 全程 no-op),绝不静默吞。
|
|
79
103
|
deps.logger?.warn?.("memory_sync_failed", { scope, peer: parsed.value.peer, err: String(err) });
|
|
80
104
|
sendError(res, 500, "internal.error", "memory sync failed");
|
|
81
105
|
}
|
|
82
106
|
return;
|
|
83
107
|
}
|
|
108
|
+
// Effective server-enforced governance (CLI /permissions + /auto-mode). READ-only — a cloud
|
|
109
|
+
// supervisor shell CANNOT change server-side gating (the CLI's "permission modes" are tighten-only client
|
|
110
|
+
// cosmetics; the authoritative policy lives here, applied live in resolveSpec). Worker-global config (same for
|
|
111
|
+
// every principal), non-secret config surface like /v1/capabilities, so a principal is OPTIONAL (only enforced
|
|
112
|
+
// under REQUIRE_PRINCIPAL). Lets the client render the REAL autonomy band + command rules instead of fabricated ones.
|
|
84
113
|
if (url === "/v1/policy" && req.method === "GET") {
|
|
114
|
+
// F-fix: gatedPrincipal (VERIFIED) for the presence gate — on a direct door the legit caller authenticates by
|
|
115
|
+
// JWT (no x-agent-principal header), so a `principalFrom` gate would 401 a valid reader. Worker-global config
|
|
116
|
+
// (no per-tenant leak either way); the correctness/consistency twin of the run-owner gates. (BFF/gated: same.)
|
|
85
117
|
const principal = gatedPrincipal(req, deps.config);
|
|
86
118
|
if (deps.config.requirePrincipal && !principal) {
|
|
87
119
|
sendError(res, 401, "auth.principal_required", `missing principal header '${deps.config.principalHeader}'`);
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— 会话外事件注入 / 唤醒(design/144 §2 §3)。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`POST /v1/sessions/:id/notify`(external-notification-bridge 的 HTTP 入站门:live 走 core
|
|
5
|
+
* `TaskStream.notify()`,idle 走 inbox park,下次开流 drain)、`POST /v1/sessions/:id/wake`(对 task_done
|
|
6
|
+
* 纯 park 的「消息唤醒」——非门决策,不 allow/deny 任何 pending 动作)。
|
|
7
|
+
*
|
|
8
|
+
* wake 会**烧模型**(续跑),所以它经 `ctx.legs.resumeWake` 复用 resume 家族的同一条腿(lease/CAS/写 run log
|
|
9
|
+
* 都在腿里),而不是在本域自建第二条驱动路径。本域零可变状态。
|
|
10
|
+
*/
|
|
1
11
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
12
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
13
|
export declare function handleNotifyWake(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -6,11 +6,17 @@ export async function handleNotifyWake(req, res, url, ctx) {
|
|
|
6
6
|
await handleNotifyWakeBody(req, res, url, ctx, miss);
|
|
7
7
|
return !miss.fell;
|
|
8
8
|
}
|
|
9
|
+
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
|
|
10
|
+
* = 「本域已应答」;走到函数尾才是「没匹配上」。跨域的东西一律在首行解构出来。 */
|
|
9
11
|
async function handleNotifyWakeBody(req, res, url, ctx, miss) {
|
|
10
12
|
const { deps } = ctx;
|
|
11
13
|
const { steerableRuns } = ctx.registry;
|
|
12
14
|
const { readJson, rateLimited, quotaExceeded, leaseDenied } = ctx.helpers;
|
|
13
15
|
const { resumeWake } = ctx.legs;
|
|
16
|
+
// design/144 §2 server 半场(external-notification-bridge 的 HTTP 入站门):把「会话外事件」
|
|
17
|
+
// (daemon job 终态等)注入目标 session。live(本副本活流)→ core `TaskStream.notify()`(task_type=
|
|
18
|
+
// "external" core 铸造,sanitize/围栏/三态投递全在 core);idle → inbox park(external 独立键域,
|
|
19
|
+
// [769]① 防预占)→ 下次开流 drain。帧契约=[446] bg_notification 同族。入站鉴权在此(core 只管注入段)。
|
|
14
20
|
if (req.method === "POST" && /^\/v1\/sessions\/[^/]+\/notify$/.test(url)) {
|
|
15
21
|
if (rateLimited(req, res) || quotaExceeded(req, res))
|
|
16
22
|
return;
|
|
@@ -53,11 +59,13 @@ async function handleNotifyWakeBody(req, res, url, ctx, miss) {
|
|
|
53
59
|
sendError(res, 400, "request.field_invalid", "source must be a string of at most 190 characters when present");
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
62
|
+
// 入站 owner 门(fail-closed,exemptions 路由同款):未知 session 404;他人 session 404 无 oracle;
|
|
63
|
+
// store 错误 500 传播绝不放行;无 ownerOf 面(env-only)=501 诚实(入站门没有地基就不开门)。
|
|
56
64
|
if (!deps.sessionStorage?.ownerOf) {
|
|
57
65
|
sendError(res, 501, "capability.session_ownership_required", "external notify requires the session-ownership face (sessionStorage.ownerOf)");
|
|
58
66
|
return;
|
|
59
67
|
}
|
|
60
|
-
const notifyOwner = await deps.sessionStorage.ownerOf(notifySession);
|
|
68
|
+
const notifyOwner = await deps.sessionStorage.ownerOf(notifySession); // throws → outer 500(fail-closed)
|
|
61
69
|
if (notifyOwner === undefined) {
|
|
62
70
|
sendError(res, 404, "not_found.session", "session not found");
|
|
63
71
|
return;
|
|
@@ -75,6 +83,7 @@ async function handleNotifyWakeBody(req, res, url, ctx, miss) {
|
|
|
75
83
|
...(nb.seq !== undefined ? { seq: nb.seq } : {}),
|
|
76
84
|
...(nb.source !== undefined ? { source: nb.source } : {}),
|
|
77
85
|
};
|
|
86
|
+
// live 半场:目标 session 的活流在本副本 → core notify verb(task_type="external" core 铸,不可伪装内部帧)。
|
|
78
87
|
const liveTaskId = await deps.runStore?.getActiveTaskId?.(notifySession).catch(() => undefined);
|
|
79
88
|
const liveStream = liveTaskId !== undefined && liveTaskId !== null ? steerableRuns.get(liveTaskId) : undefined;
|
|
80
89
|
if (liveStream) {
|
|
@@ -84,13 +93,17 @@ async function handleNotifyWakeBody(req, res, url, ctx, miss) {
|
|
|
84
93
|
return;
|
|
85
94
|
}
|
|
86
95
|
catch (e) {
|
|
96
|
+
// 只有「流已结束」竞态才回落 park;core 的明确拒绝(notify.invalid_payload 等)原样 4xx——
|
|
97
|
+
// 把合同拒绝误 park = 无效通知洗成 202(fail-closed 谱系,复审 finding)。
|
|
87
98
|
const code = e.code;
|
|
88
99
|
if (typeof code === "string" && code.startsWith("notify.")) {
|
|
89
100
|
sendError(res, 400, code, e instanceof Error ? e.message : "invalid notification");
|
|
90
101
|
return;
|
|
91
102
|
}
|
|
103
|
+
/* 其余=活流刚结束竞态 → durable park(与 steer 的 live→suspended 同姿势) */
|
|
92
104
|
}
|
|
93
105
|
}
|
|
106
|
+
// idle 半场:park 进 inbox(external 键域;redact/cap 在 taskNotificationInboxEntry 内)→ 下次开流 drain。
|
|
94
107
|
if (!deps.workflowCompletionInbox) {
|
|
95
108
|
sendError(res, 501, "capability.workflow_store_required", "external notify park requires the workflow completion inbox (WORKFLOW_RUN_STORE)");
|
|
96
109
|
return;
|
|
@@ -100,13 +113,16 @@ async function handleNotifyWakeBody(req, res, url, ctx, miss) {
|
|
|
100
113
|
return;
|
|
101
114
|
}
|
|
102
115
|
if (req.method === "POST" && /^\/v1\/sessions\/[^/]+\/wake$/.test(url)) {
|
|
116
|
+
// design/144 §3(core 1.283 wake arm):对 task_done 纯 park 的「消息唤醒」。非门决策——不 allow/deny
|
|
117
|
+
// 任何 pending 动作,只解除 park 并把消息(或已 park 的 pendingSteer)作为续跑首轮输入。有未决门 =
|
|
118
|
+
// core `wake.gate_pending` 拒(永不绕审批);空 park + 无 message = `wake.nothing_to_deliver` 拒。
|
|
103
119
|
if (!deps.checkpointStore) {
|
|
104
120
|
sendError(res, 501, "capability.checkpoint_store_required", "wake requires the checkpoint store");
|
|
105
121
|
return;
|
|
106
122
|
}
|
|
107
123
|
if (rateLimited(req, res) || quotaExceeded(req, res) || (await leaseDenied(req, res)))
|
|
108
|
-
return;
|
|
109
|
-
const principal = gatedPrincipal(req, deps.config);
|
|
124
|
+
return; // 续跑=烧模型
|
|
125
|
+
const principal = gatedPrincipal(req, deps.config); // direct-door-secure(trusted 承载 operator 权威)
|
|
110
126
|
if (deps.config.requirePrincipal && principal === undefined) {
|
|
111
127
|
sendError(res, 401, "auth.principal_required", `missing principal header '${deps.config.principalHeader}'`);
|
|
112
128
|
return;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— 观测只读面。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`GET /v1/outcomes`(operator-only 机械信号聚合)、`GET /v1/usage`(per-principal 累计花费读面,
|
|
5
|
+
* 与 quotaExceeded 门同键、只读不消费)。本域零可变状态。
|
|
6
|
+
*/
|
|
1
7
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
8
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
9
|
export declare function handleObservability(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -5,8 +5,23 @@ export async function handleObservability(req, res, url, ctx) {
|
|
|
5
5
|
await handleObservabilityBody(req, res, url, ctx, miss);
|
|
6
6
|
return !miss.fell;
|
|
7
7
|
}
|
|
8
|
+
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
|
|
9
|
+
* 的语义原样 =「本域已应答」;走到函数尾才是「没匹配上」,置 `miss.fell` 交回装配器继续下一个域。
|
|
10
|
+
* 跨域的东西(deps / 助手 / 单域状态)一律在首行解构出来,于是下面每一行都逐字不变。 */
|
|
8
11
|
async function handleObservabilityBody(req, res, url, ctx, miss) {
|
|
9
12
|
const { deps } = ctx;
|
|
13
|
+
// Per-principal cumulative cost usage (CLI /cost + /usage + status usage tab). The READ twin of
|
|
14
|
+
// the cost-quota GATE (quotaExceeded): `check` is read-only (does NOT consume). Principal-scoped — a caller
|
|
15
|
+
// only ever sees its OWN spend (keyed exactly like the gate). When no cumulative quota is configured
|
|
16
|
+
// (deps.costQuota absent) → enabled:false (NOT an error) so the CLI shows "no cumulative quota; per-task cap
|
|
17
|
+
// = $X" instead of failing. ⚠️ in-memory CostQuota is per-replica (undercounts across replicas) — the TiDB
|
|
18
|
+
// twin (deps.costQuota = TiDBCostQuota) is the cross-replica-accurate backend; both satisfy `.check()`.
|
|
19
|
+
// P2 (design/73 §7.2 dashboard floor): READ-ONLY per-(taskSignature, model) outcome aggregate — pass-rate
|
|
20
|
+
// + mean cost over the graded ledger rows (the (b)-emitter data: make-real/TB harness runs + any future
|
|
21
|
+
// goal面). 🔒 Multi-tenant: operator-only — rows are NOT owner-keyed (mechanical facts keyed by signature
|
|
22
|
+
// ×model), so any-tenant access would leak cross-tenant task/perf shape; single-user turnkey is open (the
|
|
23
|
+
// sole user IS the operator). ?signature= filters to one aggregation key; ?includeAborted=true adds the
|
|
24
|
+
// infra-aborted rows (infra-health view — NEVER the training view, council blocker 3).
|
|
10
25
|
if (url === "/v1/outcomes" && req.method === "GET") {
|
|
11
26
|
if (deps.config.requirePrincipal) {
|
|
12
27
|
const principal = gatedPrincipal(req, deps.config);
|
|
@@ -19,7 +34,7 @@ async function handleObservabilityBody(req, res, url, ctx, miss) {
|
|
|
19
34
|
sendError(res, 501, "capability.outcome_ledger_required", "no queryable outcome ledger on this worker (File sink — read the JSONL dataset directly)");
|
|
20
35
|
return;
|
|
21
36
|
}
|
|
22
|
-
const q = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
37
|
+
const q = new URL(req.url ?? "/", "http://localhost").searchParams; // `url` is query-stripped upstream
|
|
23
38
|
const sig = q.get("signature") ?? undefined;
|
|
24
39
|
try {
|
|
25
40
|
const rows = await deps.outcomeSink.summary({ ...(sig ? { taskSignature: sig } : {}), includeAborted: q.get("includeAborted") === "true" });
|
|
@@ -31,8 +46,10 @@ async function handleObservabilityBody(req, res, url, ctx, miss) {
|
|
|
31
46
|
}
|
|
32
47
|
return;
|
|
33
48
|
}
|
|
49
|
+
// (用量统计查询面 /v1/usage/{summary,series,breakdown} 从这里上移到全局 service-credential 门之前——
|
|
50
|
+
// usage 门自身认 traceToken,但挂在全局门之后时 traceToken-only 调用在全局门就 401=死代码。)
|
|
34
51
|
if (url === "/v1/usage" && req.method === "GET") {
|
|
35
|
-
const principal = gatedPrincipal(req, deps.config);
|
|
52
|
+
const principal = gatedPrincipal(req, deps.config); // direct-door safe: crypto-verified principal, never the spoofable header
|
|
36
53
|
if (!principal) {
|
|
37
54
|
sendError(res, 401, "auth.principal_required", `missing principal header '${deps.config.principalHeader}'`);
|
|
38
55
|
return;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— 异步 run 面与它的全部动词。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`POST /v1/runs`(异步提交)· `GET /v1/runs/:id[/events]`(轮询 / 可恢复 SSE)· 运行期动词
|
|
5
|
+
* `cancel` / `steer` / `compact` / `detach` · 子代理面 `subagents/:target/{steer,resume,output,stream}` ·
|
|
6
|
+
* 通用任务句柄 `tasks/:handle/{output,stop}` · 三条 HITL 应答口 `elicitations|questions|tool-approvals/:id/respond`。
|
|
7
|
+
*
|
|
8
|
+
* 两段搬运:提交+run 级动词一段,子代理/任务句柄/HITL 应答一段——它们在 `handle()` 里原本被 SVC-5 的
|
|
9
|
+
* workflow steer 隔开,拆分保持各自位置(本文件里的先后只是同域归并)。`POST /v1/runs` 与 tasks 域共用
|
|
10
|
+
* `ctx.legs.prepareSpec`(同一条读体/校验/建 spec 的前段)。
|
|
11
|
+
*
|
|
12
|
+
* 可变状态全部来自跨域 registry(`idemCache` 幂等、`inflightRuns`/`preemptableRuns` 中止句柄、
|
|
13
|
+
* `cancelledViaVerb` first-writer-wins 判别、`steerableRuns` 活流句柄、`wakeParkMints` park 铸造闩)。
|
|
14
|
+
*/
|
|
1
15
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
16
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
17
|
export declare const RUN_ID_RE: RegExp;
|
|
@@ -15,5 +29,6 @@ export declare const RUN_SUBAGENT_STREAM_RE: RegExp;
|
|
|
15
29
|
export declare const RUN_TASK_OUTPUT_RE: RegExp;
|
|
16
30
|
export declare const RUN_TASK_STOP_RE: RegExp;
|
|
17
31
|
export declare function handleRuns(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
32
|
+
/** 子代理 / 任务句柄 / HITL 应答段——`handle()` 里它在 SVC-5 workflow steer **之后**,故是独立的域入口。 */
|
|
18
33
|
export declare function handleRunVerbs(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
19
34
|
//# sourceMappingURL=runs.d.ts.map
|