@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
package/dist/text-bidi.d.ts
CHANGED
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `text-bidi.ts` —— 双向控制符(bidi)与 C0 控制符字符类的**单一属主**。
|
|
3
|
-
*
|
|
4
|
-
* ## 为什么有这个文件
|
|
5
|
-
* 同一条字符类此前在本仓有两份逐字手抄(`session-titler.ts` 的 `sanitizeTitle`、
|
|
6
|
-
* `plugins/send-user-file.ts` 的 `sanitizeSendFileName`),第三份还要给审批卡的 bidi **在场检测**用。
|
|
7
|
-
* 这是一条安全语义上的词表(它划定「人眼看到的顺序可能不是字节顺序」那一族码点),三份手抄必然漂移 ——
|
|
8
|
-
* 单一属主的纪律与 `APPROVAL_GATE_KINDS` 同源(CLAUDE.md 硬条款:词表是闭集,不许散落副本)。
|
|
9
|
-
*
|
|
10
|
-
* ## 两条类刻意分开(**别合并**)
|
|
11
|
-
* · {@link BIDI_CONTROL_CHARS} —— **只有** bidi 一族(LRM/RLM、嵌入与覆写、隔离符)。它是**检测**用的:
|
|
12
|
-
* 问的是「这串文本里有没有能让人眼读到与执行顺序不同的东西」。C0 控制符不属于这一问 —— 一条 Bash
|
|
13
|
-
* 命令里出现换行、一段 diff 里出现制表符都是**正常**的,把它们算进来会让检测位恒为真、从而毫无判别力。
|
|
14
|
-
* · {@link CONTROL_AND_BIDI_CHARS} —— bidi ∪ C0/DEL,**清洗**用的(标题、文件名这类要落一行的短串)。
|
|
15
|
-
* 清洗面比检测面宽是对的:那两处要的是「只留可打印的一行」。
|
|
16
|
-
*
|
|
17
|
-
* ## 案锚
|
|
18
|
-
* Trojan Source([ref]②;`docs/DISEASE-SHAPES.md` 的不可见字符条):字面控制符让**人审与机器门看到
|
|
19
|
-
* 两份不同的文本**。审批卡是本仓唯一一处「把模型写的命令交给人眼判断」的面,所以它需要的是**披露**
|
|
20
|
-
* (告诉壳「这串里有 bidi」),不是清洗 —— 清洗会改掉即将被执行的那串字节,让卡上显示的与真正跑的不是
|
|
21
|
-
* 同一个东西,那比不披露更坏。
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* bidi 一族的字符类**内容**(不含方括号,便于拼进更大的类)。
|
|
25
|
-
*
|
|
26
|
-
* 逐字 = Unicode 的 `Bidi_Control=Yes` **全集**(12 个码点),不是「常见的那几个」:
|
|
27
|
-
* · U+061C = ALM(Arabic Letter Mark);U+200E/200F = LRM/RLM;
|
|
28
|
-
* · U+202A-202E = 嵌入/覆写族(含 RLO);U+2066-2069 = 隔离符族。
|
|
29
|
-
*
|
|
30
|
-
* 🔴 **U+061C 是 codex 交叉复审 [medium] 验真后补的**:首版漏了它 —— 而漏一个码点在**检测**面上不是
|
|
31
|
-
* 「覆盖率差一点」,是一条完整的跳过路(只用 ALM 构造的输入让在场位缺席,壳于是照常按干净渲染)。
|
|
32
|
-
* 交叉锚:core 自己的 `APPROVER_REFUSED_CHARS_RE`(`dist/core/tool-policy.js`)同样含 `\\u061c`。
|
|
33
|
-
*
|
|
34
|
-
* ⚠️ 与 core 那只**更宽**的集合的差额如实登记(刻意,不是漏):core 还含 C1(`\\u0080-\\u009f`)与
|
|
35
|
-
* U+2028/U+2029(行/段分隔符)。那两族**不是 bidi**(不影响阅读方向),属于「不可打印 / 换行伪装」的
|
|
36
|
-
* 另一问;本类是 bidi 专用,混进来会让 {@link hasBidiControls} 的语义从「方向可能骗你」滑成「有奇怪
|
|
37
|
-
* 字符」。清洗面要不要跟着加宽是另一件(见 {@link CONTROL_AND_BIDI_CHARS} 的注)。
|
|
38
|
-
*/
|
|
39
|
-
export declare const BIDI_CONTROL_CHARS = "\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069";
|
|
40
|
-
/** bidi ∪ C0/DEL —— **清洗**面用(见文件头注:清洗面比检测面宽是刻意的)。
|
|
41
|
-
* ⚠️ 仍**不含** C1(`-`)与 U+2028/U+2029:加宽是行为变更、要各自的判据支撑,不搭本批的车
|
|
42
|
-
* (登记在此,别当成漏)。两处存量消费方(标题、文件名)较其手抄前身**多剥一枚 U+061C**
|
|
43
|
-
* (经 {@link BIDI_CONTROL_CHARS} 内插带入)—— 对本清洗类是有意收紧,merge-rescan 745 验真后
|
|
44
|
-
* 钉在两消费方各自的测试里;除此之外与手抄前身逐字同集。 */
|
|
45
|
-
export declare const CONTROL_AND_BIDI_CHARS = "\\u0000-\\u001f\\u007f\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069";
|
|
46
|
-
/** 清洗用的全局正则(`String.replace` 会在返回前把 `lastIndex` 归零,故模块级常量可安全复用)。 */
|
|
47
|
-
export declare const CONTROL_AND_BIDI_STRIP_RE: RegExp;
|
|
48
|
-
/** 这串文本里**有没有** bidi 控制符。纯谓词:不改一个字节、不做任何清洗(理由见文件头注)。 */
|
|
1
|
+
/** 这串文本里**有没有** bidi 控制符(判官 = core 的 {@link carriesBidiControls})。纯谓词:不改一个字节、不做任何清洗(理由见文件头注)。 */
|
|
49
2
|
export declare function hasBidiControls(text: string): boolean;
|
|
50
3
|
//# sourceMappingURL=text-bidi.d.ts.map
|
package/dist/text-bidi.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const CONTROL_AND_BIDI_STRIP_RE = new RegExp(`[${CONTROL_AND_BIDI_CHARS}]`, "g");
|
|
4
|
-
const BIDI_DETECT_RE = new RegExp(`[${BIDI_CONTROL_CHARS}]`);
|
|
1
|
+
import { carriesBidiControls } from "@sema-agent/core";
|
|
2
|
+
const WHOLE_TEXT_SCAN = { maxNodes: 1, maxChars: Number.MAX_SAFE_INTEGER };
|
|
5
3
|
export function hasBidiControls(text) {
|
|
6
|
-
return
|
|
4
|
+
return carriesBidiControls(text, WHOLE_TEXT_SCAN);
|
|
7
5
|
}
|
|
8
6
|
//# sourceMappingURL=text-bidi.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **请求面「只收紧」座位族** —— 团队仓库里只会收紧的四张列表,在 `settings` 面各有一个每请求座位:一张闭集座位表、一组受理判据、一个能力位。
|
|
3
|
+
*
|
|
4
|
+
* | 座位(`settings.…`) | 去处 | 部署侧的表 |
|
|
5
|
+
* |-------------------------------------|-----------------------------------------------------------------------------------------------|-------------------------------------|
|
|
6
|
+
* | `readDenyPatterns` | core 任务层席 `TaskSpec.readDenyPatterns`(只增不减) | `READ_DENY_PATTERNS` |
|
|
7
|
+
* | `writeProtectedExtra` | core 任务层席 `TaskSpec.writeProtectedAdditions`(只增不减) | `WRITE_PROTECTED_EXTRA` |
|
|
8
|
+
* | `complianceAdditionalDenies` | core 任务层席 `TaskSpec.complianceAdditionalDenies`(只增不减) | `COMPLIANCE_ADDITIONAL_DENIES` |
|
|
9
|
+
* | `permissions.neverAuto` | 本仓审批席的请求叶策略(命中的工具恒问真人;见 `approval.ts` `createRequestNeverAutoPolicy`) | `APPROVAL_NEVER_AUTO` |
|
|
10
|
+
*
|
|
11
|
+
* ## 律
|
|
12
|
+
* · **取并在拥有部署表的那一层做一次**:三座的部署表在 core 的 `RunnerDeps`(`readDenyPatterns` / `writeProtectedPaths` / `compliancePostureResolver`),与任务层列表的并集由 core 在 prepare 取
|
|
13
|
+
* (`CLAMP_SET` 的 addOnly 律:`[]` 不抹任何行、任务层只加不减);`neverAuto` 的部署表在本仓审批席,请求叶与基线名单经 `tightenGoverned` 的 deny-wins 折叠取并。
|
|
14
|
+
* **本仓不在折叠之外手写第二份并集** —— 那是下游改上游席语义(并集规则一份在 core,哪天 core 改身份函数,本仓的副本会静默分岔)。
|
|
15
|
+
* · **空数组 ≡ 缺席**(并集的单位元):读入时不铸键,spec 与不带这个座位的请求字节相同。
|
|
16
|
+
* · **请求面没有放宽臂**:列表只能加行;送空、送别的行,部署的表一行不少。
|
|
17
|
+
* · **条目律借引擎的判官**(同一批 env 腿读的那几只:`compileReadDeny` / `resolveWriteProtectedTable` / `COMPLIANCE_CAPABILITIES`),宿主不自造第二份校验语义;读拒条目的元素文法 env / 中心 / 请求三腿同读
|
|
18
|
+
* `read-deny-entry.ts` 的那一只。受理面在 prepare 之前把坏形响亮拒掉(400),不让它变成 200 之后才失败的一跑。
|
|
19
|
+
* · 受理判据一处({@link tightenOnlySeatIssue}):不是数组 / 超帽 / 坏项 ⇒ 400 `request.field_invalid` + 机读位(`field` / `reason` / `count`+`cap` | `index`),与 S-904 三桶同形。
|
|
20
|
+
* fresh 受理口、`resolveSpec`(两腿)、存体重放预判三处调这一只。
|
|
21
|
+
* · 座位表是闭集:加一座 = 加一行(`TIGHTEN_ONLY_SEAT_NAMES` 与表互为编译期穷举;`wire` 位置必须落在 `task-settings.ts` 的受理列里 —— 下面的编译期门)。
|
|
22
|
+
*
|
|
23
|
+
* 谁调:`task-settings.ts`(`parseTaskSettings` 读入 · `applyTaskSettings` 投影 · 键闭集门)· `http/admission.ts` / `boot/resolve-spec.ts` / `http/stored-body-replay.ts`(受理判据)·
|
|
24
|
+
* `http/routes/capabilities.ts`(能力位 `taskSettings.tightenOnlySeats`)· `request-key-closure.ts`(顶层同名键的拒句指路)。
|
|
25
|
+
*/
|
|
26
|
+
import { type ComplianceCapability, type ReadDenyEntry, type WriteProtectedEntry } from "@sema-agent/core";
|
|
27
|
+
import type { GovernanceOverrides } from "./governance-overrides.js";
|
|
28
|
+
import { type LimitFacts } from "./limit-refusal.js";
|
|
29
|
+
/** 四座(表序;句子说「表序里第一座」)。 */
|
|
30
|
+
export declare const TIGHTEN_ONLY_SEAT_NAMES: readonly ["neverAuto", "readDenyPatterns", "writeProtectedExtra", "complianceAdditionalDenies"];
|
|
31
|
+
export type TightenOnlySeatName = (typeof TIGHTEN_ONLY_SEAT_NAMES)[number];
|
|
32
|
+
/** 每座一个条目的类型(归一后的值;进 spec / 请求叶的就是它,不另投影)。 */
|
|
33
|
+
interface SeatEntryTypes {
|
|
34
|
+
readonly neverAuto: string;
|
|
35
|
+
readonly readDenyPatterns: ReadDenyEntry;
|
|
36
|
+
readonly writeProtectedExtra: WriteProtectedEntry;
|
|
37
|
+
readonly complianceAdditionalDenies: ComplianceCapability;
|
|
38
|
+
}
|
|
39
|
+
/** 读入的产物:每座一份归一后的非空列表(缺席的座不在)。 */
|
|
40
|
+
export type TightenOnlySeatValues = {
|
|
41
|
+
readonly [N in TightenOnlySeatName]?: readonly SeatEntryTypes[N][];
|
|
42
|
+
};
|
|
43
|
+
type SeatValuesDraft = {
|
|
44
|
+
-readonly [N in TightenOnlySeatName]?: readonly SeatEntryTypes[N][];
|
|
45
|
+
};
|
|
46
|
+
/** 三座落 core 任务层席时进 spec 的片段(键 = core 的 `TaskSpec` 席名)。 */
|
|
47
|
+
export type TightenOnlySpecSeats = Pick<GovernanceOverrides, "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies">;
|
|
48
|
+
/** 座位在 `settings` 里的位置:顶层键,或 `permissions` 下的一个成员。 */
|
|
49
|
+
type SeatWire = readonly [key: string] | readonly [container: "permissions", key: string];
|
|
50
|
+
declare const SEAT_WIRE: {
|
|
51
|
+
readonly neverAuto: readonly ["permissions", "neverAuto"];
|
|
52
|
+
readonly readDenyPatterns: readonly ["readDenyPatterns"];
|
|
53
|
+
readonly writeProtectedExtra: readonly ["writeProtectedExtra"];
|
|
54
|
+
readonly complianceAdditionalDenies: readonly ["complianceAdditionalDenies"];
|
|
55
|
+
};
|
|
56
|
+
/** 编译期门:每座的 wire 位置都在 `task-settings.ts` 的受理列里(座位表加一行而受理列没跟 ⇒ 这里红 —— 否则键闭集门会把新座 400 掉)。 */
|
|
57
|
+
type SeatTopKeys = Extract<(typeof SEAT_WIRE)[TightenOnlySeatName], readonly [string]>[0];
|
|
58
|
+
type SeatPermissionKeys = Extract<(typeof SEAT_WIRE)[TightenOnlySeatName], readonly ["permissions", string]>[1];
|
|
59
|
+
/** 一个条目的读数:归一值,或接在坐标后面成句的原因(自带连接符)。 */
|
|
60
|
+
type EntryReading<E> = {
|
|
61
|
+
readonly ok: true;
|
|
62
|
+
readonly value: E;
|
|
63
|
+
} | {
|
|
64
|
+
readonly ok: false;
|
|
65
|
+
readonly after: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* 一行座位。方法写成**方法签名**(参数双变):表是异质的,遍历时由 {@link eachSeat} 用同一个 `E` 把一行的读 / 放 / 投影三件事配回去。
|
|
69
|
+
* · `grammar` —— 句子里说「这张表该装什么」;
|
|
70
|
+
* · `readEntry` —— 一个条目的受理判(借引擎的判官);
|
|
71
|
+
* · `get` / `put` —— 归一值在 {@link TightenOnlySeatValues} 里的位置(每行自己拼一次本座的键,类型检查);
|
|
72
|
+
* · `sink` —— 去处:core 任务层席(`toSpec` 给出进 spec 的片段)或本仓审批席。
|
|
73
|
+
*/
|
|
74
|
+
interface SeatRow<E> {
|
|
75
|
+
readonly wire: SeatWire;
|
|
76
|
+
readonly grammar: string;
|
|
77
|
+
readEntry(entry: unknown): EntryReading<E>;
|
|
78
|
+
get(values: TightenOnlySeatValues): readonly E[] | undefined;
|
|
79
|
+
put(draft: SeatValuesDraft, list: readonly E[]): void;
|
|
80
|
+
/** 这一座的条数帽(超了响亮拒 `over_cap`,不截;先于逐条读,拒体有界)。 */
|
|
81
|
+
readonly maxEntries: number;
|
|
82
|
+
/** 整张列表的**成本预算**(可选;只给「引擎匹配代价随条目内容增长」的座):`measure` 数一张列表占多少预算,超 `cap` ⇒ 响亮拒(`over_cap` + `count` + `cap`),不截。 */
|
|
83
|
+
readonly budget?: {
|
|
84
|
+
measure(list: readonly E[]): number;
|
|
85
|
+
readonly cap: number;
|
|
86
|
+
readonly unit: string;
|
|
87
|
+
};
|
|
88
|
+
readonly sink: {
|
|
89
|
+
readonly kind: "core_task_seat";
|
|
90
|
+
toSpec(list: readonly E[]): TightenOnlySpecSeats;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: "approval_seat";
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 读拒模式的**成本单位 = 一颗 `*`**:引擎(core `compileSegmentPattern`)把每一颗 `*` 编成一个 `[^/]*`,相邻的星就是相邻的回溯点 ——
|
|
97
|
+
* 一段里 k 颗 `*` 对长度 n 的路径段是 n 的 k 次方级回溯(实测 16 颗连续的星对 17 字的段 ≈ 4 s,跑在事件循环上、任何计时器打不断)。
|
|
98
|
+
* 所以界按**调用方写下的每一颗**计,不按「连续的一串」计。整段 `**` / `id_rsa*` / `*.pem` / `*secret*` / `*_*_key` / `a**b` 都在内。
|
|
99
|
+
*/
|
|
100
|
+
export declare const MAX_READ_DENY_STARS_PER_SEGMENT = 2;
|
|
101
|
+
/** 整张 `readDenyPatterns` 列表的 `*` 总预算:引擎每次判路径对每条模式、每个路径段各跑一遍,一段 2 颗星是段长的平方 —— 总量只界住「乘几遍」(128 颗时 64 条的表对万字段 ≈ 3.9 s)。
|
|
102
|
+
* 不是上界:16 颗的整表(8 条各 2 颗)对对手形的 4000 字段本机实测约 1 s、万字段约 5–6 s;段长的那一维只能在引擎里收(线性时间匹配或路径段长度上限,已向引擎请托)。 */
|
|
103
|
+
export declare const MAX_READ_DENY_STARS_TOTAL = 16;
|
|
104
|
+
/** 每座条数的缺省上限 —— 与 `settings.permissions` 三桶同一只帽(编译口的整表帽;超了响亮拒,不截)。读拒模式另有更紧的一只({@link MAX_READ_DENY_ENTRIES}),每座的帽写在座位表那一行。 */
|
|
105
|
+
export declare const MAX_TIGHTEN_ONLY_SEAT_ENTRIES = 1000;
|
|
106
|
+
/** 整张 `readDenyPatterns` 列表的条数帽:不带星的条目也是每段一遍匹配,条数本身就是成本(其余三座的帽是 {@link MAX_TIGHTEN_ONLY_SEAT_ENTRIES})。 */
|
|
107
|
+
export declare const MAX_READ_DENY_ENTRIES = 32;
|
|
108
|
+
/** 座位表(闭集;`{ [N in 座名]: SeatRow }` 双向穷举:少一座 / 多一座都是编译红)。 */
|
|
109
|
+
export declare const TIGHTEN_ONLY_SEATS: {
|
|
110
|
+
readonly [N in TightenOnlySeatName]: SeatRow<SeatEntryTypes[N]>;
|
|
111
|
+
};
|
|
112
|
+
/** 一座在体内的坐标的**字面类型**(`settings.readDenyPatterns` | … | `settings.permissions.neverAuto`),从 {@link SEAT_WIRE} 派生,不手抄。 */
|
|
113
|
+
export type TightenOnlySeatField = `settings.${SeatTopKeys}` | `settings.permissions.${SeatPermissionKeys}`;
|
|
114
|
+
/** 一座在体内的坐标(`settings.readDenyPatterns` / `settings.permissions.neverAuto`)。 */
|
|
115
|
+
export declare function tightenOnlySeatField(name: TightenOnlySeatName): TightenOnlySeatField;
|
|
116
|
+
/** 拒体的机读位:撞帽 = {@link LimitFacts}(`over_cap` + `count` + `cap`),坏项 = `bad_entry`(+ 首个坏项的下标;整座不是数组时无下标)。 */
|
|
117
|
+
export type TightenOnlySeatIssueFields = LimitFacts | {
|
|
118
|
+
readonly field: string;
|
|
119
|
+
readonly reason: "bad_entry";
|
|
120
|
+
readonly index?: number;
|
|
121
|
+
};
|
|
122
|
+
/** 一次裁决:是哪一座、wire 文案、机读位。 */
|
|
123
|
+
export interface TightenOnlySeatIssue {
|
|
124
|
+
readonly seat: TightenOnlySeatName;
|
|
125
|
+
readonly message: string;
|
|
126
|
+
readonly fields: TightenOnlySeatIssueFields;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 四座的**唯一**受理判据(纯函数)。逐座按表序(整表判只有 {@link readSeat} 一只,本函数与 {@link readTightenOnlySeats} 共用):缺席 / `null` ⇒ 不判;不是数组 ⇒ `bad_entry`(无下标);
|
|
130
|
+
* 超帽 ⇒ `over_cap`(先于逐条读,拒体有界);首个坏条目 ⇒ `bad_entry` + 它的下标;成本预算超了 ⇒ `over_cap`(`count` = 占用,`cap` = 预算)。全合法 ⇒ `null`。空数组合法(单位元)。
|
|
131
|
+
* 句子出口剥控制与双向字符(引擎的原因句可能转载调用方的条目文字)。
|
|
132
|
+
*/
|
|
133
|
+
export declare function tightenOnlySeatIssue(settings: unknown): TightenOnlySeatIssue | null;
|
|
134
|
+
/** 读入的结果:归一后的非空列表(空数组 ≡ 缺席,不铸键);判据说不合法的座**整座丢弃**并报名(`rejected`)—— 只有绕过两道入口的读者走得到,留痕由调用方记。 */
|
|
135
|
+
export interface ReadTightenOnlySeats {
|
|
136
|
+
readonly values: TightenOnlySeatValues;
|
|
137
|
+
readonly rejected: readonly TightenOnlySeatName[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 把一份**未验过**的 `settings` 读成四座的归一值(`parseTaskSettings` 的读入腿 —— RESUME 重放也走这里,所以宽容:不抛、坏座整座丢弃并报名)。
|
|
141
|
+
* 与 {@link tightenOnlySeatIssue} 共用 {@link readSeat}(同一只整表判):fresh 提交与续跑在更早处已被它响亮拒过,这里是宽容层。
|
|
142
|
+
*/
|
|
143
|
+
export declare function readTightenOnlySeats(settings: unknown): ReadTightenOnlySeats;
|
|
144
|
+
/**
|
|
145
|
+
* 三座落 core 任务层席的 spec 片段(进 `tightenGoverned` 的 `TaskSpec` 席名 —— 与部署表取并由 core 的 addOnly 律在 prepare 做一次)。没有这三座的值 ⇒ `{}`。
|
|
146
|
+
* `neverAuto` 不在这里(它的去处是审批席的请求叶策略,见 `approval.ts` 的 `createRequestNeverAutoPolicy`)。
|
|
147
|
+
*/
|
|
148
|
+
export declare function tightenOnlySpecSeats(values: TightenOnlySeatValues): TightenOnlySpecSeats;
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=tighten-only-seats.d.ts.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { COMPLIANCE_CAPABILITIES, compileReadDeny, resolveWriteProtectedTable } from "@sema-agent/core";
|
|
2
|
+
import { echoCallerText } from "./caller-text-echo.js";
|
|
3
|
+
import { limitRefusal } from "./limit-refusal.js";
|
|
4
|
+
import { MAX_PERMISSION_RULES_PER_LIST } from "./permission-rule-list.js";
|
|
5
|
+
import { readReadDenyEntry } from "./read-deny-entry.js";
|
|
6
|
+
import { stripControlAndBidi } from "@sema-agent/settings-schema";
|
|
7
|
+
export const TIGHTEN_ONLY_SEAT_NAMES = ["neverAuto", "readDenyPatterns", "writeProtectedExtra", "complianceAdditionalDenies"];
|
|
8
|
+
const SEAT_WIRE = {
|
|
9
|
+
neverAuto: ["permissions", "neverAuto"],
|
|
10
|
+
readDenyPatterns: ["readDenyPatterns"],
|
|
11
|
+
writeProtectedExtra: ["writeProtectedExtra"],
|
|
12
|
+
complianceAdditionalDenies: ["complianceAdditionalDenies"],
|
|
13
|
+
};
|
|
14
|
+
const CORE_REASON_ECHO_CHARS = 400;
|
|
15
|
+
function coreReason(e) {
|
|
16
|
+
const text = e instanceof Error ? e.message : String(e);
|
|
17
|
+
return echoCallerText(text.replace(/^(?:readDenyPatterns \(additions\)|writeProtectedPaths): /, ""), { maxChars: CORE_REASON_ECHO_CHARS });
|
|
18
|
+
}
|
|
19
|
+
export const MAX_READ_DENY_STARS_PER_SEGMENT = 2;
|
|
20
|
+
export const MAX_READ_DENY_STARS_TOTAL = 16;
|
|
21
|
+
export const MAX_TIGHTEN_ONLY_SEAT_ENTRIES = MAX_PERMISSION_RULES_PER_LIST;
|
|
22
|
+
export const MAX_READ_DENY_ENTRIES = 32;
|
|
23
|
+
const starsIn = (text) => (text.match(/\*/g) ?? []).length;
|
|
24
|
+
function maxStarsPerSegment(pattern) {
|
|
25
|
+
return pattern.split("/").reduce((max, segment) => Math.max(max, starsIn(segment)), 0);
|
|
26
|
+
}
|
|
27
|
+
function isComplianceCapability(entry) {
|
|
28
|
+
return COMPLIANCE_CAPABILITIES.includes(entry);
|
|
29
|
+
}
|
|
30
|
+
export const TIGHTEN_ONLY_SEATS = {
|
|
31
|
+
neverAuto: {
|
|
32
|
+
wire: SEAT_WIRE.neverAuto,
|
|
33
|
+
grammar: "non-empty tool-name strings",
|
|
34
|
+
readEntry: (entry) => (typeof entry === "string" && entry.length > 0 ? { ok: true, value: entry } : { ok: false, after: " is not a non-empty tool name string" }),
|
|
35
|
+
maxEntries: MAX_TIGHTEN_ONLY_SEAT_ENTRIES,
|
|
36
|
+
get: (values) => values.neverAuto,
|
|
37
|
+
put: (draft, list) => {
|
|
38
|
+
draft.neverAuto = list;
|
|
39
|
+
},
|
|
40
|
+
sink: { kind: "approval_seat" },
|
|
41
|
+
},
|
|
42
|
+
readDenyPatterns: {
|
|
43
|
+
wire: SEAT_WIRE.readDenyPatterns,
|
|
44
|
+
grammar: "read-deny patterns (a string, or an object { pattern, caseSensitive? })",
|
|
45
|
+
readEntry: (entry) => {
|
|
46
|
+
const read = readReadDenyEntry(entry);
|
|
47
|
+
if (!read.ok)
|
|
48
|
+
return { ok: false, after: read.after };
|
|
49
|
+
try {
|
|
50
|
+
compileReadDeny([read.entry]);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return { ok: false, after: ` is refused by the engine: ${coreReason(e)}` };
|
|
54
|
+
}
|
|
55
|
+
const stars = maxStarsPerSegment(read.entry.pattern);
|
|
56
|
+
if (stars > MAX_READ_DENY_STARS_PER_SEGMENT) {
|
|
57
|
+
return { ok: false, after: ` has a path segment with ${stars} "*" wildcards — at most ${MAX_READ_DENY_STARS_PER_SEGMENT} per segment are accepted in a request, each "*" counted (the engine matches a segment by backtracking and the cost grows with each extra wildcard); merge them, or ask the operator to put the row in READ_DENY_PATTERNS` };
|
|
58
|
+
}
|
|
59
|
+
return { ok: true, value: read.entry };
|
|
60
|
+
},
|
|
61
|
+
maxEntries: MAX_READ_DENY_ENTRIES,
|
|
62
|
+
get: (values) => values.readDenyPatterns,
|
|
63
|
+
put: (draft, list) => {
|
|
64
|
+
draft.readDenyPatterns = list;
|
|
65
|
+
},
|
|
66
|
+
budget: { measure: (list) => list.reduce((sum, entry) => sum + starsIn(typeof entry === "string" ? entry : entry.pattern), 0), cap: MAX_READ_DENY_STARS_TOTAL, unit: `"*" wildcards` },
|
|
67
|
+
sink: { kind: "core_task_seat", toSpec: (list) => ({ readDenyPatterns: [...list] }) },
|
|
68
|
+
},
|
|
69
|
+
writeProtectedExtra: {
|
|
70
|
+
wire: SEAT_WIRE.writeProtectedExtra,
|
|
71
|
+
grammar: "write-protection names (a literal name string, or an object { name, kind })",
|
|
72
|
+
readEntry: (entry) => {
|
|
73
|
+
try {
|
|
74
|
+
const rows = resolveWriteProtectedTable([entry]);
|
|
75
|
+
const row = rows[0];
|
|
76
|
+
if (rows.length !== 1 || row === undefined)
|
|
77
|
+
return { ok: false, after: " does not read as exactly one write-protection row" };
|
|
78
|
+
return { ok: true, value: row };
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
return { ok: false, after: ` is refused by the engine: ${coreReason(e)}` };
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
maxEntries: MAX_TIGHTEN_ONLY_SEAT_ENTRIES,
|
|
85
|
+
get: (values) => values.writeProtectedExtra,
|
|
86
|
+
put: (draft, list) => {
|
|
87
|
+
draft.writeProtectedExtra = list;
|
|
88
|
+
},
|
|
89
|
+
sink: { kind: "core_task_seat", toSpec: (list) => ({ writeProtectedAdditions: [...list] }) },
|
|
90
|
+
},
|
|
91
|
+
complianceAdditionalDenies: {
|
|
92
|
+
wire: SEAT_WIRE.complianceAdditionalDenies,
|
|
93
|
+
grammar: `capability names (${COMPLIANCE_CAPABILITIES.join("|")})`,
|
|
94
|
+
readEntry: (entry) => isComplianceCapability(entry)
|
|
95
|
+
? { ok: true, value: entry }
|
|
96
|
+
: { ok: false, after: ` is not one of ${COMPLIANCE_CAPABILITIES.join("|")}` },
|
|
97
|
+
maxEntries: MAX_TIGHTEN_ONLY_SEAT_ENTRIES,
|
|
98
|
+
get: (values) => values.complianceAdditionalDenies,
|
|
99
|
+
put: (draft, list) => {
|
|
100
|
+
draft.complianceAdditionalDenies = list;
|
|
101
|
+
},
|
|
102
|
+
sink: { kind: "core_task_seat", toSpec: (list) => ({ complianceAdditionalDenies: [...list] }) },
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
function eachSeat(visit) {
|
|
106
|
+
return TIGHTEN_ONLY_SEAT_NAMES.map((name) => visit(name, TIGHTEN_ONLY_SEATS[name]));
|
|
107
|
+
}
|
|
108
|
+
export function tightenOnlySeatField(name) {
|
|
109
|
+
const wire = SEAT_WIRE[name];
|
|
110
|
+
return wire.length === 1 ? `settings.${wire[0]}` : `settings.${wire[0]}.${wire[1]}`;
|
|
111
|
+
}
|
|
112
|
+
function rawListOf(settings, wire) {
|
|
113
|
+
if (settings === null || typeof settings !== "object" || Array.isArray(settings))
|
|
114
|
+
return undefined;
|
|
115
|
+
const top = settings[wire[0]];
|
|
116
|
+
if (wire.length === 1)
|
|
117
|
+
return top;
|
|
118
|
+
if (top === null || typeof top !== "object" || Array.isArray(top))
|
|
119
|
+
return undefined;
|
|
120
|
+
return top[wire[1]];
|
|
121
|
+
}
|
|
122
|
+
function readSeat(name, row, settings) {
|
|
123
|
+
const raw = rawListOf(settings, row.wire);
|
|
124
|
+
if (raw === undefined || raw === null)
|
|
125
|
+
return { kind: "absent" };
|
|
126
|
+
const field = tightenOnlySeatField(name);
|
|
127
|
+
const refuse = (message, fields) => ({ kind: "refused", seat: name, message: sanitized(message), fields });
|
|
128
|
+
if (!Array.isArray(raw)) {
|
|
129
|
+
return refuse(`${field} must be an array of ${row.grammar} — refused rather than ignored, because an ignored list reads as "in effect" to the caller`, { field, reason: "bad_entry" });
|
|
130
|
+
}
|
|
131
|
+
if (raw.length > row.maxEntries) {
|
|
132
|
+
const refusal = limitRefusal(field, "entries", raw.length, row.maxEntries, {
|
|
133
|
+
tail: "Refused rather than truncated: a truncated list silently drops the entries past the cap, and a dropped tightening is one that never happened. Merge entries into broader patterns or trim the list",
|
|
134
|
+
});
|
|
135
|
+
return refuse(refusal.message, refusal.facts);
|
|
136
|
+
}
|
|
137
|
+
const list = [];
|
|
138
|
+
for (let index = 0; index < raw.length; index++) {
|
|
139
|
+
const read = row.readEntry(raw[index]);
|
|
140
|
+
if (!read.ok) {
|
|
141
|
+
const after = read.after.replace(/\.$/, "");
|
|
142
|
+
return refuse(`${field}[${index}]${after} — every entry must be ${row.grammar}. Refused rather than dropped, because a dropped entry reads as "in effect" to the caller`, { field, reason: "bad_entry", index });
|
|
143
|
+
}
|
|
144
|
+
list.push(read.value);
|
|
145
|
+
}
|
|
146
|
+
const budget = row.budget;
|
|
147
|
+
if (budget !== undefined) {
|
|
148
|
+
const count = budget.measure(list);
|
|
149
|
+
if (count > budget.cap) {
|
|
150
|
+
return refuse(`${field} has ${count} ${budget.unit} in total — at most ${budget.cap} are accepted. Refused rather than truncated: a truncated list silently drops the entries past the budget, and a dropped tightening is one that never happened. Merge entries into broader patterns or trim the list`, { field, reason: "over_cap", count, cap: budget.cap });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { kind: "list", list };
|
|
154
|
+
}
|
|
155
|
+
export function tightenOnlySeatIssue(settings) {
|
|
156
|
+
for (const reading of eachSeat((name, row) => readSeat(name, row, settings))) {
|
|
157
|
+
if (reading.kind === "refused")
|
|
158
|
+
return { seat: reading.seat, message: reading.message, fields: reading.fields };
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
function sanitized(message) {
|
|
163
|
+
return stripControlAndBidi(message);
|
|
164
|
+
}
|
|
165
|
+
export function readTightenOnlySeats(settings) {
|
|
166
|
+
const draft = {};
|
|
167
|
+
const rejected = [];
|
|
168
|
+
eachSeat((name, row) => {
|
|
169
|
+
const reading = readSeat(name, row, settings);
|
|
170
|
+
if (reading.kind === "refused")
|
|
171
|
+
rejected.push(name);
|
|
172
|
+
else if (reading.kind === "list" && reading.list.length > 0)
|
|
173
|
+
row.put(draft, reading.list);
|
|
174
|
+
});
|
|
175
|
+
return { values: draft, rejected };
|
|
176
|
+
}
|
|
177
|
+
export function tightenOnlySpecSeats(values) {
|
|
178
|
+
const fragments = eachSeat((_name, row) => {
|
|
179
|
+
const list = row.get(values);
|
|
180
|
+
if (list === undefined || list.length === 0)
|
|
181
|
+
return undefined;
|
|
182
|
+
const sink = row.sink;
|
|
183
|
+
switch (sink.kind) {
|
|
184
|
+
case "core_task_seat":
|
|
185
|
+
return sink.toSpec(list);
|
|
186
|
+
case "approval_seat":
|
|
187
|
+
return undefined;
|
|
188
|
+
default: {
|
|
189
|
+
const unhandled = sink;
|
|
190
|
+
throw new Error(`tighten-only seat sink ${JSON.stringify(unhandled)} has no projection arm`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return fragments.reduce((acc, fragment) => (fragment === undefined ? acc : { ...acc, ...fragment }), {});
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=tighten-only-seats.js.map
|