@sema-agent/server 7.132.0 → 7.134.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/MIGRATION.md +353 -0
- package/README.md +8 -9
- package/README.zh-CN.md +7 -6
- package/USAGE.md +301 -64
- package/deploy/sema-up/README.md +35 -1
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
- package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +19 -2
- package/deploy/sema-up/chart/templates/server.yaml +19 -2
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- package/deploy/sema-up/stack/compose.yaml +3 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
- package/dist/adoption/plan.d.ts +3 -2
- package/dist/adoption/plan.js +7 -5
- package/dist/adoption/runner.js +3 -10
- package/dist/adoption/sql.d.ts +3 -2
- package/dist/adoption/sql.js +3 -5
- package/dist/adoption/wire.d.ts +4 -1
- package/dist/adoption/wire.js +1 -0
- package/dist/approval-ask-audit-store.d.ts +32 -14
- package/dist/approval-ask-audit-store.js +272 -74
- package/dist/approval-ask-machine.d.ts +15 -0
- package/dist/approval-ask-machine.js +6 -0
- package/dist/approval-ask-retention.d.ts +136 -0
- package/dist/approval-ask-retention.js +102 -0
- package/dist/approval-card.d.ts +83 -23
- package/dist/approval-card.js +45 -15
- package/dist/approval-content-kind.d.ts +5 -2
- package/dist/approval-content-kind.js +16 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +72 -0
- package/dist/approval-gate-currency.js +94 -0
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +55 -17
- package/dist/audit.d.ts +27 -10
- package/dist/audit.js +12 -16
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/coordinators.d.ts +6 -1
- package/dist/boot/coordinators.js +6 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/execution-env.js +9 -7
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.d.ts +2 -0
- package/dist/boot/leader.js +4 -1
- package/dist/boot/memory-boundary.js +2 -2
- package/dist/boot/memory-consolidation.d.ts +5 -4
- package/dist/boot/memory-consolidation.js +7 -6
- package/dist/boot/org-delivery.d.ts +28 -0
- package/dist/boot/org-delivery.js +20 -0
- package/dist/boot/read-deny-anchor-audit.js +2 -2
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +60 -81
- package/dist/boot/runner-deps.d.ts +18 -5
- package/dist/boot/runner-deps.js +10 -0
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-06-runners.d.ts +6 -3
- package/dist/boot/stage-06-runners.js +20 -4
- package/dist/boot/stage-07-capability-layer.d.ts +4 -1
- package/dist/boot/stage-07-capability-layer.js +24 -3
- package/dist/boot/stage-08-reapers.d.ts +4 -1
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +5 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +5 -1
- package/dist/boot/stage-10-http-server.js +6 -6
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -14
- package/dist/boot/web-admin.d.ts +10 -0
- package/dist/boot/web-admin.js +162 -65
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +8 -3
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +11 -6
- package/dist/caller-text-echo.js +10 -12
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +21 -0
- package/dist/capabilities/hands-lane.js +10 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -4
- package/dist/capabilities/mcp-probe.js +29 -6
- package/dist/capabilities/scenarios.d.ts +63 -7
- package/dist/capabilities/scenarios.js +39 -7
- package/dist/capability-facts.d.ts +36 -4
- package/dist/capability-facts.js +30 -4
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
- package/dist/checkpoint-ctx-seal-m28.js +19 -0
- package/dist/checkpoint-identity.d.ts +16 -0
- package/dist/checkpoint-identity.js +19 -0
- package/dist/config-catalog.d.ts +17 -10
- package/dist/config-catalog.js +43 -28
- package/dist/config-d-migration.d.ts +3 -1
- package/dist/config-d-migration.js +2 -2
- package/dist/config-dir-trust.d.ts +114 -0
- package/dist/config-dir-trust.js +388 -0
- package/dist/config-invariants.d.ts +18 -5
- package/dist/config-invariants.js +35 -3
- package/dist/config-provider.d.ts +6 -1
- package/dist/config-provider.js +6 -2
- package/dist/config-types.d.ts +71 -14
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +121 -59
- package/dist/delegated-session-owner.d.ts +185 -0
- package/dist/delegated-session-owner.js +119 -0
- package/dist/device-protocol.d.ts +5 -3
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +21 -2
- package/dist/device-ws-protocol.d.ts +70 -6
- package/dist/device-ws-protocol.js +50 -23
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/execution-lane-caps.d.ts +49 -10
- package/dist/execution-lane-caps.js +43 -4
- package/dist/field-conflict.d.ts +44 -0
- package/dist/field-conflict.js +21 -0
- package/dist/file-history-disclosure.d.ts +34 -5
- package/dist/file-history-disclosure.js +2 -2
- package/dist/fleet/fleet-bus.d.ts +84 -6
- package/dist/fleet/fleet-bus.js +42 -9
- package/dist/hooks/classic-stations.d.ts +10 -5
- package/dist/hooks/classic-stations.js +4 -4
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.js +2 -2
- package/dist/hooks/hook-runner.d.ts +127 -25
- package/dist/hooks/hook-runner.js +668 -287
- package/dist/hooks/hook-source.d.ts +44 -0
- package/dist/hooks/hook-source.js +40 -0
- package/dist/http/active-run-conflict.d.ts +5 -13
- package/dist/http/active-run-conflict.js +17 -27
- package/dist/http/admission.js +111 -60
- package/dist/http/approval-sweeps.js +58 -19
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +173 -18
- package/dist/http/checkpoint-ctx.js +171 -12
- package/dist/http/claimed-run.d.ts +4 -3
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +2 -1
- package/dist/http/dispatch.js +13 -7
- package/dist/http/durable-run-leg.d.ts +4 -32
- package/dist/http/durable-run-leg.js +37 -12
- package/dist/http/idempotency.d.ts +2 -2
- package/dist/http/idempotency.js +2 -2
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +78 -27
- package/dist/http/principal-gate.js +64 -14
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +16 -32
- package/dist/http/request-guards.js +31 -30
- package/dist/http/resume-ctx-read.d.ts +50 -6
- package/dist/http/resume-ctx-read.js +33 -7
- package/dist/http/resume-legs.d.ts +5 -5
- package/dist/http/resume-legs.js +163 -91
- package/dist/http/retired-service-deps.d.ts +43 -0
- package/dist/http/retired-service-deps.js +18 -0
- package/dist/http/route-ctx.d.ts +44 -37
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.js +3 -4
- package/dist/http/routes/admin-config-refresh.js +1 -1
- package/dist/http/routes/admin-drain.js +1 -1
- package/dist/http/routes/admin-memory-optout.js +5 -1
- package/dist/http/routes/adoption.js +2 -9
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.js +91 -56
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +20 -4
- package/dist/http/routes/config-catalog.d.ts +3 -3
- package/dist/http/routes/config-catalog.js +1 -1
- package/dist/http/routes/devices.js +3 -17
- package/dist/http/routes/diagnostics.d.ts +3 -3
- package/dist/http/routes/diagnostics.js +6 -2
- package/dist/http/routes/fleet.js +4 -4
- package/dist/http/routes/images.js +6 -7
- package/dist/http/routes/leader.js +1 -8
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +3 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-consolidation.js +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/memory-policy.d.ts +1 -1
- package/dist/http/routes/memory-policy.js +3 -2
- package/dist/http/routes/notify-wake.js +8 -21
- package/dist/http/routes/observability.js +2 -2
- package/dist/http/routes/principal-inbox.d.ts +39 -0
- package/dist/http/routes/principal-inbox.js +76 -0
- package/dist/http/routes/retention-ops.js +2 -9
- package/dist/http/routes/rules.js +9 -22
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +63 -115
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +53 -48
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +3 -4
- package/dist/http/routes/sessions.js +33 -43
- package/dist/http/routes/side-query.js +6 -4
- package/dist/http/routes/tasks.js +71 -30
- package/dist/http/routes/trace-usage.js +7 -9
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/run-declared-families.d.ts +16 -0
- package/dist/http/run-declared-families.js +12 -0
- package/dist/http/send.d.ts +24 -3
- package/dist/http/send.js +14 -2
- package/dist/http/server.d.ts +23 -18
- package/dist/http/server.js +20 -15
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +4 -3
- package/dist/http/submit-ctx.js +23 -6
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +17 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/lane-home-probe.d.ts +78 -9
- package/dist/lane-home-probe.js +78 -12
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/leader/wire.d.ts +4 -0
- package/dist/leader/wire.js +8 -7
- package/dist/limit-refusal.d.ts +17 -5
- package/dist/limit-refusal.js +4 -1
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +31 -10
- package/dist/mcp-assertion-header.js +10 -3
- package/dist/memory-origin-fence.js +2 -2
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +23 -16
- package/dist/memory-scope.js +24 -8
- package/dist/memory-sync-client.d.ts +27 -13
- package/dist/memory-sync-client.js +107 -18
- package/dist/model-compat.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +9 -1
- package/dist/model-entry-refusal.js +6 -1
- package/dist/model-plane-face.d.ts +51 -0
- package/dist/model-plane-face.js +24 -0
- package/dist/model-provider.d.ts +5 -0
- package/dist/model-provider.js +4 -2
- package/dist/model-route-endpoint.d.ts +8 -11
- package/dist/model-route-endpoint.js +4 -7
- package/dist/model-route-env.d.ts +22 -0
- package/dist/model-route-env.js +2 -0
- package/dist/model-route-gap.d.ts +60 -30
- package/dist/model-route-gap.js +21 -15
- package/dist/observability/corrupt-read-seat.d.ts +7 -0
- package/dist/observability/corrupt-read-seat.js +9 -0
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +35 -9
- package/dist/observability/fail-open.js +35 -9
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/prompt-manifest.d.ts +22 -25
- package/dist/observability/prompt-manifest.js +54 -50
- package/dist/observability/tool-trace.js +9 -10
- package/dist/operator-ask.d.ts +10 -0
- package/dist/operator-ask.js +3 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
- package/dist/orchestration/workflow-agent-session-index.js +9 -13
- package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
- package/dist/orchestration/workflow-completion-inbox.js +13 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
- package/dist/orchestration/workflow-notify-journal.js +27 -34
- package/dist/orchestration/workflow-park-decision.d.ts +89 -0
- package/dist/orchestration/workflow-park-decision.js +119 -0
- package/dist/org-delivery-gate.d.ts +81 -0
- package/dist/org-delivery-gate.js +59 -0
- package/dist/panel-tool-names.d.ts +23 -0
- package/dist/panel-tool-names.js +8 -0
- package/dist/parked-decide.d.ts +43 -11
- package/dist/parked-decide.js +100 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/permission-rule-vocab.d.ts +1 -23
- package/dist/permission-rule-vocab.js +0 -13
- package/dist/plugins/approval-ask-store-file.d.ts +16 -1
- package/dist/plugins/approval-ask-store-file.js +21 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
- package/dist/plugins/approval-ask-store-memory.js +34 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
- package/dist/plugins/approval-ask-store-sql.js +37 -1
- package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- package/dist/plugins/blob-backend.d.ts +38 -25
- package/dist/plugins/blob-backend.js +29 -19
- package/dist/plugins/breaker-state-sql.d.ts +2 -2
- package/dist/plugins/breaker-state-sql.js +4 -4
- package/dist/plugins/caching-session-store.d.ts +4 -1
- package/dist/plugins/caching-session-store.js +7 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +36 -1
- package/dist/plugins/checkpoint-store-sql.js +65 -3
- package/dist/plugins/file-history-store-sql.d.ts +5 -2
- package/dist/plugins/file-history-store-sql.js +3 -1
- package/dist/plugins/file-run-store.d.ts +5 -13
- package/dist/plugins/file-run-store.js +9 -0
- package/dist/plugins/fork-routing-session-store.d.ts +9 -1
- package/dist/plugins/fork-routing-session-store.js +12 -1
- package/dist/plugins/host-platform.d.ts +2 -0
- package/dist/plugins/host-platform.js +2 -1
- package/dist/plugins/local-checkpoint-store.d.ts +15 -2
- package/dist/plugins/local-checkpoint-store.js +32 -1
- package/dist/plugins/local-session-store.d.ts +13 -10
- package/dist/plugins/local-session-store.js +23 -14
- package/dist/plugins/local-session-window.d.ts +45 -0
- package/dist/plugins/local-session-window.js +38 -0
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
- package/dist/plugins/mailbox-store-sql.d.ts +30 -48
- package/dist/plugins/mailbox-store-sql.js +77 -52
- package/dist/plugins/memory-embedder-fingerprint.js +2 -1
- package/dist/plugins/memory-run-store.d.ts +5 -13
- package/dist/plugins/memory-run-store.js +8 -0
- package/dist/plugins/one-time-migrations.d.ts +121 -5
- package/dist/plugins/one-time-migrations.js +332 -8
- package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
- package/dist/plugins/org-delivery-quota-store.js +228 -0
- package/dist/plugins/permission-rule-store-file.js +10 -6
- package/dist/plugins/permission-rule-store-sql.js +8 -8
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +18 -5
- package/dist/plugins/pg-session-storage.js +68 -23
- package/dist/plugins/remote-env-adb.d.ts +6 -12
- package/dist/plugins/remote-env-adb.js +12 -2
- package/dist/plugins/remote-env-device.d.ts +14 -7
- package/dist/plugins/remote-env-device.js +23 -15
- package/dist/plugins/remote-env-k8s.d.ts +8 -12
- package/dist/plugins/remote-env-k8s.js +23 -5
- package/dist/plugins/remote-env-local-docker.d.ts +10 -15
- package/dist/plugins/remote-env-local-docker.js +12 -9
- package/dist/plugins/remote-env-ssh.d.ts +10 -16
- package/dist/plugins/remote-env-ssh.js +17 -11
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-user-file.js +2 -2
- package/dist/plugins/session-epoch-anchor.d.ts +32 -6
- package/dist/plugins/session-epoch-anchor.js +2 -3
- package/dist/plugins/session-ownership.d.ts +11 -0
- package/dist/plugins/session-ownership.js +11 -0
- package/dist/plugins/session-placement.d.ts +12 -14
- package/dist/plugins/session-placement.js +2 -15
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/sql-driver.d.ts +74 -11
- package/dist/plugins/sql-driver.js +210 -12
- package/dist/plugins/sql-errors.d.ts +23 -0
- package/dist/plugins/sql-errors.js +21 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +40 -14
- package/dist/plugins/store-contracts.d.ts +42 -0
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/tidb-pool.d.ts +6 -1
- package/dist/plugins/tidb-pool.js +44 -10
- package/dist/plugins/tidb-session-storage.d.ts +3 -2
- package/dist/plugins/tidb-session-storage.js +2 -2
- package/dist/plugins/tidb-session-store.d.ts +25 -5
- package/dist/plugins/tidb-session-store.js +67 -21
- package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
- package/dist/plugins/workflow-journal-store-sql.js +19 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
- package/dist/plugins/workflow-run-store-sql.js +50 -9
- package/dist/posture-source.d.ts +18 -10
- package/dist/posture-source.js +4 -1
- package/dist/project-identity.d.ts +45 -6
- package/dist/project-identity.js +162 -8
- package/dist/project-layer-key.d.ts +28 -0
- package/dist/project-layer-key.js +29 -0
- package/dist/question.js +3 -2
- package/dist/read-deny-entry.d.ts +25 -0
- package/dist/read-deny-entry.js +12 -0
- package/dist/read-face-posture.d.ts +37 -11
- package/dist/read-face-posture.js +32 -3
- package/dist/request-key-closure.d.ts +7 -0
- package/dist/request-key-closure.js +9 -1
- package/dist/request-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +26 -2
- package/dist/rule-entry-list.js +72 -12
- package/dist/rules-consent.js +3 -4
- package/dist/run-acceptance.d.ts +19 -3
- package/dist/run-acceptance.js +13 -1
- package/dist/run-local.js +37 -6
- package/dist/runs.d.ts +12 -10
- package/dist/runs.js +25 -6
- package/dist/runtime-caps-resolver.d.ts +16 -6
- package/dist/runtime-caps-resolver.js +18 -5
- package/dist/sandbox-pkg-source.d.ts +19 -1
- package/dist/sandbox-pkg-source.js +29 -7
- package/dist/sealed-key.d.ts +32 -0
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +95 -15
- package/dist/security.js +52 -9
- package/dist/session-error-wire.d.ts +31 -7
- package/dist/session-error-wire.js +9 -2
- package/dist/session-sync-kernel.d.ts +37 -10
- package/dist/session-sync-kernel.js +10 -0
- package/dist/session-titled-frame.d.ts +33 -0
- package/dist/session-titled-frame.js +4 -0
- package/dist/session-titler.d.ts +9 -1
- package/dist/session-titler.js +15 -4
- package/dist/spec-fields.js +21 -2
- package/dist/sql-engine-posture.d.ts +3 -1
- package/dist/task-a2a.js +4 -3
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +5 -5
- package/dist/task-mcp.js +27 -74
- package/dist/task-settings.d.ts +93 -88
- package/dist/task-settings.js +71 -63
- package/dist/text-bidi.d.ts +0 -4
- package/dist/text-bidi.js +1 -3
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +451 -136
- package/dist/tool-approval.js +733 -256
- package/dist/tool-rule-names.d.ts +6 -0
- package/dist/trace/core-keyset-guard.d.ts +108 -25
- package/dist/trace/exit-seat.d.ts +40 -0
- package/dist/trace/exit-seat.js +130 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/project.d.ts +98 -13
- package/dist/trace/project.js +57 -32
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +57 -0
- package/dist/trace/redact.js +962 -168
- package/dist/trace/self-minted-wire.d.ts +349 -1
- package/dist/trace/self-minted-wire.js +118 -1
- package/dist/trace/wire-projection-faces.d.ts +304 -2
- package/dist/trace/wire-projection-faces.js +160 -13
- package/dist/url-refusal.js +2 -0
- package/dist/web-admin-client/apply-effective.d.ts +12 -0
- package/dist/web-admin-client/apply-effective.js +56 -5
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.js +6 -8
- package/dist/web-admin-client/types.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -2
- package/scripts/drain-check.mysql.sql +20 -2
- package/scripts/drain-check.pg.sql +20 -2
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -106
|
@@ -64,7 +64,27 @@ export function mutateInPlace(target, source) {
|
|
|
64
64
|
Object.assign(target, source);
|
|
65
65
|
}
|
|
66
66
|
const appliedGeneration = new WeakMap();
|
|
67
|
-
const
|
|
67
|
+
const envModelPlane = new WeakMap();
|
|
68
|
+
function envModelPlaneOf(config) {
|
|
69
|
+
let snap = envModelPlane.get(config);
|
|
70
|
+
if (snap === undefined) {
|
|
71
|
+
snap = {
|
|
72
|
+
models: { ...config.models },
|
|
73
|
+
model: config.envModel,
|
|
74
|
+
modelApiKeyEnv: { ...config.modelApiKeyEnv },
|
|
75
|
+
modelApiKeys: { ...config.modelApiKeys },
|
|
76
|
+
modelRefusals: { ...config.modelRefusals },
|
|
77
|
+
droppedCatalogEntries: [...config.droppedCatalogEntries],
|
|
78
|
+
quotaWeights: { ...config.modelQuotaWeights },
|
|
79
|
+
roles: { ...config.roles },
|
|
80
|
+
activeTiers: { ...config.tiers },
|
|
81
|
+
atMention: config.atMention,
|
|
82
|
+
infoLine: {},
|
|
83
|
+
};
|
|
84
|
+
envModelPlane.set(config, snap);
|
|
85
|
+
}
|
|
86
|
+
return snap;
|
|
87
|
+
}
|
|
68
88
|
function stageAtMention(raw, usableNames, logger) {
|
|
69
89
|
const read = readAtMention(raw);
|
|
70
90
|
if (read === undefined) {
|
|
@@ -172,7 +192,7 @@ function commitStaged(config, staged) {
|
|
|
172
192
|
config.droppedCatalogEntries = mp.droppedCatalogEntries;
|
|
173
193
|
mutateInPlace(config.modelQuotaWeights, mp.quotaWeights);
|
|
174
194
|
mutateInPlace(config.models, mp.models);
|
|
175
|
-
config.model =
|
|
195
|
+
config.model = mp.model;
|
|
176
196
|
mutateInPlace(config.roles, mp.roles);
|
|
177
197
|
mutateInPlace(config.tiers, mp.activeTiers);
|
|
178
198
|
config.atMention = mp.atMention;
|
|
@@ -227,7 +247,38 @@ function modelPlaneGroupReport(group) {
|
|
|
227
247
|
};
|
|
228
248
|
}
|
|
229
249
|
const ROLE_BINDING_UNAVAILABLE_HINT = "tasks resolving this role fail: alias/tier expansion cannot mint this name; the engine refuses it loud — bind the role to a usable model, or make the entry usable (see the entry's own warn)";
|
|
250
|
+
export const NO_CENTER_EFFECTIVE = deepFreeze({ version: 0, updatedAt: "", models: { models: [], roles: {} }, mcp: { servers: [] } });
|
|
251
|
+
export const isNoCenterEffective = (eff) => eff === NO_CENTER_EFFECTIVE;
|
|
252
|
+
function deepFreeze(v) {
|
|
253
|
+
if (v !== null && typeof v === "object") {
|
|
254
|
+
for (const x of Object.values(v))
|
|
255
|
+
deepFreeze(x);
|
|
256
|
+
Object.freeze(v);
|
|
257
|
+
}
|
|
258
|
+
return v;
|
|
259
|
+
}
|
|
260
|
+
function stageEnvModelPlane(config) {
|
|
261
|
+
if (servedModelTableLeg(config) === "env")
|
|
262
|
+
return { stages: {} };
|
|
263
|
+
const snap = envModelPlane.get(config);
|
|
264
|
+
if (snap === undefined)
|
|
265
|
+
throw new Error("applyEffective: the center model plane is in force but no env snapshot was taken — the model plane was written outside applyEffective, so the no-center tier has no baseline to return to");
|
|
266
|
+
return {
|
|
267
|
+
stages: {
|
|
268
|
+
models: {
|
|
269
|
+
...snap,
|
|
270
|
+
modelApiKeyEnv: { ...snap.modelApiKeyEnv },
|
|
271
|
+
modelApiKeys: { ...snap.modelApiKeys },
|
|
272
|
+
modelRefusals: { ...snap.modelRefusals },
|
|
273
|
+
droppedCatalogEntries: [...snap.droppedCatalogEntries],
|
|
274
|
+
infoLine: { source: "no-center-baseline", default: snap.model.id, roles: Object.keys(snap.roles), tiers: [], atMention: snap.atMention.mode },
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
230
279
|
function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
280
|
+
if (isNoCenterEffective(eff))
|
|
281
|
+
return stageEnvModelPlane(config);
|
|
231
282
|
const enabled = (eff.models?.models ?? []).filter((m) => m.enabled !== false);
|
|
232
283
|
const verdict = judgeCatalogEntries(enabled, { anthropicRouteMounted: config.anthropic !== undefined }, eff.models?.droppedCatalogEntries);
|
|
233
284
|
if (enabled.length === 0 && verdict.malformed.length === 0 && verdict.dropped.every((row) => row.identity?.enabled === false))
|
|
@@ -293,8 +344,7 @@ function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
|
293
344
|
quotaWeights[m.id] = qw;
|
|
294
345
|
}
|
|
295
346
|
}
|
|
296
|
-
|
|
297
|
-
envRolesBaseline.set(config, { ...config.roles });
|
|
347
|
+
const envPlane = envModelPlaneOf(config);
|
|
298
348
|
const centerRoles = {};
|
|
299
349
|
for (const [role, tgt] of Object.entries(eff.models.roles ?? {})) {
|
|
300
350
|
if ("model" in tgt)
|
|
@@ -302,7 +352,7 @@ function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
|
302
352
|
else if ("select" in tgt)
|
|
303
353
|
centerRoles[role] = { select: tgt.select };
|
|
304
354
|
}
|
|
305
|
-
const roles = { ...
|
|
355
|
+
const roles = { ...envPlane.roles, ...centerRoles };
|
|
306
356
|
const activeTiers = {};
|
|
307
357
|
for (const [tier, target] of Object.entries(resolveActiveTiers(eff.models) ?? {})) {
|
|
308
358
|
if (models[target] !== undefined) {
|
|
@@ -365,6 +415,7 @@ function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
|
365
415
|
const defaultModel = models.default;
|
|
366
416
|
const plane = {
|
|
367
417
|
models,
|
|
418
|
+
model: defaultModel,
|
|
368
419
|
modelApiKeyEnv,
|
|
369
420
|
modelApiKeys,
|
|
370
421
|
modelRefusals: { ...verdict.refused },
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* importers to update, which was done in the same commit.
|
|
49
49
|
*/
|
|
50
50
|
export { fetchEffective, fetchPrincipalCaps, fetchPrincipalOrgMemory, WebAdminHttpError, fetchSkillContent, fetchPromptArtifact, fetchPromptBlob, } from "./http-client.js";
|
|
51
|
-
export { mutateInPlace, applyEffective, type ApplyReport, applyRuntimeGates, applyRuntimeHot, logEffectiveDiff, MODEL_PLANE_DOMAINS, type ModelPlaneDomain, type ModelPlaneOf, withModelPlaneOf, fullyLandedForLkg, } from "./apply-effective.js";
|
|
51
|
+
export { mutateInPlace, applyEffective, NO_CENTER_EFFECTIVE, isNoCenterEffective, type ApplyReport, applyRuntimeGates, applyRuntimeHot, logEffectiveDiff, MODEL_PLANE_DOMAINS, type ModelPlaneDomain, type ModelPlaneOf, withModelPlaneOf, fullyLandedForLkg, } from "./apply-effective.js";
|
|
52
52
|
export { restartReasons, modelPlaneChanged, type RestartSlice, type RestartSliceCtx, type EngineRestartSignal, } from "./restart-signal.js";
|
|
53
53
|
export { applySkillsManifest, resolveMcpServers, mcpForScenario, resolveA2aPeers, a2aForScenario } from "./skills-mcp.js";
|
|
54
54
|
export { applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, CENTER_READ_FACE_LIVE_KEYS, type CenterReadFaceApply, type CenterReadFaceReport, type ReadFaceBaseline, type ReadFaceSeat } from "./read-face.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { fetchEffective, fetchPrincipalCaps, fetchPrincipalOrgMemory, WebAdminHttpError, fetchSkillContent, fetchPromptArtifact, fetchPromptBlob, } from "./http-client.js";
|
|
2
|
-
export { mutateInPlace, applyEffective, applyRuntimeGates, applyRuntimeHot, logEffectiveDiff, MODEL_PLANE_DOMAINS, withModelPlaneOf, fullyLandedForLkg, } from "./apply-effective.js";
|
|
2
|
+
export { mutateInPlace, applyEffective, NO_CENTER_EFFECTIVE, isNoCenterEffective, applyRuntimeGates, applyRuntimeHot, logEffectiveDiff, MODEL_PLANE_DOMAINS, withModelPlaneOf, fullyLandedForLkg, } from "./apply-effective.js";
|
|
3
3
|
export { restartReasons, modelPlaneChanged, } from "./restart-signal.js";
|
|
4
4
|
export { applySkillsManifest, resolveMcpServers, mcpForScenario, resolveA2aPeers, a2aForScenario } from "./skills-mcp.js";
|
|
5
5
|
export { applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, CENTER_READ_FACE_LIVE_KEYS } from "./read-face.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compileReadDeny, isSwappableDepSeat, resolveReadDenyBuiltins } from "@sema-agent/core";
|
|
2
|
+
import { readReadDenyEntry } from "../read-deny-entry.js";
|
|
2
3
|
export function buildReadFaceBaseline(config) {
|
|
3
4
|
return {
|
|
4
5
|
...(config.readFace !== undefined ? { readFace: config.readFace } : {}),
|
|
@@ -44,15 +45,10 @@ function normalizeDenyPatterns(raw) {
|
|
|
44
45
|
if (!Array.isArray(raw))
|
|
45
46
|
throw new ReadFaceDomainError("readFace.denyPatterns must be an array of \"pattern\" strings or {pattern, caseSensitive?} objects");
|
|
46
47
|
return raw.map((it, i) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
const cs = it.caseSensitive;
|
|
53
|
-
if (cs !== undefined && typeof cs !== "boolean")
|
|
54
|
-
throw new ReadFaceDomainError(`readFace.denyPatterns[${i}].caseSensitive must be boolean when present`);
|
|
55
|
-
return { pattern: it.pattern, caseSensitive: cs === true };
|
|
48
|
+
const read = readReadDenyEntry(it);
|
|
49
|
+
if (!read.ok)
|
|
50
|
+
throw new ReadFaceDomainError(`readFace.denyPatterns[${i}]${read.after}`);
|
|
51
|
+
return read.entry;
|
|
56
52
|
});
|
|
57
53
|
}
|
|
58
54
|
function assertFace(raw) {
|
|
@@ -30,7 +30,7 @@ export declare function applySkillsManifest(baseline: LoadedSkill[], manifest: {
|
|
|
30
30
|
* Resolve center MCP servers (`/effective.mcp`) into core `McpServerSpec`s + the scenarios each applies to.
|
|
31
31
|
* env-NAME refs → real values from THIS service's env (secret boundary unchanged); a server with any missing
|
|
32
32
|
* ref is skipped (`resolveRefs` → null). `enabled:false` skipped. A server whose `toolFaces` / `toolAxes` declaration is
|
|
33
|
-
* malformed is skipped whole (both are trust-root declarations —
|
|
33
|
+
* malformed is skipped whole (both are trust-root declarations — the engine's `readToolFaces` / `readMcpToolAxes` judge them). Restart-to-apply
|
|
34
34
|
* (filtered per scenario in `resolveSpec` via `mcpForScenario`).
|
|
35
35
|
*/
|
|
36
36
|
export declare function resolveMcpServers(mcp: {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { readMcpSourceLabel } from "../mcp-source-label.js";
|
|
2
|
-
import { readMcpToolFaces } from "../mcp-tool-faces.js";
|
|
3
2
|
import { skillContentHash } from "@sema-agent/settings-schema";
|
|
4
|
-
import { readMcpToolAxes } from "@sema-agent/core";
|
|
5
|
-
import { MCP_CONTENT_ORIGINS, isContentOriginWord, isUsableWireName } from "@sema-agent/settings-schema";
|
|
6
|
-
import {
|
|
7
|
-
import { noteMcpAssertionHeaderNotSent } from "../mcp-assertion-header.js";
|
|
3
|
+
import { readMcpToolAxes, readToolFaces } from "@sema-agent/core";
|
|
4
|
+
import { MCP_CONTENT_ORIGINS, describeBadContentOrigin, describeBadWireName, isContentOriginWord, isUsableWireName } from "@sema-agent/settings-schema";
|
|
5
|
+
import { noteMcpAssertionHeaderNotSent, sentMcpAssertionHeaderMember, withholdsMcpAssertionHeader } from "../mcp-assertion-header.js";
|
|
8
6
|
import { SHA256_HEX_RE } from "../digest-form.js";
|
|
9
7
|
function skillBodyPresent(body) {
|
|
10
8
|
return body !== undefined && body !== "";
|
|
@@ -117,7 +115,7 @@ export function resolveMcpServers(mcp, logger) {
|
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
const source = readMcpSourceLabel(s.name, s.source);
|
|
120
|
-
const facesRead =
|
|
118
|
+
const facesRead = readToolFaces(s.toolFaces);
|
|
121
119
|
if (!facesRead.ok) {
|
|
122
120
|
logger?.warn("web_admin_mcp_tool_faces_invalid", {
|
|
123
121
|
server: s.name,
|
|
@@ -150,11 +148,11 @@ export function resolveMcpServers(mcp, logger) {
|
|
|
150
148
|
const headers = resolveRefs(s.transport.headerRefs, s.name, "header", logger);
|
|
151
149
|
if (headers === null)
|
|
152
150
|
continue;
|
|
153
|
-
if (s.transport.assertionHeader
|
|
151
|
+
if (withholdsMcpAssertionHeader(s.transport.assertionHeader))
|
|
154
152
|
noteMcpAssertionHeaderNotSent(logger, s.name);
|
|
155
153
|
out.push({
|
|
156
154
|
scenarios: s.scenarios ?? [],
|
|
157
|
-
spec: { name: s.name, transport: { kind: "http", url: s.transport.url, ...(Object.keys(headers).length ? { headers } : {}), ...(s.transport.principalHeader ? { principalHeader: s.transport.principalHeader } : {}) }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes },
|
|
155
|
+
spec: { name: s.name, transport: { kind: "http", url: s.transport.url, ...(Object.keys(headers).length ? { headers } : {}), ...(s.transport.principalHeader ? { principalHeader: s.transport.principalHeader } : {}), ...sentMcpAssertionHeaderMember(s.transport.assertionHeader) }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes },
|
|
158
156
|
});
|
|
159
157
|
}
|
|
160
158
|
}
|
|
@@ -147,7 +147,7 @@ export interface CenterMcpServer {
|
|
|
147
147
|
*
|
|
148
148
|
* 🔴 类型是 `unknown` 而不是那个结构,**刻意的**:本类型是两条 center 腿的**承载形**(本地 config.d 经
|
|
149
149
|
* settings-schema 的 `z.unknown()` 解析透明地过来、远端 /effective 是直读 JSON),判据与坏形处置的单一
|
|
150
|
-
*
|
|
150
|
+
* 属主是引擎根导出的 `readToolFaces`(`resolveMcpServers` 在铸 spec 那一刻调它)。在承载
|
|
151
151
|
* 形上先写一个结构,等于把同一张判据表抄成两份(而其中一份没有执行力)。
|
|
152
152
|
*/
|
|
153
153
|
toolFaces?: unknown;
|
|
@@ -20,7 +20,8 @@ dials the device, so the device needs no inbound port, no public address and no
|
|
|
20
20
|
(this deployment has no device lane) or an object `{ enabled: true, protocolVersion, maxInflightPerDevice,
|
|
21
21
|
wsPath, management }`. Read `wsPath` from there rather than hardcoding it: the path is part of the wire
|
|
22
22
|
contract and reading it means a future path change is not a cross-repo break. `protocolVersion` tells you
|
|
23
|
-
which
|
|
23
|
+
which protocol **revision** the server speaks before you spend a handshake finding out (§2.1: the revision decides
|
|
24
|
+
which `errorCode` words the server accepts from you).
|
|
24
25
|
|
|
25
26
|
---
|
|
26
27
|
|
|
@@ -144,6 +145,13 @@ The server sends `challenge` immediately on open. From the moment the socket ope
|
|
|
144
145
|
the handshake completes, **frames are capped at `maxPreAuthFrameBytes` (4096 bytes)** and a malformed
|
|
145
146
|
pre-auth frame closes the connection outright.
|
|
146
147
|
|
|
148
|
+
**Which revision to declare.** `challenge.protocolVersion` is the highest protocol revision this server speaks
|
|
149
|
+
(`DEVICE_MIN_PROTOCOL_VERSION` is the lowest it accepts, §2.1). Put the highest revision *you* implement that is
|
|
150
|
+
not above `challenge.protocolVersion` into `hello.protocolVersion` — the same integer you sign (§1.3) — and emit
|
|
151
|
+
only the `errorCode` words of that revision (the revision table in §2.1). Nothing is renegotiated after `hello`:
|
|
152
|
+
the revision you declared is the contract for the whole connection. If the highest revision you implement is below
|
|
153
|
+
`DEVICE_MIN_PROTOCOL_VERSION`, the server answers `helloReject: protocol_version_unsupported` (§1.4).
|
|
154
|
+
|
|
147
155
|
### 1.3 The `hello` signature (byte-exact — do not improvise)
|
|
148
156
|
|
|
149
157
|
Sign with the device private key over exactly these bytes:
|
|
@@ -245,18 +253,32 @@ backoff, exponential to a 60 s ceiling, jittered — except for `revoked`, which
|
|
|
245
253
|
|
|
246
254
|
`helloAck` carries:
|
|
247
255
|
|
|
256
|
+
<!-- closed-set: DEVICE_HELLO_ACK_BOUNDS -->
|
|
257
|
+
|
|
248
258
|
| Field | Form | Meaning |
|
|
249
259
|
|---|---|---|
|
|
250
260
|
| `ok` | always `true` | — |
|
|
251
|
-
| `heartbeatIntervalMs` | integer ms | how often you should send `heartbeat` (deployment default 15000) |
|
|
252
|
-
| `maxInflight` | integer | how many instructions the server will have outstanding on this device at once (deployment default 4) |
|
|
261
|
+
| `heartbeatIntervalMs` | `integer ms ≥ 1` | how often you should send `heartbeat` (deployment default 15000) |
|
|
262
|
+
| `maxInflight` | `integer ≥ 1` | how many instructions the server will have outstanding on this device at once (deployment default 4) |
|
|
253
263
|
| `gen` | **canonical decimal string** (`"7"`, never `7`, never `"07"`) | the connection generation. Stamp it on every frame you send |
|
|
254
264
|
| `pendingInstructions` | `string[]` | instruction ids the server still considers in flight for you — see §5 R2 |
|
|
255
265
|
| `chunkWatermarks` | `{ [instructionId]: number }` | per instruction, the highest **contiguous** `streamSeq` the server has already accepted. `-1` means "nothing accepted yet" |
|
|
256
|
-
| `reconnectGraceMs` | integer ms | the reconnect grace **in force on this server** (R4): how long in-flight work survives a dropped socket. Deployment-tunable, default 120000 |
|
|
257
|
-
| `cancelGraceMs` | integer ms | the cancel grace in force (R11): how long after a `cancel` is delivered the server waits for your terminal `result`. Default 10000 |
|
|
258
|
-
| `chunkGapTimeoutMs` | integer ms | the chunk-gap timeout in force (R8): how long the server waits for a missing `streamSeq` before failing the instruction. Default 30000 |
|
|
259
|
-
| `executionCeilingGraceMs` | integer ms | the grace added to an instruction's `timeoutMs` before the server gives up and settles it as outcome-unknown (R12: the ceiling is `timeoutMs + executionCeilingGraceMs`). Default 30000 |
|
|
266
|
+
| `reconnectGraceMs` | `integer ms ≥ 0` | the reconnect grace **in force on this server** (R4): how long in-flight work survives a dropped socket. Deployment-tunable, default 120000 |
|
|
267
|
+
| `cancelGraceMs` | `integer ms ≥ 0` | the cancel grace in force (R11): how long after a `cancel` is delivered the server waits for your terminal `result`. Default 10000 |
|
|
268
|
+
| `chunkGapTimeoutMs` | `integer ms ≥ 0` | the chunk-gap timeout in force (R8): how long the server waits for a missing `streamSeq` before failing the instruction. Default 30000 |
|
|
269
|
+
| `executionCeilingGraceMs` | `integer ms ≥ 0` | the grace added to an instruction's `timeoutMs` before the server gives up and settles it as outcome-unknown (R12: the ceiling is `timeoutMs + executionCeilingGraceMs`). Default 30000 |
|
|
270
|
+
|
|
271
|
+
**Bounds.** The six numeric fields above are validated by the server when it starts: a deployment whose knob (or
|
|
272
|
+
embedding option) is outside its row's range refuses to boot — the value is never clamped and never replaced by a
|
|
273
|
+
default — so a `helloAck` on the wire is always in range, and every number in it is the value the server's own
|
|
274
|
+
timers and slot counts are armed with. Every `ms` field is also at most `2147483647` (the largest delay a
|
|
275
|
+
timer can hold; a larger value would be silently collapsed to 1 ms); `maxInflight` has no ceiling beyond an
|
|
276
|
+
integer JSON represents exactly (at most `9007199254740991`). A `0` grace means "no grace": that timer
|
|
277
|
+
fires at once. An executor that reads a value outside its row's range must treat it as a protocol violation — the executor-side twin
|
|
278
|
+
of the server's `bad_shape` refusal (§2.4): close the connection and reconnect with backoff — and must **not** read the
|
|
279
|
+
out-of-range value as the default.
|
|
280
|
+
`deviceHelloAckNumberFlaw` (from `@sema-agent/server/device-protocol`) is the same check the server applies.
|
|
281
|
+
The *absence* of one of the four grace fields is a different case, described below, and still means "not told".
|
|
260
282
|
|
|
261
283
|
The four grace fields are the values the server's own timers are armed with — not documentation defaults. Size
|
|
262
284
|
your reconnect backoff ceiling, your `cancel` answer deadline, your retransmission cadence and your own
|
|
@@ -314,8 +336,8 @@ base64 inside JSON fields.
|
|
|
314
336
|
| Constant | Value | Meaning |
|
|
315
337
|
|---|---|---|
|
|
316
338
|
| `DEVICE_WS_PATH` | `/v1/device/ws` | the upgrade path (prefer the `wsPath` from `/v1/capabilities`) |
|
|
317
|
-
| `DEVICE_PROTOCOL_VERSION` | `
|
|
318
|
-
| `DEVICE_MIN_PROTOCOL_VERSION` | `1` | the lowest
|
|
339
|
+
| `DEVICE_PROTOCOL_VERSION` | `2` | the protocol revision this server speaks (the highest it accepts) |
|
|
340
|
+
| `DEVICE_MIN_PROTOCOL_VERSION` | `1` | the lowest revision it accepts; below it (or above the highest), a loud `helloReject` — never a silent downgrade |
|
|
319
341
|
| `DEVICE_HELLO_DOMAIN_TAG` | `sema.device.hello.v1` | the handshake signature domain tag (§1.3) |
|
|
320
342
|
|
|
321
343
|
<!-- closed-set: DEVICE_WS_LIMITS -->
|
|
@@ -330,6 +352,29 @@ base64 inside JSON fields.
|
|
|
330
352
|
Note the asymmetry: the transport cap is 1 MiB, and the 4096-byte pre-auth cap is applied **after** the
|
|
331
353
|
frame has been reassembled. Keep `hello` small; it is not a place for long `supports` prose.
|
|
332
354
|
|
|
355
|
+
#### Protocol revisions and the `errorCode` set
|
|
356
|
+
|
|
357
|
+
The protocol revision is the only thing an executor can read *before* it sends `hello` (the `challenge` frame
|
|
358
|
+
carries it), so the set of `errorCode` words the server accepts from you is a function of the revision, not a
|
|
359
|
+
separate list. The table gives, per revision, the words **added** at that revision; the set at revision *N* is
|
|
360
|
+
the union of the rows up to *N*, and the full set at the current revision is the §3.3 table.
|
|
361
|
+
|
|
362
|
+
<!-- closed-set: DEVICE_OUTCOME_ERROR_CODES_BY_REVISION -->
|
|
363
|
+
|
|
364
|
+
| Revision | `errorCode` words added at this revision |
|
|
365
|
+
|---|---|
|
|
366
|
+
| `1` | `aborted`, `already_exists`, `auth_failed`, `callback_error`, `invalid`, `is_directory`, `not_directory`, `not_found`, `not_supported`, `outcome_unknown`, `permission_denied`, `precondition_failed`, `shell_unavailable`, `spawn_error`, `suspended`, `target_unavailable`, `timeout`, `transport_lost`, `unknown` |
|
|
367
|
+
| `2` | `liveness_no_output` |
|
|
368
|
+
|
|
369
|
+
Rules: adding a frame or a field is additive and does not raise the revision; adding a word to a closed set the
|
|
370
|
+
server *accepts from you* (today: the `errorCode` set) raises `DEVICE_PROTOCOL_VERSION` and adds a row here; a
|
|
371
|
+
released row never changes. Declare a revision as §1.2 says and send only the words of that revision: an executor
|
|
372
|
+
that declared revision 1 never sends `liveness_no_output` (the server does not police this per connection — it
|
|
373
|
+
decodes every connection against the current revision's full set — but a word above your declared revision is outside
|
|
374
|
+
your contract). The same sets are importable:
|
|
375
|
+
`DEVICE_OUTCOME_ERROR_CODES_BY_REVISION` and `deviceOutcomeErrorCodesAt(revision)` from
|
|
376
|
+
`@sema-agent/server/device-protocol`.
|
|
377
|
+
|
|
333
378
|
### 2.2 Device → server frames
|
|
334
379
|
|
|
335
380
|
<!-- closed-set: DEVICE_FRAME_TYPES -->
|
|
@@ -515,6 +560,9 @@ a moment ago. If you omit `created`, the consumer reports the weaker of the two
|
|
|
515
560
|
|
|
516
561
|
`message` is required on the failure arm and is shown to the model — make it specific.
|
|
517
562
|
|
|
563
|
+
This is the full set at the current revision (`2`); the revision table in §2.1 says which revision each word arrived
|
|
564
|
+
with, and an executor sends only the words of the revision it declared (§1.2).
|
|
565
|
+
|
|
518
566
|
<!-- closed-set: DEVICE_OUTCOME_ERROR_CODES -->
|
|
519
567
|
|
|
520
568
|
| `errorCode` | Use it when |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.134.0",
|
|
4
4
|
"description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/device-protocol.d.ts",
|
|
19
19
|
"default": "./dist/device-protocol.js"
|
|
20
20
|
},
|
|
21
|
+
"./model-route-env": {
|
|
22
|
+
"types": "./dist/model-route-env.d.ts",
|
|
23
|
+
"default": "./dist/model-route-env.js"
|
|
24
|
+
},
|
|
21
25
|
"./package.json": "./package.json",
|
|
22
26
|
"./deploy/sema-up/lanes.json": "./deploy/sema-up/lib/lanes.json"
|
|
23
27
|
},
|
|
@@ -64,8 +68,8 @@
|
|
|
64
68
|
"build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
|
|
65
69
|
},
|
|
66
70
|
"dependencies": {
|
|
67
|
-
"@sema-agent/core": "7.
|
|
68
|
-
"@sema-agent/settings-schema": "14.
|
|
71
|
+
"@sema-agent/core": "7.54.1",
|
|
72
|
+
"@sema-agent/settings-schema": "14.2.0",
|
|
69
73
|
"e2b": "^2.28.0",
|
|
70
74
|
"libsodium-wrappers": "^0.8.4",
|
|
71
75
|
"mysql2": "^3.22.4",
|
|
@@ -80,7 +84,7 @@
|
|
|
80
84
|
"sharp": "^0.35.3"
|
|
81
85
|
},
|
|
82
86
|
"devDependencies": {
|
|
83
|
-
"@sema-agent/sdk": "
|
|
87
|
+
"@sema-agent/sdk": "24.0.0",
|
|
84
88
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
85
89
|
"@types/node": "22.10.2",
|
|
86
90
|
"@types/pg": "^8.20.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* 换钉前的**排空检查 —— `DB_BACKEND=local`(File 店)车道**,只读。随 npm 包出(`scripts/drain-check-local.mjs`)。
|
|
4
|
-
*
|
|
4
|
+
* 一次跑**九条判据**(判据表 {@link DRAIN_CRITERIA},每条一行末行、各自的命中行;SQL 车道的同一判据是同目录随包的 `drain-check.mysql.sql` / `drain-check.pg.sql`,
|
|
5
5
|
* 每条判据一段、段首标记 `-- drain-check:<判据名>:<后端>`,判据名与本表的 `name` 同一个词):
|
|
6
6
|
* · `skill-grants-rollback`(**回滚**到 7.115.x 前,即引擎从 7.41 退回 7.40):四样任一 ——
|
|
7
7
|
* ① pending 行带 `state.skillGrants`(本次 run 冻结在行上的技能授予行:模型激活 / 子代捕获写下的放行与禁止);
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
* `dist/orchestration/workflow-agent-session-index.js` 取 —— 本脚本只按 runId 折叠;读不出的行计入 `corrupt`(rc 2:读不出的那一行可能正是点名某张待批卡的那一份);
|
|
32
32
|
* 窗与删码:本判据是一次性迁移 M9 的读侧半场 —— 窗口与删码清单见引擎启动期一次性迁移登记表(one-time-migrations)M9 一行,随 M9 一起删;这里不写第二份窗。
|
|
33
33
|
* · `parked-tool-lists`(升级到 7.132.0 前)/ `own-tool-lists-rollback`(从 7.132.0 回滚前):停驻行记下的工具名清单 / 7.52 写下的 `ownToolLists`(判据与出路见判据表那两条的注);
|
|
34
|
+
* · `sealed-credentials-rollback`(从 7.134.0 回滚前):续跑上下文的凭据位上带封签的 pending 行(7.133.x 读不懂封签,续跑时把这些位当没有;判据与出路见判据表那一条的注);
|
|
34
35
|
* · `retired-mode-seed`(换钉 7.113.0 前,core 7.39.0 删掉退役 mode-seed 的一次性迁移):pending 行的 `state.inheritedGate` 仍带退役成员;
|
|
35
36
|
* · `permissions-allow-list`(换钉 7.117.0 前,本服务把 `settings.permissions.allow` 整份交给引擎的 allow 层):pending 行所在会话的续跑上下文
|
|
36
37
|
* (`checkpoint-ctx/*.json` 的信封 `{ sessionId, updatedAt, ctx }`)里,`ctx.body.settings.permissions.allow` 是非空数组,且 `ctx.permissionsAllowReading` 不是 `"allow_layer"`
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
* `SKILL-DENY-INERT-ROW token=<token> sessionId=<id> createdAt=<ms> member=<skills|agents.skills>` /
|
|
75
76
|
* `WORKFLOW-PARK-ROW token=<token> sessionId=<id> createdAt=<ms> runId=<点名它的 run,逗号连接>` /
|
|
76
77
|
* `PARKED-TOOL-LISTS-ROW token=<token> sessionId=<id> createdAt=<ms> member=<toolCeiling|constraintChain|boundGrantDigest>` / `OWN-TOOL-LISTS-ROW token=<token> sessionId=<id> createdAt=<ms>` /
|
|
78
|
+
* `SEALED-CREDENTIALS-ROW token=<token> sessionId=<id> createdAt=<ms> field=<第一处带封签的凭据位>|runId=<workflow 子代卡:点它的 run>` /
|
|
77
79
|
* `ALLOW-LIST-ROW token=<token> sessionId=<id> createdAt=<ms>` / `RETIRED-ROW token=<token> sessionId=<id> createdAt=<ms> member=<成员>`;
|
|
78
80
|
* · 每条判据一行末行(表序;`RETIRED-MODE-SEED` 那一行恒在最后,7.113.0 起读「最后一行」的下游不受影响;`PERMISSIONS-ALLOW-LIST` 仍是倒数第二行):
|
|
79
81
|
* `SKILL-GRANTS rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
@@ -82,6 +84,7 @@
|
|
|
82
84
|
* `WORKFLOW-PARK-HOLDER rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
83
85
|
* `PARKED-TOOL-LISTS rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
84
86
|
* `OWN-TOOL-LISTS-ROLLBACK rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
87
|
+
* `SEALED-CREDENTIALS-ROLLBACK rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
85
88
|
* `PERMISSIONS-ALLOW-LIST rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`,
|
|
86
89
|
* `RETIRED-MODE-SEED rows=<命中数> pending=<pending 行数> total=<行数> unknownEvents=<n> corrupt=<n> root=<实际读的数据根>`;
|
|
87
90
|
* `corrupt` = 共用扫描的坏记录 + 这条判据自己读不懂的旁路输入(`permissions-allow-list`:读不懂的 ctx 档,文件名进 stderr —— 一份读不懂的 ctx 可能正是某条 pending 行带 `allow` 的那一份;
|
|
@@ -97,7 +100,7 @@ import { join } from "node:path";
|
|
|
97
100
|
import { fileURLToPath } from "node:url";
|
|
98
101
|
|
|
99
102
|
/** 从脚本隔壁的编译产物取来的服务判据(脚本不持第二份实现)。
|
|
100
|
-
* @typedef {{ allowListReadingUnstated: (ctx: Record<string, unknown>) => boolean, retiredSkillManifestLayerOf: (body: unknown) => "skills" | "agents.skills" | undefined, skillDenyInertEntryOf: (body: unknown) => { layer: "skills" | "agents.skills", message: string } | undefined, readAgentSessionLedgerLine: (v: unknown) => { runId: string, rows: Array<{ sessionId: string }> } | undefined }} ServiceCriteria */
|
|
103
|
+
* @typedef {{ allowListReadingUnstated: (ctx: Record<string, unknown>) => boolean, sealedCredentialFieldOf: (ctx: unknown) => string | undefined, retiredSkillManifestLayerOf: (body: unknown) => "skills" | "agents.skills" | undefined, skillDenyInertEntryOf: (body: unknown) => { layer: "skills" | "agents.skills", message: string } | undefined, readAgentSessionLedgerLine: (v: unknown) => { runId: string, rows: Array<{ sessionId: string }> } | undefined }} ServiceCriteria */
|
|
101
104
|
|
|
102
105
|
/** 读期间文件在变时的有界重读次数(含第一次)。 */
|
|
103
106
|
const STABLE_READ_ATTEMPTS = 3;
|
|
@@ -460,6 +463,34 @@ export const DRAIN_CRITERIA = [
|
|
|
460
463
|
load: () => ({ input: undefined, corrupt: 0, unreadable: [] }),
|
|
461
464
|
judge: (row) => (isObject(row.state) && Object.hasOwn(/** @type {Record<string, unknown>} */ (row.state), "ownToolLists") ? "" : undefined),
|
|
462
465
|
},
|
|
466
|
+
{
|
|
467
|
+
// 从 7.134.0 回滚到 7.133.x 之前:pending 行所在会话的续跑上下文里,提交体的凭据位(MCP / A2A 请求头与 env、settings.env、settings.webSearch.apiKey、http hook 请求头)
|
|
468
|
+
// 上带封签 —— 7.134.0 封好才落盘,7.133.x 读不懂封签、续跑时把这些位当作没有(无凭据照跑、不报错)。出路:回滚前把它们决掉或取消(随包 `MIGRATION.md` 7.134.0 节)。
|
|
469
|
+
// 判据函数是服务里那一只(`sealedCredentialFieldOf`,经编译产物 `dist/http/checkpoint-ctx.js` 取;走法与封口 / 开口 / 一次性迁移同一只),本脚本不写第二份;
|
|
470
|
+
// 命中行点名第一处凭据位(`field=`,键名;值从不出来);读不懂的 ctx 档 / 索引账本行计入 `corrupt`(rc 2)。
|
|
471
|
+
// 读哪一份续跑上下文与续跑腿同:workflow 子代卡(子会话被 park 索引点名)续跑读**发起会话**那一份,而发起会话记在引擎的 run 账里(引擎自己的账本格式,本脚本不重抄)
|
|
472
|
+
// ⇒ 子代卡数的是真超集:自己那一份带封签,或数据根里任一份 ctx 带封签,即记为候选并点名点它的 run(`runId=`)—— 与随包 SQL 孪生同为超集,不漏。
|
|
473
|
+
// 表序在 `permissions-allow-list` 之前 —— 那一条仍倒数第二、`RETIRED-MODE-SEED` 仍最后。
|
|
474
|
+
name: "sealed-credentials-rollback",
|
|
475
|
+
tail: "SEALED-CREDENTIALS-ROLLBACK",
|
|
476
|
+
hit: "SEALED-CREDENTIALS-ROW",
|
|
477
|
+
load: (root, service) => {
|
|
478
|
+
const idx = readCtxIndex(root);
|
|
479
|
+
const parks = readParkIndex(root, service.readAgentSessionLedgerLine);
|
|
480
|
+
const fieldOf = service.sealedCredentialFieldOf;
|
|
481
|
+
const anySealed = [...idx.bySession.values()].some((ctx) => fieldOf(ctx) !== undefined);
|
|
482
|
+
return { input: { bySession: idx.bySession, fieldOf, parkedBy: parks.bySession, anySealed }, corrupt: idx.corrupt + parks.corrupt, unreadable: [...idx.unreadable, ...parks.unreadable] };
|
|
483
|
+
},
|
|
484
|
+
judge: (row, input) => {
|
|
485
|
+
const { bySession, fieldOf, parkedBy, anySealed } = /** @type {{ bySession: Map<string, Record<string, unknown>>, fieldOf: ServiceCriteria["sealedCredentialFieldOf"], parkedBy: Map<string, string[]>, anySealed: boolean }} */ (input);
|
|
486
|
+
if (typeof row.sessionId !== "string") return undefined;
|
|
487
|
+
const ctx = bySession.get(row.sessionId);
|
|
488
|
+
const field = ctx === undefined ? undefined : fieldOf(ctx);
|
|
489
|
+
if (field !== undefined) return ` field=${field}`;
|
|
490
|
+
const runs = parkedBy.get(row.sessionId);
|
|
491
|
+
return runs !== undefined && anySealed ? ` runId=${runs.join(",")}` : undefined;
|
|
492
|
+
},
|
|
493
|
+
},
|
|
463
494
|
{
|
|
464
495
|
name: "permissions-allow-list",
|
|
465
496
|
tail: "PERMISSIONS-ALLOW-LIST",
|
|
@@ -503,6 +534,7 @@ async function loadServiceCriteria(rootEcho) {
|
|
|
503
534
|
/** @type {Array<[string, () => Promise<Record<string, unknown>>, string]>} 〔产物相对路径(报告用), 取模块, 导出名〕 */
|
|
504
535
|
const wanted = [
|
|
505
536
|
["dist/http/checkpoint-ctx.js", () => import("../dist/http/checkpoint-ctx.js"), "allowListReadingUnstated"],
|
|
537
|
+
["dist/http/checkpoint-ctx.js", () => import("../dist/http/checkpoint-ctx.js"), "sealedCredentialFieldOf"],
|
|
506
538
|
["dist/http/retired-skill-manifest.js", () => import("../dist/http/retired-skill-manifest.js"), "retiredSkillManifestLayerOf"],
|
|
507
539
|
["dist/rule-entry-list.js", () => import("../dist/rule-entry-list.js"), "skillDenyInertEntryOf"],
|
|
508
540
|
["dist/orchestration/workflow-agent-session-index.js", () => import("../dist/orchestration/workflow-agent-session-index.js"), "readAgentSessionLedgerLine"],
|
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
-- sessions 命中行所在的会话 id,逗号连接,新的在前。以 hit_rows 为准:这一列被会话变量 group_concat_max_len(缺省 1024 字节)截断时,列出的会话数会少于 hit_rows ——
|
|
9
9
|
-- 先处理列出的再跑一次,或先在同一个会话里 SET SESSION group_concat_max_len = 1048576; 再跑本文件(本文件自己只含 SELECT)。
|
|
10
10
|
-- 每段只数 pending 行(已决 / 已过期的行不数);判据只看**键在不在 / 值形**,不读行的其余内容。
|
|
11
|
-
-- DB_BACKEND=local(File 店)没有 SQL:用同目录的 drain-check-local.mjs
|
|
11
|
+
-- DB_BACKEND=local(File 店)没有 SQL:用同目录的 drain-check-local.mjs,九条判据同名。
|
|
12
12
|
--
|
|
13
|
-
--
|
|
13
|
+
-- 九条判据(顺序同 drain-check-local.mjs 的判据表):
|
|
14
14
|
-- skill-grants-rollback 回滚到 7.115.x(引擎 7.40)之前:7.116.0 停驻的行带 7.40 不读的技能授予节 / 卡绑定 / 会话上下文里的人点名技能 / 还没被激活的技能声明的禁止清单。
|
|
15
15
|
-- retired-skill-manifest 升级到 7.116.0 之前:停驻、持久化提交体里技能(顶层 skills[] 或子代 agents[].skills[])还带已退役的 manifest 键。
|
|
16
16
|
-- skill-deny-inert 换钉 7.117.0 之前:停驻、提交体里技能(顶层 skills[] 或子代 agents[].skills[])的 disallowedTools 有引擎会读成空的条目的**候选**(见该段注)。
|
|
17
17
|
-- workflow-park-holder 换钉 7.118.0 之前 / 从 7.118.0 回滚到 7.117.x 之前:此刻待批、且子会话被 workflow park 索引点名的卡(workflow 子代卡;见该段注)。
|
|
18
18
|
-- parked-tool-lists 升级到 7.132.0 之前:停驻行记着子代工具天花板 / 冻结的父约束链 / Skill 卡的清单绑定(7.52 在认领前按规范拼写读它们)的**候选**(见该段注)。
|
|
19
19
|
-- own-tool-lists-rollback 从 7.132.0 回滚到 7.131.x 之前:7.132.0 停驻、带 state.ownToolLists 的行(7.131.x 读不了)。
|
|
20
|
+
-- sealed-credentials-rollback 从 7.134.0 回滚到 7.133.x 之前:停驻、续跑上下文里提交体的凭据位上带封签的行(7.133.x 读不懂封签,续跑时把这些位当没有)的**候选**(见该段注)。
|
|
20
21
|
-- permissions-allow-list 换钉 7.117.0 之前:停驻、提交体 settings.permissions.allow 是非空数组且读法记号不是当前的 "allow_layer"(无记号 = 名单时代;"statement" = 表态时代)。
|
|
21
22
|
-- retired-mode-seed 换钉 7.113.0 之前:检查点的 inheritedGate 里仍带退役 mode-seed 成员。
|
|
22
23
|
|
|
@@ -115,6 +116,23 @@ FROM checkpoint k
|
|
|
115
116
|
WHERE k.status = 'pending'
|
|
116
117
|
AND JSON_CONTAINS_PATH(k.checkpoint, 'one', '$.state.ownToolLists');
|
|
117
118
|
|
|
119
|
+
-- drain-check:sealed-credentials-rollback:mysql —— 期望 hit_rows = 0;每一行 = 一条**候选**:从 7.134.0 回滚到 7.133.x 后续跑会丢掉请求凭据的停驻行。
|
|
120
|
+
-- 在**回滚之前**、对 7.134.0 的数据跑:7.134.0 把续跑上下文里提交体的凭据位(MCP / A2A 请求头与 env、settings.env、settings.webSearch.apiKey、http hook 请求头)
|
|
121
|
+
-- 封成封签(对象,格式词 "checkpoint-ctx-sealedbox-v1")才落盘;7.133.x 读不懂封签,续跑时把这些位当作没有(无凭据照跑、不报错)。出路:回滚前把它们决掉或取消(见随包 MIGRATION.md 7.134.0 节)。
|
|
122
|
+
-- 读哪一份续跑上下文:与续跑腿同(连接形与 permissions-allow-list 段逐字同,理由见该段注)。SQL 不走凭据位闭集 ⇒ 数的是**真超集**:提交体里任何一处有一个
|
|
123
|
+
-- JSON 串值恰为这个格式词即数(封签只落在凭据位上;体里别处恰好写着这个词的串值也会被数到 —— 多数,不漏)。本地脚本同名判据走服务里那一只凭据位走法(精确)。
|
|
124
|
+
SELECT 'sealed-credentials-rollback' AS criterion, COUNT(*) AS hit_rows,
|
|
125
|
+
COALESCE(GROUP_CONCAT(k.session_id ORDER BY k.created_at_ms DESC SEPARATOR ','), '') AS sessions
|
|
126
|
+
FROM checkpoint k
|
|
127
|
+
WHERE k.status = 'pending'
|
|
128
|
+
AND EXISTS (SELECT 1
|
|
129
|
+
FROM checkpoint kk
|
|
130
|
+
LEFT JOIN workflow_agent_session w ON w.session_id = kk.session_id
|
|
131
|
+
LEFT JOIN workflow_run r ON r.id = w.run_id
|
|
132
|
+
JOIN checkpoint_ctx c ON c.session_id = COALESCE(JSON_UNQUOTE(JSON_EXTRACT(r.run, '$.originatingSessionId')), kk.session_id)
|
|
133
|
+
WHERE kk.token = k.token
|
|
134
|
+
AND LOCATE('"checkpoint-ctx-sealedbox-v1"', CAST(JSON_EXTRACT(c.ctx, '$.body') AS CHAR)) > 0);
|
|
135
|
+
|
|
118
136
|
-- drain-check:permissions-allow-list:mysql —— 期望 hit_rows = 0;每一行 = 一条升级后续跑会被拒的停驻行。
|
|
119
137
|
-- 读哪一份续跑上下文:与续跑腿同 —— workflow 子代的停驻行(在 workflow_agent_session 里登记过)续跑时读的是**发起这条 workflow 的会话**那一份
|
|
120
138
|
-- (workflow_run.run 的 originatingSessionId);其余行读自己会话那一份。一个子会话可以被好几条 workflow 记录点名(续跑链 / 分叉;7.118.0 起索引主键是
|
|
@@ -7,15 +7,16 @@
|
|
|
7
7
|
-- hit_rows 命中的停驻行数(pending 行里算命中的那些);**全部为 0 才算排空**,非 0 ⇒ 逐条答完或取消(各判据对应的升级 / 回滚说明见随包 MIGRATION.md);
|
|
8
8
|
-- sessions 命中行所在的会话 id,逗号连接,新的在前。
|
|
9
9
|
-- 每段只数 pending 行(已决 / 已过期的行不数);判据只看**键在不在 / 值形**,不读行的其余内容。
|
|
10
|
-
-- DB_BACKEND=local(File 店)没有 SQL:用同目录的 drain-check-local.mjs
|
|
10
|
+
-- DB_BACKEND=local(File 店)没有 SQL:用同目录的 drain-check-local.mjs,九条判据同名。
|
|
11
11
|
--
|
|
12
|
-
--
|
|
12
|
+
-- 九条判据(顺序同 drain-check-local.mjs 的判据表):
|
|
13
13
|
-- skill-grants-rollback 回滚到 7.115.x(引擎 7.40)之前:7.116.0 停驻的行带 7.40 不读的技能授予节 / 卡绑定 / 会话上下文里的人点名技能 / 还没被激活的技能声明的禁止清单。
|
|
14
14
|
-- retired-skill-manifest 升级到 7.116.0 之前:停驻、持久化提交体里技能(顶层 skills[] 或子代 agents[].skills[])还带已退役的 manifest 键。
|
|
15
15
|
-- skill-deny-inert 换钉 7.117.0 之前:停驻、提交体里技能(顶层 skills[] 或子代 agents[].skills[])的 disallowedTools 有引擎会读成空的条目的**候选**(见该段注)。
|
|
16
16
|
-- workflow-park-holder 换钉 7.118.0 之前 / 从 7.118.0 回滚到 7.117.x 之前:此刻待批、且子会话被 workflow park 索引点名的卡(workflow 子代卡;见该段注)。
|
|
17
17
|
-- parked-tool-lists 升级到 7.132.0 之前:停驻行记着子代工具天花板 / 冻结的父约束链 / Skill 卡的清单绑定(7.52 在认领前按规范拼写读它们)的**候选**(见该段注)。
|
|
18
18
|
-- own-tool-lists-rollback 从 7.132.0 回滚到 7.131.x 之前:7.132.0 停驻、带 state.ownToolLists 的行(7.131.x 读不了)。
|
|
19
|
+
-- sealed-credentials-rollback 从 7.134.0 回滚到 7.133.x 之前:停驻、续跑上下文里提交体的凭据位上带封签的行(7.133.x 读不懂封签,续跑时把这些位当没有)的**候选**(见该段注)。
|
|
19
20
|
-- permissions-allow-list 换钉 7.117.0 之前:停驻、提交体 settings.permissions.allow 是非空数组且读法记号不是当前的 "allow_layer"(无记号 = 名单时代;"statement" = 表态时代)。
|
|
20
21
|
-- retired-mode-seed 换钉 7.113.0 之前:检查点的 inheritedGate 里仍带退役 mode-seed 成员。
|
|
21
22
|
|
|
@@ -123,6 +124,23 @@ FROM checkpoint k
|
|
|
123
124
|
WHERE k.status = 'pending'
|
|
124
125
|
AND (k.checkpoint -> 'state') ? 'ownToolLists';
|
|
125
126
|
|
|
127
|
+
-- drain-check:sealed-credentials-rollback:pg —— 期望 hit_rows = 0;每一行 = 一条**候选**:从 7.134.0 回滚到 7.133.x 后续跑会丢掉请求凭据的停驻行。
|
|
128
|
+
-- 在**回滚之前**、对 7.134.0 的数据跑:7.134.0 把续跑上下文里提交体的凭据位(MCP / A2A 请求头与 env、settings.env、settings.webSearch.apiKey、http hook 请求头)
|
|
129
|
+
-- 封成封签(对象,格式词 "checkpoint-ctx-sealedbox-v1")才落盘;7.133.x 读不懂封签,续跑时把这些位当作没有(无凭据照跑、不报错)。出路:回滚前把它们决掉或取消(见随包 MIGRATION.md 7.134.0 节)。
|
|
130
|
+
-- 读哪一份续跑上下文:与续跑腿同(连接形与 permissions-allow-list 段逐字同,理由见该段注)。SQL 不走凭据位闭集 ⇒ 数的是**真超集**:提交体里任何一处有一个
|
|
131
|
+
-- JSON 串值恰为这个格式词即数(封签只落在凭据位上;体里别处恰好写着这个词的串值也会被数到 —— 多数,不漏)。本地脚本同名判据走服务里那一只凭据位走法(精确)。
|
|
132
|
+
SELECT 'sealed-credentials-rollback' AS criterion, count(*) AS hit_rows,
|
|
133
|
+
coalesce(string_agg(k.session_id, ',' ORDER BY k.created_at_ms DESC), '') AS sessions
|
|
134
|
+
FROM checkpoint k
|
|
135
|
+
WHERE k.status = 'pending'
|
|
136
|
+
AND EXISTS (SELECT 1
|
|
137
|
+
FROM checkpoint kk
|
|
138
|
+
LEFT JOIN workflow_agent_session w ON w.session_id = kk.session_id
|
|
139
|
+
LEFT JOIN workflow_run r ON r.id = w.run_id
|
|
140
|
+
JOIN checkpoint_ctx c ON c.session_id = COALESCE(r.run::json->>'originatingSessionId', kk.session_id)
|
|
141
|
+
WHERE kk.token = k.token
|
|
142
|
+
AND strpos((c.ctx -> 'body')::text, '"checkpoint-ctx-sealedbox-v1"') > 0);
|
|
143
|
+
|
|
126
144
|
-- drain-check:permissions-allow-list:pg —— 期望 hit_rows = 0;每一行 = 一条升级后续跑会被拒的停驻行。
|
|
127
145
|
-- 读哪一份续跑上下文:与续跑腿同 —— workflow 子代的停驻行(在 workflow_agent_session 里登记过)续跑时读的是**发起这条 workflow 的会话**那一份
|
|
128
146
|
-- (workflow_run.run 的 originatingSessionId);其余行读自己会话那一份。一个子会话可以被好几条 workflow 记录点名(续跑链 / 分叉;7.118.0 起索引主键是
|
package/dist/mcp-tool-faces.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `McpServerSpec.toolFaces` —— MCP 工具的**面覆盖层**(core 7.8.0 [ref] §1.1/§2.7;声明面
|
|
3
|
-
* settings-schema 1.9.0)。一条规则、三条腿共用(请求腿 `task-mcp.ts normalizeServer` / center 腿
|
|
4
|
-
* `web-admin-client/skills-mcp.ts resolveMcpServers` / 本地 config.d 腿 `config-provider.ts` 只做承载),
|
|
5
|
-
* 与 {@link import("./mcp-source-label.js").readMcpSourceLabel} 同一个「判据单点、三腿一致」的形。
|
|
6
|
-
*
|
|
7
|
-
* ## 分工(为什么本层**不**复述 core 的那张表)
|
|
8
|
-
* 覆盖层的**语义**校验属 core 的摄入侧,而且只有它做得了:`pathTarget.param` 是不是这只工具**物化后
|
|
9
|
-
* schema** 的顶层属性、审批卡要的键在不在、`ruleFace` 指的是不是标量键 —— 三件都要看远端 server 真发
|
|
10
|
-
* 回来的 schema,本层手里根本没有。core 的处置也已经定死:不合 ⇒ **这只工具在这条腿上不挂**,并通告
|
|
11
|
-
* 一次 `config.tool_face_invalid`(亲读 `dist/core/runner/tool-face-overlay.js` 的 `return undefined` 臂 ——
|
|
12
|
-
* 该文件 d.ts 头注里那句「the tool mounts BARE」是**过期**的,以实现为准)。
|
|
13
|
-
*
|
|
14
|
-
* 本层因此只做 core 的校验器**假定成立**的那一件事:**JSON 结构合不合 TS 型**。理由是硬的 —— core 的
|
|
15
|
-
* `toolFaceProblem` 是按 TS 型写的,`renderHints.summaryParams` 是个字符串时它会 `.find is not a function`
|
|
16
|
-
* 地把 prepare 整条炸掉,`ruleFace.params` 是个数字时 `for...of` 直接抛。原样透传一份任意 JSON 不是
|
|
17
|
-
* 「解析透明」,是把类型错误变成运行期崩溃。
|
|
18
|
-
*
|
|
19
|
-
* 闭词(`family` / `pathTarget.access` / `renderHints.approvalCard`)判据**取自 core 的导出常量**
|
|
20
|
-
* (`TOOL_FAMILIES` / `TOOL_PATH_ACCESSES` / `TOOL_APPROVAL_CARDS`),本仓一个词都不枚举 —— 与
|
|
21
|
-
* `MCP_DELIVERY_VERDICTS` 的消费姿势同款:词表单一属主在 core,抄一遍就是抄了一张会漂的表。
|
|
22
|
-
*
|
|
23
|
-
* ## 坏形的方向:**整条 server 不进**(fail-closed)
|
|
24
|
-
* 🔴 这一条被 codex 对抗复审 r1 的 [high] **翻正过一次**,把翻正的理由留在这里,因为它是本模块最容易
|
|
25
|
-
* 想错的一格:初版按 `contentOrigin` 的先例判「丢声明、留 server + 留痕」,而那条先例管的是**放宽**键
|
|
26
|
-
* (丢它 ⇒ 回落到过度标记 = fail-closed 的那一侧)。`toolFaces` 是**收窄**声明:它声明的 `pathTarget`
|
|
27
|
-
* 正是敏感路径策略、写围栏、编辑跟踪读的那一格 —— 丢掉它,那只工具就**无面挂载**,运维声明的保护
|
|
28
|
-
* 静默失效。codex 实测(同一只 MCP 写工具、同一个 `/work/.env` 目标,仅把 `renderHints.summaryParams`
|
|
29
|
-
* 从数组写成字符串):`createSensitivePathPolicy` 从 deny 变成 allow。一条 warn 补偿不了这个方向。
|
|
30
|
-
*
|
|
31
|
-
* 所以判据回到本仓对**收窄键**已经成文的那一条(`task-mcp.ts` 的 `allowTools`,[ref] / [ref] codex F1):
|
|
32
|
-
* **一个键在场就必须合法,否则这条 server 整条不进**。三问逐条:
|
|
33
|
-
* ① 谁需要 —— 在部署侧给 MCP 工具声明写围栏 / 审批卡 / 显示名的运维;
|
|
34
|
-
* ② 谁受伤 —— 覆盖层写错的那台 server:它**整条**不挂(请求腿进 `dropped` 并点名上报,center 腿跳过
|
|
35
|
-
* 该条、兄弟 server 照挂)。代价是真的(少一套工具),但它**响亮且立刻**;反方向的代价是一条
|
|
36
|
-
* **静默失效的安全声明**,而后者按 [ref] 不许存在于安全轴上;
|
|
37
|
-
* ③ 拿什么补偿 —— 报出来的名字本身:请求腿 `mcp_injection_dropped{dropped:[name]}`、center 腿
|
|
38
|
-
* `web_admin_mcp_tool_faces_invalid{server,problem,note}` 一条点名 warn(`problem` 里带工具名与哪一段不合;运维照着改那一行即可)。
|
|
39
|
-
* 每只工具的面是**整只**判(core 明写 "applied whole or not at all");而**任一只**判不出形 ⇒ 整条 server
|
|
40
|
-
* 不进 —— 「留下好的那几只」同样是让坏的那一只无面挂载,与整张丢没有区别。
|
|
41
|
-
*/
|
|
42
|
-
import { type McpServerSpec } from "@sema-agent/core";
|
|
43
|
-
type ToolFaces = NonNullable<McpServerSpec["toolFaces"]>;
|
|
44
|
-
/**
|
|
45
|
-
* 一条 server 条目的 `toolFaces` 判形结果:
|
|
46
|
-
* · `{ ok: true, faces }` —— 合形(`faces` 缺席 = 这台 server 没有覆盖层,或声明了一个**空**覆盖层:
|
|
47
|
-
* 两者对 core 同义,都不铸键);
|
|
48
|
-
* · `{ ok: false, problem }` —— 判不出形,**整条 server 不进**(方向与理由见模块头注),`problem` 是
|
|
49
|
-
* 给运维的一句点名(只带工具名与哪一段不合,不带面的值)。
|
|
50
|
-
*/
|
|
51
|
-
export type McpToolFacesRead = {
|
|
52
|
-
ok: true;
|
|
53
|
-
faces?: ToolFaces;
|
|
54
|
-
} | {
|
|
55
|
-
ok: false;
|
|
56
|
-
problem: string;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* 从任一腿的原始条目里读出 `toolFaces` —— **三条腿共用的唯一判据点**。
|
|
60
|
-
* 缺席 ⇒ 合形无覆盖层;整只不是对象 / **任一只**工具的面判不出形 ⇒ `ok:false`(调用方整条 server 不收)。
|
|
61
|
-
*
|
|
62
|
-
* 🔴 工具名是 `__proto__` ⇒ 同样判不出形,**响亮拒**:按名存面的记录装不下它 —— JSON 的自有键 `"__proto__"` 写进记录那一步走的是原型的设置器,
|
|
63
|
-
* 键从结果里消失而判官答 `ok`,那条 server 照挂、收窄面叠层被无声丢掉。方向与本模块头注同(收窄声明在场就必须原样可用)。
|
|
64
|
-
* 只拒这一个名字:`constructor` / `toString` 等其余根原型成员名写进记录是普通自有键、不丢,引擎按名查面也取得到 —— 拒它们是给重放存量 body 的腿
|
|
65
|
-
* 新添一条「整条 server 不进」,不是修这个病。
|
|
66
|
-
*/
|
|
67
|
-
export declare function readMcpToolFaces(v: unknown): McpToolFacesRead;
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=mcp-tool-faces.d.ts.map
|