@sema-agent/server 7.132.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 +266 -0
- package/README.md +8 -9
- package/README.zh-CN.md +7 -6
- package/USAGE.md +174 -55
- 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 +79 -19
- package/dist/approval-card.js +44 -13
- 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 +27 -10
- package/dist/audit.js +12 -16
- package/dist/bake-runner/main.js +3 -2
- 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.js +2 -0
- 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/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.js +1 -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 +2 -0
- package/dist/boot/stage-06-runners.js +6 -3
- package/dist/boot/stage-07-capability-layer.d.ts +2 -0
- package/dist/boot/stage-07-capability-layer.js +24 -3
- package/dist/boot/stage-08-reapers.d.ts +2 -0
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +3 -0
- package/dist/boot/stage-10-http-server.d.ts +3 -0
- package/dist/boot/stage-10-http-server.js +5 -6
- package/dist/boot/stores.js +2 -2
- package/dist/boot/web-admin.d.ts +4 -0
- package/dist/boot/web-admin.js +151 -63
- 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/caller-text-echo.d.ts +9 -6
- package/dist/caller-text-echo.js +8 -11
- 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 +27 -4
- package/dist/capabilities/scenarios.d.ts +63 -7
- package/dist/capabilities/scenarios.js +39 -7
- 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 +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 +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 +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 +103 -60
- package/dist/http/approval-sweeps.js +55 -18
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +16 -16
- package/dist/http/checkpoint-ctx.js +13 -10
- 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 +10 -4
- package/dist/http/durable-run-leg.d.ts +4 -32
- package/dist/http/durable-run-leg.js +34 -10
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +48 -23
- package/dist/http/principal-gate.js +39 -12
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/request-guards.d.ts +16 -23
- package/dist/http/request-guards.js +30 -15
- 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 +3 -4
- package/dist/http/resume-legs.js +126 -69
- 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 +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.js +5 -1
- 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 +33 -106
- package/dist/http/routes/session-sync.js +15 -28
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/side-query.js +6 -4
- package/dist/http/routes/tasks.js +50 -14
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +24 -3
- package/dist/http/send.js +14 -2
- package/dist/http/server.d.ts +17 -18
- package/dist/http/server.js +15 -13
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.js +4 -3
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +10 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -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/limit-refusal.d.ts +17 -5
- package/dist/limit-refusal.js +4 -1
- package/dist/mcp-assertion-header.d.ts +31 -10
- package/dist/mcp-assertion-header.js +10 -3
- package/dist/mcp-tool-faces.js +1 -3
- 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-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 +3 -17
- package/dist/observability/prompt-manifest.js +45 -42
- package/dist/observability/tool-trace.js +9 -9
- 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/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- 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 +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 +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +14 -0
- package/dist/plugins/checkpoint-store-sql.js +20 -2
- 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 +2 -0
- package/dist/plugins/local-checkpoint-store.js +6 -1
- package/dist/plugins/local-session-store.d.ts +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 +110 -5
- package/dist/plugins/one-time-migrations.js +320 -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/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +17 -4
- package/dist/plugins/pg-session-storage.js +29 -6
- package/dist/plugins/remote-env-adb.d.ts +6 -12
- package/dist/plugins/remote-env-adb.js +12 -2
- 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-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 +24 -4
- package/dist/plugins/tidb-session-store.js +28 -4
- 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-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 +36 -6
- package/dist/runs.d.ts +10 -9
- package/dist/runs.js +21 -3
- 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/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- 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-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +7 -66
- package/dist/task-settings.d.ts +89 -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 +303 -87
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +104 -22
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +3 -2
- package/dist/trace/project.d.ts +80 -12
- package/dist/trace/project.js +41 -28
- 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 +298 -2
- package/dist/trace/wire-projection-faces.js +154 -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.js +4 -5
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
- package/package.json +7 -3
|
@@ -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">>>;
|
|
@@ -149,10 +153,62 @@ type _GuardPermissionTraceNonEmpty = AssertAllKeysHandled<AssertNonEmpty<Permiss
|
|
|
149
153
|
type PromptAssembledFrame = Extract<TraceEvent, {
|
|
150
154
|
kind: "prompt.assembled";
|
|
151
155
|
}>;
|
|
152
|
-
type
|
|
153
|
-
type
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
type ManifestFaces = typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES;
|
|
157
|
+
type ManifestDeclared<F, N extends keyof F> = F[N] extends {
|
|
158
|
+
readonly keys: infer K;
|
|
159
|
+
} ? keyof K : never;
|
|
160
|
+
type ManifestDeclaredOptional<F, N extends keyof F> = F[N] extends {
|
|
161
|
+
readonly keys: infer K;
|
|
162
|
+
} ? {
|
|
163
|
+
[P in keyof K]: K[P] extends {
|
|
164
|
+
readonly optional: true;
|
|
165
|
+
} ? P : never;
|
|
166
|
+
}[keyof K] : never;
|
|
167
|
+
type ManifestNotOnRow<F, N extends keyof F> = F[N] extends {
|
|
168
|
+
readonly excluded: readonly (infer E)[];
|
|
169
|
+
} ? E : never;
|
|
170
|
+
/** 引擎型上带 `?` 的键。 */
|
|
171
|
+
type OptionalKeysOf<T> = {
|
|
172
|
+
[P in keyof T]-?: {} extends Pick<T, P> ? P : never;
|
|
173
|
+
}[keyof T];
|
|
174
|
+
/**
|
|
175
|
+
* 一层的正向残余:引擎型有、声明里没有也没登记不上行的键;以及可选性不对的键 —— 非行层:声明为可选的键 ≠ 引擎型上带 `?` 的键;
|
|
176
|
+
* 行层:声明里每个键都得是可选(行的成员一律可缺席;少写一个 `optional`,解释器会把「引擎没发这个成员」读成读不出并计一次丢弃)。
|
|
177
|
+
* 全收敛到 `never` 才过。`Row` = 这一层是不是行。
|
|
178
|
+
*/
|
|
179
|
+
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>>);
|
|
180
|
+
/** 一层的反向残余:声明过或登记为不上行、而引擎型里已经没有的键(引擎退役它而簿里留着残条目)。 */
|
|
181
|
+
type ManifestLevelReverse<F, N extends keyof F, Core> = Exclude<ManifestDeclared<F, N> | ManifestNotOnRow<F, N>, keyof Core>;
|
|
182
|
+
/** 十二层的引擎型(层名 = 登记表里的面名)。 */
|
|
183
|
+
type ManifestCore = {
|
|
184
|
+
prompt_manifest: PromptAssembledFrame;
|
|
185
|
+
prompt_manifest_identity: PromptManifestIdentity;
|
|
186
|
+
prompt_manifest_identity_layers: PromptIdentityLayers;
|
|
187
|
+
prompt_manifest_selectors: PromptManifestSelectors;
|
|
188
|
+
prompt_manifest_selectors_host: PromptManifestSelectors["host"];
|
|
189
|
+
prompt_manifest_block: PromptAssembledFrame["blocks"][number];
|
|
190
|
+
prompt_manifest_section: PromptManifestSection;
|
|
191
|
+
prompt_manifest_section_renderer: NonNullable<PromptManifestSection["renderer"]>;
|
|
192
|
+
prompt_manifest_chain_link: PromptChainLink;
|
|
193
|
+
prompt_manifest_superseded: SupersededOverlay;
|
|
194
|
+
prompt_manifest_tool: NonNullable<PromptAssembledFrame["tools"]>[number];
|
|
195
|
+
prompt_manifest_tool_disclosure: ToolDisclosureManifest;
|
|
196
|
+
};
|
|
197
|
+
/** 残余非空的层,按 `<层>.<残余键>` 点名(tsc 的报错里直接看见是哪一层的哪一个键)。 */
|
|
198
|
+
/** 十二层的残余汇总:每层的正向残余(见 {@link ManifestLevelForward})按 `<层>.<残余键>` 点名;`F` = 登记表的形。全收敛到 `never` 才过。 */
|
|
199
|
+
type ManifestForwardResidue<F extends Record<keyof ManifestCore, unknown>> = {
|
|
200
|
+
[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}`;
|
|
201
|
+
}[keyof ManifestCore];
|
|
202
|
+
type _GuardPromptManifestKeys = AssertAllKeysHandled<ManifestForwardResidue<ManifestFaces>>;
|
|
203
|
+
type _GuardPromptManifestKeysReverse = AssertAllKeysHandled<{
|
|
204
|
+
[L in keyof ManifestCore]: [ManifestLevelReverse<ManifestFaces, L, ManifestCore[L]>] extends [never] ? never : `${L}.${ManifestLevelReverse<ManifestFaces, L, ManifestCore[L]> & string}`;
|
|
205
|
+
}[keyof ManifestCore]>;
|
|
206
|
+
/** 非空 —— 十二层的声明都在(层名拼错 / 声明被整行删掉 ⇒ `ManifestDeclared` 坍成 `never`,上面的反向钉恒绿,这一条补上)。 */
|
|
207
|
+
type _GuardPromptManifestKeysNonEmpty = AssertAllKeysHandled<{
|
|
208
|
+
[L in keyof ManifestCore]: [ManifestDeclared<ManifestFaces, L>] extends [never] ? L : never;
|
|
209
|
+
}[keyof ManifestCore]>;
|
|
210
|
+
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "mandated" | "mandate" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "boundGrantAbsence" | "checkpointId";
|
|
211
|
+
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy";
|
|
156
212
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
157
213
|
type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected | SummaryExcluded, keyof CheckpointSummary>>;
|
|
158
214
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
@@ -163,9 +219,9 @@ type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCal
|
|
|
163
219
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
164
220
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
165
221
|
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";
|
|
222
|
+
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
223
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
168
|
-
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "
|
|
224
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm";
|
|
169
225
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
170
226
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
171
227
|
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 +266,25 @@ type _GuardSettlementReverse = AssertAllKeysHandled<Exclude<SettlementProjected,
|
|
|
210
266
|
type SettlementWhoProjected = "party" | "approver" | "window";
|
|
211
267
|
type _GuardSettlementWho = AssertAllKeysHandled<Exclude<SettlementWhoKeys, SettlementWhoProjected>>;
|
|
212
268
|
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
|
|
269
|
+
type WorkflowTables = typeof import("../http/routes/workflows.js");
|
|
270
|
+
type _GuardWorkflowRun = AssertAllKeysHandled<Exclude<keyof WorkflowRun, TableCoreKeys<WorkflowTables["WORKFLOW_RUN_DISPOSITIONS"]>>>;
|
|
271
|
+
type _GuardWorkflowRunReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_DISPOSITIONS"]>, keyof WorkflowRun>>;
|
|
272
|
+
type _GuardWorkflowParkRow = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["parks"]>[number], TableCoreKeys<WorkflowTables["WORKFLOW_PARK_ROW_DISPOSITIONS"]>>>;
|
|
273
|
+
type _GuardWorkflowParkRowReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_PARK_ROW_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["parks"]>[number]>>;
|
|
274
|
+
type _GuardWorkflowPhase = AssertAllKeysHandled<Exclude<keyof WorkflowRun["phases"][number], TableCoreKeys<WorkflowTables["WORKFLOW_PHASE_DISPOSITIONS"]>>>;
|
|
275
|
+
type _GuardWorkflowPhaseReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_PHASE_DISPOSITIONS"]>, keyof WorkflowRun["phases"][number]>>;
|
|
276
|
+
type _GuardWorkflowAgent = AssertAllKeysHandled<Exclude<keyof WorkflowRun["agents"][number], TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_DISPOSITIONS"]>>>;
|
|
277
|
+
type _GuardWorkflowAgentReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_DISPOSITIONS"]>, keyof WorkflowRun["agents"][number]>>;
|
|
278
|
+
type _GuardWorkflowAgentActivity = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["agents"][number]["activity"]>[number], TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS"]>>>;
|
|
279
|
+
type _GuardWorkflowAgentActivityReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["agents"][number]["activity"]>[number]>>;
|
|
280
|
+
type _GuardWorkflowAgentPendingApproval = AssertAllKeysHandled<Exclude<keyof NonNullable<WorkflowRun["agents"][number]["pendingApproval"]>, TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS"]>>>;
|
|
281
|
+
type _GuardWorkflowAgentPendingApprovalReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS"]>, keyof NonNullable<WorkflowRun["agents"][number]["pendingApproval"]>>>;
|
|
282
|
+
type _GuardWorkflowGroup = AssertAllKeysHandled<Exclude<keyof WorkflowRun["groups"][number], TableCoreKeys<WorkflowTables["WORKFLOW_GROUP_DISPOSITIONS"]>>>;
|
|
283
|
+
type _GuardWorkflowGroupReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_GROUP_DISPOSITIONS"]>, keyof WorkflowRun["groups"][number]>>;
|
|
284
|
+
type _GuardWorkflowRunStats = AssertAllKeysHandled<Exclude<keyof WorkflowRun["stats"], TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_DISPOSITIONS"]>>>;
|
|
285
|
+
type _GuardWorkflowRunStatsReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_DISPOSITIONS"]>, keyof WorkflowRun["stats"]>>;
|
|
286
|
+
type _GuardWorkflowRunStatsNested = AssertAllKeysHandled<Exclude<keyof WorkflowRun["stats"]["nested"], TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS"]>>>;
|
|
287
|
+
type _GuardWorkflowRunStatsNestedReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<WorkflowTables["WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS"]>, keyof WorkflowRun["stats"]["nested"]>>;
|
|
223
288
|
type ReadRootCandidateProjected = "dir" | "clearsThisAsk" | "covers";
|
|
224
289
|
type _GuardReadRootCandidate = AssertAllKeysHandled<Exclude<keyof ReadRootGrantCandidate, ReadRootCandidateProjected>>;
|
|
225
290
|
type _GuardReadRootCandidateReverse = AssertAllKeysHandled<Exclude<ReadRootCandidateProjected, keyof ReadRootGrantCandidate>>;
|
|
@@ -321,11 +386,15 @@ export type CoreKeysetGuards = [
|
|
|
321
386
|
_GuardWiringModelGateReverse,
|
|
322
387
|
_GuardWiringAutoMode,
|
|
323
388
|
_GuardWiringAutoModeReverse,
|
|
389
|
+
_GuardWiringPermissionMode,
|
|
390
|
+
_GuardWiringPermissionModeReverse,
|
|
324
391
|
_GuardWiringGovernance,
|
|
325
392
|
_GuardWiringGovernanceReverse,
|
|
326
393
|
_GuardPermissionTrace,
|
|
327
394
|
_GuardPermissionTraceReverse,
|
|
328
|
-
|
|
395
|
+
_GuardPromptManifestKeys,
|
|
396
|
+
_GuardPromptManifestKeysReverse,
|
|
397
|
+
_GuardPromptManifestKeysNonEmpty,
|
|
329
398
|
_GuardPermissionTraceNonEmpty,
|
|
330
399
|
_GuardInboxSummary,
|
|
331
400
|
_GuardInboxSummaryReverse,
|
|
@@ -352,9 +421,22 @@ export type CoreKeysetGuards = [
|
|
|
352
421
|
_GuardSettlementWhoReverse,
|
|
353
422
|
_GuardWorkflowRun,
|
|
354
423
|
_GuardWorkflowRunReverse,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
424
|
+
_GuardWorkflowParkRow,
|
|
425
|
+
_GuardWorkflowParkRowReverse,
|
|
426
|
+
_GuardWorkflowPhase,
|
|
427
|
+
_GuardWorkflowPhaseReverse,
|
|
428
|
+
_GuardWorkflowAgent,
|
|
429
|
+
_GuardWorkflowAgentReverse,
|
|
430
|
+
_GuardWorkflowAgentActivity,
|
|
431
|
+
_GuardWorkflowAgentActivityReverse,
|
|
432
|
+
_GuardWorkflowAgentPendingApproval,
|
|
433
|
+
_GuardWorkflowAgentPendingApprovalReverse,
|
|
434
|
+
_GuardWorkflowGroup,
|
|
435
|
+
_GuardWorkflowGroupReverse,
|
|
436
|
+
_GuardWorkflowRunStats,
|
|
437
|
+
_GuardWorkflowRunStatsReverse,
|
|
438
|
+
_GuardWorkflowRunStatsNested,
|
|
439
|
+
_GuardWorkflowRunStatsNestedReverse,
|
|
358
440
|
_GuardReadRootCandidate,
|
|
359
441
|
_GuardReadRootCandidateReverse,
|
|
360
442
|
_GuardRiskAxes,
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
*/
|
|
12
|
+
declare const EXIT_SEATS: {
|
|
13
|
+
readonly "trace-frame-text": {
|
|
14
|
+
readonly scope: "free-text";
|
|
15
|
+
};
|
|
16
|
+
readonly "trace-frame-line": {
|
|
17
|
+
readonly scope: "free-text";
|
|
18
|
+
readonly maxChars: 300;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
22
|
+
/**
|
|
23
|
+
* 出口座:`seat` 是座表的一行,`text` 是要出门的自由文本。返回的 {@link SafeText} 就是这个出口该写出去的字节。
|
|
24
|
+
* 表外的座名(只有绕过类型才到得了)⇒ 抛 —— 那是调用方的编程错,不是脱敏失败,不吞成占位。
|
|
25
|
+
*/
|
|
26
|
+
export declare function seatText(seat: ExitSeat, text: string): SafeText;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=exit-seat.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { errorKindOf } from "../observability/err-text.js";
|
|
2
|
+
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
|
+
import { OVERSIZED_REDACTION_PLACEHOLDER } from "../observability/run-terminal.js";
|
|
4
|
+
import { proposeRedactionSpans, REDACTION_TOKEN_RE_SRC } from "./redact.js";
|
|
5
|
+
const EXIT_SEATS = {
|
|
6
|
+
"trace-frame-text": { scope: "free-text" },
|
|
7
|
+
"trace-frame-line": { scope: "free-text", maxChars: 300 },
|
|
8
|
+
};
|
|
9
|
+
const SEAT_ROWS = new Map(Object.entries(EXIT_SEATS));
|
|
10
|
+
for (const [name, row] of SEAT_ROWS) {
|
|
11
|
+
if (row.maxChars !== undefined && row.maxChars < OVERSIZED_REDACTION_PLACEHOLDER.length) {
|
|
12
|
+
throw new Error(`exit seat "${name}": maxChars ${row.maxChars} cannot hold the failure placeholder (${OVERSIZED_REDACTION_PLACEHOLDER.length} code units)`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function mergeSpans(spans) {
|
|
16
|
+
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);
|
|
17
|
+
const out = [];
|
|
18
|
+
for (const { s } of order) {
|
|
19
|
+
const last = out[out.length - 1];
|
|
20
|
+
if (last === undefined || s.start > last.end)
|
|
21
|
+
out.push(s);
|
|
22
|
+
else if (s.end > last.end)
|
|
23
|
+
out[out.length - 1] = { start: last.start, end: s.end, repl: last.repl };
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
const TOKEN_AT = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
|
|
28
|
+
function cutPlain(gap, room) {
|
|
29
|
+
let cut = room;
|
|
30
|
+
const hi = gap.charCodeAt(cut - 1);
|
|
31
|
+
if (cut > 0 && hi >= 0xd800 && hi <= 0xdbff && (gap.charCodeAt(cut) & 0xfc00) === 0xdc00)
|
|
32
|
+
cut -= 1;
|
|
33
|
+
const open = cut > 0 ? gap.lastIndexOf("«", cut - 1) : -1;
|
|
34
|
+
if (open !== -1) {
|
|
35
|
+
TOKEN_AT.lastIndex = open;
|
|
36
|
+
const m = TOKEN_AT.exec(gap);
|
|
37
|
+
if (m !== null && open + m[0].length > cut)
|
|
38
|
+
cut = open;
|
|
39
|
+
}
|
|
40
|
+
return gap.slice(0, cut);
|
|
41
|
+
}
|
|
42
|
+
function renderOnce(text, groups, maxChars) {
|
|
43
|
+
const parts = [];
|
|
44
|
+
let len = 0;
|
|
45
|
+
let at = 0;
|
|
46
|
+
for (const g of groups) {
|
|
47
|
+
const gap = text.slice(at, g.start);
|
|
48
|
+
if (maxChars !== undefined && len + gap.length > maxChars)
|
|
49
|
+
return parts.join("") + cutPlain(gap, maxChars - len);
|
|
50
|
+
parts.push(gap);
|
|
51
|
+
len += gap.length;
|
|
52
|
+
if (maxChars !== undefined && len + g.repl.length > maxChars)
|
|
53
|
+
return parts.join("");
|
|
54
|
+
parts.push(g.repl);
|
|
55
|
+
len += g.repl.length;
|
|
56
|
+
at = g.end;
|
|
57
|
+
}
|
|
58
|
+
const tail = text.slice(at);
|
|
59
|
+
parts.push(maxChars === undefined || len + tail.length <= maxChars ? tail : cutPlain(tail, maxChars - len));
|
|
60
|
+
return parts.join("");
|
|
61
|
+
}
|
|
62
|
+
export function seatText(seat, text) {
|
|
63
|
+
const row = SEAT_ROWS.get(seat);
|
|
64
|
+
if (row === undefined)
|
|
65
|
+
throw new Error(`exit seat: ${JSON.stringify(seat)} is not a row of the seat table`);
|
|
66
|
+
let out;
|
|
67
|
+
try {
|
|
68
|
+
out = renderOnce(text, mergeSpans(proposeRedactionSpans(text, row.scope)), row.maxChars);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
recordFailOpen("server.run-terminal.redact-threw", `seat=${seat} len=${typeof text === "string" ? text.length : -1} err=${errorKindOf(err)}`);
|
|
72
|
+
out = OVERSIZED_REDACTION_PLACEHOLDER;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=exit-seat.js.map
|
|
@@ -55,8 +55,9 @@ export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" |
|
|
|
55
55
|
| "suspended" | "needs_review" | "done" | "failed" | "suggestions" | "model_usage" | "prompt_assembled" | "config_assembled" | "file_link"
|
|
56
56
|
/** 人在环三族的 open/close 帧对(投递面 = 本腿的 durable events tail)。 */
|
|
57
57
|
| "elicitation" | "elicitation_complete" | "question" | "question_complete" | "tool_approval" | "tool_approval_complete"
|
|
58
|
-
/** [ref] §4.3
|
|
59
|
-
|
|
58
|
+
/** [ref] §4.3 呈卡族的开卡帧与单卡消卡帧(与上面两只 tool_approval 帧同一条投递面;一条腿只发其中一族,
|
|
59
|
+
* bg / resume 两条 durable 腿恒是呈卡腿 ⇒ 它们的账本自 7.133.0 起只有本族)。 */
|
|
60
|
+
| "approval_request" | "approval_complete"
|
|
60
61
|
/**
|
|
61
62
|
* [ref]([ref]):批级撤卡帧在 **bg/resume 两条 durable 腿**的账本落行(与呈卡帧同口
|
|
62
63
|
* `append(type, rest)`,seq 由腿自己的 ledger 链步分配)。此前成文「reaper/收敛器无 seq 可分配故
|
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";
|
|
@@ -373,7 +381,11 @@ export declare function taskProgressEventData(ev: {
|
|
|
373
381
|
workflowAgentLabel?: string;
|
|
374
382
|
seq?: number;
|
|
375
383
|
model?: string;
|
|
376
|
-
}):
|
|
384
|
+
}): FrameData<{
|
|
385
|
+
name?: SafeText;
|
|
386
|
+
currentAction?: SafeText;
|
|
387
|
+
workflowAgentLabel?: SafeText;
|
|
388
|
+
}>;
|
|
377
389
|
/**
|
|
378
390
|
* The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
|
|
379
391
|
* 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
|
|
@@ -414,7 +426,10 @@ export declare function taskStartedEventData(ev: {
|
|
|
414
426
|
startedAt: number;
|
|
415
427
|
eventId?: string;
|
|
416
428
|
parentToolCallId?: string;
|
|
417
|
-
}):
|
|
429
|
+
}): FrameData<{
|
|
430
|
+
name?: SafeText;
|
|
431
|
+
workflowAgentLabel?: SafeText;
|
|
432
|
+
}>;
|
|
418
433
|
/** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
|
|
419
434
|
* LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
|
|
420
435
|
* attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
|
|
@@ -492,7 +507,28 @@ export declare function taskNotificationEventData(ev: {
|
|
|
492
507
|
* **事件顶层**键,不是 {@link TaskNotificationPayload} 的键,所以只有把整只 core 事件交给本投影的腿
|
|
493
508
|
* 拿得到它;只拿到载荷的 park-drain 腿结构上没有这一位。 */
|
|
494
509
|
priority?: SystemInjectionPriority;
|
|
495
|
-
}):
|
|
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
|
+
}>;
|
|
496
532
|
/** The `compacted` payload — EXPLICIT WHITELIST shared by all three legs (bg runs.ts + resume append + the sync
|
|
497
533
|
* live SSE frame; the 1.72 task_progress lesson: never `{...ev}`). trigger/tokensBefore (MF-18) verbatim;
|
|
498
534
|
* `preserved_segment.firstKeptEntryId` verbatim (a core-mint entryId, the shell's compaction-divider anchor);
|
|
@@ -519,7 +555,16 @@ export declare function diagnosticsEventData(ev: {
|
|
|
519
555
|
isNew: boolean;
|
|
520
556
|
eventId?: string;
|
|
521
557
|
parentToolCallId?: string;
|
|
522
|
-
}):
|
|
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
|
+
}>;
|
|
523
568
|
/** The `steering_injected` payload([ref]/[ref] 裁定透传;core `TaskEvent` 联合臂 `type: "steering_injected"`,
|
|
524
569
|
* shell 渲染源 = CC 的系统提醒条:core 在 turn 之间给模型注入一条系统提示[todo 提醒/文件变化/日期跨天/
|
|
525
570
|
* 技能列表变化…]时随手抛的展示投影,一附件一帧)。EXPLICIT WHITELIST(source=封闭枚举 verbatim;
|
|
@@ -530,7 +575,9 @@ export declare function steeringInjectedEventData(ev: {
|
|
|
530
575
|
preview: string;
|
|
531
576
|
eventId?: string;
|
|
532
577
|
parentToolCallId?: string;
|
|
533
|
-
}):
|
|
578
|
+
}): FrameData<{
|
|
579
|
+
preview: SafeText;
|
|
580
|
+
}>;
|
|
534
581
|
/** `compaction_outcome`(core 2.5.0 [ref]②:压缩非 compacted 结局——manual /compact 的 mooted/failed
|
|
535
582
|
* 两条真路)。[ref]A-2/C-2:此前它是**唯一**不走共享 builder、只在 live 腿 res.write 内联挑键的
|
|
536
583
|
* 内容帧 ⇒ 两条 durable 腿零 case、回放即消失、三方普查各自失明。收进共享白名单 builder,三腿同源。
|
|
@@ -542,7 +589,9 @@ export declare function compactionOutcomeEventData(ev: {
|
|
|
542
589
|
pass?: unknown;
|
|
543
590
|
eventId?: unknown;
|
|
544
591
|
parentToolCallId?: unknown;
|
|
545
|
-
}):
|
|
592
|
+
}): FrameData<{
|
|
593
|
+
reason?: SafeText;
|
|
594
|
+
}>;
|
|
546
595
|
/**
|
|
547
596
|
* `compaction_started`(S-1732,core 7.53.0 #2008)—— 一次压缩 pass 在提交点(触发闸过了、切点在、`preCompact` 没拦)宣告开始,先于摘要调用:
|
|
548
597
|
* 一次在供应方重试表里等很久的摘要(core 实测 503 × 11、173 s)从此在流上不是静默的。**原样投影**:`{ trigger, pass, startedAt }` + 身份两键,
|
|
@@ -567,7 +616,9 @@ export declare function workspaceChangedEventData(ev: {
|
|
|
567
616
|
cwd: string;
|
|
568
617
|
eventId?: string;
|
|
569
618
|
parentToolCallId?: string;
|
|
570
|
-
}):
|
|
619
|
+
}): FrameData<{
|
|
620
|
+
cwd: SafeText;
|
|
621
|
+
}>;
|
|
571
622
|
/**
|
|
572
623
|
* `wiring_manifest`(core 5.14.0 [ref] 新 `TaskEvent` 臂)—— 每条腿(root/child/resume)在 prepare
|
|
573
624
|
* 时自证「我到底接了什么线」的清单帧。
|
|
@@ -802,8 +853,8 @@ export declare function wiringManifestEventData(ev: {
|
|
|
802
853
|
* 代价是 operator 看不到历史腿的 governance 段 —— 治理四布尔是部署形事实(不随 leg 漂),静态自检面
|
|
803
854
|
* (`GET /v1/diagnostics/wiring`)随时给出当前真值。
|
|
804
855
|
*
|
|
805
|
-
* 准入判据是 `explicitOperatorOk`(
|
|
806
|
-
*
|
|
856
|
+
* 准入判据是 `explicitOperatorOk`(「谁是 operator」的唯一读法):空 `OPERATOR_PRINCIPALS` 是「没有人是 operator」,不是「所有人都是」——
|
|
857
|
+
* 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。单用户形显式声明 `OPERATOR_SINGLE_USER=true` 时它的每个调用方都是。
|
|
807
858
|
*
|
|
808
859
|
* `configFingerprint` 只在本构造器里透传:它是 `sha256(canonicalize(manifest 去 leg/去两个 provenance))`
|
|
809
860
|
* 前 16 hex,**无盐**且输入含整个 governance 段,而 governance 只有 4 个布尔 ⇒ 16 种组合。租户手里已有其余
|
|
@@ -885,7 +936,16 @@ export declare function humanInputEventData(ev: {
|
|
|
885
936
|
attachments?: unknown;
|
|
886
937
|
eventId?: unknown;
|
|
887
938
|
parentToolCallId?: unknown;
|
|
888
|
-
}):
|
|
939
|
+
}): FrameData<{
|
|
940
|
+
issuer?: SafeText;
|
|
941
|
+
actor?: FrameData<{
|
|
942
|
+
id?: SafeText;
|
|
943
|
+
issuer?: SafeText;
|
|
944
|
+
}>;
|
|
945
|
+
attachments?: Array<FrameData<{
|
|
946
|
+
label?: SafeText;
|
|
947
|
+
}>>;
|
|
948
|
+
}>;
|
|
889
949
|
/** S4 (SILENT-FALLBACK P0-a): the durable `brain_status` observation row, shared by the bg + resume append
|
|
890
950
|
* sites. core marks the live `status` frame EPHEMERAL (never replayed by core on resume) — this row is the
|
|
891
951
|
* SERVICE's own observation record (why a turn stalled: rate_limited/retrying/reconnecting/circuit_open, and
|
|
@@ -907,7 +967,9 @@ export declare function brainStatusEventData(ev: {
|
|
|
907
967
|
providerConditionSource?: string;
|
|
908
968
|
eventId?: string;
|
|
909
969
|
parentToolCallId?: string;
|
|
910
|
-
}):
|
|
970
|
+
}): FrameData<{
|
|
971
|
+
detail?: SafeText;
|
|
972
|
+
}>;
|
|
911
973
|
export declare function compactedEventData(ev: {
|
|
912
974
|
eventId?: string;
|
|
913
975
|
parentToolCallId?: string;
|
|
@@ -945,7 +1007,13 @@ export declare function compactedEventData(ev: {
|
|
|
945
1007
|
};
|
|
946
1008
|
/** S-1732(core 7.53.0 #2008):这次落地的压缩 pass 的 id —— 与它的 `compaction_started` 帧同一个值(引擎在每次落地上都设;型上可选)。逐字。 */
|
|
947
1009
|
pass?: string;
|
|
948
|
-
}):
|
|
1010
|
+
}): FrameData<{
|
|
1011
|
+
attachedFiles?: Array<{
|
|
1012
|
+
path: SafeText;
|
|
1013
|
+
chars: number;
|
|
1014
|
+
truncated: boolean;
|
|
1015
|
+
}>;
|
|
1016
|
+
}>;
|
|
949
1017
|
export interface TraceTurn {
|
|
950
1018
|
/** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
|
|
951
1019
|
seq: number;
|