@sema-agent/server 7.131.0 → 7.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +575 -0
- package/README.md +12 -9
- package/README.zh-CN.md +9 -6
- package/USAGE.md +326 -98
- package/deploy/sema-up/README.md +19 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
- package/deploy/sema-up/chart/templates/server.yaml +5 -2
- package/deploy/sema-up/stack/compose.yaml +3 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
- package/dist/adoption/plan.d.ts +3 -2
- package/dist/adoption/plan.js +7 -5
- package/dist/adoption/runner.js +3 -10
- package/dist/adoption/sql.d.ts +3 -2
- package/dist/adoption/sql.js +3 -5
- package/dist/adoption/wire.d.ts +4 -1
- package/dist/adoption/wire.js +1 -0
- package/dist/approval-ask-audit-store.d.ts +31 -13
- package/dist/approval-ask-audit-store.js +272 -74
- package/dist/approval-ask-machine.d.ts +15 -0
- package/dist/approval-ask-machine.js +6 -0
- package/dist/approval-ask-retention.d.ts +136 -0
- package/dist/approval-ask-retention.js +102 -0
- package/dist/approval-card.d.ts +82 -20
- package/dist/approval-card.js +46 -16
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval.d.ts +9 -0
- package/dist/approval.js +24 -3
- package/dist/audit.d.ts +33 -19
- package/dist/audit.js +12 -16
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/deployment-mods.d.ts +31 -0
- package/dist/boot/deployment-mods.js +26 -0
- package/dist/boot/execution-env.d.ts +1 -1
- package/dist/boot/execution-env.js +27 -12
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.js +2 -0
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-boundary.js +2 -2
- package/dist/boot/memory-consolidation.d.ts +5 -4
- package/dist/boot/memory-consolidation.js +7 -6
- package/dist/boot/org-delivery.d.ts +28 -0
- package/dist/boot/org-delivery.js +20 -0
- package/dist/boot/read-deny-anchor-audit.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +4 -5
- package/dist/boot/resolve-spec.js +74 -123
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +15 -2
- package/dist/boot/session-faces.d.ts +2 -7
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -4
- package/dist/boot/stage-05-execution-env.js +7 -10
- package/dist/boot/stage-06-runners.d.ts +4 -2
- package/dist/boot/stage-06-runners.js +11 -7
- package/dist/boot/stage-07-capability-layer.d.ts +4 -2
- package/dist/boot/stage-07-capability-layer.js +27 -6
- package/dist/boot/stage-08-reapers.d.ts +4 -2
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +6 -9
- package/dist/boot/stage-10-http-server.d.ts +6 -9
- package/dist/boot/stage-10-http-server.js +7 -9
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +7 -8
- package/dist/boot/web-admin.d.ts +4 -3
- package/dist/boot/web-admin.js +186 -98
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +25 -25
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +23 -0
- package/dist/caller-text-echo.js +21 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +32 -59
- package/dist/capabilities/center-prompts.js +18 -32
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +30 -6
- package/dist/capabilities/hands-lane.js +11 -1
- package/dist/capabilities/mcp-probe.d.ts +48 -3
- package/dist/capabilities/mcp-probe.js +47 -135
- package/dist/capabilities/scenarios.d.ts +95 -45
- package/dist/capabilities/scenarios.js +53 -38
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capability-facts.d.ts +34 -4
- package/dist/capability-facts.js +28 -2
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- package/dist/checkpoint-identity.d.ts +16 -0
- package/dist/checkpoint-identity.js +19 -0
- package/dist/config-catalog.d.ts +17 -10
- package/dist/config-catalog.js +47 -32
- package/dist/config-d-migration.d.ts +3 -1
- package/dist/config-d-migration.js +2 -2
- package/dist/config-dir-trust.d.ts +114 -0
- package/dist/config-dir-trust.js +388 -0
- package/dist/config-invariants.d.ts +18 -5
- package/dist/config-invariants.js +35 -3
- package/dist/config-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +9 -2
- package/dist/config-provider.js +18 -6
- package/dist/config-types.d.ts +75 -20
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +137 -62
- package/dist/delegated-session-owner.d.ts +185 -0
- package/dist/delegated-session-owner.js +119 -0
- package/dist/device-protocol.d.ts +5 -3
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +21 -2
- package/dist/device-ws-protocol.d.ts +70 -6
- package/dist/device-ws-protocol.js +50 -22
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/env-name-allowlist-knobs.d.ts +12 -2
- package/dist/env-name-allowlist-knobs.js +5 -4
- package/dist/exec-bounds.d.ts +15 -3
- package/dist/exec-bounds.js +4 -0
- package/dist/execution-lane-caps.d.ts +56 -10
- package/dist/execution-lane-caps.js +50 -0
- package/dist/field-conflict.d.ts +43 -0
- package/dist/field-conflict.js +20 -0
- package/dist/fleet/fleet-bus.d.ts +80 -6
- package/dist/fleet/fleet-bus.js +41 -9
- package/dist/hooks/classic-stations.d.ts +91 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +79 -36
- package/dist/hooks/hook-runner.d.ts +349 -95
- package/dist/hooks/hook-runner.js +855 -568
- package/dist/hooks/hook-source.d.ts +44 -0
- package/dist/hooks/hook-source.js +40 -0
- package/dist/http/active-run-conflict.d.ts +5 -13
- package/dist/http/active-run-conflict.js +17 -27
- package/dist/http/admission.d.ts +8 -2
- package/dist/http/admission.js +188 -101
- package/dist/http/approval-sweeps.js +99 -21
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +41 -24
- package/dist/http/checkpoint-ctx.js +23 -16
- package/dist/http/claimed-run.d.ts +14 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +7 -11
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +15 -13
- package/dist/http/durable-run-leg.d.ts +6 -33
- package/dist/http/durable-run-leg.js +36 -10
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +70 -28
- package/dist/http/principal-gate.js +61 -15
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +43 -23
- package/dist/http/request-guards.js +53 -17
- package/dist/http/resume-ctx-read.d.ts +2 -5
- package/dist/http/resume-ctx-read.js +7 -4
- package/dist/http/resume-legs.d.ts +28 -4
- package/dist/http/resume-legs.js +169 -91
- package/dist/http/retired-service-deps.d.ts +43 -0
- package/dist/http/retired-service-deps.js +18 -0
- package/dist/http/route-ctx.d.ts +44 -28
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.js +3 -4
- package/dist/http/routes/admin-config-refresh.js +1 -1
- package/dist/http/routes/admin-drain.js +1 -1
- package/dist/http/routes/admin-memory-optout.js +5 -1
- package/dist/http/routes/adoption.js +2 -9
- package/dist/http/routes/approvals-assistant.js +49 -48
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +21 -5
- package/dist/http/routes/config-catalog.d.ts +3 -3
- package/dist/http/routes/config-catalog.js +1 -1
- package/dist/http/routes/devices.js +3 -17
- package/dist/http/routes/diagnostics.js +6 -2
- package/dist/http/routes/images.js +6 -7
- package/dist/http/routes/leader.js +1 -8
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +3 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-consolidation.js +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/memory-policy.d.ts +1 -1
- package/dist/http/routes/memory-policy.js +3 -2
- package/dist/http/routes/notify-wake.js +8 -21
- package/dist/http/routes/observability.js +2 -2
- package/dist/http/routes/principal-inbox.d.ts +39 -0
- package/dist/http/routes/principal-inbox.js +76 -0
- package/dist/http/routes/retention-ops.js +2 -9
- package/dist/http/routes/rules.js +5 -18
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +34 -107
- package/dist/http/routes/session-sync.js +15 -26
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +8 -7
- package/dist/http/routes/tasks.js +67 -21
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +33 -10
- package/dist/http/send.js +21 -4
- package/dist/http/server.d.ts +27 -18
- package/dist/http/server.js +34 -6
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +40 -0
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +11 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/lane-home-probe.d.ts +112 -0
- package/dist/lane-home-probe.js +101 -0
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/limit-refusal.d.ts +59 -0
- package/dist/limit-refusal.js +15 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +32 -19
- package/dist/mcp-assertion-header.js +10 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +6 -4
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +24 -17
- package/dist/memory-scope.js +24 -8
- package/dist/memory-sync-client.d.ts +27 -13
- package/dist/memory-sync-client.js +107 -18
- package/dist/model-entry-refusal.d.ts +9 -1
- package/dist/model-entry-refusal.js +6 -1
- package/dist/model-plane-face.d.ts +51 -0
- package/dist/model-plane-face.js +24 -0
- package/dist/model-provider.d.ts +44 -12
- package/dist/model-provider.js +21 -2
- package/dist/model-route-endpoint.d.ts +9 -12
- package/dist/model-route-endpoint.js +8 -11
- package/dist/model-route-env.d.ts +22 -0
- package/dist/model-route-env.js +2 -0
- package/dist/model-route-gap.d.ts +60 -30
- package/dist/model-route-gap.js +21 -15
- package/dist/observability/corrupt-read-seat.d.ts +7 -0
- package/dist/observability/corrupt-read-seat.js +9 -0
- package/dist/observability/cost-taxonomy.d.ts +7 -7
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +76 -14
- package/dist/observability/fail-open.js +76 -14
- package/dist/observability/metrics.js +4 -1
- package/dist/observability/prompt-manifest.d.ts +33 -82
- package/dist/observability/prompt-manifest.js +122 -17
- package/dist/observability/run-terminal.js +14 -6
- package/dist/observability/secret-env-scrub.d.ts +13 -1
- package/dist/observability/secret-env-scrub.js +13 -1
- package/dist/observability/tool-trace.d.ts +16 -21
- package/dist/observability/tool-trace.js +58 -49
- package/dist/operator-ask.d.ts +10 -0
- package/dist/operator-ask.js +3 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
- package/dist/orchestration/workflow-agent-session-index.js +9 -13
- package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
- package/dist/orchestration/workflow-completion-inbox.js +13 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
- package/dist/orchestration/workflow-notify-journal.js +27 -34
- package/dist/orchestration/workflow-park-decision.d.ts +89 -0
- package/dist/orchestration/workflow-park-decision.js +118 -0
- package/dist/org-delivery-gate.d.ts +81 -0
- package/dist/org-delivery-gate.js +59 -0
- package/dist/panel-tool-names.d.ts +23 -0
- package/dist/panel-tool-names.js +8 -0
- package/dist/parked-decide.d.ts +39 -6
- package/dist/parked-decide.js +98 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- package/dist/plugins/approval-ask-store-file.d.ts +16 -1
- package/dist/plugins/approval-ask-store-file.js +21 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
- package/dist/plugins/approval-ask-store-memory.js +34 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
- package/dist/plugins/approval-ask-store-sql.js +37 -1
- package/dist/plugins/blob-backend.d.ts +83 -15
- package/dist/plugins/blob-backend.js +68 -15
- package/dist/plugins/breaker-state-sql.d.ts +2 -2
- package/dist/plugins/breaker-state-sql.js +4 -4
- package/dist/plugins/caching-session-store.d.ts +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +28 -4
- package/dist/plugins/checkpoint-store-sql.js +59 -28
- package/dist/plugins/file-history-store-sql.d.ts +5 -2
- package/dist/plugins/file-history-store-sql.js +3 -1
- package/dist/plugins/file-run-store.d.ts +5 -13
- package/dist/plugins/file-run-store.js +9 -0
- package/dist/plugins/fork-routing-session-store.d.ts +9 -1
- package/dist/plugins/fork-routing-session-store.js +12 -1
- package/dist/plugins/host-platform.d.ts +2 -0
- package/dist/plugins/host-platform.js +2 -1
- package/dist/plugins/k8s-bg-scripts.d.ts +11 -0
- package/dist/plugins/k8s-bg-scripts.js +22 -0
- package/dist/plugins/local-checkpoint-store.d.ts +2 -0
- package/dist/plugins/local-checkpoint-store.js +11 -3
- package/dist/plugins/local-session-store.d.ts +1 -1
- package/dist/plugins/local-session-store.js +1 -1
- package/dist/plugins/local-session-window.d.ts +39 -0
- package/dist/plugins/local-session-window.js +54 -0
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
- package/dist/plugins/mailbox-store-sql.d.ts +30 -48
- package/dist/plugins/mailbox-store-sql.js +77 -52
- package/dist/plugins/memory-embedder-fingerprint.js +2 -1
- package/dist/plugins/memory-run-store.d.ts +5 -13
- package/dist/plugins/memory-run-store.js +8 -0
- package/dist/plugins/one-time-migrations.d.ts +245 -93
- package/dist/plugins/one-time-migrations.js +668 -207
- package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
- package/dist/plugins/org-delivery-quota-store.js +228 -0
- package/dist/plugins/permission-rule-store-sql.d.ts +13 -7
- package/dist/plugins/permission-rule-store-sql.js +4 -18
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +20 -8
- package/dist/plugins/pg-session-storage.js +34 -21
- package/dist/plugins/remote-env-adb.d.ts +12 -12
- package/dist/plugins/remote-env-adb.js +21 -6
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +1 -1
- package/dist/plugins/remote-env-e2b.js +21 -9
- package/dist/plugins/remote-env-host.d.ts +9 -9
- package/dist/plugins/remote-env-host.js +10 -32
- package/dist/plugins/remote-env-k8s.d.ts +103 -38
- package/dist/plugins/remote-env-k8s.js +288 -95
- package/dist/plugins/remote-env-local-docker.d.ts +27 -13
- package/dist/plugins/remote-env-local-docker.js +82 -11
- package/dist/plugins/remote-env-ssh.d.ts +21 -12
- package/dist/plugins/remote-env-ssh.js +117 -5
- package/dist/plugins/remote-shell.d.ts +0 -1
- package/dist/plugins/remote-shell.js +1 -2
- package/dist/plugins/retention-store-sql.js +6 -2
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-user-file.js +2 -2
- package/dist/plugins/session-epoch-anchor.d.ts +39 -0
- package/dist/plugins/session-epoch-anchor.js +22 -0
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
- package/dist/plugins/shared-memory-store-sql.js +5 -16
- package/dist/plugins/sql-driver.d.ts +205 -1
- package/dist/plugins/sql-driver.js +325 -13
- package/dist/plugins/sql-errors.d.ts +64 -0
- package/dist/plugins/sql-errors.js +57 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +42 -15
- package/dist/plugins/store-contracts.d.ts +42 -0
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/tidb-pool.d.ts +6 -1
- package/dist/plugins/tidb-pool.js +44 -10
- package/dist/plugins/tidb-session-storage.d.ts +8 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.d.ts +24 -4
- package/dist/plugins/tidb-session-store.js +29 -5
- package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
- package/dist/plugins/workflow-journal-store-sql.js +19 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
- package/dist/plugins/workflow-run-store-sql.js +50 -9
- package/dist/posture-source.d.ts +18 -10
- package/dist/posture-source.js +4 -1
- package/dist/project-identity.d.ts +45 -6
- package/dist/project-identity.js +162 -8
- package/dist/project-layer-key.d.ts +28 -0
- package/dist/project-layer-key.js +29 -0
- package/dist/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- package/dist/question.js +3 -2
- package/dist/read-deny-entry.d.ts +25 -0
- package/dist/read-deny-entry.js +12 -0
- package/dist/read-face-posture.d.ts +37 -11
- package/dist/read-face-posture.js +32 -3
- package/dist/request-key-closure.d.ts +9 -2
- package/dist/request-key-closure.js +11 -5
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +38 -11
- package/dist/rule-entry-list.js +106 -30
- package/dist/rules-consent.js +3 -4
- package/dist/run-acceptance.d.ts +19 -3
- package/dist/run-acceptance.js +13 -1
- package/dist/run-local.js +54 -24
- package/dist/runs.d.ts +15 -8
- package/dist/runs.js +35 -1
- package/dist/runtime-caps-resolver.d.ts +16 -6
- package/dist/runtime-caps-resolver.js +18 -5
- package/dist/sandbox-pkg-source.d.ts +19 -1
- package/dist/sandbox-pkg-source.js +29 -7
- package/dist/security.d.ts +87 -9
- package/dist/security.js +52 -9
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- package/dist/session-titled-frame.d.ts +33 -0
- package/dist/session-titled-frame.js +4 -0
- package/dist/session-titler.d.ts +9 -1
- package/dist/session-titler.js +27 -6
- package/dist/spec-fields.d.ts +28 -16
- package/dist/spec-fields.js +66 -54
- package/dist/sql-engine-posture.d.ts +31 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-tool-axes-m19.d.ts +19 -4
- package/dist/stored-request-tool-axes-m19.js +30 -2
- package/dist/task-a2a.d.ts +9 -1
- package/dist/task-a2a.js +73 -47
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +46 -58
- package/dist/task-mcp.js +82 -107
- package/dist/task-settings.d.ts +95 -108
- package/dist/task-settings.js +77 -98
- package/dist/text-bidi.d.ts +1 -48
- package/dist/text-bidi.js +3 -5
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +304 -88
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +122 -20
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/ledger-sink.js +4 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +98 -17
- package/dist/trace/project.js +98 -50
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +54 -0
- package/dist/trace/redact.js +778 -152
- package/dist/trace/self-minted-wire.d.ts +345 -1
- package/dist/trace/self-minted-wire.js +117 -1
- package/dist/trace/wire-projection-faces.d.ts +377 -3
- package/dist/trace/wire-projection-faces.js +164 -1
- package/dist/url-refusal.js +2 -0
- package/dist/web-admin-client/apply-effective.d.ts +12 -0
- package/dist/web-admin-client/apply-effective.js +56 -5
- package/dist/web-admin-client/candidate-gate.d.ts +6 -6
- package/dist/web-admin-client/candidate-gate.js +3 -3
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/read-warnings.d.ts +13 -0
- package/dist/web-admin-client/read-warnings.js +10 -0
- package/dist/web-admin-client/skills-mcp.d.ts +3 -0
- package/dist/web-admin-client/skills-mcp.js +11 -9
- package/dist/web-admin-client/types.d.ts +2 -3
- package/dist/workspace-cache.d.ts +35 -0
- package/dist/workspace-cache.js +36 -0
- package/dist/workspace-space.d.ts +3 -2
- package/dist/workspace-space.js +2 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +65 -10
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -1
- package/scripts/drain-check.mysql.sql +30 -2
- package/scripts/drain-check.pg.sql +29 -2
- package/dist/capabilities/memory-notice.d.ts +0 -138
- package/dist/capabilities/memory-notice.js +0 -64
- package/dist/capabilities/prompt.d.ts +0 -17
- package/dist/capabilities/prompt.js +0 -6
- package/dist/mcp-content-origin.d.ts +0 -34
- package/dist/mcp-content-origin.js +0 -10
- package/dist/tool-axis-words.d.ts +0 -27
- package/dist/tool-axis-words.js +0 -9
- package/dist/wire-name-bound.d.ts +0 -14
- package/dist/wire-name-bound.js +0 -13
package/dist/trace/project.d.ts
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import type { GateOutcome, McpDelivered, TaskResult, SystemInjectionPriority } from "@sema-agent/core";
|
|
27
27
|
import type { RunEvent, RunRecord } from "../plugins/store-contracts.js";
|
|
28
28
|
import type { ModelUsageDelta, ModelUsageTracker, PromptManifestRecord } from "../budget.js";
|
|
29
|
+
import { type SafeText } from "./exit-seat.js";
|
|
29
30
|
import { type SemaProvenanceInput } from "./sema-provenance.js";
|
|
30
31
|
import type { LedgerEventType } from "./ledger-events.js";
|
|
31
32
|
import type { InstructionsSegment } from "../instruction-selection.js";
|
|
@@ -81,6 +82,13 @@ export declare function attachModelUsage<T extends TaskResult>(result: T, ctx: {
|
|
|
81
82
|
* · **键在场但值坏**(NaN / 字符串 / null)= 数据损坏,写了键的 producer 是在声称自己知道 ⇒ 维持既有
|
|
82
83
|
* 折叠(按 0 计,不传染,已知量不受损),否则一条陈年坏行就能把整个模型的成本抹成"未知"。
|
|
83
84
|
* 下游补偿件早已就位:usage-analytics 的 numOf + `estimated` 标记(缺数值键 ⇒ 总量偏低并诚实标注)。 */
|
|
85
|
+
/** **trace 帧数据的出口形**(RH-1 第一期):`Slots` 里列出的自由文本位只收 {@link SafeText}(出口座铸的),其余键照旧开放 ——
|
|
86
|
+
* 裸 `string` 写进这些位是 tsc 红;整只帧数据**只读**(交出去之后按键改写 —— 含动态键 `frame[k] = raw` —— 也是 tsc 红)。
|
|
87
|
+
* 对既有的 `Record<string, unknown>` 读者可赋值(零调用点改动)。类型层管不到的两形如实记:`any` 值、以及把一只 `Record<string, unknown>`
|
|
88
|
+
* 展开进字面量 / `Object.assign` 事后改写(TypeScript 不拿索引签名去对可选位、也不查 `Object.assign` 的目标)—— 品牌推到汇(SSE 写口 / 账本 append)是第三期。 */
|
|
89
|
+
type FrameData<Slots extends object> = Readonly<Slots> & {
|
|
90
|
+
readonly [key: string]: unknown;
|
|
91
|
+
};
|
|
84
92
|
export declare function aggregateModelUsage(events: RunEvent[]): Record<string, ModelUsageDelta> | undefined;
|
|
85
93
|
export type TraceBlock = {
|
|
86
94
|
type: "thinking";
|
|
@@ -113,11 +121,7 @@ export type TraceBlock = {
|
|
|
113
121
|
parentToolCallId?: string;
|
|
114
122
|
} | {
|
|
115
123
|
type: "prompt-assembled";
|
|
116
|
-
|
|
117
|
-
totalChars: number;
|
|
118
|
-
blocks: unknown;
|
|
119
|
-
sections?: unknown;
|
|
120
|
-
tools?: unknown;
|
|
124
|
+
readonly [member: string]: unknown;
|
|
121
125
|
};
|
|
122
126
|
/**
|
|
123
127
|
* 🔴 **模型自由文本账本行(`text` / `reasoning`)的唯一载荷铸点**(B-106 / S-268,7.75.1)。
|
|
@@ -377,7 +381,11 @@ export declare function taskProgressEventData(ev: {
|
|
|
377
381
|
workflowAgentLabel?: string;
|
|
378
382
|
seq?: number;
|
|
379
383
|
model?: string;
|
|
380
|
-
}):
|
|
384
|
+
}): FrameData<{
|
|
385
|
+
name?: SafeText;
|
|
386
|
+
currentAction?: SafeText;
|
|
387
|
+
workflowAgentLabel?: SafeText;
|
|
388
|
+
}>;
|
|
381
389
|
/**
|
|
382
390
|
* The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
|
|
383
391
|
* 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
|
|
@@ -418,7 +426,10 @@ export declare function taskStartedEventData(ev: {
|
|
|
418
426
|
startedAt: number;
|
|
419
427
|
eventId?: string;
|
|
420
428
|
parentToolCallId?: string;
|
|
421
|
-
}):
|
|
429
|
+
}): FrameData<{
|
|
430
|
+
name?: SafeText;
|
|
431
|
+
workflowAgentLabel?: SafeText;
|
|
432
|
+
}>;
|
|
422
433
|
/** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
|
|
423
434
|
* LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
|
|
424
435
|
* attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
|
|
@@ -496,7 +507,28 @@ export declare function taskNotificationEventData(ev: {
|
|
|
496
507
|
* **事件顶层**键,不是 {@link TaskNotificationPayload} 的键,所以只有把整只 core 事件交给本投影的腿
|
|
497
508
|
* 拿得到它;只拿到载荷的 park-drain 腿结构上没有这一位。 */
|
|
498
509
|
priority?: SystemInjectionPriority;
|
|
499
|
-
}):
|
|
510
|
+
}): FrameData<{
|
|
511
|
+
summary: SafeText;
|
|
512
|
+
result?: SafeText;
|
|
513
|
+
output_file?: SafeText;
|
|
514
|
+
source?: SafeText;
|
|
515
|
+
diagnostics?: SafeText;
|
|
516
|
+
error?: SafeText;
|
|
517
|
+
lines?: SafeText[];
|
|
518
|
+
recentSteps?: Array<{
|
|
519
|
+
tool: string;
|
|
520
|
+
target: SafeText;
|
|
521
|
+
outcome: SafeText;
|
|
522
|
+
}>;
|
|
523
|
+
editedFiles?: Array<{
|
|
524
|
+
path: SafeText;
|
|
525
|
+
edits: number;
|
|
526
|
+
}>;
|
|
527
|
+
agentMessage?: {
|
|
528
|
+
from: string;
|
|
529
|
+
body: SafeText;
|
|
530
|
+
};
|
|
531
|
+
}>;
|
|
500
532
|
/** The `compacted` payload — EXPLICIT WHITELIST shared by all three legs (bg runs.ts + resume append + the sync
|
|
501
533
|
* live SSE frame; the 1.72 task_progress lesson: never `{...ev}`). trigger/tokensBefore (MF-18) verbatim;
|
|
502
534
|
* `preserved_segment.firstKeptEntryId` verbatim (a core-mint entryId, the shell's compaction-divider anchor);
|
|
@@ -523,7 +555,16 @@ export declare function diagnosticsEventData(ev: {
|
|
|
523
555
|
isNew: boolean;
|
|
524
556
|
eventId?: string;
|
|
525
557
|
parentToolCallId?: string;
|
|
526
|
-
}):
|
|
558
|
+
}): FrameData<{
|
|
559
|
+
files: Array<{
|
|
560
|
+
uri: SafeText;
|
|
561
|
+
diagnostics: Array<FrameData<{
|
|
562
|
+
message: SafeText;
|
|
563
|
+
code?: SafeText | number;
|
|
564
|
+
source?: SafeText;
|
|
565
|
+
}>>;
|
|
566
|
+
}>;
|
|
567
|
+
}>;
|
|
527
568
|
/** The `steering_injected` payload([ref]/[ref] 裁定透传;core `TaskEvent` 联合臂 `type: "steering_injected"`,
|
|
528
569
|
* shell 渲染源 = CC 的系统提醒条:core 在 turn 之间给模型注入一条系统提示[todo 提醒/文件变化/日期跨天/
|
|
529
570
|
* 技能列表变化…]时随手抛的展示投影,一附件一帧)。EXPLICIT WHITELIST(source=封闭枚举 verbatim;
|
|
@@ -534,7 +575,9 @@ export declare function steeringInjectedEventData(ev: {
|
|
|
534
575
|
preview: string;
|
|
535
576
|
eventId?: string;
|
|
536
577
|
parentToolCallId?: string;
|
|
537
|
-
}):
|
|
578
|
+
}): FrameData<{
|
|
579
|
+
preview: SafeText;
|
|
580
|
+
}>;
|
|
538
581
|
/** `compaction_outcome`(core 2.5.0 [ref]②:压缩非 compacted 结局——manual /compact 的 mooted/failed
|
|
539
582
|
* 两条真路)。[ref]A-2/C-2:此前它是**唯一**不走共享 builder、只在 live 腿 res.write 内联挑键的
|
|
540
583
|
* 内容帧 ⇒ 两条 durable 腿零 case、回放即消失、三方普查各自失明。收进共享白名单 builder,三腿同源。
|
|
@@ -543,6 +586,23 @@ export declare function compactionOutcomeEventData(ev: {
|
|
|
543
586
|
outcome?: unknown;
|
|
544
587
|
trigger?: unknown;
|
|
545
588
|
reason?: unknown;
|
|
589
|
+
pass?: unknown;
|
|
590
|
+
eventId?: unknown;
|
|
591
|
+
parentToolCallId?: unknown;
|
|
592
|
+
}): FrameData<{
|
|
593
|
+
reason?: SafeText;
|
|
594
|
+
}>;
|
|
595
|
+
/**
|
|
596
|
+
* `compaction_started`(S-1732,core 7.53.0 #2008)—— 一次压缩 pass 在提交点(触发闸过了、切点在、`preCompact` 没拦)宣告开始,先于摘要调用:
|
|
597
|
+
* 一次在供应方重试表里等很久的摘要(core 实测 503 × 11、173 s)从此在流上不是静默的。**原样投影**:`{ trigger, pass, startedAt }` + 身份两键,
|
|
598
|
+
* 不自铸相位、不铸 run / session id(那是流的,不是帧的键)。三键都是引擎铸的闭形值:`trigger` 闭集词(`auto` / `manual` / `forced`,与结束帧同一张词表)、
|
|
599
|
+
* `pass` 不透明 id(结束这次 pass 的那一帧 —— `compacted` 或 `compaction_outcome` —— 带同一个 `pass`)、`startedAt` 引擎时钟 epoch 毫秒 ⇒ 不脱敏、逐字;
|
|
600
|
+
* 形不合即缺席(与 {@link compactionOutcomeEventData} 同款守卫,不编值)。三条消费腿(live 帧、两条 durable 腿)共用这一只。
|
|
601
|
+
*/
|
|
602
|
+
export declare function compactionStartedEventData(ev: {
|
|
603
|
+
trigger?: unknown;
|
|
604
|
+
pass?: unknown;
|
|
605
|
+
startedAt?: unknown;
|
|
546
606
|
eventId?: unknown;
|
|
547
607
|
parentToolCallId?: unknown;
|
|
548
608
|
}): Record<string, unknown>;
|
|
@@ -556,7 +616,9 @@ export declare function workspaceChangedEventData(ev: {
|
|
|
556
616
|
cwd: string;
|
|
557
617
|
eventId?: string;
|
|
558
618
|
parentToolCallId?: string;
|
|
559
|
-
}):
|
|
619
|
+
}): FrameData<{
|
|
620
|
+
cwd: SafeText;
|
|
621
|
+
}>;
|
|
560
622
|
/**
|
|
561
623
|
* `wiring_manifest`(core 5.14.0 [ref] 新 `TaskEvent` 臂)—— 每条腿(root/child/resume)在 prepare
|
|
562
624
|
* 时自证「我到底接了什么线」的清单帧。
|
|
@@ -791,8 +853,8 @@ export declare function wiringManifestEventData(ev: {
|
|
|
791
853
|
* 代价是 operator 看不到历史腿的 governance 段 —— 治理四布尔是部署形事实(不随 leg 漂),静态自检面
|
|
792
854
|
* (`GET /v1/diagnostics/wiring`)随时给出当前真值。
|
|
793
855
|
*
|
|
794
|
-
* 准入判据是 `explicitOperatorOk`(
|
|
795
|
-
*
|
|
856
|
+
* 准入判据是 `explicitOperatorOk`(「谁是 operator」的唯一读法):空 `OPERATOR_PRINCIPALS` 是「没有人是 operator」,不是「所有人都是」——
|
|
857
|
+
* 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。单用户形显式声明 `OPERATOR_SINGLE_USER=true` 时它的每个调用方都是。
|
|
796
858
|
*
|
|
797
859
|
* `configFingerprint` 只在本构造器里透传:它是 `sha256(canonicalize(manifest 去 leg/去两个 provenance))`
|
|
798
860
|
* 前 16 hex,**无盐**且输入含整个 governance 段,而 governance 只有 4 个布尔 ⇒ 16 种组合。租户手里已有其余
|
|
@@ -806,7 +868,7 @@ export declare function wiringManifestEventData(ev: {
|
|
|
806
868
|
* `core-keyset-guard.ts` ⑥b `WiringSectionExcluded`)。**present-iff 武装**:
|
|
807
869
|
* · 整段缺席 ⇒ **未武装**,不铸键、不计数(正面事实,不是「未知」,更不是 `{onRecommendation:false}`);
|
|
808
870
|
* · 在场且 `onRecommendation === true` ⇒ 逐字铸出(core 的在场形只有这一个,构造期门已拒掉「武装但跑不起来」);
|
|
809
|
-
* · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `
|
|
871
|
+
* · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `mods` 同一条
|
|
810
872
|
* 族规:「在场但读不出 ⇒ 计一次并丢弃」;**不**自造第三态,词表/形的属主在 core)。
|
|
811
873
|
* 🔴 代价如实登记,与 `writeProtection` 那一格逐字同源:wire 上「读不出」与「真未武装」是**同一个形**,
|
|
812
874
|
* 分得开它们的只有 `server.trace.projection-input-malformed` 这只计数 —— 而这一格比那一格更该说清楚,
|
|
@@ -874,7 +936,16 @@ export declare function humanInputEventData(ev: {
|
|
|
874
936
|
attachments?: unknown;
|
|
875
937
|
eventId?: unknown;
|
|
876
938
|
parentToolCallId?: unknown;
|
|
877
|
-
}):
|
|
939
|
+
}): FrameData<{
|
|
940
|
+
issuer?: SafeText;
|
|
941
|
+
actor?: FrameData<{
|
|
942
|
+
id?: SafeText;
|
|
943
|
+
issuer?: SafeText;
|
|
944
|
+
}>;
|
|
945
|
+
attachments?: Array<FrameData<{
|
|
946
|
+
label?: SafeText;
|
|
947
|
+
}>>;
|
|
948
|
+
}>;
|
|
878
949
|
/** S4 (SILENT-FALLBACK P0-a): the durable `brain_status` observation row, shared by the bg + resume append
|
|
879
950
|
* sites. core marks the live `status` frame EPHEMERAL (never replayed by core on resume) — this row is the
|
|
880
951
|
* SERVICE's own observation record (why a turn stalled: rate_limited/retrying/reconnecting/circuit_open, and
|
|
@@ -896,7 +967,9 @@ export declare function brainStatusEventData(ev: {
|
|
|
896
967
|
providerConditionSource?: string;
|
|
897
968
|
eventId?: string;
|
|
898
969
|
parentToolCallId?: string;
|
|
899
|
-
}):
|
|
970
|
+
}): FrameData<{
|
|
971
|
+
detail?: SafeText;
|
|
972
|
+
}>;
|
|
900
973
|
export declare function compactedEventData(ev: {
|
|
901
974
|
eventId?: string;
|
|
902
975
|
parentToolCallId?: string;
|
|
@@ -932,7 +1005,15 @@ export declare function compactedEventData(ev: {
|
|
|
932
1005
|
persistMs?: number;
|
|
933
1006
|
ptlRetries?: number;
|
|
934
1007
|
};
|
|
935
|
-
|
|
1008
|
+
/** S-1732(core 7.53.0 #2008):这次落地的压缩 pass 的 id —— 与它的 `compaction_started` 帧同一个值(引擎在每次落地上都设;型上可选)。逐字。 */
|
|
1009
|
+
pass?: string;
|
|
1010
|
+
}): FrameData<{
|
|
1011
|
+
attachedFiles?: Array<{
|
|
1012
|
+
path: SafeText;
|
|
1013
|
+
chars: number;
|
|
1014
|
+
truncated: boolean;
|
|
1015
|
+
}>;
|
|
1016
|
+
}>;
|
|
936
1017
|
export interface TraceTurn {
|
|
937
1018
|
/** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
|
|
938
1019
|
seq: number;
|
package/dist/trace/project.js
CHANGED
|
@@ -3,6 +3,8 @@ import { MCP_DELIVERY_VERDICTS, MCP_LIVENESS_STATES, screenGateOutcome, TEAM_ROL
|
|
|
3
3
|
import { Value } from "typebox/value";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
5
|
import { redactSecrets, redactDeep } from "./redact.js";
|
|
6
|
+
import { seatText } from "./exit-seat.js";
|
|
7
|
+
import { sanitizeWireText } from "./engine-notice-wire.js";
|
|
6
8
|
import { projectToolOutput, projectToolStructured } from "./tool-output-media.js";
|
|
7
9
|
import { injectionTierOrAbsent } from "./injection-tier.js";
|
|
8
10
|
import { semaProvenanceOrAbsent } from "./sema-provenance.js";
|
|
@@ -269,14 +271,14 @@ export function taskProgressEventData(ev) {
|
|
|
269
271
|
...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
|
|
270
272
|
...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
|
|
271
273
|
...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
|
|
272
|
-
...(ev.name ? { name:
|
|
274
|
+
...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
|
|
273
275
|
...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
|
|
274
276
|
...(typeof ev.model === "string" && ev.model.length > 0 ? { model: ev.model } : {}),
|
|
275
277
|
...(ev.status !== undefined ? { status: ev.status } : {}),
|
|
276
278
|
...(ev.usage ? { usage: ev.usage } : {}),
|
|
277
|
-
...(ev.currentAction ? { currentAction:
|
|
279
|
+
...(ev.currentAction ? { currentAction: seatText("trace-frame-text", ev.currentAction) } : {}),
|
|
278
280
|
...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
|
|
279
|
-
...(ev.workflowAgentLabel ? { workflowAgentLabel:
|
|
281
|
+
...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
|
|
280
282
|
...identityFields(ev),
|
|
281
283
|
};
|
|
282
284
|
}
|
|
@@ -287,11 +289,11 @@ export function taskStartedEventData(ev) {
|
|
|
287
289
|
...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
|
|
288
290
|
...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
|
|
289
291
|
...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
|
|
290
|
-
...(ev.workflowAgentLabel ? { workflowAgentLabel:
|
|
292
|
+
...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
|
|
291
293
|
...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
|
|
292
294
|
...(ev.parentSessionId ? { parentSessionId: ev.parentSessionId } : {}),
|
|
293
295
|
...(ev.rootSessionId ? { rootSessionId: ev.rootSessionId } : {}),
|
|
294
|
-
...(ev.name ? { name:
|
|
296
|
+
...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
|
|
295
297
|
...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
|
|
296
298
|
...(ev.agentType ? { agentType: ev.agentType } : {}),
|
|
297
299
|
model: ev.model,
|
|
@@ -309,10 +311,10 @@ export function taskNotificationEventData(ev) {
|
|
|
309
311
|
...(n.toolUseId !== undefined ? { toolUseId: n.toolUseId } : {}),
|
|
310
312
|
status: n.status,
|
|
311
313
|
...(n.seq !== undefined ? { seq: n.seq } : {}),
|
|
312
|
-
...(n.lines !== undefined ? { lines: n.lines.map((l) =>
|
|
314
|
+
...(n.lines !== undefined ? { lines: n.lines.map((l) => seatText("trace-frame-text", l)) } : {}),
|
|
313
315
|
...(n.stoppedBy !== undefined ? { stoppedBy: n.stoppedBy } : {}),
|
|
314
316
|
...(n.completionId !== undefined ? { completionId: n.completionId } : {}),
|
|
315
|
-
...(n.error !== undefined ? { error:
|
|
317
|
+
...(n.error !== undefined ? { error: seatText("trace-frame-text", n.error) } : {}),
|
|
316
318
|
...(n.errorCode !== undefined ? { errorCode: n.errorCode } : {}),
|
|
317
319
|
...(n.apiFailure !== undefined
|
|
318
320
|
? {
|
|
@@ -322,20 +324,20 @@ export function taskNotificationEventData(ev) {
|
|
|
322
324
|
},
|
|
323
325
|
}
|
|
324
326
|
: {}),
|
|
325
|
-
...(n.source !== undefined ? { source:
|
|
327
|
+
...(n.source !== undefined ? { source: seatText("trace-frame-text", n.source) } : {}),
|
|
326
328
|
...(n.exitCode !== undefined ? { exitCode: n.exitCode } : {}),
|
|
327
329
|
...(n.partial !== undefined ? { partial: n.partial } : {}),
|
|
328
|
-
...(n.diagnostics !== undefined ? { diagnostics:
|
|
330
|
+
...(n.diagnostics !== undefined ? { diagnostics: seatText("trace-frame-text", n.diagnostics) } : {}),
|
|
329
331
|
...(n.recentSteps !== undefined
|
|
330
|
-
? { recentSteps: n.recentSteps.map((s) => ({ tool: s.tool, target:
|
|
332
|
+
? { recentSteps: n.recentSteps.map((s) => ({ tool: s.tool, target: seatText("trace-frame-text", s.target), outcome: seatText("trace-frame-text", s.outcome) })) }
|
|
331
333
|
: {}),
|
|
332
|
-
...(n.editedFiles !== undefined ? { editedFiles: n.editedFiles.map((f) => ({ path:
|
|
334
|
+
...(n.editedFiles !== undefined ? { editedFiles: n.editedFiles.map((f) => ({ path: seatText("trace-frame-text", f.path), edits: f.edits })) } : {}),
|
|
333
335
|
...(n.resumable !== undefined ? { resumable: n.resumable } : {}),
|
|
334
|
-
summary:
|
|
335
|
-
...(n.result !== undefined ? { result:
|
|
336
|
-
...(n.output_file !== undefined ? { output_file:
|
|
336
|
+
summary: seatText("trace-frame-text", n.summary),
|
|
337
|
+
...(n.result !== undefined ? { result: seatText("trace-frame-text", n.result) } : {}),
|
|
338
|
+
...(n.output_file !== undefined ? { output_file: seatText("trace-frame-text", n.output_file) } : {}),
|
|
337
339
|
...(n.usage !== undefined ? { usage: n.usage } : {}),
|
|
338
|
-
...(n.agentMessage !== undefined ? { agentMessage: { from: n.agentMessage.from, body:
|
|
340
|
+
...(n.agentMessage !== undefined ? { agentMessage: { from: n.agentMessage.from, body: seatText("trace-frame-text", n.agentMessage.body) } } : {}),
|
|
339
341
|
...(() => {
|
|
340
342
|
if (n._sema_provenance === undefined)
|
|
341
343
|
return {};
|
|
@@ -354,13 +356,13 @@ export function taskNotificationEventData(ev) {
|
|
|
354
356
|
export function diagnosticsEventData(ev) {
|
|
355
357
|
return {
|
|
356
358
|
files: (Array.isArray(ev.files) ? ev.files : []).map((f) => ({
|
|
357
|
-
uri:
|
|
359
|
+
uri: seatText("trace-frame-text", String(f.uri)),
|
|
358
360
|
diagnostics: (Array.isArray(f.diagnostics) ? f.diagnostics : []).map((d) => ({
|
|
359
|
-
message:
|
|
361
|
+
message: seatText("trace-frame-text", String(d.message)),
|
|
360
362
|
...(d.severity !== undefined ? { severity: d.severity } : {}),
|
|
361
363
|
...(d.range !== undefined ? { range: d.range } : {}),
|
|
362
|
-
...(d.code !== undefined ? { code: typeof d.code === "number" ? d.code :
|
|
363
|
-
...(d.source !== undefined ? { source:
|
|
364
|
+
...(d.code !== undefined ? { code: typeof d.code === "number" ? d.code : seatText("trace-frame-text", String(d.code)) } : {}),
|
|
365
|
+
...(d.source !== undefined ? { source: seatText("trace-frame-text", String(d.source)) } : {}),
|
|
364
366
|
})),
|
|
365
367
|
})),
|
|
366
368
|
isNew: ev.isNew === true,
|
|
@@ -370,7 +372,7 @@ export function diagnosticsEventData(ev) {
|
|
|
370
372
|
export function steeringInjectedEventData(ev) {
|
|
371
373
|
return {
|
|
372
374
|
source: String(ev.source),
|
|
373
|
-
preview:
|
|
375
|
+
preview: seatText("trace-frame-text", String(ev.preview)),
|
|
374
376
|
...identityFields(ev),
|
|
375
377
|
};
|
|
376
378
|
}
|
|
@@ -379,13 +381,23 @@ export function compactionOutcomeEventData(ev) {
|
|
|
379
381
|
return {
|
|
380
382
|
...(s(ev.outcome) !== undefined ? { outcome: s(ev.outcome) } : {}),
|
|
381
383
|
...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
|
|
382
|
-
...(ev.reason !== undefined ? { reason:
|
|
384
|
+
...(ev.reason !== undefined ? { reason: seatText("trace-frame-text", String(ev.reason)) } : {}),
|
|
385
|
+
...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
|
|
386
|
+
...identityFields(ev),
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
export function compactionStartedEventData(ev) {
|
|
390
|
+
const s = (v) => (typeof v === "string" ? v : undefined);
|
|
391
|
+
return {
|
|
392
|
+
...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
|
|
393
|
+
...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
|
|
394
|
+
...(typeof ev.startedAt === "number" && Number.isFinite(ev.startedAt) ? { startedAt: ev.startedAt } : {}),
|
|
383
395
|
...identityFields(ev),
|
|
384
396
|
};
|
|
385
397
|
}
|
|
386
398
|
export function workspaceChangedEventData(ev) {
|
|
387
399
|
return {
|
|
388
|
-
cwd:
|
|
400
|
+
cwd: seatText("trace-frame-line", String(ev.cwd)),
|
|
389
401
|
...identityFields(ev),
|
|
390
402
|
};
|
|
391
403
|
}
|
|
@@ -513,26 +525,55 @@ export function wiringManifestEventData(ev, instructions) {
|
|
|
513
525
|
})();
|
|
514
526
|
const toolsIn = m.tools;
|
|
515
527
|
const tools = toolsIn === undefined ? undefined : Value.Check(ToolRoster, toolsIn) ? toolsIn : (recordFailOpen("server.trace.tool-roster-malformed", "wiring_manifest.tools did not fit core ToolRoster"), undefined);
|
|
516
|
-
const
|
|
517
|
-
const
|
|
518
|
-
|
|
528
|
+
const strList = (v) => (Array.isArray(v) && v.every((x) => typeof x === "string") ? [...v] : undefined);
|
|
529
|
+
const registrantText = (v) => {
|
|
530
|
+
const t = str(v);
|
|
531
|
+
return t === undefined ? undefined : sanitizeWireText(t);
|
|
532
|
+
};
|
|
533
|
+
const modsIn = m.mods;
|
|
534
|
+
const mods = (() => {
|
|
535
|
+
if (modsIn === undefined)
|
|
519
536
|
return undefined;
|
|
520
|
-
if (!Array.isArray(
|
|
521
|
-
return dropProjectedFace("wiring_manifest.
|
|
537
|
+
if (!Array.isArray(modsIn))
|
|
538
|
+
return dropProjectedFace("wiring_manifest.mods is not an array");
|
|
522
539
|
const rows = [];
|
|
523
|
-
for (const raw of
|
|
540
|
+
for (const raw of modsIn) {
|
|
524
541
|
const e = sec(raw);
|
|
525
|
-
|
|
526
|
-
|
|
542
|
+
const name = registrantText(e?.name);
|
|
543
|
+
const seat = str(e?.seat);
|
|
544
|
+
const tier = str(e?.tier);
|
|
545
|
+
if (e === undefined || name === undefined || seat === undefined || tier === undefined) {
|
|
546
|
+
dropProjectedFace("wiring_manifest.mods[] row is missing name/seat/tier");
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
const refusedBy = registrantText(e.refusedBy);
|
|
550
|
+
const reason = registrantText(e.reason);
|
|
551
|
+
if (refusedBy !== undefined && reason !== undefined) {
|
|
552
|
+
rows.push({ name, seat, tier, refusedBy, reason });
|
|
527
553
|
continue;
|
|
528
554
|
}
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
dropProjectedFace("wiring_manifest.hooks[] row is missing family/owner");
|
|
555
|
+
const events = strList(e.events);
|
|
556
|
+
if (events === undefined) {
|
|
557
|
+
dropProjectedFace("wiring_manifest.mods[] row is neither a mounted nor a refused record");
|
|
533
558
|
continue;
|
|
534
559
|
}
|
|
535
|
-
|
|
560
|
+
const observe = e.observe === undefined ? undefined : (strList(e.observe) ?? dropProjectedFace("wiring_manifest.mods[].observe is not a list of strings"));
|
|
561
|
+
const skipped = e.skipped === undefined
|
|
562
|
+
? undefined
|
|
563
|
+
: Array.isArray(e.skipped)
|
|
564
|
+
? e.skipped.flatMap((x) => {
|
|
565
|
+
const k = sec(x);
|
|
566
|
+
const registration = registrantText(k?.registration);
|
|
567
|
+
const cause = registrantText(k?.cause);
|
|
568
|
+
const why = registrantText(k?.reason);
|
|
569
|
+
if (registration === undefined || cause === undefined || why === undefined) {
|
|
570
|
+
dropProjectedFace("wiring_manifest.mods[].skipped[] element is missing registration/cause/reason");
|
|
571
|
+
return [];
|
|
572
|
+
}
|
|
573
|
+
return [{ registration, cause, reason: why }];
|
|
574
|
+
})
|
|
575
|
+
: dropProjectedFace("wiring_manifest.mods[].skipped is not an array");
|
|
576
|
+
rows.push({ name, seat, tier, events, ...(observe !== undefined ? { observe } : {}), ...(skipped !== undefined && skipped.length > 0 ? { skipped } : {}) });
|
|
536
577
|
}
|
|
537
578
|
return rows.length > 0 ? rows : undefined;
|
|
538
579
|
})();
|
|
@@ -589,11 +630,23 @@ export function wiringManifestEventData(ev, instructions) {
|
|
|
589
630
|
return dropProjectedFace("wiring_manifest.fileHistory is not a non-empty string");
|
|
590
631
|
return word;
|
|
591
632
|
})();
|
|
633
|
+
const permissionMode = (() => {
|
|
634
|
+
if (m.permissionMode === undefined)
|
|
635
|
+
return undefined;
|
|
636
|
+
const seg = sec(m.permissionMode);
|
|
637
|
+
const effective = str(seg?.effective);
|
|
638
|
+
const requested = seg?.requested === undefined ? undefined : str(seg.requested);
|
|
639
|
+
const foldedBy = seg?.foldedBy === undefined ? undefined : str(seg.foldedBy);
|
|
640
|
+
if (effective === undefined || (seg?.requested !== undefined && requested === undefined) || (seg?.foldedBy !== undefined && foldedBy === undefined))
|
|
641
|
+
return dropProjectedFace("wiring_manifest.permissionMode is not a receipt shape (effective a non-empty string, requested / foldedBy absent or non-empty strings)");
|
|
642
|
+
return { ...(requested !== undefined ? { requested } : {}), effective, ...(foldedBy !== undefined ? { foldedBy } : {}) };
|
|
643
|
+
})();
|
|
592
644
|
return {
|
|
593
645
|
...(num(m.schemaVersion) !== undefined ? { schemaVersion: m.schemaVersion } : {}),
|
|
594
646
|
...(str(legIn.kind) !== undefined ? { leg: { kind: legIn.kind } } : {}),
|
|
595
647
|
...(teamRole !== undefined ? { teamRole } : {}),
|
|
596
648
|
...(fileHistory !== undefined ? { fileHistory } : {}),
|
|
649
|
+
...(permissionMode !== undefined ? { permissionMode } : {}),
|
|
597
650
|
...(ask !== undefined ? { ask } : {}),
|
|
598
651
|
...(question !== undefined ? { question } : {}),
|
|
599
652
|
...(str(interactionIn.posture) !== undefined ? { interaction: { posture: interactionIn.posture } } : {}),
|
|
@@ -606,7 +659,7 @@ export function wiringManifestEventData(ev, instructions) {
|
|
|
606
659
|
...(autoMode !== undefined ? { autoMode } : {}),
|
|
607
660
|
...(tools !== undefined ? { tools } : {}),
|
|
608
661
|
...(mcp !== undefined ? { mcp } : {}),
|
|
609
|
-
...(
|
|
662
|
+
...(mods !== undefined ? { mods } : {}),
|
|
610
663
|
...(lsp !== undefined ? { lsp } : {}),
|
|
611
664
|
...(hands !== undefined ? { hands } : {}),
|
|
612
665
|
...(writeProtection !== undefined ? { writeProtection } : {}),
|
|
@@ -672,13 +725,13 @@ export function humanInputEventData(ev) {
|
|
|
672
725
|
...(typeof m.ordinal === "number" && Number.isFinite(m.ordinal) ? { ordinal: m.ordinal } : {}),
|
|
673
726
|
...(str(m.kind) !== undefined ? { kind: m.kind } : {}),
|
|
674
727
|
...(str(m.outcome) !== undefined ? { outcome: m.outcome } : {}),
|
|
675
|
-
...(str(m.label) !== undefined ? { label:
|
|
728
|
+
...(str(m.label) !== undefined ? { label: seatText("trace-frame-text", String(m.label)) } : {}),
|
|
676
729
|
}))
|
|
677
730
|
: undefined;
|
|
678
731
|
const actor = {
|
|
679
|
-
...(str(a.id) !== undefined ? { id:
|
|
732
|
+
...(str(a.id) !== undefined ? { id: seatText("trace-frame-text", String(a.id)) } : {}),
|
|
680
733
|
...(typeof a.hostAsserted === "boolean" ? { hostAsserted: a.hostAsserted } : {}),
|
|
681
|
-
...(str(a.issuer) !== undefined ? { issuer:
|
|
734
|
+
...(str(a.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(a.issuer)) } : {}),
|
|
682
735
|
};
|
|
683
736
|
return {
|
|
684
737
|
...(str(ev.inputId) !== undefined ? { inputId: ev.inputId } : {}),
|
|
@@ -686,7 +739,7 @@ export function humanInputEventData(ev) {
|
|
|
686
739
|
...(str(ev.carrier) !== undefined ? { carrier: ev.carrier } : {}),
|
|
687
740
|
...(str(ev.source) !== undefined ? { source: ev.source } : {}),
|
|
688
741
|
...(str(ev.delivery) !== undefined ? { delivery: ev.delivery } : {}),
|
|
689
|
-
...(str(ev.issuer) !== undefined ? { issuer:
|
|
742
|
+
...(str(ev.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(ev.issuer)) } : {}),
|
|
690
743
|
...(Object.keys(actor).length > 0 ? { actor } : {}),
|
|
691
744
|
...(str(ev.entryId) !== undefined ? { entryId: ev.entryId } : {}),
|
|
692
745
|
...(attachments !== undefined ? { attachments } : {}),
|
|
@@ -697,7 +750,7 @@ export function brainStatusEventData(ev) {
|
|
|
697
750
|
const num = (v) => typeof v === "number" && Number.isFinite(v);
|
|
698
751
|
return {
|
|
699
752
|
phase: String(ev.phase),
|
|
700
|
-
...(typeof ev.detail === "string" && ev.detail.length > 0 ? { detail:
|
|
753
|
+
...(typeof ev.detail === "string" && ev.detail.length > 0 ? { detail: seatText("trace-frame-line", ev.detail) } : {}),
|
|
701
754
|
...(num(ev.retryInSec) ? { retryInSec: ev.retryInSec } : {}),
|
|
702
755
|
...(num(ev.attempt) ? { attempt: ev.attempt } : {}),
|
|
703
756
|
...(num(ev.maxRetries) ? { maxRetries: ev.maxRetries } : {}),
|
|
@@ -737,7 +790,7 @@ export function compactedEventData(ev) {
|
|
|
737
790
|
const files = ev.attachedFiles
|
|
738
791
|
.filter((f) => typeof f === "object" && f !== null && typeof f.path === "string"
|
|
739
792
|
&& num(f.chars) !== undefined && typeof f.truncated === "boolean")
|
|
740
|
-
.map((f) => ({ path:
|
|
793
|
+
.map((f) => ({ path: seatText("trace-frame-text", f.path), chars: f.chars, truncated: f.truncated }));
|
|
741
794
|
return files.length > 0 ? { attachedFiles: files } : {};
|
|
742
795
|
})(),
|
|
743
796
|
...(ev.modelFallback === true ? { modelFallback: true } : {}),
|
|
@@ -758,6 +811,7 @@ export function compactedEventData(ev) {
|
|
|
758
811
|
})(),
|
|
759
812
|
...(num(ev.durationMs) !== undefined ? { durationMs: num(ev.durationMs) } : {}),
|
|
760
813
|
...(phaseDurations !== undefined ? { phaseDurations } : {}),
|
|
814
|
+
...(typeof ev.pass === "string" ? { pass: ev.pass } : {}),
|
|
761
815
|
};
|
|
762
816
|
}
|
|
763
817
|
export function contextUsageEventData(ev) {
|
|
@@ -880,14 +934,7 @@ export function projectEvents(events, opts = {}) {
|
|
|
880
934
|
}
|
|
881
935
|
case "prompt_assembled":
|
|
882
936
|
firstTs ??= ev.ts;
|
|
883
|
-
blocks.push({
|
|
884
|
-
type: "prompt-assembled",
|
|
885
|
-
constitution: String(d.constitution ?? ""),
|
|
886
|
-
totalChars: Number(d.totalChars ?? 0),
|
|
887
|
-
blocks: d.blocks,
|
|
888
|
-
...(d.sections !== undefined ? { sections: d.sections } : {}),
|
|
889
|
-
...(d.tools !== undefined ? { tools: d.tools } : {}),
|
|
890
|
-
});
|
|
937
|
+
blocks.push({ ...d, type: "prompt-assembled" });
|
|
891
938
|
break;
|
|
892
939
|
case "turn_end":
|
|
893
940
|
flushTurn(ev.seq, ev.ts, toContractTokens(d.usage, d.usageMissing));
|
|
@@ -966,6 +1013,7 @@ function mapTraceEventInner(type, seq, data) {
|
|
|
966
1013
|
return { event: "error", data: { type: "error", errorCode: "WORKER_DOWN", message: redactErrorMessage(String(data.errorMessage ?? "run failed")) ?? "run failed" } };
|
|
967
1014
|
case "context_usage":
|
|
968
1015
|
case "compaction_outcome":
|
|
1016
|
+
case "compaction_started":
|
|
969
1017
|
case "wiring_manifest":
|
|
970
1018
|
case "human_input":
|
|
971
1019
|
case "tool_roster_delta":
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **投影处置表**:一个 core 类型在一张出口面上的样子,只由一张表回答。
|
|
3
|
+
*
|
|
4
|
+
* ## 一条规则
|
|
5
|
+
* 表对该类型的**每一个键**给四词之一,表外键 = tsc 红(`satisfies DispositionTable<T, …>`):
|
|
6
|
+
* · `"forward"` —— 原值出门(只配叶值:原语或原语列表);`{ forward: 读法 }` = 读法认得才出门(读不出 ⇒ 键缺席并计一次),值不改;
|
|
7
|
+
* · `"strip"` —— 本面不出现;
|
|
8
|
+
* · `{ redact: 入口 }` —— 原值经**点名的既有脱敏入口**出门(词就是那只导出的名字,本模块不另铸脱敏逻辑);
|
|
9
|
+
* · `{ nested: 子表 }` —— 成员级子表;对象逐成员、列表逐元素(列表必须写 `rows`:`"each"` = 每个元素,或一只**只做选取 / 排序**的函数
|
|
10
|
+
* —— 运行期按身份核它交回的元素都来自原列表,值仍逐个过子表,带不出表外值);`admit` = 整只对象的读法。
|
|
11
|
+
* 本仓**自铸**的键(core 没有的派生事实)以 `{ mint: (src, root) => 值 }` 写在表里它的出口位次上 —— 它不是处置词,类型上不许与 core 键同名。
|
|
12
|
+
* ⚠️ 铸键读到的是**原值**(要从原值算计数 / 时长 / 展示词):它只许回派生事实,不许把原值或其片段回出去 —— 这是表里唯一一处
|
|
13
|
+
* 表本身拦不住、要靠复审看的地方。
|
|
14
|
+
* 值形限制写在类型上(整只值形一起判,不按联合分配):叶值(联合每一臂都是原语 / 原语列表)才能 `forward`,文本才能 `redact`,
|
|
15
|
+
* `nested` 不收各臂键不同的联合(`keyof` 只给交集,某一臂独有的键会悄悄没有处置),core 写成 `unknown` / `any` 的值只能 `strip`;
|
|
16
|
+
* **一格只许一词** —— 类型上把其余词的键写成 `never`(展开也混不进第二个词),运行期再核一次,两词同在 ⇒ 响亮抛。
|
|
17
|
+
* 投影函数是表的解释器 {@link projectByTable};`core-keyset-guard.ts` 读表({@link TableCoreKeys})—— 门与投影只有一个写者。
|
|
18
|
+
*
|
|
19
|
+
* ## 三条读法(所有表同一条)
|
|
20
|
+
* · **缺席即缺席**:源值 `undefined` ⇒ 键缺席(不补 `[]` / `false` / 默认值);
|
|
21
|
+
* · **表序 = 出口序**:表字面量按出口顺序写,铸键按位插 ⇒ 输出的键序就是表的键序;
|
|
22
|
+
* · **在场却读不出 ⇒ 计一次并丢**(`dropProjectedFace`,F 类;缺席从不计数):读法拒、`redact` 位不是文本、嵌套位不是对象、
|
|
23
|
+
* 写了 `rows` 的位不是列表、列表元素不是对象 —— 那一格丢,其余照投,不抛、不 500。表里出现解释器不认识的词(只可能经运行期旁路造出)⇒ 响亮抛。
|
|
24
|
+
*
|
|
25
|
+
* ## 凭据
|
|
26
|
+
* `redact` 管「**可能含**凭据的文本」;「**本身是**凭据的值」(赎回令牌)写 `strip`。core 打了品牌的凭据型(`CheckpointToken`)上,
|
|
27
|
+
* 类型层写不出 `forward`。
|
|
28
|
+
*/
|
|
29
|
+
import type { CheckpointToken } from "@sema-agent/core";
|
|
30
|
+
/** `redact` 可点名的既有脱敏入口(闭集;一词 = 一只既有导出的名字,解释器原样调用)。 */
|
|
31
|
+
export type RedactEntry = "redactSecrets" | "redactErrorMessage";
|
|
32
|
+
/** 窄读:认得 ⇒ `true`(原值出门),认不得 ⇒ 键缺席并计一次。只判不改。 */
|
|
33
|
+
export type Admit = (raw: unknown) => boolean;
|
|
34
|
+
/** 列表位怎么带:`"each"` = 每个元素;函数 = 选取 / 排序(只许交回原列表里的元素 —— 运行期按身份核,交回别的就响亮抛)。 */
|
|
35
|
+
type RowsOf<E, R> = "each" | ((list: readonly E[], root: R) => readonly E[]);
|
|
36
|
+
/** 一格只许一词:对象形的处置把其余词的键写成 `never` —— 多余属性检查之外,经展开 / 赋值也写不进第二个词。 */
|
|
37
|
+
type DispositionKey = "forward" | "redact" | "nested" | "rows" | "admit" | "mint";
|
|
38
|
+
type Only<K extends DispositionKey, T> = T & {
|
|
39
|
+
readonly [P in Exclude<DispositionKey, K>]?: never;
|
|
40
|
+
};
|
|
41
|
+
/** 不透明值(core 型写成 `unknown` / `any`):本仓写不出它的成员表,也说不出它是不是文本 ⇒ 只能 `strip`。 */
|
|
42
|
+
type IsOpaque<V> = unknown extends V ? true : false;
|
|
43
|
+
/** 叶值:联合的**每一臂**都是原语,或元素每一臂都是原语的列表(不透明元素不算)。 */
|
|
44
|
+
type LeafMember<M> = M extends readonly (infer E)[] ? (unknown extends E ? false : [Extract<E, object>] extends [never] ? true : false) : M extends object ? false : true;
|
|
45
|
+
type IsLeaf<V> = false extends LeafMember<NonNullable<V>> ? false : true;
|
|
46
|
+
/** 联合的任一臂(或列表元素的任一臂)是 core 的品牌凭据。 */
|
|
47
|
+
type TokenMember<M> = M extends readonly (infer E)[] ? ([Extract<E, CheckpointToken>] extends [never] ? false : true) : [Extract<M, CheckpointToken>] extends [never] ? false : true;
|
|
48
|
+
type HoldsToken<V> = true extends TokenMember<NonNullable<V>> ? true : false;
|
|
49
|
+
/** 判别联合的各臂键并集;`nested` 只收「各臂键相同」的对象型 —— 否则 `keyof` 只给交集,只在某一臂上的键会悄悄没有处置。 */
|
|
50
|
+
type ArmKeys<E> = E extends unknown ? keyof E : never;
|
|
51
|
+
type NestedTarget<E> = [ArmKeys<E>] extends [keyof E] ? true : false;
|
|
52
|
+
/** 值形决定可写哪几个词:叶值才能 `forward`(对象 / 对象列表的成员必须逐个处置),文本才能 `redact`,对象 / 对象列表才能 `nested`
|
|
53
|
+
* (列表必须写 `rows`、对象不许写),品牌凭据写不出 `forward`,不透明值只能 `strip`。判断都**不按联合分配**:整只值形一起判。 */
|
|
54
|
+
type NestedOf<V, R> = [
|
|
55
|
+
NonNullable<V>
|
|
56
|
+
] extends [readonly (infer E)[]] ? [E] extends [object] ? NestedTarget<E> extends true ? Only<"nested" | "rows" | "admit", {
|
|
57
|
+
readonly nested: CoreTable<E, R>;
|
|
58
|
+
readonly rows: RowsOf<E, R>;
|
|
59
|
+
readonly admit?: Admit;
|
|
60
|
+
}> : never : never : [NonNullable<V>] extends [object] ? NestedTarget<NonNullable<V>> extends true ? Only<"nested" | "admit", {
|
|
61
|
+
readonly nested: CoreTable<NonNullable<V>, R>;
|
|
62
|
+
readonly admit?: Admit;
|
|
63
|
+
}> : never : never;
|
|
64
|
+
type ForwardOf<V> = IsLeaf<V> extends true ? (HoldsToken<V> extends true ? never : "forward" | Only<"forward", {
|
|
65
|
+
readonly forward: Admit;
|
|
66
|
+
}>) : never;
|
|
67
|
+
/** 一个 core 键在一张面上的处置(四词;`R` = 铸键能读到的根)。 */
|
|
68
|
+
export type Disposition<V, R> = IsOpaque<V> extends true ? "strip" : ForwardOf<V> | "strip" | (NonNullable<V> extends string ? Only<"redact", {
|
|
69
|
+
readonly redact: RedactEntry;
|
|
70
|
+
}> : never) | NestedOf<V, R>;
|
|
71
|
+
/** 本仓铸键:core 没有的派生事实,值 = `mint(源, 根)`,`undefined` ⇒ 缺席。 */
|
|
72
|
+
export type Mint<T, R> = Only<"mint", {
|
|
73
|
+
readonly mint: (src: T, root: R) => unknown;
|
|
74
|
+
}>;
|
|
75
|
+
/** `T` 的全量处置(每个键恰一词;可选键也必须写)。 */
|
|
76
|
+
export type CoreTable<T, R> = {
|
|
77
|
+
readonly [K in keyof T]-?: Disposition<T[K], R>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* 一张处置表的类型:`T` 的全量处置 + 名为 `M` 的铸键。`M` 与 `keyof T` 相交 ⇒ 整张表型变成错误标记(两个写者抢一个键)。
|
|
81
|
+
* 用法:`export const X_DISPOSITIONS = { … } as const satisfies DispositionTable<T, R, "铸键A" | "铸键B">`。
|
|
82
|
+
*/
|
|
83
|
+
export type DispositionTable<T, R = T, M extends string = never> = [Extract<M, keyof T>] extends [never] ? CoreTable<T, R> & {
|
|
84
|
+
readonly [K in M]: Mint<T, R>;
|
|
85
|
+
} : {
|
|
86
|
+
readonly __mintCollidesWithCoreKey: Extract<M, keyof T>;
|
|
87
|
+
};
|
|
88
|
+
/** 表里处置 core 键的那些键(铸键除外)—— `core-keyset-guard.ts` 读这个。 */
|
|
89
|
+
export type TableCoreKeys<Tbl> = {
|
|
90
|
+
[K in keyof Tbl]-?: Tbl[K] extends {
|
|
91
|
+
readonly mint: unknown;
|
|
92
|
+
} ? never : K;
|
|
93
|
+
}[keyof Tbl];
|
|
94
|
+
/**
|
|
95
|
+
* 按表投影一个值。`face` = 计数 / 报错里的面名(`<面>.<键路径>`);`root` = 铸键与 `rows` 读到的根(面的顶层值)。
|
|
96
|
+
* 纯数据进、纯数据出;不改入参。
|
|
97
|
+
*/
|
|
98
|
+
export declare function projectByTable<T extends object, R>(face: string, table: CoreTable<T, R>, value: T, root: R): Record<string, unknown>;
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=projection-table.d.ts.map
|