@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,12 +1,34 @@
|
|
|
1
1
|
import type { EffectiveConfig } from "./types.js";
|
|
2
2
|
export type RestartSlice = "skills" | "mcp" | "scenarios" | "runtime-gates" | "models-tiers";
|
|
3
|
+
/** Structured restart signal an orchestrator consumes (GET /health → `restart`). Change-detected against the
|
|
4
|
+
* process's BOOT config, NOT presence — so it stays absent when nothing baked-at-boot changed (presence would
|
|
5
|
+
* re-fire every refresh → a restart LOOP). `restartRequired` is always true when this object exists. */
|
|
3
6
|
export interface RestartSignal {
|
|
4
7
|
restartRequired: true;
|
|
8
|
+
/** Which restart-to-apply slices differ from the value baked at boot. */
|
|
5
9
|
reasons: RestartSlice[];
|
|
10
|
+
/** The sema-registry version that currently differs from boot (latest seen). */
|
|
6
11
|
version: number;
|
|
12
|
+
/** Epoch ms when this restart first became required (stable across refreshes while `reasons` is unchanged). */
|
|
7
13
|
since: number;
|
|
8
14
|
}
|
|
15
|
+
/** Restart-to-apply slices that DIFFER between this process's BOOT config and a freshly-pulled one. Empty =
|
|
16
|
+
* nothing baked-at-boot changed (only hot-apply slices moved, or nothing) → no restart needed. An orchestrator
|
|
17
|
+
* can auto rolling-restart on a non-empty result WITHOUT a restart loop, because the comparison is always
|
|
18
|
+
* against boot (a refresh that re-fires the same diff is idempotent, not a fresh trigger). */
|
|
9
19
|
export declare function restartReasons(boot: EffectiveConfig | undefined, current: EffectiveConfig): RestartSlice[];
|
|
20
|
+
/** codex R10 (models-tiers 窗收口): TRUE when the MODEL PLANE (enabled models + active tier table + resolved
|
|
21
|
+
* default) of `next` differs from the last-APPLIED plane `prev`. Under a tier-frozen Runner (tiers non-empty at
|
|
22
|
+
* construction → private expanded copy) main.ts DEFERS the whole plane mutation until restart when this is true —
|
|
23
|
+
* admission (/v1/models, the catalog gates) and the Runner then stay on ONE generation through the restart
|
|
24
|
+
* window, so a same-key retarget can never silently route/bill the stale Model object. `prev === undefined`
|
|
25
|
+
* (env-boot plane, no EffectiveConfig to compare) is conservatively "changed" — one deferred adoption + restart
|
|
26
|
+
* converges. Deliberately NOT gated on tier activity of either side (unlike the restart slice): a frozen Runner
|
|
27
|
+
* goes stale on ANY plane change, including a tiers-off flip. */
|
|
28
|
+
/** codex R12: TRUE when this candidate resolves an ACTIVE tier table. Used by main.ts's defer predicate — a
|
|
29
|
+
* tier-less-booted Runner never re-runs expandTiers, so hot-applying an ARRIVING tier table splits admission
|
|
30
|
+
* (tier words pass the expanded gate) from execution (core throws "Unknown model ref"). Hot-apply of the model
|
|
31
|
+
* plane is safe only when BOTH the constructed generation and the candidate are tier-less. */
|
|
10
32
|
export declare function planeHasActiveTiers(eff: EffectiveConfig): boolean;
|
|
11
33
|
export declare function modelPlaneChanged(prev: EffectiveConfig | undefined, next: EffectiveConfig): boolean;
|
|
12
34
|
//# sourceMappingURL=restart-signal.d.ts.map
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restart-to-apply CHANGE detection — the structured `RestartSignal` an orchestrator consumes (GET /health →
|
|
3
|
+
* `restart`), computed against the process's BOOT config (not presence, else a refresh would re-fire the same
|
|
4
|
+
* diff and loop-restart). Also owns the model-plane deferral predicates (`planeHasActiveTiers`/
|
|
5
|
+
* `modelPlaneChanged`) main.ts uses to decide whether a hot-apply is safe under a tier-frozen Runner. Split out
|
|
6
|
+
* of `sema-registry.ts` (design/158 A13, internal-lossless — the facade re-exports every symbol below unchanged).
|
|
7
|
+
*/
|
|
1
8
|
import { resolveActiveTiers } from "@sema-agent/registry-core";
|
|
2
9
|
import { RUNTIME_GATE_KEYS, runtimeGatePresent, resolveDefaultModelName } from "./apply-effective.js";
|
|
3
10
|
const RESTART_SLICES = ["skills", "mcp", "scenarios", "runtime-gates", "models-tiers"];
|
|
11
|
+
/** Canonical, key-sorted JSON (array order preserved) so two semantically-equal effective slices fingerprint
|
|
12
|
+
* identically regardless of object key order from the center serializer. */
|
|
4
13
|
function stableStringify(v) {
|
|
5
14
|
if (v === null || typeof v !== "object")
|
|
6
15
|
return JSON.stringify(v) ?? "null";
|
|
@@ -12,6 +21,11 @@ function stableStringify(v) {
|
|
|
12
21
|
.map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`)
|
|
13
22
|
.join(",")}}`;
|
|
14
23
|
}
|
|
24
|
+
/** The comparable value of one restart-to-apply slice (undefined config / unpublished slice → null, so
|
|
25
|
+
* "center started/stopped publishing skills" is itself a detectable change). Skills/MCP/scenarios fingerprint
|
|
26
|
+
* ONLY the ENABLED entries — the runtime consumers (applyCenterSkills / resolveMcpServers / centerScenarios) skip
|
|
27
|
+
* `enabled:false`, so a disabled entry's content has zero runtime effect and must NOT trigger a restart.
|
|
28
|
+
* Every enable/disable FLIP still changes the filtered set → still triggers, correctly. */
|
|
15
29
|
function enabledOnly(rows) {
|
|
16
30
|
if (!rows)
|
|
17
31
|
return null;
|
|
@@ -38,19 +52,44 @@ function restartSliceValue(eff, slice) {
|
|
|
38
52
|
return Object.keys(present).length ? present : null;
|
|
39
53
|
}
|
|
40
54
|
case "models-tiers": {
|
|
55
|
+
// Fingerprint the models+tiers pair ONLY when this side resolves an active tier table (the Runner-copy
|
|
56
|
+
// decoupling only exists under tiers). Tier-less side → null: both sides tier-less never signals (hot-apply
|
|
57
|
+
// is real there); a tiers on/off FLIP is itself a detectable change (null vs object) — correctly signals,
|
|
58
|
+
// because the flip only takes effect at Runner construction.
|
|
41
59
|
const active = eff.models ? resolveActiveTiers(eff.models) : undefined;
|
|
42
60
|
if (!active || Object.keys(active).length === 0)
|
|
43
61
|
return null;
|
|
44
62
|
const enabled = enabledOnly(eff.models?.models);
|
|
63
|
+
// codex R8: the resolved DEFAULT rides the fingerprint too — the Runner's frozen copy carries its own
|
|
64
|
+
// boot-time `default` entry, so a refresh that ONLY moves the default source (models.default /
|
|
65
|
+
// roles.default / tier binding) re-points config.models.default while spec.model="default" keeps routing
|
|
66
|
+
// the stale Runner entry. SAME resolver as applyEffective (resolveDefaultModelName, single source);
|
|
67
|
+
// dangling candidates fall through silently here — applyEffective owns the warn.
|
|
45
68
|
const names = new Set((enabled ?? []).map((m) => m.name));
|
|
46
69
|
const def = resolveDefaultModelName(eff, (n) => names.has(n), enabled?.[0]?.name ?? "");
|
|
47
70
|
return { models: enabled, tiers: active, default: def.name };
|
|
48
71
|
}
|
|
49
72
|
}
|
|
50
73
|
}
|
|
74
|
+
/** Restart-to-apply slices that DIFFER between this process's BOOT config and a freshly-pulled one. Empty =
|
|
75
|
+
* nothing baked-at-boot changed (only hot-apply slices moved, or nothing) → no restart needed. An orchestrator
|
|
76
|
+
* can auto rolling-restart on a non-empty result WITHOUT a restart loop, because the comparison is always
|
|
77
|
+
* against boot (a refresh that re-fires the same diff is idempotent, not a fresh trigger). */
|
|
51
78
|
export function restartReasons(boot, current) {
|
|
52
79
|
return RESTART_SLICES.filter((s) => stableStringify(restartSliceValue(boot, s)) !== stableStringify(restartSliceValue(current, s)));
|
|
53
80
|
}
|
|
81
|
+
/** codex R10 (models-tiers 窗收口): TRUE when the MODEL PLANE (enabled models + active tier table + resolved
|
|
82
|
+
* default) of `next` differs from the last-APPLIED plane `prev`. Under a tier-frozen Runner (tiers non-empty at
|
|
83
|
+
* construction → private expanded copy) main.ts DEFERS the whole plane mutation until restart when this is true —
|
|
84
|
+
* admission (/v1/models, the catalog gates) and the Runner then stay on ONE generation through the restart
|
|
85
|
+
* window, so a same-key retarget can never silently route/bill the stale Model object. `prev === undefined`
|
|
86
|
+
* (env-boot plane, no EffectiveConfig to compare) is conservatively "changed" — one deferred adoption + restart
|
|
87
|
+
* converges. Deliberately NOT gated on tier activity of either side (unlike the restart slice): a frozen Runner
|
|
88
|
+
* goes stale on ANY plane change, including a tiers-off flip. */
|
|
89
|
+
/** codex R12: TRUE when this candidate resolves an ACTIVE tier table. Used by main.ts's defer predicate — a
|
|
90
|
+
* tier-less-booted Runner never re-runs expandTiers, so hot-applying an ARRIVING tier table splits admission
|
|
91
|
+
* (tier words pass the expanded gate) from execution (core throws "Unknown model ref"). Hot-apply of the model
|
|
92
|
+
* plane is safe only when BOTH the constructed generation and the candidate are tier-less. */
|
|
54
93
|
export function planeHasActiveTiers(eff) {
|
|
55
94
|
const active = eff.models ? resolveActiveTiers(eff.models) : undefined;
|
|
56
95
|
return active !== undefined && Object.keys(active).length > 0;
|
|
@@ -3,11 +3,30 @@ import type { ScopedMcpServer } from "../config-types.js";
|
|
|
3
3
|
import type { Logger } from "../observability/logger.js";
|
|
4
4
|
import type { LoadedSkill } from "../capabilities/skills.js";
|
|
5
5
|
import type { CenterMcpServer, CenterSkillManifest } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Merge center skills OVER the image baseline (design/41-sibling B1; `docs/MCP-SKILLS.md`). Load order =
|
|
8
|
+
* `loadSkills(SKILLS_DIR)` baseline → center skills lazily fetched by hash and overlaid BY NAME (center
|
|
9
|
+
* wins on a clash → can override a built-in; guarded center-side by publisher RBAC + the publish gate).
|
|
10
|
+
* `enabled:false` is skipped. Content is verified + cached by hash (same hash fetched once). A skill whose
|
|
11
|
+
* content fetch/verify fails is skipped (the baseline version, if any, stays) — never blocks startup.
|
|
12
|
+
* Restart-to-apply: this runs at boot, before `buildScenarios` bakes skills into scenarios.
|
|
13
|
+
*/
|
|
6
14
|
export declare function applyCenterSkills(baseline: LoadedSkill[], manifest: {
|
|
7
15
|
skills: CenterSkillManifest[];
|
|
8
|
-
}, baseUrl: string, token: string, logger?: Logger, fetchImpl?: typeof fetch,
|
|
16
|
+
}, baseUrl: string, token: string, logger?: Logger, fetchImpl?: typeof fetch,
|
|
17
|
+
/** LKG 姊妹面(clay 拍 2026-07-18):skill 正文的 content-addressed 盘缓存目录。读序=内存→盘(验
|
|
18
|
+
* hash,坏文件忽略)→中心(成功后 best-effort 回写)。让 LKG-boot 在中心不可达时不再于正文拉取上
|
|
19
|
+
* 挂数秒(live 实测黑洞 +5.3s/skill 批),顺带省正常 refresh 的重复拉取。undefined=无盘缓存(原行为)。 */
|
|
20
|
+
diskCacheDir?: string): Promise<LoadedSkill[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve center MCP servers (`/effective.mcp`) into core `McpServerSpec`s + the scenarios each applies to.
|
|
23
|
+
* env-NAME refs → real values from THIS service's env (secret boundary unchanged); a server with any missing
|
|
24
|
+
* ref is skipped (`resolveRefs` → null). `enabled:false` skipped. Restart-to-apply (filtered per scenario in
|
|
25
|
+
* `resolveSpec` via `mcpForScenario`).
|
|
26
|
+
*/
|
|
9
27
|
export declare function resolveMcpServers(mcp: {
|
|
10
28
|
servers: CenterMcpServer[];
|
|
11
29
|
}, logger?: Logger): ScopedMcpServer[];
|
|
30
|
+
/** The MCP servers applicable to a scenario: tagged with it, or untagged (global). undefined when none. */
|
|
12
31
|
export declare function mcpForScenario(servers: ScopedMcpServer[] | undefined, scenario: string): McpServerSpec[] | undefined;
|
|
13
32
|
//# sourceMappingURL=skills-mcp.d.ts.map
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two small consumption lanes that both project a center manifest domain onto a per-request runtime shape:
|
|
3
|
+
* skills application (`applyCenterSkills` — merge center skills OVER the image baseline, content-addressed
|
|
4
|
+
* fetch+verify+cache) and MCP server resolution (`resolveMcpServers`/`mcpForScenario` — env-NAME ref
|
|
5
|
+
* resolution + per-scenario filtering). Split out of `sema-registry.ts` (design/158 A13, internal-lossless —
|
|
6
|
+
* the facade re-exports every symbol below unchanged).
|
|
7
|
+
*/
|
|
1
8
|
import { skillContentHash } from "@sema-agent/registry-core";
|
|
2
9
|
import { fetchSkillContent } from "./http-client.js";
|
|
3
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Merge center skills OVER the image baseline (design/41-sibling B1; `docs/MCP-SKILLS.md`). Load order =
|
|
12
|
+
* `loadSkills(SKILLS_DIR)` baseline → center skills lazily fetched by hash and overlaid BY NAME (center
|
|
13
|
+
* wins on a clash → can override a built-in; guarded center-side by publisher RBAC + the publish gate).
|
|
14
|
+
* `enabled:false` is skipped. Content is verified + cached by hash (same hash fetched once). A skill whose
|
|
15
|
+
* content fetch/verify fails is skipped (the baseline version, if any, stays) — never blocks startup.
|
|
16
|
+
* Restart-to-apply: this runs at boot, before `buildScenarios` bakes skills into scenarios.
|
|
17
|
+
*/
|
|
18
|
+
export async function applyCenterSkills(baseline, manifest, baseUrl, token, logger, fetchImpl = fetch,
|
|
19
|
+
/** LKG 姊妹面(clay 拍 2026-07-18):skill 正文的 content-addressed 盘缓存目录。读序=内存→盘(验
|
|
20
|
+
* hash,坏文件忽略)→中心(成功后 best-effort 回写)。让 LKG-boot 在中心不可达时不再于正文拉取上
|
|
21
|
+
* 挂数秒(live 实测黑洞 +5.3s/skill 批),顺带省正常 refresh 的重复拉取。undefined=无盘缓存(原行为)。 */
|
|
22
|
+
diskCacheDir) {
|
|
4
23
|
const { promises: fsp } = await import("node:fs");
|
|
5
24
|
const { join: joinPath } = await import("node:path");
|
|
6
25
|
const diskRead = async (hash) => {
|
|
@@ -8,17 +27,21 @@ export async function applyCenterSkills(baseline, manifest, baseUrl, token, logg
|
|
|
8
27
|
return undefined;
|
|
9
28
|
const hex = hash.replace(/^sha256:/, "");
|
|
10
29
|
if (!/^[0-9a-f]{64}$/.test(hex))
|
|
11
|
-
return undefined;
|
|
30
|
+
return undefined; // hash 形不对=不碰盘(路径安全)
|
|
12
31
|
try {
|
|
13
32
|
const text = await fsp.readFile(joinPath(diskCacheDir, hex), "utf8");
|
|
14
33
|
if (skillContentHash(text) === hash)
|
|
15
|
-
return text;
|
|
34
|
+
return text; // content-addressed:必验,坏文件=undefined 走中心
|
|
16
35
|
logger?.warn("sema_registry_skill_cache_corrupt", { hash, note: "on-disk body fails its own hash — ignored, refetching from center" });
|
|
17
36
|
}
|
|
18
37
|
catch {
|
|
38
|
+
/* absent/unreadable → center */
|
|
19
39
|
}
|
|
20
40
|
return undefined;
|
|
21
41
|
};
|
|
42
|
+
// F5(LKG 复审三轮):写盘 promises 收集、函数返回前 await——fire-and-forget 会让 persistLkgDurable
|
|
43
|
+
// 的「先落正文再发信号」序失效(await 只等到 fetch,rename 还在飞,窗口内重启=离线 boot 缺 skill)。
|
|
44
|
+
// 单写失败仍 warn 软降级(收集的是 catch 过的 promise,Promise.all 不会炸)。
|
|
22
45
|
const pendingWrites = [];
|
|
23
46
|
const diskWrite = (hash, content) => {
|
|
24
47
|
if (!diskCacheDir)
|
|
@@ -32,8 +55,8 @@ export async function applyCenterSkills(baseline, manifest, baseUrl, token, logg
|
|
|
32
55
|
})().catch((err) => logger?.warn("sema_registry_skill_cache_write_failed", { hash, err: String(err) })));
|
|
33
56
|
};
|
|
34
57
|
const byName = new Map(baseline.map((s) => [s.spec.name, s]));
|
|
35
|
-
const contentCache = new Map();
|
|
36
|
-
const seenNames = new Set();
|
|
58
|
+
const contentCache = new Map(); // content-addressed: same hash fetched once
|
|
59
|
+
const seenNames = new Set(); // duplicate names WITHIN the center manifest collapse last-wins — warn so a bad publish is diagnosable
|
|
37
60
|
for (const m of manifest.skills ?? []) {
|
|
38
61
|
if (m.enabled === false)
|
|
39
62
|
continue;
|
|
@@ -46,7 +69,7 @@ export async function applyCenterSkills(baseline, manifest, baseUrl, token, logg
|
|
|
46
69
|
content = await diskRead(m.contentHash);
|
|
47
70
|
if (content === undefined) {
|
|
48
71
|
content = await fetchSkillContent(baseUrl, token, m.contentHash, fetchImpl);
|
|
49
|
-
diskWrite(m.contentHash, content);
|
|
72
|
+
diskWrite(m.contentHash, content); // best-effort 回写(content-addressed,幂等)
|
|
50
73
|
}
|
|
51
74
|
contentCache.set(m.contentHash, content);
|
|
52
75
|
const overrodeBuiltin = byName.has(m.name);
|
|
@@ -57,9 +80,12 @@ export async function applyCenterSkills(baseline, manifest, baseUrl, token, logg
|
|
|
57
80
|
logger?.warn("sema_registry_skill_failed", { name: m.name, hash: m.contentHash, err: String(err), note: "keeping baseline if any; skipping center version" });
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
|
-
await Promise.all(pendingWrites);
|
|
83
|
+
await Promise.all(pendingWrites); // F5:返回=正文已 durable(或已 warn),调用方的落盘序才成立
|
|
61
84
|
return [...byName.values()];
|
|
62
85
|
}
|
|
86
|
+
/** Resolve env-NAME refs (target-key → ENV_NAME) to real values from THIS service's env. Returns null when
|
|
87
|
+
* ANY referenced env var is unset → the caller skips the whole server (fail-safe: never wire a half-credentialed
|
|
88
|
+
* endpoint). Mirrors the missing-apiKeyEnv handling for models (the secret boundary is unchanged). */
|
|
63
89
|
function resolveRefs(refs, server, kind, logger) {
|
|
64
90
|
if (!refs)
|
|
65
91
|
return {};
|
|
@@ -74,12 +100,20 @@ function resolveRefs(refs, server, kind, logger) {
|
|
|
74
100
|
}
|
|
75
101
|
return out;
|
|
76
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolve center MCP servers (`/effective.mcp`) into core `McpServerSpec`s + the scenarios each applies to.
|
|
105
|
+
* env-NAME refs → real values from THIS service's env (secret boundary unchanged); a server with any missing
|
|
106
|
+
* ref is skipped (`resolveRefs` → null). `enabled:false` skipped. Restart-to-apply (filtered per scenario in
|
|
107
|
+
* `resolveSpec` via `mcpForScenario`).
|
|
108
|
+
*/
|
|
77
109
|
export function resolveMcpServers(mcp, logger) {
|
|
78
110
|
const out = [];
|
|
79
111
|
for (const s of mcp.servers ?? []) {
|
|
80
112
|
if (s.enabled === false)
|
|
81
113
|
continue;
|
|
82
114
|
const allow = s.allowTools && s.allowTools.length > 0 ? { allowTools: s.allowTools } : {};
|
|
115
|
+
// E23 (shell-host contract): carry the per-server inbound-elicitation opt-in onto McpServerSpec.elicitation. Only when
|
|
116
|
+
// explicitly true (default OFF / fail-closed) — core advertises the capability only when this AND onElicit hold.
|
|
83
117
|
const elicit = s.elicitation === true ? { elicitation: true } : {};
|
|
84
118
|
if (s.transport.kind === "stdio") {
|
|
85
119
|
const env = resolveRefs(s.transport.envRefs, s.name, "env", logger);
|
|
@@ -104,6 +138,7 @@ export function resolveMcpServers(mcp, logger) {
|
|
|
104
138
|
logger?.info("sema_registry_mcp", { servers: out.map((s) => s.spec.name) });
|
|
105
139
|
return out;
|
|
106
140
|
}
|
|
141
|
+
/** The MCP servers applicable to a scenario: tagged with it, or untagged (global). undefined when none. */
|
|
107
142
|
export function mcpForScenario(servers, scenario) {
|
|
108
143
|
if (!servers || servers.length === 0)
|
|
109
144
|
return undefined;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config-center wire types — the sema-registry `/api/config/effective` payload shapes (`CenterModel`,
|
|
3
|
+
* `CenterTeam`, `CenterSkillManifest`, `CenterMcpServer`, `EffectiveConfig`) plus the per-principal
|
|
4
|
+
* execution/session-mirror ruling shapes riding the caps view (`ExecutionRuling`/`SessionMirrorRuling`).
|
|
5
|
+
* Pure type/interface declarations — no runtime logic. Split out of `sema-registry.ts` (design/158 A13,
|
|
6
|
+
* internal-lossless: the facade re-exports every symbol below unchanged).
|
|
7
|
+
*/
|
|
1
8
|
import type { CollabTemplateWire } from "../capabilities/collab-wire.js";
|
|
2
9
|
import type { Autonomy, CommandRule } from "../runtime-governance.js";
|
|
3
10
|
export interface CenterModel {
|
|
@@ -7,6 +14,10 @@ export interface CenterModel {
|
|
|
7
14
|
api: "openai-completions" | "anthropic-messages";
|
|
8
15
|
baseUrl?: string;
|
|
9
16
|
apiKeyEnv?: string;
|
|
17
|
+
/** registry-core 0.10.5 sealed-box 托管密文(浏览器端 crypto_box_seal 封给执行域公钥,center
|
|
18
|
+
* 只存密文)。执行侧按 publicKeyId 精确选本机私钥解封 → 明文进内存 key 管道(config.modelApiKeys)。
|
|
19
|
+
* 互斥语义(契约):与 apiKeyEnv 双设 = sealed 优先,且解封失败**不回落** env 引用(fail-loud,见
|
|
20
|
+
* applyEffective)。🔴 ciphertext 绝不进任何日志(registry-core write-only 纪律的执行侧半场)。 */
|
|
10
21
|
sealedApiKey?: {
|
|
11
22
|
ciphertext: string;
|
|
12
23
|
publicKeyId: string;
|
|
@@ -18,7 +29,12 @@ export interface CenterModel {
|
|
|
18
29
|
vision?: boolean;
|
|
19
30
|
contextWindow?: number;
|
|
20
31
|
maxTokens?: number;
|
|
32
|
+
/** [818]① 1M dual-window (core 1.289 `Model.autoCompactTokens`): an EXPLICIT roster value wins the
|
|
33
|
+
* contextWindow derivation in toModel (applyAutoCompactWindow). Declared on the type face (codex F5) so the
|
|
34
|
+
* config-provider local-lane projection carries it — toModel keeps its structural read for older shapes. */
|
|
21
35
|
autoCompactTokens?: number;
|
|
36
|
+
/** design/123 D2 (core 1.226): chars ≈ 1 token for this model's tokenizer, feeding every structural
|
|
37
|
+
* (non-usage-anchored) token estimate. CJK-heavy models should declare 2–3; absent → env default → core 4. */
|
|
22
38
|
charsPerToken?: number;
|
|
23
39
|
cost?: {
|
|
24
40
|
input: number;
|
|
@@ -26,10 +42,26 @@ export interface CenterModel {
|
|
|
26
42
|
cacheRead?: number;
|
|
27
43
|
cacheWrite?: number;
|
|
28
44
|
};
|
|
45
|
+
/** registry-core 0.6.0 配额倍率(models 域 ModelEntry.quotaWeight,缺省=1):weight-at-burn——
|
|
46
|
+
* 记账时固化进 UsageEntry.{weightedTokens,quotaWeightAtUse} 与 lease weightedTokens 轴;改倍率只影响
|
|
47
|
+
* 此后记账,不回算窗口内历史(registry types.d.ts 同句契约)。 */
|
|
29
48
|
quotaWeight?: number;
|
|
49
|
+
/** design/111 L2②: per-model declarative thinking config (center roster). defaultThinking = this model's DEFAULT
|
|
50
|
+
* tier (resolution chain spec.thinking ?? role.thinking ?? model.defaultThinking); reasoningEffortLevels (openai
|
|
51
|
+
* endpoints) = tiers the endpoint accepts. Validated against core's ThinkingLevel in toModel; "off" is dropped. */
|
|
30
52
|
defaultThinking?: string;
|
|
31
53
|
reasoningEffortLevels?: string[];
|
|
54
|
+
/** Generation-tuning passthrough, mirrors core `Model.extraBody` (1.60) — e.g. frequency/presence
|
|
55
|
+
* penalties that *prevent* degenerate looping. Same category as `cost`/`tier`: logical model metadata,
|
|
56
|
+
* no secrets. Carried through `toModel()` verbatim. When a center roster replaces the env model this is
|
|
57
|
+
* the ONLY way to keep per-model tuning that lived in env (`MODEL_FREQUENCY_PENALTY` etc.) — see the
|
|
58
|
+
* review-gw heterogeneous-roster migration. MUST be static per published version (prompt-cache prefix). */
|
|
32
59
|
extraBody?: Record<string, unknown>;
|
|
60
|
+
/** registry-core 0.10.13 ([1002]/[998]⑤c): per-model behavior-slot mitigation sentences, mirrors core
|
|
61
|
+
* `Model.promptGuidance` (core 1.303+ assembles them into the volatile tail's per-model position).
|
|
62
|
+
* Same category as `extraBody`: logical model metadata, carried verbatim — without this projection the
|
|
63
|
+
* configured sentences parse fine in registry-core but never reach the assembly face ([1028]① 排雷:
|
|
64
|
+
* the missing leg made every promptGuidance pilot a false control). */
|
|
33
65
|
promptGuidance?: string[];
|
|
34
66
|
enabled?: boolean;
|
|
35
67
|
}
|
|
@@ -56,6 +88,7 @@ export interface CenterTeam {
|
|
|
56
88
|
maxTranscriptTokens?: number;
|
|
57
89
|
enabled?: boolean;
|
|
58
90
|
}
|
|
91
|
+
/** Skill MANIFEST entry (content is NOT inline — fetched by hash; see `fetchSkillContent`). */
|
|
59
92
|
export interface CenterSkillManifest {
|
|
60
93
|
name: string;
|
|
61
94
|
description: string;
|
|
@@ -63,18 +96,27 @@ export interface CenterSkillManifest {
|
|
|
63
96
|
contentHash: string;
|
|
64
97
|
enabled?: boolean;
|
|
65
98
|
}
|
|
99
|
+
/** MCP server registry entry. `envRefs`/`headerRefs` are env-NAME refs (target-key → ENV_NAME), NOT secrets. */
|
|
66
100
|
export interface CenterMcpServer {
|
|
67
101
|
name: string;
|
|
68
102
|
scenarios: string[];
|
|
69
103
|
enabled?: boolean;
|
|
70
104
|
allowTools?: string[];
|
|
105
|
+
/** E23 (shell-host contract): opt THIS server into INBOUND elicitation — it may ask the END USER for input mid-tool-call.
|
|
106
|
+
* Maps to `McpServerSpec.elicitation`; core advertises the capability ONLY when this is true AND the service wired
|
|
107
|
+
* `RunnerDeps.onElicit` (MCP_ELICITATION_ENABLED). Default OFF (omitted) — a server cannot pull a human into the
|
|
108
|
+
* loop unless an operator explicitly opts it in. */
|
|
71
109
|
elicitation?: boolean;
|
|
72
110
|
transport: {
|
|
73
111
|
kind: "stdio";
|
|
74
112
|
command: string;
|
|
75
113
|
args?: string[];
|
|
76
114
|
envRefs?: Record<string, string>;
|
|
77
|
-
}
|
|
115
|
+
}
|
|
116
|
+
/** `principalHeader` (design/62): the header name into which the runner injects the task's authenticated
|
|
117
|
+
* end-user principal per-task, so a consumer MCP (e.g. oa-mcp) can enforce per-user RBAC. Not a ref — a
|
|
118
|
+
* literal header name. The runner fills the value (never the model). */
|
|
119
|
+
| {
|
|
78
120
|
kind: "http";
|
|
79
121
|
url: string;
|
|
80
122
|
headerRefs?: Record<string, string>;
|
|
@@ -89,9 +131,15 @@ export interface EffectiveConfig {
|
|
|
89
131
|
roles: Record<string, CenterRoleTarget>;
|
|
90
132
|
atModelAllowlist?: string[];
|
|
91
133
|
};
|
|
134
|
+
/** OPTIONAL since registry-core 0.7 deleted the teams domain: a 0.7+ center /effective payload
|
|
135
|
+
* has NO teams key (collab is its successor). Absent/empty ⇒ registerTeams resets to BUILTIN_TEAMS (the
|
|
136
|
+
* permanent builtin base). */
|
|
92
137
|
teams?: {
|
|
93
138
|
teams: CenterTeam[];
|
|
94
139
|
};
|
|
140
|
+
/** registry-core 0.7 collab domain (teams' successor) — consumed by the slice-① read-only
|
|
141
|
+
* projection (projectCollabToTeams → registerTeams). Both lanes carry it: the remote worker /effective view
|
|
142
|
+
* ships collab, and local FileConfigStore reads config.d/collab.json (PORTABLE_DOMAINS includes collab). */
|
|
95
143
|
collab?: {
|
|
96
144
|
templates: CollabTemplateWire[];
|
|
97
145
|
};
|
|
@@ -101,6 +149,11 @@ export interface EffectiveConfig {
|
|
|
101
149
|
mcp?: {
|
|
102
150
|
servers: CenterMcpServer[];
|
|
103
151
|
};
|
|
152
|
+
/** Center-declared scenarios (composition-as-config; capability stays code-pinned): each entry names a
|
|
153
|
+
* deploy-registered TOOLSET (`none` / `repo-readonly`) + an optional static prompt (≤4KB, audited at
|
|
154
|
+
* publish). Restart-to-apply like skills/mcp (baked into the scenario table at boot). Center entries
|
|
155
|
+
* MAY shadow built-in scenario names (clay 2026-06-11: usability first) — shadows are logged at boot.
|
|
156
|
+
* Validation/registry live in capabilities/scenarios.ts `centerScenarios`. */
|
|
104
157
|
scenarios?: {
|
|
105
158
|
scenarios: Array<{
|
|
106
159
|
name: string;
|
|
@@ -108,6 +161,9 @@ export interface EffectiveConfig {
|
|
|
108
161
|
enabled?: boolean;
|
|
109
162
|
}>;
|
|
110
163
|
};
|
|
164
|
+
/** Fleet governance/limit gates (phase-2, center SERVICE-INTEGRATION「Runtime 治理/限额闸」). All restart-to-apply,
|
|
165
|
+
* non-secret, all center `.optional()` (center `f95438a`): absent = unmanaged → keep env; present (incl. an
|
|
166
|
+
* explicit 0/[] = "publish OFF") = override. Consumption precedence is in `applyRuntimeGates`. */
|
|
111
167
|
runtime?: {
|
|
112
168
|
rateLimitPerMin?: number;
|
|
113
169
|
approvalRequire?: string[];
|
|
@@ -115,27 +171,62 @@ export interface EffectiveConfig {
|
|
|
115
171
|
maxTaskTokens?: number;
|
|
116
172
|
maxPrincipalCostUsd?: number;
|
|
117
173
|
costQuotaWindowSec?: number;
|
|
174
|
+
/** Runtime governance second baton (center §10): autonomy mode + per-command rules. UNLIKE the 6 gates above,
|
|
175
|
+
* these are per-request HOT (read live in resolveSpec, not baked into boot middleware) → applied on boot AND
|
|
176
|
+
* refresh by `applyRuntimeHot` (NOT in RUNTIME_GATE_KEYS / restart-to-apply). Same presence rule (undefined =
|
|
177
|
+
* unmanaged → keep). */
|
|
118
178
|
autonomy?: Autonomy;
|
|
119
179
|
commandPolicy?: CommandRule[];
|
|
120
180
|
};
|
|
181
|
+
/** 142-S4(registry-core 0.10.0 第 15 域):center 项目登记簿。wire 面 verbatim JSON —
|
|
182
|
+
* registry-core `ProjectsConfig` 的形状是 `{projects: Record<projectId, ProjectRegistration>}`(skills/mcp
|
|
183
|
+
* 同款域包裹),但本 interface 宽读两种形态(包裹/裸 Record——projectId 是 UUID,永远不会撞 "projects"
|
|
184
|
+
* 字面键,判包裹无歧义)。消费=applyEffective → config.projects(displayName/gitRemotes/defaultScopes
|
|
185
|
+
* 三个 runtime 字段;审计字段不进 ServiceConfig)。 */
|
|
121
186
|
projects?: {
|
|
122
187
|
projects?: Record<string, unknown>;
|
|
123
188
|
} | Record<string, unknown>;
|
|
189
|
+
/** registry-core 0.6:治理三件(autonomy/commandPolicy/approvalRequire)拆新 governance 域=真值;
|
|
190
|
+
* 过渡期 effective 在 runtime 位双写镜像。读取优先 governance 新位、runtime 旧位 fallback(顺序契约:
|
|
191
|
+
* 消费端先切换、确认后 center 才撤双写,治理闸零 fail-open 窗口)。 */
|
|
124
192
|
governance?: {
|
|
125
193
|
autonomy?: Autonomy;
|
|
126
194
|
commandPolicy?: CommandRule[];
|
|
127
195
|
approvalRequire?: string[];
|
|
128
196
|
};
|
|
197
|
+
/** plugins 域(registry-core 0.5 additive;契约冻结 [1361]②/[1362]/[1366]①,消费半场 2026-07-28
|
|
198
|
+
* 开工车):center 只存"插件从哪来"(PluginSpec 引用,永不承载可执行字节);worker 半场在
|
|
199
|
+
* capabilities/center-plugins.ts `applyCenterPlugins`(https-only+ALLOW_HOSTS 纵深复验/sha 钉扎/
|
|
200
|
+
* 隔离 clone/LKG/撞名让位)。此前本 interface 无此键 ⇒ wire 上的 plugins 被 server 静默丢弃。 */
|
|
129
201
|
plugins?: {
|
|
130
202
|
plugins?: unknown[];
|
|
131
203
|
};
|
|
204
|
+
/** prompts 域(additive key;双轴 wire=registry-core `EffectivePromptsWire` 或 legacy 平铺形——
|
|
205
|
+
* server 侧判形/采用全在 capabilities/center-prompts.ts `validatePromptsDomain`,本 interface 只
|
|
206
|
+
* 声明键位存在(unknown:候选门是唯一解释者,这里不复刻形)。 */
|
|
132
207
|
prompts?: unknown;
|
|
133
208
|
}
|
|
209
|
+
/** (stage7 P5,registry-core 0.8 `execution` 域): the center-resolved per-principal execution
|
|
210
|
+
* ruling riding the caps view. `required=false` / ruling absent = no enforcement (legacy). `allowedLanes` is
|
|
211
|
+
* an OPEN value domain (adding one is never BREAKING; consumers tolerate unknown names). Known lane names:
|
|
212
|
+
* `host`/`e2b`/`k8s`/`ssh`/`adb`/`local-docker` (the REMOTE_EXEC providers) **plus `in-process`** — the
|
|
213
|
+
* REMOTE_EXEC-unset fleet posture (OA/review-style workers; named distinctly from the explicit
|
|
214
|
+
* `host` lane on purpose). ⚠️ Admins writing `required=true` policies must include `in-process` when such
|
|
215
|
+
* workers should stay admittable — center UI/doc 词表待补齐。 */
|
|
134
216
|
export interface ExecutionRuling {
|
|
135
217
|
required: boolean;
|
|
136
218
|
allowedLanes: string[];
|
|
219
|
+
/** registry-core 0.10.1-0.10.2:org 会话镜像策略,
|
|
220
|
+
* execution 域收编字段,center 若把它附在 caps view 的 execution ruling 上则宽读透传(缺席=老
|
|
221
|
+
* center/未配置 → undefined,零行为差)。**server 侧只做观测面,不是执法面**——「该镜像而未镜像」
|
|
222
|
+
* 的违规发生在数据产生端(壳),server 收不到该信号(论证见 http/server.ts sync/import 的
|
|
223
|
+
* session_mirror audit 注释);本字段供 audit 日志/metrics 关联镜像到达与治理态。 */
|
|
137
224
|
sessionMirror?: SessionMirrorRuling;
|
|
138
225
|
}
|
|
226
|
+
/** 两层形状(registry-core `SessionMirrorPolicy` 的消费侧镜像):`required:false`=便利默认值(壳解析
|
|
227
|
+
* 序第三腿);`required:true`=org 治理强制(镜像默认开且不可关,本地覆盖不生效——
|
|
228
|
+
* org 压一切)。锁定执法在壳(CC managed-settings 心智,registry-core 域头注「required 的锁今天也是
|
|
229
|
+
* CLIENT-SIDE 执法」);service 半场=观测。 */
|
|
139
230
|
export interface SessionMirrorRuling {
|
|
140
231
|
engineUrl: string;
|
|
141
232
|
required: boolean;
|
package/dist/config-lkg.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** 落盘信封。`effective`/`etag` 逐字=当时的 fetchEffective 返回(JSON verbatim 面)。 */
|
|
1
2
|
export interface PersistedLkg {
|
|
2
3
|
formatVersion: 1;
|
|
3
4
|
savedAt: string;
|
|
@@ -5,9 +6,20 @@ export interface PersistedLkg {
|
|
|
5
6
|
etag?: string;
|
|
6
7
|
effective: Record<string, unknown>;
|
|
7
8
|
}
|
|
9
|
+
/** skill 正文的 content-addressed 盘缓存目录(LKG 的姊妹面):LKG 只含 skills MANIFEST(正文按
|
|
10
|
+
* hash 另拉)——黑洞中心下 LKG-boot 会在 skill 正文拉取上再挂数秒(live 实测 +5.3s)。正文按
|
|
11
|
+
* `<dir>/<sha-hex>` 落盘,读侧**必验 hash**(content-addressed 的全部意义;坏文件=忽略重拉)。 */
|
|
8
12
|
export declare function defaultSkillCacheDir(): string;
|
|
13
|
+
/** 默认路径(scheduler store 同门:SEMA_CONFIG_DIR → ~/.sema)。`CONFIG_LKG_PATH` 覆写;
|
|
14
|
+
* `CONFIG_LKG_ENABLED=false` 关闭(读写双关;design/158 B4 正名前叫 `CONFIG_LKG_DISABLED=true`,兼容期内仍认)。 */
|
|
9
15
|
export declare function defaultLkgPath(worker: string | undefined): string;
|
|
16
|
+
/** 原子落盘一个干净候选(tmp+rename,0600)。BEST-EFFORT:失败=一条 warn 的素材(调用方发),绝不
|
|
17
|
+
* 影响在飞的应用链——LKG 缓存丢失的代价只是下次冷启动回到 env 兜底。 */
|
|
10
18
|
export declare function saveLkg(path: string, worker: string | undefined, effective: Record<string, unknown>, etag: string | undefined): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 读盘上 LKG。返回 undefined 的所有情形都「安静地回 env 兜底」(调用方 warn 点名 reason):
|
|
21
|
+
* 文件缺席/JSON 坏/信封形不对/worker 不匹配(防同名文件跨 worker 串包)/prompts 面复判失败。
|
|
22
|
+
*/
|
|
11
23
|
export declare function loadLkg(path: string, worker: string | undefined): Promise<{
|
|
12
24
|
lkg: PersistedLkg;
|
|
13
25
|
} | {
|
package/dist/config-lkg.js
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LKG 落盘(clay 拍,2026-07-18)——干净配置候选的本机持久化,boot 的第三级来源:
|
|
3
|
+
* 中心(预算窗内)> 盘上 LKG > env 兜底。
|
|
4
|
+
*
|
|
5
|
+
* 为什么存在(1.222.0 发版复审的残余环,clay 重裁量证据):boot 抢答窗让慢中心不再阻塞启动,但
|
|
6
|
+
* skills/mcp/scenarios/runtime-gates 四个 restart-to-apply 面是 boot 烤进进程的——配置迟到只能发
|
|
7
|
+
* restartRequired 信号。center 发布了这些面 + 中心**持续**慢于预算 + orchestrator 自动重启 ⇒ 每个
|
|
8
|
+
* 新进程都为真缺失的面发一次信号 = 反复重启环。盘上 LKG 让下一进程 boot 直读上一进程验证过的干净
|
|
9
|
+
* 候选(全部面进 buildScenarios),到货后与之比较通常零差异 ⇒ 无信号无环;中心恢复自然收敛。
|
|
10
|
+
* 白拿的第二收益:重启秒起且配置齐全(不再有「起服后几秒 roster pending」窗口)。
|
|
11
|
+
*
|
|
12
|
+
* 安全边界:config plane 恒只携带 env-NAME 引用(apiKeyEnv/tokenEnv/…),真实秘密从不入 effective
|
|
13
|
+
* ——落盘物按同一纪律无秘密;文件 0600 + 原子写(tmp+rename)。**只存干净候选**(候选门通过的:
|
|
14
|
+
* boot clean / refresh LKG advance / deferred clean),所以读侧只需防「文件坏形/被改」:JSON+信封
|
|
15
|
+
* 判形+prompts 面复判(validatePromptsDomain,与候选门同函数),任何不对 ⇒ 忽略文件走 env(warn
|
|
16
|
+
* 点名,绝不让坏缓存挡启动)。
|
|
17
|
+
*
|
|
18
|
+
* 范围:**remote lane only**——local lane 的 FileConfigStore 本来就是盘上即时读,无此需要。
|
|
19
|
+
* 文件按 worker 键控(`config-lkg-<worker|global>.json`),同宿主多 worker 不互踩。
|
|
20
|
+
*/
|
|
1
21
|
import { promises as fs } from "node:fs";
|
|
2
22
|
import { homedir } from "node:os";
|
|
3
23
|
import { join, dirname } from "node:path";
|
|
4
24
|
import { randomBytes } from "node:crypto";
|
|
5
25
|
import { validatePromptsDomain } from "./prompts-domain-validate.js";
|
|
26
|
+
/** skill 正文的 content-addressed 盘缓存目录(LKG 的姊妹面):LKG 只含 skills MANIFEST(正文按
|
|
27
|
+
* hash 另拉)——黑洞中心下 LKG-boot 会在 skill 正文拉取上再挂数秒(live 实测 +5.3s)。正文按
|
|
28
|
+
* `<dir>/<sha-hex>` 落盘,读侧**必验 hash**(content-addressed 的全部意义;坏文件=忽略重拉)。 */
|
|
6
29
|
export function defaultSkillCacheDir() {
|
|
7
30
|
return join(process.env.SEMA_CONFIG_DIR ?? join(homedir(), ".sema"), "skill-cache");
|
|
8
31
|
}
|
|
32
|
+
/** 默认路径(scheduler store 同门:SEMA_CONFIG_DIR → ~/.sema)。`CONFIG_LKG_PATH` 覆写;
|
|
33
|
+
* `CONFIG_LKG_ENABLED=false` 关闭(读写双关;design/158 B4 正名前叫 `CONFIG_LKG_DISABLED=true`,兼容期内仍认)。 */
|
|
9
34
|
export function defaultLkgPath(worker) {
|
|
10
35
|
const dir = process.env.SEMA_CONFIG_DIR ?? join(homedir(), ".sema");
|
|
11
36
|
const key = (worker ?? "global").replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 64);
|
|
12
37
|
return join(dir, `config-lkg-${key}.json`);
|
|
13
38
|
}
|
|
39
|
+
/** 原子落盘一个干净候选(tmp+rename,0600)。BEST-EFFORT:失败=一条 warn 的素材(调用方发),绝不
|
|
40
|
+
* 影响在飞的应用链——LKG 缓存丢失的代价只是下次冷启动回到 env 兜底。 */
|
|
14
41
|
export async function saveLkg(path, worker, effective, etag) {
|
|
15
42
|
const body = { formatVersion: 1, savedAt: new Date().toISOString(), worker: worker ?? "global", ...(etag !== undefined ? { etag } : {}), effective };
|
|
16
43
|
const tmp = `${path}.${randomBytes(6).toString("hex")}.tmp`;
|
|
@@ -18,6 +45,10 @@ export async function saveLkg(path, worker, effective, etag) {
|
|
|
18
45
|
await fs.writeFile(tmp, JSON.stringify(body), { mode: 0o600 });
|
|
19
46
|
await fs.rename(tmp, path);
|
|
20
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 读盘上 LKG。返回 undefined 的所有情形都「安静地回 env 兜底」(调用方 warn 点名 reason):
|
|
50
|
+
* 文件缺席/JSON 坏/信封形不对/worker 不匹配(防同名文件跨 worker 串包)/prompts 面复判失败。
|
|
51
|
+
*/
|
|
21
52
|
export async function loadLkg(path, worker) {
|
|
22
53
|
let text;
|
|
23
54
|
try {
|
|
@@ -44,9 +75,18 @@ export async function loadLkg(path, worker) {
|
|
|
44
75
|
return { reason: "bad effective" };
|
|
45
76
|
if (p.etag !== undefined && typeof p.etag !== "string")
|
|
46
77
|
return { reason: "bad etag" };
|
|
78
|
+
// 浅域判形(LKG 复审 F4):applyEffective 是 in-place mutate——半程炸=混态。载荷信任面与 live 远端
|
|
79
|
+
// 相同(config plane、本机文件=operator 权限),这里防的是**跨版本 schema 漂移/文件被改**的结构性坏形:
|
|
80
|
+
// 各域存在时必须是对象、其主数组存在时必须是数组、version 必须是数;更深的语义仍归 apply 层
|
|
81
|
+
// (live 载荷同待遇——LKG 不引入第二套 schema)。
|
|
47
82
|
const eff = p.effective;
|
|
48
83
|
if (typeof eff.version !== "number")
|
|
49
84
|
return { reason: "bad effective.version" };
|
|
85
|
+
// codex R24(真存量 bug):teams 的真形=信封 `{ teams: CenterTeam[] }`(EffectiveConfig 声明形,
|
|
86
|
+
// applyEffective 消费 `eff.teams?.teams`)——旧判形要求裸数组,任何带 teams 的候选保存成功、下次 boot
|
|
87
|
+
// 被拒("bad effective.teams")→ env 兜底 → 慢中心下 defer 再签,正是交棒门要消的环。teams 改与其他域
|
|
88
|
+
// 同姿势:对象 + 主数组存在时必须是数组。(旧夹具 `teams: []` 曾遮住此形;裸数组从未被真实 save 产出,
|
|
89
|
+
// 拒掉无害:unusable → env 兜底 → 下个干净候选重写。)
|
|
50
90
|
for (const [domain, arrayKey] of [["models", "models"], ["teams", "teams"], ["skills", "skills"], ["mcp", "servers"], ["scenarios", "scenarios"], ["runtime", null]]) {
|
|
51
91
|
const v = eff[domain];
|
|
52
92
|
if (v === undefined)
|
|
@@ -59,6 +99,7 @@ export async function loadLkg(path, worker) {
|
|
|
59
99
|
return { reason: `bad effective.${domain}.${arrayKey}` };
|
|
60
100
|
}
|
|
61
101
|
}
|
|
102
|
+
// prompts 面复判(候选门同函数):坏 prompts 若放行,boot 采用后每个任务 prepare 都会炸。
|
|
62
103
|
const promptsRaw = p.effective.prompts;
|
|
63
104
|
if (promptsRaw !== undefined && !validatePromptsDomain(promptsRaw).ok)
|
|
64
105
|
return { reason: "prompts face fails re-validation" };
|