@sema-agent/server 7.133.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 +221 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/USAGE.md +222 -36
- package/deploy/sema-up/README.md +16 -0
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
- package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +14 -0
- package/deploy/sema-up/chart/templates/server.yaml +14 -0
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- package/dist/adoption/plan.d.ts +1 -1
- package/dist/approval-ask-audit-store.d.ts +25 -25
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +66 -154
- package/dist/approval-card.js +33 -52
- package/dist/approval-content-kind.d.ts +26 -6
- package/dist/approval-content-kind.js +23 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +91 -0
- package/dist/approval-gate-currency.js +120 -0
- 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 +14 -8
- package/dist/approval.js +35 -16
- 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 +7 -2
- package/dist/boot/coordinators.js +8 -5
- 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 +2 -0
- package/dist/boot/leader.js +2 -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/read-deny-anchor-audit.js +2 -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 +29 -16
- package/dist/boot/runner-deps.js +12 -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.d.ts +4 -3
- package/dist/boot/stage-06-runners.js +15 -4
- package/dist/boot/stage-07-capability-layer.d.ts +2 -1
- package/dist/boot/stage-08-reapers.d.ts +2 -1
- package/dist/boot/stage-09-leader.d.ts +2 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +2 -1
- package/dist/boot/stage-10-http-server.js +2 -1
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -13
- package/dist/boot/web-admin.d.ts +21 -15
- package/dist/boot/web-admin.js +16 -12
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/budget.d.ts +4 -4
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +2 -0
- package/dist/caller-text-echo.js +2 -1
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- 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 +2 -2
- package/dist/capabilities/composite-members.js +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/mcp-probe.js +2 -2
- 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 +27 -24
- package/dist/capability-facts.js +18 -20
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +4 -4
- package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
- package/dist/checkpoint-ctx-seal-m28.js +19 -0
- package/dist/checkpoint-identity.d.ts +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/field-conflict.d.ts +2 -1
- package/dist/field-conflict.js +1 -0
- package/dist/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +50 -9
- package/dist/file-history-disclosure.js +8 -13
- package/dist/fleet/drain-entry.d.ts +2 -2
- package/dist/fleet/fleet-bus.d.ts +26 -14
- package/dist/fleet/fleet-bus.js +6 -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 +38 -20
- 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 +28 -5
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +5 -2
- package/dist/http/checkpoint-ctx.d.ts +183 -2
- package/dist/http/checkpoint-ctx.js +197 -2
- package/dist/http/dispatch.d.ts +3 -3
- package/dist/http/dispatch.js +3 -3
- package/dist/http/durable-run-leg.js +7 -5
- package/dist/http/idempotency.d.ts +4 -4
- package/dist/http/idempotency.js +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 +39 -13
- package/dist/http/principal-gate.js +30 -6
- package/dist/http/readiness.d.ts +1 -1
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +4 -13
- package/dist/http/request-guards.js +4 -17
- package/dist/http/resume-ctx-read.d.ts +53 -6
- package/dist/http/resume-ctx-read.js +26 -3
- package/dist/http/resume-legs.d.ts +5 -4
- package/dist/http/resume-legs.js +47 -29
- package/dist/http/route-ctx.d.ts +29 -38
- package/dist/http/route-table.d.ts +9 -9
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +5 -5
- package/dist/http/routes/approvals-assistant.js +91 -17
- 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 +6 -6
- package/dist/http/routes/diagnostics.js +1 -1
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/fleet.js +5 -4
- 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/memory-origin.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/rules.js +4 -4
- package/dist/http/routes/runs.js +44 -11
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +109 -62
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +4 -5
- package/dist/http/routes/sessions.js +34 -48
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/tasks.js +21 -16
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/trace-usage.js +7 -9
- 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 +39 -33
- package/dist/http/server.js +5 -2
- 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.d.ts +4 -3
- package/dist/http/submit-ctx.js +19 -3
- 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 +35 -24
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- 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 +9 -5
- package/dist/leader/wire.js +8 -7
- package/dist/list-entry-display.d.ts +1 -1
- package/dist/lsp-evict.d.ts +1 -1
- package/dist/main.js +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-origin-fence.js +2 -2
- 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-compat.d.ts +1 -1
- 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/prompt-manifest.d.ts +19 -8
- package/dist/observability/prompt-manifest.js +9 -8
- 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/observability/tool-trace.js +8 -9
- 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/orchestration/workflow-park-decision.d.ts +1 -1
- package/dist/orchestration/workflow-park-decision.js +1 -0
- package/dist/outbound-dispatcher.d.ts +4 -4
- package/dist/parent-watch.d.ts +4 -4
- package/dist/parked-decide.d.ts +20 -20
- package/dist/parked-decide.js +8 -5
- 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 +3 -25
- package/dist/permission-rule-vocab.js +0 -13
- 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/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- 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 +24 -33
- package/dist/plugins/caching-session-store.js +8 -19
- 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 +66 -67
- package/dist/plugins/checkpoint-store-sql.js +100 -103
- 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 +23 -12
- package/dist/plugins/local-checkpoint-store.js +29 -4
- package/dist/plugins/local-session-store.d.ts +44 -45
- package/dist/plugins/local-session-store.js +42 -52
- package/dist/plugins/local-session-window.d.ts +12 -6
- package/dist/plugins/local-session-window.js +1 -17
- 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 +76 -39
- package/dist/plugins/one-time-migrations.js +127 -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 +16 -19
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
- package/dist/plugins/permission-rule-store-sql.js +74 -31
- 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 +9 -21
- package/dist/plugins/pg-session-storage.js +51 -42
- package/dist/plugins/remote-env-adb.d.ts +10 -10
- package/dist/plugins/remote-env-device.d.ts +22 -14
- package/dist/plugins/remote-env-device.js +28 -16
- 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.d.ts +11 -0
- package/dist/plugins/session-ownership.js +11 -0
- package/dist/plugins/session-placement.d.ts +12 -14
- package/dist/plugins/session-placement.js +2 -15
- package/dist/plugins/session-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 +17 -27
- package/dist/plugins/tidb-session-store.js +52 -42
- 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-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- 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/run-local.js +1 -0
- package/dist/runs.d.ts +15 -12
- package/dist/runs.js +19 -4
- 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 +34 -2
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +31 -32
- 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 +19 -12
- package/dist/session-error-wire.js +4 -1
- 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 +38 -11
- package/dist/session-sync-kernel.js +10 -0
- 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 +38 -5
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +14 -10
- package/dist/task-mcp.js +39 -12
- package/dist/task-settings.d.ts +34 -18
- package/dist/task-settings.js +34 -4
- 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 +273 -228
- package/dist/tool-approval.js +125 -47
- package/dist/tool-rule-names.d.ts +7 -1
- package/dist/trace/core-keyset-guard.d.ts +15 -9
- 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 +40 -1
- package/dist/trace/exit-seat.js +46 -14
- package/dist/trace/ledger-events.d.ts +6 -4
- package/dist/trace/ledger-sink.d.ts +1 -1
- package/dist/trace/model-segment.d.ts +3 -3
- package/dist/trace/project.d.ts +65 -46
- package/dist/trace/project.js +49 -5
- package/dist/trace/redact.d.ts +44 -27
- package/dist/trace/redact.js +343 -73
- package/dist/trace/self-minted-wire.d.ts +39 -14
- package/dist/trace/self-minted-wire.js +9 -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 +9 -3
- package/dist/trace/wire-projection-faces.js +7 -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 +29 -4
- package/dist/web-admin-client/skills-mcp.js +31 -4
- package/dist/web-admin-client/types.d.ts +17 -10
- 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 +35 -2
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/skills/loop.md +1 -1
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -104
- package/dist/orchestration/workflow-journal-entry.js +0 -27
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AcquiredSession, type PlacedSessionRow, type RetentionDeclaration, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
|
|
2
2
|
import type { OwnerAwareSessionStore, SessionListItem } from "../security.js";
|
|
3
3
|
import type { StagingHandle } from "../session-sync-kernel.js";
|
|
4
4
|
import { type PlacementAcquireOpts } from "./session-placement.js";
|
|
5
5
|
import type { InstructionSourceStore } from "../instruction-source-notice.js";
|
|
6
|
-
import type { SessionFaceReader } from "../session-incarnation.js";
|
|
7
6
|
import type { OwnerlessClaim } from "../delegated-session-owner.js";
|
|
8
7
|
export interface CachingOptions {
|
|
9
8
|
/** Idle seconds a woken session is kept warm. 0 disables caching (pure passthrough). */
|
|
10
9
|
ttlSec: number;
|
|
11
10
|
sweepIntervalMs?: number;
|
|
12
|
-
/** Called once per warm hit that turned out stale (the store's head no longer names the cached leaf, or the
|
|
13
|
-
* gone): the entry was dropped and the session woken from the store again. Not an error — the operator signal for
|
|
11
|
+
/** Called once per warm hit that turned out stale (the store's head no longer names the cached occupant and leaf, or the
|
|
12
|
+
* session is gone): the entry was dropped and the session woken from the store again. Not an error — the operator signal for
|
|
14
13
|
* "requests for one session alternate between replicas within the TTL" (the hit rate affinity would buy back). */
|
|
15
14
|
onStaleHit?: (sessionId: string) => void;
|
|
16
15
|
}
|
|
17
|
-
/** The store's current head for one session — the one read every warm hit is checked
|
|
18
|
-
*
|
|
19
|
-
export type SessionHeadReader = Required<Pick<
|
|
16
|
+
/** The store's current head for one session — core `SessionStore.headOf`, the one by-id read of the row every warm hit is checked
|
|
17
|
+
* against (`undefined` = no such session). This cache requires its inner store to have it. */
|
|
18
|
+
export type SessionHeadReader = Required<Pick<SessionStore, "headOf">>;
|
|
20
19
|
/**
|
|
21
20
|
* Warm cache in front of a durable {@link SessionStore}.
|
|
22
21
|
*
|
|
23
22
|
* Keeps a woken session in memory and **reuses the same storage instance across turns**, so an active session is not
|
|
24
23
|
* woken from the store (meta row + event log) on every short turn. Idle sessions expire after `ttlSec`; `release` evicts.
|
|
25
24
|
*
|
|
26
|
-
* **One rule: a warm entry is served only while the store's head for that session still names the
|
|
27
|
-
* holds.** Every hit reads the head first (`
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
25
|
+
* **One rule: a warm entry is served only while the store's head for that session still names the occupant and the leaf
|
|
26
|
+
* the entry holds.** Every hit reads the head first (`headOf` — one primary-key row read on the SQL twins); head gone, another
|
|
27
|
+
* occupant (core `compareOccupants` — anything but `same`, `unknown` included), or leaf moved ⇒ the entry is dropped and the
|
|
28
|
+
* session is woken from the store again ({@link CachingOptions.onStaleHit}). The leaf is half the token because it is exactly
|
|
29
|
+
* what the stores' conditional writes compare (`expectedLeafId`): a handle this cache hands out is never behind the store's
|
|
30
|
+
* leaf, so those writes fail only on a genuinely concurrent write — two runs writing one session at the same time. The
|
|
31
|
+
* occupant is the other half: a row another replica deleted and created again under the same id can stand at the leaf the
|
|
32
|
+
* entry holds (both empty — `null`), and serving the old view would hand a run the previous occupant's token. Any number of
|
|
33
|
+
* replicas may share one store under any routing; session affinity only raises the hit rate.
|
|
33
34
|
*
|
|
34
35
|
* Open item (the same before this rule): a write that rewrites history while leaving the final leaf id where it was —
|
|
35
36
|
* a session-sync replace / `overwrite-dst` staged commit on ANOTHER replica that changes entry payloads under the same
|
|
@@ -50,17 +51,12 @@ export declare class CachingSessionStore implements SessionStore {
|
|
|
50
51
|
private readonly ttlMs;
|
|
51
52
|
private readonly timer?;
|
|
52
53
|
private readonly onStaleHit?;
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* 与记忆座在默认部署上读不到化身。 */
|
|
58
|
-
readonly sessionFaceOf?: SessionFaceReader;
|
|
59
|
-
/** core `SessionStore.incarnationOf`(按 id 读住客)—— 同一条纯转发、同一条理由:答的是行上那一格,绝不从暖缓存里那只会话的元数据答
|
|
60
|
-
* (缓存的会话活得比「另一只店删掉又重建了这一行」长)。🔴 必须转发:k8s 工作区空间的每 run 读与起服门读的就是本类。 */
|
|
61
|
-
readonly incarnationOf?: SessionStore["incarnationOf"];
|
|
54
|
+
/** core `SessionStore.headOf` —— 按 id 读一行(属主 / 住客 / 叶子)的唯一读口,**纯转发、不经暖缓存**(答的是行,绝不从暖缓存里那只会话的元数据答 ——
|
|
55
|
+
* 缓存的会话活得比「另一只店删掉又重建了这一行」长)。内层店必有(本类的暖命中按它核新鲜)。🔴 必须转发:生产默认把真店包进本类,授权口 / 属主门 /
|
|
56
|
+
* parked 两读 / k8s 工作区空间 / SSE 探针 / resume-at 读的都是本类。 */
|
|
57
|
+
readonly headOf: SessionHeadReader["headOf"];
|
|
62
58
|
readonly register?: (sessionId: string, owner: string | null) => Promise<void>;
|
|
63
|
-
/**
|
|
59
|
+
/** [ref] 委派继承律的认领口,纯转发(写的是行上的属主那一格 —— 只 CAS 子行自己,不碰暖缓存里的会话;停驻挂点在默认部署上读的就是本类 —— 与 `placementOf` 同转发同缺:内店记录委派树 ⇒ 两只都在)。 */
|
|
64
60
|
readonly claimOwnerless?: OwnerlessClaim;
|
|
65
61
|
/** Delegated SessionRepo seam (§0.5) — list/fork/delete operate on the DURABLE tables directly (they bypass the
|
|
66
62
|
* warm cache by design; a fork/delete must read/write durable state, not a possibly-stale cached view). */
|
|
@@ -84,16 +80,11 @@ export declare class CachingSessionStore implements SessionStore {
|
|
|
84
80
|
/** The auto-titler's NULL-only title write (SQL twins + local sidecar carry it; pure pass-through). */
|
|
85
81
|
readonly setTitleIfNull?: (sessionId: string, title: string) => Promise<boolean>;
|
|
86
82
|
readonly probeTitle?: (sessionId: string) => Promise<"none" | "untitled" | "titled">;
|
|
87
|
-
/**
|
|
83
|
+
/** [ref] —— 换源通告的基线面(`session_meta.instruction_source` / local sidecar),纯转发、不经暖缓存。
|
|
88
84
|
* 🔴 必须转发(与 retention / placements 同一条教训):默认 `SESSION_CACHE_TTL_SEC=300` 把真店包进本类,
|
|
89
85
|
* 而装配点按「店上两个方法都在」判席 —— 不转发 = 默认部署上换源通告**静默不发**,且没有任何一处报错。 */
|
|
90
86
|
readonly readInstructionSource?: InstructionSourceStore["readInstructionSource"];
|
|
91
87
|
readonly recordInstructionSource?: InstructionSourceStore["recordInstructionSource"];
|
|
92
|
-
/** E18 — delegate the leaf read straight to inner (a cache-bypassing single SELECT; the resume-at turn-capture
|
|
93
|
-
* reads the DURABLE leaf, not a possibly-stale cached view — same discipline as the §0.5 repo ops above). */
|
|
94
|
-
readonly getLeafId?: (sessionId: string) => Promise<string | null>;
|
|
95
|
-
/** [ref] 六轮复审:owner+leafId 原子快照透传(cache-bypassing,getLeafId 同姿势)。内层店必有(本类的暖命中按它核新鲜)。 */
|
|
96
|
-
readonly getHead: SessionHeadReader["getHead"];
|
|
97
88
|
/** 2c session-sync — delegated export/import seam, DURABLE (bypasses the warm cache exactly like
|
|
98
89
|
* list/fork: an export reads the full durable log, an import writes durable state). */
|
|
99
90
|
readonly exportEntries?: (sessionId: string) => Promise<SessionTreeEntry[] | null>;
|
|
@@ -154,9 +145,9 @@ export declare class CachingSessionStore implements SessionStore {
|
|
|
154
145
|
touch(sessionId: string): Promise<void>;
|
|
155
146
|
release(sessionId: string): Promise<void>;
|
|
156
147
|
/**
|
|
157
|
-
* The cache's one rule: the warm entry for `sessionId`, if the store's head still names the leaf it holds;
|
|
158
|
-
* the entry is dropped (counted once via `onStaleHit`) and `undefined` sends the caller to the store. The head is
|
|
159
|
-
* first, the cached
|
|
148
|
+
* The cache's one rule: the warm entry for `sessionId`, if the store's head still names the occupant and the leaf it holds;
|
|
149
|
+
* otherwise the entry is dropped (counted once via `onStaleHit`) and `undefined` sends the caller to the store. The head is
|
|
150
|
+
* read first, the cached view second: a write this replica commits in between can only turn a fresh verdict into a stale
|
|
160
151
|
* one (an extra wake), never the reverse.
|
|
161
152
|
*/
|
|
162
153
|
private freshHit;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { admitSessionPlacement, compareOccupants } from "@sema-agent/core";
|
|
2
|
+
import { placementCapabilityOf } from "./session-placement.js";
|
|
2
3
|
export class CachingSessionStore {
|
|
3
4
|
inner;
|
|
4
5
|
cache = new Map();
|
|
@@ -6,9 +7,7 @@ export class CachingSessionStore {
|
|
|
6
7
|
ttlMs;
|
|
7
8
|
timer;
|
|
8
9
|
onStaleHit;
|
|
9
|
-
|
|
10
|
-
sessionFaceOf;
|
|
11
|
-
incarnationOf;
|
|
10
|
+
headOf;
|
|
12
11
|
register;
|
|
13
12
|
claimOwnerless;
|
|
14
13
|
listSessions;
|
|
@@ -20,8 +19,6 @@ export class CachingSessionStore {
|
|
|
20
19
|
probeTitle;
|
|
21
20
|
readInstructionSource;
|
|
22
21
|
recordInstructionSource;
|
|
23
|
-
getLeafId;
|
|
24
|
-
getHead;
|
|
25
22
|
exportEntries;
|
|
26
23
|
listEntryIds;
|
|
27
24
|
exportEntriesStream;
|
|
@@ -38,7 +35,7 @@ export class CachingSessionStore {
|
|
|
38
35
|
this.inner = inner;
|
|
39
36
|
this.ttlMs = Math.max(0, opts.ttlSec) * 1000;
|
|
40
37
|
this.onStaleHit = opts.onStaleHit;
|
|
41
|
-
this.
|
|
38
|
+
this.headOf = inner.headOf.bind(inner);
|
|
42
39
|
const declared = inner.retention;
|
|
43
40
|
if (declared !== undefined)
|
|
44
41
|
this.retention = declared;
|
|
@@ -50,12 +47,6 @@ export class CachingSessionStore {
|
|
|
50
47
|
if (typeof innerPlacementOf === "function")
|
|
51
48
|
this.placementOf = (id) => innerPlacementOf.call(inner, id);
|
|
52
49
|
const ownerAware = inner;
|
|
53
|
-
if (ownerAware.ownerOf)
|
|
54
|
-
this.ownerOf = ownerAware.ownerOf.bind(inner);
|
|
55
|
-
if (ownerAware.sessionFaceOf)
|
|
56
|
-
this.sessionFaceOf = ownerAware.sessionFaceOf.bind(inner);
|
|
57
|
-
if (typeof inner.incarnationOf === "function")
|
|
58
|
-
this.incarnationOf = inner.incarnationOf.bind(inner);
|
|
59
50
|
if (ownerAware.register)
|
|
60
51
|
this.register = ownerAware.register.bind(inner);
|
|
61
52
|
if (ownerAware.claimOwnerless)
|
|
@@ -76,8 +67,6 @@ export class CachingSessionStore {
|
|
|
76
67
|
this.recordInstructionSource = ownerAware.recordInstructionSource.bind(inner);
|
|
77
68
|
if (ownerAware.fork)
|
|
78
69
|
this.fork = ownerAware.fork.bind(inner);
|
|
79
|
-
if (ownerAware.getLeafId)
|
|
80
|
-
this.getLeafId = ownerAware.getLeafId.bind(inner);
|
|
81
70
|
if (ownerAware.exportEntries)
|
|
82
71
|
this.exportEntries = ownerAware.exportEntries.bind(inner);
|
|
83
72
|
if (ownerAware.listEntryIds)
|
|
@@ -144,7 +133,7 @@ export class CachingSessionStore {
|
|
|
144
133
|
}
|
|
145
134
|
const hit = await this.freshHit(sessionId);
|
|
146
135
|
if (hit && opts?.requireExisting !== true && this.placements !== undefined && this.placementOf !== undefined) {
|
|
147
|
-
|
|
136
|
+
admitSessionPlacement(sessionId, await this.placementOf(sessionId), opts ?? {}, placementCapabilityOf(this));
|
|
148
137
|
}
|
|
149
138
|
if (hit) {
|
|
150
139
|
hit.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -159,7 +148,7 @@ export class CachingSessionStore {
|
|
|
159
148
|
if (inflight) {
|
|
160
149
|
const acquired = await inflight;
|
|
161
150
|
if (this.placements !== undefined && this.placementOf !== undefined) {
|
|
162
|
-
|
|
151
|
+
admitSessionPlacement(sessionId, await this.placementOf(sessionId), opts ?? {}, placementCapabilityOf(this));
|
|
163
152
|
}
|
|
164
153
|
return acquired;
|
|
165
154
|
}
|
|
@@ -187,8 +176,8 @@ export class CachingSessionStore {
|
|
|
187
176
|
const hit = this.cache.get(sessionId);
|
|
188
177
|
if (hit === undefined)
|
|
189
178
|
return undefined;
|
|
190
|
-
const head = await this.inner.
|
|
191
|
-
if (head !== undefined && head.leafId === (await hit.acquired.session.getLeafId()))
|
|
179
|
+
const head = await this.inner.headOf(sessionId);
|
|
180
|
+
if (head !== undefined && compareOccupants(head, await hit.acquired.session.getMetadata()) === "same" && head.leafId === (await hit.acquired.session.getLeafId()))
|
|
192
181
|
return hit;
|
|
193
182
|
if (this.cache.get(sessionId) === hit)
|
|
194
183
|
this.cache.delete(sessionId);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `checkpoint` 表的**索引列**:怎么写(一只派生)、到期 facet 怎么从列上读(一只生成谓词)。SQL 两孪生的写口(`checkpoint-store-sql.ts` `put`)、
|
|
3
|
+
* 一次性迁移 M29 的存量回填(`one-time-migrations.ts`)与到期两条腿(`reapExpired` / `listExpiredApprovalGates`)都只读本模块。
|
|
4
|
+
*
|
|
5
|
+
* ## 写:一只派生 = core `checkpointIndexFacts(cp)`(core 7.55.0 [ref] P1 阶段二)
|
|
6
|
+
* 行上「core 铸下、此后不动」的十三个事实(令牌、scope、会话、格式版本、门型、卡、待决工具的名 / 调用 id / 入参摘要、deadline、铸行时刻、风险描述符、
|
|
7
|
+
* 双向控制字符在场位),每一个都由 core 那一只函数答;本模块只把它们落到列名下({@link buildCheckpointIndexCells})。修前写口自己从寄存行 / 门上逐格读,
|
|
8
|
+
* 对任何寄存臂、任何门都不分臂 —— 与 core 读法在契约外的行上答两样(计划门上的卡、审阅寄存行上的工具位)。键表对 core 的事实键闭合
|
|
9
|
+
* ({@link CHECKPOINT_INDEX_COLUMNS} `satisfies Record<keyof CheckpointIndexFacts, …>`):core 加 / 删一个事实 ⇒ 编译红,由人决定它落不落列。
|
|
10
|
+
* 不在这里的:CAS 面推动的状态(`status` / `rev` / `reopen_reason` / 执行记录)、部署铸的值(`terminal_at_ms` 兜底)、部署截长脱敏的展示投影(`tool_input` /
|
|
11
|
+
* `rule_suggestions`)—— 它们不是行的不变事实,core 也不答。
|
|
12
|
+
*
|
|
13
|
+
* ## 读:到期 facet 是由 core 两张表**生成**的一条 SQL 表达式
|
|
14
|
+
* facet = 部署收割器对一行的 deadline 的读法(`A` = 审批门,deadline 是 SLA 拒;`B` = 无人值守 TTL,到期作废;`-` = 非门停驻)。core 的判官是
|
|
15
|
+
* `facetOf(gate)`:门上的卡是 `CARD_FACET_OVERRIDES` 的键 ⇒ 那个键的 facet,否则门型在 `PAUSE_REGISTRY` 的 `facet` 列。列上存的是卡词本身
|
|
16
|
+
* (`approval_card`,不是 facet —— 存一份 facet 会在 core 改表那天陈旧),谓词由那两张表机械生成({@link CHECKPOINT_FACET_CASES} → {@link CHECKPOINT_FACET_SQL}),
|
|
17
|
+
* 逐行与 `facetOf` 同答(`test/checkpoint-index-columns.test.ts` B 节、db 组同名文件)。本仓不写第二份判据:没有手写门型表、没有手写卡词。
|
|
18
|
+
* 卡那一侧不带「是不是审批门」的合取:列上的卡只在审批门上非 NULL(同一只派生),与 core 对生成谓词的成文形逐字相同。未登记门型 / NULL 门型 ⇒ 表达式 NULL(无 ELSE)。
|
|
19
|
+
*
|
|
20
|
+
* ## 谓词什么时候开
|
|
21
|
+
* core 的迁移条款:存量行的卡列由同一只函数回填,并且只在部署自己记下「回填跑完了」之后才开生成谓词。本仓的记录 = 起服序列:M29 跑在一次性迁移段
|
|
22
|
+
* (`boot/stores.ts`,先于任何路由与收割器装配),跑不完就拒启 —— 所以每只副本的收割器只在本次起服的 M29 完成之后才运行。混跑期间旧副本新写的行
|
|
23
|
+
* 不带卡列(它们不认这一列),由下一次起服的 M29 补上;升级序见 MIGRATION 7.135.0 节(同一只库不混跑两版)。
|
|
24
|
+
*/
|
|
25
|
+
import { PAUSE_REGISTRY, type Checkpoint, type CheckpointIndexFacts, type GateKind, type RiskDescriptor } from "@sema-agent/core";
|
|
26
|
+
import type { SqlDialect } from "./sql-driver.js";
|
|
27
|
+
/** 每个索引事实落在哪一列(键表对 core 的事实键闭合:core 加 / 删一个事实 ⇒ 编译红)。 */
|
|
28
|
+
export declare const CHECKPOINT_INDEX_COLUMNS: {
|
|
29
|
+
readonly token: "token";
|
|
30
|
+
readonly scope: "scope";
|
|
31
|
+
readonly sessionId: "session_id";
|
|
32
|
+
readonly version: "version";
|
|
33
|
+
readonly gateKind: "gate_kind";
|
|
34
|
+
readonly approvalCard: "approval_card";
|
|
35
|
+
readonly toolName: "tool_name";
|
|
36
|
+
readonly toolCallId: "tool_call_id";
|
|
37
|
+
readonly boundInputHash: "bound_input_hash";
|
|
38
|
+
readonly deadline: "deadline";
|
|
39
|
+
readonly createdAt: "created_at_ms";
|
|
40
|
+
readonly riskDescriptor: "risk_descriptor";
|
|
41
|
+
readonly hasBidiControls: "has_bidi_controls";
|
|
42
|
+
};
|
|
43
|
+
type IndexColumnOf<K extends keyof CheckpointIndexFacts> = (typeof CHECKPOINT_INDEX_COLUMNS)[K];
|
|
44
|
+
/**
|
|
45
|
+
* 一行的索引列格:core 的事实落在列名下。值逐字是事实本身,只有一处换形:双向控制字符在场位落 `1` 或 NULL(列是 TINYINT / SMALLINT,恒不写 0 —— core 的契约
|
|
46
|
+
* 是「`true` 或缺席」,0 会把「没检出」谎成「已确认干净」)。描述符是行自己的对象,写口负责编码(两方言的 JSON 编码器不同)。
|
|
47
|
+
*/
|
|
48
|
+
export type CheckpointIndexCells = {
|
|
49
|
+
readonly [K in keyof CheckpointIndexFacts as IndexColumnOf<K>]: K extends "hasBidiControls" ? 1 | null : K extends "riskDescriptor" ? RiskDescriptor | null : CheckpointIndexFacts[K];
|
|
50
|
+
};
|
|
51
|
+
/** 一行的索引列格(纯数据;写口与 M29 回填同调这一只 —— 回填不另读门子树自算)。 */
|
|
52
|
+
export declare function buildCheckpointIndexCells(cp: Checkpoint): CheckpointIndexCells;
|
|
53
|
+
/**
|
|
54
|
+
* `approval_card` 列放得下的卡词**字节数**(UTF-8 字节,不是字符数),按方言各一格(键表对 {@link SqlDialect} 闭合:加一种方言 ⇒ 编译红)。
|
|
55
|
+
* MySQL 协议(TiDB / MySQL)的列型是 `TEXT`,上限 65,535 字节 —— 严格模式下超长写入抛 `Data too long`,非严格模式静默截成半只卡词;PG 的 `TEXT` 没有这个上限。
|
|
56
|
+
* 列型的属主是中央 DDL(`tidb-pool.ts` / `pg-pool.ts` 的 `approval_card`),本表只是那一列的容量事实(`test/checkpoint-index-columns.test.ts` 把两处同读,换列型 ⇒ 红)。
|
|
57
|
+
* 引擎照存集外词、长度不由本仓定,但引擎铸得出的卡词是闭集短词 —— 超出容量的只会是手改 / 外来写者写下的存量行;读它的是 M29 回填(超出 ⇒ 计数 + 点名跳过,不挡起服)。
|
|
58
|
+
*/
|
|
59
|
+
export declare const APPROVAL_CARD_COLUMN_MAX_BYTES: Readonly<Record<SqlDialect, number>>;
|
|
60
|
+
/** facet 的词(core 登记表 `facet` 列的值域)。 */
|
|
61
|
+
type Facet = (typeof PAUSE_REGISTRY)[GateKind]["facet"];
|
|
62
|
+
/** 生成谓词的一条 WHEN:某一列的值落在这几个词里 ⇒ 这个 facet。 */
|
|
63
|
+
export interface FacetCase {
|
|
64
|
+
readonly column: typeof CHECKPOINT_INDEX_COLUMNS.approvalCard | typeof CHECKPOINT_INDEX_COLUMNS.gateKind;
|
|
65
|
+
readonly words: readonly string[];
|
|
66
|
+
readonly facet: Facet;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 生成谓词的 WHEN 表:先卡(`CARD_FACET_OVERRIDES` 的键 ⇒ 它的 facet),后门型(`PAUSE_REGISTRY` 每一行 ⇒ 它的 `facet` 列)。第一条命中的赢;都不中 ⇒ NULL。
|
|
70
|
+
* 纯数据,只由 core 那两张表生成 —— 零手写词。
|
|
71
|
+
*/
|
|
72
|
+
export declare const CHECKPOINT_FACET_CASES: readonly FacetCase[];
|
|
73
|
+
/**
|
|
74
|
+
* 一行的到期 facet,按方言各一份(同一张 WHEN 表):`CASE WHEN approval_card IN (…) THEN 'B' WHEN gate_kind IN (…) THEN 'A' … END`(无 ELSE ⇒ 未登记门型读 NULL)。
|
|
75
|
+
* 两份的差别只在「列怎么比」:引擎按**字节**认词(`'question '` 是集外词),而 MySQL 协议表的 `utf8mb4_bin` 是 PAD SPACE 排序(比较时忽略尾空格,`'question '` = `'question'`)
|
|
76
|
+
* ⇒ 那一方言两列按 `CAST(… AS BINARY)` 比(变长二进制串逐字节比,不补位);PG 的 `varchar` / `text` 比较本来不补位,列原样。
|
|
77
|
+
* 列名不带表限定:两条读腿都只查 `checkpoint` 一张表。拒扫腿读 `= 'A'`,收割的作废分支读 `COALESCE(…, '') <> 'A'`(NULL 门型的行走作废,与修前同向)。
|
|
78
|
+
*/
|
|
79
|
+
export declare const CHECKPOINT_FACET_SQL: Readonly<Record<SqlDialect, string>>;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=checkpoint-index-columns.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CARD_FACET_OVERRIDES, PAUSE_REGISTRY, checkpointIndexFacts } from "@sema-agent/core";
|
|
2
|
+
export const CHECKPOINT_INDEX_COLUMNS = {
|
|
3
|
+
token: "token",
|
|
4
|
+
scope: "scope",
|
|
5
|
+
sessionId: "session_id",
|
|
6
|
+
version: "version",
|
|
7
|
+
gateKind: "gate_kind",
|
|
8
|
+
approvalCard: "approval_card",
|
|
9
|
+
toolName: "tool_name",
|
|
10
|
+
toolCallId: "tool_call_id",
|
|
11
|
+
boundInputHash: "bound_input_hash",
|
|
12
|
+
deadline: "deadline",
|
|
13
|
+
createdAt: "created_at_ms",
|
|
14
|
+
riskDescriptor: "risk_descriptor",
|
|
15
|
+
hasBidiControls: "has_bidi_controls",
|
|
16
|
+
};
|
|
17
|
+
export function buildCheckpointIndexCells(cp) {
|
|
18
|
+
const f = checkpointIndexFacts(cp);
|
|
19
|
+
return {
|
|
20
|
+
token: f.token,
|
|
21
|
+
scope: f.scope,
|
|
22
|
+
session_id: f.sessionId,
|
|
23
|
+
version: f.version,
|
|
24
|
+
gate_kind: f.gateKind,
|
|
25
|
+
approval_card: f.approvalCard,
|
|
26
|
+
tool_name: f.toolName,
|
|
27
|
+
tool_call_id: f.toolCallId,
|
|
28
|
+
bound_input_hash: f.boundInputHash,
|
|
29
|
+
deadline: f.deadline,
|
|
30
|
+
created_at_ms: f.createdAt,
|
|
31
|
+
risk_descriptor: f.riskDescriptor,
|
|
32
|
+
has_bidi_controls: f.hasBidiControls === true ? 1 : null,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export const APPROVAL_CARD_COLUMN_MAX_BYTES = {
|
|
36
|
+
tidb: 65_535,
|
|
37
|
+
pg: Number.POSITIVE_INFINITY,
|
|
38
|
+
};
|
|
39
|
+
function groupByFacet(pairs, column) {
|
|
40
|
+
const groups = new Map();
|
|
41
|
+
for (const [word, facet] of pairs) {
|
|
42
|
+
const words = groups.get(facet);
|
|
43
|
+
if (words === undefined)
|
|
44
|
+
groups.set(facet, [word]);
|
|
45
|
+
else
|
|
46
|
+
words.push(word);
|
|
47
|
+
}
|
|
48
|
+
return [...groups].map(([facet, words]) => ({ column, words, facet }));
|
|
49
|
+
}
|
|
50
|
+
export const CHECKPOINT_FACET_CASES = [
|
|
51
|
+
...groupByFacet(Object.entries(CARD_FACET_OVERRIDES), CHECKPOINT_INDEX_COLUMNS.approvalCard),
|
|
52
|
+
...groupByFacet(Object.keys(PAUSE_REGISTRY).map((k) => [k, PAUSE_REGISTRY[k].facet]), CHECKPOINT_INDEX_COLUMNS.gateKind),
|
|
53
|
+
];
|
|
54
|
+
const literal = (word) => `'${word.replace(/'/g, "''")}'`;
|
|
55
|
+
function renderFacetCase(compared) {
|
|
56
|
+
return `CASE ${CHECKPOINT_FACET_CASES.map((c) => `WHEN ${compared(c.column)} IN (${c.words.map(literal).join(", ")}) THEN ${literal(c.facet)}`).join(" ")} END`;
|
|
57
|
+
}
|
|
58
|
+
export const CHECKPOINT_FACET_SQL = Object.freeze({
|
|
59
|
+
tidb: renderFacetCase((column) => `CAST(${column} AS BINARY)`),
|
|
60
|
+
pg: renderFacetCase((column) => column),
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=checkpoint-index-columns.js.map
|