@sema-agent/server 7.147.0 → 7.149.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 +1468 -24
- package/README.md +35 -7
- package/README.zh-CN.md +18 -8
- package/USAGE.md +444 -193
- package/deploy/sema-up/README.md +16 -5
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/_helpers.tpl +20 -4
- package/deploy/sema-up/chart/values.yaml +3 -2
- package/deploy/sema-up/cluster-up.sh +74 -176
- package/deploy/sema-up/kube-up.sh +29 -49
- package/deploy/sema-up/lib/chart-run.sh +23 -0
- package/deploy/sema-up/lib/dataroot.sh +3 -3
- package/deploy/sema-up/lib/health.sh +62 -13
- package/deploy/sema-up/lib/helm-values-cluster.py +18 -0
- package/deploy/sema-up/lib/helm-values-kube.py +35 -0
- package/deploy/sema-up/lib/regcred.py +8 -0
- package/deploy/sema-up/lib/remote/helm-install.sh +3 -0
- package/deploy/sema-up/lib/remote/image-import.sh +6 -0
- package/deploy/sema-up/lib/remote/machine-precheck.sh +11 -0
- package/deploy/sema-up/lib/remote/region-probe.sh +3 -0
- package/deploy/sema-up/lib/remote/stack-ready.sh +26 -0
- package/deploy/sema-up/lib/remote/vxlan-guard.sh +8 -0
- package/deploy/sema-up/lib/render-stack.py +17 -0
- package/deploy/sema-up/lib/shell-text.sh +87 -0
- package/deploy/sema-up/lib/usage-flags.txt +10 -0
- package/deploy/sema-up/lib/usage-head.txt +1 -0
- package/deploy/sema-up/lib/usage-tail.txt +13 -0
- package/deploy/sema-up/preflight.sh +10 -8
- package/deploy/sema-up/sema-up.sh +14 -39
- package/deploy/sema-up/smoke.sh +7 -6
- package/deploy/sema-up/stack/compose.dataroot.yaml +3 -0
- package/deploy/sema-up/stack/compose.yaml +13 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +21 -0
- package/dist/adoption/plan.d.ts +24 -0
- package/dist/adoption/plan.js +53 -1
- package/dist/adoption/runner.d.ts +10 -1
- package/dist/adoption/runner.js +36 -16
- package/dist/approval-card.d.ts +36 -38
- package/dist/approval-gate-currency.js +3 -2
- package/dist/approval-leg-origin.d.ts +33 -0
- package/dist/approval-leg-origin.js +4 -0
- package/dist/approval-reconciler.d.ts +4 -13
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.d.ts +13 -11
- package/dist/approval.js +3 -3
- package/dist/audit.d.ts +10 -3
- package/dist/audit.js +15 -7
- package/dist/auth-bridge.d.ts +9 -15
- package/dist/auth-bridge.js +4 -11
- package/dist/auth-keys.d.ts +10 -1
- package/dist/auth-keys.js +8 -0
- package/dist/auto-mode-face.d.ts +10 -7
- package/dist/auto-mode-face.js +7 -4
- package/dist/background-agent-name.d.ts +19 -1
- package/dist/background-agent-name.js +12 -2
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.js +9 -6
- package/dist/bench/s1/arms.js +6 -5
- package/dist/bench/s1/live-deps.js +5 -2
- package/dist/bench/s1/run-firm.js +6 -5
- package/dist/bind-host.d.ts +25 -0
- package/dist/bind-host.js +25 -0
- package/dist/boot/adoption.d.ts +3 -0
- package/dist/boot/adoption.js +1 -0
- package/dist/boot/deployment-mods.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +17 -7
- package/dist/boot/execution-env.js +47 -42
- package/dist/boot/execution-lane.d.ts +6 -4
- package/dist/boot/execution-lane.js +3 -1
- package/dist/boot/exit-boundary.d.ts +2 -2
- package/dist/boot/exit-boundary.js +6 -5
- package/dist/boot/fatal-exit.d.ts +3 -5
- package/dist/boot/fatal-exit.js +2 -2
- package/dist/boot/leader.d.ts +15 -0
- package/dist/boot/leader.js +17 -15
- package/dist/boot/memory-consolidation.d.ts +37 -29
- package/dist/boot/memory-consolidation.js +11 -5
- package/dist/boot/org-delivery.d.ts +3 -2
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/parked-revive-gate.js +2 -2
- package/dist/boot/reapers.d.ts +4 -3
- package/dist/boot/reapers.js +19 -16
- package/dist/boot/resolve-spec.d.ts +5 -3
- package/dist/boot/resolve-spec.js +60 -70
- package/dist/boot/retention-lane.d.ts +4 -4
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +28 -7
- package/dist/boot/runner-deps.js +14 -5
- package/dist/boot/runtime-caps.d.ts +2 -2
- package/dist/boot/runtime-caps.js +16 -2
- package/dist/boot/session-faces.d.ts +16 -7
- package/dist/boot/session-faces.js +114 -94
- package/dist/boot/shutdown.d.ts +5 -4
- package/dist/boot/shutdown.js +6 -4
- package/dist/boot/stage-01-config.d.ts +1 -0
- package/dist/boot/stage-01-config.js +13 -4
- package/dist/boot/stage-02-web-admin-pull.d.ts +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +16 -3
- package/dist/boot/stage-03-store-backend.d.ts +4 -0
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +3 -0
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +8 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +12 -13
- package/dist/boot/stage-06-runners.js +23 -15
- package/dist/boot/stage-07-capability-layer.d.ts +13 -9
- package/dist/boot/stage-07-capability-layer.js +5 -3
- package/dist/boot/stage-08-reapers.d.ts +13 -9
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +14 -16
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +14 -16
- package/dist/boot/stage-10-http-server.js +7 -4
- package/dist/boot/store-evidence.d.ts +20 -0
- package/dist/boot/store-evidence.js +13 -0
- package/dist/boot/stores.d.ts +6 -0
- package/dist/boot/stores.js +41 -27
- package/dist/boot/task-list-lane.d.ts +4 -4
- package/dist/boot/web-admin.d.ts +4 -2
- package/dist/boot/web-admin.js +55 -35
- package/dist/boot/webfetch-summarize-lane.d.ts +1 -1
- package/dist/boot-reclaim.d.ts +3 -1
- package/dist/boot-reclaim.js +1 -1
- package/dist/brain.d.ts +7 -18
- package/dist/brain.js +5 -17
- package/dist/budget.js +6 -6
- package/dist/capabilities/center-plugins.d.ts +7 -1
- package/dist/capabilities/center-plugins.js +32 -10
- package/dist/capabilities/center-wiring.js +1 -1
- package/dist/capabilities/composite-members.d.ts +2 -2
- package/dist/capabilities/composite-members.js +2 -2
- package/dist/capabilities/repo-tools.d.ts +2 -0
- package/dist/capabilities/repo-tools.js +14 -12
- package/dist/capabilities/scenarios.d.ts +6 -15
- package/dist/capabilities/scenarios.js +11 -16
- package/dist/capabilities/skills.d.ts +1 -1
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +39 -11
- package/dist/capability-facts.js +35 -7
- package/dist/card-settle-stored-scope.d.ts +56 -0
- package/dist/card-settle-stored-scope.js +27 -0
- package/dist/card-void.d.ts +8 -13
- package/dist/card-void.js +2 -7
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +7 -3
- package/dist/config-catalog.d.ts +28 -1
- package/dist/config-catalog.js +95 -85
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +43 -3
- package/dist/config-invariants.js +69 -5
- package/dist/config-lkg.d.ts +23 -1
- package/dist/config-lkg.js +17 -3
- package/dist/config-provider.d.ts +9 -9
- package/dist/config-provider.js +25 -110
- package/dist/config-pull-failure.d.ts +50 -0
- package/dist/config-pull-failure.js +48 -0
- package/dist/config-types.d.ts +62 -21
- package/dist/config.d.ts +14 -21
- package/dist/config.js +141 -64
- package/dist/context-window-notice.d.ts +31 -0
- package/dist/context-window-notice.js +28 -0
- package/dist/delegated-session-owner.d.ts +1 -1
- package/dist/deleted-session-ids.d.ts +3 -2
- package/dist/deployment-governance.d.ts +3 -3
- package/dist/deployment-shape.d.ts +46 -11
- package/dist/deployment-shape.js +8 -0
- package/dist/egress-redirect.d.ts +25 -7
- package/dist/egress-redirect.js +20 -2
- package/dist/elicitation.d.ts +6 -5
- package/dist/elicitation.js +23 -22
- package/dist/engine-identity.d.ts +28 -0
- package/dist/engine-identity.js +10 -0
- package/dist/entry-problems.d.ts +5 -7
- package/dist/entry-problems.js +1 -1
- package/dist/env-facts.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +6 -5
- package/dist/env-name-allowlist-knobs.js +5 -0
- package/dist/env-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-lane-caps.d.ts +25 -23
- package/dist/execution-lane-caps.js +18 -26
- package/dist/execution-placement.d.ts +58 -18
- package/dist/execution-placement.js +41 -2
- package/dist/field-conflict.d.ts +7 -11
- package/dist/field-conflict.js +3 -3
- package/dist/file-history-capture.d.ts +3 -3
- package/dist/file-history-disclosure.js +1 -0
- package/dist/fleet/fleet-bus.d.ts +21 -3
- package/dist/fleet/fleet-bus.js +35 -25
- package/dist/fleet/fleet-reconciler.js +2 -2
- package/dist/fleet/serving-lease.js +3 -3
- package/dist/fleet-client.js +3 -3
- package/dist/fleet-lease.d.ts +0 -1
- package/dist/fleet-lease.js +4 -5
- package/dist/history-anchor.d.ts +23 -3
- package/dist/history-anchor.js +24 -4
- package/dist/hitl-delivery.d.ts +90 -0
- package/dist/hitl-delivery.js +98 -0
- package/dist/hooks/classic-stations.d.ts +8 -11
- package/dist/hooks/classic-stations.js +0 -7
- package/dist/hooks/command-spawn.d.ts +7 -2
- package/dist/hooks/command-spawn.js +13 -6
- package/dist/hooks/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +72 -57
- package/dist/hooks/hook-runner.js +271 -193
- package/dist/host-lsp-manager.d.ts +22 -8
- package/dist/host-lsp-manager.js +4 -1
- package/dist/http/active-run-conflict.d.ts +2 -43
- package/dist/http/active-run-conflict.js +3 -7
- package/dist/http/admission.d.ts +4 -18
- package/dist/http/admission.js +76 -79
- package/dist/http/approval-sweeps.d.ts +3 -3
- package/dist/http/approval-sweeps.js +56 -31
- package/dist/http/caller-trust.d.ts +8 -10
- package/dist/http/caller-trust.js +1 -2
- package/dist/http/claim-heartbeat.d.ts +49 -0
- package/dist/http/claim-heartbeat.js +46 -0
- package/dist/http/claimed-run.d.ts +16 -8
- package/dist/http/claimed-run.js +8 -0
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +78 -30
- package/dist/http/durable-run-leg.d.ts +11 -4
- package/dist/http/durable-run-leg.js +45 -21
- package/dist/http/execution-context.d.ts +122 -47
- package/dist/http/execution-context.js +135 -43
- package/dist/http/health-reader.d.ts +36 -0
- package/dist/http/health-reader.js +21 -0
- package/dist/http/health-self-report.d.ts +9 -9
- package/dist/http/health-self-report.js +4 -4
- package/dist/http/idempotency.d.ts +9 -5
- package/dist/http/idempotency.js +4 -4
- package/dist/http/memory-compliance-failure-reply.d.ts +15 -16
- package/dist/http/memory-compliance-failure-reply.js +4 -2
- package/dist/http/memory-face-fault-reply.d.ts +67 -0
- package/dist/http/memory-face-fault-reply.js +71 -0
- package/dist/http/memory-store-refusal-reply.d.ts +1 -1
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +392 -67
- package/dist/http/owner-access.js +370 -35
- package/dist/http/principal-gate.d.ts +39 -89
- package/dist/http/principal-gate.js +26 -68
- package/dist/http/refusal-body.d.ts +35 -2
- package/dist/http/refusal-body.js +34 -0
- package/dist/http/request-guards.d.ts +9 -13
- package/dist/http/request-guards.js +34 -68
- package/dist/http/resume-composition.d.ts +37 -0
- package/dist/http/resume-composition.js +18 -0
- package/dist/http/resume-ctx-read.d.ts +46 -12
- package/dist/http/resume-ctx-read.js +31 -6
- package/dist/http/resume-legs.d.ts +54 -19
- package/dist/http/resume-legs.js +408 -196
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/route-ctx.d.ts +31 -32
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +60 -37
- package/dist/http/routes/admin-config-refresh.js +2 -2
- package/dist/http/routes/admin-drain.js +2 -2
- package/dist/http/routes/admin-memory-optout.js +4 -3
- package/dist/http/routes/adoption.d.ts +3 -0
- package/dist/http/routes/adoption.js +17 -10
- package/dist/http/routes/agents-roster.js +13 -7
- package/dist/http/routes/approvals-assistant.js +73 -67
- package/dist/http/routes/attachments.js +2 -2
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +9 -17
- package/dist/http/routes/capabilities.js +16 -19
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.d.ts +3 -3
- package/dist/http/routes/devices.js +4 -4
- package/dist/http/routes/diagnostics.d.ts +29 -3
- package/dist/http/routes/diagnostics.js +49 -18
- package/dist/http/routes/engine.js +2 -2
- package/dist/http/routes/fleet.js +5 -3
- package/dist/http/routes/images.js +10 -6
- package/dist/http/routes/leader.d.ts +7 -2
- package/dist/http/routes/leader.js +12 -3
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +7 -15
- package/dist/http/routes/memory-bundle.js +4 -7
- package/dist/http/routes/memory-compliance.js +4 -4
- package/dist/http/routes/memory-consolidation.js +6 -9
- package/dist/http/routes/memory-origin.d.ts +2 -0
- package/dist/http/routes/memory-origin.js +7 -8
- package/dist/http/routes/memory-policy.js +17 -12
- package/dist/http/routes/notify-wake.js +10 -19
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/principal-inbox.d.ts +4 -2
- package/dist/http/routes/principal-inbox.js +5 -4
- package/dist/http/routes/projects.d.ts +1 -1
- package/dist/http/routes/projects.js +3 -2
- package/dist/http/routes/retention-ops.js +6 -9
- package/dist/http/routes/rules.js +20 -5
- package/dist/http/routes/run-memory-capture.d.ts +2 -2
- package/dist/http/routes/run-memory-capture.js +6 -12
- package/dist/http/routes/run-permission-mode.d.ts +2 -2
- package/dist/http/routes/run-permission-mode.js +10 -17
- package/dist/http/routes/runs.js +155 -237
- package/dist/http/routes/session-memory-sync.d.ts +2 -2
- package/dist/http/routes/session-memory-sync.js +7 -13
- package/dist/http/routes/session-sync.d.ts +28 -7
- package/dist/http/routes/session-sync.js +63 -50
- package/dist/http/routes/sessions-list.d.ts +3 -3
- package/dist/http/routes/sessions-list.js +9 -9
- package/dist/http/routes/sessions.js +87 -124
- package/dist/http/routes/shared-memory.js +6 -6
- package/dist/http/routes/side-query.js +2 -2
- package/dist/http/routes/tasks.js +237 -187
- package/dist/http/routes/trace-usage.d.ts +0 -12
- package/dist/http/routes/trace-usage.js +40 -46
- package/dist/http/routes/workflows.d.ts +39 -4
- package/dist/http/routes/workflows.js +42 -14
- package/dist/http/run-concurrency-cap.d.ts +20 -12
- package/dist/http/run-concurrency-cap.js +39 -26
- package/dist/http/run-read-face.d.ts +3 -5
- package/dist/http/run-read-face.js +8 -13
- package/dist/http/send.d.ts +12 -3
- package/dist/http/send.js +42 -6
- package/dist/http/server.d.ts +43 -45
- package/dist/http/server.js +61 -11
- package/dist/http/sse-log.d.ts +17 -10
- package/dist/http/sse-log.js +7 -7
- package/dist/http/stored-body-replay.d.ts +12 -0
- package/dist/http/stored-body-replay.js +2 -2
- package/dist/http/submit-ctx.d.ts +17 -8
- package/dist/http/submit-ctx.js +8 -5
- package/dist/http/submit-replay.d.ts +19 -6
- package/dist/http/submit-replay.js +18 -6
- package/dist/http/sync-submit-body.d.ts +3 -4
- package/dist/http/sync-submit-body.js +4 -5
- package/dist/http/wire-types.d.ts +4 -3
- package/dist/identity-source.d.ts +36 -5
- package/dist/identity-source.js +27 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/key-resolver.d.ts +32 -0
- package/dist/key-resolver.js +23 -9
- package/dist/leader/diffup.js +2 -1
- package/dist/leader/endpoint.d.ts +26 -5
- package/dist/leader/endpoint.js +154 -14
- package/dist/leader/fanout.d.ts +3 -0
- package/dist/leader/fanout.js +78 -63
- package/dist/leader/leader.d.ts +16 -0
- package/dist/leader/leader.js +43 -3
- package/dist/leader/merge.d.ts +9 -1
- package/dist/leader/merge.js +16 -1
- package/dist/leader/repair-wire.js +1 -1
- package/dist/leader/wire.d.ts +36 -3
- package/dist/leader/wire.js +59 -18
- package/dist/leg-facts.d.ts +7 -2
- package/dist/leg-facts.js +1 -0
- package/dist/local-store-declaration.d.ts +54 -0
- package/dist/local-store-declaration.js +59 -0
- package/dist/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/mcp-assertion-header.js +1 -1
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-project-layer.js +1 -1
- package/dist/memory-scope.d.ts +33 -6
- package/dist/memory-scope.js +68 -19
- package/dist/memory-store-refusal.d.ts +5 -2
- package/dist/memory-sync-client.d.ts +3 -2
- package/dist/memory-sync-client.js +8 -5
- package/dist/model-compat.d.ts +17 -8
- package/dist/model-compat.js +6 -2
- package/dist/model-context-window.d.ts +57 -0
- package/dist/model-context-window.js +21 -0
- package/dist/model-entry-headers.d.ts +46 -4
- package/dist/model-entry-headers.js +2 -2
- package/dist/model-entry-refusal.d.ts +40 -20
- package/dist/model-entry-refusal.js +57 -30
- package/dist/model-plane-face.d.ts +19 -11
- package/dist/model-plane-face.js +9 -1
- package/dist/model-plane-probe.d.ts +2 -0
- package/dist/model-plane-probe.js +17 -0
- package/dist/model-provider.d.ts +3 -3
- package/dist/model-reach-scope.d.ts +2 -1
- package/dist/model-route-endpoint.d.ts +9 -5
- package/dist/model-route-endpoint.js +29 -7
- package/dist/model-select.d.ts +16 -0
- package/dist/model-select.js +4 -0
- package/dist/mountinfo.d.ts +37 -0
- package/dist/mountinfo.js +47 -0
- package/dist/namespaced-rule-name.d.ts +23 -14
- package/dist/namespaced-rule-name.js +8 -11
- package/dist/net-address.d.ts +1 -1
- package/dist/observability/corrupt-read-seat.d.ts +4 -4
- package/dist/observability/corrupt-read-seat.js +5 -3
- package/dist/observability/fail-open.d.ts +72 -40
- package/dist/observability/fail-open.js +74 -40
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.js +4 -5
- package/dist/observability/otel-exporter.js +2 -1
- package/dist/observability/principal-context.d.ts +14 -7
- package/dist/observability/principal-context.js +8 -3
- package/dist/observability/run-terminal.d.ts +7 -1
- package/dist/observability/run-terminal.js +6 -2
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +1 -0
- package/dist/orchestration/hardened-vm-runner.js +11 -5
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +0 -14
- package/dist/orchestration/hardened-vm-worker-runner.js +5 -0
- package/dist/orchestration/hardened-vm-worker.js +2 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.js +3 -2
- package/dist/org-delivery-gate.d.ts +36 -10
- package/dist/org-delivery-gate.js +12 -8
- package/dist/outbound-dispatcher.d.ts +1 -1
- package/dist/outbound-dispatcher.js +6 -12
- package/dist/owner-brands.d.ts +81 -0
- package/dist/owner-brands.js +42 -0
- package/dist/owner-faces.d.ts +532 -0
- package/dist/owner-faces.js +126 -0
- package/dist/park-row-commit.d.ts +67 -0
- package/dist/park-row-commit.js +76 -0
- package/dist/parked-decide.d.ts +76 -12
- package/dist/parked-decide.js +152 -11
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +7 -9
- package/dist/peer-directory.js +3 -2
- package/dist/permission-rule-vocab.d.ts +53 -8
- package/dist/permission-rule-vocab.js +30 -2
- package/dist/plugins/adoption-log-sql.d.ts +3 -25
- package/dist/plugins/adoption-log-sql.js +23 -21
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.d.ts +7 -0
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.js +17 -0
- package/dist/plugins/approval-ask-store-file.d.ts +18 -7
- package/dist/plugins/approval-ask-store-file.js +37 -14
- package/dist/plugins/approval-ask-store-memory.d.ts +12 -4
- package/dist/plugins/approval-ask-store-memory.js +24 -10
- package/dist/plugins/approval-ask-store-sql.d.ts +40 -21
- package/dist/plugins/approval-ask-store-sql.js +44 -15
- package/dist/plugins/approval-exemption-skill-cutoff.d.ts +64 -0
- package/dist/plugins/approval-exemption-skill-cutoff.js +122 -0
- package/dist/plugins/approval-exemption-skill-m46.d.ts +14 -0
- package/dist/plugins/approval-exemption-skill-m46.js +21 -0
- package/dist/plugins/approval-exemption-store.d.ts +32 -2
- package/dist/plugins/approval-exemption-store.js +42 -19
- package/dist/plugins/approval-nonce-store.d.ts +39 -12
- package/dist/plugins/approval-nonce-store.js +72 -23
- package/dist/plugins/blob-backend.d.ts +2 -0
- package/dist/plugins/blob-backend.js +9 -6
- package/dist/plugins/caching-session-store.d.ts +13 -1
- package/dist/plugins/caching-session-store.js +43 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +32 -5
- package/dist/plugins/checkpoint-index-columns.js +36 -1
- package/dist/plugins/checkpoint-store-face.d.ts +83 -10
- package/dist/plugins/checkpoint-store-face.js +18 -1
- package/dist/plugins/device-store-sql.js +1 -0
- package/dist/plugins/ensure-index.d.ts +13 -1
- package/dist/plugins/ensure-index.js +154 -21
- package/dist/plugins/ensure-schema-lock-policy.d.ts +36 -18
- package/dist/plugins/ensure-schema-lock-policy.js +76 -9
- package/dist/plugins/file-run-store.d.ts +85 -32
- package/dist/plugins/file-run-store.js +177 -94
- package/dist/plugins/host-platform.d.ts +24 -3
- package/dist/plugins/host-platform.js +15 -1
- package/dist/plugins/image-bake-store-sql.js +2 -0
- package/dist/plugins/imported-layer-root-retirement.d.ts +2 -2
- package/dist/plugins/k8s-pod-reaper.d.ts +1 -3
- package/dist/plugins/k8s-pod-reaper.js +0 -1
- package/dist/plugins/leader-run-store-sql.d.ts +22 -0
- package/dist/plugins/leader-run-store-sql.js +34 -4
- package/dist/plugins/local-checkpoint-store.d.ts +62 -23
- package/dist/plugins/local-checkpoint-store.js +197 -77
- package/dist/plugins/local-data-dir-modes-m39.js +2 -1
- package/dist/plugins/local-data-root-admission.d.ts +52 -0
- package/dist/plugins/local-data-root-admission.js +100 -0
- package/dist/plugins/local-docker-capacity.d.ts +93 -0
- package/dist/plugins/local-docker-capacity.js +194 -0
- package/dist/plugins/local-docker-reaper.d.ts +92 -0
- package/dist/plugins/local-docker-reaper.js +102 -0
- package/dist/plugins/local-engine-high-water.d.ts +29 -6
- package/dist/plugins/local-engine-high-water.js +27 -19
- package/dist/plugins/local-session-store.d.ts +458 -140
- package/dist/plugins/local-session-store.js +906 -292
- package/dist/plugins/local-session-window.d.ts +3 -2
- package/dist/plugins/local-session-window.js +3 -2
- package/dist/plugins/local-sidecar-quarantine.js +3 -2
- package/dist/plugins/local-task-attachment-store.d.ts +18 -1
- package/dist/plugins/local-task-attachment-store.js +22 -1
- package/dist/plugins/memory-embedder.js +9 -7
- package/dist/plugins/memory-engine-pg.d.ts +3 -2
- package/dist/plugins/memory-engine-pg.js +14 -5
- package/dist/plugins/memory-engine-sql-apply.d.ts +8 -4
- package/dist/plugins/memory-engine-sql-apply.js +6 -8
- package/dist/plugins/memory-engine-tidb.d.ts +4 -2
- package/dist/plugins/memory-engine-tidb.js +11 -2
- package/dist/plugins/memory-optout-grant-store-sql.d.ts +1 -1
- package/dist/plugins/memory-optout-grant-store-sql.js +3 -3
- package/dist/plugins/memory-run-store.d.ts +53 -36
- package/dist/plugins/memory-run-store.js +116 -88
- package/dist/plugins/one-time-migration-marker.d.ts +26 -0
- package/dist/plugins/one-time-migration-marker.js +13 -0
- package/dist/plugins/one-time-migrations.d.ts +214 -47
- package/dist/plugins/one-time-migrations.js +481 -135
- package/dist/plugins/org-delivery-quota-store.d.ts +34 -11
- package/dist/plugins/org-delivery-quota-store.js +31 -15
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +5 -64
- package/dist/plugins/permission-rule-store-sql.js +11 -95
- package/dist/plugins/pg-pool.d.ts +2 -32
- package/dist/plugins/pg-pool.js +24 -17
- package/dist/plugins/remote-env-device.d.ts +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +8 -32
- package/dist/plugins/remote-env-e2b.js +44 -32
- package/dist/plugins/remote-env-host.d.ts +51 -17
- package/dist/plugins/remote-env-host.js +111 -42
- package/dist/plugins/remote-env-k8s.d.ts +40 -45
- package/dist/plugins/remote-env-k8s.js +111 -60
- package/dist/plugins/remote-env-local-docker.d.ts +152 -15
- package/dist/plugins/remote-env-local-docker.js +352 -72
- package/dist/plugins/remote-scratchpad.js +4 -0
- package/dist/plugins/retention-deployment.d.ts +49 -17
- package/dist/plugins/retention-deployment.js +39 -8
- package/dist/plugins/run-preview-m45.d.ts +11 -0
- package/dist/plugins/run-preview-m45.js +19 -0
- package/dist/plugins/run-store-sql.d.ts +82 -75
- package/dist/plugins/run-store-sql.js +164 -125
- package/dist/plugins/s3-answer.d.ts +2 -1
- package/dist/plugins/sandbox-reaper.d.ts +26 -0
- package/dist/plugins/sandbox-reaper.js +2 -0
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +56 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +56 -0
- package/dist/plugins/scheduler-support.d.ts +16 -1
- package/dist/plugins/scheduler-support.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +131 -14
- package/dist/plugins/schema-consistency.js +388 -18
- package/dist/plugins/schema-drift-sentence.d.ts +10 -6
- package/dist/plugins/schema-drift-sentence.js +15 -7
- package/dist/plugins/schema-ensure-legs.d.ts +9 -0
- package/dist/plugins/schema-ensure-legs.js +1 -1
- package/dist/plugins/schema-indexes.js +3 -0
- package/dist/plugins/schema-live-columns.d.ts +14 -5
- package/dist/plugins/schema-live-columns.js +10 -10
- package/dist/plugins/send-user-file.js +2 -1
- package/dist/plugins/session-birth.d.ts +37 -0
- package/dist/plugins/session-birth.js +38 -0
- package/dist/plugins/session-epoch-anchor.d.ts +40 -12
- package/dist/plugins/session-epoch-anchor.js +33 -11
- package/dist/plugins/session-ext-table.d.ts +27 -3
- package/dist/plugins/session-ext-table.js +19 -6
- package/dist/plugins/session-fork.d.ts +15 -1
- package/dist/plugins/session-fork.js +3 -0
- package/dist/plugins/session-ownership.d.ts +1 -1
- package/dist/plugins/session-placement.d.ts +27 -20
- package/dist/plugins/session-placement.js +15 -12
- package/dist/plugins/session-row-sql.d.ts +12 -0
- package/dist/plugins/session-row-sql.js +3 -3
- package/dist/plugins/session-run-rollup.d.ts +29 -0
- package/dist/plugins/session-run-rollup.js +40 -0
- package/dist/plugins/session-store-sql.d.ts +38 -12
- package/dist/plugins/session-store-sql.js +130 -30
- package/dist/plugins/session-withdraw-sql.d.ts +36 -0
- package/dist/plugins/session-withdraw-sql.js +42 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +0 -69
- package/dist/plugins/shared-memory-store-sql.js +2 -1
- package/dist/plugins/shell-sentinel-owner-m48.d.ts +42 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +9 -0
- package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
- package/dist/plugins/sql-driver.d.ts +1 -1
- package/dist/plugins/sql-driver.js +2 -1
- package/dist/plugins/sql-errors.d.ts +32 -5
- package/dist/plugins/sql-errors.js +55 -7
- package/dist/plugins/sql-json-column.d.ts +8 -7
- package/dist/plugins/sql-json-column.js +10 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +16 -0
- package/dist/plugins/stop-then-start-sentence.js +7 -0
- package/dist/plugins/store-backend.d.ts +99 -16
- package/dist/plugins/store-backend.js +230 -65
- package/dist/plugins/store-contracts.d.ts +123 -33
- package/dist/plugins/store-contracts.js +38 -1
- package/dist/plugins/store-fault.d.ts +28 -2
- package/dist/plugins/store-fault.js +20 -2
- package/dist/plugins/task-attachment-store.d.ts +15 -3
- package/dist/plugins/task-attachment-store.js +22 -9
- package/dist/plugins/tidb-pool.d.ts +11 -6
- package/dist/plugins/tidb-pool.js +39 -18
- package/dist/plugins/web-search.js +5 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +6 -1
- package/dist/plugins/workflow-run-store-sql.js +11 -5
- package/dist/plugins/workspace-custody.d.ts +44 -0
- package/dist/plugins/workspace-custody.js +47 -0
- package/dist/principal-jwt.d.ts +4 -4
- package/dist/principal-jwt.js +20 -5
- package/dist/principal-shape.d.ts +41 -0
- package/dist/principal-shape.js +19 -0
- package/dist/project-identity.d.ts +8 -7
- package/dist/project-identity.js +40 -17
- package/dist/project-layer-key.d.ts +13 -2
- package/dist/project-layer-key.js +9 -1
- package/dist/question.d.ts +13 -23
- package/dist/question.js +21 -39
- package/dist/read-deny-floor-notice.d.ts +36 -0
- package/dist/read-deny-floor-notice.js +40 -0
- package/dist/{plain-string-record.d.ts → request-declaration-disposition.d.ts} +9 -23
- package/dist/request-declaration-disposition.js +39 -0
- package/dist/request-declaration-refusal.d.ts +35 -12
- package/dist/request-declaration-refusal.js +21 -9
- package/dist/request-form.d.ts +58 -0
- package/dist/request-form.js +72 -0
- package/dist/request-image-urls.d.ts +8 -2
- package/dist/request-image-urls.js +2 -1
- package/dist/request-images.d.ts +20 -0
- package/dist/request-images.js +59 -0
- package/dist/request-key-closure.d.ts +6 -7
- package/dist/request-key-closure.js +15 -2
- package/dist/resource-suspend.d.ts +7 -16
- package/dist/resource-suspend.js +1 -1
- package/dist/retired-name-host-notice.d.ts +21 -0
- package/dist/retired-name-host-notice.js +12 -0
- package/dist/rule-entry-list.d.ts +2 -2
- package/dist/rule-entry-list.js +3 -4
- package/dist/rule-issue-reading.d.ts +58 -0
- package/dist/rule-issue-reading.js +14 -0
- package/dist/rules-consent.d.ts +5 -3
- package/dist/rules-consent.js +1 -0
- package/dist/run-acceptance.d.ts +3 -1
- package/dist/run-acceptance.js +3 -0
- package/dist/run-cancel-card.d.ts +28 -0
- package/dist/run-cancel-card.js +19 -0
- package/dist/run-cancel-context.d.ts +10 -0
- package/dist/run-cancel-context.js +1 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +117 -90
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +56 -21
- package/dist/runs.js +73 -43
- package/dist/runtime-caps-resolver.d.ts +21 -6
- package/dist/runtime-caps-resolver.js +17 -4
- package/dist/runtime-governance.d.ts +2 -2
- package/dist/runtime-governance.js +5 -3
- package/dist/sealed-key-layout.d.ts +12 -5
- package/dist/sealed-key-layout.js +5 -0
- package/dist/sealed-key.d.ts +12 -2
- package/dist/sealed-key.js +115 -27
- package/dist/security.d.ts +128 -158
- package/dist/security.js +163 -59
- package/dist/sema-config-dir.d.ts +20 -0
- package/dist/sema-config-dir.js +25 -0
- package/dist/server-secret-env.d.ts +55 -25
- package/dist/server-secret-env.js +75 -22
- package/dist/session-agent.d.ts +3 -2
- package/dist/session-children-retire.d.ts +13 -8
- package/dist/session-children-retire.js +9 -7
- package/dist/session-deletion.d.ts +88 -0
- package/dist/session-deletion.js +8 -0
- package/dist/session-erase.d.ts +145 -0
- package/dist/session-erase.js +115 -0
- package/dist/session-error-wire.d.ts +5 -5
- package/dist/session-error-wire.js +1 -1
- package/dist/session-incarnation.d.ts +52 -5
- package/dist/session-incarnation.js +19 -2
- package/dist/session-policy-wire.d.ts +6 -3
- package/dist/session-policy-wire.js +11 -1
- package/dist/session-resident-background.d.ts +0 -71
- package/dist/session-resident-background.js +4 -3
- package/dist/session-row.d.ts +2 -1
- package/dist/session-rules-seat.d.ts +12 -0
- package/dist/session-rules-seat.js +19 -0
- package/dist/session-titler.d.ts +7 -15
- package/dist/session-titler.js +1 -1
- package/dist/session-workspace.d.ts +3 -3
- package/dist/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-admission.d.ts +33 -0
- package/dist/store-admission.js +49 -0
- package/dist/store-posture.d.ts +141 -20
- package/dist/store-posture.js +205 -3
- package/dist/stored-request-hooks-m20.js +2 -2
- package/dist/stores-sql/background-agent-store-sql.d.ts +11 -2
- package/dist/stores-sql/background-agent-store-sql.js +73 -20
- package/dist/stores-sql/checkpoint-store-sql.d.ts +34 -29
- package/dist/stores-sql/checkpoint-store-sql.js +78 -49
- package/dist/stores-sql/file-history-store-sql.d.ts +1 -1
- package/dist/stores-sql/file-history-store-sql.js +3 -5
- package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
- package/dist/stores-sql/mailbox-store-sql.js +31 -32
- package/dist/stores-sql/pg-session-storage.d.ts +7 -5
- package/dist/stores-sql/pg-session-storage.js +54 -46
- package/dist/stores-sql/retention-store-sql.d.ts +87 -19
- package/dist/stores-sql/retention-store-sql.js +92 -27
- package/dist/stores-sql/session-policy-store-sql.d.ts +32 -10
- package/dist/stores-sql/session-policy-store-sql.js +44 -36
- package/dist/stores-sql/session-write-hooks.d.ts +12 -6
- package/dist/stores-sql/tidb-session-storage.d.ts +4 -4
- package/dist/stores-sql/tidb-session-storage.js +13 -8
- package/dist/stores-sql/tidb-session-store.d.ts +36 -17
- package/dist/stores-sql/tidb-session-store.js +69 -39
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +4 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +5 -0
- package/dist/stores-sql/windowed-session-storage.js +9 -0
- package/dist/submission-exit.d.ts +50 -0
- package/dist/submission-exit.js +108 -0
- package/dist/task-a2a.d.ts +3 -8
- package/dist/task-a2a.js +28 -30
- package/dist/task-cwd.d.ts +43 -7
- package/dist/task-cwd.js +11 -0
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +4 -4
- package/dist/task-settings.d.ts +14 -10
- package/dist/task-settings.js +19 -7
- package/dist/terminal.d.ts +27 -43
- package/dist/terminal.js +49 -14
- package/dist/tool-approval.d.ts +173 -163
- package/dist/tool-approval.js +247 -232
- package/dist/trace/core-keyset-guard.d.ts +13 -6
- package/dist/trace/core-vocab-wire.d.ts +95 -0
- package/dist/trace/core-vocab-wire.js +15 -0
- package/dist/trace/engine-notice-wire.d.ts +24 -21
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +30 -4
- package/dist/trace/exit-seat.js +40 -36
- package/dist/trace/extension-call-face.d.ts +3 -2
- package/dist/trace/extension-call-face.js +3 -1
- package/dist/trace/ledger-events.d.ts +4 -7
- package/dist/trace/ledger-sink.d.ts +4 -31
- package/dist/trace/ledger-sink.js +0 -11
- package/dist/trace/model-segment.d.ts +5 -5
- package/dist/trace/model-segment.js +5 -5
- package/dist/trace/project.d.ts +59 -44
- package/dist/trace/project.js +60 -26
- package/dist/trace/redact.d.ts +135 -27
- package/dist/trace/redact.js +884 -260
- package/dist/trace/self-minted-wire.d.ts +567 -20
- package/dist/trace/self-minted-wire.js +205 -24
- package/dist/trace/wire-projection-faces.d.ts +5 -6
- package/dist/trace/wire-projection-faces.js +2 -2
- package/dist/upstream-body.d.ts +23 -0
- package/dist/upstream-body.js +16 -0
- package/dist/url-refusal.d.ts +3 -3
- package/dist/url-refusal.js +11 -4
- package/dist/user-authored-text.d.ts +1 -1
- package/dist/user-input-ledger.d.ts +7 -8
- package/dist/user-input-ledger.js +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +6 -3
- package/dist/web-admin-client/apply-effective.js +33 -23
- package/dist/web-admin-client/apply-ledger.d.ts +16 -7
- package/dist/web-admin-client/apply-ledger.js +5 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/center-request.js +15 -15
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +1 -1
- package/dist/web-admin-client/entry-metadata.d.ts +8 -0
- package/dist/web-admin-client/entry-metadata.js +13 -0
- package/dist/web-admin-client/http-client.d.ts +1 -1
- package/dist/web-admin-client/http-client.js +23 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/mcp-revocation.js +2 -1
- package/dist/web-admin-client/read-warnings.d.ts +1 -0
- package/dist/web-admin-client/read-warnings.js +1 -0
- package/dist/web-admin-client/restart-signal.js +8 -4
- package/dist/web-admin-client/skills-mcp.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +1 -2
- package/dist/workspace-space.d.ts +3 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
- package/docs/error-text-lexicon.json +317 -0
- package/package.json +8 -3
- package/scripts/drain-check-local.mjs +118 -147
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/scripts/embed-minimal.mjs +183 -0
- package/wire-changes/server@7.148.0.json +1517 -0
- package/wire-changes/server@7.149.0.json +372 -0
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +0 -25
- package/dist/http/memory-control-plane-corrupt-reply.js +0 -19
- package/dist/http/memory-layer-reply.d.ts +0 -30
- package/dist/http/memory-layer-reply.js +0 -24
- package/dist/lsp/e2b-bridge.d.ts +0 -57
- package/dist/lsp/e2b-bridge.js +0 -139
- package/dist/lsp/e2b-manager.d.ts +0 -93
- package/dist/lsp/e2b-manager.js +0 -178
- package/dist/lsp/lsp-frames.d.ts +0 -14
- package/dist/lsp/lsp-frames.js +0 -25
- package/dist/lsp/manager.d.ts +0 -129
- package/dist/lsp/manager.js +0 -127
- package/dist/lsp/types.d.ts +0 -12
- package/dist/lsp/types.js +0 -2
- package/dist/lsp/ws-transport.d.ts +0 -40
- package/dist/lsp/ws-transport.js +0 -210
- package/dist/plain-string-record.js +0 -70
package/dist/security.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { uuidv7, PROJECT_ID_REGEX,
|
|
1
|
+
import { uuidv7, PROJECT_ID_REGEX, SessionError, buildCrossSessionEnvelope, encodePeerAddress, CrossSessionCodecError } from "@sema-agent/core";
|
|
2
2
|
import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FACES, OWNERLESS_ORDINARY_CELL, ownerCellOf, ownerlessCellWithoutRead, qualsOf, recoveredSubject, visibleOn } from "./owner-faces.js";
|
|
4
|
+
import { mintDurableOwnerKey, mintPerson, partsOf, personOf, scenarioNamed, subjectOf } from "./owner-brands.js";
|
|
5
|
+
import { deletionHeadReadOf } from "./session-incarnation.js";
|
|
4
6
|
import { memoryScopeFor } from "./memory-scope.js";
|
|
5
7
|
import { verifyPrincipalJwt } from "./principal-jwt.js";
|
|
6
8
|
import { fieldConflictFacts } from "./field-conflict.js";
|
|
7
|
-
import {
|
|
9
|
+
import { refusalReservedKeyMessage, refusalReservedKeyOf } from "./http/refusal-body.js";
|
|
10
|
+
import { PRINCIPAL_MAX_BYTES, principalShapeProblem } from "./principal-shape.js";
|
|
11
|
+
import { birthFaceOf, withdrawFaceOf } from "./plugins/session-birth.js";
|
|
8
12
|
import { NOT_A_PRINCIPAL_NAME } from "./plugins/session-ownership.js";
|
|
9
13
|
export function isDestructiveSessionWrite(method, url) {
|
|
10
14
|
if (method === "DELETE")
|
|
@@ -15,37 +19,66 @@ export function isDestructiveSessionWrite(method, url) {
|
|
|
15
19
|
return /^\/v1\/sessions\/[^/]+\/(sync\/import|fork|memory\/erase)$/.test(url);
|
|
16
20
|
return false;
|
|
17
21
|
}
|
|
18
|
-
export function
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export function claimCallerOf(subject, config) {
|
|
23
|
+
return {
|
|
24
|
+
subject,
|
|
25
|
+
operator: false,
|
|
26
|
+
fleet: undefined,
|
|
27
|
+
traceRead: false,
|
|
28
|
+
principalRequired: DEPLOYMENT_SHAPE_PREDICATES.principalRequired.holds(config),
|
|
29
|
+
multiTenant: DEPLOYMENT_SHAPE_PREDICATES.multiTenant.holds(config),
|
|
30
|
+
};
|
|
23
31
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return !cell.placed || caller.fleet;
|
|
32
|
+
export const ATTACH_ABSENT_MESSAGE = "requireExistingSession: session does not exist (resume.session_not_found)";
|
|
33
|
+
function attachAbsentError() {
|
|
34
|
+
return createCodedHttpError(404, "resume.session_not_found", ATTACH_ABSENT_MESSAGE);
|
|
28
35
|
}
|
|
29
36
|
export async function sessionOwnerCellOf(store, sessionId, owner) {
|
|
30
37
|
if (owner !== null)
|
|
31
|
-
return
|
|
38
|
+
return ownerCellOf(owner);
|
|
32
39
|
const placementOf = store?.placementOf;
|
|
33
40
|
return { owner: null, placed: placementOf !== undefined && (await placementOf.call(store, sessionId)) !== undefined };
|
|
34
41
|
}
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
export async function sessionCellFor(face, caller, store, sessionId, owner) {
|
|
43
|
+
if (owner !== null)
|
|
44
|
+
return sessionOwnerCellOf(store, sessionId, owner);
|
|
45
|
+
const unread = ownerlessCellWithoutRead(face, caller);
|
|
46
|
+
if (unread !== undefined)
|
|
47
|
+
return unread;
|
|
48
|
+
try {
|
|
49
|
+
return await sessionOwnerCellOf(store, sessionId, null);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
if (FACES[face].placementUnreadable === "ordinary" && archiveUnreadable(e))
|
|
53
|
+
return OWNERLESS_ORDINARY_CELL;
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
38
56
|
}
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
function archiveUnreadable(e) {
|
|
58
|
+
if (!(e instanceof SessionError))
|
|
59
|
+
return false;
|
|
60
|
+
const code = e.code;
|
|
61
|
+
switch (code) {
|
|
62
|
+
case "corrupt_session":
|
|
63
|
+
case "invalid_session":
|
|
64
|
+
return true;
|
|
65
|
+
case "not_found":
|
|
66
|
+
case "invalid_entry":
|
|
67
|
+
case "invalid_fork_target":
|
|
68
|
+
case "storage":
|
|
69
|
+
case "conflict":
|
|
70
|
+
case "placement_refused":
|
|
71
|
+
case "unknown":
|
|
72
|
+
return false;
|
|
73
|
+
default: {
|
|
74
|
+
const unknownCode = code;
|
|
75
|
+
throw new Error(`archiveUnreadable: unknown SessionError code ${String(unknownCode)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
41
78
|
}
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return true;
|
|
46
|
-
if (rowOwner === null)
|
|
47
|
-
return legacyUnownedAmnestyOpen(deployment, principal);
|
|
48
|
-
return !DEPLOYMENT_SHAPE_PREDICATES.principalRequired.holds(deployment) && rowOwner === LEGACY_SHELL_SENTINEL_OWNER && principal === null;
|
|
79
|
+
export function sameSessionOwner(deployment, rowOwner, occupant) {
|
|
80
|
+
const quals = qualsOf(claimCallerOf(recoveredSubject(occupant), deployment), ownerCellOf(rowOwner));
|
|
81
|
+
return rowOwner === null ? occupant === null || quals.has("j4") : quals.has("owner");
|
|
49
82
|
}
|
|
50
83
|
const UUIDV7_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
51
84
|
export function isUuidV7(s) {
|
|
@@ -65,6 +98,11 @@ export class HttpError extends Error {
|
|
|
65
98
|
code;
|
|
66
99
|
extra;
|
|
67
100
|
constructor(status, message, opts) {
|
|
101
|
+
if (opts?.extra !== undefined) {
|
|
102
|
+
const reserved = refusalReservedKeyOf(opts.extra);
|
|
103
|
+
if (reserved !== undefined)
|
|
104
|
+
throw new TypeError(refusalReservedKeyMessage(opts.code ?? `HTTP ${status}`, reserved));
|
|
105
|
+
}
|
|
68
106
|
super(message);
|
|
69
107
|
this.status = status;
|
|
70
108
|
this.name = "HttpError";
|
|
@@ -77,10 +115,23 @@ export class HttpError extends Error {
|
|
|
77
115
|
export function createCodedHttpError(status, errorCode, message, extra) {
|
|
78
116
|
return new HttpError(status, message, extra === undefined ? { code: errorCode } : { code: errorCode, extra });
|
|
79
117
|
}
|
|
80
|
-
export function createAuthorizer(config, sessionStore) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
export function createAuthorizer(config, sessionStore, logger) {
|
|
119
|
+
const attachRefused = (reason, subject) => {
|
|
120
|
+
logger?.info("owner_gate_refused", { policyFace: "session.attach", reason, principalPresent: subject !== undefined });
|
|
121
|
+
return attachAbsentError();
|
|
122
|
+
};
|
|
123
|
+
const birthFace = birthFaceOf(sessionStore);
|
|
124
|
+
const withdrawFace = withdrawFaceOf(sessionStore);
|
|
125
|
+
const registerNew = async (id, owner, register, onBirth) => {
|
|
126
|
+
if (birthFace === undefined || withdrawFace === undefined)
|
|
127
|
+
return register(id, owner);
|
|
128
|
+
const receipt = await birthFace.registerWithReceipt(id, owner);
|
|
129
|
+
if (receipt.minted !== undefined)
|
|
130
|
+
onBirth?.(receipt.minted, withdrawFace);
|
|
131
|
+
};
|
|
132
|
+
return async ({ req, body, onBirth }) => {
|
|
133
|
+
const subject = verifiedSubject(req, config);
|
|
134
|
+
if (config.requirePrincipal && !subject) {
|
|
84
135
|
throw new HttpError(401, `missing principal header '${config.principalHeader}'`);
|
|
85
136
|
}
|
|
86
137
|
let projectId;
|
|
@@ -91,7 +142,7 @@ export function createAuthorizer(config, sessionStore) {
|
|
|
91
142
|
projectId = body.projectId.toLowerCase();
|
|
92
143
|
}
|
|
93
144
|
const requireExisting = body.requireExistingSession === true;
|
|
94
|
-
const headOf =
|
|
145
|
+
const headOf = deletionHeadReadOf(sessionStore);
|
|
95
146
|
let head;
|
|
96
147
|
const readOwner = headOf === undefined ? undefined : async (id) => {
|
|
97
148
|
head = await headOf(id);
|
|
@@ -105,24 +156,20 @@ export function createAuthorizer(config, sessionStore) {
|
|
|
105
156
|
let owner = await readOwner(requested);
|
|
106
157
|
if (owner === undefined) {
|
|
107
158
|
if (requireExisting) {
|
|
108
|
-
throw
|
|
159
|
+
throw attachRefused("missing", subject);
|
|
109
160
|
}
|
|
110
161
|
if (register) {
|
|
111
|
-
await
|
|
162
|
+
await registerNew(requested, subject ?? null, register, onBirth);
|
|
112
163
|
owner = await readOwner(requested);
|
|
113
164
|
}
|
|
114
165
|
else if (config.requirePrincipal) {
|
|
115
166
|
throw new HttpError(403, "cannot claim a caller-supplied sessionId on a multi-tenant deployment: this worker's session store cannot record session ownership, so the id would stay unowned and the next caller could attach to it. Configure a durable session backend (SESSION_BACKEND), or omit sessionId to start a new session.");
|
|
116
167
|
}
|
|
117
168
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (owner != null && !sameSessionOwner(config, owner, principal ?? null)) {
|
|
123
|
-
throw principal
|
|
124
|
-
? new HttpError(403, "session does not belong to this principal")
|
|
125
|
-
: new HttpError(401, `session is principal-owned; missing principal header '${config.principalHeader}'`);
|
|
169
|
+
if (owner !== undefined) {
|
|
170
|
+
const claimCaller = claimCallerOf(subject, config);
|
|
171
|
+
if (!visibleOn("session.attach", qualsOf(claimCaller, await sessionCellFor("session.attach", claimCaller, sessionStore, requested, owner))))
|
|
172
|
+
throw attachRefused("not_visible", subject);
|
|
126
173
|
}
|
|
127
174
|
}
|
|
128
175
|
else if (config.requirePrincipal) {
|
|
@@ -136,26 +183,13 @@ export function createAuthorizer(config, sessionStore) {
|
|
|
136
183
|
}
|
|
137
184
|
sessionId = uuidv7();
|
|
138
185
|
if (register)
|
|
139
|
-
await
|
|
186
|
+
await registerNew(sessionId, subject ?? null, register, onBirth);
|
|
140
187
|
if (readOwner)
|
|
141
188
|
await readOwner(sessionId);
|
|
142
189
|
}
|
|
143
|
-
return {
|
|
190
|
+
return { subject, sessionId, memoryScope: memoryScopeFor(config, subject === undefined ? undefined : personOf(subject), projectId), resolvedProjectId: projectId, ...(head === undefined ? {} : { head }) };
|
|
144
191
|
};
|
|
145
192
|
}
|
|
146
|
-
export const PRINCIPAL_MAX_LENGTH = 190;
|
|
147
|
-
export const PRINCIPAL_MAX_UTF8_BYTES = PRINCIPAL_MAX_LENGTH * 3;
|
|
148
|
-
export const RESERVED_PRINCIPALS = ["_", "__none__", "_leader"];
|
|
149
|
-
export const RESERVED_PRINCIPAL_PREFIXES = ["_leader-", ORPHAN_SESSION_OWNER_PREFIX];
|
|
150
|
-
export function principalShapeProblem(principal) {
|
|
151
|
-
if (principalNameOf(principal) === undefined)
|
|
152
|
-
return "not_a_name";
|
|
153
|
-
if (RESERVED_PRINCIPALS.includes(principal) || RESERVED_PRINCIPAL_PREFIXES.some((p) => principal.startsWith(p)))
|
|
154
|
-
return "reserved";
|
|
155
|
-
if (principal.length > PRINCIPAL_MAX_LENGTH)
|
|
156
|
-
return "too_long";
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
193
|
export function assertPrincipalShape(principal) {
|
|
160
194
|
const problem = principalShapeProblem(principal);
|
|
161
195
|
switch (problem) {
|
|
@@ -166,21 +200,44 @@ export function assertPrincipalShape(principal) {
|
|
|
166
200
|
case "reserved":
|
|
167
201
|
throw createCodedHttpError(400, "principal_reserved", `principal ${JSON.stringify(principal)} is reserved (an internal scope sentinel) — authenticate with a real tenant identifier`);
|
|
168
202
|
case "too_long":
|
|
169
|
-
throw createCodedHttpError(400, "principal_too_long", `principal exceeds ${
|
|
203
|
+
throw createCodedHttpError(400, "principal_too_long", `principal exceeds ${PRINCIPAL_MAX_BYTES} UTF-8 bytes (the identity-column width every store pins, e.g. sendfile_link.scope VARCHAR(190), mailbox.scope_key VARBINARY(190)); got ${Buffer.byteLength(principal, "utf8")}`);
|
|
170
204
|
default: {
|
|
171
205
|
const unknownProblem = problem;
|
|
172
206
|
throw new Error(`assertPrincipalShape: unknown problem ${String(unknownProblem)}`);
|
|
173
207
|
}
|
|
174
208
|
}
|
|
175
209
|
}
|
|
210
|
+
export const CROSS_SESSION_FROM_SCOPE_MAX_ENCODED = 190;
|
|
211
|
+
export const SUBJECT_ENCODED_BUDGET = CROSS_SESSION_FROM_SCOPE_MAX_ENCODED;
|
|
212
|
+
export function subjectWidthExceeded(subject) {
|
|
213
|
+
try {
|
|
214
|
+
buildCrossSessionEnvelope({ from: encodePeerAddress("width-probe"), fromScope: subject }, "");
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
if (e instanceof CrossSessionCodecError && e.code === "cross_session.invalid_from_scope")
|
|
219
|
+
return true;
|
|
220
|
+
throw e;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
176
223
|
export const CHECKPOINT_PUBLIC_SCOPE = "_";
|
|
177
224
|
export const BACKGROUND_REGISTRY_ANON_SCOPE = "default";
|
|
178
225
|
export function backgroundScopesForCheckpointScope(scope) {
|
|
179
226
|
return scope === CHECKPOINT_PUBLIC_SCOPE ? [CHECKPOINT_PUBLIC_SCOPE, BACKGROUND_REGISTRY_ANON_SCOPE] : [scope];
|
|
180
227
|
}
|
|
181
|
-
export const encodeCheckpointScope = (
|
|
182
|
-
export const decodeCheckpointScope = (scope) => (scope === CHECKPOINT_PUBLIC_SCOPE ? undefined : scope);
|
|
228
|
+
export const encodeCheckpointScope = (subject) => subject ?? CHECKPOINT_PUBLIC_SCOPE;
|
|
229
|
+
export const decodeCheckpointScope = (scope) => (scope === CHECKPOINT_PUBLIC_SCOPE ? undefined : mintDurableOwnerKey(scope));
|
|
183
230
|
export const ownerOfCheckpointScope = (scope) => decodeCheckpointScope(scope) ?? null;
|
|
231
|
+
export const checkpointPartsOf = (scope) => {
|
|
232
|
+
const key = decodeCheckpointScope(scope);
|
|
233
|
+
return key === undefined ? undefined : partsOf(key);
|
|
234
|
+
};
|
|
235
|
+
export function scopeCellOf(scope) {
|
|
236
|
+
if (typeof scope !== "string")
|
|
237
|
+
return undefined;
|
|
238
|
+
const owner = decodeCheckpointScope(scope);
|
|
239
|
+
return owner === undefined ? OWNERLESS_ORDINARY_CELL : { owner };
|
|
240
|
+
}
|
|
184
241
|
export function principalFrom(req, config) {
|
|
185
242
|
if (!config.principalHeader)
|
|
186
243
|
return undefined;
|
|
@@ -225,7 +282,54 @@ export function ssoVerifiedPrincipalInc(req) {
|
|
|
225
282
|
const v = SSO_PRINCIPAL_INCS.get(req);
|
|
226
283
|
return v !== undefined && v.length > 0 ? v : undefined;
|
|
227
284
|
}
|
|
228
|
-
export function
|
|
285
|
+
export function verifiedPerson(req, config) {
|
|
286
|
+
const verified = verifiedIdentity(req, config);
|
|
287
|
+
return verified === undefined ? undefined : mintPerson(verified);
|
|
288
|
+
}
|
|
289
|
+
export const SCENARIO_HEADER = "x-agent-scenario";
|
|
290
|
+
export function scenarioHeaderOf(req) {
|
|
291
|
+
const raw = req.headers[SCENARIO_HEADER];
|
|
292
|
+
return (Array.isArray(raw) ? raw[0] : raw)?.trim() || undefined;
|
|
293
|
+
}
|
|
294
|
+
export function scenarioWithoutPrincipalError() {
|
|
295
|
+
return createCodedHttpError(400, "request.scenario_without_principal", `the ${SCENARIO_HEADER} header selects a partition inside a verified person, but this request carries no verified principal — authenticate the person, or drop the header`);
|
|
296
|
+
}
|
|
297
|
+
export function scenarioHeaderUnknownError(name, known) {
|
|
298
|
+
return createCodedHttpError(400, "scenario_unknown", `unknown scenario ${JSON.stringify(name)} in the ${SCENARIO_HEADER} header — it is not a scenario of this deployment`, known === undefined ? undefined : { known: [...known] });
|
|
299
|
+
}
|
|
300
|
+
const REQUEST_SUBJECTS = new WeakMap();
|
|
301
|
+
export function verifiedSubject(req, config) {
|
|
302
|
+
let memo = REQUEST_SUBJECTS.get(req);
|
|
303
|
+
if (memo === undefined) {
|
|
304
|
+
try {
|
|
305
|
+
memo = { subject: judgeRequestSubject(req, config) };
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
memo = { error };
|
|
309
|
+
}
|
|
310
|
+
REQUEST_SUBJECTS.set(req, memo);
|
|
311
|
+
}
|
|
312
|
+
if ("error" in memo)
|
|
313
|
+
throw memo.error;
|
|
314
|
+
return memo.subject;
|
|
315
|
+
}
|
|
316
|
+
function judgeRequestSubject(req, config) {
|
|
317
|
+
const person = verifiedPerson(req, config);
|
|
318
|
+
const raw = scenarioHeaderOf(req);
|
|
319
|
+
if (raw === undefined)
|
|
320
|
+
return person === undefined ? undefined : subjectOf(person);
|
|
321
|
+
if (person === undefined)
|
|
322
|
+
throw scenarioWithoutPrincipalError();
|
|
323
|
+
const scenario = scenarioNamed(raw);
|
|
324
|
+
if (scenario === undefined)
|
|
325
|
+
throw scenarioHeaderUnknownError(raw, undefined);
|
|
326
|
+
const subject = subjectOf(person, scenario);
|
|
327
|
+
if (subjectWidthExceeded(subject)) {
|
|
328
|
+
throw createCodedHttpError(400, "principal_too_long", `principal plus the ${SCENARIO_HEADER} scenario exceeds ${SUBJECT_ENCODED_BUDGET} characters once percent-encoded (the narrowest face the subject lands in: the cross-session envelope from-scope) — use a shorter principal or scenario name`);
|
|
329
|
+
}
|
|
330
|
+
return subject;
|
|
331
|
+
}
|
|
332
|
+
function verifiedIdentity(req, config) {
|
|
229
333
|
const sso = ssoVerifiedPrincipal(req);
|
|
230
334
|
if (sso) {
|
|
231
335
|
assertPrincipalShape(sso);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type DeploymentShapeInput } from "./deployment-shape.js";
|
|
1
2
|
import type { Logger } from "./observability/logger.js";
|
|
3
|
+
import type { LaunchWorkspace } from "./task-cwd.js";
|
|
2
4
|
/** 部署声明的配置根(绝对路径);没声明 ⇒ `undefined`;空串 ⇒ 抛(起服拒,句子点名变量与出路)。纯读 env,不碰文件。**只有 `loadConfig` 调它**
|
|
3
5
|
* (结果 = 配置席 `agentConfigDir`);别的读者读那一席。 */
|
|
4
6
|
export declare function declaredSemaConfigDir(env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -16,4 +18,22 @@ export declare function configRootOf(config: {
|
|
|
16
18
|
export declare function provisionSemaConfigDir(config: {
|
|
17
19
|
readonly agentConfigDir?: string;
|
|
18
20
|
}, logger: Pick<Logger, "warn">): void;
|
|
21
|
+
/**
|
|
22
|
+
* 起服的**公告动作**(每个入口一次):配置根就是工作区、或是工作区的祖先 ⇒ warn 恰一行 `sema_config_root_encloses_workspace`;不相交(含配置根在工作区之内)⇒ 零行。**不拒启、不改任何行为。**
|
|
23
|
+
*
|
|
24
|
+
* 为什么要说:引擎缺省写保护表的 `.sema` 行在声明的配置根下同样守,根**之内**任何路径的写都过 `write_protection` 一问(allow 规则清不掉、`acceptEdits` 不放、无人值守腿直接拒)——
|
|
25
|
+
* 配置根是工作区的祖先时,工作区里每一次写都出这一张卡,而此前起服与首条任务零行。能不能用仍只有引擎一个判官,本服务只把这个构造说出来,不判、不铸拒句。
|
|
26
|
+
*
|
|
27
|
+
* 判法:配置根({@link configRootOf})与工作区({@link LaunchWorkspace},读链唯一属主 `task-cwd.ts` 的 `launchWorkspaceOf`)各取一次规范形后,`pathIsWithin(配置根, 工作区)`(含相等);两侧同一只规范形座。
|
|
28
|
+
* 读数里的两条路径是**原样拼写**(运维认得出来的那两条)。手不在本机盘上的车道(部署形表行 `sandboxPathAdjudication`:工具跑在沙箱 / 远程)不判 —— 那里的工作区不是本进程这台机的盘。
|
|
29
|
+
* 看不见的一半(随包文档如实写):请求体里按任务给的 `cwd` 起服时不可知,不在读链里;规范形对**尚不存在**的尾巴只比字串、不折大小写 —— 大小写不敏感的盘上,两个只差大小写且尾巴都还不存在的拼写读成两处,这一行会漏报
|
|
30
|
+
* (与记忆根那一判共用同一只规范形,那一判的失败方向是多报,这一判的是漏报;如实披露)。
|
|
31
|
+
* 句子只描述位置关系,后果限定在引擎**缺省**写保护表上:用 `WRITE_PROTECTED_TABLE_REPLACE` 去掉那一行的部署不受影响(这一行不读那张表),可忽略它。
|
|
32
|
+
*
|
|
33
|
+
* 规范形读不出(盘上竞态:探完到取值之间目录被挪走 / 搜索权限被收)⇒ 披露面不得把起服打死:响亮报另一行 `sema_config_root_workspace_check_unavailable`(类名 + 机器码),起服照常。
|
|
34
|
+
* 位置:HTTP 服务在装配第 2 段执行车道合成之后(读的是合成后的车道与工作区底),`run-local` 在工作区定下之后 —— 车道在这两处才定形,所以不与 {@link provisionSemaConfigDir} 同一拍。
|
|
35
|
+
*/
|
|
36
|
+
export declare function announceConfigRootEnclosingWorkspace(config: {
|
|
37
|
+
readonly agentConfigDir?: string;
|
|
38
|
+
} & DeploymentShapeInput<"lane">, logger: Pick<Logger, "warn">, workspace: LaunchWorkspace, canonical?: (p: string) => string): void;
|
|
19
39
|
//# sourceMappingURL=sema-config-dir.d.ts.map
|
package/dist/sema-config-dir.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { ensureDir } from "@sema-agent/core";
|
|
4
|
+
import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
|
|
5
|
+
import { canonicalPathOf, pathIsWithin } from "./memory-scope.js";
|
|
6
|
+
import { errorCodeOf, errorKindOf } from "./observability/err-text.js";
|
|
4
7
|
export function declaredSemaConfigDir(env = process.env) {
|
|
5
8
|
const raw = env.SEMA_CONFIG_DIR;
|
|
6
9
|
if (raw === undefined)
|
|
@@ -30,4 +33,26 @@ export function provisionSemaConfigDir(config, logger) {
|
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
35
|
}
|
|
36
|
+
export function announceConfigRootEnclosingWorkspace(config, logger, workspace, canonical = canonicalPathOf) {
|
|
37
|
+
if (DEPLOYMENT_SHAPE_PREDICATES.sandboxPathAdjudication.holds(config))
|
|
38
|
+
return;
|
|
39
|
+
const configRoot = configRootOf(config);
|
|
40
|
+
try {
|
|
41
|
+
if (!pathIsWithin(configRoot, workspace.dir, canonical))
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
logger.warn("sema_config_root_workspace_check_unavailable", { configRoot, workspace: workspace.dir, workspaceFrom: workspace.from, errorKind: errorKindOf(e), errorCode: errorCodeOf(e) });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
logger.warn("sema_config_root_encloses_workspace", {
|
|
49
|
+
configRoot,
|
|
50
|
+
workspace: workspace.dir,
|
|
51
|
+
workspaceFrom: workspace.from,
|
|
52
|
+
note: "The configuration root (配置根, SEMA_CONFIG_DIR; default ~/.sema) is the workspace (工作区) itself or one of its ancestors. With the engine's default write-protection table, every file the agent writes " +
|
|
53
|
+
"inside it goes through a write-protection prompt that allow rules cannot clear, and unattended runs are refused (a deployment that replaced or disabled that table with WRITE_PROTECTED_TABLE_REPLACE " +
|
|
54
|
+
"is not affected and can ignore this line: it only reports where the two directories sit). This line changes nothing. Point SEMA_CONFIG_DIR at a dedicated directory outside the workspace " +
|
|
55
|
+
"(unset it to use ~/.sema).",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
33
58
|
//# sourceMappingURL=sema-config-dir.js.map
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 剥掉的键经一个登记过的 `SecretEnvScrubSite` 留痕(现场按**腿**命名);git 腿再叠 git 自己的两件({@link gitSubprocessEnv})。射程 = **每一条**宿主腿:
|
|
14
14
|
* src 里每一只值引 `node:child_process` 的文件都是登记腿、其中每一次起子进程都显式交组合出的 env(普查门在 `test/secret-env-scrub-host-legs.test.ts`)。
|
|
15
15
|
* 腿的继承词是调用点的事实,按「子进程里跑的是谁选的代码」定:模型命令(host shell,交任务自己的词)/ 仓里的钩子与凭据助手(三条 git 腿)/ 执行仓代码的
|
|
16
|
-
* 语言服务器 / 配方脚本 ⇒ 形状剥 `"scrub"`;请求带来的 settings hooks 命令 ⇒ 严格名单(十二名基础名单,`[names]` 臂;请求的继承词只给工具 shell、对 hook 不作用)
|
|
16
|
+
* 语言服务器 / 配方脚本 ⇒ 形状剥 `"scrub"`;请求带来的 settings hooks 命令 ⇒ 严格名单(十二名基础名单,`[names]` 臂;请求的继承词只给工具 shell、对 hook 不作用)∪ 部署方 `HOOK_ENV_ALLOW` 点名放回、请求的有效环境层作授予叠在继承结果之上(引擎的 `hostChildEnv`);部署方装在宿主上的 CLI(`docker` / `adb`,命令本身
|
|
17
17
|
* 在容器 / 设备里跑、那边的 env 由 `-e` 显式给)⇒ `"all"` —— 只扣本服务自有凭据,CLI 与它的凭据助手 / 插件要读的生态变量照交(形状剥会剥
|
|
18
18
|
* `ADB_VENDOR_KEYS` / `AWS_SECRET_ACCESS_KEY` 一类,实测)。三个继承词只在引擎一处判:
|
|
19
19
|
* · `"all"` = 整份环境 **减** 本进程声明的自有凭据名;`"scrub"`(缺省)= 形状剥 ∪ 该名单;`[names]` = 严格白名单,点到名单中的名 ⇒ 引擎响亮拒
|
|
@@ -25,27 +25,31 @@
|
|
|
25
25
|
* 与每次生效配置换代(`web-admin-client/apply-effective.ts` 本体:CAS 之后、Runner 换装与 commit 之前 —— 声明先于席位,旧世代不声明)。名单只随**落地**的世代
|
|
26
26
|
* 增长(本进程 env 是 boot 期输入:一个名字一旦指过本进程的凭据,条目改名 / 删掉之后它的值仍在 env 里 ⇒ 落地过的名不退出;没落地的候选不留痕 —— 名单重判命中 / 换装拒 ⇒
|
|
27
27
|
* {@link withdrawServerWithheldEnv} 撤回到换代前的集合)。声明失败(坏形名 / 运行时回填名)⇒ 引擎抛且声明保持原状:起服那次 = 拒启,换代那次 = 候选整拒(与 stage
|
|
28
|
-
* 抛同路)
|
|
29
|
-
* {@link
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* 抛同路)。「引擎扣没扣这些名」只有一只读法 {@link ownCredentialNamesNotWithheld}(问引擎本尊的判官,不读本文件的镜像),两个读者:
|
|
29
|
+
* `loadConfig()` 的**声明前提**({@link ownCredentialDeclarationRefusal}:起服表的名没全扣 ⇒ `loadConfig` 抛,拒句点名 {@link declareServerWithheldEnv} —— 「先声明」不再只是入口里的位置契约,
|
|
30
|
+
* 不经入口直接调 `loadConfig` 的进程〔包根嵌入方 / bench / 探针脚本〕得先声明,声明对它们才不是空的)与能力词 `inherit_env.own_credentials_withheld` 在本进程的事实
|
|
31
|
+
* {@link ownCredentialsWithheld}(当前生效配置应声明的名全被扣;活配置经 {@link bindOwnCredentialsConfig} 在 `loadConfig()` 之后绑一次;未绑 / 没扣 ⇒ false)。
|
|
32
|
+
* · **值臂**(core 7.52.0 [ref]):声明是一张表 `{ names, values }`。`values` = 本进程持有凭据的变量(目录 secret 名 ∪ 模型条目 `apiKeyEnv`,{@link serverCredentialValueSources})
|
|
33
|
+
* 此刻装着的**每一枚**本服务凭据 —— 颗粒按本服务读这只变量的那一只解析器定(目录行的 `credentialForm`:整值总在内,`SERVICE_AUTH_TOKENS` 另加每一枚令牌、
|
|
34
|
+
* `APPROVAL_HMAC_KEYS` 另加每一把钥;{@link credentialsHeldBy})—— 引擎按整串比,所以一枚令牌换了个变量名放着与原变量同扣,部分重叠 / 前后缀不同的值不扣。
|
|
35
|
+
* 逐枚交给引擎的同一只判;引擎判「不是凭据值」的那一枚不扣、名照扣、不拒启、点名那个变量一次。能力词 `inherit_env.own_credential_values_withheld` 的事实 = {@link ownCredentialValuesWithheld}(位真 ⇔ 值臂每一枚都真扣)。
|
|
36
|
+
* 「这个变量是不是本服务的凭据」(名是,或值是)只有一只读法 {@link ownCredentialVariable}(判官 = 引擎此刻的声明):名单型旋钮的解析器与声明增长时的重判都问它。
|
|
33
37
|
* · 调用方显式传入的 env(`cfg.env` / 单次命令的 `env` / 沙箱的点名放回)不是继承,照旧原样叠在组合结果之上 —— 那是适配器自己的凭据通道。
|
|
34
38
|
* 各腿只调 {@link hostSubprocessEnv} / {@link gitSubprocessEnv} —— 不许再有内联拼装、不许再有 `{ ...process.env }`、不许本仓再判任何一个继承词、不许起子进程不交 env
|
|
35
39
|
* (类级门与普查门在 `test/secret-env-scrub-host-legs.test.ts`)。
|
|
36
40
|
*
|
|
37
41
|
* ## 点名放行([ref] / [ref],一只谓词各处用)
|
|
38
42
|
* {@link allowlistedEnv} 是本仓「一张名单点到哪些 env 键,就把它们从源 env **原样**交给沙箱」的唯一实现。调用:沙箱带外 env 的 `E2B_SANDBOX_ENV` / `DOCKER_SANDBOX_ENV` /
|
|
39
|
-
* `K8S_SANDBOX_ENV`(`config.ts`)与名单解析器的「在不在」判。宿主子进程的剥后放回(`LSP_ENV_ALLOW` / `BAKE_ENV_ALLOW`)不经它 —— 那是引擎的严格名单臂(上一段)。
|
|
43
|
+
* `K8S_SANDBOX_ENV`(`config.ts`)与名单解析器的「在不在」判。宿主子进程的剥后放回(`LSP_ENV_ALLOW` / `HOOK_ENV_ALLOW` / `BAKE_ENV_ALLOW`)不经它 —— 那是引擎的严格名单臂(上一段)。
|
|
40
44
|
* host shell 的 `inheritEnv:[names]`(hermetic 形)7.129.0 起由引擎读(与 core `NodeExecutionEnv` 同名选项同义,点到自有凭据名即拒),不经本谓词。
|
|
41
45
|
* 名单型旋钮的**名单**另由 `config.ts` 的同一只解析器 `parseEnvNameAllowlist` 判形(形错 / 点名名单型旋钮 / 点名本服务自有凭据名 ⇒ 拒启;源里没有的名按序号 warn),本函数只管取值。
|
|
42
46
|
* 「点名」在各处同义:点到的键原样带值(空串值照带),密钥形也照过(点名 = 部署方显式承担);源里没有的名不产生条目。
|
|
43
|
-
* 剥后放回形(`LSP_ENV_ALLOW` / `BAKE_ENV_ALLOW`)的放回本身也经引擎:{@link composeHostSubprocessEnv} 把名单交引擎的严格名单臂(`inheritedHostEnv([names])`)叠在
|
|
47
|
+
* 剥后放回形(`LSP_ENV_ALLOW` / `HOOK_ENV_ALLOW` / `BAKE_ENV_ALLOW`)的放回本身也经引擎:{@link composeHostSubprocessEnv} 把名单交引擎的严格名单臂(`inheritedHostEnv([names])`)叠在
|
|
44
48
|
* 继承结果之上 ⇒ 点到本服务自有凭据名 = 引擎在**组合这一刻**抛(语言服务器在构造时组合一次、之后 spawn 用那份静态记录;bake-runner 每次 spawn 组合;
|
|
45
49
|
* 起服时解析器 `parseEnvNameAllowlist` 已用同一只判 `inheritEnvPolicyProblem` 拒过 —— 解析器对五只名单一律拒,点到**解析时已声明**的自有凭据名的沙箱名单因此
|
|
46
50
|
* 到不了 {@link allowlistedEnv} 取值这一步;声明之后增长(中心 / config.d 模型条目的 `apiKeyEnv` 换代并进)时,换代声明对活配置里每只名单此刻交出去的名用同一只判
|
|
47
|
-
* 重判一次 —— 命中 ⇒ 撤回这次增长、候选整拒,已装好的沙箱 env / 语言服务器 env 不变成本服务的凭据,`config.ts` `ownCredentialHitsInForce`)
|
|
48
|
-
*
|
|
51
|
+
* 重判一次 —— 命中 ⇒ 撤回这次增长、候选整拒,已装好的沙箱 env / 语言服务器 env 不变成本服务的凭据,`config.ts` `ownCredentialHitsInForce`)。
|
|
52
|
+
* 解析器与重判问的是「点到的变量是不是本服务的凭据」—— 名是,**或值是**(另一个名下的副本,{@link ownCredentialVariable})—— 都拒;组合这一刻引擎照样扣下值副本(不变量)。本仓不另判、不比值。
|
|
49
53
|
*/
|
|
50
54
|
import { type InheritEnvPolicy, type SecretEnvFinding } from "@sema-agent/core";
|
|
51
55
|
import type { ServiceConfig } from "./config-types.js";
|
|
@@ -60,8 +64,9 @@ export type ModelApiKeyEnvTable = Readonly<Record<string, string>>;
|
|
|
60
64
|
*/
|
|
61
65
|
export declare function serverWithheldEnvNames(modelApiKeyEnv?: ModelApiKeyEnvTable): readonly string[];
|
|
62
66
|
/**
|
|
63
|
-
* 本进程**持有凭据值**的变量名(值臂的来源;core 7.52.0 [ref]):目录 secret 名 ∪ 模型条目 `apiKeyEnv` 的值 ——
|
|
64
|
-
*
|
|
67
|
+
* 本进程**持有凭据值**的变量名(值臂的来源;core 7.52.0 [ref]):目录 secret 名 ∪ 模型条目 `apiKeyEnv` 的值 —— 名单与值臂两臂同一张表派生,只少不在目录里的名单型旋钮名
|
|
68
|
+
* (今天 = bake-runner 进程的 `BAKE_ENV_ALLOW`);目录里的名单型旋钮行是 secret 行,原文按凭据类整值对待(行上 `credentialForm: "whole"`)。每个来源装着几枚凭据
|
|
69
|
+
* 由目录行的颗粒定({@link credentialsHeldBy})。纯函数,排序只为读数稳定。
|
|
65
70
|
*/
|
|
66
71
|
export declare function serverCredentialValueSources(modelApiKeyEnv?: ModelApiKeyEnvTable): readonly string[];
|
|
67
72
|
/**
|
|
@@ -71,15 +76,14 @@ export declare function serverCredentialValueSources(modelApiKeyEnv?: ModelApiKe
|
|
|
71
76
|
* · **名臂**:此前声明过的 ∪ 这张表的 {@link serverWithheldEnvNames}。引擎对坏形名 / 运行时回填名(`PATH` / `HOME` …)响亮抛且声明保持原状 —— 本函数不接住:
|
|
72
77
|
* 起服那次抛 = 拒启;换代那次抛 = 候选整拒(`applyEffective` 抛,与 stage 抛同路)。第一次交表带着名臂与**此前已收下的值**(引擎收过、env 不变 ⇒ 同值照收),
|
|
73
78
|
* 所以这一次抛只可能是名的问题。
|
|
74
|
-
* · **值臂**:{@link serverCredentialValueSources}
|
|
75
|
-
*
|
|
76
|
-
*
|
|
79
|
+
* · **值臂**:{@link serverCredentialValueSources} 的每一个变量此刻装着的每一枚凭据({@link credentialsHeldBy}:整值,列表形另加每一枚),逐枚交给引擎**同一只**判
|
|
80
|
+
* (不另写「什么算凭据值」的第二份判据):引擎收下 ⇒ 记进值臂;
|
|
81
|
+
* 引擎拒(不是凭据值:空白 / 占位词 / 一个字符重复 / 不足 8 字符;或它是每个子进程都会拿到的变量的值)⇒ 这一枚不扣(同一变量的其余几枚照收)、名照扣、**不拒启**(与引擎自己的收值口
|
|
82
|
+
* `holdOwnCredentialValues` 同一姿势:不收 + 说一次),经留痕座结构化点名那个变量一次(它装着几枚被拒都是一行)—— `warn` 行 `own_credential_value_not_withheld { name, reason }`
|
|
77
83
|
* ({@link recordOwnCredentialValueNotWithheld};`reason` 是引擎拒句原文,从不回显值;起服第一步还没有 logger 时当拍经进程默认的 JSON 行日志器写 stderr,不缓冲),能力位 `inherit_env.own_credential_values_withheld`
|
|
78
84
|
* 因此答 false(位真 ⇔ 值臂真扣)。引擎拒一个值时声明保持上一份,所以逐个交表的中间态都是上一份的超集。
|
|
79
|
-
* 🔴
|
|
80
|
-
*
|
|
81
|
-
* 本仓不在引擎外面吞 console、也不拿声明口去抢引擎的「每进程每值说一次」账(下游不改上游座的语义);等 core 给席或让声明口的拒收记作已说。读数与翻面条件:
|
|
82
|
-
* `test/own-credential-value-boot-lines.test.ts`(真主进程;零裸行的期望以 `it.fails` 立着,core 改形那天转红再翻成常规钉)。
|
|
85
|
+
* 🔴 **这一行是唯一的一行**:值是网关密钥(`MODEL_API_KEY` / `ANTHROPIC_API_KEY`)时,引擎在适配器构造口收下同一个值,声明口拒过的值它记作已说、不再说第二遍
|
|
86
|
+
* (core 7.62.0 起;此前那里另有一行引擎的裸 `console.warn`)。读数:`test/own-credential-value-boot-lines.test.ts`(真主进程,零裸文本行)。
|
|
83
87
|
* 返回声明的名单(只名、不值)。
|
|
84
88
|
*/
|
|
85
89
|
export declare function declareServerWithheldEnv(modelApiKeyEnv?: ModelApiKeyEnvTable): readonly string[];
|
|
@@ -92,15 +96,40 @@ export declare function withdrawServerWithheldEnv(): void;
|
|
|
92
96
|
/** 把活配置交给能力位读(stage-01 / run-local 在 `loadConfig()` 之后各一次;读的是 `config.modelApiKeyEnv` 这个**属性**,commit 整表重赋值之后看到的就是新表)。 */
|
|
93
97
|
export declare function bindOwnCredentialsConfig(config: Pick<ServiceConfig, "modelApiKeyEnv">): void;
|
|
94
98
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
99
|
+
* 「引擎此刻扣不扣这些名」的**唯一读法**:给哪张表就判哪张表的应声明集合({@link serverWithheldEnvNames}),答引擎此刻**没有**扣下的那些名(空 = 全扣)。
|
|
100
|
+
* 读引擎本尊的判官 `inheritEnvPolicyProblem`(名单解析器 ② 判「点到本服务自有凭据名」问的同一只;按平台比名),不读本文件的镜像 `declared` ——
|
|
101
|
+
* 镜像只是声明口的写者状态(并集 / 深度 1 撤回),答「扣没扣」的只有引擎:引擎的声明是进程级的(换一份模块图、镜像归零,它照在)。两个读者:
|
|
102
|
+
* `loadConfig` 的声明前提({@link ownCredentialDeclarationRefusal},起服表 = 空表)与能力位({@link ownCredentialsWithheld},活表)。
|
|
103
|
+
*/
|
|
104
|
+
export declare function ownCredentialNamesNotWithheld(modelApiKeyEnv?: ModelApiKeyEnvTable): readonly string[];
|
|
105
|
+
/**
|
|
106
|
+
* 🔴 `loadConfig()` 的前提:本进程的自有凭据名(起服表 = 目录 secret 名 ∪ 名单型旋钮名)此刻全被引擎扣下 —— 否则拒因(句子只写这一处),满足 ⇒ `undefined`。
|
|
107
|
+
* 名单型旋钮的自有凭据判与每一条宿主腿的扣留都读引擎此刻的声明;声明为空时判官恒答「合法」⇒ 名单点到本服务凭据照收、宿主子进程照拿,零声响。
|
|
108
|
+
* 三个进程入口第一步就声明(stage-01 / run-local 先于 `loadConfig()`,bake-runner 先于它自己的 env 读),所以本服务起服序里这句永远不出现;
|
|
109
|
+
* 它说给不经入口直接调 `loadConfig()` 的进程听(包根的嵌入方、bench、探针脚本):出路一步 —— 先调包根的 {@link declareServerWithheldEnv}。
|
|
110
|
+
* 回显的是变量**名**(不是值)。
|
|
111
|
+
*/
|
|
112
|
+
export declare function ownCredentialDeclarationRefusal(): string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* 能力词 `inherit_env.own_credentials_withheld` 在本进程的事实:当前生效配置应声明的每一个名,引擎此刻都扣着({@link ownCredentialNamesNotWithheld} 为空)。
|
|
115
|
+
* 是一次比较,不是「声明过」的旗 —— 活表若被谁绕过声明写了新名,这里立刻 false(位不替流程担保)。没绑活配置 / 引擎没扣 ⇒ false(fail-closed)。
|
|
97
116
|
*/
|
|
98
117
|
export declare function ownCredentialsWithheld(): boolean;
|
|
99
118
|
/**
|
|
100
|
-
* 能力词 `inherit_env.own_credential_values_withheld`(core 7.52.0)在本进程的事实:当前生效配置的每一个凭据值来源({@link serverCredentialValueSources})
|
|
101
|
-
*
|
|
119
|
+
* 能力词 `inherit_env.own_credential_values_withheld`(core 7.52.0)在本进程的事实:当前生效配置的每一个凭据值来源({@link serverCredentialValueSources})此刻装着的
|
|
120
|
+
* **每一枚**凭据({@link credentialsHeldBy})都已交进值臂、被引擎收下。位真 ⇔ 值臂真扣:有一枚被引擎判「扣不了」⇒ false;env 里没有值的来源没有东西可扣,不影响事实。
|
|
121
|
+
* 没绑活配置 / 没声明过 ⇒ false。
|
|
102
122
|
*/
|
|
103
123
|
export declare function ownCredentialValuesWithheld(): boolean;
|
|
124
|
+
/** {@link ownCredentialVariable} 的答案:这个变量是本服务的凭据,因为它的**名**是声明过的自有凭据名,还是它此刻的**值**是本服务的某一枚凭据(另一个名下的副本)。 */
|
|
125
|
+
export type OwnCredentialHold = "name" | "value";
|
|
126
|
+
/**
|
|
127
|
+
* 「本进程环境里这个变量是不是本服务的自有凭据」的**唯一读法**(判官 = 引擎此刻的声明;本仓不比值、不持值):名是声明过的自有凭据名 ⇒ `"name"`;
|
|
128
|
+
* 名不是,而它此刻的值等于引擎扣着的某一枚凭据(值臂按颗粒逐枚声明的,或引擎自己收下的)⇒ `"value"`;都不是 / 变量不在本进程环境里 ⇒ `undefined`。
|
|
129
|
+
* 值的那一半读引擎严格名单臂对这一名的扣留(`inheritedHostEnv([name])` 的 `own-credential` 发现 —— 严格名单不做形状剥,那里扣下的只有自有凭据一类)。
|
|
130
|
+
* 调用方先判过名形(引擎对坏形名同样答「有问题」,会被读成 `"name"`)。读者:名单型旋钮的解析器 ② 与声明增长时的重判(`config.ts` `ownCredentialHitsInForce`)。
|
|
131
|
+
*/
|
|
132
|
+
export declare function ownCredentialVariable(name: string): OwnCredentialHold | undefined;
|
|
104
133
|
/** 测试缝:撤回声明(引擎侧重声明为空表)、忘掉两份声明镜像、点名记账与活配置;生产代码从不调它。 */
|
|
105
134
|
export declare function __resetServerWithheldEnvForTest(): void;
|
|
106
135
|
/** 一条宿主腿要什么:现场(留痕)、继承策略(缺省 `"scrub"`;按头注「腿的继承词」一条由调用点定)、部署方点名放回的键、调用方显式交的授予(按序叠在继承之上,后者赢)。 */
|
|
@@ -117,8 +146,9 @@ export interface HostSubprocessEnvRequest {
|
|
|
117
146
|
* 不是剥除,不计数、不披露。源 env 恒为本进程 env(引擎只读 `process.env`,本仓没有第二个源)。
|
|
118
147
|
*
|
|
119
148
|
* 九条宿主腿都只经它(直接或经 {@link gitSubprocessEnv}):host shell(三个继承词原样交给 `policy`)、project-memory / center-plugins / leader 三条 git 腿、
|
|
120
|
-
* 本地语言服务器、bake-runner 的每一只子进程组、local-docker 与 adb 两条 CLI 腿(`"all"`)、settings hooks 的命令腿(十二名严格名单 + 有效环境层作授予)。`allow` 只在**有部署级出路**的现场非空(今天 = `LSP_ENV_ALLOW` / `BAKE_ENV_ALLOW`,
|
|
121
|
-
* 它们的现场在 `SECRET_ENV_SCRUB_SITES` 里登记了 `remedy`,披露行因此是 warn + 放行名单 +
|
|
149
|
+
* 本地语言服务器、bake-runner 的每一只子进程组、local-docker 与 adb 两条 CLI 腿(`"all"`)、settings hooks 的命令腿(十二名严格名单 ∪ `HOOK_ENV_ALLOW` 放回 + 有效环境层作授予)。`allow` 只在**有部署级出路**的现场非空(今天 = `LSP_ENV_ALLOW` / `BAKE_ENV_ALLOW`,
|
|
150
|
+
* 它们的现场在 `SECRET_ENV_SCRUB_SITES` 里登记了 `remedy`,披露行因此是 warn + 放行名单 + 出路句;settings hooks 的 `HOOK_ENV_ALLOW` 也走这只槽,但那条腿是严格名单,
|
|
151
|
+
* finding 只有自有凭据的扣留、任何名单都放不回,现场登记 `remedy: null`,理由在登记处);其余现场传 `[]`。
|
|
122
152
|
* 「扣了哪些名字」一腿一个读者:host shell 腿由引擎读 `withheldEnv` 说(`inherit_env.names_withheld`,现场登记 `told:"engine-notice"` ⇒ 本函数对它只计数、不写披露行);
|
|
123
153
|
* 其余各条腿(含 host 适配器类里不交给引擎的 git worktree 基环境,`HostEnvConfig.gitBase`)引擎没有读者,披露行是唯一的读法(`told:"log"`)。
|
|
124
154
|
* 返回 `NodeJS.ProcessEnv` 形(值可能是 `undefined` 的键本来就不会进子进程);调用方显式要交的键(`LC_ALL`、`cfg.env` …)叠在它之上。
|