@sema-agent/server 7.134.0 → 7.135.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 +134 -0
- package/USAGE.md +98 -30
- package/dist/adoption/plan.d.ts +1 -1
- package/dist/approval-ask-audit-store.d.ts +24 -24
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +62 -150
- package/dist/approval-card.js +33 -51
- package/dist/approval-content-kind.d.ts +22 -5
- package/dist/approval-content-kind.js +8 -1
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +22 -3
- package/dist/approval-gate-currency.js +44 -18
- package/dist/approval-hmac.d.ts +7 -7
- package/dist/approval-policy-settlement.d.ts +2 -2
- package/dist/approval-reconciler.d.ts +3 -3
- package/dist/approval.d.ts +8 -8
- package/dist/approval.js +4 -2
- package/dist/auth-bridge.d.ts +1 -1
- package/dist/auto-mode-face.d.ts +4 -4
- package/dist/background-session-reap.d.ts +2 -2
- package/dist/bake-runner/main.d.ts +2 -2
- package/dist/bake-runner/runner.d.ts +4 -4
- package/dist/bench/s1/live-deps.d.ts +1 -1
- package/dist/bench/s1/run-firm.d.ts +1 -1
- package/dist/boot/coordinators.d.ts +2 -2
- package/dist/boot/coordinators.js +2 -2
- package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
- package/dist/boot/deferred-sandbox-path-env.js +0 -5
- package/dist/boot/engine-lease.d.ts +5 -5
- package/dist/boot/execution-env.d.ts +16 -15
- package/dist/boot/execution-env.js +19 -21
- package/dist/boot/fatal-exit.d.ts +2 -2
- package/dist/boot/late-binds.d.ts +1 -1
- package/dist/boot/leader.d.ts +1 -1
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +15 -15
- package/dist/boot/parked-revive-gate.d.ts +3 -3
- package/dist/boot/parked-revive-gate.js +3 -2
- package/dist/boot/reapers.d.ts +4 -4
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +28 -24
- package/dist/boot/runner-deps.d.ts +11 -11
- package/dist/boot/runner-deps.js +3 -2
- package/dist/boot/session-faces.d.ts +3 -3
- package/dist/boot/session-faces.js +11 -30
- package/dist/boot/shutdown.d.ts +5 -5
- package/dist/boot/side-query-lane.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.js +4 -4
- package/dist/boot/stage-06-runners.js +0 -2
- package/dist/boot/stores.js +2 -1
- package/dist/boot/web-admin.d.ts +17 -17
- package/dist/boot/web-admin.js +5 -10
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/budget.d.ts +4 -4
- package/dist/capabilities/approvals-push.d.ts +4 -4
- package/dist/capabilities/builtin-tools.d.ts +5 -5
- package/dist/capabilities/center-plugins.d.ts +5 -5
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +1 -1
- package/dist/capabilities/center-wiring.d.ts +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/execution-lane.d.ts +5 -5
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +5 -5
- package/dist/capabilities/mcp-probe.d.ts +10 -7
- package/dist/capabilities/sandbox-file-send.d.ts +1 -18
- package/dist/capabilities/sandbox-file-send.js +0 -7
- package/dist/capabilities/scenarios.d.ts +28 -10
- package/dist/capabilities/scenarios.js +15 -5
- package/dist/capabilities/send-user-file-tool.d.ts +1 -1
- package/dist/capabilities/skills.d.ts +31 -12
- package/dist/capabilities/skills.js +23 -17
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +26 -25
- package/dist/capability-facts.js +14 -16
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +4 -4
- package/dist/checkpoint-identity.d.ts +5 -0
- package/dist/checkpoint-identity.js +14 -0
- package/dist/config-catalog.d.ts +12 -12
- package/dist/config-invariants.d.ts +4 -4
- package/dist/config-invariants.js +3 -2
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +2 -1
- package/dist/config-types.d.ts +83 -83
- package/dist/config.d.ts +26 -24
- package/dist/config.js +12 -10
- package/dist/cross-session-settings.d.ts +1 -1
- package/dist/delegated-session-owner.d.ts +16 -13
- package/dist/delegated-session-owner.js +9 -10
- package/dist/deployment-governance.d.ts +16 -16
- package/dist/deployment-shape.d.ts +127 -0
- package/dist/deployment-shape.js +72 -0
- package/dist/device-store.d.ts +1 -1
- package/dist/device-ws-hub.d.ts +1 -1
- package/dist/egress-redirect.d.ts +1 -1
- package/dist/entry-mode-clamp-notice.d.ts +2 -2
- package/dist/env-facts.d.ts +10 -9
- package/dist/env-facts.js +1 -1
- package/dist/env-name-allowlist-knobs.d.ts +5 -5
- package/dist/exec-bounds.d.ts +2 -2
- package/dist/execution-lane-caps.d.ts +31 -43
- package/dist/execution-lane-caps.js +0 -13
- package/dist/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +23 -11
- package/dist/file-history-disclosure.js +7 -12
- package/dist/fleet/drain-entry.d.ts +2 -2
- package/dist/fleet/fleet-bus.d.ts +22 -14
- package/dist/fleet/fleet-bus.js +5 -5
- package/dist/fleet/fleet-reconciler.d.ts +9 -9
- package/dist/fleet/subagent-tail-bus.d.ts +4 -4
- package/dist/fleet-client.d.ts +13 -13
- package/dist/fleet-lease.d.ts +16 -16
- package/dist/governance-http-status.d.ts +2 -2
- package/dist/hooks/hook-llm.d.ts +7 -7
- package/dist/hooks/hook-runner.d.ts +57 -30
- package/dist/hooks/hook-runner.js +36 -18
- package/dist/host-decision.d.ts +5 -5
- package/dist/host-lsp-manager.d.ts +5 -5
- package/dist/hosted-posture.d.ts +23 -13
- package/dist/hosted-posture.js +4 -9
- package/dist/http/admission.d.ts +2 -2
- package/dist/http/admission.js +20 -5
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +2 -1
- package/dist/http/checkpoint-ctx.d.ts +39 -13
- package/dist/http/checkpoint-ctx.js +74 -35
- package/dist/http/dispatch.d.ts +3 -3
- package/dist/http/durable-run-leg.js +4 -3
- package/dist/http/idempotency.d.ts +2 -2
- package/dist/http/mcp-dial-deadline.d.ts +7 -5
- package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
- package/dist/http/owner-access.d.ts +4 -6
- package/dist/http/owner-access.js +1 -1
- package/dist/http/principal-gate.d.ts +7 -7
- package/dist/http/principal-gate.js +3 -2
- package/dist/http/readiness.d.ts +1 -1
- package/dist/http/request-guards.d.ts +4 -4
- package/dist/http/request-guards.js +2 -1
- package/dist/http/resume-ctx-read.d.ts +7 -7
- package/dist/http/resume-ctx-read.js +1 -1
- package/dist/http/resume-legs.d.ts +3 -3
- package/dist/http/resume-legs.js +11 -8
- package/dist/http/route-ctx.d.ts +29 -29
- package/dist/http/route-table.d.ts +9 -9
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/approvals-assistant.d.ts +5 -5
- package/dist/http/routes/approvals-assistant.js +55 -15
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +2 -2
- package/dist/http/routes/capabilities.d.ts +1 -1
- package/dist/http/routes/capabilities.js +16 -8
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/devices.d.ts +1 -1
- package/dist/http/routes/diagnostics.d.ts +3 -3
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/fleet.js +2 -1
- package/dist/http/routes/mcp-reconnect.d.ts +4 -4
- package/dist/http/routes/mcp-reconnect.js +3 -3
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/notify-wake.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -2
- package/dist/http/routes/rules.d.ts +1 -1
- package/dist/http/routes/runs.js +22 -10
- package/dist/http/routes/session-sync.d.ts +1 -1
- package/dist/http/routes/session-sync.js +73 -44
- package/dist/http/routes/sessions-list.js +1 -1
- package/dist/http/routes/sessions.js +30 -44
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/workflows.d.ts +3 -0
- package/dist/http/routes/workflows.js +31 -28
- package/dist/http/send.d.ts +5 -5
- package/dist/http/server.d.ts +34 -34
- package/dist/http/session-inherit-env.d.ts +3 -3
- package/dist/http/sse-lifecycle.d.ts +1 -1
- package/dist/http/sse-log.d.ts +2 -2
- package/dist/http/submit-ctx.js +1 -1
- package/dist/http/sync-submit-body.d.ts +1 -1
- package/dist/http/verify-rounds.d.ts +1 -1
- package/dist/http/wire-types.d.ts +28 -21
- package/dist/instruction-source-notice.d.ts +2 -2
- package/dist/key-resolver.d.ts +3 -3
- package/dist/lane-home-probe.d.ts +1 -1
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/leader/diffup.d.ts +2 -2
- package/dist/leader/endpoint.d.ts +1 -1
- package/dist/leader/fanout.d.ts +1 -1
- package/dist/leader/leader.d.ts +4 -4
- package/dist/leader/merge.d.ts +3 -3
- package/dist/leader/repair-wire.d.ts +1 -1
- package/dist/leader/wire.d.ts +6 -6
- package/dist/list-entry-display.d.ts +1 -1
- package/dist/lsp-evict.d.ts +1 -1
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/memory-layer-legacy-lock.d.ts +1 -1
- package/dist/memory-operator-faces.d.ts +1 -1
- package/dist/memory-posture.js +4 -2
- package/dist/memory-project-layer.d.ts +1 -1
- package/dist/memory-scope.d.ts +19 -19
- package/dist/memory-store-refusal.d.ts +4 -4
- package/dist/model-entry-headers.d.ts +2 -2
- package/dist/model-entry-refusal.d.ts +17 -17
- package/dist/model-provider.d.ts +10 -10
- package/dist/model-reach-scope.d.ts +1 -1
- package/dist/model-route-endpoint.d.ts +6 -6
- package/dist/model-route-url.d.ts +5 -5
- package/dist/model-select.d.ts +15 -6
- package/dist/model-select.js +5 -0
- package/dist/model-unreachable-notice.d.ts +3 -3
- package/dist/namespaced-rule-name.d.ts +15 -5
- package/dist/namespaced-rule-name.js +3 -2
- package/dist/observability/corrupt-read-seat.d.ts +9 -9
- package/dist/observability/cost-taxonomy.d.ts +1 -1
- package/dist/observability/err-text.d.ts +1 -1
- package/dist/observability/fail-open.d.ts +12 -8
- package/dist/observability/fail-open.js +12 -8
- package/dist/observability/metrics.d.ts +3 -3
- package/dist/observability/run-terminal.d.ts +36 -36
- package/dist/observability/secret-env-scrub.d.ts +3 -3
- package/dist/observability/tool-trace.d.ts +1 -1
- package/dist/operator-ask.d.ts +4 -4
- package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
- package/dist/orchestration/workflow-completion-inbox.js +29 -7
- package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
- package/dist/orchestration/workflow-notify-journal.js +17 -0
- package/dist/outbound-dispatcher.d.ts +4 -4
- package/dist/parent-watch.d.ts +4 -4
- package/dist/parked-decide.d.ts +16 -15
- package/dist/parked-decide.js +5 -4
- package/dist/parked-revive-surface.d.ts +7 -7
- package/dist/parked-revive-surface.js +2 -3
- package/dist/peer-directory.d.ts +3 -3
- package/dist/peer-directory.js +1 -1
- package/dist/permission-rule-list.d.ts +10 -1
- package/dist/permission-rule-list.js +7 -5
- package/dist/permission-rule-vocab.d.ts +2 -2
- package/dist/plugins/adoption-log-sql.d.ts +1 -1
- package/dist/plugins/approval-ask-store-file.d.ts +8 -1
- package/dist/plugins/approval-ask-store-file.js +6 -3
- package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
- package/dist/plugins/approval-ask-store-memory.js +11 -7
- package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
- package/dist/plugins/approval-ask-store-sql.js +18 -5
- package/dist/plugins/approval-exemption-store.d.ts +3 -3
- package/dist/plugins/approval-nonce-store.d.ts +3 -3
- package/dist/plugins/background-agent-store-sql.d.ts +1 -1
- package/dist/plugins/background-shell-support.d.ts +2 -2
- package/dist/plugins/blob-backend.d.ts +1 -1
- package/dist/plugins/caching-session-store.d.ts +23 -32
- package/dist/plugins/caching-session-store.js +5 -17
- package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
- package/dist/plugins/checkpoint-index-columns.js +62 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +44 -66
- package/dist/plugins/checkpoint-store-sql.js +55 -102
- package/dist/plugins/device-store-sql.d.ts +7 -6
- package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
- package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
- package/dist/plugins/file-history-store-sql.d.ts +9 -7
- package/dist/plugins/file-history-store-sql.js +27 -15
- package/dist/plugins/file-run-store.d.ts +8 -8
- package/dist/plugins/fork-routing-session-store.d.ts +2 -2
- package/dist/plugins/fork-routing-session-store.js +1 -1
- package/dist/plugins/host-platform.d.ts +10 -10
- package/dist/plugins/image-bake-store-sql.d.ts +1 -1
- package/dist/plugins/image-index-sql.d.ts +1 -1
- package/dist/plugins/leader-run-store-sql.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -10
- package/dist/plugins/local-checkpoint-store.js +3 -4
- package/dist/plugins/local-session-store.d.ts +34 -38
- package/dist/plugins/local-session-store.js +20 -39
- package/dist/plugins/local-session-window.d.ts +1 -1
- package/dist/plugins/mailbox-store-sql.d.ts +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +1 -1
- package/dist/plugins/memory-run-store.d.ts +4 -4
- package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +66 -40
- package/dist/plugins/one-time-migrations.js +115 -34
- package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
- package/dist/plugins/park-commit-watch.d.ts +3 -3
- package/dist/plugins/permission-rule-store-file.d.ts +5 -5
- package/dist/plugins/permission-rule-store-file.js +12 -19
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
- package/dist/plugins/permission-rule-store-sql.js +67 -24
- package/dist/plugins/pg-cost-quota.d.ts +1 -1
- package/dist/plugins/pg-pool.d.ts +2 -2
- package/dist/plugins/pg-pool.js +5 -2
- package/dist/plugins/pg-rate-limiter.d.ts +1 -1
- package/dist/plugins/pg-session-storage.d.ts +8 -20
- package/dist/plugins/pg-session-storage.js +14 -27
- package/dist/plugins/remote-env-adb.d.ts +10 -10
- package/dist/plugins/remote-env-device.d.ts +10 -9
- package/dist/plugins/remote-env-device.js +6 -2
- package/dist/plugins/remote-env-e2b.d.ts +3 -3
- package/dist/plugins/remote-env-host.d.ts +16 -16
- package/dist/plugins/remote-env-k8s.d.ts +8 -8
- package/dist/plugins/remote-env-local-docker.d.ts +2 -2
- package/dist/plugins/remote-env-ssh.d.ts +4 -4
- package/dist/plugins/remote-scratchpad.d.ts +2 -3
- package/dist/plugins/remote-scratchpad.js +0 -4
- package/dist/plugins/remote-shell.d.ts +6 -6
- package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
- package/dist/plugins/retention-store-sql.d.ts +4 -4
- package/dist/plugins/roster-store-sql.d.ts +1 -1
- package/dist/plugins/run-store-sql.d.ts +8 -8
- package/dist/plugins/schema-consistency.d.ts +2 -2
- package/dist/plugins/schema-ensure-legs.d.ts +3 -3
- package/dist/plugins/schema-indexes.d.ts +1 -1
- package/dist/plugins/schema-live-columns.d.ts +1 -1
- package/dist/plugins/session-event-payload.d.ts +4 -4
- package/dist/plugins/session-fork.d.ts +34 -0
- package/dist/plugins/session-fork.js +29 -0
- package/dist/plugins/session-ownership.js +1 -1
- package/dist/plugins/session-placement.d.ts +1 -1
- package/dist/plugins/session-policy-store-sql.d.ts +12 -12
- package/dist/plugins/session-store.d.ts +2 -2
- package/dist/plugins/session-store.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
- package/dist/plugins/sql-driver.d.ts +8 -8
- package/dist/plugins/sql-errors.d.ts +1 -1
- package/dist/plugins/sql-json-column.d.ts +21 -21
- package/dist/plugins/sql-row-helpers.d.ts +2 -2
- package/dist/plugins/store-backend.d.ts +17 -16
- package/dist/plugins/store-backend.js +3 -3
- package/dist/plugins/store-contracts.d.ts +21 -21
- package/dist/plugins/task-attachment-store.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/tidb-pool.d.ts +2 -2
- package/dist/plugins/tidb-pool.js +9 -2
- package/dist/plugins/tidb-session-store.d.ts +16 -26
- package/dist/plugins/tidb-session-store.js +15 -27
- package/dist/plugins/tool-result-store-sql.d.ts +1 -1
- package/dist/plugins/usage-window-store-sql.d.ts +3 -3
- package/dist/plugins/user-input-ledger-file.d.ts +1 -1
- package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
- package/dist/plugins/web-search.d.ts +19 -5
- package/dist/plugins/web-search.js +19 -4
- package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
- package/dist/plugins/workflow-journal-payload.js +32 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
- package/dist/plugins/workflow-journal-store-sql.js +34 -15
- package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
- package/dist/posture-source.d.ts +11 -11
- package/dist/principal-jwt.d.ts +6 -6
- package/dist/project-identity.d.ts +3 -3
- package/dist/project-memory.d.ts +4 -4
- package/dist/read-face-posture.d.ts +7 -7
- package/dist/request-key-closure.d.ts +1 -1
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +15 -8
- package/dist/request-value-closure.js +2 -0
- package/dist/router/route-orchestration.d.ts +11 -16
- package/dist/router/route-orchestration.js +2 -12
- package/dist/rule-entry-list.d.ts +8 -7
- package/dist/rule-entry-list.js +2 -9
- package/dist/rules-consent.d.ts +6 -6
- package/dist/rules-consent.js +2 -0
- package/dist/run-cancel-context.d.ts +5 -5
- package/dist/run-local.d.ts +10 -10
- package/dist/runs.d.ts +13 -11
- package/dist/runs.js +15 -1
- package/dist/runtime-caps-resolver.d.ts +6 -6
- package/dist/runtime-governance.d.ts +9 -9
- package/dist/sandbox-pkg-source.d.ts +9 -31
- package/dist/sandbox-pkg-source.js +14 -8
- package/dist/sealed-key.d.ts +3 -3
- package/dist/security.d.ts +23 -26
- package/dist/security.js +12 -9
- package/dist/server-secret-env.d.ts +10 -10
- package/dist/session-children-retire.d.ts +1 -1
- package/dist/session-error-wire.d.ts +7 -7
- package/dist/session-incarnation.d.ts +52 -35
- package/dist/session-incarnation.js +23 -8
- package/dist/session-policy-wire.d.ts +27 -5
- package/dist/session-policy-wire.js +15 -1
- package/dist/session-records-skipped-notice.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +4 -4
- package/dist/session-sync.d.ts +49 -6
- package/dist/session-sync.js +52 -10
- package/dist/session-titler.d.ts +7 -6
- package/dist/session-titler.js +8 -13
- package/dist/session-watch.d.ts +3 -3
- package/dist/session-watch.js +4 -4
- package/dist/sighup-idle.d.ts +2 -2
- package/dist/spec-fields.d.ts +4 -4
- package/dist/sql-engine-posture.d.ts +3 -3
- package/dist/store-posture.d.ts +2 -2
- package/dist/stored-request-tool-axes-m19.d.ts +1 -1
- package/dist/task-a2a.d.ts +3 -1
- package/dist/task-a2a.js +34 -2
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +12 -8
- package/dist/task-mcp.js +19 -4
- package/dist/task-settings.d.ts +30 -18
- package/dist/task-settings.js +33 -3
- package/dist/task-workflow.d.ts +0 -24
- package/dist/task-workflow.js +2 -1
- package/dist/terminal.d.ts +5 -5
- package/dist/tighten-only-seats.d.ts +7 -6
- package/dist/tighten-only-seats.js +1 -1
- package/dist/tool-approval.d.ts +143 -197
- package/dist/tool-approval.js +13 -28
- package/dist/tool-rule-names.d.ts +2 -2
- package/dist/trace/core-keyset-guard.d.ts +12 -7
- package/dist/trace/engine-notice-wire.d.ts +5 -5
- package/dist/trace/engine-notice-wire.js +1 -0
- package/dist/trace/exit-seat.d.ts +31 -4
- package/dist/trace/exit-seat.js +41 -63
- package/dist/trace/ledger-events.d.ts +3 -3
- package/dist/trace/ledger-sink.d.ts +1 -1
- package/dist/trace/model-segment.d.ts +3 -3
- package/dist/trace/project.d.ts +47 -45
- package/dist/trace/project.js +33 -1
- package/dist/trace/redact.d.ts +44 -30
- package/dist/trace/redact.js +191 -89
- package/dist/trace/self-minted-wire.d.ts +35 -14
- package/dist/trace/self-minted-wire.js +8 -0
- package/dist/trace/sema-provenance.d.ts +1 -1
- package/dist/trace/task-notification-facets.d.ts +4 -4
- package/dist/trace/wire-projection-faces.d.ts +3 -3
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/unattended-permission-mode.d.ts +5 -5
- package/dist/url-credential.d.ts +52 -0
- package/dist/url-credential.js +49 -0
- package/dist/url-refusal.d.ts +6 -2
- package/dist/url-refusal.js +8 -1
- package/dist/usage-analytics.d.ts +2 -2
- package/dist/user-input-ledger.d.ts +23 -23
- package/dist/web-admin-client/apply-effective.d.ts +5 -5
- package/dist/web-admin-client/apply-effective.js +2 -1
- package/dist/web-admin-client/apply-ledger.d.ts +2 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/facade.d.ts +5 -5
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
- package/dist/web-admin-client/http-client.d.ts +4 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/pull-state.d.ts +1 -1
- package/dist/web-admin-client/read-face.d.ts +2 -2
- package/dist/web-admin-client/read-warnings.d.ts +5 -5
- package/dist/web-admin-client/restart-signal.d.ts +6 -6
- package/dist/web-admin-client/skills-mcp.d.ts +28 -3
- package/dist/web-admin-client/skills-mcp.js +29 -1
- package/dist/web-admin-client/types.d.ts +16 -9
- package/dist/workspace-space.d.ts +5 -3
- package/dist/write-protection.d.ts +2 -2
- package/package.json +4 -3
- package/scripts/drain-check-local.mjs +2 -1
- package/scripts/drain-check.mysql.sql +4 -2
- package/scripts/drain-check.pg.sql +4 -2
- package/skills/loop.md +1 -1
- package/dist/http/run-declared-families.d.ts +0 -16
- package/dist/http/run-declared-families.js +0 -12
- package/dist/orchestration/workflow-journal-entry.js +0 -27
package/dist/tool-approval.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readApprovalCard } from "./approval-content-kind.js";
|
|
2
2
|
import { heldAskOf, liveSettledBy, readDecidedBy, retiredDecisionKeyFacts, DECIDED_BY_OUTSIDE_CLOSED_SET, POLICY_CANNOT_ALLOW_PERSON_ASK } from "./host-decision.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { uuidv7, classifyAsk, foldArbitrationRow, policyCannotAnswer, screenAskClassMembers, MAX_RULE_TEXT_CHARS, READ_ROOT_CANDIDATE_DIR_MAX, parseRuleText, pathConfinableWriteToolNames } from "@sema-agent/core";
|
|
@@ -12,8 +12,8 @@ import { errorKindOf } from "./observability/err-text.js";
|
|
|
12
12
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
13
13
|
import { ownerOfCheckpointScope } from "./security.js";
|
|
14
14
|
import { deriveAskId, deriveAskScopedBatchId, deriveBatchId, MAX_DECISION_NOTE_CHARS, noteLandedOnRow, noteRecordedReceipt } from "./approval-ask-machine.js";
|
|
15
|
-
import { currentParkArm, MAX_RULE_OFFERS, buildApprovalCard, buildApprovalCardEnvelope, buildApprovalRequestFrame, buildReplayFrame, buildRevokeFrame, readDenialLimitFallback, readProbeCause, readProbeReason, readReadRootCandidate, readStoredCardEnvelope, readRuleEvidence, readAllowRuleShadowed, readRuleOffersAbsence, readRuleOffersAbsenceSeat, readParkRowTrueSeat, readAskClassPair, readClosedWordSeat, buildApprovalCompleteFrame,
|
|
16
|
-
import { POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
|
|
15
|
+
import { currentParkArm, MAX_RULE_OFFERS, buildApprovalCard, buildApprovalCardEnvelope, buildApprovalRequestFrame, buildReplayFrame, buildRevokeFrame, readDenialLimitFallback, readProbeCause, readProbeReason, readReadRootCandidate, readStoredCardEnvelope, readRuleEvidence, readAllowRuleShadowed, readRuleOffersAbsence, readRuleOffersAbsenceSeat, readParkRowTrueSeat, readAskClassPair, readClosedWordSeat, buildApprovalCompleteFrame, readRuleOfferList, } from "./approval-card.js";
|
|
16
|
+
import { askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
|
|
17
17
|
import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, causeOfAskRow } from "./approval-deny-reasons.js";
|
|
18
18
|
import { settleByPolicy } from "./approval-policy-settlement.js";
|
|
19
19
|
import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
|
|
@@ -23,14 +23,6 @@ import { operatorAsk } from "./operator-ask.js";
|
|
|
23
23
|
import { APPROVAL_EXEMPTED_EVENT } from "./plugins/approval-exemption-store.js";
|
|
24
24
|
import { refusalBody } from "./http/refusal-body.js";
|
|
25
25
|
const defaultLogger = createLogger();
|
|
26
|
-
export const APPROVAL_GATE_KINDS = ["human", "irreversible_ask"];
|
|
27
|
-
export function isApprovalGateKind(k) {
|
|
28
|
-
return k !== undefined && APPROVAL_GATE_KINDS.includes(k);
|
|
29
|
-
}
|
|
30
|
-
export function denySweepOwns(gate) {
|
|
31
|
-
return isApprovalGateKind(typeof gate?.kind === "string" ? gate.kind : undefined) && parkedFacetOf(gate) === "A";
|
|
32
|
-
}
|
|
33
|
-
export const APPROVAL_GATE_KINDS_SQL_IN = `(${APPROVAL_GATE_KINDS.map((k) => `'${k}'`).join(",")})`;
|
|
34
26
|
const MAX_APPROVAL_ARGS_BYTES = 16384;
|
|
35
27
|
const DEFAULT_APPROVAL_TTL_MS = 5 * 60_000;
|
|
36
28
|
const DEFAULT_UNREACHED_ASK_TTL_MS = 60 * 60_000;
|
|
@@ -770,16 +762,7 @@ export class ToolApprovalCoordinator {
|
|
|
770
762
|
const over = (s) => s.length > MAX_RULE_TEXT_CHARS;
|
|
771
763
|
const clipSegment = (s) => (over(s) ? s.slice(0, MAX_RULE_TEXT_CHARS) : s);
|
|
772
764
|
const out = [];
|
|
773
|
-
for (const
|
|
774
|
-
const parsed = RuleOfferRawSchema.safeParse(screenUncoveredDetailSeat(backfillLegacyBatchMemberKind(raw)));
|
|
775
|
-
if (!parsed.success) {
|
|
776
|
-
defaultLogger.warn("rule_offer_dropped_unreadable_shape", {
|
|
777
|
-
kind: typeof raw === "object" && raw !== null ? String(raw.kind) : typeof raw,
|
|
778
|
-
note: "this offer's shape is outside the closed vocabulary this build reads (member kind / match / reason) — dropped whole; sibling offers still render (core/dist skew?)",
|
|
779
|
-
});
|
|
780
|
-
continue;
|
|
781
|
-
}
|
|
782
|
-
const offer = parsed.data;
|
|
765
|
+
for (const { offer } of readRuleOfferList(offers)) {
|
|
783
766
|
if (ToolApprovalCoordinator.ruleOfferTextsOverSize(offer))
|
|
784
767
|
return undefined;
|
|
785
768
|
if (!ToolApprovalCoordinator.ruleOfferDerivedFactsAgree(offer)) {
|
|
@@ -2070,7 +2053,7 @@ export class ToolApprovalCoordinator {
|
|
|
2070
2053
|
if (!entry || (entry.owner !== null && entry.owner !== principal)) {
|
|
2071
2054
|
return this.respondLate(id, principal, parsed, httpReq);
|
|
2072
2055
|
}
|
|
2073
|
-
return this.answerRegistration(entry, id, principal, parsed, httpReq);
|
|
2056
|
+
return this.answerRegistration(entry, entry.owner, id, principal, parsed, httpReq);
|
|
2074
2057
|
}
|
|
2075
2058
|
async respondAdopted(entry, id, principal, parsed, httpReq) {
|
|
2076
2059
|
const store = this.askStore;
|
|
@@ -2081,9 +2064,9 @@ export class ToolApprovalCoordinator {
|
|
|
2081
2064
|
return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
|
|
2082
2065
|
if (row.state !== "STREAM_PENDING")
|
|
2083
2066
|
return this.dispatchRowTruth(row, id, parsed, httpReq, principal);
|
|
2084
|
-
return this.answerRegistration(entry, id, principal, parsed, httpReq);
|
|
2067
|
+
return this.answerRegistration(entry, row.owner, id, principal, parsed, httpReq);
|
|
2085
2068
|
}
|
|
2086
|
-
answerRegistration(entry, id, principal, parsed, httpReq) {
|
|
2069
|
+
answerRegistration(entry, judgedOwner, id, principal, parsed, httpReq) {
|
|
2087
2070
|
const preRule = this.precheckEditedRuleBeforeDecision(entry, parsed);
|
|
2088
2071
|
if (preRule !== undefined)
|
|
2089
2072
|
return preRule;
|
|
@@ -2093,7 +2076,7 @@ export class ToolApprovalCoordinator {
|
|
|
2093
2076
|
const ruleEligibility = { eligible: true };
|
|
2094
2077
|
const store = this.askStore;
|
|
2095
2078
|
if (store && entry.askId !== undefined && entry.batchId !== undefined) {
|
|
2096
|
-
return this.respondWithCas(store, entry.askId, entry.batchId, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, parsed, principal, ruleEligibility));
|
|
2079
|
+
return this.respondWithCas(store, entry.askId, entry.batchId, judgedOwner, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, parsed, principal, ruleEligibility));
|
|
2097
2080
|
}
|
|
2098
2081
|
return this.afterLiveDecision(this.finishRespond(entry, parsed), entry, parsed, principal, ruleEligibility);
|
|
2099
2082
|
}
|
|
@@ -2228,7 +2211,7 @@ export class ToolApprovalCoordinator {
|
|
|
2228
2211
|
switch (gate.kind) {
|
|
2229
2212
|
case "open": {
|
|
2230
2213
|
const parkSession = parkSessionOf(row);
|
|
2231
|
-
body = { state: "parked", ...projection, ...(parkSession !== undefined ? { decidePath: approvalDecidePath(parkSession) } : {}) };
|
|
2214
|
+
body = { state: "parked", ...projection, ...(parkSession !== undefined ? { decidePath: approvalDecidePath(parkSession) } : {}), ...(gate.reopened !== undefined ? { reopened: gate.reopened } : {}) };
|
|
2232
2215
|
break;
|
|
2233
2216
|
}
|
|
2234
2217
|
case "decided":
|
|
@@ -2676,12 +2659,12 @@ export class ToolApprovalCoordinator {
|
|
|
2676
2659
|
return withFlag(false, "rule_store_error");
|
|
2677
2660
|
}
|
|
2678
2661
|
}
|
|
2679
|
-
async respondWithCas(askStore, askId, batchId, entry, parsed, ruleEligibility) {
|
|
2662
|
+
async respondWithCas(askStore, askId, batchId, owner, entry, parsed, ruleEligibility) {
|
|
2680
2663
|
let winnerRow;
|
|
2681
2664
|
let ambiguousConfirmedRow;
|
|
2682
2665
|
let noteLanded = false;
|
|
2683
2666
|
try {
|
|
2684
|
-
const decided = await this.withStoreDeadline(askStore.decideAsk(askId, batchId, {
|
|
2667
|
+
const decided = await this.withStoreDeadline(askStore.decideAsk(askId, batchId, owner, {
|
|
2685
2668
|
decision: parsed.value === "deny" ? "deny" : "approve",
|
|
2686
2669
|
...(parsed.note !== undefined ? { decisionNote: parsed.note } : {}),
|
|
2687
2670
|
...(parsed.value !== "deny" && parsed.updatedInput !== undefined ? { updatedInput: parsed.updatedInput } : {}),
|
|
@@ -2703,6 +2686,8 @@ export class ToolApprovalCoordinator {
|
|
|
2703
2686
|
ruleEligibility.eligible = false;
|
|
2704
2687
|
try {
|
|
2705
2688
|
const row = await this.withStoreDeadline(askStore.getAsk(askId), "getAsk(decideAsk-confirm)", DURABLE_CONVERGE_READ_TIMEOUT_MS);
|
|
2689
|
+
if (row !== null && !askRowCarriesOwner(row, owner))
|
|
2690
|
+
return { lost: true, row: null };
|
|
2706
2691
|
if (row?.state === "DECIDED" && row.decision === (parsed.value === "deny" ? "deny" : "approve")) {
|
|
2707
2692
|
winnerRow = row;
|
|
2708
2693
|
ambiguousConfirmedRow = row;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref](安全轴,八病审计 SG H2-a)—— 本仓**收紧方向**按引擎工具名匹配的策略臂的**唯一**名字读法。
|
|
3
3
|
*
|
|
4
4
|
* ## 规则(一条,与 core 7.36.0 [ref] `NAME_READINGS` 同判)
|
|
5
5
|
* 一个调用可以答好几个名字:嵌入方工具声明别名(`MyShell{aliases:["Bash"]}`)后,模型按哪个名调它、它的 wire 名、
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* 修前(≤7.107.0)本仓自写的这些臂只比 `req.toolName`:模型按别名调嵌入方工具时,运维名单一个都不拦(core 同族策略判 deny、
|
|
18
18
|
* 本仓判 allow)。本仓自身不声明带别名的工具,所以只有经 `resolveSpec` 席挂别名工具的嵌入方走得到。
|
|
19
19
|
*
|
|
20
|
-
* ⚠️ **别名只是名字,不是标记的载体**(core 7.54.0
|
|
20
|
+
* ⚠️ **别名只是名字,不是标记的载体**(core 7.54.0 [ref],[ref] 已定案):上面这条读法只回答「这次调用答得上哪些名字」;嵌入方工具自己的
|
|
21
21
|
* 安全标记(`egress`、不可逆层级 `irreversibility`、可逆探针)**不再**因别名恰是引擎工具名(`MyShell{aliases:["Bash"]}`)而镜像到引擎 shell 上 ——
|
|
22
22
|
* 7.53.x 及以前,`MyShell` 的 `egress: true` / `irreversibility: "always"` 会让引擎 `Bash` 的调用多问一次(收紧),它的恒可逆探针会让引擎 `Bash` 的
|
|
23
23
|
* `touch` 不问就跑(放宽);7.54.0 起两者都不再作用于引擎 shell。要收紧引擎 shell:给**正名**叫 `Bash` 的工具声明标记(同名标记仍作用),或请求
|
|
@@ -60,7 +60,7 @@ type _GuardMailboxReverse = AssertAllKeysHandled<Exclude<MailboxProjected, keyof
|
|
|
60
60
|
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
61
61
|
type _GuardMailboxAppend = AssertAllKeysHandled<Exclude<keyof MailboxAppendMessage, MailboxAppendProjected>>;
|
|
62
62
|
type _GuardMailboxAppendReverse = AssertAllKeysHandled<Exclude<MailboxAppendProjected, keyof MailboxAppendMessage>>;
|
|
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
|
+
type WiringSectionProjected = "schemaVersion" | "leg" | "ask" | "question" | "interaction" | "elicit" | "parkLane" | "session" | "fleet" | "permissionRules" | "modelGate" | "autoMode" | "mcp" | "tools" | "mods" | "lsp" | "hands" | "writeProtection" | "teamRole" | "fileHistory" | "permissionMode" | "sessionRules" | "projectMemory";
|
|
64
64
|
type WiringSectionExcluded = (typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES)["wiring_manifest_tenant"]["excluded"][number];
|
|
65
65
|
type _GuardWiringSections = AssertAllKeysHandled<Exclude<keyof WiringManifest, WiringSectionProjected | WiringSectionExcluded>>;
|
|
66
66
|
type _GuardWiringSectionsReverse = AssertAllKeysHandled<Exclude<WiringSectionProjected | WiringSectionExcluded, keyof WiringManifest>>;
|
|
@@ -133,6 +133,9 @@ type _GuardWiringAutoConsolidationReverse = AssertAllKeysHandled<Exclude<WiringA
|
|
|
133
133
|
type WiringModelGateHandled = "class" | "removed" | "restore";
|
|
134
134
|
type _GuardWiringModelGate = AssertAllKeysHandled<Exclude<keyof WiringSection<"modelGate">, WiringModelGateHandled>>;
|
|
135
135
|
type _GuardWiringModelGateReverse = AssertAllKeysHandled<Exclude<WiringModelGateHandled, keyof WiringSection<"modelGate">>>;
|
|
136
|
+
type ProjectTables = typeof import("./project.js");
|
|
137
|
+
type _GuardWiringSessionRules = AssertAllKeysHandled<Exclude<keyof WiringSection<"sessionRules">, TableCoreKeys<ProjectTables["WIRING_SESSION_RULES_DISPOSITIONS"]>>>;
|
|
138
|
+
type _GuardWiringSessionRulesReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<ProjectTables["WIRING_SESSION_RULES_DISPOSITIONS"]>, keyof WiringSection<"sessionRules">>>;
|
|
136
139
|
type WiringPermissionModeHandled = "requested" | "effective" | "foldedBy";
|
|
137
140
|
type _GuardWiringPermissionMode = AssertAllKeysHandled<Exclude<keyof PermissionModeReceipt, WiringPermissionModeHandled>>;
|
|
138
141
|
type _GuardWiringPermissionModeReverse = AssertAllKeysHandled<Exclude<WiringPermissionModeHandled, keyof PermissionModeReceipt>>;
|
|
@@ -216,13 +219,13 @@ type ParkArmKeys = keyof Extract<PendingAction, {
|
|
|
216
219
|
kind: "tool_approval";
|
|
217
220
|
}>;
|
|
218
221
|
type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts;
|
|
219
|
-
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling";
|
|
222
|
+
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling";
|
|
220
223
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
221
224
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
222
225
|
type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
|
|
223
|
-
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
|
|
226
|
+
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" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
|
|
224
227
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
225
|
-
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm";
|
|
228
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel";
|
|
226
229
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
227
230
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
228
231
|
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";
|
|
@@ -244,7 +247,7 @@ type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "fold
|
|
|
244
247
|
type SessionMemoryStatusExcluded = "writeHome";
|
|
245
248
|
type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<keyof SessionMemoryStatus, SessionMemoryStatusProjected | SessionMemoryStatusExcluded>>;
|
|
246
249
|
type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded, keyof SessionMemoryStatus>>;
|
|
247
|
-
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage";
|
|
250
|
+
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut";
|
|
248
251
|
type SideQueryResultStripped = never;
|
|
249
252
|
type _GuardSideQueryResult = AssertAllKeysHandled<Exclude<keyof SideQueryResult, SideQueryResultForwarded | SideQueryResultStripped>>;
|
|
250
253
|
type _GuardSideQueryResultReverse = AssertAllKeysHandled<Exclude<SideQueryResultForwarded | SideQueryResultStripped, keyof SideQueryResult>>;
|
|
@@ -258,7 +261,7 @@ type GateOutcomeProjected = "disposition" | "settlement" | "origin";
|
|
|
258
261
|
type _GuardGateOutcome = AssertAllKeysHandled<Exclude<keyof GateOutcome, GateOutcomeProjected>>;
|
|
259
262
|
type _GuardGateOutcomeReverse = AssertAllKeysHandled<Exclude<GateOutcomeProjected, keyof GateOutcome>>;
|
|
260
263
|
type GateDispositionKeys = GateDisposition extends infer D ? (D extends object ? keyof D : never) : never;
|
|
261
|
-
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "mode" | "askClass" | "classes";
|
|
264
|
+
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes";
|
|
262
265
|
type _GuardGateDisposition = AssertAllKeysHandled<Exclude<GateDispositionKeys, GateDispositionProjected>>;
|
|
263
266
|
type _GuardGateDispositionReverse = AssertAllKeysHandled<Exclude<GateDispositionProjected, GateDispositionKeys>>;
|
|
264
267
|
type SettlementProjected = "kind" | "who" | "when" | "note";
|
|
@@ -317,7 +320,7 @@ type LspOptionsUnwired = "onNotice" | "servers" | "spawn" | "readText" | "resolv
|
|
|
317
320
|
type _GuardLspOptions = AssertAllKeysHandled<Exclude<keyof NodeLspManagerOptions, LspOptionsWired | LspOptionsUnwired>>;
|
|
318
321
|
type _GuardLspOptionsReverse = AssertAllKeysHandled<Exclude<LspOptionsWired | LspOptionsUnwired, keyof NodeLspManagerOptions>>;
|
|
319
322
|
type _NoDoubleBookLspOptions = AssertAllKeysHandled<Extract<LspOptionsWired, LspOptionsUnwired>>;
|
|
320
|
-
/** ⑯ 账上记过、已接线的 `RunnerDeps` 席(
|
|
323
|
+
/** ⑯ 账上记过、已接线的 `RunnerDeps` 席([ref] 起 `fileHistoryCapture`)。反向钉:core 改名 / 退役 ⇒ 红。 */
|
|
321
324
|
type RunnerDepsLedgerWired = "fileHistoryCapture";
|
|
322
325
|
type _GuardLedgerRunnerDepsReverse = AssertAllKeysHandled<Exclude<RunnerDepsLedgerWired, keyof RunnerDeps>>;
|
|
323
326
|
export type CoreKeysetGuards = [
|
|
@@ -389,6 +392,8 @@ export type CoreKeysetGuards = [
|
|
|
389
392
|
_GuardWiringAutoModeReverse,
|
|
390
393
|
_GuardWiringPermissionMode,
|
|
391
394
|
_GuardWiringPermissionModeReverse,
|
|
395
|
+
_GuardWiringSessionRules,
|
|
396
|
+
_GuardWiringSessionRulesReverse,
|
|
392
397
|
_GuardWiringGovernance,
|
|
393
398
|
_GuardWiringGovernanceReverse,
|
|
394
399
|
_GuardPermissionTrace,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
|
|
17
17
|
* 刚立,立完就在下一次加码时自己咬住了)。
|
|
18
18
|
*/
|
|
19
|
-
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar"];
|
|
19
|
+
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached"];
|
|
20
20
|
export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
|
|
21
21
|
/** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
|
|
22
22
|
export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
|
|
@@ -98,7 +98,7 @@ export declare function redactNoticeMessage(message: unknown): string;
|
|
|
98
98
|
* 通告 `detail` 里的**规则文本**换成条目的脱敏原值({@link redactListEntry}:凭据换记号,不加引号、不转义 —— 机读位不是显示面,显示形只属于人读句)。
|
|
99
99
|
* 会话流行(经 {@link engineNoticeEventData},之后照常过 {@link sanitizeNoticeDetail})与运维日志行(`boot/runner-deps.ts` 的转发席,其余字段逐字)
|
|
100
100
|
* 同调这一只 ⇒ 两条出路上同一条规则文本逐字节同(会话流行另有 detail 串的 {@link NOTICE_TEXT_MAX} 字上限,超长的那一截只在日志行上),两只码里同一条
|
|
101
|
-
* 规则文本也同 —— core 7.53.0(
|
|
101
|
+
* 规则文本也同 —— core 7.53.0([ref])起引擎交来的两形就是同一只读法的产物(原串,长于 1 024 码点的截到 1 024 + 一枚截断记号;修前 `rule_row_dropped`
|
|
102
102
|
* 交中和形,空白 / 超长的条目两只码不同)。其余字段、其余码原样。
|
|
103
103
|
*/
|
|
104
104
|
export declare function redactNoticeRuleText(code: string, detail: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
@@ -109,7 +109,7 @@ export declare function engineNoticeEventData(notice: {
|
|
|
109
109
|
}, sessionId: string, nowMs: number): EngineNoticeWireRow;
|
|
110
110
|
/**
|
|
111
111
|
* 一条 run 腿注册进来的投递口。抛错由 {@link EngineNoticeRouter.route} 隔离(见那里的 fail-open 登记)。
|
|
112
|
-
* 返回值只对 {@link EngineNoticeRouter.routeConfirmed} 有意义(
|
|
112
|
+
* 返回值只对 {@link EngineNoticeRouter.routeConfirmed} 有意义([ref] codex r1-F2 / r2-F1):durable 口交回它那一次账本写的 thenable,
|
|
113
113
|
* 兑现 `true` = 这一帧落进了账本;`false` / 拒绝 = 没落(写失败已由口自己留痕);同步口(live SSE)不交 thenable,**不是**落账确认。`route()` 不读返回值。
|
|
114
114
|
*/
|
|
115
115
|
export type EngineNoticeWireSink = (row: EngineNoticeWireRow) => unknown;
|
|
@@ -163,7 +163,7 @@ export declare class EngineNoticeRouter {
|
|
|
163
163
|
sessionId?: unknown;
|
|
164
164
|
}, nowMs?: number): number;
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
166
|
+
* [ref](codex r1-F2 / r2-F1;[ref] opus 腿 L2 改按槽判):同一只扇出,但**等**每只口交回的持久化结果 —— 返回**确认落账**的口数:
|
|
167
167
|
* 只数 **`durable` 槽**里交回 thenable 且兑现 `true` 的口;兑现 `false` / 拒绝不算;`live` 槽**结构上不计**(不管它返回什么 —— 流上的人收没收到说明不了落账;
|
|
168
168
|
* 修前按「交回 thenable」反推是不是 durable 口,哪天 live 口改成 async 返回 `true` 就会被计成落账)。给「投出之后要记一笔『告知过』」的铸点用:
|
|
169
169
|
* 记账必须跟在**落账**之后,不能跟在「调用了口」之后(后台腿唯一的口是事件账 append,写失败时 `route()` 的计数照样是 1)。判据(白名单 / 归属 / 最新代 / 隔离)与 `route()` 逐字同一条。
|
|
@@ -195,7 +195,7 @@ export declare function registerEngineNoticeLeg(opts: {
|
|
|
195
195
|
durable?: EngineNoticeWireSink;
|
|
196
196
|
router?: EngineNoticeRouter;
|
|
197
197
|
/**
|
|
198
|
-
*
|
|
198
|
+
* [ref] —— **腿开张之前**就已经铸好的通告(装配期 `resolveSpec` 的产物,经
|
|
199
199
|
* `PreparedTaskSubmission.engineNotices` 递过来)。注册完口**立刻**经同一只 {@link EngineNoticeRouter.route}
|
|
200
200
|
* 投出:白名单、归属键、消毒、隔离四件判据一个都不绕,**不是**第二条投递机制 —— 只是把 `route()` 挪到
|
|
201
201
|
* 「这条会话已经有口在听」的那一拍。
|
|
@@ -43,6 +43,7 @@ export const ENGINE_NOTICE_WIRE_CODES = [
|
|
|
43
43
|
"route.credential_origin_mismatch",
|
|
44
44
|
"mods.registration_refused",
|
|
45
45
|
"config.session_rules_earlier_grammar",
|
|
46
|
+
"advisor.not_attached",
|
|
46
47
|
];
|
|
47
48
|
const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
|
|
48
49
|
export function isEngineNoticeWireCode(code) {
|
|
@@ -8,8 +8,12 @@ export type SafeText = string & {
|
|
|
8
8
|
* **座表(闭集;一行 = 一类出口)**。加一类出口 = 加一行;表外的座名是编译错误。
|
|
9
9
|
* · `trace-frame-text`:trace 帧的自由文本位(子代名 / 动作行 / 通告正文与结果 / 诊断 / 注入摘录 / 压缩说明 / 人类输入的署名与附件标签 …),不设界;
|
|
10
10
|
* · `trace-frame-line`:trace 帧里一行宽的展示位(`workspace_changed.cwd` / `brain_status.detail`),界 300 码元;
|
|
11
|
-
* · `operator-log-text`:运维日志字段里的一句话 —— 读口坏行的缺陷句(core 的筛按位置点名并回显落盘标量)、`tool_trace` 行里工具的输出 / 失败句 /
|
|
12
|
-
*
|
|
11
|
+
* · `operator-log-text`:运维日志字段里的一句话 —— 读口坏行的缺陷句(core 的筛按位置点名并回显落盘标量)、`tool_trace` 行里工具的输出 / 失败句 / 拒因、
|
|
12
|
+
* hook 吐出的预览(非 JSON 的输出 / 应答体)与判词、Stop 评估者回话的头、观察面回调与唤醒投递抛出的句子、matcher 超预算的那两串、标题器的两只失败句;界 200 码元(含截断记号);
|
|
13
|
+
* · `operator-log-arg`:运维日志字段里模型写的工具入参(`tool_trace` 的 `arg.*`:路径 / 命令 / 模式 / 非对象入参的串形);界 120 码元(含截断记号);
|
|
14
|
+
* · `operator-log-error`:运维日志字段里 hook 一侧的报错 —— hook 命令的 stderr、prompt 条目的载体失败句、起子进程 / 读会话分支抛出的句子;界 300 码元(含截断记号);
|
|
15
|
+
* · `operator-log-message`:运维日志字段里写给人看的一段话 —— hook 输出的 `systemMessage`、Stop 评估者判「做不到」的理由;界 500 码元(含截断记号);
|
|
16
|
+
* · `session-title`:自动标题器落行的会话标题(落库 / 列表面 / `session_titled` 帧同一份);界 80 码元(含截断记号),在 `title` 列宽之内。
|
|
13
17
|
*/
|
|
14
18
|
declare const EXIT_SEATS: {
|
|
15
19
|
readonly "trace-frame-text": {
|
|
@@ -22,15 +26,38 @@ declare const EXIT_SEATS: {
|
|
|
22
26
|
readonly "operator-log-text": {
|
|
23
27
|
readonly scope: "free-text";
|
|
24
28
|
readonly maxChars: 200;
|
|
25
|
-
readonly
|
|
29
|
+
readonly emit: "log-line";
|
|
26
30
|
};
|
|
27
31
|
readonly "operator-log-arg": {
|
|
28
32
|
readonly scope: "free-text";
|
|
29
33
|
readonly maxChars: 120;
|
|
30
|
-
readonly
|
|
34
|
+
readonly emit: "log-line";
|
|
35
|
+
};
|
|
36
|
+
readonly "operator-log-error": {
|
|
37
|
+
readonly scope: "free-text";
|
|
38
|
+
readonly maxChars: 300;
|
|
39
|
+
readonly emit: "log-line";
|
|
40
|
+
};
|
|
41
|
+
readonly "operator-log-message": {
|
|
42
|
+
readonly scope: "free-text";
|
|
43
|
+
readonly maxChars: 500;
|
|
44
|
+
readonly emit: "log-line";
|
|
45
|
+
};
|
|
46
|
+
readonly "session-title": {
|
|
47
|
+
readonly scope: "free-text";
|
|
48
|
+
readonly maxChars: 80;
|
|
49
|
+
readonly emit: "title-line";
|
|
31
50
|
};
|
|
32
51
|
};
|
|
33
52
|
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
53
|
+
/** 设了界的座名。 */
|
|
54
|
+
export type BoundedExitSeat = {
|
|
55
|
+
[K in ExitSeat]: (typeof EXIT_SEATS)[K] extends {
|
|
56
|
+
readonly maxChars: number;
|
|
57
|
+
} ? K : never;
|
|
58
|
+
}[ExitSeat];
|
|
59
|
+
/** 一行的界(码元;含截断记号)—— 界的唯一属主是座表,站点要用这个数(显示预算、文档钉)就读它,不另抄一份。 */
|
|
60
|
+
export declare function seatMaxChars(seat: BoundedExitSeat): number;
|
|
34
61
|
/**
|
|
35
62
|
* 出口座:`seat` 是座表的一行,`text` 是要出门的自由文本。返回的 {@link SafeText} 就是这个出口该写出去的字节。
|
|
36
63
|
* 表外的座名(只有绕过类型才到得了)⇒ 抛 —— 那是调用方的编程错,不是脱敏失败,不吞成占位。
|
package/dist/trace/exit-seat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stripControlAndBidi } from "@sema-agent/settings-schema";
|
|
2
2
|
import { CALLER_TEXT_CUT_MARK } from "../caller-text-echo.js";
|
|
3
3
|
import { errorKindOf } from "../observability/err-text.js";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
@@ -7,16 +7,22 @@ import { proposeRedactionSpans, REDACTION_TOKEN_RE_SRC } from "./redact.js";
|
|
|
7
7
|
const EXIT_SEATS = {
|
|
8
8
|
"trace-frame-text": { scope: "free-text" },
|
|
9
9
|
"trace-frame-line": { scope: "free-text", maxChars: 300 },
|
|
10
|
-
"operator-log-text": { scope: "free-text", maxChars: 200,
|
|
11
|
-
"operator-log-arg": { scope: "free-text", maxChars: 120,
|
|
10
|
+
"operator-log-text": { scope: "free-text", maxChars: 200, emit: "log-line" },
|
|
11
|
+
"operator-log-arg": { scope: "free-text", maxChars: 120, emit: "log-line" },
|
|
12
|
+
"operator-log-error": { scope: "free-text", maxChars: 300, emit: "log-line" },
|
|
13
|
+
"operator-log-message": { scope: "free-text", maxChars: 500, emit: "log-line" },
|
|
14
|
+
"session-title": { scope: "free-text", maxChars: 80, emit: "title-line" },
|
|
12
15
|
};
|
|
16
|
+
export function seatMaxChars(seat) {
|
|
17
|
+
return EXIT_SEATS[seat].maxChars;
|
|
18
|
+
}
|
|
13
19
|
const SEAT_ROWS = new Map(Object.entries(EXIT_SEATS));
|
|
14
20
|
for (const [name, row] of SEAT_ROWS) {
|
|
15
21
|
if (row.maxChars !== undefined && row.maxChars < OVERSIZED_REDACTION_PLACEHOLDER.length) {
|
|
16
22
|
throw new Error(`exit seat "${name}": maxChars ${row.maxChars} cannot hold the failure placeholder (${OVERSIZED_REDACTION_PLACEHOLDER.length} code units)`);
|
|
17
23
|
}
|
|
18
|
-
if (row.
|
|
19
|
-
throw new Error(`exit seat "${name}": a
|
|
24
|
+
if (row.emit !== undefined && row.maxChars === undefined) {
|
|
25
|
+
throw new Error(`exit seat "${name}": a row with an emission form must declare maxChars (the cut mark counts inside the bound)`);
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
function mergeSpans(spans) {
|
|
@@ -46,71 +52,39 @@ function cutPlain(gap, room) {
|
|
|
46
52
|
}
|
|
47
53
|
return gap.slice(0, cut);
|
|
48
54
|
}
|
|
49
|
-
function renderOnce(text, groups
|
|
55
|
+
function renderOnce(text, groups) {
|
|
50
56
|
const parts = [];
|
|
51
|
-
let len = 0;
|
|
52
57
|
let at = 0;
|
|
53
58
|
for (const g of groups) {
|
|
54
|
-
|
|
55
|
-
if (maxChars !== undefined && len + gap.length > maxChars)
|
|
56
|
-
return parts.join("") + cutPlain(gap, maxChars - len);
|
|
57
|
-
parts.push(gap);
|
|
58
|
-
len += gap.length;
|
|
59
|
-
if (maxChars !== undefined && len + g.repl.length > maxChars)
|
|
60
|
-
return parts.join("");
|
|
61
|
-
parts.push(g.repl);
|
|
62
|
-
len += g.repl.length;
|
|
59
|
+
parts.push(text.slice(at, g.start), g.repl);
|
|
63
60
|
at = g.end;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
parts.push(maxChars === undefined || len + tail.length <= maxChars ? tail : cutPlain(tail, maxChars - len));
|
|
62
|
+
parts.push(text.slice(at));
|
|
67
63
|
return parts.join("");
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (; at < mark; at++)
|
|
84
|
-
if (STRIPPED_UNIT[text.charCodeAt(at)] === 1)
|
|
85
|
-
removed += 1;
|
|
86
|
-
strippedBefore.set(mark, mark - removed);
|
|
65
|
+
function emitAs(form, text) {
|
|
66
|
+
switch (form) {
|
|
67
|
+
case "log-line":
|
|
68
|
+
return stripControlAndBidi(text);
|
|
69
|
+
case "title-line":
|
|
70
|
+
return stripControlAndBidi(text.replace(/[\r\n]+/g, " "))
|
|
71
|
+
.trim()
|
|
72
|
+
.replace(/^["'「『]+/, "")
|
|
73
|
+
.replace(/["'」』]+$/, "")
|
|
74
|
+
.trim();
|
|
75
|
+
default: {
|
|
76
|
+
const unhandled = form;
|
|
77
|
+
throw new Error(`exit seat: unhandled emission form ${String(unhandled)}`);
|
|
78
|
+
}
|
|
87
79
|
}
|
|
88
|
-
const mapped = [];
|
|
89
|
-
for (const sp of spans) {
|
|
90
|
-
const start = strippedBefore.get(sp.start);
|
|
91
|
-
const end = strippedBefore.get(sp.end);
|
|
92
|
-
if (end > start)
|
|
93
|
-
mapped.push({ start, end, repl: sp.repl });
|
|
94
|
-
}
|
|
95
|
-
return mapped;
|
|
96
|
-
}
|
|
97
|
-
function proposeLogFieldSpans(text, scope) {
|
|
98
|
-
const read = stripControlAndBidi(text);
|
|
99
|
-
if (read === text)
|
|
100
|
-
return { read, spans: proposeRedactionSpans(text, scope) };
|
|
101
|
-
if (read.length === 0)
|
|
102
|
-
return { read, spans: [] };
|
|
103
|
-
const original = proposeRedactionSpans(text, scope);
|
|
104
|
-
const stripped = proposeRedactionSpans(read, scope, { countHits: original.length === 0 });
|
|
105
|
-
return { read, spans: [...stripped, ...mapSpansIntoStripped(text, original)] };
|
|
106
80
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
return
|
|
113
|
-
return
|
|
81
|
+
const layoutOf = (row) => (row.emit === undefined ? "multi-line" : "single-line");
|
|
82
|
+
function boundRow(out, row) {
|
|
83
|
+
if (row.maxChars === undefined || out.length <= row.maxChars)
|
|
84
|
+
return out;
|
|
85
|
+
if (row.emit === undefined)
|
|
86
|
+
return cutPlain(out, row.maxChars);
|
|
87
|
+
return cutPlain(out, row.maxChars - CALLER_TEXT_CUT_MARK.length) + CALLER_TEXT_CUT_MARK;
|
|
114
88
|
}
|
|
115
89
|
export function seatText(seat, text) {
|
|
116
90
|
const row = SEAT_ROWS.get(seat);
|
|
@@ -118,8 +92,12 @@ export function seatText(seat, text) {
|
|
|
118
92
|
throw new Error(`exit seat: ${JSON.stringify(seat)} is not a row of the seat table`);
|
|
119
93
|
let out;
|
|
120
94
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
95
|
+
if (row.emit !== undefined && emitAs(row.emit, text) === "")
|
|
96
|
+
out = "";
|
|
97
|
+
else {
|
|
98
|
+
const rendered = renderOnce(text, mergeSpans(proposeRedactionSpans(text, row.scope, layoutOf(row))));
|
|
99
|
+
out = boundRow(row.emit === undefined ? rendered : emitAs(row.emit, rendered), row);
|
|
100
|
+
}
|
|
123
101
|
}
|
|
124
102
|
catch (err) {
|
|
125
103
|
recordFailOpen("server.run-terminal.redact-threw", `seat=${seat} len=${typeof text === "string" ? text.length : -1} err=${errorKindOf(err)}`);
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
* · **腿自己的带外行**:park/终局/失败/建议/用量/装配自证(不来自流事件)。
|
|
33
33
|
*/
|
|
34
34
|
export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" | "status" | "context_usage" | "compacted" | "diagnostics" | "steering_injected" | "compaction_outcome"
|
|
35
|
-
/**
|
|
35
|
+
/** [ref](core 7.53.0 [ref]):压缩 pass 的开始帧(`{ trigger, pass, startedAt }`;结束帧带同一个 `pass`)。原样落账,两条 durable 腿同源。 */
|
|
36
36
|
| "compaction_started" | "workspace_changed" | "wiring_manifest"
|
|
37
|
-
/**
|
|
37
|
+
/** [ref](7.71.0):运行期名册变更(core 7.8.0 [ref] ⑪)。**快照语义**——`delta.roster` 是整只
|
|
38
38
|
* 变更后名册,消费端收到即整只替换,所以回放不需要任何合并;它的耐久面因此不是 `wiring_manifest.tools`
|
|
39
39
|
* 的重复,而是那份开腿快照**之后**的每一次改动(修前两条 durable 腿零 case ⇒ 回放只见开头一版)。 */
|
|
40
40
|
| "tool_roster_delta"
|
|
@@ -95,7 +95,7 @@ export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" |
|
|
|
95
95
|
export declare const PARK_LEDGER_EVENT_TYPES: readonly ["suspended", "needs_review"];
|
|
96
96
|
export type ParkLedgerEventType = (typeof PARK_LEDGER_EVENT_TYPES)[number];
|
|
97
97
|
/**
|
|
98
|
-
* 🔴 **模型自由文本行名的运行时闭集**(
|
|
98
|
+
* 🔴 **模型自由文本行名的运行时闭集**([ref] / [ref])—— 与 {@link PARK_LEDGER_EVENT_TYPES} 同一条理由、
|
|
99
99
|
* 同一种锁步形。
|
|
100
100
|
*
|
|
101
101
|
* 这两行(`text` = 模型写给用户的文本,`reasoning` = 同一支笔的 CoT)是账本上**唯二**逐字携带模型散文的型,
|
|
@@ -152,7 +152,7 @@ export declare function createLedgerSink(opts: {
|
|
|
152
152
|
* 各传自己看得见的那个词(位①=流事件 `ev.type`,位②=账本行 `type`);拿不到类型的打点方
|
|
153
153
|
* (core 的 onActivity 第五席、resume 腿手动打点)省参,`kind` 诚实缺席(见 turn-activity.ts)。 */
|
|
154
154
|
onActivity?: (kind?: string, statusData?: Record<string, unknown>) => void;
|
|
155
|
-
/**
|
|
155
|
+
/** [ref]:这条腿的 `wiring_manifest.instructions` 段(腿的 `InstructionSelectionLeg.segment`)。**必填**:账本行与 live 帧是
|
|
156
156
|
* 同一条腿的两个载体,段必须来自同一只腿;在投帧那一刻读(core 推帧之前已 await 过 loader)。返回 `undefined` ⇒ 段缺席。 */
|
|
157
157
|
instructionsSegment: () => InstructionsSegment | undefined;
|
|
158
158
|
}): LedgerSink;
|
|
@@ -7,7 +7,7 @@ import { type SegmentEndFields } from "./project.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function isModelSegmentBoundary(type: string): boolean;
|
|
9
9
|
/** live 面的段末帧(`type` 即事件名;其余键由 `reasoningEndEventData` 白名单铸出)。
|
|
10
|
-
* 形是**声明**出来的、不是 `Record<string, unknown>`(
|
|
10
|
+
* 形是**声明**出来的、不是 `Record<string, unknown>`([ref] 门①):`eventId` 是本帧的续流游标,
|
|
11
11
|
* 型必须说得出口 —— live 腿的 `id:` 行取的正是它。 */
|
|
12
12
|
export type ReasoningEndFrame = SegmentEndFields & {
|
|
13
13
|
type: "reasoning_end";
|
|
@@ -54,7 +54,7 @@ export interface ReasoningSegments {
|
|
|
54
54
|
/**
|
|
55
55
|
* 一段推理的**段末事件 id** —— 唯一铸点,live 段末帧与账本 `reasoning` 行共用这一只。
|
|
56
56
|
*
|
|
57
|
-
* 🔴 **为什么段末帧不能沿用任何一块 delta 的 `eventId`**(
|
|
57
|
+
* 🔴 **为什么段末帧不能沿用任何一块 delta 的 `eventId`**([ref]):SSE 的 `id:` 行是**续流游标**,
|
|
58
58
|
* 「每帧唯一」就是它的定义(消费端据它做**整帧幂等**:见过的 id 整帧丢);而本仓 live 腿的 `id:` 行
|
|
59
59
|
* 恰恰取自载荷的 `eventId`(`http/routes/tasks.ts` 的 `sseData`)。沿用段内某一块的锚 ⇒ 段末帧与那一块
|
|
60
60
|
* delta 顶着同一枚游标,消费端把**权威段**当重放帧丢弃 —— 本帧存在的唯一理由(整段脱敏后的权威副本)
|
|
@@ -74,7 +74,7 @@ export interface ReasoningSegments {
|
|
|
74
74
|
export declare function reasoningSegmentEventId(anchor: unknown): string | undefined;
|
|
75
75
|
/** 一块 `reasoning_delta` 对段的**贡献字节** —— 非空串才算。账本腿与三条 live 腿共用这一只:空/坏形
|
|
76
76
|
* 增量一个字节都不贡献,既不开段也不参与闩锚 ⇒ 两面结构上不可能把锚闩在不同的帧上(`reasoning_end`
|
|
77
|
-
* 与账本 `reasoning` 行的正文早就逐字节相等,身份面随
|
|
77
|
+
* 与账本 `reasoning` 行的正文早就逐字节相等,身份面随 [ref] 收进同一条规则)。 */
|
|
78
78
|
export declare function reasoningDeltaBytes(ev: {
|
|
79
79
|
delta?: unknown;
|
|
80
80
|
}): string | undefined;
|