@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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一条提交腿**刚认领**的 run 在起跑之前就收场 —— 撤掉本请求建的东西的**唯一**写法。三个调用点:device 落点拒
|
|
3
|
+
* (`device-placement.ts` `commitPlacement`)、续跑输入写不进(`submit-ctx.ts` `persistSubmitCtx`)与 workflow 决定行没落成
|
|
4
|
+
* (`durable-run-leg.ts` 的 fresh 投递腿;此刻认领可能已被收割归了别人 —— 两步都按这一跑自己的 taskId,碰不到别人的认领)。
|
|
5
|
+
*
|
|
6
|
+
* 撤两步,**各自独立**(一步失败不拦另一步,残余最小):
|
|
7
|
+
* · 终结这条 run 行(`setTerminal` 是按 taskId 的 CAS,首写者赢 ⇒ 重复调用是 no-op)—— 随之释放它的 `task_active` 认领;
|
|
8
|
+
* · 放开它占的提交幂等键(拒绝答复邀请重试;同键重试必须真跑,不是回放这次拒绝 —— `RunStore.releaseIdemKey`)。
|
|
9
|
+
* 撤不掉不致命、但要响:每一步的失败各交给调用方按自己的名字留痕(`onFailure`)。终结没落下 ⇒ 起跑前的心跳随调用腿收场停下(或从没起过),`reapStale`
|
|
10
|
+
* 在 `REAP_RUN_STALE_SEC` 之后把这条行翻 failed 并释放会话;幂等键没放开 ⇒ 同键重提回放这条行的回执(两形都是修前每一次的样子)。
|
|
11
|
+
*/
|
|
12
|
+
import type { RunStore } from "../plugins/store-backend.js";
|
|
13
|
+
export declare function releaseClaimedRun(runStore: Pick<RunStore, "setTerminal" | "releaseIdemKey">, taskId: string, why: string, onFailure: (err: unknown, step: "terminal" | "idem_key") => void): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=claimed-run.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function releaseClaimedRun(runStore, taskId, why, onFailure) {
|
|
2
|
+
try {
|
|
3
|
+
await runStore.setTerminal(taskId, "failed", null, why);
|
|
4
|
+
}
|
|
5
|
+
catch (err) {
|
|
6
|
+
onFailure(err, "terminal");
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
await runStore.releaseIdemKey(taskId);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
onFailure(err, "idem_key");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=claimed-run.js.map
|
|
@@ -53,6 +53,7 @@ import { type DeviceOwner } from "../device-store.js";
|
|
|
53
53
|
import { type DeviceEnrollment, type DeviceRejection } from "../device-enrollment.js";
|
|
54
54
|
import type { ServiceConfig } from "../config.js";
|
|
55
55
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
56
|
+
import { type RefusalBody } from "./refusal-body.js";
|
|
56
57
|
/**
|
|
57
58
|
* 调用方 device 域的**唯一铸造点**。`undefined` = 判不出域(无 principal,或凭据不带 tenant claim)——
|
|
58
59
|
* 消费点必须响亮拒,禁静默空视图。
|
|
@@ -170,8 +171,5 @@ export declare function placementWriteDeadlineMs(runStaleSec: number | undefined
|
|
|
170
171
|
*/
|
|
171
172
|
export declare function commitPlacement(ctx: PlacementCommitCtx, runStore: RunStore, taskId: string, intent: DevicePlacementIntent | undefined): Promise<DeviceRejection | null>;
|
|
172
173
|
/** 拒绝的**唯一** wire 体铸点(四个消费点各自用自己协议的发送姿势,但体的键集只有这一份)。 */
|
|
173
|
-
export declare function devicePlacementErrorBody(rej: DeviceRejection):
|
|
174
|
-
error: string;
|
|
175
|
-
errorCode: string;
|
|
176
|
-
};
|
|
174
|
+
export declare function devicePlacementErrorBody(rej: DeviceRejection): RefusalBody;
|
|
177
175
|
//# sourceMappingURL=device-placement.d.ts.map
|
|
@@ -2,6 +2,8 @@ import { createCodedHttpError, ssoVerifiedScope } from "../security.js";
|
|
|
2
2
|
import { gatedPrincipal } from "./principal-gate.js";
|
|
3
3
|
import { DEVICE_ERROR_CODES, assertDeviceIdShape, } from "../device-store.js";
|
|
4
4
|
import { buildDeviceRejection } from "../device-enrollment.js";
|
|
5
|
+
import { releaseClaimedRun } from "./claimed-run.js";
|
|
6
|
+
import { refusalBody } from "./refusal-body.js";
|
|
5
7
|
export function deviceOwnerDomainOf(req, config) {
|
|
6
8
|
const subject = gatedPrincipal(req, config);
|
|
7
9
|
if (subject === undefined)
|
|
@@ -89,16 +91,10 @@ export async function commitPlacement(ctx, runStore, taskId, intent) {
|
|
|
89
91
|
if (intent === undefined)
|
|
90
92
|
return null;
|
|
91
93
|
const enrollment = ctx.deviceEnrollment;
|
|
92
|
-
const releaseRun =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
ctx.logger?.warn("device_placement_run_release_failed", { taskId, err: err instanceof Error ? err.message : String(err) });
|
|
99
|
-
ctx.metrics?.inc("device_placement_run_release_failed_total");
|
|
100
|
-
}
|
|
101
|
-
};
|
|
94
|
+
const releaseRun = (why) => releaseClaimedRun(runStore, taskId, why, (err, step) => {
|
|
95
|
+
ctx.logger?.warn("device_placement_run_release_failed", { taskId, step, err: err instanceof Error ? err.message : String(err) });
|
|
96
|
+
ctx.metrics?.inc("device_placement_run_release_failed_total");
|
|
97
|
+
});
|
|
102
98
|
if (!enrollment) {
|
|
103
99
|
await releaseRun("device placement could not be committed: the device lane's admission chain is not wired");
|
|
104
100
|
throw new Error("commitPlacement: a device placement intent was minted without a DeviceEnrollment — assembly bug (both are read from the same ServiceDeps)");
|
|
@@ -144,6 +140,6 @@ export async function commitPlacement(ctx, runStore, taskId, intent) {
|
|
|
144
140
|
return rejection;
|
|
145
141
|
}
|
|
146
142
|
export function devicePlacementErrorBody(rej) {
|
|
147
|
-
return {
|
|
143
|
+
return refusalBody({ errorCode: rej.code, message: rej.message });
|
|
148
144
|
}
|
|
149
145
|
//# sourceMappingURL=device-placement.js.map
|
package/dist/http/dispatch.d.ts
CHANGED
|
@@ -18,10 +18,6 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
18
18
|
import type { ServiceConfig } from "../config-types.js";
|
|
19
19
|
import type { RouteCtxBase, RunRegistry } from "./route-ctx.js";
|
|
20
20
|
import type { FlatServiceDeps } from "./server.js";
|
|
21
|
-
/** 「这台部署配了任何一把 service 凭证吗」—— fail-closed 写门族的真值源。**单一属主**:`handle()` 的
|
|
22
|
-
* 凭证门、[ref] 的 parked 赎回席、以及 [ref] 的 consolidation 阀门启动期告警读同一句(手抄迟早
|
|
23
|
-
* 只改一处,而这条判据决定的是「无凭证部署上写口开不开」)。导出仅为最后一个消费点(main.ts)。 */
|
|
24
|
-
export declare function hasServiceAuth(config: ServiceConfig): boolean;
|
|
25
21
|
/**
|
|
26
22
|
* 🔴 S-672(test T-72 [ref];主会话裁 ①,分诊 [ref])—— 全局服务凭据门**之前**那几族只读路
|
|
27
23
|
* (`route-table.ts` 里 `position: "read-credential"` 的行)的**唯一**鉴权谓词:「服务凭据 ∨ 已验 principal」。
|
package/dist/http/dispatch.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { setSsoPrincipal, ssoVerifiedPrincipal, setSsoScope, isDestructiveSessionWrite, PRINCIPAL_TOKEN_HEADER, APPROVAL_MAC_HEADER, APPROVAL_MAC_KID_HEADER } from "../security.js";
|
|
2
|
+
import { setSsoPrincipal, ssoVerifiedPrincipal, setSsoScope, setSsoRole, isDestructiveSessionWrite, PRINCIPAL_TOKEN_HEADER, APPROVAL_MAC_HEADER, APPROVAL_MAC_KID_HEADER } from "../security.js";
|
|
3
3
|
import { publicStoreProbeError } from "../store-live-probe.js";
|
|
4
4
|
import { looksLikeJwt } from "@sema-agent/settings-schema/api/auth-bridge";
|
|
5
5
|
import { ROUTE_METHOD_ORDER } from "./route-ctx.js";
|
|
6
6
|
import { READ_CREDENTIAL_ROUTES, PUBLIC_ROUTES, POST_CREDENTIAL_ROUTES, routeLabel, isBillableSubmitPath, billableKindOf, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, lookupRoute, isProbePath, isSubscriptionRequest } from "./route-table.js";
|
|
7
7
|
import { sendJson, sendError, isSseResponse, endSseWithError } from "./send.js";
|
|
8
|
-
import { admissionRefusalOf, readinessOf, healthReadinessKeys, sendReadyz, sendBillableRefusal, billableRefusalOf } from "./readiness.js";
|
|
8
|
+
import { admissionRefusalOf, readinessOf, healthReadinessKeys, sendReadyz, sendBillableRefusal, billableRefusalOf, billableRefusalFrame } from "./readiness.js";
|
|
9
9
|
import { ENGINE_SIGNAL_KEY, buildEngineSignal, fleetMembershipKeys, healthConfigLedgerKeys, healthDrainingKeys, mintEngineSignal, restartActionable } from "../fleet/engine-signal.js";
|
|
10
10
|
import { buildHealthSelfReport } from "./health-self-report.js";
|
|
11
|
-
import { authorized, systemFor, gatedPrincipal, sendPrincipalRefusal, sendUnauthorized, verifiedIdentitySource } from "./principal-gate.js";
|
|
11
|
+
import { authorized, systemFor, gatedPrincipal, sendPrincipalRefusal, sendUnauthorized, verifiedIdentitySource, hasServiceAuth, devOpenDeployment } from "./principal-gate.js";
|
|
12
12
|
const PROCESS_STARTED_AT_MS = Date.now() - Math.round(process.uptime() * 1000);
|
|
13
|
-
export function hasServiceAuth(config) {
|
|
14
|
-
return Boolean(config.authToken) || Object.keys(config.authTokens ?? {}).length > 0;
|
|
15
|
-
}
|
|
16
13
|
export function readCredentialOk(req, config) {
|
|
17
14
|
if (!hasServiceAuth(config))
|
|
18
15
|
return true;
|
|
@@ -54,10 +51,10 @@ export function createDispatch(ctx) {
|
|
|
54
51
|
};
|
|
55
52
|
deps.drainState.lastAttachEndedAt = () => lastAttachEndedAt;
|
|
56
53
|
deps.drainState.endSubscriptions = () => {
|
|
57
|
-
const
|
|
54
|
+
const frame = billableRefusalFrame(billableRefusalOf("draining"));
|
|
58
55
|
for (const r of [...openSubscriptions])
|
|
59
56
|
if (isSseResponse(r))
|
|
60
|
-
endSseWithError(r,
|
|
57
|
+
endSseWithError(r, frame);
|
|
61
58
|
};
|
|
62
59
|
}
|
|
63
60
|
async function dispatchSegment(rows, req, res, url, search, method, allow, ctx, admit) {
|
|
@@ -151,7 +148,7 @@ export function createDispatch(ctx) {
|
|
|
151
148
|
startedAt: PROCESS_STARTED_AT_MS,
|
|
152
149
|
port: req.socket.localPort,
|
|
153
150
|
...(deps.config.directDoorActive ? { directDoorActive: true } : {}),
|
|
154
|
-
...buildHealthSelfReport(deps
|
|
151
|
+
...buildHealthSelfReport(deps),
|
|
155
152
|
...(signal.restart ? { ...(restartActionable(signal) ? { restartRequired: true } : {}), restart: signal.restart } : {}),
|
|
156
153
|
...(() => {
|
|
157
154
|
const configHandoff = deps.configHandoffState?.();
|
|
@@ -162,6 +159,10 @@ export function createDispatch(ctx) {
|
|
|
162
159
|
const credential = deps.centerCredentialState?.();
|
|
163
160
|
return credential ? { centerCredential: credential } : {};
|
|
164
161
|
})(),
|
|
162
|
+
...(() => {
|
|
163
|
+
const identityNotice = deps.centerIdentityNoticeState?.();
|
|
164
|
+
return identityNotice ? { centerIdentityNotice: identityNotice } : {};
|
|
165
|
+
})(),
|
|
165
166
|
...(() => {
|
|
166
167
|
const modelRefusals = deps.modelRefusalsState?.();
|
|
167
168
|
return modelRefusals ? { modelRefusals } : {};
|
|
@@ -188,10 +189,9 @@ export function createDispatch(ctx) {
|
|
|
188
189
|
sendError(res, 404, "feature.metrics_disabled", "metrics disabled");
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const ok = devOpen || (anyT && systemFor(req, deps.config) !== undefined) || (!!mt && authorized(req, mt));
|
|
192
|
+
const mt = deps.config.metricsToken;
|
|
193
|
+
const devOpen = devOpenDeployment(deps) && !mt;
|
|
194
|
+
const ok = devOpen || systemFor(req, deps.config) !== undefined || (!!mt && authorized(req, mt));
|
|
195
195
|
if (!ok) {
|
|
196
196
|
sendUnauthorized(res, "operator");
|
|
197
197
|
return;
|
|
@@ -218,6 +218,8 @@ export function createDispatch(ctx) {
|
|
|
218
218
|
req.headers[deps.config.principalHeader.toLowerCase()] = v.identity.principal;
|
|
219
219
|
if (v.identity.scope)
|
|
220
220
|
setSsoScope(req, v.identity.scope);
|
|
221
|
+
if (v.identity.role)
|
|
222
|
+
setSsoRole(req, v.identity.role);
|
|
221
223
|
deps.logger?.info?.("auth_bridge_principal_accepted", { principal: v.identity.principal, ...(v.identity.scope ? { scope: v.identity.scope } : {}) });
|
|
222
224
|
}
|
|
223
225
|
}
|
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* **一条 durable run 的「建行 + 驱动」单一属主**(S-218 提取;此前整段住在 `routes/runs.ts` 的
|
|
3
|
-
* `createDurableRun` 里,只服务 HTTP/A2A 两条提交门)。
|
|
4
|
-
*
|
|
5
|
-
* 🔴 为什么提成模块:`/decide` 的 workflow 第三条车道在**宿主不在 park 上**时,同样要在宿主会话上起
|
|
6
|
-
* 一跑新 turn 把决定交给宿主的模型(S-218)。这条链上挂着 `createRun` 的会话 claim(以及它唯一诚实的
|
|
7
|
-
* 409 出路)、checkpoint ctx 落库、fleet 行发布、resume/rewind 两族锚点捕获、审批 ALS、通告投递……
|
|
8
|
-
* 手抄第二份 = 把这十来件事复制成两份会漂的实现,而漂开的那天没有任何东西会说话(`createDurableRun`
|
|
9
|
-
* 当年从路由体里提取出来时,头注写的就是同一条判词)。方向:`routes/runs.ts` 与 `http/server.ts`
|
|
10
|
-
* 都 import 本模块,本模块谁都不 import —— 与 `http/run-meta.ts` 同一条「两个域共用一件 ⇒ 单独成文件」。
|
|
11
|
-
*
|
|
12
|
-
* 边界(本腿**不**含的东西,留给各自的门):同键重放的回执(`http/submit-replay.ts`)、`Idempotency-Key` 的在飞合流、
|
|
13
|
-
* lease / 治理窗 pre-admission、属主门。它们是**提交面**的判据(读请求、写响应),而本腿只吃已经备好的
|
|
14
|
-
* `PreparedTaskSubmission` 并交回一份收据 —— 这正是它能被一条没有 `ServerResponse` 的内部车道复用的原因。
|
|
15
|
-
*/
|
|
16
|
-
import { type RunInternals } from "@sema-agent/core";
|
|
17
1
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
18
2
|
import type { RunIdemBinding, RunRecord } from "../plugins/store-contracts.js";
|
|
19
|
-
import type { PreparedTaskSubmission, RouteCtxBase } from "./route-ctx.js";
|
|
20
|
-
/**
|
|
21
|
-
* 🔴 **TRUSTED run internals** —— 由**部署方**(不是模型、不是请求体、不是工具参数)铸给这一跑的
|
|
22
|
-
* core 内部席位。今天唯一成员 `workflowParkedResume` = 人对一条 parked workflow 子代的决定
|
|
23
|
-
* (语义属主 = core `RunInternals.workflowParkedResume` 的 d.ts 顶注:「A host that decided a workflow
|
|
24
|
-
* child's parked checkpoint launches the run that re-invokes `Workflow({resumeFromRunId})` with the
|
|
25
|
-
* decision here」)。
|
|
26
|
-
*
|
|
27
|
-
* 为什么单独命名而不是直接摊 `RunInternals`:`RunInternals` 里绝大多数席位是**执行腿自己**铸的
|
|
28
|
-
* (onForwardEvent / onTaskNotification / onActivity …),把整只类型开给调用方等于邀请第二个写者;
|
|
29
|
-
* 本类型只开「部署方可以决定的那一格」,新增一格时**必须**在这里显式点名,编译期看得见。
|
|
30
|
-
* 缺席 ⇒ 对两条腿都是完整 no-op。
|
|
31
|
-
*/
|
|
32
|
-
export type TrustedRunInternals = Pick<RunInternals, "workflowParkedResume">;
|
|
3
|
+
import type { PreparedTaskSubmission, RouteCtxBase, WorkflowDecisionDelivery } from "./route-ctx.js";
|
|
33
4
|
export interface DurableRunLegArgs {
|
|
34
5
|
/** `prepareSpec` 的产物,或内部车道按同一条 `resolveSpec` 装配出来的等价形。 */
|
|
35
6
|
prepared: PreparedTaskSubmission;
|
|
@@ -49,8 +20,9 @@ export interface DurableRunLegArgs {
|
|
|
49
20
|
elicitOwner: string | null;
|
|
50
21
|
/** run 行元数据的 `source` 列(调用方的系统身份;内部车道传自己的车道名)。 */
|
|
51
22
|
source: string | null;
|
|
52
|
-
/**
|
|
53
|
-
|
|
23
|
+
/** `/decide` 第三条车道的 fresh 投递腿交来的那一件决定投递(带着的决定 + 起跑之前落行的那一笔;语义与 TRUSTED 纪律的属主 =
|
|
24
|
+
* `route-ctx.ts` 的 {@link WorkflowDecisionDelivery} 顶注)。缺席 ⇒ 只摊本会话已受理的决定行。 */
|
|
25
|
+
workflowDecision?: WorkflowDecisionDelivery;
|
|
54
26
|
}
|
|
55
27
|
/**
|
|
56
28
|
* 本腿的结局:一份收据,或「这次提交的一把幂等钥匙已经指向一条行」(店的原子赢或观察的**观察**臂 —— 本腿不碰
|
|
@@ -72,7 +44,8 @@ export type DurableRunLegOutcome = {
|
|
|
72
44
|
/**
|
|
73
45
|
* 建行 + 驱动。返回 `202` = 新行已建并在跑(体带 `taskId`/`sessionId`);`409` = 会话被别的 run 占着,
|
|
74
46
|
* **没有**建行(体 = `buildActiveRunConflict` 的既有形,含 `errorCode: "conflict.session_active_run"`);
|
|
75
|
-
* `existing` = 这次提交的钥匙(`idem.key` / `clientTaskId`)
|
|
47
|
+
* `existing` = 这次提交的钥匙(`idem.key` / `clientTaskId`)已经指向一条行,没建新行;落点拒(device 车道)与续跑输入一行装不下
|
|
48
|
+
* (`413 request.payload_too_large`,`submit-ctx.ts`)= 行建了又撤了(终结 + 放认领 + 放幂等键),什么都没跑。
|
|
76
49
|
* 协议渲染归调用方(HTTP `sendJson` / A2A 协议对象 / `/decide` 的受理体)。
|
|
77
50
|
*/
|
|
78
51
|
export declare function mintAndDriveDurableRun(ctx: RouteCtxBase, runStore: RunStore, args: DurableRunLegArgs): Promise<DurableRunLegOutcome>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { uuidv7 } from "@sema-agent/core";
|
|
2
|
-
import {
|
|
2
|
+
import { heldWorkflowParkDecisions } from "../parked-decide.js";
|
|
3
|
+
import { HEARTBEAT_MS, runInBackground } from "../runs.js";
|
|
3
4
|
import { fleetRunPublisher, fleetRunLabels } from "../fleet/fleet-bus.js";
|
|
4
5
|
import { cascadeConfig, runMeta } from "./run-meta.js";
|
|
5
6
|
import { resolveStreamApprovalGate } from "../tool-approval.js";
|
|
@@ -8,13 +9,15 @@ import { commitPlacement, devicePlacementErrorBody } from "./device-placement.js
|
|
|
8
9
|
import { commitSessionInheritEnv } from "./session-inherit-env.js";
|
|
9
10
|
import { clearTurnActivity, readTurnActivityMs } from "../turn-activity.js";
|
|
10
11
|
import { recordResourceWindow } from "../resource-window.js";
|
|
11
|
-
import {
|
|
12
|
+
import { persistSubmitCtx } from "./submit-ctx.js";
|
|
13
|
+
import { releaseClaimedRun } from "./claimed-run.js";
|
|
12
14
|
import { serviceVersion } from "../service-version.js";
|
|
13
15
|
export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
14
16
|
const { deps } = ctx;
|
|
15
17
|
const { inflightRuns, preemptableRuns, steerableRuns } = ctx.registry;
|
|
16
18
|
const sessionId = args.prepared.spec.sessionId ?? uuidv7();
|
|
17
19
|
const taskId = args.clientTaskId ?? uuidv7();
|
|
20
|
+
const trustedInternals = await heldWorkflowParkDecisions(deps, sessionId, args.workflowDecision?.carried);
|
|
18
21
|
const created = await runStore.createRun(taskId, sessionId, args.prepared.auth?.principal ?? null, deps.instanceId ?? "default", { ...runMeta(args.prepared, args.source), idem: args.idem ?? null });
|
|
19
22
|
if (created.ok)
|
|
20
23
|
clearTurnActivity(taskId);
|
|
@@ -25,13 +28,36 @@ export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
|
25
28
|
if (!created.ok) {
|
|
26
29
|
return { status: 409, body: await buildActiveRunConflict({ runStore, checkpointStore: deps.checkpointStore, governance: deps.config, runStaleSec: deps.config.runStaleSec, turnActivity: readTurnActivityMs }, sessionId, created.activeTaskId) };
|
|
27
30
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const owner = args.prepared.auth?.principal ?? null;
|
|
32
|
+
const preLaunchHeartbeat = setInterval(() => {
|
|
33
|
+
void runStore.heartbeat(taskId, owner).catch(() => { deps.metrics?.inc("run_signal_poll_errors_total", { kind: "heartbeat" }); });
|
|
34
|
+
}, HEARTBEAT_MS);
|
|
35
|
+
preLaunchHeartbeat.unref?.();
|
|
36
|
+
try {
|
|
37
|
+
const placementReject = await commitPlacement(deps, runStore, taskId, args.prepared.bindingIntent);
|
|
38
|
+
if (placementReject)
|
|
39
|
+
return { status: placementReject.status, body: devicePlacementErrorBody(placementReject) };
|
|
40
|
+
if (deps.checkpointStore) {
|
|
41
|
+
const ctxRefusal = await persistSubmitCtx(deps.checkpointStore, deps, { runStore, taskId }, sessionId, { body: args.prepared.body, memoryScope: args.prepared.auth?.memoryScope, writerVersion: serviceVersion() });
|
|
42
|
+
if (ctxRefusal)
|
|
43
|
+
return ctxRefusal;
|
|
44
|
+
}
|
|
45
|
+
if (args.workflowDecision !== undefined) {
|
|
46
|
+
try {
|
|
47
|
+
await args.workflowDecision.commitBeforeLaunch(taskId);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
await releaseClaimedRun(runStore, taskId, `the workflow decision this run delivers could not be recorded: ${err instanceof Error ? err.message : String(err)}`, (releaseErr, step) => {
|
|
51
|
+
deps.logger?.warn?.("workflow_decision_run_release_failed", { taskId, sessionId, step, err: releaseErr instanceof Error ? releaseErr.message : String(releaseErr) });
|
|
52
|
+
});
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
34
56
|
}
|
|
57
|
+
finally {
|
|
58
|
+
clearInterval(preLaunchHeartbeat);
|
|
59
|
+
}
|
|
60
|
+
commitSessionInheritEnv(deps, args.prepared.spec.sessionId, args.prepared.body);
|
|
35
61
|
const anchorOwner = args.prepared.auth?.principal ?? null;
|
|
36
62
|
const getLeafId = deps.sessionStorage?.getLeafId?.bind(deps.sessionStorage);
|
|
37
63
|
const captureTurnAnchor = deps.resumeAnchorStore && getLeafId
|
|
@@ -63,7 +89,7 @@ export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
|
63
89
|
windowMs: deps.config.streamApproval?.windowMs,
|
|
64
90
|
windowMarginMs: deps.config.streamAskWindowMarginMs,
|
|
65
91
|
}
|
|
66
|
-
: undefined, deps.checkpointStore, args.prepared.engineNotices,
|
|
67
|
-
return { status: 202, body: { taskId, sessionId, status: "running" } };
|
|
92
|
+
: undefined, deps.checkpointStore, args.prepared.engineNotices, trustedInternals, deps.userInputLedger, args.prepared.acceptance);
|
|
93
|
+
return { status: 202, body: { taskId, sessionId, status: "running", ...(args.prepared.warnings !== undefined ? { warnings: args.prepared.warnings } : {}) } };
|
|
68
94
|
}
|
|
69
95
|
//# sourceMappingURL=durable-run-leg.js.map
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* ## 规则(一条):自报位是**投影**,不是第二份规则
|
|
6
6
|
* 每一位读的是**门本身读的那只谓词 / 那只取值口**,本模块不判任何东西:
|
|
7
|
-
* · `auth.
|
|
8
|
-
*
|
|
7
|
+
* · `auth.kinds` = `IDENTITY_SOURCES`(`verifiedIdentitySource` 的回值闭集)里,这台部署的装配**能**回的那几个词 —— 取唯一读法 `wiredIdentitySources`
|
|
8
|
+
* (`principal-gate.ts`;「这台部署有没有身份边界」的门 `devOpenDeployment` 读同一只):
|
|
9
9
|
* `service_token` ⇐ 全局门武装(`systemFor` 只在配了 service token 时回得出值)· `sso` ⇐ 鉴权桥装了(入口预认证只在
|
|
10
10
|
* `webAdminJwtVerifier` 在场时挂身份)· `direct_door_jwt` ⇐ 直连门开着(`verifiedIdentitySource` 那一臂的第一个合取项);
|
|
11
|
+
* · `auth.required` = kinds 里有没有 `service_token` —— 那一词接没接线就是全局凭据门的武装谓词(`hasServiceAuth`;`wiredIdentitySources` 的
|
|
12
|
+
* `service_token` 臂读的正是它),所以 `required` 与 `kinds` 是同一次求值的两个投影,不是两个来源;
|
|
11
13
|
* · `auth.identityAttach` = kinds 里有没有**带调用方身份**的一类({@link carriesCallerIdentity},穷举):`service_token` 认的是系统
|
|
12
14
|
* (`systemFor` 回系统名或 null),不是人;
|
|
13
15
|
* · `operator` = 能力事实 `operatorLane`(operator 面族的 501 门读的同一只;名单本身不上 wire);
|
|
@@ -56,8 +58,8 @@ export interface HealthSelfReport {
|
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
|
-
* 三键的**唯一铸点**(`build*`:纯数据)
|
|
60
|
-
*
|
|
61
|
+
* 三键的**唯一铸点**(`build*`:纯数据)。只读装配本身:`auth` 三位都从一次 `wiredIdentitySources` 求值投出(`required` = 其中有 `service_token`),
|
|
62
|
+
* 不收调用方递进来的第二份布尔 —— 一个事实一次求值。
|
|
61
63
|
*/
|
|
62
|
-
export declare function buildHealthSelfReport(deps: Pick<FlatServiceDeps, "config" | "webAdminJwtVerifier" | "sessionStorage" | "runStore"
|
|
64
|
+
export declare function buildHealthSelfReport(deps: Pick<FlatServiceDeps, "config" | "webAdminJwtVerifier" | "sessionStorage" | "runStore">): HealthSelfReport;
|
|
63
65
|
//# sourceMappingURL=health-self-report.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wiredIdentitySources } from "./principal-gate.js";
|
|
2
2
|
import { operatorLane, sessionList } from "../capability-facts.js";
|
|
3
3
|
import { authBridgeIssuerOf } from "../auth-bridge.js";
|
|
4
4
|
import { centerLaneConfigured } from "../web-admin-client/center-request.js";
|
|
@@ -19,29 +19,15 @@ function carriesCallerIdentity(kind) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
switch (kind) {
|
|
24
|
-
case "service_token":
|
|
25
|
-
return a.credentialGateArmed;
|
|
26
|
-
case "sso":
|
|
27
|
-
return a.bridgeWired;
|
|
28
|
-
case "direct_door_jwt":
|
|
29
|
-
return a.directDoorActive;
|
|
30
|
-
default: {
|
|
31
|
-
const unknownKind = kind;
|
|
32
|
-
throw new Error(`health self-report: unknown identity source ${String(unknownKind)}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function buildHealthSelfReport(deps, credentialGateArmed) {
|
|
22
|
+
export function buildHealthSelfReport(deps) {
|
|
37
23
|
const { config } = deps;
|
|
38
24
|
const bridgeWired = deps.webAdminJwtVerifier !== undefined;
|
|
39
|
-
const kinds =
|
|
25
|
+
const kinds = wiredIdentitySources(deps);
|
|
40
26
|
const issuer = authBridgeIssuerOf(config)?.issuer;
|
|
41
27
|
const webBaseUrl = config.webAdmin?.webBaseUrl;
|
|
42
28
|
const sessionsVisible = centerLaneConfigured(config) && config.fleetAdvertiseAddress !== undefined && bridgeWired && sessionList(deps).available ? (config.requirePrincipal ? true : "unknown") : false;
|
|
43
29
|
return {
|
|
44
|
-
auth: { required:
|
|
30
|
+
auth: { required: kinds.includes("service_token"), kinds, identityAttach: kinds.some(carriesCallerIdentity) ? "available" : "unavailable" },
|
|
45
31
|
operator: operatorLane(deps).available ? "present" : "absent",
|
|
46
32
|
center: {
|
|
47
33
|
...(issuer !== undefined ? { issuer: buildDisplaySafeUrl(issuer) } : {}),
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🔴 **属主存取器**(S-487 RH-3 第一期)——「这个调用方读得到这一行 run / 会话吗」的行只经这里取得。
|
|
3
|
+
*
|
|
4
|
+
* ## 律(一条)
|
|
5
|
+
* 判官只有一只:run 行 = `principal-gate.ts` 的 `runOwnerReadable`(三条放行臂,含 [ref] C8 窄互认),会话行 = `sessionOwnerReadable`
|
|
6
|
+
* (dev-open 不钉人;无主行经 `security.ts` 的 `ownerlessRowOpen`;有主行就是 run 那一只)。本模块**不判第二遍、不另写一条**:它只做三件事 ——
|
|
7
|
+
* · 取行(或收下调用点已读到的行)并把行上的属主铸成 `DurableOwnerKey`(品牌铸点之一,见 `security.ts`);
|
|
8
|
+
* · 过判官,读不到 ⇒ `undefined` —— 与「没有这一行」**同一个值**,路由手里拿不到它无权看的行,也就没有第二种拒绝形可漏存在性;
|
|
9
|
+
* · operator 臂由调用点以闭集 {@link OwnerArm} 声明,这里统一并 `explicitOperatorOk`(此前各口手抄 `explicitOperatorOk(...) || owner === principal`)。
|
|
10
|
+
*
|
|
11
|
+
* ## 射程(第一期)
|
|
12
|
+
* 迁进来的口:leader 登记表的读与幂等重放、A2A `tasks/get`、preempt、审批豁免面;`request-guards.ts` 的 `runOwnerOk` 与提交撞键的回执函数
|
|
13
|
+
* (`submit-replay.ts`)经 {@link runRowReadable} 读同一只判官。其余按 run / 会话寻址的口(`runOwnerOk` 16 处、`sessionOwnerOk` 10 处)第二期整体换成
|
|
14
|
+
* {@link readOwnedRun} / {@link readOwnedSession} 并删两只 helper;裸 store 读口按文件计数钉在 `test/owner-gate-single-owner.test.ts`(增即红)。
|
|
15
|
+
*/
|
|
16
|
+
import type { ServiceConfig } from "../config-types.js";
|
|
17
|
+
import type { RunRecord } from "../plugins/store-contracts.js";
|
|
18
|
+
import { type OwnerAwareSessionStore, type Principal, type SessionCaller, type SessionOwnerCell } from "../security.js";
|
|
19
|
+
import { type IdentityWiring, type OperatorRoster } from "./principal-gate.js";
|
|
20
|
+
/** 调用点挂哪条臂(闭集):`owner` = 只有属主判官;`owner_or_operator` = 属主判官 ∨ 显式运维(`explicitOperatorOk`,唯一读法)。 */
|
|
21
|
+
export type OwnerArm = "owner" | "owner_or_operator";
|
|
22
|
+
/** 存取器读的配置格:判官要 `requirePrincipal`(C8 臂的单用户条件),operator 臂要运维名册。 */
|
|
23
|
+
export type OwnerAccessConfig = Pick<ServiceConfig, "requirePrincipal"> & OperatorRoster;
|
|
24
|
+
/**
|
|
25
|
+
* 一行 run 行的属主过判官。`owner`:串 = 有主,`null` = 无主(开放);**`undefined` = 属主格坏了**(型上是 `string | null`,盘上的 run.json 少了这个键时
|
|
26
|
+
* 运行期会读成缺席 —— 文件店的形判据不验它)⇒ 谁都读不到(fail-closed,不猜成无主;operator 臂照常并)。leader 登记行的 `owner` 是可选键、缺席 = 无主,
|
|
27
|
+
* 那是 leader 记录型自己的语义,由 {@link createLeaderRunVisibility} 在 leader 边界上显式折成 `null`,不在这里混读。
|
|
28
|
+
*/
|
|
29
|
+
export declare function runRowReadable(config: OwnerAccessConfig, principal: Principal | undefined, owner: string | null | undefined, arm: OwnerArm): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 按**会话**寻址的面上读一行 run 行(会话面板的上一腿 MCP 投影:读的是这只会话最新那条 run 的账本行):判官 = 会话面那一只(`sessionOwnerReadable`:
|
|
32
|
+
* dev-open 不钉人,与会话列表同读);run 行不是委派子代的 placed 会话行 ⇒ 无主时 `placed: false`(与 run 面对无主 run 的读法同)。
|
|
33
|
+
*/
|
|
34
|
+
export declare function runRowReadableOnSessionFace(w: IdentityWiring & {
|
|
35
|
+
readonly config: OwnerAccessConfig;
|
|
36
|
+
}, caller: SessionCaller, owner: string | null, arm: OwnerArm): boolean;
|
|
37
|
+
/** run 行读口:行 | `undefined`(没有这一行 ≡ 读不到,同一个值)。 */
|
|
38
|
+
export declare function readOwnedRun(config: OwnerAccessConfig, runStore: {
|
|
39
|
+
getRun(taskId: string): Promise<RunRecord | undefined>;
|
|
40
|
+
}, principal: Principal | undefined, taskId: string, arm: OwnerArm): Promise<RunRecord | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* 会话行读口:属主一读 + 无主时 placement 一格(`sessionOwnerCellOf`,S-1770)+ 会话面判官。`undefined` = 没有这只会话(`ownerOf` 答 `undefined`)≡ 读不到。
|
|
43
|
+
* 读回的那一格交给调用点(要按属主作答的口用它)。店的读失败照常抛(500,绝不当成「读不到」或「读得到」)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function readOwnedSession(w: IdentityWiring & {
|
|
46
|
+
readonly config: OwnerAccessConfig;
|
|
47
|
+
}, store: Pick<OwnerAwareSessionStore, "placementOf"> & {
|
|
48
|
+
ownerOf(sessionId: string): Promise<string | null | undefined>;
|
|
49
|
+
}, caller: SessionCaller, sessionId: string, arm: OwnerArm): Promise<SessionOwnerCell | undefined>;
|
|
50
|
+
/**
|
|
51
|
+
* leader 登记表的判官形(boot 装配一次,`createLeaderEndpoint` 的必填席)—— leader 模块不再自判属主(修前它手抄 `owner == null || owner === requester`,
|
|
52
|
+
* 缺 C8 窄互认臂而注称 mirrors runOwnerOk)。leader 腿的调用方身份经幂等身份结构(`IdemCaller.principal`,即 `gatedPrincipal` 的回值)转手而来,
|
|
53
|
+
* 这里是 `Principal` 的「上游已验」适配铸点(第二期随那只结构带品牌而删)。`config` 是活的配置对象(每次调用现读)。
|
|
54
|
+
*/
|
|
55
|
+
export declare function createLeaderRunVisibility(config: OwnerAccessConfig): (principal: string | null | undefined, owner: string | null | undefined) => boolean;
|
|
56
|
+
//# sourceMappingURL=owner-access.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mintDurableOwnerKey, mintPrincipal, sessionOwnerCellOf } from "../security.js";
|
|
2
|
+
import { explicitOperatorOk, runOwnerReadable, sessionOwnerReadable } from "./principal-gate.js";
|
|
3
|
+
function operatorArmHolds(config, principal, arm) {
|
|
4
|
+
switch (arm) {
|
|
5
|
+
case "owner":
|
|
6
|
+
return false;
|
|
7
|
+
case "owner_or_operator":
|
|
8
|
+
return explicitOperatorOk(principal, config);
|
|
9
|
+
default: {
|
|
10
|
+
const unknownArm = arm;
|
|
11
|
+
throw new Error(`owner access: unknown arm ${String(unknownArm)}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function runRowReadable(config, principal, owner, arm) {
|
|
16
|
+
if (operatorArmHolds(config, principal, arm))
|
|
17
|
+
return true;
|
|
18
|
+
if (owner === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
return runOwnerReadable(principal, owner === null ? null : mintDurableOwnerKey(owner), config);
|
|
21
|
+
}
|
|
22
|
+
export function runRowReadableOnSessionFace(w, caller, owner, arm) {
|
|
23
|
+
if (operatorArmHolds(w.config, caller.principal, arm))
|
|
24
|
+
return true;
|
|
25
|
+
const cell = owner === null ? { owner: null, placed: false } : { owner: mintDurableOwnerKey(owner) };
|
|
26
|
+
return sessionOwnerReadable(caller, cell, w);
|
|
27
|
+
}
|
|
28
|
+
export async function readOwnedRun(config, runStore, principal, taskId, arm) {
|
|
29
|
+
const row = await runStore.getRun(taskId);
|
|
30
|
+
return row !== undefined && runRowReadable(config, principal, row.owner, arm) ? row : undefined;
|
|
31
|
+
}
|
|
32
|
+
export async function readOwnedSession(w, store, caller, sessionId, arm) {
|
|
33
|
+
const owner = await store.ownerOf(sessionId);
|
|
34
|
+
if (owner === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const cell = await sessionOwnerCellOf(store, sessionId, owner);
|
|
37
|
+
return operatorArmHolds(w.config, caller.principal, arm) || sessionOwnerReadable(caller, cell, w) ? cell : undefined;
|
|
38
|
+
}
|
|
39
|
+
export function createLeaderRunVisibility(config) {
|
|
40
|
+
return (principal, owner) => runRowReadable(config, principal == null ? undefined : mintPrincipal(principal), owner ?? null, "owner");
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=owner-access.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import type { ServiceConfig } from "../config-types.js";
|
|
3
|
+
import { type DurableOwnerKey, type Principal, type SessionCaller, type SessionOwnerCell } from "../security.js";
|
|
3
4
|
/** Coerce a possibly-repeated request header to a single string (or undefined). */
|
|
4
5
|
export declare function headerStr(v: string | string[] | undefined): string | undefined;
|
|
5
6
|
export declare function safeEqual(a: string, b: string): boolean;
|
|
@@ -27,7 +28,7 @@ export type IdentitySource = (typeof IDENTITY_SOURCES)[number];
|
|
|
27
28
|
* 有可验身份时才是身份,零凭据下它只是谁都能写的字符串;而 JWT 身份不依赖静态 token 的在场。
|
|
28
29
|
*/
|
|
29
30
|
export declare function verifiedIdentitySource(req: IncomingMessage, config: ServiceConfig): IdentitySource | undefined;
|
|
30
|
-
export declare function gatedPrincipal(req: IncomingMessage, config: ServiceConfig):
|
|
31
|
+
export declare function gatedPrincipal(req: IncomingMessage, config: ServiceConfig): Principal | undefined;
|
|
31
32
|
/**
|
|
32
33
|
* 「**出示了凭证但验不过** ≠ **没出示**」在 **direct-door principal JWT** 面上的形 —— 本仓
|
|
33
34
|
* {@link bearerPresentedButUnverified} 早就是同一条律在 Bearer 面的形,这里只是把它推到另一面。
|
|
@@ -91,40 +92,81 @@ export declare function sendUnauthorized(res: ServerResponse, face: Unauthorized
|
|
|
91
92
|
* 放宽它是一次独立裁定。需要 operator 臂的读面在**自己的调用点**显式并上 {@link explicitOperatorOk} ——
|
|
92
93
|
* 那样「谁多给了 operator 一条路」在代码上看得见,而不是被偷偷塞进共享谓词里。
|
|
93
94
|
*/
|
|
94
|
-
export declare function runOwnerReadable(principal:
|
|
95
|
+
export declare function runOwnerReadable(principal: Principal | undefined, owner: DurableOwnerKey | null, config: Pick<ServiceConfig, "requirePrincipal">): boolean;
|
|
96
|
+
/** 「这台部署配了任何一把 service 凭证吗」—— fail-closed 写门族的真值源,也是身份来源 `service_token` 接没接线的那一句。**单一属主**:`handle()` 的
|
|
97
|
+
* 凭证门、[ref] 的 parked 赎回席、[ref] 的 consolidation 阀门启动期告警、以及下面 {@link wiredIdentitySources} 读同一句(手抄迟早只改一处,而这条判据
|
|
98
|
+
* 决定的是「无凭证部署上写口开不开」)。住在本叶(与 {@link systemFor} 同处)而不是 `dispatch.ts`:身份原语只依赖本叶。 */
|
|
99
|
+
export declare function hasServiceAuth(config: ServiceConfig): boolean;
|
|
100
|
+
/** {@link wiredIdentitySources} 读的装配:部署配置 + 入口预认证的鉴权桥(装了才挂身份;`FlatServiceDeps` 结构上满足)。 */
|
|
101
|
+
export interface IdentityWiring {
|
|
102
|
+
readonly config: ServiceConfig;
|
|
103
|
+
readonly webAdminJwtVerifier?: object | undefined;
|
|
104
|
+
}
|
|
95
105
|
/**
|
|
96
|
-
* 🔴
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* 会话面的属主谓词({@link sessionOwnerReadable})—— 于是「调用方是谁」在列表与单会话面上只有一只读法。
|
|
106
|
+
* 🔴 **「这台部署的装配能回哪几个身份来源」的唯一读法**({@link IDENTITY_SOURCES} 里接了线的那几个词,序同表)。两处读它、不各写一份:
|
|
107
|
+
* `/health.auth`(自报位,`http/health-self-report.ts`:`kinds` 与 `required` 同一次求值 —— `required` = 其中有 `service_token`)与 {@link devOpenDeployment}(门)
|
|
108
|
+
* —— 于是「这台部署认不认身份、门武没武装」在自报面与门上只有一只答案。
|
|
100
109
|
*/
|
|
101
|
-
export declare function
|
|
110
|
+
export declare function wiredIdentitySources(w: IdentityWiring): readonly IdentitySource[];
|
|
111
|
+
/**
|
|
112
|
+
* 🔴 **「这台部署有没有身份边界」的唯一判据**(S-1452;S-1509 改读身份来源)。dev-open = 装配**没接任何身份来源**({@link wiredIdentitySources} 为空:
|
|
113
|
+
* 没配 service token、没装鉴权桥、没开直连门)、**也没声明**只读 trace token 或 `REQUIRE_PRINCIPAL`:请求里没有任何东西替主体头作保,头是谁都能自报的
|
|
114
|
+
* **标签**(过滤 / 展示用),不是身份。装了鉴权桥的部署(SSO 单开)带登录令牌的调用方是验过的身份 ⇒ 不是 dev-open(修前只看 token / `REQUIRE_PRINCIPAL`,
|
|
115
|
+
* 这一形被读成 dev-open,任何人 fleet-wide 读全部会话)。
|
|
116
|
+
* 四处读它、不各写一份:会话列表的 fleet-wide 第一臂(`isFleetWide`)、会话写面的 fleet-wide 第一臂(`sessionOwnerScopeForWrite`)、
|
|
117
|
+
* 会话面的属主谓词({@link sessionOwnerReadable})、`/metrics` 族的免凭据臂(`dispatch.ts`)—— 于是「调用方是谁」在列表、单会话面与指标面上只有一只读法。
|
|
118
|
+
*/
|
|
119
|
+
export declare function devOpenDeployment(w: IdentityWiring): boolean;
|
|
120
|
+
/** 会话行属主门的调用方的唯一铸点({@link SessionCaller}):验过的主体 + 是不是 fleet 调用方 —— {@link devOpenDeployment} 上的任何调用方,
|
|
121
|
+
* 或出示了这台部署的 service 凭据(`systemFor`)、不报主体的调用方(带主体头的是那位主体,不是 fleet;只读 trace token 不是 service 凭据)。 */
|
|
122
|
+
export declare function sessionCallerOf(req: IncomingMessage, w: IdentityWiring): SessionCaller;
|
|
102
123
|
/**
|
|
103
124
|
* **「这个调用方能不能动这只会话」的唯一谓词**(会话面:视图 / head / 事件流 / 记忆状态与自助抹除 / 改名置顶 / 后台任务 / MCP 重连 /
|
|
104
|
-
* 面板的上一腿 MCP 投影)
|
|
105
|
-
*
|
|
125
|
+
* 面板的上一腿 MCP 投影)。没有身份边界的部署({@link devOpenDeployment})上不钉任何人(与会话列表同读,列表把这只会话列给谁,谁就读得到它);
|
|
126
|
+
* 有身份边界的部署上:
|
|
127
|
+
* · **无主的行**经无主臂的唯一判据 `ownerlessRowOpen`(`security.ts`):普通会话照旧对任何调用方开放;委派子代的 placed 行只对 fleet 调用方
|
|
128
|
+
* ({@link sessionCallerOf})开放 —— 任何具名主体、没有 service 凭据的无身份调用方都与别人的行同体(调用点答 404)(S-1770)。
|
|
129
|
+
* 代价如实:属主还没定下的子代行连它将来的属主也暂时读不到(由一次性迁移 M23 / 那一行的下一次停驻定下);
|
|
130
|
+
* · 有主的行就是 run 面那一条谓词({@link runOwnerReadable}),一字不变。
|
|
106
131
|
* run 面(poll / events / cancel …)不读本谓词 —— 那是 run 资源的门,另一只。
|
|
107
132
|
*/
|
|
108
|
-
export declare function sessionOwnerReadable(
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
export declare function sessionOwnerReadable(caller: SessionCaller, cell: SessionOwnerCell, w: IdentityWiring): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 运维名册 —— 「谁是 operator」读的两格(都住在部署配置里):具名名单 `OPERATOR_PRINCIPALS` 与单用户形的显式声明 `OPERATOR_SINGLE_USER`。
|
|
136
|
+
* 两者互斥(声明只在单用户形、名单为空时成立;否则拒启 —— 一个事实一个来源,`config-invariants.ts` 的 `operator-single-user`)。
|
|
137
|
+
*/
|
|
138
|
+
export type OperatorRoster = Pick<ServiceConfig, "operatorPrincipals" | "operatorSingleUser">;
|
|
139
|
+
/**
|
|
140
|
+
* 🔴 **「谁是 operator」的唯一读法**(S-1050,[ref] ① 裁 A;IMAGE-API-DESIGN.md §P2.4a MUST-FIX 的那一只门)。
|
|
141
|
+
* · 名单为空 ⇒ **没人是**(没有任何形把「空名单」读成「人人是」—— 那条读法 `isOperator` 已删);
|
|
142
|
+
* · 名单非空 ⇒ 验过的主体在名单里才是;
|
|
143
|
+
* · 单用户形显式声明 `OPERATOR_SINGLE_USER=true` ⇒ 这台部署的**每个调用方**都是(单用户形只有一位用户,能到这台部署的就是他;边界是部署自己的
|
|
144
|
+
* 凭据门 —— 没配凭据的部署上,能连上端口的都是)。声明只在单用户形成立(起服不变量)。
|
|
145
|
+
* `principal` 必须是验过的身份(`gatedPrincipal`),绝不是自述头。全部运维面(审批队列、steer.trusted、记忆运维口、bake 门……)读这一只;
|
|
146
|
+
* 🔴 SINGLE mint point (E1):不要再造兄弟。
|
|
147
|
+
*/
|
|
148
|
+
export declare function explicitOperatorOk(principal: string | undefined, roster: OperatorRoster): boolean;
|
|
149
|
+
/** 「这台部署**有没有**运维」的唯一读法(名单非空 ∨ 单用户声明在场)—— 能力事实 `operatorLane`、整理阀门的可达性告警、起服提示同读这一只。 */
|
|
150
|
+
export declare function operatorRosterPresent(roster: OperatorRoster): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* 起服提示(S-1050):单用户形(`REQUIRE_PRINCIPAL` 未开)+ 没有运维名册 + 这台部署有审批底座 ⇒ 一行 warn。这一形在「空名单 = 人人是」那条读法退役之后
|
|
153
|
+
* 丢的东西就是审批队列的运维视图(跨 scope 列表 / `?owner=` / 无主体调用方的整个队列),补回它只要一行配置 —— 不拒启:升级那一拍打掉一台今天跑得好好的
|
|
154
|
+
* 单用户机器比一条提示重。多租形不提示(它另有拒启不变量);没有审批底座的形什么都没少。
|
|
155
|
+
*/
|
|
156
|
+
export declare function buildOperatorUndeclaredNotice(config: OperatorRoster & Pick<ServiceConfig, "requirePrincipal">, approvalFaceWired: boolean): {
|
|
157
|
+
event: "operator_undeclared_single_user";
|
|
158
|
+
fields: {
|
|
159
|
+
detail: string;
|
|
160
|
+
};
|
|
161
|
+
} | undefined;
|
|
116
162
|
/** operator 面族在「名单为空」这一形上的**唯一**拒发口:事实 `operatorLane`(`capability-facts.ts`)为假 ⇒ 这一面对任何
|
|
117
163
|
* 身份都打不通 = 这台部署上不可用 ⇒ 501,不是鉴权拒(403 只留给「名单非空而你不在名单上」)。能力位读的是同一只事实。 */
|
|
118
164
|
export declare function sendOperatorPrincipalsRequired(res: ServerResponse): void;
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* just because OPERATOR_PRINCIPALS is unset). Adversarial-review HIGH: `isOperator([], p)=true` made
|
|
127
|
-
* `latestPublished(..., {operator:true})` bypass tenant visibility for any caller on an operator-less deployment.
|
|
128
|
-
* (The byte-identical `explicitOperator` twin that used to live here was folded into `explicitOperatorOk` above —
|
|
129
|
-
* one judgment, one mint point.) */
|
|
165
|
+
/**
|
|
166
|
+
* 「这台部署没有运维名册」时**唯一**的出路句 —— 与 {@link operatorRosterPresent} 同一对旋钮,所以句子不比事实少说一条出路:
|
|
167
|
+
* 名单 `OPERATOR_PRINCIPALS`(具名运维;多租形只有这一条),或单用户形的显式声明 `OPERATOR_SINGLE_USER=true`(只在 `REQUIRE_PRINCIPAL` 未开且名单为空时成立,
|
|
168
|
+
* 否则起服拒 —— 句子把它限定在单用户部署上)。拒发口 {@link sendOperatorPrincipalsRequired}、能力事实闭集 `operator_principals_empty` 的义、记忆整理阀门的起服告警
|
|
169
|
+
* 都说这一句,别处不再各写一份。
|
|
170
|
+
*/
|
|
171
|
+
export declare function buildOperatorRosterWayOut(): string;
|
|
130
172
|
//# sourceMappingURL=principal-gate.d.ts.map
|