@sema-agent/server 7.131.0 → 7.133.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 +575 -0
- package/README.md +12 -9
- package/README.zh-CN.md +9 -6
- package/USAGE.md +326 -98
- package/deploy/sema-up/README.md +19 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
- package/deploy/sema-up/chart/templates/server.yaml +5 -2
- 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 +31 -13
- 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 +82 -20
- package/dist/approval-card.js +46 -16
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval.d.ts +9 -0
- package/dist/approval.js +24 -3
- package/dist/audit.d.ts +33 -19
- package/dist/audit.js +12 -16
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/deployment-mods.d.ts +31 -0
- package/dist/boot/deployment-mods.js +26 -0
- package/dist/boot/execution-env.d.ts +1 -1
- package/dist/boot/execution-env.js +27 -12
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.js +2 -0
- package/dist/boot/memory-boundary.d.ts +2 -2
- 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.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +4 -5
- package/dist/boot/resolve-spec.js +74 -123
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +15 -2
- package/dist/boot/session-faces.d.ts +2 -7
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -4
- package/dist/boot/stage-05-execution-env.js +7 -10
- package/dist/boot/stage-06-runners.d.ts +4 -2
- package/dist/boot/stage-06-runners.js +11 -7
- package/dist/boot/stage-07-capability-layer.d.ts +4 -2
- package/dist/boot/stage-07-capability-layer.js +27 -6
- package/dist/boot/stage-08-reapers.d.ts +4 -2
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +6 -9
- package/dist/boot/stage-10-http-server.d.ts +6 -9
- package/dist/boot/stage-10-http-server.js +7 -9
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +7 -8
- package/dist/boot/web-admin.d.ts +4 -3
- package/dist/boot/web-admin.js +186 -98
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +25 -25
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +23 -0
- package/dist/caller-text-echo.js +21 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +32 -59
- package/dist/capabilities/center-prompts.js +18 -32
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +30 -6
- package/dist/capabilities/hands-lane.js +11 -1
- package/dist/capabilities/mcp-probe.d.ts +48 -3
- package/dist/capabilities/mcp-probe.js +47 -135
- package/dist/capabilities/scenarios.d.ts +95 -45
- package/dist/capabilities/scenarios.js +53 -38
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capability-facts.d.ts +34 -4
- package/dist/capability-facts.js +28 -2
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -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 +47 -32
- 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-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +9 -2
- package/dist/config-provider.js +18 -6
- package/dist/config-types.d.ts +75 -20
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +137 -62
- 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 -22
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/env-name-allowlist-knobs.d.ts +12 -2
- package/dist/env-name-allowlist-knobs.js +5 -4
- package/dist/exec-bounds.d.ts +15 -3
- package/dist/exec-bounds.js +4 -0
- package/dist/execution-lane-caps.d.ts +56 -10
- package/dist/execution-lane-caps.js +50 -0
- package/dist/field-conflict.d.ts +43 -0
- package/dist/field-conflict.js +20 -0
- package/dist/fleet/fleet-bus.d.ts +80 -6
- package/dist/fleet/fleet-bus.js +41 -9
- package/dist/hooks/classic-stations.d.ts +91 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +79 -36
- package/dist/hooks/hook-runner.d.ts +349 -95
- package/dist/hooks/hook-runner.js +855 -568
- 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.d.ts +8 -2
- package/dist/http/admission.js +188 -101
- package/dist/http/approval-sweeps.js +99 -21
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +41 -24
- package/dist/http/checkpoint-ctx.js +23 -16
- package/dist/http/claimed-run.d.ts +14 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +7 -11
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +15 -13
- package/dist/http/durable-run-leg.d.ts +6 -33
- package/dist/http/durable-run-leg.js +36 -10
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +70 -28
- package/dist/http/principal-gate.js +61 -15
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +43 -23
- package/dist/http/request-guards.js +53 -17
- package/dist/http/resume-ctx-read.d.ts +2 -5
- package/dist/http/resume-ctx-read.js +7 -4
- package/dist/http/resume-legs.d.ts +28 -4
- package/dist/http/resume-legs.js +169 -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 -28
- 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/approvals-assistant.js +49 -48
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +21 -5
- 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.js +6 -2
- 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.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 +5 -18
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +34 -107
- package/dist/http/routes/session-sync.js +15 -26
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +8 -7
- package/dist/http/routes/tasks.js +67 -21
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +33 -10
- package/dist/http/send.js +21 -4
- package/dist/http/server.d.ts +27 -18
- package/dist/http/server.js +34 -6
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +40 -0
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +11 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/lane-home-probe.d.ts +112 -0
- package/dist/lane-home-probe.js +101 -0
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/limit-refusal.d.ts +59 -0
- package/dist/limit-refusal.js +15 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +32 -19
- package/dist/mcp-assertion-header.js +10 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +6 -4
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +24 -17
- 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-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 +44 -12
- package/dist/model-provider.js +21 -2
- package/dist/model-route-endpoint.d.ts +9 -12
- package/dist/model-route-endpoint.js +8 -11
- 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/cost-taxonomy.d.ts +7 -7
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +76 -14
- package/dist/observability/fail-open.js +76 -14
- package/dist/observability/metrics.js +4 -1
- package/dist/observability/prompt-manifest.d.ts +33 -82
- package/dist/observability/prompt-manifest.js +122 -17
- package/dist/observability/run-terminal.js +14 -6
- package/dist/observability/secret-env-scrub.d.ts +13 -1
- package/dist/observability/secret-env-scrub.js +13 -1
- package/dist/observability/tool-trace.d.ts +16 -21
- package/dist/observability/tool-trace.js +58 -49
- 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 +118 -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 +39 -6
- package/dist/parked-decide.js +98 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- 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/blob-backend.d.ts +83 -15
- package/dist/plugins/blob-backend.js +68 -15
- 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 +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +28 -4
- package/dist/plugins/checkpoint-store-sql.js +59 -28
- 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/k8s-bg-scripts.d.ts +11 -0
- package/dist/plugins/k8s-bg-scripts.js +22 -0
- package/dist/plugins/local-checkpoint-store.d.ts +2 -0
- package/dist/plugins/local-checkpoint-store.js +11 -3
- package/dist/plugins/local-session-store.d.ts +1 -1
- package/dist/plugins/local-session-store.js +1 -1
- package/dist/plugins/local-session-window.d.ts +39 -0
- package/dist/plugins/local-session-window.js +54 -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 +245 -93
- package/dist/plugins/one-time-migrations.js +668 -207
- 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-sql.d.ts +13 -7
- package/dist/plugins/permission-rule-store-sql.js +4 -18
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +20 -8
- package/dist/plugins/pg-session-storage.js +34 -21
- package/dist/plugins/remote-env-adb.d.ts +12 -12
- package/dist/plugins/remote-env-adb.js +21 -6
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +1 -1
- package/dist/plugins/remote-env-e2b.js +21 -9
- package/dist/plugins/remote-env-host.d.ts +9 -9
- package/dist/plugins/remote-env-host.js +10 -32
- package/dist/plugins/remote-env-k8s.d.ts +103 -38
- package/dist/plugins/remote-env-k8s.js +288 -95
- package/dist/plugins/remote-env-local-docker.d.ts +27 -13
- package/dist/plugins/remote-env-local-docker.js +82 -11
- package/dist/plugins/remote-env-ssh.d.ts +21 -12
- package/dist/plugins/remote-env-ssh.js +117 -5
- package/dist/plugins/remote-shell.d.ts +0 -1
- package/dist/plugins/remote-shell.js +1 -2
- package/dist/plugins/retention-store-sql.js +6 -2
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- 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 +39 -0
- package/dist/plugins/session-epoch-anchor.js +22 -0
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
- package/dist/plugins/shared-memory-store-sql.js +5 -16
- package/dist/plugins/sql-driver.d.ts +205 -1
- package/dist/plugins/sql-driver.js +325 -13
- package/dist/plugins/sql-errors.d.ts +64 -0
- package/dist/plugins/sql-errors.js +57 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +42 -15
- 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 +8 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.d.ts +24 -4
- package/dist/plugins/tidb-session-store.js +29 -5
- 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/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- 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 +9 -2
- package/dist/request-key-closure.js +11 -5
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +38 -11
- package/dist/rule-entry-list.js +106 -30
- 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 +54 -24
- package/dist/runs.d.ts +15 -8
- package/dist/runs.js +35 -1
- 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/security.d.ts +87 -9
- package/dist/security.js +52 -9
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- 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 +27 -6
- package/dist/spec-fields.d.ts +28 -16
- package/dist/spec-fields.js +66 -54
- package/dist/sql-engine-posture.d.ts +31 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-tool-axes-m19.d.ts +19 -4
- package/dist/stored-request-tool-axes-m19.js +30 -2
- package/dist/task-a2a.d.ts +9 -1
- package/dist/task-a2a.js +73 -47
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +46 -58
- package/dist/task-mcp.js +82 -107
- package/dist/task-settings.d.ts +95 -108
- package/dist/task-settings.js +77 -98
- package/dist/text-bidi.d.ts +1 -48
- package/dist/text-bidi.js +3 -5
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +304 -88
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +122 -20
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/ledger-sink.js +4 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +98 -17
- package/dist/trace/project.js +98 -50
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +54 -0
- package/dist/trace/redact.js +778 -152
- package/dist/trace/self-minted-wire.d.ts +345 -1
- package/dist/trace/self-minted-wire.js +117 -1
- package/dist/trace/wire-projection-faces.d.ts +377 -3
- package/dist/trace/wire-projection-faces.js +164 -1
- 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/candidate-gate.d.ts +6 -6
- package/dist/web-admin-client/candidate-gate.js +3 -3
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/read-warnings.d.ts +13 -0
- package/dist/web-admin-client/read-warnings.js +10 -0
- package/dist/web-admin-client/skills-mcp.d.ts +3 -0
- package/dist/web-admin-client/skills-mcp.js +11 -9
- package/dist/web-admin-client/types.d.ts +2 -3
- package/dist/workspace-cache.d.ts +35 -0
- package/dist/workspace-cache.js +36 -0
- package/dist/workspace-space.d.ts +3 -2
- package/dist/workspace-space.js +2 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +65 -10
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -1
- package/scripts/drain-check.mysql.sql +30 -2
- package/scripts/drain-check.pg.sql +29 -2
- package/dist/capabilities/memory-notice.d.ts +0 -138
- package/dist/capabilities/memory-notice.js +0 -64
- package/dist/capabilities/prompt.d.ts +0 -17
- package/dist/capabilities/prompt.js +0 -6
- package/dist/mcp-content-origin.d.ts +0 -34
- package/dist/mcp-content-origin.js +0 -10
- package/dist/tool-axis-words.d.ts +0 -27
- package/dist/tool-axis-words.js +0 -9
- package/dist/wire-name-bound.d.ts +0 -14
- package/dist/wire-name-bound.js +0 -13
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 执行环境的家目录:**声明 × 实测**的唯一判官与唯一的座(纯叶:零值依赖)。
|
|
3
|
+
*
|
|
4
|
+
* ## 病(一)—— 声明了却对不上
|
|
5
|
+
* `REMOTE_EXEC_HOME_DIR` 是运维对「执行环境以哪个用户的家目录运行」的声明,它是 `~/` 形权限规则的基、引擎家锚拒读行(`~/.ssh` / `~/.npmrc` …)
|
|
6
|
+
* 的落点(`execution-lane-caps.ts` `executionLaneHomeDir` 一只属主,几个消费面同读)。k8s / local-docker / ssh 三条车道的家目录是镜像 / 目标机
|
|
7
|
+
* 登录用户的属性,boot 期不可知 —— 声明了就照单全收。声明 `/home/y` 而车道真实家目录是 `/home/x` 时,`Edit(~/.ssh/**)` 守的是 `/home/y`,
|
|
8
|
+
* `/home/x/.ssh` 照读照写,运维与用户零告警:限制写了不生效且无人知。
|
|
9
|
+
*
|
|
10
|
+
* ## 病(二)—— 没声明就恒问人
|
|
11
|
+
* 执行环境不声明家目录时,引擎的家锚拒读行放不下 ⇒ 每一次泄内容的递归读(`grep -r` / `rg` / `git grep` / `tar c`)在全 shell 面恒问人、只读面直接拒。
|
|
12
|
+
* 家目录是执行环境自己的事实,车道开环境那一拍问一次就知道 —— 不必要运维手填。
|
|
13
|
+
*
|
|
14
|
+
* ## 律(一只座、两个来源、一条取值律 —— {@link LaneHomeSeat},四条会问的车道各持一只,不各写一份)
|
|
15
|
+
* · **声明在场 ⇒ 声明**(座 = 声明原样)。车道对证与否是车道的姿势(`verifiesDeclared`):对证的车道在开环境那一拍问一次(与命令同一条 shell、同一份 env:
|
|
16
|
+
* `printf %s "$HOME"`),两者不一致 ⇒ 这只执行环境不开(拒句点名两值与两条改法),环境答了的判定记在环境上(同一镜像 / 同一目标机再问也是同一个答案,不重试成风暴);
|
|
17
|
+
* 问不出答案同样不开(证不了声明 = 不拿一个没证过的目录去守),但不记 —— 与任何一次建连失败同,下一次重问;不对证的车道(adb:Android 没有 POSIX 登录家目录,声明是运维的断言)声明照单全收。
|
|
18
|
+
* · **没声明 ⇒ 实测**:同一拍问同一句;答出绝对路径 ⇒ 座 = 它,之后不再问;
|
|
19
|
+
* · **实测也缺席**(问不出 / 答的不是绝对路径,含空串)⇒ 座缺席(引擎失败关闭,不猜、不补 `/`),环境照开(没声明就没有声明可拒),一行 warn(点名读到了什么与出路)。
|
|
20
|
+
* 规则基与 422 门在下单那一刻就要家目录,而那一刻执行环境还没开 —— 它们仍只读声明(`executionLaneHomeDir`);实测值只填引擎手里的这一只座。
|
|
21
|
+
*/
|
|
22
|
+
/** 探针答案的行首标记:登录脚本 / profile 往 stdout 打的横幅不会被读成家目录 —— 只认带这个标记的那一行(取最后一行)。 */
|
|
23
|
+
export declare const LANE_HOME_PROBE_MARKER = "sema-lane-home=";
|
|
24
|
+
/**
|
|
25
|
+
* 执行环境里问家目录的那一句 —— 经车道自己的命令通道跑(同一条 shell、同一份 env),答的就是命令看到的 `$HOME`。
|
|
26
|
+
* 先换一行再打标记行:横幅没以换行收尾时,标记行照样从行首开始。
|
|
27
|
+
*/
|
|
28
|
+
export declare const LANE_HOME_PROBE_COMMAND = "printf '\\nsema-lane-home=%s\\n' \"$HOME\"";
|
|
29
|
+
/** 一次问家目录的读数:问到了(stdout 原文)/ 没问到(原因)。 */
|
|
30
|
+
export type LaneHomeProbe = {
|
|
31
|
+
readonly ok: true;
|
|
32
|
+
readonly stdout: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly ok: false;
|
|
35
|
+
readonly reason: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 判定:`undefined` = 一致,照开;否则这只环境不开 —— `refusal` 是拒句,`answered` = 环境**答了**它的家目录(不一致 / 不是绝对路径;同一镜像 / 同一登录用户
|
|
39
|
+
* 再问也是同一个答案 ⇒ 调用方记在环境上),`false` = 没答上(探针失败 / 超时 / 非零退出 / 输出里没有标记行 ⇒ 这一次不开、不记、下一次重问)。
|
|
40
|
+
*/
|
|
41
|
+
export type LaneHomeVerdict = {
|
|
42
|
+
readonly refusal: string;
|
|
43
|
+
readonly answered: boolean;
|
|
44
|
+
} | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 声明 × 实测的判官。`lane` 只进句子。拒句三形:实测与声明不一致 / 实测不是绝对路径(含空)/ 没问到。每一形都点名声明值与改法,不回显任何别的东西。
|
|
47
|
+
*/
|
|
48
|
+
export declare function judgeLaneHome(lane: string, declared: string, probe: LaneHomeProbe): LaneHomeVerdict;
|
|
49
|
+
/** 起服与每只环境「家目录答不出」那一行 warn 的事件名 —— 一只 code,起服(车道读不了)与环境(实测缺席)共用。 */
|
|
50
|
+
export declare const LANE_HOME_UNDECLARED_EVENT = "execution_lane_home_undeclared";
|
|
51
|
+
/**
|
|
52
|
+
* 「这条车道的执行环境没有家目录」的一句(纯字符串 ⇒ `build*`):`cause` 说为什么(没声明 + 车道读不了 / 读了没读到),`remedy` 说出路。
|
|
53
|
+
* 起服那一行(车道没有读数办法)与每只环境那一行(实测缺席)都走它 —— 代价那一半只有一份文字。
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildHomeAbsentNote(lane: string, cause: string, remedy: string): string;
|
|
56
|
+
/** 车道读不了家目录时的出路(起服那一行):声明它。 */
|
|
57
|
+
export declare const DECLARE_HOME_REMEDY = "Declare the home: REMOTE_EXEC_HOME_DIR=<the absolute path the environment's $HOME reads>";
|
|
58
|
+
/** 一行「这只环境没有家目录」的事实:交给运维的那一行 warn 的两个字段。 */
|
|
59
|
+
export interface LaneHomeAbsence {
|
|
60
|
+
readonly provider: string;
|
|
61
|
+
readonly note: string;
|
|
62
|
+
}
|
|
63
|
+
/** 这条车道的座怎么长出来:`declared` = 运维声明(`REMOTE_EXEC_HOME_DIR`,boot 期的唯一属主 `executionLaneHomeDir` 的答案);`verifiesDeclared` = 车道对声明对证。 */
|
|
64
|
+
export interface LaneHomeSeatOptions {
|
|
65
|
+
readonly lane: string;
|
|
66
|
+
readonly declared: string | undefined;
|
|
67
|
+
readonly verifiesDeclared: boolean;
|
|
68
|
+
/** 实测缺席时交出那一行 warn(缺席 = 不交;生产装配由 boot 递一只带去重的报告座,见 {@link createLaneHomeAbsenceReporter})。 */
|
|
69
|
+
readonly onAbsent?: ((absence: LaneHomeAbsence) => void) | undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 四条会问家目录的车道(k8s / local-docker / ssh / adb)的适配器配置里与家目录有关的两个键 —— 文字只写这一处,四个配置接口 `extends` 它。
|
|
73
|
+
*/
|
|
74
|
+
export interface LaneHomeConfig {
|
|
75
|
+
/**
|
|
76
|
+
* S-213④ / core [ref] —— 运维声明的执行环境 **home 目录**(绝对路径,本环境自己的命名空间里;`REMOTE_EXEC_HOME_DIR`)。`~/…` 形权限规则(`Edit(~/.ssh/**)`)对**跑在本 env 里的调用**
|
|
77
|
+
* 就以它为基。值由 `boot/execution-env.ts` 从**唯一属主** `execution-lane-caps.ts` 的 `executionLaneHomeDir` 递进来;adapter 不自算(两处各算一份 = 422 门与引擎对同一条规则给相反答案)。
|
|
78
|
+
* 缺席 ⇒ 不声明:车道建环境时自己问执行环境的 `$HOME`({@link LaneHomeSeat});实测也缺席 ⇒ 本 env 的 `homeDir` 座缺席,core 对 `~/` 规则判 `unreadable`
|
|
79
|
+
* (fail-closed 的 ask),绝不回落引擎进程自己的 home(那在远端腿上是另一个用户的另一个目录 —— 静默守错目录正是 [ref] 的病)。
|
|
80
|
+
*/
|
|
81
|
+
homeDir?: string;
|
|
82
|
+
/** 实测缺席(没声明、也没问到绝对路径)时交出那一行 warn;缺席 = 不交。生产装配由 boot 递一只带去重的报告座({@link createLaneHomeAbsenceReporter})。 */
|
|
83
|
+
onHomeAbsent?: (absence: LaneHomeAbsence) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 一只执行环境的家目录座 —— `ExecutionEnv.homeDir` 的**唯一取值律**:声明在场 ⇒ 声明;否则 ⇒ 车道开环境时实测到的绝对路径;实测也缺席 ⇒ `undefined`(引擎失败关闭)。
|
|
87
|
+
* 车道只做两件事:`asks` 为真时经自己的命令通道跑一次 {@link LANE_HOME_PROBE_COMMAND},把读数交给 {@link settle};`homeDir` 读 {@link home}。
|
|
88
|
+
*/
|
|
89
|
+
export declare class LaneHomeSeat {
|
|
90
|
+
private measured;
|
|
91
|
+
private readonly lane;
|
|
92
|
+
private readonly declared;
|
|
93
|
+
private readonly verifiesDeclared;
|
|
94
|
+
private readonly onAbsent;
|
|
95
|
+
constructor(options: LaneHomeSeatOptions);
|
|
96
|
+
/** 座:声明胜,否则实测,否则缺席。 */
|
|
97
|
+
get home(): string | undefined;
|
|
98
|
+
/** 这一拍还要不要问:声明在场 ⇒ 只有对证的车道问(每次连接);没声明 ⇒ 问到量出绝对路径为止。 */
|
|
99
|
+
get asks(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* 收一次读数。声明在场(且车道对证)⇒ {@link judgeLaneHome}:`undefined` = 一致,否则这只环境不开(拒句 + 记不记见 {@link LaneHomeVerdict});
|
|
102
|
+
* 没声明 ⇒ 读到绝对路径就记下;读不到 / 不是绝对路径 ⇒ 座缺席、交一行 warn、**不拒环境**(`undefined`)—— 没声明就没有声明可拒,引擎对缺席座失败关闭。
|
|
103
|
+
* 不对证的车道声明在场时不该来问(`asks` 为假),来了照单全收。
|
|
104
|
+
*/
|
|
105
|
+
settle(probe: LaneHomeProbe): LaneHomeVerdict;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 每个部署一只的「家目录实测缺席」报告座(闭包 ⇒ `create*`):同一(车道, 句子)只响一行 `execution_lane_home_undeclared`(同一镜像每个 run 的环境都读到同一个缺席,
|
|
109
|
+
* 每只环境各响一行 = 刷屏),不同的句子各响一次。`warn` 是服务日志的 warn。
|
|
110
|
+
*/
|
|
111
|
+
export declare function createLaneHomeAbsenceReporter(warn: (event: string, fields: Record<string, unknown>) => void): (absence: LaneHomeAbsence) => void;
|
|
112
|
+
//# sourceMappingURL=lane-home-probe.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export const LANE_HOME_PROBE_MARKER = "sema-lane-home=";
|
|
2
|
+
export const LANE_HOME_PROBE_COMMAND = `printf '\\n${LANE_HOME_PROBE_MARKER}%s\\n' "$HOME"`;
|
|
3
|
+
const SHOWN_MAX = 256;
|
|
4
|
+
const shown = (raw) => JSON.stringify(raw.length > SHOWN_MAX ? `${raw.slice(0, SHOWN_MAX)}…` : raw);
|
|
5
|
+
const comparable = (p) => (p.length > 1 ? p.replace(/\/+$/, "") : p);
|
|
6
|
+
function markedHome(stdout) {
|
|
7
|
+
const lines = stdout.split("\n").map((l) => l.replace(/\r$/, ""));
|
|
8
|
+
const marked = lines.flatMap((l, i) => (l.startsWith(LANE_HOME_PROBE_MARKER) ? [i] : []));
|
|
9
|
+
if (marked.length === 0)
|
|
10
|
+
return { why: "the probe printed no home line" };
|
|
11
|
+
const at = marked[0];
|
|
12
|
+
if (marked.length > 1 || lines.slice(at + 1).some((l) => l !== ""))
|
|
13
|
+
return { why: "the probe output holds more than one home line or text after it, so it cannot be read as one path" };
|
|
14
|
+
return { home: lines[at].slice(LANE_HOME_PROBE_MARKER.length) };
|
|
15
|
+
}
|
|
16
|
+
function readLaneHome(probe) {
|
|
17
|
+
if (!probe.ok)
|
|
18
|
+
return { kind: "unread", reason: probe.reason };
|
|
19
|
+
const marked = markedHome(probe.stdout);
|
|
20
|
+
if ("why" in marked)
|
|
21
|
+
return { kind: "unread", reason: marked.why };
|
|
22
|
+
return marked.home.startsWith("/") ? { kind: "home", home: marked.home } : { kind: "not_absolute", value: marked.home };
|
|
23
|
+
}
|
|
24
|
+
export function judgeLaneHome(lane, declared, probe) {
|
|
25
|
+
const head = `REMOTE_EXEC_HOME_DIR=${shown(declared)} is the home "~/" permission rules and the engine's home-anchored read-deny rows are placed under on the ${lane} execution lane`;
|
|
26
|
+
const reading = readLaneHome(probe);
|
|
27
|
+
if (reading.kind === "unread") {
|
|
28
|
+
return {
|
|
29
|
+
refusal: `${head}, but the home of this execution environment could not be read (${reading.reason}) — the declaration cannot be confirmed, so this environment is not started. Fix the lane, or unset REMOTE_EXEC_HOME_DIR (home-relative rules are then refused at submission instead).`,
|
|
30
|
+
answered: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (reading.kind === "not_absolute") {
|
|
34
|
+
return {
|
|
35
|
+
refusal: `${head}, but this execution environment reports HOME=${shown(reading.value)}, not an absolute path — the declaration cannot be confirmed, so this environment is not started. Give the environment's user a home (HOME), or unset REMOTE_EXEC_HOME_DIR.`,
|
|
36
|
+
answered: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (comparable(reading.home) === comparable(declared))
|
|
40
|
+
return undefined;
|
|
41
|
+
return {
|
|
42
|
+
refusal: `${head}, but its commands run with HOME=${shown(reading.home)} — rules would guard ${shown(declared)} while ${shown(reading.home)} stays readable and writable, ` +
|
|
43
|
+
`so this environment is not started. Set REMOTE_EXEC_HOME_DIR to ${shown(reading.home)}, or run the environment as the user whose home is ${shown(declared)}.`,
|
|
44
|
+
answered: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export const LANE_HOME_UNDECLARED_EVENT = "execution_lane_home_undeclared";
|
|
48
|
+
const HOME_ABSENT_COST = "the engine cannot place its home-anchored read-deny rows, so every contents-disclosing recursive read (grep -r, rg, git grep, tar c, …) asks a person on the full shell — " +
|
|
49
|
+
"no allow rule, mode or bypass releases that question — and is refused on the read-only face, so unattended tasks cannot search code; \"~/\" permission rules are refused at submission.";
|
|
50
|
+
export function buildHomeAbsentNote(lane, cause, remedy) {
|
|
51
|
+
return `the ${lane} lane declares no home for its execution environment (${cause}): ${HOME_ABSENT_COST} ${remedy}`;
|
|
52
|
+
}
|
|
53
|
+
const DECLARE_ARG = "REMOTE_EXEC_HOME_DIR=<the absolute path the environment's $HOME reads>";
|
|
54
|
+
export const DECLARE_HOME_REMEDY = `Declare the home: ${DECLARE_ARG}`;
|
|
55
|
+
export class LaneHomeSeat {
|
|
56
|
+
measured;
|
|
57
|
+
lane;
|
|
58
|
+
declared;
|
|
59
|
+
verifiesDeclared;
|
|
60
|
+
onAbsent;
|
|
61
|
+
constructor(options) {
|
|
62
|
+
this.lane = options.lane;
|
|
63
|
+
this.declared = options.declared;
|
|
64
|
+
this.verifiesDeclared = options.verifiesDeclared;
|
|
65
|
+
this.onAbsent = options.onAbsent;
|
|
66
|
+
}
|
|
67
|
+
get home() {
|
|
68
|
+
return this.declared ?? this.measured;
|
|
69
|
+
}
|
|
70
|
+
get asks() {
|
|
71
|
+
return this.declared === undefined ? this.measured === undefined : this.verifiesDeclared;
|
|
72
|
+
}
|
|
73
|
+
settle(probe) {
|
|
74
|
+
if (this.declared !== undefined)
|
|
75
|
+
return this.verifiesDeclared ? judgeLaneHome(this.lane, this.declared, probe) : undefined;
|
|
76
|
+
const reading = readLaneHome(probe);
|
|
77
|
+
if (reading.kind === "home") {
|
|
78
|
+
this.measured = reading.home;
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const because = reading.kind === "unread" ? `could not be read (${reading.reason})` : `reads ${shown(reading.value)}, not an absolute path`;
|
|
82
|
+
const remedy = this.verifiesDeclared
|
|
83
|
+
? "Give the environment's user an absolute HOME (a declared REMOTE_EXEC_HOME_DIR is checked against it, so declaring cannot stand in for it)."
|
|
84
|
+
: `Give the environment's user an absolute HOME, or declare it: ${DECLARE_ARG}.`;
|
|
85
|
+
this.onAbsent?.({ provider: this.lane, note: buildHomeAbsentNote(this.lane, `REMOTE_EXEC_HOME_DIR is unset and the environment's own $HOME ${because}`, remedy) });
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const ABSENCE_SEEN_MAX = 64;
|
|
90
|
+
export function createLaneHomeAbsenceReporter(warn) {
|
|
91
|
+
const seen = new Set();
|
|
92
|
+
return (absence) => {
|
|
93
|
+
const key = `${absence.provider}\u0000${absence.note}`;
|
|
94
|
+
if (seen.has(key))
|
|
95
|
+
return;
|
|
96
|
+
if (seen.size < ABSENCE_SEEN_MAX)
|
|
97
|
+
seen.add(key);
|
|
98
|
+
warn(LANE_HOME_UNDECLARED_EVENT, { provider: absence.provider, note: absence.note });
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=lane-home-probe.js.map
|
|
@@ -59,7 +59,7 @@ export interface LeaderEndpoint {
|
|
|
59
59
|
* With a store in place this Map holds only the runs THIS replica is driving. Exposed for tests. */
|
|
60
60
|
runs: Map<string, LeaderRun>;
|
|
61
61
|
}
|
|
62
|
-
export declare function createLeaderEndpoint(runLeader: (body: LeaderRequestBody) => Promise<LeaderResult>, opts
|
|
62
|
+
export declare function createLeaderEndpoint(runLeader: (body: LeaderRequestBody) => Promise<LeaderResult>, opts: {
|
|
63
63
|
logger?: {
|
|
64
64
|
info?: (m: string, x?: Record<string, unknown>) => void;
|
|
65
65
|
error?: (m: string, x?: Record<string, unknown>) => void;
|
|
@@ -73,5 +73,8 @@ export declare function createLeaderEndpoint(runLeader: (body: LeaderRequestBody
|
|
|
73
73
|
requiredFields?: readonly string[];
|
|
74
74
|
/** [ref] 车4 件1:durable 登记表。缺席 ⇒ 显式的单副本内存降级臂(见文件头注)。 */
|
|
75
75
|
store?: LeaderRunStore;
|
|
76
|
+
/** S-487 RH-3:「这个调用方读得到这一行 leader run 吗」—— 属主存取器的判官形(`http/owner-access.ts` 的 `createLeaderRunVisibility`,boot 装一次)。
|
|
77
|
+
* 必填:本模块不自判属主(修前手抄 `owner == null || owner === requester`,缺 [ref] C8 窄互认臂而注称 mirrors runOwnerOk),读面与幂等重放同读它。 */
|
|
78
|
+
ownerVisible: (principal: string | null | undefined, owner: string | null | undefined) => boolean;
|
|
76
79
|
}): LeaderEndpoint;
|
|
77
80
|
//# sourceMappingURL=endpoint.d.ts.map
|
package/dist/leader/endpoint.js
CHANGED
|
@@ -3,6 +3,7 @@ import { redactErrorMessage, redactHead, redactLeaderResult, redactLeaderResultW
|
|
|
3
3
|
import { withPrincipal } from "../observability/principal-context.js";
|
|
4
4
|
import {} from "../plugins/leader-run-store-sql.js";
|
|
5
5
|
import { idemKeyOf } from "../http/idempotency.js";
|
|
6
|
+
import { refusalBody } from "../http/refusal-body.js";
|
|
6
7
|
function statusForLeaderResult(result) {
|
|
7
8
|
if (result.conflict)
|
|
8
9
|
return "needs_human";
|
|
@@ -28,7 +29,7 @@ function idemShapeError(raw) {
|
|
|
28
29
|
}
|
|
29
30
|
return undefined;
|
|
30
31
|
}
|
|
31
|
-
export function createLeaderEndpoint(runLeader, opts
|
|
32
|
+
export function createLeaderEndpoint(runLeader, opts) {
|
|
32
33
|
const runs = new Map();
|
|
33
34
|
const memIdem = new Map();
|
|
34
35
|
function reap() {
|
|
@@ -126,19 +127,19 @@ export function createLeaderEndpoint(runLeader, opts = {}) {
|
|
|
126
127
|
function getBody(run) {
|
|
127
128
|
return { status: 200, body: { id: run.id, status: run.status, ...redactedView(run) } };
|
|
128
129
|
}
|
|
129
|
-
const NOT_FOUND = { status: 404, body: {
|
|
130
|
+
const NOT_FOUND = { status: 404, body: refusalBody({ errorCode: "not_found.leader_run", message: "leader run not found" }) };
|
|
130
131
|
async function handle(method, url, body, caller, idempotencyKey) {
|
|
131
132
|
const requester = caller?.principal ?? null;
|
|
132
133
|
const idemCaller = caller ?? { principal: null, source: null };
|
|
133
134
|
if (method === "POST" && url === "/v1/leader") {
|
|
134
135
|
const b = body;
|
|
135
136
|
if (!b || typeof b.objective !== "string" || b.objective.trim() === "") {
|
|
136
|
-
return { status: 400, body: {
|
|
137
|
+
return { status: 400, body: refusalBody({ errorCode: "request.body_shape", message: "missing 'objective' string" }) };
|
|
137
138
|
}
|
|
138
139
|
if (opts.requiredFields) {
|
|
139
140
|
const missing = opts.requiredFields.filter((f) => typeof b[f] !== "string" || b[f].trim() === "");
|
|
140
141
|
if (missing.length > 0) {
|
|
141
|
-
return { status: 400, body: {
|
|
142
|
+
return { status: 400, body: refusalBody({ errorCode: "request.body_shape", message: `missing required field(s): ${missing.join(", ")}` }) };
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
const owner = requester;
|
|
@@ -146,15 +147,15 @@ export function createLeaderEndpoint(runLeader, opts = {}) {
|
|
|
146
147
|
if (idempotencyKey != null) {
|
|
147
148
|
const bad = idemShapeError(idempotencyKey);
|
|
148
149
|
if (bad)
|
|
149
|
-
return { status: 400, body: {
|
|
150
|
+
return { status: 400, body: refusalBody({ errorCode: "request.body_shape", message: bad }) };
|
|
150
151
|
scopedIdem = idemKeyOf(idempotencyKey, idemCaller, "leader");
|
|
151
152
|
}
|
|
152
153
|
reap();
|
|
153
154
|
if (opts.store) {
|
|
154
155
|
const { created, run } = await opts.store.createRun({ objective: b.objective, owner, idemKey: scopedIdem });
|
|
155
156
|
if (!created) {
|
|
156
|
-
if (
|
|
157
|
-
return { status: 409, body: {
|
|
157
|
+
if (!opts.ownerVisible(requester, run.owner)) {
|
|
158
|
+
return { status: 409, body: refusalBody({ errorCode: "conflict.leader_run_exists", message: "idempotency key already used by another principal" }) };
|
|
158
159
|
}
|
|
159
160
|
return { status: 202, body: { leaderRunId: run.id, status: run.status } };
|
|
160
161
|
}
|
|
@@ -175,13 +176,13 @@ export function createLeaderEndpoint(runLeader, opts = {}) {
|
|
|
175
176
|
drive(id, b, owner);
|
|
176
177
|
return { status: 202, body: { leaderRunId: id, status: "running" } };
|
|
177
178
|
}
|
|
178
|
-
const ownerOk = (owner) =>
|
|
179
|
+
const ownerOk = (owner) => opts.ownerVisible(requester, owner);
|
|
179
180
|
if (method === "GET" && url === "/v1/leader") {
|
|
180
181
|
if (idempotencyKey == null)
|
|
181
|
-
return { status: 400, body: {
|
|
182
|
+
return { status: 400, body: refusalBody({ errorCode: "request.query_invalid", message: "idempotencyKey is required: pass the raw Idempotency-Key the submission was sent with" }) };
|
|
182
183
|
const bad = idemShapeError(idempotencyKey);
|
|
183
184
|
if (bad)
|
|
184
|
-
return { status: 400, body: {
|
|
185
|
+
return { status: 400, body: refusalBody({ errorCode: "request.query_invalid", message: bad }) };
|
|
185
186
|
const key = idemKeyOf(idempotencyKey, idemCaller, "leader");
|
|
186
187
|
if (opts.store) {
|
|
187
188
|
const run = await opts.store.getByIdem(key);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **帽的拒**(一张表条数太多 / 一段文字太长)在本仓受理口的一只写法:句子的头一句 + 机读位,一处铸。
|
|
3
|
+
*
|
|
4
|
+
* 律:请求体上任何一处撞了帽,拒体带同一组机读位 ——
|
|
5
|
+
* · `field` = 撞帽的那一处在请求体里的坐标(`skills[1].allowedTools`、`agents[0].denyTools[3]`、`settings.permissions.allow`);
|
|
6
|
+
* · `reason` = 帽的量纲,闭集三词:`over_cap`(条数:数组的条目数)/ `too_long`(字符数:一段文字的长度)/ `too_large`(字节数:一份载荷的体积);
|
|
7
|
+
* · `count` = 送来的量(条数、字符数或字节数,量纲由 `reason` 定);
|
|
8
|
+
* · `cap` = 帽。
|
|
9
|
+
* 句子的头一句同一句:`<field> has <count> entries|characters|bytes — at most <cap> are accepted`;之后各面可以接自己的出路句(为什么拒而不截、怎么改)。
|
|
10
|
+
* 唯一的缺量形:读体读到帽就停 / 库只说「一行装不下」时量不出送来多少 ⇒ {@link limitFactsUnmeasured}(`count` 缺席,`cap` 只在帽已知时在;不编数)。
|
|
11
|
+
* 已有句子的面(上限早于本模块定下来的受理口各处)句子逐字不变、只加机读位 —— 用 {@link limitFacts} 铸,不改写句子。
|
|
12
|
+
* 帽本身(数字)归各面的属主;本模块只管「撞了帽怎么说、怎么机读」。
|
|
13
|
+
*
|
|
14
|
+
* 量纲 → `reason` 是一张闭表({@link LIMIT_REASONS}):加一种量纲 ⇒ 这里加一行,`reason` 的词随之进闭集,读者穷举读。
|
|
15
|
+
*/
|
|
16
|
+
/** 量纲 → 机读 `reason` 词(闭集)。 */
|
|
17
|
+
export declare const LIMIT_REASONS: {
|
|
18
|
+
readonly entries: "over_cap";
|
|
19
|
+
readonly characters: "too_long";
|
|
20
|
+
readonly bytes: "too_large";
|
|
21
|
+
};
|
|
22
|
+
/** 帽的量纲:条数 / 字符数 / 字节数(句子里就是这个词)。 */
|
|
23
|
+
export type LimitMeasure = keyof typeof LIMIT_REASONS;
|
|
24
|
+
/** 机读 `reason`:`over_cap`(条数)/ `too_long`(字符数)/ `too_large`(字节数)。 */
|
|
25
|
+
export type LimitReason = (typeof LIMIT_REASONS)[LimitMeasure];
|
|
26
|
+
/** 一处撞帽的机读位(原样进拒体:`refusalBody` 的 facts / `HttpError.extra`;型别名而不是接口 —— 要能直接当 `Record<string, unknown>` 用)。 */
|
|
27
|
+
export type LimitFacts = {
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly reason: LimitReason;
|
|
30
|
+
readonly count: number;
|
|
31
|
+
readonly cap: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 撞了帽、却**量不出**送来多少的机读位:读体读到帽就停(体没读完 —— 不为量一个数把 8 MiB 之外的字节再读进内存),或库只说「一行装不下」、不说多大。
|
|
35
|
+
* 同一组键的缺量形:`field` / `reason`(量纲定)恒在,`cap` 只在帽已知时在,`count` 恒缺席 —— 缺席就是「量不出」,不编数。
|
|
36
|
+
*/
|
|
37
|
+
export type UnmeasuredLimitFacts = Pick<LimitFacts, "field" | "reason"> & {
|
|
38
|
+
readonly cap?: number;
|
|
39
|
+
};
|
|
40
|
+
/** 一处撞帽的拒:句子 + 机读位。 */
|
|
41
|
+
export interface LimitRefusal {
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly facts: LimitFacts;
|
|
44
|
+
}
|
|
45
|
+
/** 撞帽的头一句(全仓同一句;`field` 是句子里点名的那一处)。 */
|
|
46
|
+
export declare function describeLimit(field: string, measure: LimitMeasure, count: number, cap: number): string;
|
|
47
|
+
/** 机读位:`reason` 由量纲定。 */
|
|
48
|
+
export declare function limitFacts(field: string, measure: LimitMeasure, count: number, cap: number): LimitFacts;
|
|
49
|
+
/** 缺量形的机读位({@link UnmeasuredLimitFacts}):`reason` 仍由量纲定;`cap` 只在帽已知时给。 */
|
|
50
|
+
export declare function limitFactsUnmeasured(field: string, measure: LimitMeasure, cap?: number): UnmeasuredLimitFacts;
|
|
51
|
+
/**
|
|
52
|
+
* 一处撞帽的拒:句子 = {@link describeLimit}(+ `tail`:该面的出路句,接在头一句之后),机读位 = {@link limitFacts}(`field` 同一个坐标)。
|
|
53
|
+
* `sentenceField` 只在该面的句子沿用另一种点名写法时给(子代定义的句子写作 `agents[0]: agent.name`,机读位仍是体内坐标 `agents[0].name`)。
|
|
54
|
+
*/
|
|
55
|
+
export declare function limitRefusal(field: string, measure: LimitMeasure, count: number, cap: number, opts?: {
|
|
56
|
+
readonly tail?: string;
|
|
57
|
+
readonly sentenceField?: string;
|
|
58
|
+
}): LimitRefusal;
|
|
59
|
+
//# sourceMappingURL=limit-refusal.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const LIMIT_REASONS = { entries: "over_cap", characters: "too_long", bytes: "too_large" };
|
|
2
|
+
export function describeLimit(field, measure, count, cap) {
|
|
3
|
+
return `${field} has ${count} ${measure} — at most ${cap} are accepted`;
|
|
4
|
+
}
|
|
5
|
+
export function limitFacts(field, measure, count, cap) {
|
|
6
|
+
return { field, reason: LIMIT_REASONS[measure], count, cap };
|
|
7
|
+
}
|
|
8
|
+
export function limitFactsUnmeasured(field, measure, cap) {
|
|
9
|
+
return cap === undefined ? { field, reason: LIMIT_REASONS[measure] } : { field, reason: LIMIT_REASONS[measure], cap };
|
|
10
|
+
}
|
|
11
|
+
export function limitRefusal(field, measure, count, cap, opts = {}) {
|
|
12
|
+
const head = describeLimit(opts.sentenceField ?? field, measure, count, cap);
|
|
13
|
+
return { message: opts.tail === undefined ? head : `${head}. ${opts.tail}`, facts: limitFacts(field, measure, count, cap) };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=limit-refusal.js.map
|
package/dist/main.js
CHANGED
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
const s02 = await runStage02(s01);
|
|
16
16
|
const s03 = await runStage03(s02);
|
|
17
17
|
const s04 = await runStage04(s03);
|
|
18
|
-
const s05 = runStage05(s04);
|
|
18
|
+
const s05 = await runStage05(s04);
|
|
19
19
|
await settleHostLaneShell(s05.config, s05.logger);
|
|
20
20
|
const s06 = runStage06(s05);
|
|
21
21
|
const s07 = await runStage07(s06);
|
|
@@ -15,16 +15,19 @@
|
|
|
15
15
|
* · **fresh 提交腿**:判出问题 ⇒ 同步 400(同设 `request.body_shape`;值不是字符串 `request.field_invalid`)。
|
|
16
16
|
* · **其余腿(耐久 resume 重放存量 body)**:**不拒、不丢 server** —— 存量 body 里这个键当时是被静默忽略的,server 当时是挂着的;
|
|
17
17
|
* 此刻把 server 摘掉,一条 park 在该 server 工具审批上的任务批准后会撞 `resume.tool_unavailable` 并重开检查点,而每次重试重放同一份 body ⇒ 永远卡住。
|
|
18
|
-
* 所以读器
|
|
18
|
+
* 所以读器(契约包的 `readMcpIdentityHeaders`,`normalizeServer` 的 http 传输读两个身份头用它)的处置是**降级到升级前的读法**:`principalHeader` 胜(照挂,与升级前逐字相同),`assertionHeader` 不生效;
|
|
19
19
|
* 不静默 —— 真挂上的这类条目由 {@link noteMcpAssertionHeaderIgnored} 说一行 warn(部署声明面没有这一格:配置不是被重放的存量任务,契约包解析期那一刀直接丢这一条)。
|
|
20
20
|
*
|
|
21
|
-
* ## 发送归引擎座(本版只承载,不发送)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
* ## 发送归引擎座(本版只承载,不发送)—— 「发不发」只有一只开关
|
|
22
|
+
core 的 http 传输只有 `url` / `headers` / `principalHeader`,**没有**断言头座。所以本键承载到「铸 core 规格」为止:
|
|
23
|
+
请求面在 {@link toCoreMcpServerSpec} 剥掉它,settings 面的 `resolveMcpServers` 不投它;两处都用同一只
|
|
24
|
+
{@link noteMcpAssertionHeaderNotSent} 说出一行 info(声明在、发送未接)—— 披露,不是兜底:server 照常挂载、不带断言头,
|
|
25
|
+
要求断言的托管连接器会拒这些调用,运维据这一行知道原因在哪。
|
|
26
|
+
「这台 server 发不发」是**一个事实**,只有一只开关 {@link MCP_ASSERTION_HEADER_SENT} 说它;读它的地方共五处,全经 {@link withholdsMcpAssertionHeader} 这一只谓词
|
|
27
|
+
(能力位 `GET /v1/capabilities` 的 `mcpAssertionHeaderSent` 直读开关本人):请求面剥键、settings 面不投、一行 info、探测口整条拒、能力位。所以「位为真」与「还在说发送未接」
|
|
28
|
+
结构上不可能同时成立,消费方按位分支、位真时不再看到任何披露句;发送座到货的那天翻的就是这一行(与下面的退役门同批)。
|
|
29
|
+
|
|
30
|
+
## 退役(编译期自动逼,零人工记忆)
|
|
28
31
|
* 引擎的 http 传输一旦长出同名座,{@link _CoreHasNoAssertionSeat} 当场编译红:届时删本文件里的 {@link RequestMcpServerSpec}
|
|
29
32
|
* 扩展与 {@link toCoreMcpServerSpec} 的剥键、两处 info,把键直接投进引擎规格(发送由引擎座兑现)。
|
|
30
33
|
*/
|
|
@@ -56,21 +59,31 @@ export type McpIdentityHeadersIssue = "both_set" | "not_a_string";
|
|
|
56
59
|
* 两类同时成立时报 `both_set`(先名字后值)。stdio 传输不判(两键在 stdio 形上本就不存在,契约包同判)。
|
|
57
60
|
*/
|
|
58
61
|
export declare function mcpIdentityHeadersIssue(transport: Record<string, unknown>): McpIdentityHeadersIssue | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* 读器的这一格(`normalizeServer` 的 http 传输读两个身份头):字符串才收;**`principalHeader` 胜**——它在场(不论值形)时 `assertionHeader` 不收。
|
|
61
|
-
* 于是 normalize 后的形**结构上不可能同带两键**(`mcpIdentityHeadersIssue` 的 `both_set` 在读器之后不存在),重放存量 body 的处置因此就是升级前的读法。
|
|
62
|
-
*/
|
|
63
|
-
export declare function readMcpIdentityHeaders(transport: Record<string, unknown>): {
|
|
64
|
-
principalHeader?: string;
|
|
65
|
-
assertionHeader?: string;
|
|
66
|
-
};
|
|
67
62
|
/** 同设的拒句 —— 对契约包解析期那一句**逐字**(`server` = 条目名,调用方负责清洗后传入)。 */
|
|
68
63
|
export declare function describeMcpIdentityHeadersConflict(server: string): string;
|
|
69
64
|
/** `assertionHeader` 值不是字符串的**原因句**(不带条目名与键路径:点名由请求面统一的拒形 `entryFieldRefusal` 负责;值的形状只说种类,不回显值本身:它是一个调用方写的头名位置,可能是任何东西)。 */
|
|
70
65
|
export declare function describeMcpAssertionHeaderNotAString(value: unknown): string;
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
/**
|
|
67
|
+
* 引擎的 http 传输有没有断言头发送座 —— **全仓唯一的开关**。今天没有(core 的 http 传输无同名座,见头注与退役门)⇒ `false`:声明在、发送未接。
|
|
68
|
+
* 翻真 = 这一行 + 删退役门 + 把 {@link RequestHttpMcpTransport} 并进引擎型;剥键、披露、探测口拒、settings 面投影、能力位 `mcpAssertionHeaderSent` 随它一起翻
|
|
69
|
+
* (五处都读 {@link withholdsMcpAssertionHeader} / 本常量,没有第六处)。声明成 `boolean` 而不是字面 `false`:谓词里的真臂是活代码(单测传 `sent=true` 钉它),不是被收窄掉的死分支。
|
|
70
|
+
*/
|
|
71
|
+
export declare const MCP_ASSERTION_HEADER_SENT: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* 这一份 `assertionHeader` 声明是不是「被扣下」的那一类(需要剥键、需要说一行 info、探测口要拒的那一类)—— 即**声明了,而发送座不在**。
|
|
74
|
+
* 三处消费(剥键 / 披露 / 探测口拒)与 settings 面的投影共读这一只;`sent` 缺省读开关,单测传显式值钉另一臂。
|
|
75
|
+
*/
|
|
76
|
+
export declare function withholdsMcpAssertionHeader(assertionHeader: unknown, sent?: boolean): boolean;
|
|
77
|
+
/** {@link withholdsMcpAssertionHeader} 在请求面条目上的读法:只有 http 传输有这个键(stdio 形上它不存在)。 */
|
|
78
|
+
export declare function specWithholdsMcpAssertionHeader(spec: RequestMcpServerSpec): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* settings 面铸 spec 时「这个键投不投进引擎规格」:发送座在(`sent` 真)且声明了字符串 ⇒ 投,否则整键缺席。今天恒为空对象(开关假);
|
|
81
|
+
* 开关翻真的那天 settings 面因此自动跟着投,不会出现「位说发了、部署声明面却没投」。
|
|
82
|
+
*/
|
|
83
|
+
export declare function sentMcpAssertionHeaderMember(assertionHeader: unknown, sent?: boolean): {
|
|
84
|
+
assertionHeader?: string;
|
|
85
|
+
};
|
|
86
|
+
/** 请求面条目 → 交给引擎的规格:被扣下的 `assertionHeader` 剥掉(引擎无座);其余逐字不动。被扣下的条目由调用方另说一行 info。 */
|
|
74
87
|
export declare function toCoreMcpServerSpec(spec: RequestMcpServerSpec): McpServerSpec;
|
|
75
88
|
/** `noteMcpAssertionHeaderNotSent` 的日志行名(运维 grep 用;请求面与 settings 面同一个名字)。 */
|
|
76
89
|
export declare const MCP_ASSERTION_HEADER_NOT_SENT = "mcp_assertion_header_not_sent";
|
|
@@ -7,12 +7,6 @@ export function mcpIdentityHeadersIssue(transport) {
|
|
|
7
7
|
return "not_a_string";
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
-
export function readMcpIdentityHeaders(transport) {
|
|
11
|
-
return {
|
|
12
|
-
...(typeof transport.principalHeader === "string" ? { principalHeader: transport.principalHeader } : {}),
|
|
13
|
-
...(transport.principalHeader === undefined && typeof transport.assertionHeader === "string" ? { assertionHeader: transport.assertionHeader } : {}),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
10
|
export function describeMcpIdentityHeadersConflict(server) {
|
|
17
11
|
return `mcp server "${server}" sets both principalHeader and assertionHeader — an http entry names ONE header for the identity it sends: keep principalHeader (the end-user principal) or assertionHeader (the connector assertion), not both`;
|
|
18
12
|
}
|
|
@@ -20,11 +14,18 @@ export function describeMcpAssertionHeaderNotAString(value) {
|
|
|
20
14
|
const kind = value === null ? "null" : Array.isArray(value) ? "an array" : `a ${typeof value}`;
|
|
21
15
|
return `must be a string (the HTTP header NAME the connector assertion travels in) — got ${kind}; omit the key to send no assertion header`;
|
|
22
16
|
}
|
|
23
|
-
export
|
|
24
|
-
|
|
17
|
+
export const MCP_ASSERTION_HEADER_SENT = false;
|
|
18
|
+
export function withholdsMcpAssertionHeader(assertionHeader, sent = MCP_ASSERTION_HEADER_SENT) {
|
|
19
|
+
return !sent && assertionHeader !== undefined;
|
|
20
|
+
}
|
|
21
|
+
export function specWithholdsMcpAssertionHeader(spec) {
|
|
22
|
+
return spec.transport.kind === "http" && withholdsMcpAssertionHeader(spec.transport.assertionHeader);
|
|
23
|
+
}
|
|
24
|
+
export function sentMcpAssertionHeaderMember(assertionHeader, sent = MCP_ASSERTION_HEADER_SENT) {
|
|
25
|
+
return sent && typeof assertionHeader === "string" ? { assertionHeader } : {};
|
|
25
26
|
}
|
|
26
27
|
export function toCoreMcpServerSpec(spec) {
|
|
27
|
-
if (spec.transport.kind !== "http" || spec.transport.assertionHeader
|
|
28
|
+
if (spec.transport.kind !== "http" || !withholdsMcpAssertionHeader(spec.transport.assertionHeader))
|
|
28
29
|
return spec;
|
|
29
30
|
const { assertionHeader: _declaredNotSent, ...transport } = spec.transport;
|
|
30
31
|
return { ...spec, transport };
|
package/dist/mcp-tool-faces.d.ts
CHANGED
|
@@ -58,6 +58,11 @@ export type McpToolFacesRead = {
|
|
|
58
58
|
/**
|
|
59
59
|
* 从任一腿的原始条目里读出 `toolFaces` —— **三条腿共用的唯一判据点**。
|
|
60
60
|
* 缺席 ⇒ 合形无覆盖层;整只不是对象 / **任一只**工具的面判不出形 ⇒ `ok:false`(调用方整条 server 不收)。
|
|
61
|
+
*
|
|
62
|
+
* 🔴 工具名是 `__proto__` ⇒ 同样判不出形,**响亮拒**:按名存面的记录装不下它 —— JSON 的自有键 `"__proto__"` 写进记录那一步走的是原型的设置器,
|
|
63
|
+
* 键从结果里消失而判官答 `ok`,那条 server 照挂、收窄面叠层被无声丢掉。方向与本模块头注同(收窄声明在场就必须原样可用)。
|
|
64
|
+
* 只拒这一个名字:`constructor` / `toString` 等其余根原型成员名写进记录是普通自有键、不丢,引擎按名查面也取得到 —— 拒它们是给重放存量 body 的腿
|
|
65
|
+
* 新添一条「整条 server 不进」,不是修这个病。
|
|
61
66
|
*/
|
|
62
67
|
export declare function readMcpToolFaces(v: unknown): McpToolFacesRead;
|
|
63
68
|
export {};
|
package/dist/mcp-tool-faces.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { TOOL_APPROVAL_CARDS, TOOL_FAMILIES, TOOL_PATH_ABSENCES, TOOL_PATH_ACCESSES, TOOL_PATH_BASES } from "@sema-agent/core";
|
|
2
|
+
import { isStringArray } from "@sema-agent/settings-schema";
|
|
3
|
+
import { quotedCallerText } from "./caller-text-echo.js";
|
|
2
4
|
function isRecord(v) {
|
|
3
5
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4
6
|
}
|
|
5
|
-
function isStringArray(v) {
|
|
6
|
-
return Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
7
|
-
}
|
|
8
7
|
function memberOf(table, v) {
|
|
9
8
|
return typeof v === "string" && table.includes(v);
|
|
10
9
|
}
|
|
@@ -92,9 +91,12 @@ export function readMcpToolFaces(v) {
|
|
|
92
91
|
return { ok: false, problem: `toolFaces is ${Array.isArray(v) ? "an array" : typeof v}, not an object of per-tool faces` };
|
|
93
92
|
const faces = {};
|
|
94
93
|
for (const [tool, raw] of Object.entries(v)) {
|
|
94
|
+
if (tool === "__proto__") {
|
|
95
|
+
return { ok: false, problem: `toolFaces names tool "__proto__" — a per-tool record cannot hold a face under that name (writing it sets the record's prototype instead of a key), so the declaration would silently vanish` };
|
|
96
|
+
}
|
|
95
97
|
const face = readOneFace(raw);
|
|
96
98
|
if (face === undefined)
|
|
97
|
-
return { ok: false, problem: `the declared face for tool ${
|
|
99
|
+
return { ok: false, problem: `the declared face for tool ${quotedCallerText(tool)} does not fit the tool-face shape` };
|
|
98
100
|
faces[tool] = face;
|
|
99
101
|
}
|
|
100
102
|
return Object.keys(faces).length > 0 ? { ok: true, faces } : { ok: true };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S-640(S-512 片二)—— 一个任务的**项目层准备一步**:求键 → 把同一 checkout 的旧层折进当前层 → 交给同步腿跟踪。
|
|
3
|
+
* HTTP 腿(`boot/resolve-spec.ts`)与 run-local 腿共用这一只;键的规则只在 `memory-scope.ts` `memoryProjectLayerFor`(本模块不判让位、不铸键)。
|
|
4
|
+
*
|
|
5
|
+
* ## 折叠(`foldFrom`,由 `project-identity.ts` `projectLayerForTaskRoot` 给出,按序)
|
|
6
|
+
* · 退役 `repo:<sha256(根)[:24]>` 层 —— **一次性迁移**(7.98.0–7.132.x 的项目键;窗、删法见 `plugins/one-time-migrations.ts` 登记表 M25);
|
|
7
|
+
* · 当前档为 `r`(origin 远端)时本 checkout 的 `p` 档 —— **常设律**(先 `git init` 后加远端的项目,加远端那一刻不丢项目记忆)。
|
|
8
|
+
* 折 = core `migrateScope`(id 保留、rev 按新 scope 重算、逐条 CAS;冲突留原地,下一个任务再折)。**不记「已折」**:每个任务先读一眼旧层
|
|
9
|
+
* (`listHeaders`,空就不动),旧层之后又来了条目(仍在跑的旧任务 harvest、同步把别处的改动拉回旧层)下一个任务照折。
|
|
10
|
+
* 🔴 **与同步轮串行**:旧层若是被同步的层(`p` 档),在飞的那一轮的应答(拉回的改动 / 删除)按 id 落盘 —— 折在它前面,应答会把刚折走的条目改回旧层
|
|
11
|
+
* 或在新层上删掉它。所以有东西要折时,折叠排进同步腿的串行链(`MemorySyncRunner.exclusive`):等在飞的那一轮落定再折,折的时候没有轮在飞。
|
|
12
|
+
* 折在 spec 返回之前完成(`await`)⇒ 这一任务挂载时就看得见折进来的条目(代价如实:有东西要折又恰有一轮在飞时,任务起步等那一轮)。
|
|
13
|
+
* 折叠失败不挡任务(响亮 warn,条目原地不动、下次再折):项目层记忆暂时少了旧层那几条,比任务起不来更接近用户要的东西。
|
|
14
|
+
*
|
|
15
|
+
* ## 跟踪
|
|
16
|
+
* 当前层在复制覆盖面里(否则规则已让位、根本走不到这里)且有同步腿 ⇒ `track(scope)`:本地还没有条目也每轮拉它 —— 第二台设备第一次进这个项目
|
|
17
|
+
* 就拉得到第一台写的(拉回来可能晚于本任务挂载:第一个任务看不见,下一个任务看得见,如实)。
|
|
18
|
+
*/
|
|
19
|
+
import { type MemoryBackend } from "@sema-agent/core";
|
|
20
|
+
import type { ServiceConfig } from "./config-types.js";
|
|
21
|
+
import type { MemorySyncRunner } from "./memory-sync-client.js";
|
|
22
|
+
import type { MemoryProjectKey } from "./project-identity.js";
|
|
23
|
+
export interface MemoryProjectLayers {
|
|
24
|
+
/** 这一任务的项目层声明(`TaskSpec.memory.projectKey`);`undefined` 的三形同 `memoryProjectKeyFor`。 */
|
|
25
|
+
prepare(config: Pick<ServiceConfig, "requirePrincipal" | "memorySync">, scope: string | undefined, taskRoot: string | undefined): Promise<MemoryProjectKey | undefined>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createMemoryProjectLayers(deps: {
|
|
28
|
+
/** 本部署的记忆引擎 backend(File 或 SQL 孪生);缺席 ⇒ 没有可折的盘(记忆暗时调用方根本不会问)。 */
|
|
29
|
+
backend: MemoryBackend | undefined;
|
|
30
|
+
/** 同步腿(开同步时在场):跟踪当前层;有东西要折时折叠排进它的串行链。 */
|
|
31
|
+
syncRunner: Pick<MemorySyncRunner, "track" | "exclusive"> | undefined;
|
|
32
|
+
log: {
|
|
33
|
+
info(msg: string, fields?: Record<string, unknown>): void;
|
|
34
|
+
warn(msg: string, fields?: Record<string, unknown>): void;
|
|
35
|
+
};
|
|
36
|
+
}): MemoryProjectLayers;
|
|
37
|
+
//# sourceMappingURL=memory-project-layer.d.ts.map
|