@sema-agent/server 7.132.0 → 7.134.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 +353 -0
- package/README.md +8 -9
- package/README.zh-CN.md +7 -6
- package/USAGE.md +301 -64
- package/deploy/sema-up/README.md +35 -1
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
- package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +19 -2
- package/deploy/sema-up/chart/templates/server.yaml +19 -2
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- 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 +32 -14
- 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 +83 -23
- package/dist/approval-card.js +45 -15
- package/dist/approval-content-kind.d.ts +5 -2
- package/dist/approval-content-kind.js +16 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +72 -0
- package/dist/approval-gate-currency.js +94 -0
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +55 -17
- package/dist/audit.d.ts +27 -10
- package/dist/audit.js +12 -16
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/coordinators.d.ts +6 -1
- package/dist/boot/coordinators.js +6 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/execution-env.js +9 -7
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.d.ts +2 -0
- package/dist/boot/leader.js +4 -1
- 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.js +2 -2
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +60 -81
- package/dist/boot/runner-deps.d.ts +18 -5
- package/dist/boot/runner-deps.js +10 -0
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-06-runners.d.ts +6 -3
- package/dist/boot/stage-06-runners.js +20 -4
- package/dist/boot/stage-07-capability-layer.d.ts +4 -1
- package/dist/boot/stage-07-capability-layer.js +24 -3
- package/dist/boot/stage-08-reapers.d.ts +4 -1
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +5 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +5 -1
- package/dist/boot/stage-10-http-server.js +6 -6
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -14
- package/dist/boot/web-admin.d.ts +10 -0
- package/dist/boot/web-admin.js +162 -65
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +8 -3
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +11 -6
- package/dist/caller-text-echo.js +10 -12
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +21 -0
- package/dist/capabilities/hands-lane.js +10 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -4
- package/dist/capabilities/mcp-probe.js +29 -6
- package/dist/capabilities/scenarios.d.ts +63 -7
- package/dist/capabilities/scenarios.js +39 -7
- package/dist/capability-facts.d.ts +36 -4
- package/dist/capability-facts.js +30 -4
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
- package/dist/checkpoint-ctx-seal-m28.js +19 -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 +43 -28
- 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-provider.d.ts +6 -1
- package/dist/config-provider.js +6 -2
- package/dist/config-types.d.ts +71 -14
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +121 -59
- 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 -23
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/execution-lane-caps.d.ts +49 -10
- package/dist/execution-lane-caps.js +43 -4
- package/dist/field-conflict.d.ts +44 -0
- package/dist/field-conflict.js +21 -0
- package/dist/file-history-disclosure.d.ts +34 -5
- package/dist/file-history-disclosure.js +2 -2
- package/dist/fleet/fleet-bus.d.ts +84 -6
- package/dist/fleet/fleet-bus.js +42 -9
- package/dist/hooks/classic-stations.d.ts +10 -5
- package/dist/hooks/classic-stations.js +4 -4
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.js +2 -2
- package/dist/hooks/hook-runner.d.ts +127 -25
- package/dist/hooks/hook-runner.js +668 -287
- 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.js +111 -60
- package/dist/http/approval-sweeps.js +58 -19
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +173 -18
- package/dist/http/checkpoint-ctx.js +171 -12
- package/dist/http/claimed-run.d.ts +4 -3
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +2 -1
- package/dist/http/dispatch.js +13 -7
- package/dist/http/durable-run-leg.d.ts +4 -32
- package/dist/http/durable-run-leg.js +37 -12
- package/dist/http/idempotency.d.ts +2 -2
- package/dist/http/idempotency.js +2 -2
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +78 -27
- package/dist/http/principal-gate.js +64 -14
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +16 -32
- package/dist/http/request-guards.js +31 -30
- package/dist/http/resume-ctx-read.d.ts +50 -6
- package/dist/http/resume-ctx-read.js +33 -7
- package/dist/http/resume-legs.d.ts +5 -5
- package/dist/http/resume-legs.js +163 -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 -37
- 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/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.js +91 -56
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +20 -4
- 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.d.ts +3 -3
- package/dist/http/routes/diagnostics.js +6 -2
- package/dist/http/routes/fleet.js +4 -4
- 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.d.ts +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 +9 -22
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +63 -115
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +53 -48
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +3 -4
- package/dist/http/routes/sessions.js +33 -43
- package/dist/http/routes/side-query.js +6 -4
- package/dist/http/routes/tasks.js +71 -30
- package/dist/http/routes/trace-usage.js +7 -9
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/run-declared-families.d.ts +16 -0
- package/dist/http/run-declared-families.js +12 -0
- package/dist/http/send.d.ts +24 -3
- package/dist/http/send.js +14 -2
- package/dist/http/server.d.ts +23 -18
- package/dist/http/server.js +20 -15
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +4 -3
- package/dist/http/submit-ctx.js +23 -6
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +17 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/lane-home-probe.d.ts +78 -9
- package/dist/lane-home-probe.js +78 -12
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/leader/wire.d.ts +4 -0
- package/dist/leader/wire.js +8 -7
- package/dist/limit-refusal.d.ts +17 -5
- package/dist/limit-refusal.js +4 -1
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +31 -10
- package/dist/mcp-assertion-header.js +10 -3
- package/dist/memory-origin-fence.js +2 -2
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +23 -16
- 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-compat.d.ts +1 -1
- 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 +5 -0
- package/dist/model-provider.js +4 -2
- package/dist/model-route-endpoint.d.ts +8 -11
- package/dist/model-route-endpoint.js +4 -7
- 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/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +35 -9
- package/dist/observability/fail-open.js +35 -9
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/prompt-manifest.d.ts +22 -25
- package/dist/observability/prompt-manifest.js +54 -50
- package/dist/observability/tool-trace.js +9 -10
- 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 +119 -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 +43 -11
- package/dist/parked-decide.js +100 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/permission-rule-vocab.d.ts +1 -23
- package/dist/permission-rule-vocab.js +0 -13
- 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/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- package/dist/plugins/blob-backend.d.ts +38 -25
- package/dist/plugins/blob-backend.js +29 -19
- 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 +4 -1
- package/dist/plugins/caching-session-store.js +7 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +36 -1
- package/dist/plugins/checkpoint-store-sql.js +65 -3
- 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/local-checkpoint-store.d.ts +15 -2
- package/dist/plugins/local-checkpoint-store.js +32 -1
- package/dist/plugins/local-session-store.d.ts +13 -10
- package/dist/plugins/local-session-store.js +23 -14
- package/dist/plugins/local-session-window.d.ts +45 -0
- package/dist/plugins/local-session-window.js +38 -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 +121 -5
- package/dist/plugins/one-time-migrations.js +332 -8
- 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-file.js +10 -6
- package/dist/plugins/permission-rule-store-sql.js +8 -8
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +18 -5
- package/dist/plugins/pg-session-storage.js +68 -23
- package/dist/plugins/remote-env-adb.d.ts +6 -12
- package/dist/plugins/remote-env-adb.js +12 -2
- package/dist/plugins/remote-env-device.d.ts +14 -7
- package/dist/plugins/remote-env-device.js +23 -15
- package/dist/plugins/remote-env-k8s.d.ts +8 -12
- package/dist/plugins/remote-env-k8s.js +23 -5
- package/dist/plugins/remote-env-local-docker.d.ts +10 -15
- package/dist/plugins/remote-env-local-docker.js +12 -9
- package/dist/plugins/remote-env-ssh.d.ts +10 -16
- package/dist/plugins/remote-env-ssh.js +17 -11
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- 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 +32 -6
- package/dist/plugins/session-epoch-anchor.js +2 -3
- package/dist/plugins/session-ownership.d.ts +11 -0
- package/dist/plugins/session-ownership.js +11 -0
- package/dist/plugins/session-placement.d.ts +12 -14
- package/dist/plugins/session-placement.js +2 -15
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/sql-driver.d.ts +74 -11
- package/dist/plugins/sql-driver.js +210 -12
- package/dist/plugins/sql-errors.d.ts +23 -0
- package/dist/plugins/sql-errors.js +21 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +40 -14
- 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 +3 -2
- package/dist/plugins/tidb-session-storage.js +2 -2
- package/dist/plugins/tidb-session-store.d.ts +25 -5
- package/dist/plugins/tidb-session-store.js +67 -21
- 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/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 +7 -0
- package/dist/request-key-closure.js +9 -1
- package/dist/request-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +26 -2
- package/dist/rule-entry-list.js +72 -12
- 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 +37 -6
- package/dist/runs.d.ts +12 -10
- package/dist/runs.js +25 -6
- 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/sealed-key.d.ts +32 -0
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +95 -15
- package/dist/security.js +52 -9
- package/dist/session-error-wire.d.ts +31 -7
- package/dist/session-error-wire.js +9 -2
- package/dist/session-sync-kernel.d.ts +37 -10
- package/dist/session-sync-kernel.js +10 -0
- 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 +15 -4
- package/dist/spec-fields.js +21 -2
- package/dist/sql-engine-posture.d.ts +3 -1
- package/dist/task-a2a.js +4 -3
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +5 -5
- package/dist/task-mcp.js +27 -74
- package/dist/task-settings.d.ts +93 -88
- package/dist/task-settings.js +71 -63
- package/dist/text-bidi.d.ts +0 -4
- package/dist/text-bidi.js +1 -3
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +451 -136
- package/dist/tool-approval.js +733 -256
- package/dist/tool-rule-names.d.ts +6 -0
- package/dist/trace/core-keyset-guard.d.ts +108 -25
- package/dist/trace/exit-seat.d.ts +40 -0
- package/dist/trace/exit-seat.js +130 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/project.d.ts +98 -13
- package/dist/trace/project.js +57 -32
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +57 -0
- package/dist/trace/redact.js +962 -168
- package/dist/trace/self-minted-wire.d.ts +349 -1
- package/dist/trace/self-minted-wire.js +118 -1
- package/dist/trace/wire-projection-faces.d.ts +304 -2
- package/dist/trace/wire-projection-faces.js +160 -13
- 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/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.js +6 -8
- package/dist/web-admin-client/types.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -2
- package/scripts/drain-check.mysql.sql +20 -2
- package/scripts/drain-check.pg.sql +20 -2
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -106
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
* 修前(≤7.107.0)本仓自写的这些臂只比 `req.toolName`:模型按别名调嵌入方工具时,运维名单一个都不拦(core 同族策略判 deny、
|
|
18
18
|
* 本仓判 allow)。本仓自身不声明带别名的工具,所以只有经 `resolveSpec` 席挂别名工具的嵌入方走得到。
|
|
19
19
|
*
|
|
20
|
+
* ⚠️ **别名只是名字,不是标记的载体**(core 7.54.0 #2105,[ref] 已定案):上面这条读法只回答「这次调用答得上哪些名字」;嵌入方工具自己的
|
|
21
|
+
* 安全标记(`egress`、不可逆层级 `irreversibility`、可逆探针)**不再**因别名恰是引擎工具名(`MyShell{aliases:["Bash"]}`)而镜像到引擎 shell 上 ——
|
|
22
|
+
* 7.53.x 及以前,`MyShell` 的 `egress: true` / `irreversibility: "always"` 会让引擎 `Bash` 的调用多问一次(收紧),它的恒可逆探针会让引擎 `Bash` 的
|
|
23
|
+
* `touch` 不问就跑(放宽);7.54.0 起两者都不再作用于引擎 shell。要收紧引擎 shell:给**正名**叫 `Bash` 的工具声明标记(同名标记仍作用),或请求
|
|
24
|
+
* `TaskSpec.shellGate: "always"`(本仓的入口 `MANUAL_MODE_SHELL_GATE` / 请求 `shellGate`)。
|
|
25
|
+
*
|
|
20
26
|
* 返回**命中的那个名字**(调用答得上的名字里第一个被规则够到的,拼写在先)—— 规则归因(`matchedAskRule`)写运维名单里的那个名,
|
|
21
27
|
* 不写一个名单里查不到的 wire 名;够不到 ⇒ `undefined`。判定式(精确集 / covering 规则)由调用方给,本函数只管「读哪些名字」。
|
|
22
28
|
*/
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* ⑨⑩([ref],2026-08-31)把两个最大的 wire 面也纳入:TaskSpec 按「server 有无写点」记 Wired/Unwired,
|
|
18
18
|
* TaskResult 按「转发/摘除」记 Forwarded/Stripped —— 谁改 resolve-spec.ts / runs.ts 的发射点谁同步本文件。
|
|
19
19
|
*/
|
|
20
|
-
import type { TaskNotificationPayload, SemaProvenance, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, PendingAction, TaskEvent, TraceEvent, MailboxMessage, MailboxAppendMessage, TaskSpec, TaskResult, SideQueryResult, WiringManifest, GateOutcome, GateDisposition, Settlement, PausedCause, TerminalCause, WorkflowRun, ReadRootGrantCandidate, McpReconnectResult, McpServerStatus, NodeLspManagerOptions, RunnerDeps, SessionMemoryStatus } from "@sema-agent/core";
|
|
20
|
+
import type { TaskNotificationPayload, SemaProvenance, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, PendingAction, TaskEvent, TraceEvent, MailboxMessage, MailboxAppendMessage, TaskSpec, TaskResult, SideQueryResult, WiringManifest, PermissionModeReceipt, GateOutcome, GateDisposition, Settlement, PausedCause, TerminalCause, WorkflowRun, ReadRootGrantCandidate, McpReconnectResult, McpServerStatus, NodeLspManagerOptions, RunnerDeps, SessionMemoryStatus, PromptManifestIdentity, PromptIdentityLayers, PromptManifestSelectors, PromptManifestSection, PromptChainLink, SupersededOverlay, ToolDisclosureManifest } from "@sema-agent/core";
|
|
21
21
|
import type { ToolApprovalFrame } from "../tool-approval.js";
|
|
22
|
+
import type { TableCoreKeys } from "./projection-table.js";
|
|
22
23
|
/** 编译期断言:T 必须收敛到 never(有残余键 = tsc 红)。
|
|
23
24
|
* 🔴 **导出**([ref] U1/U2):本仓「词表闭集,未处置成员=编译红」的钉法只许有**一个**形 ——
|
|
24
25
|
* `observability/run-terminal.ts` 的三张叶表 + 结果顶层键表用同一只断言,而不是各自再抄一份
|
|
@@ -59,7 +60,7 @@ type _GuardMailboxReverse = AssertAllKeysHandled<Exclude<MailboxProjected, keyof
|
|
|
59
60
|
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
60
61
|
type _GuardMailboxAppend = AssertAllKeysHandled<Exclude<keyof MailboxAppendMessage, MailboxAppendProjected>>;
|
|
61
62
|
type _GuardMailboxAppendReverse = AssertAllKeysHandled<Exclude<MailboxAppendProjected, keyof MailboxAppendMessage>>;
|
|
62
|
-
type WiringSectionProjected = "schemaVersion" | "leg" | "ask" | "question" | "interaction" | "elicit" | "parkLane" | "session" | "fleet" | "permissionRules" | "modelGate" | "autoMode" | "mcp" | "tools" | "mods" | "lsp" | "hands" | "writeProtection" | "teamRole" | "fileHistory";
|
|
63
|
+
type WiringSectionProjected = "schemaVersion" | "leg" | "ask" | "question" | "interaction" | "elicit" | "parkLane" | "session" | "fleet" | "permissionRules" | "modelGate" | "autoMode" | "mcp" | "tools" | "mods" | "lsp" | "hands" | "writeProtection" | "teamRole" | "fileHistory" | "permissionMode";
|
|
63
64
|
type WiringSectionExcluded = (typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES)["wiring_manifest_tenant"]["excluded"][number];
|
|
64
65
|
type _GuardWiringSections = AssertAllKeysHandled<Exclude<keyof WiringManifest, WiringSectionProjected | WiringSectionExcluded>>;
|
|
65
66
|
type _GuardWiringSectionsReverse = AssertAllKeysHandled<Exclude<WiringSectionProjected | WiringSectionExcluded, keyof WiringManifest>>;
|
|
@@ -132,6 +133,9 @@ type _GuardWiringAutoConsolidationReverse = AssertAllKeysHandled<Exclude<WiringA
|
|
|
132
133
|
type WiringModelGateHandled = "class" | "removed" | "restore";
|
|
133
134
|
type _GuardWiringModelGate = AssertAllKeysHandled<Exclude<keyof WiringSection<"modelGate">, WiringModelGateHandled>>;
|
|
134
135
|
type _GuardWiringModelGateReverse = AssertAllKeysHandled<Exclude<WiringModelGateHandled, keyof WiringSection<"modelGate">>>;
|
|
136
|
+
type WiringPermissionModeHandled = "requested" | "effective" | "foldedBy";
|
|
137
|
+
type _GuardWiringPermissionMode = AssertAllKeysHandled<Exclude<keyof PermissionModeReceipt, WiringPermissionModeHandled>>;
|
|
138
|
+
type _GuardWiringPermissionModeReverse = AssertAllKeysHandled<Exclude<WiringPermissionModeHandled, keyof PermissionModeReceipt>>;
|
|
135
139
|
type WiringAutoModeHandled = "armed" | "reason" | "deniedSource";
|
|
136
140
|
type _GuardWiringAutoMode = AssertAllKeysHandled<Exclude<keyof WiringSection<"autoMode">, WiringAutoModeHandled>>;
|
|
137
141
|
type _GuardWiringAutoModeReverse = AssertAllKeysHandled<Exclude<WiringAutoModeHandled, keyof WiringSection<"autoMode">>>;
|
|
@@ -141,31 +145,84 @@ type _GuardWiringGovernanceReverse = AssertAllKeysHandled<Exclude<WiringGovernan
|
|
|
141
145
|
type PermissionTraceKind = Extract<TraceEvent["kind"], `permission.${string}`>;
|
|
142
146
|
export type PermissionTraceProjected = "permission.persisted_rule_allowed" | "permission.rule_store_unreadable" | "permission.read_only_allowed" | "permission.skill_allowed" | "permission.allowed_tools_allowed";
|
|
143
147
|
type PermissionTraceDropped = "permission.sandbox_admitted" | "permission.rule_sync_resurrected" | "permission.rule_sync_dropped" | "permission.org_snapshot_unavailable";
|
|
144
|
-
type
|
|
145
|
-
type
|
|
148
|
+
type PermissionTraceRunEvent = "permission.cross_boundary_taint";
|
|
149
|
+
type _GuardPermissionTrace = AssertAllKeysHandled<Exclude<PermissionTraceKind, PermissionTraceProjected | PermissionTraceDropped | PermissionTraceRunEvent>>;
|
|
150
|
+
type _GuardPermissionTraceReverse = AssertAllKeysHandled<Exclude<PermissionTraceProjected | PermissionTraceDropped | PermissionTraceRunEvent, PermissionTraceKind>>;
|
|
146
151
|
/** `T` 非 `never` 时收敛到 `never`(空集 ⇒ 残留 `"EMPTY"` ⇒ tsc 红)。 */
|
|
147
152
|
type AssertNonEmpty<T> = [T] extends [never] ? "EMPTY" : never;
|
|
148
153
|
type _GuardPermissionTraceNonEmpty = AssertAllKeysHandled<AssertNonEmpty<PermissionTraceKind>>;
|
|
149
154
|
type PromptAssembledFrame = Extract<TraceEvent, {
|
|
150
155
|
kind: "prompt.assembled";
|
|
151
156
|
}>;
|
|
152
|
-
type
|
|
153
|
-
type
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
type ManifestFaces = typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES;
|
|
158
|
+
type ManifestDeclared<F, N extends keyof F> = F[N] extends {
|
|
159
|
+
readonly keys: infer K;
|
|
160
|
+
} ? keyof K : never;
|
|
161
|
+
type ManifestDeclaredOptional<F, N extends keyof F> = F[N] extends {
|
|
162
|
+
readonly keys: infer K;
|
|
163
|
+
} ? {
|
|
164
|
+
[P in keyof K]: K[P] extends {
|
|
165
|
+
readonly optional: true;
|
|
166
|
+
} ? P : never;
|
|
167
|
+
}[keyof K] : never;
|
|
168
|
+
type ManifestNotOnRow<F, N extends keyof F> = F[N] extends {
|
|
169
|
+
readonly excluded: readonly (infer E)[];
|
|
170
|
+
} ? E : never;
|
|
171
|
+
/** 引擎型上带 `?` 的键。 */
|
|
172
|
+
type OptionalKeysOf<T> = {
|
|
173
|
+
[P in keyof T]-?: {} extends Pick<T, P> ? P : never;
|
|
174
|
+
}[keyof T];
|
|
175
|
+
/**
|
|
176
|
+
* 一层的正向残余:引擎型有、声明里没有也没登记不上行的键;以及可选性不对的键 —— 非行层:声明为可选的键 ≠ 引擎型上带 `?` 的键;
|
|
177
|
+
* 行层:声明里每个键都得是可选(行的成员一律可缺席;少写一个 `optional`,解释器会把「引擎没发这个成员」读成读不出并计一次丢弃)。
|
|
178
|
+
* 全收敛到 `never` 才过。`Row` = 这一层是不是行。
|
|
179
|
+
*/
|
|
180
|
+
type ManifestLevelForward<F, N extends keyof F, Core, Row extends boolean> = Exclude<keyof Core, ManifestDeclared<F, N> | ManifestNotOnRow<F, N>> | (Row extends true ? Exclude<ManifestDeclared<F, N>, ManifestDeclaredOptional<F, N>> : Exclude<OptionalKeysOf<Core>, ManifestDeclaredOptional<F, N>> | Exclude<ManifestDeclaredOptional<F, N>, OptionalKeysOf<Core>>);
|
|
181
|
+
/** 一层的反向残余:声明过或登记为不上行、而引擎型里已经没有的键(引擎退役它而簿里留着残条目)。 */
|
|
182
|
+
type ManifestLevelReverse<F, N extends keyof F, Core> = Exclude<ManifestDeclared<F, N> | ManifestNotOnRow<F, N>, keyof Core>;
|
|
183
|
+
/** 十二层的引擎型(层名 = 登记表里的面名)。 */
|
|
184
|
+
type ManifestCore = {
|
|
185
|
+
prompt_manifest: PromptAssembledFrame;
|
|
186
|
+
prompt_manifest_identity: PromptManifestIdentity;
|
|
187
|
+
prompt_manifest_identity_layers: PromptIdentityLayers;
|
|
188
|
+
prompt_manifest_selectors: PromptManifestSelectors;
|
|
189
|
+
prompt_manifest_selectors_host: PromptManifestSelectors["host"];
|
|
190
|
+
prompt_manifest_block: PromptAssembledFrame["blocks"][number];
|
|
191
|
+
prompt_manifest_section: PromptManifestSection;
|
|
192
|
+
prompt_manifest_section_renderer: NonNullable<PromptManifestSection["renderer"]>;
|
|
193
|
+
prompt_manifest_chain_link: PromptChainLink;
|
|
194
|
+
prompt_manifest_superseded: SupersededOverlay;
|
|
195
|
+
prompt_manifest_tool: NonNullable<PromptAssembledFrame["tools"]>[number];
|
|
196
|
+
prompt_manifest_tool_disclosure: ToolDisclosureManifest;
|
|
197
|
+
};
|
|
198
|
+
/** 残余非空的层,按 `<层>.<残余键>` 点名(tsc 的报错里直接看见是哪一层的哪一个键)。 */
|
|
199
|
+
/** 十二层的残余汇总:每层的正向残余(见 {@link ManifestLevelForward})按 `<层>.<残余键>` 点名;`F` = 登记表的形。全收敛到 `never` 才过。 */
|
|
200
|
+
type ManifestForwardResidue<F extends Record<keyof ManifestCore, unknown>> = {
|
|
201
|
+
[L in keyof ManifestCore]: [ManifestLevelForward<F, L, ManifestCore[L], L extends "prompt_manifest" ? true : false>] extends [never] ? never : `${L}.${ManifestLevelForward<F, L, ManifestCore[L], L extends "prompt_manifest" ? true : false> & string}`;
|
|
202
|
+
}[keyof ManifestCore];
|
|
203
|
+
type _GuardPromptManifestKeys = AssertAllKeysHandled<ManifestForwardResidue<ManifestFaces>>;
|
|
204
|
+
type _GuardPromptManifestKeysReverse = AssertAllKeysHandled<{
|
|
205
|
+
[L in keyof ManifestCore]: [ManifestLevelReverse<ManifestFaces, L, ManifestCore[L]>] extends [never] ? never : `${L}.${ManifestLevelReverse<ManifestFaces, L, ManifestCore[L]> & string}`;
|
|
206
|
+
}[keyof ManifestCore]>;
|
|
207
|
+
/** 非空 —— 十二层的声明都在(层名拼错 / 声明被整行删掉 ⇒ `ManifestDeclared` 坍成 `never`,上面的反向钉恒绿,这一条补上)。 */
|
|
208
|
+
type _GuardPromptManifestKeysNonEmpty = AssertAllKeysHandled<{
|
|
209
|
+
[L in keyof ManifestCore]: [ManifestDeclared<ManifestFaces, L>] extends [never] ? L : never;
|
|
210
|
+
}[keyof ManifestCore]>;
|
|
211
|
+
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "mandated" | "mandate" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "boundGrantAbsence" | "checkpointId";
|
|
212
|
+
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy";
|
|
156
213
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
157
214
|
type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected | SummaryExcluded, keyof CheckpointSummary>>;
|
|
158
215
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
159
216
|
kind: "tool_approval";
|
|
160
217
|
}>;
|
|
161
218
|
type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts;
|
|
162
|
-
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "
|
|
219
|
+
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling";
|
|
163
220
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
164
221
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
165
222
|
type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
|
|
166
|
-
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "allowedTools" | "allowTools" | "userAttachments";
|
|
223
|
+
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
|
|
167
224
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
168
|
-
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "
|
|
225
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm";
|
|
169
226
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
170
227
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
171
228
|
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction";
|
|
@@ -210,16 +267,25 @@ type _GuardSettlementReverse = AssertAllKeysHandled<Exclude<SettlementProjected,
|
|
|
210
267
|
type SettlementWhoProjected = "party" | "approver" | "window";
|
|
211
268
|
type _GuardSettlementWho = AssertAllKeysHandled<Exclude<SettlementWhoKeys, SettlementWhoProjected>>;
|
|
212
269
|
type _GuardSettlementWhoReverse = AssertAllKeysHandled<Exclude<SettlementWhoProjected, SettlementWhoKeys>>;
|
|
213
|
-
type
|
|
214
|
-
type
|
|
215
|
-
type
|
|
216
|
-
type
|
|
217
|
-
type
|
|
218
|
-
type
|
|
219
|
-
type
|
|
220
|
-
type
|
|
221
|
-
type
|
|
222
|
-
type
|
|
270
|
+
type WorkflowTables = typeof import("../http/routes/workflows.js");
|
|
271
|
+
type _GuardWorkflowRun = AssertAllKeysHandled<Exclude<keyof WorkflowRun, TableCoreKeys<WorkflowTables["WORKFLOW_RUN_DISPOSITIONS"]>>>;
|
|
272
|
+
type _GuardWorkflowRunReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_DISPOSITIONS"]>, keyof WorkflowRun>>;
|
|
273
|
+
type _GuardWorkflowParkRow = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["parks"]>[number], TableCoreKeys<WorkflowTables["WORKFLOW_PARK_ROW_DISPOSITIONS"]>>>;
|
|
274
|
+
type _GuardWorkflowParkRowReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_PARK_ROW_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["parks"]>[number]>>;
|
|
275
|
+
type _GuardWorkflowPhase = AssertAllKeysHandled<Exclude<keyof WorkflowRun["phases"][number], TableCoreKeys<WorkflowTables["WORKFLOW_PHASE_DISPOSITIONS"]>>>;
|
|
276
|
+
type _GuardWorkflowPhaseReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_PHASE_DISPOSITIONS"]>, keyof WorkflowRun["phases"][number]>>;
|
|
277
|
+
type _GuardWorkflowAgent = AssertAllKeysHandled<Exclude<keyof WorkflowRun["agents"][number], TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_DISPOSITIONS"]>>>;
|
|
278
|
+
type _GuardWorkflowAgentReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_DISPOSITIONS"]>, keyof WorkflowRun["agents"][number]>>;
|
|
279
|
+
type _GuardWorkflowAgentActivity = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["agents"][number]["activity"]>[number], TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS"]>>>;
|
|
280
|
+
type _GuardWorkflowAgentActivityReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["agents"][number]["activity"]>[number]>>;
|
|
281
|
+
type _GuardWorkflowAgentPendingApproval = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["agents"][number]["pendingApproval"]>, TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS"]>>>;
|
|
282
|
+
type _GuardWorkflowAgentPendingApprovalReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["agents"][number]["pendingApproval"]>>>;
|
|
283
|
+
type _GuardWorkflowGroup = AssertAllKeysHandled<Exclude<keyof WorkflowRun["groups"][number], TableCoreKeys<WorkflowTables["WORKFLOW_GROUP_DISPOSITIONS"]>>>;
|
|
284
|
+
type _GuardWorkflowGroupReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_GROUP_DISPOSITIONS"]>, keyof WorkflowRun["groups"][number]>>;
|
|
285
|
+
type _GuardWorkflowRunStats = AssertAllKeysHandled<Exclude<keyof WorkflowRun["stats"], TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_DISPOSITIONS"]>>>;
|
|
286
|
+
type _GuardWorkflowRunStatsReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_DISPOSITIONS"]>, keyof WorkflowRun["stats"]>>;
|
|
287
|
+
type _GuardWorkflowRunStatsNested = AssertAllKeysHandled<Exclude<keyof WorkflowRun["stats"]["nested"], TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS"]>>>;
|
|
288
|
+
type _GuardWorkflowRunStatsNestedReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS"]>, keyof WorkflowRun["stats"]["nested"]>>;
|
|
223
289
|
type ReadRootCandidateProjected = "dir" | "clearsThisAsk" | "covers";
|
|
224
290
|
type _GuardReadRootCandidate = AssertAllKeysHandled<Exclude<keyof ReadRootGrantCandidate, ReadRootCandidateProjected>>;
|
|
225
291
|
type _GuardReadRootCandidateReverse = AssertAllKeysHandled<Exclude<ReadRootCandidateProjected, keyof ReadRootGrantCandidate>>;
|
|
@@ -321,11 +387,15 @@ export type CoreKeysetGuards = [
|
|
|
321
387
|
_GuardWiringModelGateReverse,
|
|
322
388
|
_GuardWiringAutoMode,
|
|
323
389
|
_GuardWiringAutoModeReverse,
|
|
390
|
+
_GuardWiringPermissionMode,
|
|
391
|
+
_GuardWiringPermissionModeReverse,
|
|
324
392
|
_GuardWiringGovernance,
|
|
325
393
|
_GuardWiringGovernanceReverse,
|
|
326
394
|
_GuardPermissionTrace,
|
|
327
395
|
_GuardPermissionTraceReverse,
|
|
328
|
-
|
|
396
|
+
_GuardPromptManifestKeys,
|
|
397
|
+
_GuardPromptManifestKeysReverse,
|
|
398
|
+
_GuardPromptManifestKeysNonEmpty,
|
|
329
399
|
_GuardPermissionTraceNonEmpty,
|
|
330
400
|
_GuardInboxSummary,
|
|
331
401
|
_GuardInboxSummaryReverse,
|
|
@@ -352,9 +422,22 @@ export type CoreKeysetGuards = [
|
|
|
352
422
|
_GuardSettlementWhoReverse,
|
|
353
423
|
_GuardWorkflowRun,
|
|
354
424
|
_GuardWorkflowRunReverse,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
425
|
+
_GuardWorkflowParkRow,
|
|
426
|
+
_GuardWorkflowParkRowReverse,
|
|
427
|
+
_GuardWorkflowPhase,
|
|
428
|
+
_GuardWorkflowPhaseReverse,
|
|
429
|
+
_GuardWorkflowAgent,
|
|
430
|
+
_GuardWorkflowAgentReverse,
|
|
431
|
+
_GuardWorkflowAgentActivity,
|
|
432
|
+
_GuardWorkflowAgentActivityReverse,
|
|
433
|
+
_GuardWorkflowAgentPendingApproval,
|
|
434
|
+
_GuardWorkflowAgentPendingApprovalReverse,
|
|
435
|
+
_GuardWorkflowGroup,
|
|
436
|
+
_GuardWorkflowGroupReverse,
|
|
437
|
+
_GuardWorkflowRunStats,
|
|
438
|
+
_GuardWorkflowRunStatsReverse,
|
|
439
|
+
_GuardWorkflowRunStatsNested,
|
|
440
|
+
_GuardWorkflowRunStatsNestedReverse,
|
|
358
441
|
_GuardReadRootCandidate,
|
|
359
442
|
_GuardReadRootCandidateReverse,
|
|
360
443
|
_GuardRiskAxes,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** 品牌键:模块私有的 `unique symbol` —— 别处写不出这个键,于是写不出一个 `SafeText` 字面量;断言伪造由普查门在语法树上拦。 */
|
|
2
|
+
declare const SAFE_TEXT: unique symbol;
|
|
3
|
+
/** 经出口座的文本。是 `string` 的子型:读者零改;写进出口位只能用 {@link seatText} 铸的值。 */
|
|
4
|
+
export type SafeText = string & {
|
|
5
|
+
readonly [SAFE_TEXT]: true;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* **座表(闭集;一行 = 一类出口)**。加一类出口 = 加一行;表外的座名是编译错误。
|
|
9
|
+
* · `trace-frame-text`:trace 帧的自由文本位(子代名 / 动作行 / 通告正文与结果 / 诊断 / 注入摘录 / 压缩说明 / 人类输入的署名与附件标签 …),不设界;
|
|
10
|
+
* · `trace-frame-line`:trace 帧里一行宽的展示位(`workspace_changed.cwd` / `brain_status.detail`),界 300 码元;
|
|
11
|
+
* · `operator-log-text`:运维日志字段里的一句话 —— 读口坏行的缺陷句(core 的筛按位置点名并回显落盘标量)、`tool_trace` 行里工具的输出 / 失败句 / 拒因;日志字段行,界 200 码元(含截断记号);
|
|
12
|
+
* · `operator-log-arg`:运维日志字段里模型写的工具入参(`tool_trace` 的 `arg.*`:路径 / 命令 / 模式 / 非对象入参的串形);日志字段行,界 120 码元(含截断记号)。
|
|
13
|
+
*/
|
|
14
|
+
declare const EXIT_SEATS: {
|
|
15
|
+
readonly "trace-frame-text": {
|
|
16
|
+
readonly scope: "free-text";
|
|
17
|
+
};
|
|
18
|
+
readonly "trace-frame-line": {
|
|
19
|
+
readonly scope: "free-text";
|
|
20
|
+
readonly maxChars: 300;
|
|
21
|
+
};
|
|
22
|
+
readonly "operator-log-text": {
|
|
23
|
+
readonly scope: "free-text";
|
|
24
|
+
readonly maxChars: 200;
|
|
25
|
+
readonly logField: true;
|
|
26
|
+
};
|
|
27
|
+
readonly "operator-log-arg": {
|
|
28
|
+
readonly scope: "free-text";
|
|
29
|
+
readonly maxChars: 120;
|
|
30
|
+
readonly logField: true;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
34
|
+
/**
|
|
35
|
+
* 出口座:`seat` 是座表的一行,`text` 是要出门的自由文本。返回的 {@link SafeText} 就是这个出口该写出去的字节。
|
|
36
|
+
* 表外的座名(只有绕过类型才到得了)⇒ 抛 —— 那是调用方的编程错,不是脱敏失败,不吞成占位。
|
|
37
|
+
*/
|
|
38
|
+
export declare function seatText(seat: ExitSeat, text: string): SafeText;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=exit-seat.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { CONTROL_AND_BIDI_CHARS, stripControlAndBidi } from "@sema-agent/settings-schema";
|
|
2
|
+
import { CALLER_TEXT_CUT_MARK } from "../caller-text-echo.js";
|
|
3
|
+
import { errorKindOf } from "../observability/err-text.js";
|
|
4
|
+
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
|
+
import { OVERSIZED_REDACTION_PLACEHOLDER } from "../observability/run-terminal.js";
|
|
6
|
+
import { proposeRedactionSpans, REDACTION_TOKEN_RE_SRC } from "./redact.js";
|
|
7
|
+
const EXIT_SEATS = {
|
|
8
|
+
"trace-frame-text": { scope: "free-text" },
|
|
9
|
+
"trace-frame-line": { scope: "free-text", maxChars: 300 },
|
|
10
|
+
"operator-log-text": { scope: "free-text", maxChars: 200, logField: true },
|
|
11
|
+
"operator-log-arg": { scope: "free-text", maxChars: 120, logField: true },
|
|
12
|
+
};
|
|
13
|
+
const SEAT_ROWS = new Map(Object.entries(EXIT_SEATS));
|
|
14
|
+
for (const [name, row] of SEAT_ROWS) {
|
|
15
|
+
if (row.maxChars !== undefined && row.maxChars < OVERSIZED_REDACTION_PLACEHOLDER.length) {
|
|
16
|
+
throw new Error(`exit seat "${name}": maxChars ${row.maxChars} cannot hold the failure placeholder (${OVERSIZED_REDACTION_PLACEHOLDER.length} code units)`);
|
|
17
|
+
}
|
|
18
|
+
if (row.logField === true && row.maxChars === undefined) {
|
|
19
|
+
throw new Error(`exit seat "${name}": a log-field row must declare maxChars (the cut mark counts inside the bound)`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function mergeSpans(spans) {
|
|
23
|
+
const order = spans.map((s, i) => ({ s, i })).sort((a, b) => a.s.start - b.s.start || b.s.end - a.s.end || a.i - b.i);
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const { s } of order) {
|
|
26
|
+
const last = out[out.length - 1];
|
|
27
|
+
if (last === undefined || s.start > last.end)
|
|
28
|
+
out.push(s);
|
|
29
|
+
else if (s.end > last.end)
|
|
30
|
+
out[out.length - 1] = { start: last.start, end: s.end, repl: last.repl };
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
const TOKEN_AT = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
|
|
35
|
+
function cutPlain(gap, room) {
|
|
36
|
+
let cut = room;
|
|
37
|
+
const hi = gap.charCodeAt(cut - 1);
|
|
38
|
+
if (cut > 0 && hi >= 0xd800 && hi <= 0xdbff && (gap.charCodeAt(cut) & 0xfc00) === 0xdc00)
|
|
39
|
+
cut -= 1;
|
|
40
|
+
const open = cut > 0 ? gap.lastIndexOf("«", cut - 1) : -1;
|
|
41
|
+
if (open !== -1) {
|
|
42
|
+
TOKEN_AT.lastIndex = open;
|
|
43
|
+
const m = TOKEN_AT.exec(gap);
|
|
44
|
+
if (m !== null && open + m[0].length > cut)
|
|
45
|
+
cut = open;
|
|
46
|
+
}
|
|
47
|
+
return gap.slice(0, cut);
|
|
48
|
+
}
|
|
49
|
+
function renderOnce(text, groups, maxChars) {
|
|
50
|
+
const parts = [];
|
|
51
|
+
let len = 0;
|
|
52
|
+
let at = 0;
|
|
53
|
+
for (const g of groups) {
|
|
54
|
+
const gap = text.slice(at, g.start);
|
|
55
|
+
if (maxChars !== undefined && len + gap.length > maxChars)
|
|
56
|
+
return parts.join("") + cutPlain(gap, maxChars - len);
|
|
57
|
+
parts.push(gap);
|
|
58
|
+
len += gap.length;
|
|
59
|
+
if (maxChars !== undefined && len + g.repl.length > maxChars)
|
|
60
|
+
return parts.join("");
|
|
61
|
+
parts.push(g.repl);
|
|
62
|
+
len += g.repl.length;
|
|
63
|
+
at = g.end;
|
|
64
|
+
}
|
|
65
|
+
const tail = text.slice(at);
|
|
66
|
+
parts.push(maxChars === undefined || len + tail.length <= maxChars ? tail : cutPlain(tail, maxChars - len));
|
|
67
|
+
return parts.join("");
|
|
68
|
+
}
|
|
69
|
+
const STRIPPED_UNIT = (() => {
|
|
70
|
+
const inSet = new RegExp(`[${CONTROL_AND_BIDI_CHARS}]`);
|
|
71
|
+
const table = new Uint8Array(0x10000);
|
|
72
|
+
for (let unit = 0; unit < table.length; unit++)
|
|
73
|
+
if (inSet.test(String.fromCharCode(unit)))
|
|
74
|
+
table[unit] = 1;
|
|
75
|
+
return table;
|
|
76
|
+
})();
|
|
77
|
+
function mapSpansIntoStripped(text, spans) {
|
|
78
|
+
const marks = [...new Set(spans.flatMap((sp) => [sp.start, sp.end]))].sort((a, b) => a - b);
|
|
79
|
+
const strippedBefore = new Map();
|
|
80
|
+
let removed = 0;
|
|
81
|
+
let at = 0;
|
|
82
|
+
for (const mark of marks) {
|
|
83
|
+
for (; at < mark; at++)
|
|
84
|
+
if (STRIPPED_UNIT[text.charCodeAt(at)] === 1)
|
|
85
|
+
removed += 1;
|
|
86
|
+
strippedBefore.set(mark, mark - removed);
|
|
87
|
+
}
|
|
88
|
+
const mapped = [];
|
|
89
|
+
for (const sp of spans) {
|
|
90
|
+
const start = strippedBefore.get(sp.start);
|
|
91
|
+
const end = strippedBefore.get(sp.end);
|
|
92
|
+
if (end > start)
|
|
93
|
+
mapped.push({ start, end, repl: sp.repl });
|
|
94
|
+
}
|
|
95
|
+
return mapped;
|
|
96
|
+
}
|
|
97
|
+
function proposeLogFieldSpans(text, scope) {
|
|
98
|
+
const read = stripControlAndBidi(text);
|
|
99
|
+
if (read === text)
|
|
100
|
+
return { read, spans: proposeRedactionSpans(text, scope) };
|
|
101
|
+
if (read.length === 0)
|
|
102
|
+
return { read, spans: [] };
|
|
103
|
+
const original = proposeRedactionSpans(text, scope);
|
|
104
|
+
const stripped = proposeRedactionSpans(read, scope, { countHits: original.length === 0 });
|
|
105
|
+
return { read, spans: [...stripped, ...mapSpansIntoStripped(text, original)] };
|
|
106
|
+
}
|
|
107
|
+
function renderRow(text, groups, row) {
|
|
108
|
+
if (row.logField !== true || row.maxChars === undefined)
|
|
109
|
+
return renderOnce(text, groups, row.maxChars);
|
|
110
|
+
const whole = renderOnce(text, groups, undefined);
|
|
111
|
+
if (whole.length <= row.maxChars)
|
|
112
|
+
return whole;
|
|
113
|
+
return renderOnce(text, groups, row.maxChars - CALLER_TEXT_CUT_MARK.length) + CALLER_TEXT_CUT_MARK;
|
|
114
|
+
}
|
|
115
|
+
export function seatText(seat, text) {
|
|
116
|
+
const row = SEAT_ROWS.get(seat);
|
|
117
|
+
if (row === undefined)
|
|
118
|
+
throw new Error(`exit seat: ${JSON.stringify(seat)} is not a row of the seat table`);
|
|
119
|
+
let out;
|
|
120
|
+
try {
|
|
121
|
+
const { read, spans } = row.logField === true ? proposeLogFieldSpans(text, row.scope) : { read: text, spans: proposeRedactionSpans(text, row.scope) };
|
|
122
|
+
out = renderRow(read, mergeSpans(spans), row);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
recordFailOpen("server.run-terminal.redact-threw", `seat=${seat} len=${typeof text === "string" ? text.length : -1} err=${errorKindOf(err)}`);
|
|
126
|
+
out = OVERSIZED_REDACTION_PLACEHOLDER;
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=exit-seat.js.map
|
|
@@ -52,11 +52,14 @@ export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" |
|
|
|
52
52
|
| "task_started" | "task_progress" | "task_notification" | "turn_end"
|
|
53
53
|
/** park 行名**两个**(`appendParked(kind)` 逐字取自 `result.status`)—— 运行期闭集见
|
|
54
54
|
* {@link PARK_LEDGER_EVENT_TYPES}(本联合是它的类型面,两者由下方的双向断言锁步)。 */
|
|
55
|
-
| "suspended" | "needs_review" | "done" | "failed" | "suggestions" | "model_usage" | "prompt_assembled" | "config_assembled"
|
|
55
|
+
| "suspended" | "needs_review" | "done" | "failed" | "suggestions" | "model_usage" | "prompt_assembled" | "config_assembled"
|
|
56
|
+
/** core 7.54.0 [ref] O9b S1:`permission.cross_boundary_taint` 帧的耐久行(伴随记录,与 `config_assembled` 同一只队列、同一批 drain 点;只在执行于目标设备的树上有)。 */
|
|
57
|
+
| "cross_boundary_taint" | "file_link"
|
|
56
58
|
/** 人在环三族的 open/close 帧对(投递面 = 本腿的 durable events tail)。 */
|
|
57
59
|
| "elicitation" | "elicitation_complete" | "question" | "question_complete" | "tool_approval" | "tool_approval_complete"
|
|
58
|
-
/** [ref] §4.3
|
|
59
|
-
|
|
60
|
+
/** [ref] §4.3 呈卡族的开卡帧与单卡消卡帧(与上面两只 tool_approval 帧同一条投递面;一条腿只发其中一族,
|
|
61
|
+
* bg / resume 两条 durable 腿恒是呈卡腿 ⇒ 它们的账本自 7.133.0 起只有本族)。 */
|
|
62
|
+
| "approval_request" | "approval_complete"
|
|
60
63
|
/**
|
|
61
64
|
* [ref]([ref]):批级撤卡帧在 **bg/resume 两条 durable 腿**的账本落行(与呈卡帧同口
|
|
62
65
|
* `append(type, rest)`,seq 由腿自己的 ledger 链步分配)。此前成文「reaper/收敛器无 seq 可分配故
|