@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,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— Task Trace 只读面 + 用量统计面。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`GET /v1/tasks/source-summary`(跨租户 door 汇总,ops-only)、`GET /v1/tasks[/:id/{turns,stream,artifacts}]`
|
|
5
|
+
* (S1 Task Trace API)、`GET /v1/usage/{summary,series,breakdown}`(web P4 / registry AnalyticsSource)。
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ 三块都跑在全局 service-credential 门**之前**(与 /metrics 同款待遇)——只读 traceToken 单凭据的调用方
|
|
8
|
+
* (registry 中继的姿势)在全局门会被 401,挂门后=门内 traceToken 支持成死代码(1.148 a2 实机抓获)。
|
|
9
|
+
* 因此本域在 `handle()` 里的位置就是契约的一部分:必须留在鉴权门上方,顺序不可与其他域对调。本域零可变状态。
|
|
10
|
+
*/
|
|
1
11
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
12
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
13
|
export declare function handleTraceUsage(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -10,10 +10,27 @@ export async function handleTraceUsage(req, res, url, ctx) {
|
|
|
10
10
|
await handleTraceUsageBody(req, res, url, ctx, miss);
|
|
11
11
|
return !miss.fell;
|
|
12
12
|
}
|
|
13
|
+
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
|
|
14
|
+
* = 「本域已应答」;走到函数尾才是「没匹配上」。跨域的东西一律在首行解构出来。 */
|
|
13
15
|
async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
14
16
|
const { deps } = ctx;
|
|
15
17
|
const { isFleetWide } = ctx.helpers;
|
|
18
|
+
// Task Trace API (S1, read-only): GET /v1/tasks[/:id/turns|/stream]. Authorized by EITHER the full authToken
|
|
19
|
+
// OR a read-only traceToken (sema-registry pulls traces fleet-wide with one read-only token). Handled BEFORE
|
|
20
|
+
// the global gate (like /metrics) so a traceToken-only caller isn't 401'd.
|
|
21
|
+
// ⚠️ Blast radius (council DESIGN-1): fleet-wide by design — traces are NOT per-run-owner-scoped here (the
|
|
22
|
+
// trace token is a deployment-held read-only credential, like metricsToken). Per-tenant/roster scoping is the
|
|
23
|
+
// sema-registry relay's job (admin-session + roster); the kill-switch is leaving TRACE_TOKEN unset.
|
|
24
|
+
// Per-door usage rollup (center systems-UI, SERVICE-PROPOSAL-SYSTEMS-DOMAIN): COUNT by (source,status)
|
|
25
|
+
// since ?sinceSec ago (default 24h, max 30d). Own route — TRACE_RE's :id group is both-or-neither (it
|
|
26
|
+
// deliberately never matches a bare /v1/tasks/<seg>, keeping POST /v1/tasks/stream unshadowed), so this
|
|
27
|
+
// CANNOT ride that block (caught live: the in-block branch was dead code → 404).
|
|
16
28
|
if (req.method === "GET" && url === "/v1/tasks/source-summary") {
|
|
29
|
+
// source-summary is a CROSS-TENANT aggregate (count-by-source/status across ALL tenants) with NO owner-scoped
|
|
30
|
+
// variant — so it is ops-only: fleet-wide callers (system/trace token) on any deployment, or dev-open on a
|
|
31
|
+
// single-user deployment. A multi-tenant deployment without a token must NOT see it (isFleetWide fail-closes —
|
|
32
|
+
// the SAME HIGH tenant-isolation fix as the trace/session gates; this endpoint had the un-migrated fail-open
|
|
33
|
+
// clause, caught by the systematic-audit review's dimension-2 sweep).
|
|
17
34
|
if (!isFleetWide(req)) {
|
|
18
35
|
sendError(res, 401, "auth.unauthorized", "unauthorized");
|
|
19
36
|
return;
|
|
@@ -29,8 +46,11 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
29
46
|
}
|
|
30
47
|
const traceMatch = req.method === "GET" ? TRACE_RE.exec(url) : null;
|
|
31
48
|
if (traceMatch) {
|
|
49
|
+
// FLEET-WIDE (sees ALL tenants): a system authToken or the read-only traceToken (sema-registry ops
|
|
50
|
+
// relay), or dev-open on a SINGLE-USER deployment. A multi-tenant deployment without a token is owner-gated,
|
|
51
|
+
// NEVER fleet-wide — see isFleetWide (HIGH tenant-isolation audit fix). Otherwise a principal caller is owner-gated.
|
|
32
52
|
const fleetWide = isFleetWide(req);
|
|
33
|
-
const gateOwner = fleetWide ? null : (gatedPrincipal(req, deps.config) || null);
|
|
53
|
+
const gateOwner = fleetWide ? null : (gatedPrincipal(req, deps.config) || null); // direct-door safe; `|| null`: an absent principal ("" / undefined) → null
|
|
34
54
|
if (!fleetWide && gateOwner === null) {
|
|
35
55
|
sendError(res, 401, "auth.unauthorized", "unauthorized");
|
|
36
56
|
return;
|
|
@@ -41,7 +61,8 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
41
61
|
}
|
|
42
62
|
const query = new URL(req.url ?? "", "http://x").searchParams;
|
|
43
63
|
const taskId = traceMatch[1];
|
|
44
|
-
const sub = traceMatch[2];
|
|
64
|
+
const sub = traceMatch[2]; // undefined (list) | "/turns" | "/stream" | "/artifacts"
|
|
65
|
+
// per-id owner gate for the principal path (404 for a non-owner — no existence oracle, parity with runOwnerOk).
|
|
45
66
|
if (taskId && gateOwner !== null) {
|
|
46
67
|
const run = await deps.runStore.getRun(taskId);
|
|
47
68
|
if (!run || (run.owner !== null && run.owner !== gateOwner)) {
|
|
@@ -50,7 +71,7 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
if (!taskId)
|
|
53
|
-
await handleTaskList(res, deps.runStore, query, gateOwner);
|
|
74
|
+
await handleTaskList(res, deps.runStore, query, gateOwner); // gateOwner (when set) forces the owner filter
|
|
54
75
|
else if (sub === "/turns")
|
|
55
76
|
await handleTaskTurns(res, deps.runStore, taskId, query);
|
|
56
77
|
else if (sub === "/stream")
|
|
@@ -61,6 +82,16 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
61
82
|
sendError(res, 404, "not_found.route", "not found");
|
|
62
83
|
return;
|
|
63
84
|
}
|
|
85
|
+
// ── 用量统计查询面(web P4,registry AnalyticsSource "service-usage" 数据源)────────────────
|
|
86
|
+
// GET /v1/usage/{summary|series|breakdown}?from&to&…(ISO 或 epoch-ms)。鉴权双支持(回帖契约):
|
|
87
|
+
// - fleet 凭证(authToken/traceToken)= 全量视角,可用 principal 参数过滤任意主体;
|
|
88
|
+
// - registry JWT(1.141 鉴权桥,verifiedPrincipal)= 强制 owner=本人(参数里的 principal 被忽略);
|
|
89
|
+
// - 都没有 → 401。scope 参数 v1 不实装(principal 即租户键;registry 侧按需把 scope→principal 集合映射)。
|
|
90
|
+
// 聚合=usage-analytics 纯函数;store 扫窗触顶 → truncated:true 诚实上抛(绝不静默截断)。
|
|
91
|
+
// 🔴 位置(1.148 修):必须在全局 service-credential 门【之前】(与 trace 门/metrics 同款待遇)——
|
|
92
|
+
// 门函数 isFleetWide 认只读 traceToken,但配了 authToken 的部署里全局门只认 service token/SSO-JWT,
|
|
93
|
+
// usage 挂门后时 traceToken-only 调用(registry 用量中继的姿势)在全局门就 401=门内 traceToken 支持成死代码
|
|
94
|
+
// (a2 实机抓获)。本块所有命中路径自带 401/501 fail-closed 再 return,未命中 sub 落回后续路由(含全局门)。
|
|
64
95
|
if (url.startsWith("/v1/usage/") && req.method === "GET") {
|
|
65
96
|
const sub = url.slice("/v1/usage/".length).split("?")[0];
|
|
66
97
|
if (sub === "summary" || sub === "series" || sub === "breakdown") {
|
|
@@ -69,12 +100,12 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
69
100
|
return;
|
|
70
101
|
}
|
|
71
102
|
const fleetWide = isFleetWide(req);
|
|
72
|
-
const jwtOwner = fleetWide ? undefined : gatedPrincipal(req, deps.config);
|
|
103
|
+
const jwtOwner = fleetWide ? undefined : gatedPrincipal(req, deps.config); // 经 gatedPrincipal:未验 Bearer 不回退头
|
|
73
104
|
if (!fleetWide && !jwtOwner) {
|
|
74
105
|
sendError(res, 401, "auth.unauthorized", "unauthorized");
|
|
75
106
|
return;
|
|
76
107
|
}
|
|
77
|
-
const q = new URL(req.url ?? "", "http://x").searchParams;
|
|
108
|
+
const q = new URL(req.url ?? "", "http://x").searchParams; // NB: `url` 已剥 query,参数必须读 req.url
|
|
78
109
|
const parseT = (v, dflt) => {
|
|
79
110
|
if (!v)
|
|
80
111
|
return dflt;
|
|
@@ -82,12 +113,13 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
82
113
|
return Number.isFinite(n) ? n : NaN;
|
|
83
114
|
};
|
|
84
115
|
const now = Date.now();
|
|
85
|
-
const from = parseT(q.get("from"), now - 7 * 86_400_000);
|
|
116
|
+
const from = parseT(q.get("from"), now - 7 * 86_400_000); // 默认近 7 天
|
|
86
117
|
const to = parseT(q.get("to"), now);
|
|
87
118
|
if (Number.isNaN(from) || Number.isNaN(to) || from >= to) {
|
|
88
119
|
sendError(res, 400, "request.query_invalid", "invalid from/to (ISO-8601 or epoch-ms; from < to)");
|
|
89
120
|
return;
|
|
90
121
|
}
|
|
122
|
+
// owner 过滤:JWT 主体强制=本人;fleet 凭证可选 principal 参数。
|
|
91
123
|
const owner = jwtOwner ?? (q.get("principal") ?? undefined);
|
|
92
124
|
try {
|
|
93
125
|
const scan = await deps.runStore.usageScan(from, to, owner !== undefined ? { owner } : undefined);
|
|
@@ -110,6 +142,7 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
110
142
|
sendError(res, 400, "request.query_invalid", "dimension=principal|model");
|
|
111
143
|
return;
|
|
112
144
|
}
|
|
145
|
+
// JWT 主体查 dimension=principal 只会看到自己一桶(owner 已强制)——语义自然成立,无泄漏面。
|
|
113
146
|
sendJson(res, 200, { ...base, dimension, breakdown: usageBreakdown(scan.rows, dimension) });
|
|
114
147
|
}
|
|
115
148
|
}
|
|
@@ -122,6 +155,7 @@ async function handleTraceUsageBody(req, res, url, ctx, miss) {
|
|
|
122
155
|
}
|
|
123
156
|
miss.fell = true;
|
|
124
157
|
}
|
|
158
|
+
// ─────────── Task Trace API handlers (S1) ───────────
|
|
125
159
|
function encodeCursor(c) {
|
|
126
160
|
return Buffer.from(JSON.stringify(c)).toString("base64url");
|
|
127
161
|
}
|
|
@@ -130,27 +164,35 @@ function decodeCursor(s) {
|
|
|
130
164
|
return undefined;
|
|
131
165
|
try {
|
|
132
166
|
const o = JSON.parse(Buffer.from(s, "base64url").toString());
|
|
167
|
+
// Same date-validity guard as decodeSessionCursor: a tampered non-date createdAt would reach `new Date()` in the
|
|
168
|
+
// store keyset predicate and 500 (same latent issue as the sibling cursor).
|
|
133
169
|
return o.createdAt && o.taskId && !Number.isNaN(Date.parse(o.createdAt)) ? { createdAt: o.createdAt, taskId: o.taskId } : undefined;
|
|
134
170
|
}
|
|
135
171
|
catch {
|
|
136
172
|
return undefined;
|
|
137
173
|
}
|
|
138
174
|
}
|
|
175
|
+
/** GET /v1/tasks — cheap list summary (contract 2.1), keyset-paginated newest-first. */
|
|
139
176
|
async function handleTaskList(res, runStore, query, forceOwner) {
|
|
140
177
|
const status = query.get("status") ?? undefined;
|
|
141
|
-
const jobId = query.get("jobId") ?? undefined;
|
|
142
|
-
const source = query.get("source") ?? undefined;
|
|
178
|
+
const jobId = query.get("jobId") ?? undefined; // work-view group filter — all runs of one logical task
|
|
179
|
+
const source = query.get("source") ?? undefined; // credential-derived door filter (oa/cc-mcp/portal)
|
|
180
|
+
// forceOwner (set on the principal path) PINS the listing to the caller's own runs — it overrides any ?owner
|
|
181
|
+
// so a principal can't list another tenant. null/undefined (fleet-wide path) → honor the ?owner query (ops view).
|
|
143
182
|
const owner = forceOwner != null ? forceOwner : (query.get("owner") ?? undefined);
|
|
144
183
|
const limit = Math.min(100, Math.max(1, Number(query.get("limit") ?? 50) || 50));
|
|
145
184
|
const cursor = decodeCursor(query.get("cursor"));
|
|
146
185
|
const rows = await runStore.listRuns({ ...(status ? { status } : {}), ...(jobId ? { jobId } : {}), ...(source ? { source } : {}), ...(owner ? { owner } : {}), ...(cursor ? { cursor } : {}), limit: limit + 1 });
|
|
147
186
|
const hasMore = rows.length > limit;
|
|
148
187
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
149
|
-
const tasks = page.map((r) => taskSummary(r));
|
|
188
|
+
const tasks = page.map((r) => taskSummary(r)); // lastStep from status; latest-event lastStep = a later refinement
|
|
150
189
|
const last = page[page.length - 1];
|
|
151
190
|
const nextCursor = hasMore && last ? encodeCursor({ createdAt: last.createdAt, taskId: last.taskId }) : undefined;
|
|
152
191
|
sendJson(res, 200, { tasks, ...(nextCursor ? { nextCursor } : {}) });
|
|
153
192
|
}
|
|
193
|
+
/** GET /v1/tasks/:id/turns — lazy history (contract 2.2), backward-paginated by turn seq. */
|
|
194
|
+
/** GET /v1/tasks/:id/artifacts — what the agent produced (M2). A pure projection of the
|
|
195
|
+
* durable log (no new write path), so it works for every historical run. */
|
|
154
196
|
async function handleTaskArtifacts(res, runStore, taskId) {
|
|
155
197
|
const run = await runStore.getRun(taskId);
|
|
156
198
|
if (!run) {
|
|
@@ -167,15 +209,20 @@ async function handleTaskTurns(res, runStore, taskId, query) {
|
|
|
167
209
|
return;
|
|
168
210
|
}
|
|
169
211
|
const limit = Math.min(100, Math.max(1, Number(query.get("limit") ?? 20) || 20));
|
|
170
|
-
const cursorSeq = Number(query.get("cursor") ?? 0) || 0;
|
|
212
|
+
const cursorSeq = Number(query.get("cursor") ?? 0) || 0; // turns with seq < cursor (older); 0 = newest page
|
|
171
213
|
const [events, retainedFrom] = await Promise.all([runStore.getEvents(taskId, 0), runStore.retainedFrom(taskId)]);
|
|
172
|
-
const all = projectEvents(events);
|
|
214
|
+
const all = projectEvents(events); // the objective (user turn) isn't on the run row → omitted for MVP (refinement)
|
|
173
215
|
const eligible = cursorSeq > 0 ? all.filter((t) => t.seq < cursorSeq) : all;
|
|
174
|
-
const turns = eligible.slice(Math.max(0, eligible.length - limit));
|
|
216
|
+
const turns = eligible.slice(Math.max(0, eligible.length - limit)); // backward = the newest of the eligible
|
|
175
217
|
const oldest = turns[0];
|
|
218
|
+
// The turns cursor is a plain turn-seq (turns are seq-ordered); it is opaque to the client per the contract
|
|
219
|
+
// (2.2), so it needn't match the list endpoint's base64url(createdAt,taskId) keyset cursor (council).
|
|
176
220
|
const nextCursor = eligible.length > limit && oldest ? String(oldest.seq) : undefined;
|
|
177
221
|
sendJson(res, 200, { turns, ...(nextCursor ? { nextCursor } : {}), retainedFrom });
|
|
178
222
|
}
|
|
223
|
+
/** GET /v1/tasks/:id/stream — resumable SSE (contract 2.3). Maps the durable event log to the contract event
|
|
224
|
+
* names, declares mode in the first event, 416s a resume point evicted past retention, heartbeats, and emits an
|
|
225
|
+
* explicit `error` on stall so the client never hangs. */
|
|
179
226
|
async function streamTaskTrace(req, res, runStore, taskId, staleMs) {
|
|
180
227
|
const run0 = await runStore.getRun(taskId);
|
|
181
228
|
if (!run0) {
|
|
@@ -183,15 +230,18 @@ async function streamTaskTrace(req, res, runStore, taskId, staleMs) {
|
|
|
183
230
|
return;
|
|
184
231
|
}
|
|
185
232
|
const lastId = Number(req.headers["last-event-id"] ?? new URL(req.url ?? "", "http://x").searchParams.get("from") ?? 0);
|
|
186
|
-
let from = Number.isFinite(lastId) ? lastId : 0;
|
|
233
|
+
let from = Number.isFinite(lastId) ? lastId : 0; // unified with streamRunEvents (council DESIGN-4); a <0 from just replays all
|
|
187
234
|
if (from > 0) {
|
|
188
235
|
const retainedFrom = await runStore.retainedFrom(taskId);
|
|
189
236
|
if (retainedFrom > from + 1) {
|
|
237
|
+
// The events the client wants to resume past were evicted → it must re-sync via GET /turns (contract 2.3).
|
|
190
238
|
sendError(res, 416, "limit.retention_evicted", "resume point evicted past retention", { retainedFrom });
|
|
191
239
|
return;
|
|
192
240
|
}
|
|
193
241
|
}
|
|
194
242
|
sseHeaders(res);
|
|
243
|
+
// First event declares the stream contract: mode + a version (council — lets the relay detect a worker whose
|
|
244
|
+
// SSE shape changed, e.g. when P1 adds token-delta granularity). resumeFrom echoes the honored Last-Event-ID.
|
|
195
245
|
res.write(`event: meta\ndata: ${JSON.stringify({ version: 1, mode: "delta", resumeFrom: from })}\n\n`);
|
|
196
246
|
let closed = false;
|
|
197
247
|
req.on("close", () => {
|
|
@@ -214,7 +264,7 @@ async function streamTaskTrace(req, res, runStore, taskId, staleMs) {
|
|
|
214
264
|
if (!run)
|
|
215
265
|
break;
|
|
216
266
|
if (run.status !== "running") {
|
|
217
|
-
write(await runStore.getEvents(taskId, from));
|
|
267
|
+
write(await runStore.getEvents(taskId, from)); // the terminal event can land in the gap above
|
|
218
268
|
break;
|
|
219
269
|
}
|
|
220
270
|
const stale = Date.now() - new Date(run.updatedAt).getTime() > staleMs;
|
|
@@ -223,6 +273,8 @@ async function streamTaskTrace(req, res, runStore, taskId, staleMs) {
|
|
|
223
273
|
break;
|
|
224
274
|
}
|
|
225
275
|
if (Date.now() - start > MAX_MS) {
|
|
276
|
+
// BL-16: the stream hit its 15-min cap but the RUN is still going — emit a terminal event so the client
|
|
277
|
+
// can tell "reconnect to continue" from "task completed" (a silent close looked like completion).
|
|
226
278
|
res.write(`event: error\ndata: ${JSON.stringify({ code: "STREAM_MAX_DURATION", message: "trace stream reached its 15-minute cap — reconnect with Last-Event-ID to continue (the run is still active)" })}\n\n`);
|
|
227
279
|
break;
|
|
228
280
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/158 A9 域模块 —— S8 自编排 workflow 面(design/97/98)。
|
|
3
|
+
*
|
|
4
|
+
* 路由:`GET /v1/workflows`(列表)· `GET /v1/workflows/:id[/journal]`(详情)· `GET /v1/workflows/:id/stream`
|
|
5
|
+
* (在进程内 live SSE)· `POST /v1/workflows/:id/agents/:label/steer`(SVC-5:给 workflow 里某个仍在跑的
|
|
6
|
+
* agent 注入引导)。
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ 只读三路跑在全局 service-credential 门**之前**(与 trace/fleet 同列),因此块内那道按 scope 的 per-tenant
|
|
9
|
+
* 门就是这些读的唯一租户边界;steer 那路在门之后。两段在 `handle()` 里原本相隔很远(中间隔着 tasks/runs 两域),
|
|
10
|
+
* 拆分保持了各自的相对位置 —— 本文件里的先后只是同域归并,不代表路由顺序变化。本域零可变状态。
|
|
11
|
+
*/
|
|
1
12
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
13
|
import type { RouteCtx } from "../route-ctx.js";
|
|
3
14
|
export declare function handleWorkflows(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
15
|
+
/** SVC-5 的 steer 路——`handle()` 里位置在 tasks/runs 之后(鉴权门之后),故是**独立**的域入口。 */
|
|
4
16
|
export declare function handleWorkflowAgentSteer(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
5
17
|
//# sourceMappingURL=workflows.d.ts.map
|