@sema-agent/server 1.322.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +546 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +455 -60
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +2132 -96
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +59 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
|
@@ -1,7 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-NEUTRAL SQL exec/transaction seam for the "single-file dual-dialect" store collapses
|
|
3
|
+
* (design/158 A12 定型半场). Sibling of `sql-escape.ts` / `sql-row-helpers.ts` / `store-contracts.ts`:
|
|
4
|
+
* a leaf module with ZERO store logic, so a collapsed pair never has to load the other dialect's
|
|
5
|
+
* adapter to reach a driver call.
|
|
6
|
+
*
|
|
7
|
+
* What it normalizes (and ONLY this):
|
|
8
|
+
* - `query(sql, params)` → `{ rows, affected }` — the two drivers disagree on the RESULT shape
|
|
9
|
+
* (mysql2 `[rowsOrHeader, fields]` + `ResultSetHeader.affectedRows`; node-pg `{rows, rowCount}`).
|
|
10
|
+
* - transaction control verbs — mysql2 has NATIVE `beginTransaction/commit/rollback` methods while
|
|
11
|
+
* node-pg issues them as statements. Call-shape matters (the fake-pool unit suites script the
|
|
12
|
+
* `query` calls IN ORDER), so the seam keeps each engine on its historical verb form.
|
|
13
|
+
*
|
|
14
|
+
* What it deliberately does NOT normalize (the A12 判据 — 方言差异必须显式):
|
|
15
|
+
* - SQL TEXT: placeholders (`?` vs `$n`), `ON DUPLICATE KEY UPDATE` vs `ON CONFLICT … DO UPDATE`,
|
|
16
|
+
* `CAST(? AS JSON)` vs `$n::jsonb`, `INSERT IGNORE` vs `ON CONFLICT DO NOTHING`, `<=>` vs
|
|
17
|
+
* `IS NOT DISTINCT FROM`, VARBINARY vs `COLLATE "C"` — every one of these stays written out at
|
|
18
|
+
* the call site so a reader sees BOTH statements side by side (the real-DB suites are the oracle).
|
|
19
|
+
* - error classification: `ER_DUP_ENTRY`/errno 1062 vs SQLSTATE `23505`, and WHICH unique key
|
|
20
|
+
* collided (mysql2 `sqlMessage` text vs pg `err.constraint`) — those live with the store that
|
|
21
|
+
* needs them, because the discrimination rule is store-specific, not driver-generic.
|
|
22
|
+
* - per-query timeouts: mysql2 takes `{sql, timeout}` while node-pg takes a `QueryConfig` with
|
|
23
|
+
* `query_timeout`. The counter family (write-behind-counter.ts) needs those and keeps its own
|
|
24
|
+
* exec; this seam stays on the plain (sql, params) form.
|
|
25
|
+
*
|
|
26
|
+
* `beginPessimistic()` is TiDB's `BEGIN PESSIMISTIC` (a CURRENT read for the FOR UPDATE admission
|
|
27
|
+
* check — a snapshot read would double-admit) and a plain `BEGIN` on PG (READ COMMITTED already
|
|
28
|
+
* reads the latest committed row under the sentinel lock). It is a NAMED verb precisely so the
|
|
29
|
+
* divergence is visible rather than hidden inside `begin()`.
|
|
30
|
+
*
|
|
31
|
+
* ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
32
|
+
* REPLICATION PLAYBOOK — collapsing the remaining tidb-/pg- twin pairs (design/158 A12)
|
|
33
|
+
* ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
34
|
+
* Reference collapses: image-bake-store-sql.ts (class + transactions) and checkpoint-store-sql.ts
|
|
35
|
+
* (class, no transactions). Function-style stores follow task-list-store-sql.ts instead (inline
|
|
36
|
+
* `dialect === "tidb" ? … : …` ternaries, no driver object) — pick the shape the pair already has.
|
|
37
|
+
*
|
|
38
|
+
* STEPS
|
|
39
|
+
* 1. Read BOTH twins end to end first. List every method and mark it identical / SQL-text-only /
|
|
40
|
+
* genuinely-divergent-algorithm. Do not start editing before that list exists.
|
|
41
|
+
* 2. New file `<name>-store-sql.ts`. Move the WHOLE implementation into a `Sql<Name>` class (or
|
|
42
|
+
* `createSql<Name>` fn) taking a `SqlDriver`. Keep every doc comment — merge the two headers,
|
|
43
|
+
* never drop the longer twin's rationale.
|
|
44
|
+
* 3. Per statement, write BOTH texts at the call site via a 2-arg `q(tidbSql, pgSql)` helper.
|
|
45
|
+
* Never build one text with a placeholder-numbering loop — the point is that a reviewer sees
|
|
46
|
+
* the two statements adjacent.
|
|
47
|
+
* 4. Genuinely-divergent algorithms get an `if (dialect === "tidb") { … } else { … }` block with a
|
|
48
|
+
* 🔴 comment saying WHY both are correct. Never "unify" them by picking one engine's algorithm.
|
|
49
|
+
* 5. Old files become thin re-export shims. Class names, ctor arity, exported constants/types and
|
|
50
|
+
* helper names stay EXACTLY as they were — consumers and tests must not move.
|
|
51
|
+
* 6. Subclass bindings at the bottom: `class TiDB<X> extends Sql<X> { ctor(pool: MySqlPool, …) }`
|
|
52
|
+
* and `class Pg<X> extends Sql<X> { ctor(pool: PgPool, …) }`.
|
|
53
|
+
* 7. Verify: `npm run typecheck` → the pair's unit suites → a HEAD-vs-new SQL parity harness (drive
|
|
54
|
+
* every method on a recording fake pool for both dialects and diff the (sql, params) sequence;
|
|
55
|
+
* `git show HEAD:<file>` into a temp `__head_*.ts` sibling, delete it after) → the env-gated
|
|
56
|
+
* real dual-DB suite before release. Never trust a comment-level review for SQL text.
|
|
57
|
+
*
|
|
58
|
+
* WHAT MUST STAY EXPLICIT (never parameterized away)
|
|
59
|
+
* placeholders (?/$n) · upsert form (ON DUPLICATE vs ON CONFLICT) · JSON casts (CAST(? AS JSON) /
|
|
60
|
+
* $n::jsonb) · null-safe compare (<=> vs IS NOT DISTINCT FROM) AND its placeholder-arity fallout ·
|
|
61
|
+
* key-column byte semantics (VARBINARY vs COLLATE "C") · isolation/txn verbs · error classification
|
|
62
|
+
* (ER_DUP_ENTRY/errno vs SQLSTATE, sqlMessage vs err.constraint) · PG-only protocol-byte handling
|
|
63
|
+
* (pgSafeJsonStringify / pgProtocolJsonStringify / pgSanitizeText / pgHasUnstorable) · DDL.
|
|
64
|
+
*
|
|
65
|
+
* WHAT MAY BE PARAMETERIZED
|
|
66
|
+
* result unwrapping (rows/affected) · transaction plumbing · numeric coercion of BIGINT-as-string
|
|
67
|
+
* (`Number(...)` is already dialect-safe) · row→record mappers, column lists, pure predicates and
|
|
68
|
+
* validation (those belong in store-contracts.ts / sql-row-helpers.ts / sql-escape.ts) · table
|
|
69
|
+
* bindings (`{table, keyCol, valCol}`) when the generated text is byte-identical to the old literal
|
|
70
|
+
* — prove that with the parity harness, don't assume it.
|
|
71
|
+
*/
|
|
1
72
|
import type { Pool as MySqlPool } from "mysql2/promise";
|
|
2
73
|
import type { Pool as PgPool } from "pg";
|
|
3
74
|
export type SqlDialect = "tidb" | "pg";
|
|
4
75
|
export type SqlRow = Record<string, unknown>;
|
|
76
|
+
/** Normalized statement result: `rows` for SELECTs, `affected` for INSERT/UPDATE/DELETE. */
|
|
5
77
|
export interface SqlResult {
|
|
6
78
|
rows: SqlRow[];
|
|
7
79
|
affected: number;
|
|
@@ -9,8 +81,10 @@ export interface SqlResult {
|
|
|
9
81
|
export interface SqlExec {
|
|
10
82
|
query(sql: string, params?: unknown[]): Promise<SqlResult>;
|
|
11
83
|
}
|
|
84
|
+
/** A pooled connection with transaction control (released by the caller in a `finally`). */
|
|
12
85
|
export interface SqlTxConn extends SqlExec {
|
|
13
86
|
begin(): Promise<void>;
|
|
87
|
+
/** TiDB: `BEGIN PESSIMISTIC` (current-read txn). PG: plain `BEGIN`. */
|
|
14
88
|
beginPessimistic(): Promise<void>;
|
|
15
89
|
commit(): Promise<void>;
|
|
16
90
|
rollback(): Promise<void>;
|
|
@@ -20,6 +94,9 @@ export interface SqlDriver extends SqlExec {
|
|
|
20
94
|
readonly dialect: SqlDialect;
|
|
21
95
|
connect(): Promise<SqlTxConn>;
|
|
22
96
|
}
|
|
97
|
+
/** MySQL-protocol (TiDB) driver. Transaction control uses mysql2's NATIVE methods — the historical
|
|
98
|
+
* call shape the fake-pool unit suites script around. */
|
|
23
99
|
export declare function mysqlDriver(pool: MySqlPool): SqlDriver;
|
|
100
|
+
/** PostgreSQL driver. Transaction control is issued as STATEMENTS (node-pg has no native verbs). */
|
|
24
101
|
export declare function pgDriver(pool: PgPool): SqlDriver;
|
|
25
102
|
//# sourceMappingURL=sql-driver.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** mysql2 hands back `[rows]` for a SELECT and `[ResultSetHeader]` for a write. */
|
|
1
2
|
function mysqlResult(r) {
|
|
2
3
|
if (Array.isArray(r))
|
|
3
4
|
return { rows: r, affected: 0 };
|
|
@@ -8,6 +9,8 @@ async function mysqlQuery(q, sql, params) {
|
|
|
8
9
|
const [r] = (await q.query(sql, params ?? []));
|
|
9
10
|
return mysqlResult(r);
|
|
10
11
|
}
|
|
12
|
+
/** MySQL-protocol (TiDB) driver. Transaction control uses mysql2's NATIVE methods — the historical
|
|
13
|
+
* call shape the fake-pool unit suites script around. */
|
|
11
14
|
export function mysqlDriver(pool) {
|
|
12
15
|
return {
|
|
13
16
|
dialect: "tidb",
|
|
@@ -31,6 +34,7 @@ async function pgQuery(q, sql, params) {
|
|
|
31
34
|
const res = await q.query(sql, params ?? []);
|
|
32
35
|
return { rows: (res.rows ?? []), affected: res.rowCount ?? 0 };
|
|
33
36
|
}
|
|
37
|
+
/** PostgreSQL driver. Transaction control is issued as STATEMENTS (node-pg has no native verbs). */
|
|
34
38
|
export function pgDriver(pool) {
|
|
35
39
|
return {
|
|
36
40
|
dialect: "pg",
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-NEUTRAL SQL string escaping (design/158 A3 沉底).
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own leaf so no adapter has to load another dialect's adapter module to get a pure
|
|
5
|
+
* string transform (the PG stores used to runtime-import the TiDB tool-result store for exactly
|
|
6
|
+
* this one function). Zero dialect deps by construction — keep it that way.
|
|
7
|
+
*/
|
|
8
|
+
/** Escape SQL LIKE metacharacters (`\`, `%`, `_`) so a value is matched literally (default `\` escape char). */
|
|
1
9
|
export declare function escapeLike(s: string): string;
|
|
2
10
|
//# sourceMappingURL=sql-escape.d.ts.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-NEUTRAL SQL string escaping (design/158 A3 沉底).
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own leaf so no adapter has to load another dialect's adapter module to get a pure
|
|
5
|
+
* string transform (the PG stores used to runtime-import the TiDB tool-result store for exactly
|
|
6
|
+
* this one function). Zero dialect deps by construction — keep it that way.
|
|
7
|
+
*/
|
|
8
|
+
/** Escape SQL LIKE metacharacters (`\`, `%`, `_`) so a value is matched literally (default `\` escape char). */
|
|
1
9
|
export function escapeLike(s) {
|
|
2
10
|
return s.replace(/[\\%_]/g, (ch) => `\\${ch}`);
|
|
3
11
|
}
|
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pure row-mapping helpers for the SQL store twins (design/158 S8 纯 helper 归位).
|
|
3
|
+
*
|
|
4
|
+
* These were duplicated verbatim across the pg-/tidb- store twin pairs; each store imports the flavor
|
|
5
|
+
* it was written against (usually under its historical local alias, e.g. `parseJsonStrict as
|
|
6
|
+
* parseJson`) so call sites and semantics are byte-identical to before.
|
|
7
|
+
*
|
|
8
|
+
* THREE parseJson flavors exist ON PURPOSE — they differ in what a corrupted/legacy JSON column
|
|
9
|
+
* reads back as (lenient → null / strict → throw / fallback value), and the TWO nullable date→ISO
|
|
10
|
+
* helpers differ in how a non-Date cell is rendered (String() passthrough vs `new Date()` re-parse).
|
|
11
|
+
* Do NOT collapse them into one.
|
|
12
|
+
*/
|
|
13
|
+
/** JSON column → value; a corrupted/legacy JSON column reads back as `null` instead of failing the
|
|
14
|
+
* read. Non-strings pass through (node-pg parses jsonb → object already). */
|
|
1
15
|
export declare function parseJsonLenient<T>(v: unknown): T | null;
|
|
16
|
+
/** JSON column → value; malformed JSON THROWS. For stores whose write arm keeps the column clean
|
|
17
|
+
* (R7 终形:协议面拒绝式,库内恒干净,直读). Non-strings pass through (node-pg parses jsonb →
|
|
18
|
+
* object already). */
|
|
2
19
|
export declare function parseJsonStrict<T>(v: unknown): T | null;
|
|
20
|
+
/** JSON column → value with a caller-supplied fallback for NULL/corrupted cells. Non-strings pass
|
|
21
|
+
* through (node-pg parses jsonb → object already; tolerate a string just in case). */
|
|
3
22
|
export declare function parseJsonOr<T>(v: unknown, fallback: T): T;
|
|
23
|
+
/** NOT NULL datetime column → ISO string (drivers return Date; a string cell passes through via
|
|
24
|
+
* String() — NOT re-parsed). */
|
|
4
25
|
export declare function toIso(v: unknown): string;
|
|
26
|
+
/** Nullable twin of {@link toIso} (string cells still pass through verbatim). */
|
|
5
27
|
export declare function toIsoOrNull(v: unknown): string | null;
|
|
28
|
+
/** Nullable datetime column → ISO string, RE-PARSING a string cell via `new Date()` (normalizes a
|
|
29
|
+
* raw DB datetime string like "2026-01-01 00:00:00" to ISO — unlike {@link toIsoOrNull}, which
|
|
30
|
+
* passes it through unchanged). */
|
|
6
31
|
export declare function normalizeIsoOrNull(v: unknown): string | null;
|
|
7
32
|
//# sourceMappingURL=sql-row-helpers.d.ts.map
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pure row-mapping helpers for the SQL store twins (design/158 S8 纯 helper 归位).
|
|
3
|
+
*
|
|
4
|
+
* These were duplicated verbatim across the pg-/tidb- store twin pairs; each store imports the flavor
|
|
5
|
+
* it was written against (usually under its historical local alias, e.g. `parseJsonStrict as
|
|
6
|
+
* parseJson`) so call sites and semantics are byte-identical to before.
|
|
7
|
+
*
|
|
8
|
+
* THREE parseJson flavors exist ON PURPOSE — they differ in what a corrupted/legacy JSON column
|
|
9
|
+
* reads back as (lenient → null / strict → throw / fallback value), and the TWO nullable date→ISO
|
|
10
|
+
* helpers differ in how a non-Date cell is rendered (String() passthrough vs `new Date()` re-parse).
|
|
11
|
+
* Do NOT collapse them into one.
|
|
12
|
+
*/
|
|
13
|
+
/** JSON column → value; a corrupted/legacy JSON column reads back as `null` instead of failing the
|
|
14
|
+
* read. Non-strings pass through (node-pg parses jsonb → object already). */
|
|
1
15
|
export function parseJsonLenient(v) {
|
|
2
16
|
if (v == null)
|
|
3
17
|
return null;
|
|
@@ -10,11 +24,16 @@ export function parseJsonLenient(v) {
|
|
|
10
24
|
return null;
|
|
11
25
|
}
|
|
12
26
|
}
|
|
27
|
+
/** JSON column → value; malformed JSON THROWS. For stores whose write arm keeps the column clean
|
|
28
|
+
* (R7 终形:协议面拒绝式,库内恒干净,直读). Non-strings pass through (node-pg parses jsonb →
|
|
29
|
+
* object already). */
|
|
13
30
|
export function parseJsonStrict(v) {
|
|
14
31
|
if (v == null)
|
|
15
32
|
return null;
|
|
16
33
|
return (typeof v === "string" ? JSON.parse(v) : v);
|
|
17
34
|
}
|
|
35
|
+
/** JSON column → value with a caller-supplied fallback for NULL/corrupted cells. Non-strings pass
|
|
36
|
+
* through (node-pg parses jsonb → object already; tolerate a string just in case). */
|
|
18
37
|
export function parseJsonOr(v, fallback) {
|
|
19
38
|
if (v == null)
|
|
20
39
|
return fallback;
|
|
@@ -27,14 +46,20 @@ export function parseJsonOr(v, fallback) {
|
|
|
27
46
|
return fallback;
|
|
28
47
|
}
|
|
29
48
|
}
|
|
49
|
+
/** NOT NULL datetime column → ISO string (drivers return Date; a string cell passes through via
|
|
50
|
+
* String() — NOT re-parsed). */
|
|
30
51
|
export function toIso(v) {
|
|
31
52
|
return v instanceof Date ? v.toISOString() : String(v);
|
|
32
53
|
}
|
|
54
|
+
/** Nullable twin of {@link toIso} (string cells still pass through verbatim). */
|
|
33
55
|
export function toIsoOrNull(v) {
|
|
34
56
|
if (v == null)
|
|
35
57
|
return null;
|
|
36
58
|
return v instanceof Date ? v.toISOString() : String(v);
|
|
37
59
|
}
|
|
60
|
+
/** Nullable datetime column → ISO string, RE-PARSING a string cell via `new Date()` (normalizes a
|
|
61
|
+
* raw DB datetime string like "2026-01-01 00:00:00" to ISO — unlike {@link toIsoOrNull}, which
|
|
62
|
+
* passes it through unchanged). */
|
|
38
63
|
export function normalizeIsoOrNull(v) {
|
|
39
64
|
if (v == null)
|
|
40
65
|
return null;
|
|
@@ -30,16 +30,41 @@ import { TiDBRateLimiter } from "./tidb-rate-limiter.js";
|
|
|
30
30
|
import type { CounterDegradeHook } from "./write-behind-counter.js";
|
|
31
31
|
import { PgRateLimiter } from "./pg-rate-limiter.js";
|
|
32
32
|
export type RunStore = TiDBRunStore | PgRunStore | FileRunStore;
|
|
33
|
+
/** E18 resume-at eventId→entryId anchor map — tidb/pg/local 3-backend (works LOCAL; needs only the session tree +
|
|
34
|
+
* this map, no cloud-only checkpoint). Union = the three nominal twins; consumers use put/resolve/deleteBySession.
|
|
35
|
+
* FileResumeAnchorStore is the FILE-backed local twin (P0.5 variant-1; survives restart). */
|
|
33
36
|
export type ResumeAnchorStore = TiDBResumeAnchorStore | PgResumeAnchorStore | FileResumeAnchorStore;
|
|
34
37
|
export type { ApprovalExemptionStore } from "./approval-exemption-store.js";
|
|
38
|
+
/** E6 SessionPolicyStore — core's interface PLUS the service `deleteBySession` (E21 purge; only the durable twins carry
|
|
39
|
+
* it, core's InMemory omits it → optional). tidb/pg = durable twins; local = core's InMemorySessionPolicyStore (works
|
|
40
|
+
* local — rules need no cloud-only infra). The shared env-gated equivalence suite keeps the twins byte-matched to InMemory. */
|
|
35
41
|
export type ServiceSessionPolicyStore = SessionPolicyStore;
|
|
42
|
+
/** E19 rewind-files FileSnapshotStore — core's interface PLUS the service `deleteBySession` (E21 purge; the durable
|
|
43
|
+
* twins carry it, core's InMemory omits it → optional). tidb/pg = durable twins (manifest+blobs, reuse core
|
|
44
|
+
* captureManifest/applyManifest); local = core's FileFileSnapshotStore(file-backed content-addressed,跨重启
|
|
45
|
+
* 存活——接入审计 L6 订正:旧注释写 InMemory 会误导 local 快照持久性判断). Also the 2c work-artifact transfer store. */
|
|
36
46
|
export type ServiceFileSnapshotStore = FileSnapshotStore & {
|
|
47
|
+
/** [805]③a observability tail (SQL twins only — core's local stores drop the count internally, a core-side
|
|
48
|
+
* gap): captureManifest's tolerated-vanished counter → metric sink, assigned by main.ts when present.
|
|
49
|
+
* codex F8: async sinks admitted; the twins swallow a rejected promise (never-throw seam holds). */
|
|
37
50
|
onSkippedVanished?: (count: number) => void | Promise<void>;
|
|
38
51
|
deleteBySession?(scope: string): Promise<number>;
|
|
52
|
+
/** 2c session-sync DoS bound — GLOBALLY GC grace-window orphan blobs (standalone PUTs never imported, plus the
|
|
53
|
+
* blobs reap()/deleteBySession() left orphaned — byte deletion is ASYNC, never on the sync purge path). The durable
|
|
54
|
+
* twins carry it (scheduled by the main.ts reaper, error-tolerant → eventual consistency); core's InMemory omits it. */
|
|
39
55
|
sweepOrphanBlobs?(): Promise<number>;
|
|
56
|
+
/** The subset of `hashes` already present — a cheap SQL INDEX probe (BOTH backends). Used by the §10 import
|
|
57
|
+
* blob-presence pre-check (a HEAD/index check, NOT N full getBlob GETs). The durable twins carry it; optional. */
|
|
40
58
|
hasBlobs?(hashes: string[]): Promise<Set<string>>;
|
|
41
59
|
};
|
|
60
|
+
/** SVC-2 (core CORE-7) WorkflowJournalStore — core's interface PLUS the service `deleteByRun` (GC extra). tidb/pg =
|
|
61
|
+
* durable SQL twins (cross-replica resume journal); local = the service {@link FileWorkflowJournalStore}
|
|
62
|
+
* (single-box but RESTART-durable crash-safe JSONL, replacing core's InMemory). The shared equivalence suite keeps
|
|
63
|
+
* all three byte-matched (scope guard / idempotent-per-ordinal / oversize skip-journal). */
|
|
42
64
|
export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
|
|
65
|
+
/** codex R1-H2(journal 读面界):分页+单行字节门的投影读——SQL 端 LIMIT/OFFSET 定行数、LENGTH 门
|
|
66
|
+
* 定单行(超 maxResultBytes 的行 resultJson=null 只回 resultBytes,读面标 truncated)。HTTP 读面
|
|
67
|
+
* 优先走此面;缺席(旧实现/in-memory)回落全量 load(元素少的店可受)。 */
|
|
43
68
|
loadPage?(runId: string, scope: string, opts: {
|
|
44
69
|
offset: number;
|
|
45
70
|
limit: number;
|
|
@@ -50,34 +75,82 @@ export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
|
|
|
50
75
|
resultBytes: number;
|
|
51
76
|
}>>;
|
|
52
77
|
deleteByRun?(runId: string): Promise<number>;
|
|
78
|
+
/** SVC-2 GC sweep (durable twins only): purge entries older than `maxAgeMs` — wired into the reaper to bound the
|
|
79
|
+
* TaskResult-bearing table (the per-run deleteByRun has no run-store reap hook). Local InMemory omits it. */
|
|
53
80
|
reapExpired?(now: number, maxAgeMs: number): Promise<number>;
|
|
54
81
|
};
|
|
55
82
|
export type ApprovalStore = TiDBApprovalStore | PgApprovalStore;
|
|
56
83
|
export type ImageIndex = TiDBImageIndex | PgImageIndex;
|
|
57
84
|
export type ImageBake = TiDBImageBake | PgImageBake;
|
|
85
|
+
/** The FULL checkpoint store (core CheckpointStore + the service operator-queue/ctx methods listPending/
|
|
86
|
+
* listByScope/findPendingTokenBySession/peekPendingScope/putCtx/getCtx/reapCtx) — the SQL twins carry them,
|
|
87
|
+
* and the LOCAL lane now does too (core FileCheckpointStore + the service half — TOC plan-mode /
|
|
88
|
+
* durable HITL work on one box). */
|
|
58
89
|
export type CheckpointStoreFull = TiDBCheckpointStore | PgCheckpointStore | LocalCheckpointStore;
|
|
90
|
+
/** The full tool-result store: core `ToolResultStore` + the service maintenance extras. The SQL twins carry
|
|
91
|
+
* both extras; the LOCAL lane returns core's `FileToolResultStore` (core 1.219 — durable across a
|
|
92
|
+
* process restart, the TOC "ReadToolResult(ref) 恒空" fix) which carries NEITHER — consumers must optional-call
|
|
93
|
+
* (`store.reapOlderThan?.()`). Structural (not a nominal union) so all three backends flow through one seam. */
|
|
59
94
|
export type ToolResultStoreFull = ToolResultStore & {
|
|
95
|
+
/** TTL sweep (SQL twins only): purge rows older than the cutoff. Local file store omits it (CC posture:
|
|
96
|
+
* a single user's tool-result files persist like transcripts; bounded by being text previews). */
|
|
60
97
|
reapOlderThan?(cutoffMs: number): Promise<number>;
|
|
98
|
+
/** E21 purge (SQL twins only): delete `tr_<sessionId>_%` refs when a session is purged. */
|
|
61
99
|
deleteBySession?(sessionId: string): Promise<number>;
|
|
62
100
|
};
|
|
101
|
+
/** Cross-replica counter twins expose the write-behind lifecycle (startRefresh/stop) main.ts drives. */
|
|
63
102
|
export type BreakerStateStore = TiDBBreakerState | PgBreakerState;
|
|
64
103
|
export type CostQuotaStore = TiDBCostQuota | PgCostQuota;
|
|
65
104
|
export type RateLimiterStore = TiDBRateLimiter | PgRateLimiter;
|
|
66
105
|
export interface StoreBackend {
|
|
106
|
+
/** Protocol-truth kind (clay 2026-07-06 wording): "mysql" = any MySQL-protocol server (MySQL / TiDB /
|
|
107
|
+
* MariaDB) behind the one mysql2 pool — the startup summary prints durable(mysql) for all of them. */
|
|
67
108
|
readonly kind: "mysql" | "pg" | "local";
|
|
109
|
+
/** Connect + create schema (also the reachability probe). */
|
|
68
110
|
ensureSchema(): Promise<void>;
|
|
69
111
|
close(): Promise<void>;
|
|
70
112
|
run(): RunStore;
|
|
113
|
+
/** E18 resume-at eventId→entryId map. REQUIRED on all backends (works local — needs only the session tree + this
|
|
114
|
+
* map, no cloud-only checkpoint), unlike the optional cloud-only stores below. */
|
|
71
115
|
resumeAnchor(): ResumeAnchorStore;
|
|
116
|
+
/** Per-session per-toolName approval exemption ("本会话不再询问") — an approval MEMORY the F4
|
|
117
|
+
* ask-gate consults after deny/neverAuto. REQUIRED on all backends (works local, like resumeAnchor). */
|
|
72
118
|
approvalExemption(): ApprovalExemptionStore;
|
|
119
|
+
/** SendUserFile scope↔object ledger (multi-tenant list/revoke handle; the hashed key segment hides the
|
|
120
|
+
* mapping from URLs). REQUIRED on all backends (works local — one JSONL, like approvalExemption). */
|
|
73
121
|
sendFileLedger(): SendFileLedger;
|
|
122
|
+
/** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). REQUIRED on all backends — works local
|
|
123
|
+
* (local = core's InMemorySessionPolicyStore), like resumeAnchor. Backs core's RunnerDeps.sessionPolicyStore. */
|
|
74
124
|
sessionPolicy(): ServiceSessionPolicyStore;
|
|
125
|
+
/** E19 rewind-files FileSnapshotStore (working-tree snapshot/restore keyed by entryId; also the 2c artifact-transfer
|
|
126
|
+
* store). REQUIRED on all backends (local = core's InMemoryFileSnapshotStore). Backs core's RunnerDeps.fileSnapshotStore. */
|
|
75
127
|
fileSnapshot(): ServiceFileSnapshotStore;
|
|
128
|
+
/** SVC-2 (core CORE-7) durable WorkflowJournalStore — the cross-replica resume journal for an LLM-authored workflow
|
|
129
|
+
* (RunWorkflowOptions.journalStore). REQUIRED on all backends (tidb/pg = durable twins; local = core's
|
|
130
|
+
* InMemoryWorkflowJournalStore, single-replica/in-process).
|
|
131
|
+
*
|
|
132
|
+
* ✅ WIRED (was "NOT YET WIRABLE, as of core 1.144.0" — that claim went STALE and sat here misleading readers
|
|
133
|
+
* until a 2026-07-25 doc-rot sweep caught it). core 1.145.0 added the seam this comment was waiting for:
|
|
134
|
+
* `RunnerDeps.workflowJournalStore` (now `@sema-agent/core` `dist/core/types.d.ts:708`) + `journalStore` on the
|
|
135
|
+
* run_workflow tool deps (`dist/orchestration/run-workflow-tool.d.ts:65`), and main.ts consumes it end-to-end:
|
|
136
|
+
* built at §run_workflow mount (`main.ts:1349`), threaded into RunnerDeps (`main.ts:1636`), reaped on the
|
|
137
|
+
* maintenance tick (`main.ts:2399`), and read by `GET /v1/workflows/:id/journal` (`main.ts:3077`, [1402]). */
|
|
76
138
|
workflowJournal(): ServiceWorkflowJournalStore;
|
|
139
|
+
/** design/73 §1 consumption sink for `RunnerDeps.onTaskOutcome` facts. REQUIRED on all backends:
|
|
140
|
+
* tidb/pg = the outcome-ledger twins (SQL rows, mapped via coreOutcomeToLedgerRow + verbatim core_outcome
|
|
141
|
+
* JSON); local = an owner-only JSONL File sink. Read-only v1 — records facts, drives no policy. */
|
|
77
142
|
outcomeSink(): OutcomeSink;
|
|
143
|
+
/** P1 (fleet failover): durable cross-replica WorkflowRunStore + completion-inbox twins. OPTIONAL —
|
|
144
|
+
* SQL backends only (local keeps the File pair: single box, no cross-replica surface). main.ts prefers
|
|
145
|
+
* these under WORKFLOW_RUN_STORE=auto (the default). */
|
|
78
146
|
workflowRun?(): import("@sema-agent/core").WorkflowRunStore;
|
|
79
147
|
completionInbox?(onWarn?: InboxWarn): import("../orchestration/workflow-completion-inbox.js").WorkflowCompletionInbox;
|
|
148
|
+
/** 1.108 review fix (lens③ HIGH): the notify-JOURNAL twin — third leg of the same axis (a SQL run store +
|
|
149
|
+
* inbox with a replica-LOCAL File journal stranded a dead replica's un-acked notify forever). */
|
|
80
150
|
notifyJournal?(): import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore;
|
|
151
|
+
/** Cloud-only stores below are OPTIONAL: the `local` (in-memory/file) backend omits them (it has no core
|
|
152
|
+
* in-memory twin carrying the service extras, and these are fleet/multi-replica concepts), so a local HTTP
|
|
153
|
+
* service degrades EXACTLY like today's no-DB env (the consumers gate on `backend?.X?.()`). TiDB/PG provide all. */
|
|
81
154
|
checkpoint?(logger?: {
|
|
82
155
|
info?(msg: string, meta?: unknown): void;
|
|
83
156
|
}): CheckpointStoreFull;
|
|
@@ -88,14 +161,44 @@ export interface StoreBackend {
|
|
|
88
161
|
breaker?(onWriteFail?: (streak: number) => void): BreakerStateStore;
|
|
89
162
|
costQuota?(limitMicroUsd: number, windowMs: number, onDegraded?: CounterDegradeHook): CostQuotaStore;
|
|
90
163
|
rateLimiter?(limit: number, onDegraded?: CounterDegradeHook): RateLimiterStore;
|
|
164
|
+
/** Session store (caller wraps caching). DB-backed on tidb/pg; the in-memory/file `LocalSessionStore` on local. */
|
|
91
165
|
session(): SessionStore;
|
|
166
|
+
/** The raw mysql2 pool — ONLY on the TiDB backend (undefined on PG). For the few TiDB-specific raw-SQL
|
|
167
|
+
* consumers outside the store abstraction (session audit, degenerate-output instrument); those features are
|
|
168
|
+
* no-ops on PG until ported. */
|
|
92
169
|
mysqlPool(): MysqlPool | undefined;
|
|
170
|
+
/** S3-TOB(设计 §1.4):the raw PG pool for the memory-engine DB backend's PgQueryFn binding (mirror of
|
|
171
|
+
* mysqlPool). undefined on non-PG backends. */
|
|
93
172
|
pgPool(): PgPool | undefined;
|
|
173
|
+
/** S10 (SILENT-FALLBACK P1): the DB server's wall clock in epoch ms — the reaper probes it against the local
|
|
174
|
+
* clock to expose replica clock skew (the write-behind counters bucket on LOCAL floor(now/windowMs); skew
|
|
175
|
+
* splits a fleet window into disjoint buckets = soft-limit leak). OPTIONAL: local backend omits (no fleet). */
|
|
94
176
|
dbNowMs?(): Promise<number>;
|
|
95
177
|
}
|
|
178
|
+
/** (c)(clay 拍 a+c,2026-07-27)云形快照 blob 姿势门——boot 时调用(main.ts),纯函数可单测。
|
|
179
|
+
* SQL 后端(mysql|pg)把 blob 字节落 `snapshot_blob` 单行的形已被两役实证撞 mysql-协议包墙
|
|
180
|
+
* (D-1 附件 → 对象存储裁定;snapshot_blob >31MiB 同墙):大字节归对象存储。云形缺 MinIO ⇒
|
|
181
|
+
* fail-loud(启动了才是假安全);`SNAPSHOT_BLOB_ALLOW_SQL_BYTES=true` = 显式接受 SQL 店 +
|
|
182
|
+
* per-blob 帽(单机/测试台形)。local 后端不经此门(file/in-memory 快照店,无 SQL 包墙)。 */
|
|
96
183
|
export declare function assertCloudSnapshotBlobPosture(kind: "mysql" | "pg" | "local", config: Pick<ServiceConfig, "snapshotBlobStore" | "snapshotBlobAllowSql">): void;
|
|
184
|
+
/** REWIND_SNAPSHOT_MAX_MB overrides ONLY the byte cap of core's DEFAULT_SNAPSHOT_BOUNDS (raise for
|
|
185
|
+
* big monorepos, lower for tight DBs). File-count / ignoreDirs stay core defaults — the knob answers the one
|
|
186
|
+
* field the 20G-workspace case needed; more knobs when a case shows up. Exported for tests
|
|
187
|
+
* (fractional-MB rounding + partial-merge semantics need a regression lock). */
|
|
97
188
|
export declare function snapshotBoundsFromConfig(config: ServiceConfig): FileSnapshotBounds;
|
|
189
|
+
/** Build the durable-store backend for `config.dbBackend`. Does NOT connect (the pool connects lazily; the
|
|
190
|
+
* reachability probe is the caller's first `ensureSchema`). Returns undefined when no DB is configured. */
|
|
98
191
|
export declare function createStoreBackend(config: ServiceConfig): StoreBackend | undefined;
|
|
192
|
+
/** boot 期打开 store 后端的**统一入口**:构造 + ensureSchema 同罩一层降级臂。
|
|
193
|
+
*
|
|
194
|
+
* 为什么必须把 `createStoreBackend()` 也罩进来(2026-07-28 修):clay 1.292 拍的口径是「裸 boot
|
|
195
|
+
* **默认推导**的 local 在只读文件系统/mkdir 失败时不得拒启」,但原先 try 只罩 `ensureSchema()`——
|
|
196
|
+
* 而 LocalBackend 的 `ensureSchema` 是**空实现**,真正会抛的 mkdir + 数据根 BootLock 在构造函数里、
|
|
197
|
+
* 落在 try 之外。于是那条降级臂对 local 形从来没生效过,注释宣称的行为与代码真做的事撕裂。
|
|
198
|
+
*
|
|
199
|
+
* 降级条件不变(两形同一姿势):`sessionBackend=auto`(配置的 DB 不可达,S5 原形)或**默认推导**的
|
|
200
|
+
* local(`dbBackend=local && !dbBackendExplicit`)。**显式** DB_BACKEND=local / tidb 仍 fail-loud——
|
|
201
|
+
* operator 要了 durable,静默丢=丢数据。 */
|
|
99
202
|
export declare function openStoreBackendWithFallback(config: ServiceConfig, logger: {
|
|
100
203
|
warn: (msg: string, meta?: Record<string, unknown>) => void;
|
|
101
204
|
}): Promise<{
|