@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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MemoryProjectKey, type MemoryProjectKeyAbsentReason } from "@sema-agent/core";
|
|
2
|
+
import { type ProjectLayerIdentity } from "./project-layer-key.js";
|
|
2
3
|
/** core 的项目身份声明席(`TaskSpec.memory.projectKey`)—— core 包根导出的型,原样转出(本仓调用方从这里取)。 */
|
|
3
4
|
export type { MemoryProjectKey };
|
|
4
5
|
/** 本仓会说的缺席词。`not_git` 刻意排除:裁 D 起非 git 目录按目录键控,不是缺席(core 闭集仍收它,本仓不铸)。 */
|
|
@@ -16,12 +17,50 @@ export type ProjectIdentity = {
|
|
|
16
17
|
* 一次向上走,规则三条按优先序:最近的 `.git`(① ② ③)> 链上最近的裸仓布局(④ bare)> 非 git 按目录键控(④)。
|
|
17
18
|
*/
|
|
18
19
|
export declare function resolveProjectIdentity(taskRoot: string): ProjectIdentity;
|
|
19
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* 退役 `repo:` 键的**唯一**铸点([ref] ①:`repo:` + sha256 hex 前 24;`root` 为 realpath 字符串,不加尾斜杠、不折大小写)。
|
|
22
|
+
* S-640 起它只是一次性迁移的来源(`memory-project-layer.ts` 把这一层的条目折进新键;窗见 `plugins/one-time-migrations.ts` 登记表)。
|
|
23
|
+
*/
|
|
20
24
|
export declare function mintRepoScopeKey(projectRoot: string): string;
|
|
25
|
+
/** 这把键是不是本仓铸的项目键族(现行 `userrepo:` 或退役的 `repo:`)—— 运维不许把它们点名成全局层 / 同步层。 */
|
|
26
|
+
export declare function isServerMintedProjectKey(key: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 起服判据:这个全局层(或同步层)能不能拥有项目层 —— 不是本仓铸的族,且属主段编码得出来(core 段编码 ≤ 64)。不能 ⇒ 抛一句点名出路的配置错。
|
|
29
|
+
* 调用方:`config.ts` 记忆域(单用户 + 记忆引擎开着时问 `MEMORY_SCOPE`;开同步时问同步层)。
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertProjectLayerOwnable(scope: string, envName: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* 远端 URL 归一(`r` 档的输入)—— 同一个仓的不同写法收成同一串,两个仓**不许**并成一串,凭据不进串:
|
|
34
|
+
* · scp 形 `[user@]host:path`(主机至少两个字符 —— 单字母是 Windows 盘符)与 scheme 形 `scheme://[userinfo@]host[:port]/path` ⇒ `host[:port]/path`
|
|
35
|
+
* (去 userinfo;主机小写;端口是该 scheme 的缺省值才去掉;路径大小写保留:不同托管对大小写的读法不同,折了会把两个仓合成一个);
|
|
36
|
+
* · 本地路径远端(`file://`、绝对 / 相对路径)⇒ `undefined`:它不是跨设备身份(相对路径还取决于 checkout 在哪),调用方落本 checkout 的 `p` 档;
|
|
37
|
+
* · 路径去首尾 `/`、去尾 `.git`、连续 `/` 收成一个;主机为空 ⇒ `undefined`。
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeGitRemoteUrl(url: string): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* 任务根 → 项目层身份(S-640):当前档(`r` 优先,没有 origin 退 `p`)+ 本 checkout 的低档(`r` 档时 = 它的 `p` 档)。
|
|
42
|
+
* 缺席形与 {@link resolveProjectIdentity} 同;git 配置在而读不了 ⇒ `unreadable`。
|
|
43
|
+
*/
|
|
44
|
+
export declare function projectLayerIdentityOf(taskRoot: string): {
|
|
45
|
+
readonly root: string;
|
|
46
|
+
readonly identity: ProjectLayerIdentity;
|
|
47
|
+
readonly lowerTiers: readonly ProjectLayerIdentity[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly absent: ProjectIdentityAbsentReason;
|
|
50
|
+
};
|
|
51
|
+
/** 一个任务的项目层:core 声明席 + 本 checkout 要折进来的低档 / 退役层(按序,`memory-project-layer.ts` 折)。 */
|
|
52
|
+
export interface ProjectLayerOfTask {
|
|
53
|
+
readonly key: MemoryProjectKey;
|
|
54
|
+
readonly foldFrom: readonly string[];
|
|
55
|
+
}
|
|
21
56
|
/**
|
|
22
|
-
* 任务根 →
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
57
|
+
* 任务根 → 项目层(S-640:`userrepo:<属主段>/<档>.<摘要>`,属主 = `owner`,调用方由 `projectLayerOwnerOf(全局层)` 求得)。
|
|
58
|
+
* `foldFrom` = 同一 checkout 能推出的旧层:退役 `repo:<同一路径哈希>`(一次性迁移,窗见 `plugins/one-time-migrations.ts` 登记表 M25)
|
|
59
|
+
* + 当前档是 `r` 时它的 `p` 档(常设律)。
|
|
60
|
+
* `taskRoot === undefined` = 调用方**此刻不知道**任务根在本机哪里(根在沙箱/设备盘上;或 host 车道会话没登记 cwd、手落在 factory 现铸的
|
|
61
|
+
* 临时目录)⇒ `unreadable` —— 「我看不到」,不是「这里没有项目」。
|
|
25
62
|
*/
|
|
26
|
-
export declare function
|
|
63
|
+
export declare function projectLayerForTaskRoot(taskRoot: string | undefined, owner: string): ProjectLayerOfTask;
|
|
64
|
+
/** {@link projectLayerForTaskRoot} 的声明席投影(core `TaskSpec.memory.projectKey`)。 */
|
|
65
|
+
export declare function projectKeyForTaskRoot(taskRoot: string | undefined, owner: string): MemoryProjectKey;
|
|
27
66
|
//# sourceMappingURL=project-identity.d.ts.map
|
package/dist/project-identity.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readFileSync, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { encodeScopeSegment } from "@sema-agent/core";
|
|
5
|
+
import { mintProjectLayerKey, PROJECT_LAYER_KEY_PREFIX, projectLayerOwnerOf } from "./project-layer-key.js";
|
|
4
6
|
const UNREADABLE = { absent: "unreadable" };
|
|
5
7
|
const BARE = { absent: "bare" };
|
|
6
8
|
function isMissing(err) {
|
|
@@ -53,7 +55,7 @@ function identityOfGitFile(dir) {
|
|
|
53
55
|
const gitDir = gitDirFact.ok;
|
|
54
56
|
const commonText = readTextFact(join(gitDir, "commondir"));
|
|
55
57
|
if (commonText === "missing")
|
|
56
|
-
return { root: dir };
|
|
58
|
+
return { root: dir, gitConfig: join(gitDir, "config") };
|
|
57
59
|
if (commonText === "unreadable")
|
|
58
60
|
return UNREADABLE;
|
|
59
61
|
const commonFact = realpathFact(resolve(gitDir, commonText.ok));
|
|
@@ -68,7 +70,7 @@ function identityOfGitFile(dir) {
|
|
|
68
70
|
const backFact = realpathFact(resolve(gitDir, back.ok));
|
|
69
71
|
if (typeof backFact !== "object" || backFact.ok !== join(dir, ".git"))
|
|
70
72
|
return UNREADABLE;
|
|
71
|
-
return { root: basename(common) !== ".git" ? common : dirname(common) };
|
|
73
|
+
return { root: basename(common) !== ".git" ? common : dirname(common), gitConfig: join(common, "config") };
|
|
72
74
|
}
|
|
73
75
|
function canonicalTaskRoot(taskRoot) {
|
|
74
76
|
const rest = [];
|
|
@@ -86,6 +88,10 @@ function canonicalTaskRoot(taskRoot) {
|
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
export function resolveProjectIdentity(taskRoot) {
|
|
91
|
+
const located = locateProject(taskRoot);
|
|
92
|
+
return "root" in located ? { root: located.root } : located;
|
|
93
|
+
}
|
|
94
|
+
function locateProject(taskRoot) {
|
|
89
95
|
const root = canonicalTaskRoot(taskRoot);
|
|
90
96
|
if (root === "unreadable")
|
|
91
97
|
return UNREADABLE;
|
|
@@ -96,7 +102,7 @@ export function resolveProjectIdentity(taskRoot) {
|
|
|
96
102
|
return UNREADABLE;
|
|
97
103
|
if (typeof dotGit === "object") {
|
|
98
104
|
if (dotGit.ok === "dir")
|
|
99
|
-
return { root: dir };
|
|
105
|
+
return { root: dir, gitConfig: join(dir, ".git", "config") };
|
|
100
106
|
if (dotGit.ok === "file")
|
|
101
107
|
return identityOfGitFile(dir);
|
|
102
108
|
}
|
|
@@ -108,13 +114,161 @@ export function resolveProjectIdentity(taskRoot) {
|
|
|
108
114
|
dir = parent;
|
|
109
115
|
}
|
|
110
116
|
}
|
|
117
|
+
function digest24(text) {
|
|
118
|
+
return createHash("sha256").update(text, "utf8").digest("hex").slice(0, 24);
|
|
119
|
+
}
|
|
120
|
+
const RETIRED_PROJECT_KEY_PREFIX = "repo:";
|
|
111
121
|
export function mintRepoScopeKey(projectRoot) {
|
|
112
|
-
return
|
|
122
|
+
return `${RETIRED_PROJECT_KEY_PREFIX}${digest24(projectRoot)}`;
|
|
123
|
+
}
|
|
124
|
+
export function isServerMintedProjectKey(key) {
|
|
125
|
+
return key.startsWith(PROJECT_LAYER_KEY_PREFIX) || key.startsWith(RETIRED_PROJECT_KEY_PREFIX);
|
|
126
|
+
}
|
|
127
|
+
export function assertProjectLayerOwnable(scope, envName) {
|
|
128
|
+
if (isServerMintedProjectKey(scope)) {
|
|
129
|
+
throw new Error(`${envName}=${JSON.stringify(scope)} names a server-minted project-layer key (the "${PROJECT_LAYER_KEY_PREFIX}" family, or the retired "${RETIRED_PROJECT_KEY_PREFIX}" family) — ` +
|
|
130
|
+
"project layers are derived per task from the project identity and cannot be named as a deployment scope. Use a user key (user:<principal>) or a plain name.");
|
|
131
|
+
}
|
|
132
|
+
const owner = ownerSegmentFact(scope);
|
|
133
|
+
if (!owner.ok) {
|
|
134
|
+
throw new Error(`${envName}=${JSON.stringify(scope)} cannot own per-project memory layers: ${owner.why} — ` +
|
|
135
|
+
"the layer owner (the principal of a user: key, otherwise the name itself) must encode to at most 64 scope-segment characters.");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function ownerSegmentFact(scope) {
|
|
139
|
+
try {
|
|
140
|
+
encodeScopeSegment(projectLayerOwnerOf(scope));
|
|
141
|
+
return { ok: true };
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return { ok: false, why: err instanceof Error ? err.message : String(err) };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const GIT_CONFIG_MAX_BYTES = 256 * 1024;
|
|
148
|
+
function readOriginRemoteUrl(configPath) {
|
|
149
|
+
const st = statFact(configPath);
|
|
150
|
+
if (st === "missing")
|
|
151
|
+
return "missing";
|
|
152
|
+
if (st === "unreadable" || st.ok !== "file")
|
|
153
|
+
return "unreadable";
|
|
154
|
+
let size;
|
|
155
|
+
try {
|
|
156
|
+
size = statSync(configPath).size;
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
return isMissing(err) ? "missing" : "unreadable";
|
|
160
|
+
}
|
|
161
|
+
if (size > GIT_CONFIG_MAX_BYTES)
|
|
162
|
+
return "unreadable";
|
|
163
|
+
const text = readTextFact(configPath);
|
|
164
|
+
if (typeof text !== "object")
|
|
165
|
+
return text;
|
|
166
|
+
let inOrigin = false;
|
|
167
|
+
for (const raw of gitConfigLogicalLines(text.ok)) {
|
|
168
|
+
const line = raw.trim();
|
|
169
|
+
if (line.startsWith("[")) {
|
|
170
|
+
const header = /^\[\s*([A-Za-z0-9.-]+)(?:\s+"((?:[^"\\]|\\.)*)")?\s*\]/.exec(line);
|
|
171
|
+
inOrigin = header !== null && header[1].toLowerCase() === "remote" && header[2] !== undefined && header[2].replace(/\\(.)/g, "$1") === "origin";
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (!inOrigin)
|
|
175
|
+
continue;
|
|
176
|
+
const kv = /^([A-Za-z][A-Za-z0-9-]*)\s*=\s*(.*)$/.exec(line);
|
|
177
|
+
if (kv === null || kv[1].toLowerCase() !== "url")
|
|
178
|
+
continue;
|
|
179
|
+
const value = gitConfigValue(kv[2]);
|
|
180
|
+
if (value !== "")
|
|
181
|
+
return { ok: value };
|
|
182
|
+
}
|
|
183
|
+
return { ok: undefined };
|
|
184
|
+
}
|
|
185
|
+
function gitConfigLogicalLines(text) {
|
|
186
|
+
const out = [];
|
|
187
|
+
let pending = "";
|
|
188
|
+
for (const physical of text.split(/\r?\n/)) {
|
|
189
|
+
const trailing = /\\*$/.exec(physical)[0].length;
|
|
190
|
+
if (trailing % 2 === 1) {
|
|
191
|
+
pending += physical.slice(0, -1);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
out.push(pending + physical);
|
|
195
|
+
pending = "";
|
|
196
|
+
}
|
|
197
|
+
if (pending !== "")
|
|
198
|
+
out.push(pending);
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
function gitConfigValue(raw) {
|
|
202
|
+
let out = "";
|
|
203
|
+
let quoted = false;
|
|
204
|
+
for (let i = 0; i < raw.length; i++) {
|
|
205
|
+
const c = raw[i];
|
|
206
|
+
if (c === "\\" && i + 1 < raw.length) {
|
|
207
|
+
out += raw[++i];
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (c === '"') {
|
|
211
|
+
quoted = !quoted;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (!quoted && (c === "#" || c === ";"))
|
|
215
|
+
break;
|
|
216
|
+
out += c;
|
|
217
|
+
}
|
|
218
|
+
return out.trim();
|
|
219
|
+
}
|
|
220
|
+
const DEFAULT_REMOTE_PORTS = { ssh: "22", "git+ssh": "22", "ssh+git": "22", https: "443", http: "80", git: "9418" };
|
|
221
|
+
export function normalizeGitRemoteUrl(url) {
|
|
222
|
+
const u = url.trim();
|
|
223
|
+
const scheme = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/(.*)$/.exec(u);
|
|
224
|
+
if (scheme !== null) {
|
|
225
|
+
const name = scheme[1].toLowerCase();
|
|
226
|
+
if (name === "file")
|
|
227
|
+
return undefined;
|
|
228
|
+
const rest = scheme[2];
|
|
229
|
+
const slash = rest.indexOf("/");
|
|
230
|
+
const authority = slash < 0 ? rest : rest.slice(0, slash);
|
|
231
|
+
const hostPort = authority.slice(authority.lastIndexOf("@") + 1);
|
|
232
|
+
const port = /:(\d*)$/.exec(hostPort);
|
|
233
|
+
const host = (port === null ? hostPort : hostPort.slice(0, port.index)).toLowerCase();
|
|
234
|
+
if (host === "")
|
|
235
|
+
return undefined;
|
|
236
|
+
const keptPort = port !== null && port[1] !== "" && port[1] !== DEFAULT_REMOTE_PORTS[name] ? `:${port[1]}` : "";
|
|
237
|
+
return `${host}${keptPort}/${cleanRemotePath(slash < 0 ? "" : rest.slice(slash))}`;
|
|
238
|
+
}
|
|
239
|
+
const scp = /^(?:[^@/]+@)?([^:/]{2,}):(.*)$/.exec(u);
|
|
240
|
+
if (scp !== null)
|
|
241
|
+
return `${scp[1].toLowerCase()}/${cleanRemotePath(scp[2])}`;
|
|
242
|
+
return undefined;
|
|
113
243
|
}
|
|
114
|
-
|
|
244
|
+
function cleanRemotePath(p) {
|
|
245
|
+
return p.replace(/\/+/g, "/").replace(/^\/+|\/+$/g, "").replace(/\.git$/, "");
|
|
246
|
+
}
|
|
247
|
+
export function projectLayerIdentityOf(taskRoot) {
|
|
248
|
+
const located = locateProject(taskRoot);
|
|
249
|
+
if (!("root" in located))
|
|
250
|
+
return located;
|
|
251
|
+
const path = { tier: "p", digest: digest24(located.root) };
|
|
252
|
+
const origin = located.gitConfig !== undefined ? readOriginRemoteUrl(located.gitConfig) : "missing";
|
|
253
|
+
if (origin === "unreadable")
|
|
254
|
+
return UNREADABLE;
|
|
255
|
+
const remote = origin === "missing" || origin.ok === undefined ? undefined : normalizeGitRemoteUrl(origin.ok);
|
|
256
|
+
if (remote === undefined)
|
|
257
|
+
return { root: located.root, identity: path, lowerTiers: [] };
|
|
258
|
+
return { root: located.root, identity: { tier: "r", digest: digest24(remote) }, lowerTiers: [path] };
|
|
259
|
+
}
|
|
260
|
+
export function projectLayerForTaskRoot(taskRoot, owner) {
|
|
115
261
|
if (taskRoot === undefined)
|
|
116
|
-
return {
|
|
117
|
-
const id =
|
|
118
|
-
|
|
262
|
+
return { key: UNREADABLE, foldFrom: [] };
|
|
263
|
+
const id = projectLayerIdentityOf(taskRoot);
|
|
264
|
+
if (!("identity" in id))
|
|
265
|
+
return { key: { absent: id.absent }, foldFrom: [] };
|
|
266
|
+
return {
|
|
267
|
+
key: { scope: mintProjectLayerKey(owner, id.identity) },
|
|
268
|
+
foldFrom: [mintRepoScopeKey(id.root), ...id.lowerTiers.map((tier) => mintProjectLayerKey(owner, tier))],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
export function projectKeyForTaskRoot(taskRoot, owner) {
|
|
272
|
+
return projectLayerForTaskRoot(taskRoot, owner).key;
|
|
119
273
|
}
|
|
120
274
|
//# sourceMappingURL=project-identity.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** 项目层键的前缀(改名链的前缀词表也读它)。 */
|
|
2
|
+
export declare const PROJECT_LAYER_KEY_PREFIX = "userrepo:";
|
|
3
|
+
/** 身份档:`r` = 仓库身份(origin 远端,跨设备),`p` = 项目根路径(本机)。 */
|
|
4
|
+
export type ProjectIdentityTier = "r" | "p";
|
|
5
|
+
/** 一个项目的身份段(档 + 24 位小写十六进制摘要)。 */
|
|
6
|
+
export interface ProjectLayerIdentity {
|
|
7
|
+
readonly tier: ProjectIdentityTier;
|
|
8
|
+
readonly digest: string;
|
|
9
|
+
}
|
|
10
|
+
/** 解出的项目层键。 */
|
|
11
|
+
export interface ParsedProjectLayerKey {
|
|
12
|
+
/** 解码后的属主(主体名,或不透明全局层名本身)。 */
|
|
13
|
+
readonly owner: string;
|
|
14
|
+
readonly identity: ProjectLayerIdentity;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 全局层 → 它的属主(见文件头文法)。`user:` 形用 core 的解析(段解码、规范形校验);坏的 `user:` 形照 core 原样抛
|
|
18
|
+
* (`config.memory_scope_key`)—— 起服经 `project-identity.ts` `assertProjectLayerOwnable` 在第一刻接住,不留到任务期。
|
|
19
|
+
*/
|
|
20
|
+
export declare function projectLayerOwnerOf(globalScope: string): string;
|
|
21
|
+
/** 铸项目层键。属主编码超长 / 空 ⇒ core 段编码原样抛(起服已由 `assertProjectLayerOwnable` 拦住)。 */
|
|
22
|
+
export declare function mintProjectLayerKey(owner: string, identity: ProjectLayerIdentity): string;
|
|
23
|
+
/**
|
|
24
|
+
* 解项目层键。**严格**:前缀 + 恰好一个 `/` + 规范形属主段(`%41` 这类第二种拼法不认 —— 一个属主不许有两把键)+ 档文法。
|
|
25
|
+
* 不合任何一条 ⇒ `undefined`(调用方读作「不是项目层」;属主门据此答与其余拒绝同体的 404)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseProjectLayerKey(key: string): ParsedProjectLayerKey | undefined;
|
|
28
|
+
//# sourceMappingURL=project-layer-key.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { decodeScopeSegment, encodeScopeSegment, parseScopeKey } from "@sema-agent/core";
|
|
2
|
+
export const PROJECT_LAYER_KEY_PREFIX = "userrepo:";
|
|
3
|
+
const DIGEST = /^[0-9a-f]{24}$/;
|
|
4
|
+
const KEY = /^userrepo:((?:[A-Za-z0-9._-]|%[0-9A-F]{2})+)\/([rp])\.([0-9a-f]{24})$/;
|
|
5
|
+
export function projectLayerOwnerOf(globalScope) {
|
|
6
|
+
const parsed = parseScopeKey(globalScope);
|
|
7
|
+
return parsed.kind === "user" ? parsed.principal : globalScope;
|
|
8
|
+
}
|
|
9
|
+
export function mintProjectLayerKey(owner, identity) {
|
|
10
|
+
if (!DIGEST.test(identity.digest))
|
|
11
|
+
throw new Error(`project layer identity digest must be 24 lowercase hex characters, got ${JSON.stringify(identity.digest)}`);
|
|
12
|
+
return `${PROJECT_LAYER_KEY_PREFIX}${encodeScopeSegment(owner)}/${identity.tier}.${identity.digest}`;
|
|
13
|
+
}
|
|
14
|
+
export function parseProjectLayerKey(key) {
|
|
15
|
+
const m = KEY.exec(key);
|
|
16
|
+
if (m === null)
|
|
17
|
+
return undefined;
|
|
18
|
+
const owner = decodeOwnerSegment(m[1]);
|
|
19
|
+
return owner.ok ? { owner: owner.owner, identity: { tier: m[2], digest: m[3] } } : undefined;
|
|
20
|
+
}
|
|
21
|
+
function decodeOwnerSegment(segment) {
|
|
22
|
+
try {
|
|
23
|
+
return { ok: true, owner: decodeScopeSegment(segment) };
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
return { ok: false, why: err instanceof Error ? err.message : String(err) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=project-layer-key.js.map
|
|
@@ -1,66 +1,22 @@
|
|
|
1
|
-
import { type PromptTextDeclaration, type PublishedPromptArtifactEnvelope } from "@sema-agent/core";
|
|
2
|
-
/** [ref]⓪ 下发形(remote effective 的 additive key,JSON verbatim 面——不经 registry-core parse,所以
|
|
3
|
-
* cli 补位前 center 发的 `contentHash` 也原样到达)。 */
|
|
4
|
-
export interface EffectiveCenterPrompts {
|
|
5
|
-
/** `center:<contentDigest 前 12>` — 纯内容寻址(同内容重发布=同 packId,epoch 不误重 pin)。 */
|
|
6
|
-
packId: string;
|
|
7
|
-
/** canonical JSON 全量 sha256(非盐化,operator 对账位 [ref]②)。 */
|
|
8
|
-
contentDigest: string;
|
|
9
|
-
/** covering 已在 center 走完的基线终形(层信息不下发,worker 零解析义务)。 */
|
|
10
|
-
sections: PromptTextDeclaration[];
|
|
11
|
-
/** per-scenario 完整重算终形(整包替换基线,非增量);无键=用基线。 */
|
|
12
|
-
scenarioOverrides?: Record<string, PromptTextDeclaration[]>;
|
|
13
|
-
}
|
|
14
1
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
2
|
+
* prompts 域候选门 —— 中心提示层的**唯一判官**(中立叶子:只依赖 `@sema-agent/core` 与契约包 `@sema-agent/settings-schema`,
|
|
3
|
+
* 不依赖 capabilities / config 任何东西;候选判官 `web-admin-client/candidate-gate.ts` 是它唯一的调用点,LKG 读回经同一只候选判官)。
|
|
4
|
+
*
|
|
5
|
+
* 律:中心层只有一种 wire 形 —— `{ schemaVersion: 2, artifact }`(契约包 `EffectivePromptsWire`;artifact 是引擎当期 schema 的发布形)。
|
|
6
|
+
* 判法两步一线:先过契约包的 wire 形(外壳、键闭集、结构与上界;旧两轴 / v2 artifact 的拒句是契约包的原句),再交引擎
|
|
7
|
+
* `verifyPromptArtifact`(语义:每条 overlay 在中心类的档权内、锁定文本、requires 复算、同目标冲突、digest —— 拒句是引擎的原句)。
|
|
8
|
+
* 本模块不写任何形判、不铸任何句子、不归一任何别的形:中心不带 prompts 键 = 不下发中心层(调用方据此撤下);带了就必须是这一种形,
|
|
9
|
+
* 否则整份候选拒(一个域都不应用)。
|
|
18
10
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
import { type PublishedPromptArtifact } from "@sema-agent/core";
|
|
12
|
+
/** 判官的结论:收下 ⇒ 引擎 verify 过的发布形 artifact(调用方交给引擎的中心源采用);拒 ⇒ 拒因(契约包 / 引擎的原句)。 */
|
|
13
|
+
export type PromptsWireVerdict = {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
readonly artifact: PublishedPromptArtifact;
|
|
22
16
|
} | {
|
|
23
|
-
ok: false;
|
|
24
|
-
error: string;
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly error: string;
|
|
25
19
|
};
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
* 第一手教训)。解析失败回 "0.0.0" = range-gated artifact 被诚实拒(fail-closed 响,绝不静默采用)。 */
|
|
29
|
-
export declare const CORE_ENGINE_VERSION: string;
|
|
30
|
-
/** validatePromptsDomain 的归一产物:两轴的已判形面 + 变更检测身份(adopt 去重键,跨轴稳定)。 */
|
|
31
|
-
export interface PromptsDomainFaces {
|
|
32
|
-
/** A 形(declaration 轴)——centerPromptProvider 继续消费(现行链路零改动)。 */
|
|
33
|
-
declarations?: EffectiveCenterPrompts;
|
|
34
|
-
/** B 形(catalog 轴)——core S1 verify 已过(digest 复算/上限/range 全管线);server 不解释内容,
|
|
35
|
-
* 原样交 core artifact 仓(e/b 班车接线位)。 */
|
|
36
|
-
catalog?: PublishedPromptArtifactEnvelope;
|
|
37
|
-
/** 采用去重键:两轴 digest 拼接(轴缺席记 "-")。 */
|
|
38
|
-
identity: string;
|
|
39
|
-
/** 观测面([ref]a §3:`center_prompts_adopted` 增 axes,看两轴共存窗)。 */
|
|
40
|
-
axes: Array<"declarations" | "catalog">;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* prompts 域候选门 v2(validateCenterPrompts 的双轴升级;整拒语义不变=任一在场轴坏形 ⇒ 整个 prompts
|
|
44
|
-
* 面拒绝采用,LKG/内置继续服务)。唯一认可形=`{schemaVersion:1, declarations?, catalog?}`
|
|
45
|
-
* (registry-core `EffectivePromptsWire`)至少一轴。[ref]B-9(5.0.0):legacy 平铺兼容窗到期删——
|
|
46
|
-
* 0.13.0 起 EffectivePromptsWire 首字段是 `schemaVersion: z.ZodLiteral<1>`,与 server 共用 ^0.13.0 的
|
|
47
|
-
* 合规 center 不可能再发平铺;非合规体=响亮拒绝(整拒落 LKG/内置),不再静默吸收。
|
|
48
|
-
* catalog 轴的语义权威=core `verifyPromptArtifact`(形/digest 逐位复算/ARTIFACT_LIMITS/compatibleCore
|
|
49
|
-
* range 全在 core 一处——[ref]③ a 解,上限单真源永不漂)。
|
|
50
|
-
*/
|
|
51
|
-
export declare function validatePromptsDomain(raw: unknown): {
|
|
52
|
-
ok: true;
|
|
53
|
-
value: PromptsDomainFaces;
|
|
54
|
-
} | {
|
|
55
|
-
ok: false;
|
|
56
|
-
error: string;
|
|
57
|
-
};
|
|
58
|
-
/** [ref](docs/R100-PROMPTS-LANE-FIX.md §V2-B)worker 腿 effective 上 `prompts` 键的**形-肯定**判别:
|
|
59
|
-
* 消费形特征(v2 `schemaVersion` 键,或 legacy 三键 packId/contentDigest/sections)⇒ 原样返回交
|
|
60
|
-
* {@link validatePromptsDomain}(收或拒,方向不变);其余=center 存储原文(global lane [ref]①e 下发
|
|
61
|
-
* 存储形是合法输入)——catalog 在场则投影 `{schemaVersion:1, catalog}`(config-provider 本地腿先例),
|
|
62
|
-
* 否则视为「center 未发」⇒ undefined。null=有意 cleared 语义([ref] 前 null 走拒,方向为宽是设计变更,
|
|
63
|
-
* 留痕于设计档)。垃圾标量原样返回(fail-loud 归 validate)。
|
|
64
|
-
* 属主放本中立叶:config-lkg 与 boot/refresh 同吃,capabilities 层会重开 S6 刚消的反向依赖边。 */
|
|
65
|
-
export declare function centerPromptsFromEffective(eff: unknown): unknown | undefined;
|
|
20
|
+
/** 一份候选 `prompts` 键的值(在场才调)→ 判官结论。 */
|
|
21
|
+
export declare function judgePromptsWire(raw: unknown): PromptsWireVerdict;
|
|
66
22
|
//# sourceMappingURL=prompts-domain-validate.d.ts.map
|
|
@@ -1,122 +1,12 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
1
|
import { verifyPromptArtifact } from "@sema-agent/core";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return `${where}: bad id`;
|
|
16
|
-
if (o.id.startsWith("core/"))
|
|
17
|
-
return `${where}: id in the reserved core/ namespace`;
|
|
18
|
-
if (typeof o.slot !== "string" || !SLOTS.includes(o.slot))
|
|
19
|
-
return `${where}: bad slot`;
|
|
20
|
-
if (typeof o.text !== "string" || o.text.length === 0)
|
|
21
|
-
return `${where}: text must be a non-empty string`;
|
|
22
|
-
if (typeof o.contentHash !== "string" || !SHA256_DIGEST_RE.test(o.contentHash))
|
|
23
|
-
return `${where}: contentHash is required (sha256:<64hex> — the epoch declaration axis needs it for byte-level change detection)`;
|
|
24
|
-
const expected = `sha256:${createHash("sha256").update(o.text).digest("hex")}`;
|
|
25
|
-
if (o.contentHash !== expected)
|
|
26
|
-
return `${where}: contentHash does not match sha256(text) — stale or altered declaration`;
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
export function validateCenterPrompts(raw) {
|
|
30
|
-
if (raw === null || typeof raw !== "object")
|
|
31
|
-
return { ok: false, error: "prompts is not an object" };
|
|
32
|
-
const p = raw;
|
|
33
|
-
if (typeof p.packId !== "string" || !/^center:[0-9a-f]{12}$/.test(p.packId))
|
|
34
|
-
return { ok: false, error: "bad packId form (center:<digest12>)" };
|
|
35
|
-
if (typeof p.contentDigest !== "string" || !SHA256_DIGEST_RE.test(p.contentDigest))
|
|
36
|
-
return { ok: false, error: "bad contentDigest form" };
|
|
37
|
-
const arrayIssue = (decls, where) => {
|
|
38
|
-
if (!Array.isArray(decls))
|
|
39
|
-
return `${where} is not an array`;
|
|
40
|
-
if (decls.length === 0)
|
|
41
|
-
return `${where} is empty (an empty replacement set is not a v1 semantic — omit the key instead)`;
|
|
42
|
-
const seen = new Set();
|
|
43
|
-
for (let i = 0; i < decls.length; i++) {
|
|
44
|
-
const issue = declarationIssue(decls[i], `${where}[${i}]`);
|
|
45
|
-
if (issue)
|
|
46
|
-
return issue;
|
|
47
|
-
const id = decls[i].id;
|
|
48
|
-
if (seen.has(id))
|
|
49
|
-
return `${where}[${i}]: duplicate id "${id}" (core composer throws on duplicates)`;
|
|
50
|
-
seen.add(id);
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
};
|
|
54
|
-
const sectionsIssue = arrayIssue(p.sections, "sections");
|
|
55
|
-
if (sectionsIssue)
|
|
56
|
-
return { ok: false, error: sectionsIssue };
|
|
57
|
-
if (p.scenarioOverrides !== undefined) {
|
|
58
|
-
if (p.scenarioOverrides === null || typeof p.scenarioOverrides !== "object" || Array.isArray(p.scenarioOverrides)) {
|
|
59
|
-
return { ok: false, error: "scenarioOverrides is not an object" };
|
|
60
|
-
}
|
|
61
|
-
for (const [name, decls] of Object.entries(p.scenarioOverrides)) {
|
|
62
|
-
const issue = arrayIssue(decls, `scenarioOverrides[${name}]`);
|
|
63
|
-
if (issue)
|
|
64
|
-
return { ok: false, error: issue };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { ok: true, value: raw };
|
|
68
|
-
}
|
|
69
|
-
export const CORE_ENGINE_VERSION = (() => {
|
|
70
|
-
try {
|
|
71
|
-
const entry = createRequire(import.meta.url).resolve("@sema-agent/core");
|
|
72
|
-
return JSON.parse(readFileSync(join(dirname(entry), "..", "package.json"), "utf8")).version ?? "0.0.0";
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return "0.0.0";
|
|
76
|
-
}
|
|
77
|
-
})();
|
|
78
|
-
export function validatePromptsDomain(raw) {
|
|
79
|
-
if (raw === null || typeof raw !== "object")
|
|
80
|
-
return { ok: false, error: "prompts is not an object" };
|
|
81
|
-
const w = raw;
|
|
82
|
-
if (w.schemaVersion === undefined) {
|
|
83
|
-
return { ok: false, error: "prompts payload has no schemaVersion — the legacy flat shape was retired in 5.0.0; wrap as {schemaVersion:1, declarations:{...}} (registry-core EffectivePromptsWire)" };
|
|
84
|
-
}
|
|
85
|
-
if (w.schemaVersion !== 1)
|
|
86
|
-
return { ok: false, error: `unsupported prompts schemaVersion ${String(w.schemaVersion)}` };
|
|
87
|
-
if (w.declarations === undefined && w.catalog === undefined)
|
|
88
|
-
return { ok: false, error: "dual-axis prompts carries neither axis (at least one of declarations|catalog required)" };
|
|
89
|
-
const value = { identity: "", axes: [] };
|
|
90
|
-
if (w.declarations !== undefined) {
|
|
91
|
-
const d = validateCenterPrompts(w.declarations);
|
|
92
|
-
if (!d.ok)
|
|
93
|
-
return { ok: false, error: `declarations axis: ${d.error}` };
|
|
94
|
-
value.declarations = d.value;
|
|
95
|
-
value.axes.push("declarations");
|
|
96
|
-
}
|
|
97
|
-
if (w.catalog !== undefined) {
|
|
98
|
-
const c = verifyPromptArtifact(w.catalog, { engineVersion: CORE_ENGINE_VERSION });
|
|
99
|
-
if (!c.ok)
|
|
100
|
-
return { ok: false, error: `catalog axis: ${c.code}: ${c.reason}` };
|
|
101
|
-
value.catalog = w.catalog;
|
|
102
|
-
value.axes.push("catalog");
|
|
103
|
-
}
|
|
104
|
-
value.identity = `${value.declarations?.contentDigest ?? "-"}+${value.catalog?.artifact.artifactDigest ?? "-"}`;
|
|
105
|
-
return { ok: true, value };
|
|
106
|
-
}
|
|
107
|
-
export function centerPromptsFromEffective(eff) {
|
|
108
|
-
const prompts = eff?.prompts;
|
|
109
|
-
if (prompts === undefined || prompts === null)
|
|
110
|
-
return undefined;
|
|
111
|
-
if (typeof prompts !== "object" || Array.isArray(prompts))
|
|
112
|
-
return prompts;
|
|
113
|
-
const o = prompts;
|
|
114
|
-
if ("schemaVersion" in o)
|
|
115
|
-
return prompts;
|
|
116
|
-
if ("packId" in o && "contentDigest" in o && "sections" in o)
|
|
117
|
-
return prompts;
|
|
118
|
-
if (o.catalog !== undefined)
|
|
119
|
-
return { schemaVersion: 1, catalog: o.catalog };
|
|
120
|
-
return undefined;
|
|
2
|
+
import { EffectivePromptsWire, formatConfigPath, sanitizeZodError } from "@sema-agent/settings-schema";
|
|
3
|
+
export function judgePromptsWire(raw) {
|
|
4
|
+
const wire = EffectivePromptsWire.safeParse(raw);
|
|
5
|
+
if (!wire.success) {
|
|
6
|
+
const issues = sanitizeZodError(wire.error).issues.map((i) => `${i.path.length === 0 ? "prompts" : `prompts.${formatConfigPath(i.path.map((s) => (typeof s === "number" ? s : String(s))))}`}: ${i.message}`);
|
|
7
|
+
return { ok: false, error: issues.join("; ") };
|
|
8
|
+
}
|
|
9
|
+
const verified = verifyPromptArtifact(wire.data.artifact);
|
|
10
|
+
return verified.ok ? { ok: true, artifact: verified.artifact } : { ok: false, error: `prompts.artifact refused by the engine (${verified.code}): ${verified.reason}` };
|
|
121
11
|
}
|
|
122
12
|
//# sourceMappingURL=prompts-domain-validate.js.map
|
package/dist/question.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
2
2
|
import { uuidv7 } from "@sema-agent/core";
|
|
3
3
|
import { redactDeep } from "./trace/redact.js";
|
|
4
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
5
|
+
import { refusalBody } from "./http/refusal-body.js";
|
|
5
6
|
const MAX_QUESTIONS_BYTES = 16384;
|
|
6
7
|
function isFaceReachable(ctx) {
|
|
7
8
|
if (ctx.deliverable === undefined)
|
|
@@ -150,10 +151,10 @@ export class QuestionCoordinator {
|
|
|
150
151
|
respond(id, principal, body) {
|
|
151
152
|
const parsed = parseQuestionResponse(body);
|
|
152
153
|
if (!parsed.ok)
|
|
153
|
-
return { status: 400, body: {
|
|
154
|
+
return { status: 400, body: refusalBody({ errorCode: "request.body_shape", message: parsed.error }) };
|
|
154
155
|
const entry = this.pending.get(id);
|
|
155
156
|
if (!entry || (entry.owner !== null && entry.owner !== principal)) {
|
|
156
|
-
return { status: 404, body: {
|
|
157
|
+
return { status: 404, body: refusalBody({ errorCode: "question.not_pending", message: "no pending question for this id (answered, expired, or not on this replica)" }) };
|
|
157
158
|
}
|
|
158
159
|
entry.settle(parsed.value, "answered");
|
|
159
160
|
return { status: 200, body: { questionId: id, delivery: "applied" } };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **读拒模式条目的归一**(全仓唯一一只读法)—— `READ_DENY_PATTERNS` 的 env 腿(`config.ts`)、中心下发 `readFace.denyPatterns` 的腿(`web-admin-client/read-face.ts`)、
|
|
3
|
+
* 请求 `settings.readDenyPatterns` 的腿(`tighten-only-seats.ts`)三处读同一份元素文法:`"pattern"` 裸串简写 ≡ `{ pattern, caseSensitive: false }`,
|
|
4
|
+
* 对象形 `{ pattern: string, caseSensitive?: boolean }`(与 core `ReadDenyEntry = string | {…}` 同宽)。三份手抄的元素读法就是三个会各自漂的真源,所以收成这一只。
|
|
5
|
+
*
|
|
6
|
+
* 只管**元素形**(串 / 带串 `pattern` 的对象 / 布尔 `caseSensitive`);模式编不编得过由调用方交给 core 的 `compileReadDeny`(引擎同一套规则,宿主不自造第二份校验语义)。
|
|
7
|
+
* 返回的是**接在坐标后面的原因尾巴**(` must be a string or an object with a string 'pattern'` / `.caseSensitive must be boolean when present`),不带坐标 —— 调用方自己前缀坐标
|
|
8
|
+
* (`READ_DENY_PATTERNS[2]` / `readFace.denyPatterns[2]` / `settings.readDenyPatterns[2]`),各腿既有的拒句字节不变。叶模块,零 import。
|
|
9
|
+
*/
|
|
10
|
+
/** 归一后的一行(core `compileReadDeny` 收的对象形)。 */
|
|
11
|
+
export interface NormalizedReadDenyEntry {
|
|
12
|
+
readonly pattern: string;
|
|
13
|
+
readonly caseSensitive: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** 一个元素的读数:归一后的行,或接在调用方坐标后面成句的原因尾巴(`after` 自带连接符:空格或点)。 */
|
|
16
|
+
export type ReadDenyEntryReading = {
|
|
17
|
+
readonly ok: true;
|
|
18
|
+
readonly entry: NormalizedReadDenyEntry;
|
|
19
|
+
} | {
|
|
20
|
+
readonly ok: false;
|
|
21
|
+
readonly after: string;
|
|
22
|
+
};
|
|
23
|
+
/** 读一个元素。裸串 ⇒ 大小写默认不敏感(与对象形缺席 `caseSensitive` 一致);坏形 ⇒ 原因子句,不抛、不丢。 */
|
|
24
|
+
export declare function readReadDenyEntry(it: unknown): ReadDenyEntryReading;
|
|
25
|
+
//# sourceMappingURL=read-deny-entry.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function readReadDenyEntry(it) {
|
|
2
|
+
if (typeof it === "string")
|
|
3
|
+
return { ok: true, entry: { pattern: it, caseSensitive: false } };
|
|
4
|
+
if (typeof it !== "object" || it === null || typeof it.pattern !== "string") {
|
|
5
|
+
return { ok: false, after: " must be a string or an object with a string 'pattern'" };
|
|
6
|
+
}
|
|
7
|
+
const cs = it.caseSensitive;
|
|
8
|
+
if (cs !== undefined && typeof cs !== "boolean")
|
|
9
|
+
return { ok: false, after: ".caseSensitive must be boolean when present" };
|
|
10
|
+
return { ok: true, entry: { pattern: it.pattern, caseSensitive: cs === true } };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=read-deny-entry.js.map
|