@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
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
* `resolveSpec` 本身留作真正的拒点(提交腿 400;续跑腿在到它之前已被本判据答掉)。再开第六个问点必须调这两只,不许各判各的 —— 此前铸卡前只判了
|
|
40
40
|
* allow 记号,工具名清单那一问漏在外面,卡铸出来了、`/wake` 恒 409([ref] 合并复审两腿同报)。
|
|
41
41
|
*
|
|
42
|
+
* ## 凭据位密封(7.134.0;常设规则,不是迁移)
|
|
43
|
+
* 体里请求面凭据位上的值在 ctx 里只以封签存在 —— 写:{@link buildCheckpointCtx} / {@link sealCheckpointCtx} 一只封口;读:续跑上下文读口里一只开口
|
|
44
|
+
* {@link openCheckpointCtx};开不开 ⇒ `409 conflict.checkpoint_ctx_unsealable`。规则全文在本文件末段「凭据位密封」的头注。
|
|
45
|
+
*
|
|
42
46
|
* ## 何时删(一次性迁移,不是长期双读)
|
|
43
47
|
* 本判据、拒臂、记号写点与 `CheckpointCtx.permissionsAllowReading` 一起删,删除条件与窗登记在 `plugins/one-time-migrations.ts` 的
|
|
44
48
|
* 一次性迁移登记表(本条那一行):所有旧读法下停驻的行都已结束或被收割(停驻行的终局 = 落盘起 `TERMINAL_BACKSTOP_MS`,见
|
|
@@ -73,14 +77,16 @@ export declare function bodyCarriesAllowList(body: TaskRequestBody): boolean;
|
|
|
73
77
|
* 调用方是「本进程刚按当前读法读过这份体」的写点:fresh 提交(受理门按当前读法读过 `allow`),或已经过了续跑拒臂的重放腿
|
|
74
78
|
* (`startFreshHostTurn` 把宿主的存量体交给 `POST /v1/runs` 同一条链 —— 它在那之前调过 `resolveResumeSpecOrBlocked`,没记号却带 `allow` 的体到不了这里)。
|
|
75
79
|
* 续跑腿的**写回**不经本函数:**不改词**的写回传读进来的 ctx(记号随行,不重新判 —— 在写回口重新判会把一条没记号的旧行「洗」成新行);
|
|
76
|
-
* **改词**的写回(只有 `plan_review` 的批准 / 编辑)经 {@link withPermissionModeRewritten}。
|
|
80
|
+
* **改词**的写回(只有 `plan_review` 的批准 / 编辑)经 {@link withPermissionModeRewritten}。两种写回落盘之前都过同一只封口 {@link sealCheckpointCtx}。
|
|
81
|
+
*
|
|
82
|
+
* `sealer` / `sessionId`:凭据位密封的两件(本文件末段)—— `sessionId` 是这一行的会话(绑进封签);`sealer` 必传,缺席也要说出来(`undefined`)。
|
|
77
83
|
*/
|
|
78
84
|
export declare function buildCheckpointCtx(fields: {
|
|
79
85
|
body: TaskRequestBody;
|
|
80
86
|
memoryScope?: string | undefined;
|
|
81
87
|
unattendedLeg?: true;
|
|
82
88
|
writerVersion: string;
|
|
83
|
-
}):
|
|
89
|
+
}, sealer: CheckpointCtxSealer | undefined, sessionId: string): SealedCheckpointCtx;
|
|
84
90
|
/**
|
|
85
91
|
* 模式词的**第二个写者** —— `plan_review` 的批准 / 编辑把这条 run 的体词从 `plan` 写成批准的档(`resume-legs.ts` `drivePlanReview`,调用点只有那一处;
|
|
86
92
|
* `test/allow-list-reading-park-refusal.test.ts` 枚举调用点,多一处即红)。与 {@link buildCheckpointCtx} **同一条规则**:按当前读法写下的词,盖当前读法记号。
|
|
@@ -208,4 +214,179 @@ export declare function storedBodyReplayLogFields(refusal: StoredBodyReplayRefus
|
|
|
208
214
|
* 没有默认值:每个调用点必须说出这件事实。
|
|
209
215
|
*/
|
|
210
216
|
export declare function storedBodyReplayAnswer(refusal: StoredBodyReplayRefusal, readerVersion: string, cardPending: boolean): ResumeRefusalAnswer;
|
|
217
|
+
/**
|
|
218
|
+
* 🔴 **停驻行里请求面凭据的落盘形 —— 一条规则**:提交体里**凭据位**({@link CHECKPOINT_CTX_CREDENTIAL_SLOTS},闭集)上的每一个值,在 `checkpoint_ctx`
|
|
219
|
+
* (local 店的 `<数据根>/checkpoint-ctx/<会话>.json` / SQL 店的 `checkpoint_ctx.ctx` 列)里只以**封签**({@link SealedCheckpointValue})存在。
|
|
220
|
+
* · **写**:一只封口 {@link sealCheckpointCtx}。新的持久化写经 {@link buildCheckpointCtx}(它的唯一产物形就是封好的 {@link StoredCheckpointCtx}),
|
|
221
|
+
* 续跑腿的写回(`resume-legs.ts` 的 `commitResumeCtx`:读进来的 ctx 在内存里是开封形)经它本身;一次性迁移 M28 对存量行用同一只走法
|
|
222
|
+
* ({@link sealStoredCheckpointCtxM28})。凭据位上的**每一个值都封,不分类型**(串、数字、`null`、对象 —— 包括调用方自己送来的封签形对象):
|
|
223
|
+
* 封签里装的是那个 JSON 值本身,开封逐字还原。字典位上的容器本身不是字典(串 / 数组 / `null` / 封签形对象)⇒ 整只容器当一个值封。
|
|
224
|
+
* 于是落盘形里凭据位上**只有本封口铸的封签**,没有哪个值能「原样存下、续跑时被开成别的东西」(调用方送一只封签形对象 ⇒ 存的是再封一层,
|
|
225
|
+
* 开出来还是那只对象 —— 与新提交腿看到的同一个值)。没有封签器而有值要封 ⇒ 抛 {@link CheckpointCtxUnsealableError}(`no_key_store`,调用方在写之前拒)。
|
|
226
|
+
* · **读法记号**(与本文件另两只记号同一条「写的人盖章」):封口铸出的每一份落盘形都带 `credentialSeal: CHECKPOINT_CTX_SEAL_ALG` 与
|
|
227
|
+
* `credentialSlotGeneration`(= 这一行里**带值的**凭据位最新的那一代,最小 1)—— 这一行的凭据位全部由本封口封过,且它用到的位不比这一代新。
|
|
228
|
+
* 代数取「用到的」而不取「本版的」:不带新位值的行与上一代的写者写下的同形,回滚到上一代照读;代数比读者新 ⇒ 这一行**一定**带着读者不认识的位 ⇒ 读者整行拒。没有记号的行是 7.134.0 之前的写者写下的:
|
|
229
|
+
* 那时没有任何写者封值,所以它凭据位上的封签形对象只可能是调用方原样送来的,不是封签。代数缺席的带记号行是 7.134.0 的写者写下的 —— 它封的是第 1 代
|
|
230
|
+
* (闭集每行的 `since`);某一位的 `since` 大于这一行封过的代数 ⇒ 那一位上的值不论长什么样都没被封过(一只恰好长成封签形的明文字典也是明文)。
|
|
231
|
+
* 记号只在落盘形上(开口交出的开封形里没有它;写回再封时重新盖)。
|
|
232
|
+
* · **读**:一只开口 {@link openCheckpointCtx},唯一调用方 = 续跑上下文唯一读口 `resume-ctx-read.ts` 的 `readResumeCtx`(读出的 ctx 在任何消费者
|
|
233
|
+
* 看到之前已开封)。逐值判词 = {@link credentialValueReading}(开口与 M28 同一只):行带当前记号、这一位在它封过的那一代里:凭据位上封签 ⇒ 开(开不开 ⇒ 拒);
|
|
234
|
+
* 带 `sealed` 键却不是本闭集的封签形(含将来的 `alg`)⇒ 拒 `unrecognized_seal`;其余任何值 ⇒ 拒 `plaintext`。这一位比行封过的代数新 ⇒ 任何值 ⇒ 拒 `plaintext`。
|
|
235
|
+
* 行没有记号 ⇒ 凭据位上**任何**值(含封签形对象)⇒ 拒 `plaintext`(更早版本写下、M28 还没扫到);记号认不得(将来的格式)⇒
|
|
236
|
+
* 凭据位上任何值 ⇒ 拒 `unrecognized_seal`,凭据位上没有值的行不论记号照常开;代数认不得(比本版新 / 不是正整数)⇒ **整行**拒 `unrecognized_seal`(`field` = 记号位名),不看已知位上有没有值。
|
|
237
|
+
* **拒** = 读口第四态 `unsealable`(`field` = 哪一个凭据位,`reason` ∈ {@link CHECKPOINT_CTX_UNSEALABLE_REASONS}),各续跑入口答
|
|
238
|
+
* `409 conflict.checkpoint_ctx_unsealable`(`resume-ctx-read.ts` 的 `resumeCtxUnsealableAnswer`)。**没有**明文回落臂、**没有**静默丢键臂。
|
|
239
|
+
* · **装配**:`checkpointStore` 在场而封签器缺席 ⇒ 拒启({@link CHECKPOINT_CTX_SEALING_REQUIRED};`createHttpServer` 与起服第 6 段同一句)。
|
|
240
|
+
*
|
|
241
|
+
* **一个域一对钥匙**:停驻行封签用这一域自己的保管店(`<数据根>/sealed-key/checkpoint-ctx-keys/`,生产工厂 `sealed-key.ts` `ensureCheckpointCtxSealing`),
|
|
242
|
+
* 与模型钥匙(`ModelEntry.sealedApiKey`)的那对钥匙不共用 —— 模型钥匙的密文放进凭据位、停驻行的封签放进 `sealedApiKey`,两边都是「不持有那把钥匙」;
|
|
243
|
+
* 封签再把**会话 id 绑进密文**(信封 = `[alg, sessionId, value]`):别的会话那一行的封签搬过来开不开 —— 读口不是这台副本任何一把钥匙的解密预言机。
|
|
244
|
+
*
|
|
245
|
+
* 本模块的零值依赖纪律照旧:封签器 / 开封器是调用方递进来的接口(实现在 `sealed-key.ts`,它依赖 libsodium,不进本模块的闭包)。
|
|
246
|
+
*/
|
|
247
|
+
export declare const CHECKPOINT_CTX_SEAL_ALG = "checkpoint-ctx-sealedbox-v1";
|
|
248
|
+
/** 停驻行里一只凭据值的**封签**(闭集形:恰这三键、三值皆串、`alg` 只有 {@link CHECKPOINT_CTX_SEAL_ALG} 一个词)。与明文不可混淆:明文是串,封签是对象。 */
|
|
249
|
+
export interface SealedCheckpointValue {
|
|
250
|
+
readonly alg: typeof CHECKPOINT_CTX_SEAL_ALG;
|
|
251
|
+
/** 封它的那把公钥的 id(开封按它**精确**选私钥,不逐把试)。 */
|
|
252
|
+
readonly publicKeyId: string;
|
|
253
|
+
/** `crypto_box_seal` 密文的标准 base64。 */
|
|
254
|
+
readonly sealed: string;
|
|
255
|
+
}
|
|
256
|
+
/** 封口(只会封):把凭据位上的一个 JSON 值(任何类型)封进 `sessionId` 那一行。抛 = 封不了(调用方当写失败处置)。 */
|
|
257
|
+
export interface CheckpointCtxSealer {
|
|
258
|
+
seal(value: unknown, sessionId: string): SealedCheckpointValue;
|
|
259
|
+
}
|
|
260
|
+
/** 开口:`holds` = 这台副本有没有 `publicKeyId` 那把私钥;`open` 抛 = 开不开(密文坏 / 不是 `sessionId` 那一行封的 / 不是停驻行信封);返回封进去的那个 JSON 值。
|
|
261
|
+
* 🔴 `open` 的返回值是活凭据:只进内存,不进日志、不落盘(再落盘必经 {@link sealCheckpointCtx})。 */
|
|
262
|
+
export interface CheckpointCtxOpener {
|
|
263
|
+
holds(publicKeyId: string): boolean;
|
|
264
|
+
open(sealed: SealedCheckpointValue, sessionId: string): unknown;
|
|
265
|
+
}
|
|
266
|
+
/** 封签器 = 封口 + 开口(生产工厂 `sealed-key.ts` `ensureCheckpointCtxSealing`;`ServiceDeps.checkpointCtxSealing` 的型)。 */
|
|
267
|
+
export interface CheckpointCtxSealing extends CheckpointCtxSealer, CheckpointCtxOpener {
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* **凭据位闭集**(提交体里值为凭据的位置)。路径段 `*` = 那一格容器的**每一个成员**:数组的每一项、字典的每一个值(一只走法,不分容器种类 —— 字典成员的点名形
|
|
271
|
+
* `field` 是 `.<键>`,数组是 `[<下标>]`)。`map` = 那一格是串值字典,**每一个值**都是凭据(不分哪一键);`value` = 那一格本身是凭据。
|
|
272
|
+
* 入表判据(一条):请求面上**为承载凭据而设**的字段 —— 静态请求头(MCP http 传输、A2A 对端〔引擎型注:「e.g. an auth bearer」〕、http hook 条目)、
|
|
273
|
+
* 交给子进程的 env(MCP stdio 传输、任务 shell 的 `settings.env`、command hook 条目的插件选项)、请求自带的搜索后端钥匙。http hook 的头与另两种静态头同判:契约包的条目形是
|
|
274
|
+
* `headers: Record<string, string>`、受理面(`parseHooksConfig`)只判条数与字数、`interpolateHookEnvVars` 只换 `$NAME` 引用而字面值原样上 wire ——
|
|
275
|
+
* 头值可以就是字面的 `Authorization: Bearer …`。插件选项与 `settings.env` 同判:`plugin.options` 的每一个值就是 hook 子进程环境里的 `CLAUDE_PLUGIN_OPTION_<KEY>`
|
|
276
|
+
* (`hooks/command-spawn.ts` 的 `hookPluginEnv`),参照实现也把 sensitive 选项照样交进这一族环境变量 —— 值是不是秘密不是本层能判的,所以整格封,不判值形。
|
|
277
|
+
* hooks 的形 = 事件名 → 匹配组数组 → 组的 `hooks` 数组 → 条目;只有 `type:"http"` 的条目有 `headers`、只有带 `plugin` 的 command 条目有 `plugin.options`,
|
|
278
|
+
* 别的条目在那一段缺席、走法照常不往下走。**不入表**:命令行 / URL / 工具实参之类自由文本(不是凭据字段;它们里有没有秘密不是本层能判的)。
|
|
279
|
+
* 加一位 = 加一行,读写两侧与一次性迁移 M28 共用 {@link mapCredentialSlots} 一只走法:写侧与读侧立即覆盖;已落盘的行由 M28 补封 ——
|
|
280
|
+
* 新行的 `since` 取下一代:封口铸的落盘形盖「这一行里带值的位最新的那一代」(`credentialSlotGeneration`),读者据它判那一行用到、封过哪几位 —— 代数更早的行上新位的值一律是明文(记号本身不证明它封过新位)。
|
|
281
|
+
* M28 封的是「读口会答 `plaintext` 的每一个值」({@link credentialValueReading}),所以新加的一位上的明文在带记号的行里也被补封(只在 M28 的窗内;窗外加位要另起迁移)。
|
|
282
|
+
*/
|
|
283
|
+
export declare const CHECKPOINT_CTX_CREDENTIAL_SLOTS: readonly [{
|
|
284
|
+
readonly path: readonly ["mcpServers", "*", "transport", "headers"];
|
|
285
|
+
readonly holds: "map";
|
|
286
|
+
readonly since: 1;
|
|
287
|
+
}, {
|
|
288
|
+
readonly path: readonly ["mcpServers", "*", "transport", "env"];
|
|
289
|
+
readonly holds: "map";
|
|
290
|
+
readonly since: 1;
|
|
291
|
+
}, {
|
|
292
|
+
readonly path: readonly ["a2aPeers", "*", "headers"];
|
|
293
|
+
readonly holds: "map";
|
|
294
|
+
readonly since: 1;
|
|
295
|
+
}, {
|
|
296
|
+
readonly path: readonly ["settings", "env"];
|
|
297
|
+
readonly holds: "map";
|
|
298
|
+
readonly since: 1;
|
|
299
|
+
}, {
|
|
300
|
+
readonly path: readonly ["settings", "webSearch", "apiKey"];
|
|
301
|
+
readonly holds: "value";
|
|
302
|
+
readonly since: 1;
|
|
303
|
+
}, {
|
|
304
|
+
readonly path: readonly ["settings", "hooks", "*", "*", "hooks", "*", "headers"];
|
|
305
|
+
readonly holds: "map";
|
|
306
|
+
readonly since: 1;
|
|
307
|
+
}, {
|
|
308
|
+
readonly path: readonly ["settings", "hooks", "*", "*", "hooks", "*", "plugin", "options"];
|
|
309
|
+
readonly holds: "map";
|
|
310
|
+
readonly since: 2;
|
|
311
|
+
}];
|
|
312
|
+
/** 本版闭集的代数 = 表里最大的 `since`(读者认得的最新一代)。落盘形的 `credentialSlotGeneration` 不大于它;大于它的行是更新的写者带着本版不认识的位写下的。 */
|
|
313
|
+
export declare const CHECKPOINT_CTX_CREDENTIAL_GENERATION: number;
|
|
314
|
+
/** 开不开 / 封不了的成因(闭集):`no_key_store` = 这台副本没有封签器(没有保管店);`key_not_held` = 封它的那把钥匙不在这台副本的保管店里
|
|
315
|
+
* (多副本不共享 `<数据根>/sealed-key/`,或保管目录被换过);`unopenable` = 钥匙在、开不开(密文坏 / 不是这一行封的 / 不是停驻行信封);
|
|
316
|
+
* `plaintext` = 凭据位上是明文(更早版本的写者);`unrecognized_seal` = 带 `sealed` 键却不是本闭集的封签形(含将来的 `alg`)。 */
|
|
317
|
+
export declare const CHECKPOINT_CTX_UNSEALABLE_REASONS: readonly ["no_key_store", "key_not_held", "unopenable", "plaintext", "unrecognized_seal"];
|
|
318
|
+
export type CheckpointCtxUnsealableReason = (typeof CHECKPOINT_CTX_UNSEALABLE_REASONS)[number];
|
|
319
|
+
/** 封不了 / 开不开的那一格:`field` = 凭据位在提交体里的路径(如 `mcpServers[0].transport.headers.Authorization`、
|
|
320
|
+
* `settings.hooks.PreToolUse[0].hooks[0].headers.Authorization`;键名不是秘密,值从不进来)。 */
|
|
321
|
+
export declare class CheckpointCtxUnsealableError extends Error {
|
|
322
|
+
readonly field: string;
|
|
323
|
+
readonly reason: CheckpointCtxUnsealableReason;
|
|
324
|
+
constructor(field: string, reason: CheckpointCtxUnsealableReason);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* 停驻行的**落盘形**:凭据位上是封签,不是 {@link TaskRequestBody} 型面说的串 —— 所以体在型面上只是「一只对象」,读它的唯一合法方式是 {@link openCheckpointCtx}
|
|
328
|
+
* (经续跑上下文读口)。产物只有两只铸点:{@link buildCheckpointCtx} 与 {@link sealCheckpointCtx}。
|
|
329
|
+
*/
|
|
330
|
+
export type StoredCheckpointCtx = Omit<CheckpointCtx, "body"> & {
|
|
331
|
+
readonly body: {
|
|
332
|
+
readonly [key: string]: unknown;
|
|
333
|
+
};
|
|
334
|
+
readonly credentialSeal?: typeof CHECKPOINT_CTX_SEAL_ALG;
|
|
335
|
+
/** 这一行的写者封过的闭集代数(读法记号的另一半;缺席 + 带 `credentialSeal` = 7.134.0 的写者 = 第 1 代)。 */
|
|
336
|
+
readonly credentialSlotGeneration?: number;
|
|
337
|
+
};
|
|
338
|
+
declare const sealedCheckpointCtxBrand: unique symbol;
|
|
339
|
+
/**
|
|
340
|
+
* **封口铸出的**落盘形(品牌型):店的写口(`putCtx`)与一次性迁移 M28 的行改写只收它 ⇒ 「写 ctx 只有封口一个写入面」由型面守,
|
|
341
|
+
* 不再靠逐个数调用点(把开封形 / 裸对象直接交给写口 = 当场 tsc 红)。铸点闭集(都在本模块,都经 {@link mintSealedCheckpointCtx}):
|
|
342
|
+
* {@link sealCheckpointCtx}(新的持久化写经 {@link buildCheckpointCtx} 到它;续跑腿的写回)与 {@link sealStoredCheckpointCtxM28}。零运行期变化。
|
|
343
|
+
*/
|
|
344
|
+
export type SealedCheckpointCtx = StoredCheckpointCtx & {
|
|
345
|
+
readonly [sealedCheckpointCtxBrand]: true;
|
|
346
|
+
};
|
|
347
|
+
/** 装配期拒启的那一句(`createHttpServer` 与起服第 6 段同调;一句、一个出口)。 */
|
|
348
|
+
export declare const CHECKPOINT_CTX_SEALING_REQUIRED = "a durable checkpoint store is wired but checkpointCtxSealing is not: suspended tasks keep the request's credentials (MCP / A2A headers and env values, settings.env, settings.webSearch.apiKey, http hook headers, command hook plugin options) in their resume context, and they are stored sealed or not at all \u2014 give the service a sealed-key store for them (this service builds it under <data root>/sealed-key/checkpoint-ctx-keys/ at boot; a failure there is the earlier checkpoint_ctx_sealing_unavailable warning \u2014 make that directory creatable and chmod-able by the service, or repair or remove a key file there whose public and private halves do not belong together), or, when embedding, pass checkpointCtxSealing: await ensureCheckpointCtxSealing(sealedKeyDir); refusing to start rather than write credentials in plaintext";
|
|
349
|
+
/** 封签形的判官(恰三键、三值皆串、`alg` 是本闭集那一个词)。 */
|
|
350
|
+
export declare function isSealedCheckpointValue(v: unknown): v is SealedCheckpointValue;
|
|
351
|
+
/**
|
|
352
|
+
* **封口**(写的一侧唯一的一只):内存里的开封形 ctx ⇒ 落盘形。`sealer` 必传(缺席也要说出来:`undefined` = 这台副本没有保管店 ⇒ 体里有凭据就抛
|
|
353
|
+
* {@link CheckpointCtxUnsealableError} `no_key_store`,调用方在写之前拒;体里没有凭据 ⇒ 没有要封的东西,照常)。`sessionId` = 这一行的会话(绑进封签)。
|
|
354
|
+
* 调用方:{@link buildCheckpointCtx}(新的持久化写)与续跑腿的写回(`resume-legs.ts` `commitResumeCtx`)。
|
|
355
|
+
*/
|
|
356
|
+
export declare function sealCheckpointCtx(ctx: CheckpointCtx, sealer: CheckpointCtxSealer | undefined, sessionId: string): SealedCheckpointCtx;
|
|
357
|
+
/** {@link openCheckpointCtx} 的结局:开封形 ctx,或第一处开不开的凭据位。 */
|
|
358
|
+
export type OpenedCheckpointCtx = {
|
|
359
|
+
readonly kind: "ok";
|
|
360
|
+
readonly ctx: CheckpointCtx;
|
|
361
|
+
} | {
|
|
362
|
+
readonly kind: "unsealable";
|
|
363
|
+
readonly field: string;
|
|
364
|
+
readonly reason: CheckpointCtxUnsealableReason;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* **开口**(读的一侧唯一的一只;唯一调用方 = 续跑上下文读口 `readResumeCtx`):落盘形 ⇒ 开封形。`opener` 缺席 = 这台副本没有保管店(体里有封签就
|
|
368
|
+
* `no_key_store`;没有凭据的行照常开)。判词见本段头注与 {@link credentialValueReading}。
|
|
369
|
+
*/
|
|
370
|
+
export declare function openCheckpointCtx(stored: StoredCheckpointCtx, opener: CheckpointCtxOpener | undefined, sessionId: string): OpenedCheckpointCtx;
|
|
371
|
+
/**
|
|
372
|
+
* 一份落盘 ctx(持久化 JSON,不信型面)的凭据位上**第一只封签**的点名(`field`,形同拒句里的那一位;键名不是秘密,值从不出来)—— 没有 ⇒ `undefined`。
|
|
373
|
+
* 走法 = 封口 / 开口 / M28 共用的那一只 {@link mapCredentialSlots},判形 = {@link isSealedCheckpointValue};不开封、不看记号(只问「凭据位上有没有封签」)。
|
|
374
|
+
* 唯一读者:随包排空检查脚本的 `sealed-credentials-rollback` 判据(经编译产物取):7.133.x 读不懂封签、续跑时把这些凭据位当没有 ⇒ 回滚之前先把这样的停驻行决掉或取消。
|
|
375
|
+
*/
|
|
376
|
+
export declare function sealedCredentialFieldOf(stored: unknown): string | undefined;
|
|
377
|
+
/**
|
|
378
|
+
* 🔴 **一次性迁移 M28 的行改写**(窗与删法见 `plugins/one-time-migrations.ts` 登记表 M28;编排 = `checkpoint-ctx-seal-m28.ts`):一行存量 ctx
|
|
379
|
+
* (持久化 JSON,不信型面)凭据位上**读口会答 `plaintext` 的每一个值**({@link credentialValueReading},与开口同一只判词)用同一只封口封好、盖记号 ——
|
|
380
|
+
* 与写侧 {@link sealCheckpointCtx} 同一条规则。两种存量行落在这一条里:
|
|
381
|
+
* · 没有读法记号的行(7.134.0 之前的写者)—— 每一个值都是 `plaintext`(含调用方原样送来的封签形对象)⇒ 全封;
|
|
382
|
+
* · 带当前记号、而某一位比行封过的代数新的行(7.134.0 的写者封第 1 代,没封第 2 代的 `plugin.options`)—— 那一位上的值不论长什么样都是明文 ⇒ 封
|
|
383
|
+
* (恰好长成封签形的选项字典按字典容器整只封,开出来还是那只字典);行封过的那一代里的封签不动。改写后的行盖「带值的位最新的那一代」(与封口同一条)。
|
|
384
|
+
* 读口会答 `seal` / `unrecognized_seal` 的值不动(认不得的留给读口拒);一个值都没封 ⇒ `undefined`(不写:第二跑零命中;记号认不得的行因此一个字节不动);
|
|
385
|
+
* 体不是对象 ⇒ `undefined`(读口自己的形判接住)。其余位(另两只记号、写者版本、非凭据字段)原样。
|
|
386
|
+
*/
|
|
387
|
+
export declare function sealStoredCheckpointCtxM28(stored: object, sealer: CheckpointCtxSealer, sessionId: string): {
|
|
388
|
+
readonly ctx: SealedCheckpointCtx;
|
|
389
|
+
readonly valuesSealed: number;
|
|
390
|
+
} | undefined;
|
|
391
|
+
export {};
|
|
211
392
|
//# sourceMappingURL=checkpoint-ctx.d.ts.map
|
|
@@ -12,8 +12,8 @@ export function bodyCarriesAllowList(body) {
|
|
|
12
12
|
const allow = permissions["allow"];
|
|
13
13
|
return Array.isArray(allow) && allow.length > 0;
|
|
14
14
|
}
|
|
15
|
-
export function buildCheckpointCtx(fields) {
|
|
16
|
-
|
|
15
|
+
export function buildCheckpointCtx(fields, sealer, sessionId) {
|
|
16
|
+
const ctx = {
|
|
17
17
|
body: fields.body,
|
|
18
18
|
writerVersion: fields.writerVersion,
|
|
19
19
|
...(fields.memoryScope !== undefined ? { memoryScope: fields.memoryScope } : {}),
|
|
@@ -21,6 +21,7 @@ export function buildCheckpointCtx(fields) {
|
|
|
21
21
|
...(bodyCarriesAllowList(fields.body) ? { permissionsAllowReading: "allow_layer" } : {}),
|
|
22
22
|
permissionModeReading: "entry_word",
|
|
23
23
|
};
|
|
24
|
+
return sealCheckpointCtx(ctx, sealer, sessionId);
|
|
24
25
|
}
|
|
25
26
|
export function withPermissionModeRewritten(ctx, body) {
|
|
26
27
|
return { ...ctx, body, permissionModeReading: "entry_word" };
|
|
@@ -122,4 +123,198 @@ function storedBodyReplayArmAnswer(refusal, readerVersion) {
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
126
|
+
export const CHECKPOINT_CTX_SEAL_ALG = "checkpoint-ctx-sealedbox-v1";
|
|
127
|
+
export const CHECKPOINT_CTX_CREDENTIAL_SLOTS = [
|
|
128
|
+
{ path: ["mcpServers", "*", "transport", "headers"], holds: "map", since: 1 },
|
|
129
|
+
{ path: ["mcpServers", "*", "transport", "env"], holds: "map", since: 1 },
|
|
130
|
+
{ path: ["a2aPeers", "*", "headers"], holds: "map", since: 1 },
|
|
131
|
+
{ path: ["settings", "env"], holds: "map", since: 1 },
|
|
132
|
+
{ path: ["settings", "webSearch", "apiKey"], holds: "value", since: 1 },
|
|
133
|
+
{ path: ["settings", "hooks", "*", "*", "hooks", "*", "headers"], holds: "map", since: 1 },
|
|
134
|
+
{ path: ["settings", "hooks", "*", "*", "hooks", "*", "plugin", "options"], holds: "map", since: 2 },
|
|
135
|
+
];
|
|
136
|
+
export const CHECKPOINT_CTX_CREDENTIAL_GENERATION = Math.max(...CHECKPOINT_CTX_CREDENTIAL_SLOTS.map((slot) => slot.since));
|
|
137
|
+
export const CHECKPOINT_CTX_UNSEALABLE_REASONS = ["no_key_store", "key_not_held", "unopenable", "plaintext", "unrecognized_seal"];
|
|
138
|
+
export class CheckpointCtxUnsealableError extends Error {
|
|
139
|
+
field;
|
|
140
|
+
reason;
|
|
141
|
+
constructor(field, reason) {
|
|
142
|
+
super(`checkpoint ctx credential at ${field} cannot be ${reason === "no_key_store" ? "sealed or opened without a sealed-key store" : `opened (${reason})`}`);
|
|
143
|
+
this.name = "CheckpointCtxUnsealableError";
|
|
144
|
+
this.field = field;
|
|
145
|
+
this.reason = reason;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function mintSealedCheckpointCtx(sealed) {
|
|
149
|
+
return sealed;
|
|
150
|
+
}
|
|
151
|
+
export const CHECKPOINT_CTX_SEALING_REQUIRED = "a durable checkpoint store is wired but checkpointCtxSealing is not: suspended tasks keep the request's credentials (MCP / A2A headers and env values, settings.env, settings.webSearch.apiKey, http hook headers, command hook plugin options) in their resume context, and they are stored sealed or not at all — give the service a sealed-key store for them (this service builds it under <data root>/sealed-key/checkpoint-ctx-keys/ at boot; a failure there is the earlier checkpoint_ctx_sealing_unavailable warning — make that directory creatable and chmod-able by the service, or repair or remove a key file there whose public and private halves do not belong together), or, when embedding, pass checkpointCtxSealing: await ensureCheckpointCtxSealing(sealedKeyDir); refusing to start rather than write credentials in plaintext";
|
|
152
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
153
|
+
export function isSealedCheckpointValue(v) {
|
|
154
|
+
if (!isRecord(v))
|
|
155
|
+
return false;
|
|
156
|
+
const keys = Object.keys(v);
|
|
157
|
+
return keys.length === 3 && v["alg"] === CHECKPOINT_CTX_SEAL_ALG && typeof v["publicKeyId"] === "string" && typeof v["sealed"] === "string";
|
|
158
|
+
}
|
|
159
|
+
function defineOwn(target, key, value) {
|
|
160
|
+
Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
|
|
161
|
+
}
|
|
162
|
+
function mapCredentialSlots(body, visit) {
|
|
163
|
+
let out = body;
|
|
164
|
+
for (const slot of CHECKPOINT_CTX_CREDENTIAL_SLOTS)
|
|
165
|
+
out = mapAt(out, slot.path, 0, slot.holds, "", (value, field) => visit(value, field, slot));
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function mapAt(node, path, i, holds, field, visit) {
|
|
169
|
+
if (i === path.length) {
|
|
170
|
+
if (holds === "value")
|
|
171
|
+
return visit(node, field);
|
|
172
|
+
if (!isRecord(node) || isSealedCheckpointValue(node))
|
|
173
|
+
return visit(node, field);
|
|
174
|
+
let copy;
|
|
175
|
+
for (const [k, v] of Object.entries(node)) {
|
|
176
|
+
const next = visit(v, memberField(field, k));
|
|
177
|
+
if (next !== v)
|
|
178
|
+
defineOwn((copy ??= { ...node }), k, next);
|
|
179
|
+
}
|
|
180
|
+
return copy ?? node;
|
|
181
|
+
}
|
|
182
|
+
const seg = path[i];
|
|
183
|
+
if (seg === "*") {
|
|
184
|
+
if (Array.isArray(node)) {
|
|
185
|
+
let copy;
|
|
186
|
+
node.forEach((el, idx) => {
|
|
187
|
+
const next = mapAt(el, path, i + 1, holds, `${field}[${idx}]`, visit);
|
|
188
|
+
if (next !== el)
|
|
189
|
+
(copy ??= [...node])[idx] = next;
|
|
190
|
+
});
|
|
191
|
+
return copy ?? node;
|
|
192
|
+
}
|
|
193
|
+
if (!isRecord(node))
|
|
194
|
+
return node;
|
|
195
|
+
let copy;
|
|
196
|
+
for (const [k, v] of Object.entries(node)) {
|
|
197
|
+
const next = mapAt(v, path, i + 1, holds, memberField(field, k), visit);
|
|
198
|
+
if (next !== v)
|
|
199
|
+
defineOwn((copy ??= { ...node }), k, next);
|
|
200
|
+
}
|
|
201
|
+
return copy ?? node;
|
|
202
|
+
}
|
|
203
|
+
if (!isRecord(node) || !Object.hasOwn(node, seg))
|
|
204
|
+
return node;
|
|
205
|
+
const child = node[seg];
|
|
206
|
+
const next = mapAt(child, path, i + 1, holds, memberField(field, seg), visit);
|
|
207
|
+
if (next === child)
|
|
208
|
+
return node;
|
|
209
|
+
const copy = { ...node };
|
|
210
|
+
defineOwn(copy, seg, next);
|
|
211
|
+
return copy;
|
|
212
|
+
}
|
|
213
|
+
function memberField(field, key) {
|
|
214
|
+
return field === "" ? key : `${field}.${key}`;
|
|
215
|
+
}
|
|
216
|
+
function sealBody(body, sealer, sessionId) {
|
|
217
|
+
let valuesSealed = 0;
|
|
218
|
+
let generation = 1;
|
|
219
|
+
const sealed = mapCredentialSlots(body, (value, field, slot) => {
|
|
220
|
+
if (sealer === undefined)
|
|
221
|
+
throw new CheckpointCtxUnsealableError(field, "no_key_store");
|
|
222
|
+
valuesSealed += 1;
|
|
223
|
+
generation = Math.max(generation, slot.since);
|
|
224
|
+
return sealer.seal(value, sessionId);
|
|
225
|
+
});
|
|
226
|
+
return { body: sealed, valuesSealed, generation };
|
|
227
|
+
}
|
|
228
|
+
export function sealCheckpointCtx(ctx, sealer, sessionId) {
|
|
229
|
+
const { body, generation } = sealBody(ctx.body, sealer, sessionId);
|
|
230
|
+
return mintSealedCheckpointCtx({ ...ctx, body: body, credentialSeal: CHECKPOINT_CTX_SEAL_ALG, credentialSlotGeneration: generation });
|
|
231
|
+
}
|
|
232
|
+
const CREDENTIAL_GENERATION_FIELD = "credentialSlotGeneration";
|
|
233
|
+
function credentialStampOf(stored) {
|
|
234
|
+
const stamp = stored.credentialSeal;
|
|
235
|
+
const raw = stored.credentialSlotGeneration;
|
|
236
|
+
const generation = raw === undefined ? 1 : Number.isInteger(raw) && raw >= 1 && raw <= CHECKPOINT_CTX_CREDENTIAL_GENERATION ? raw : undefined;
|
|
237
|
+
return { stamp, generation };
|
|
238
|
+
}
|
|
239
|
+
function credentialValueReading(row, slot, value) {
|
|
240
|
+
if (row.stamp === undefined)
|
|
241
|
+
return "plaintext";
|
|
242
|
+
if (row.stamp !== CHECKPOINT_CTX_SEAL_ALG || row.generation === undefined)
|
|
243
|
+
return "unrecognized_seal";
|
|
244
|
+
if (slot.since > row.generation)
|
|
245
|
+
return "plaintext";
|
|
246
|
+
if (isSealedCheckpointValue(value))
|
|
247
|
+
return "seal";
|
|
248
|
+
if (isRecord(value) && Object.hasOwn(value, "sealed"))
|
|
249
|
+
return "unrecognized_seal";
|
|
250
|
+
return "plaintext";
|
|
251
|
+
}
|
|
252
|
+
export function openCheckpointCtx(stored, opener, sessionId) {
|
|
253
|
+
const { credentialSeal: _stamp, credentialSlotGeneration: _generation, ...rest } = stored;
|
|
254
|
+
const row = credentialStampOf(stored);
|
|
255
|
+
if (row.stamp === CHECKPOINT_CTX_SEAL_ALG && row.generation === undefined)
|
|
256
|
+
return { kind: "unsealable", field: CREDENTIAL_GENERATION_FIELD, reason: "unrecognized_seal" };
|
|
257
|
+
try {
|
|
258
|
+
const body = mapCredentialSlots(stored.body, (value, field, slot) => {
|
|
259
|
+
const reading = credentialValueReading(row, slot, value);
|
|
260
|
+
switch (reading) {
|
|
261
|
+
case "plaintext":
|
|
262
|
+
case "unrecognized_seal":
|
|
263
|
+
throw new CheckpointCtxUnsealableError(field, reading);
|
|
264
|
+
case "seal": {
|
|
265
|
+
const sealed = value;
|
|
266
|
+
if (opener === undefined)
|
|
267
|
+
throw new CheckpointCtxUnsealableError(field, "no_key_store");
|
|
268
|
+
if (!opener.holds(sealed.publicKeyId))
|
|
269
|
+
throw new CheckpointCtxUnsealableError(field, "key_not_held");
|
|
270
|
+
try {
|
|
271
|
+
return opener.open(sealed, sessionId);
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
throw new CheckpointCtxUnsealableError(field, "unopenable");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
default: {
|
|
278
|
+
const unreachable = reading;
|
|
279
|
+
return unreachable;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
return { kind: "ok", ctx: { ...rest, body: body } };
|
|
284
|
+
}
|
|
285
|
+
catch (e) {
|
|
286
|
+
if (e instanceof CheckpointCtxUnsealableError)
|
|
287
|
+
return { kind: "unsealable", field: e.field, reason: e.reason };
|
|
288
|
+
throw e;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
export function sealedCredentialFieldOf(stored) {
|
|
292
|
+
if (!isRecord(stored))
|
|
293
|
+
return undefined;
|
|
294
|
+
let first;
|
|
295
|
+
mapCredentialSlots(stored["body"], (value, field) => {
|
|
296
|
+
if (first === undefined && isSealedCheckpointValue(value))
|
|
297
|
+
first = field;
|
|
298
|
+
return value;
|
|
299
|
+
});
|
|
300
|
+
return first;
|
|
301
|
+
}
|
|
302
|
+
export function sealStoredCheckpointCtxM28(stored, sealer, sessionId) {
|
|
303
|
+
const row = credentialStampOf(stored);
|
|
304
|
+
const body = stored.body;
|
|
305
|
+
if (!isRecord(body))
|
|
306
|
+
return undefined;
|
|
307
|
+
let valuesSealed = 0;
|
|
308
|
+
let generation = 1;
|
|
309
|
+
const sealed = mapCredentialSlots(body, (value, _field, slot) => {
|
|
310
|
+
generation = Math.max(generation, slot.since);
|
|
311
|
+
if (credentialValueReading(row, slot, value) !== "plaintext")
|
|
312
|
+
return value;
|
|
313
|
+
valuesSealed += 1;
|
|
314
|
+
return sealer.seal(value, sessionId);
|
|
315
|
+
});
|
|
316
|
+
return valuesSealed === 0
|
|
317
|
+
? undefined
|
|
318
|
+
: { ctx: mintSealedCheckpointCtx({ ...stored, body: sealed, credentialSeal: CHECKPOINT_CTX_SEAL_ALG, credentialSlotGeneration: generation }), valuesSealed };
|
|
319
|
+
}
|
|
125
320
|
//# sourceMappingURL=checkpoint-ctx.js.map
|
package/dist/http/dispatch.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 请求流水线(
|
|
2
|
+
* 请求流水线([ref] 切片:`http/server.ts` 的 `handle()` 与它的模块级词表搬家;[ref] 再把「这是什么路由」
|
|
3
3
|
* 整件事交给 `./route-table.ts`)。
|
|
4
4
|
*
|
|
5
5
|
* 住在这里的是**一条请求从进门到落地**的全过程,一件事一遍:admission 计数 / 附着登记 / CORS / /health /
|
|
6
6
|
* /metrics / 鉴权桥 / 全局服务凭据门 / 无凭据写门 / drain 与 roster-pending 两道 503 / 破坏性会话写门 /
|
|
7
7
|
* 两段分派 / 全局 404。
|
|
8
8
|
*
|
|
9
|
-
* 🔴
|
|
9
|
+
* 🔴 [ref] 之后本文件**不再持有任何一份路由名单**:分派序、门侧、标签、三只门的判据全部读
|
|
10
10
|
* `ROUTES` / `ROUTE_DECLARATIONS`(见 route-table.ts 头注)。三道门也不再「按行号插在 37 只 if 中间」——
|
|
11
11
|
* 它们在门前段与门后段之间**恒定一处**执行,三段代码逐字未动,只是不再被域调用夹着。
|
|
12
12
|
*
|
|
@@ -19,7 +19,7 @@ import type { ServiceConfig } from "../config-types.js";
|
|
|
19
19
|
import type { RouteCtxBase, RunRegistry } from "./route-ctx.js";
|
|
20
20
|
import type { FlatServiceDeps } from "./server.js";
|
|
21
21
|
/**
|
|
22
|
-
* 🔴
|
|
22
|
+
* 🔴 [ref](test T-72 [ref];主会话裁 ①,分诊 [ref])—— 全局服务凭据门**之前**那几族只读路
|
|
23
23
|
* (`route-table.ts` 里 `position: "read-credential"` 的行)的**唯一**鉴权谓词:「服务凭据 ∨ 已验 principal」。
|
|
24
24
|
*
|
|
25
25
|
* 病:这几族(trace-usage / workflows / fleet)排在全局门之前,理由只有一条 —— 只读 `TRACE_TOKEN` 单凭据的调用方
|
package/dist/http/dispatch.js
CHANGED
|
@@ -8,14 +8,14 @@ import { sendJson, sendError, isSseResponse, endSseWithError } from "./send.js";
|
|
|
8
8
|
import { admissionRefusalOf, readinessOf, healthReadinessKeys, sendReadyz, sendBillableRefusal, billableRefusalOf, billableRefusalFrame } from "./readiness.js";
|
|
9
9
|
import { ENGINE_SIGNAL_KEY, buildEngineSignal, fleetMembershipKeys, healthConfigLedgerKeys, healthDrainingKeys, mintEngineSignal, restartActionable } from "../fleet/engine-signal.js";
|
|
10
10
|
import { buildHealthSelfReport } from "./health-self-report.js";
|
|
11
|
-
import { authorized, systemFor, gatedPrincipal, sendPrincipalRefusal, sendUnauthorized, verifiedIdentitySource, hasServiceAuth, devOpenDeployment } from "./principal-gate.js";
|
|
11
|
+
import { actsForDeployment, authorized, systemFor, gatedPrincipal, sendPrincipalRefusal, sendUnauthorized, traceTokenPresented, verifiedIdentitySource, hasServiceAuth, devOpenDeployment } from "./principal-gate.js";
|
|
12
12
|
const PROCESS_STARTED_AT_MS = Date.now() - Math.round(process.uptime() * 1000);
|
|
13
13
|
export function readCredentialOk(req, config) {
|
|
14
14
|
if (!hasServiceAuth(config))
|
|
15
15
|
return true;
|
|
16
16
|
if (verifiedIdentitySource(req, config) !== undefined)
|
|
17
17
|
return true;
|
|
18
|
-
return
|
|
18
|
+
return traceTokenPresented(req, config);
|
|
19
19
|
}
|
|
20
20
|
function cors(res, req, origins, principalHeader) {
|
|
21
21
|
if (!origins || origins.length === 0)
|
|
@@ -191,7 +191,7 @@ export function createDispatch(ctx) {
|
|
|
191
191
|
}
|
|
192
192
|
const mt = deps.config.metricsToken;
|
|
193
193
|
const devOpen = devOpenDeployment(deps) && !mt;
|
|
194
|
-
const ok = devOpen ||
|
|
194
|
+
const ok = devOpen || (!!mt && authorized(req, mt)) || actsForDeployment(req, deps.config, () => gatedPrincipal(req, deps.config));
|
|
195
195
|
if (!ok) {
|
|
196
196
|
sendUnauthorized(res, "operator");
|
|
197
197
|
return;
|
|
@@ -3,7 +3,7 @@ import { heldWorkflowParkDecisions } from "../parked-decide.js";
|
|
|
3
3
|
import { HEARTBEAT_MS, runInBackground } from "../runs.js";
|
|
4
4
|
import { fleetRunPublisher, fleetRunLabels } from "../fleet/fleet-bus.js";
|
|
5
5
|
import { cascadeConfig, runMeta } from "./run-meta.js";
|
|
6
|
-
import { resolveStreamApprovalGate } from "../tool-approval.js";
|
|
6
|
+
import { declaredApprovalFrameFamilies, resolveStreamApprovalGate } from "../tool-approval.js";
|
|
7
7
|
import { buildActiveRunConflict } from "./active-run-conflict.js";
|
|
8
8
|
import { commitPlacement, devicePlacementErrorBody } from "./device-placement.js";
|
|
9
9
|
import { commitSessionInheritEnv } from "./session-inherit-env.js";
|
|
@@ -12,6 +12,7 @@ import { recordResourceWindow } from "../resource-window.js";
|
|
|
12
12
|
import { persistSubmitCtx } from "./submit-ctx.js";
|
|
13
13
|
import { releaseClaimedRun } from "./claimed-run.js";
|
|
14
14
|
import { serviceVersion } from "../service-version.js";
|
|
15
|
+
import { headReadOf } from "../session-incarnation.js";
|
|
15
16
|
export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
16
17
|
const { deps } = ctx;
|
|
17
18
|
const { inflightRuns, preemptableRuns, steerableRuns } = ctx.registry;
|
|
@@ -59,10 +60,10 @@ export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
|
59
60
|
}
|
|
60
61
|
commitSessionInheritEnv(deps, args.prepared.spec.sessionId, args.prepared.body);
|
|
61
62
|
const anchorOwner = args.prepared.auth?.principal ?? null;
|
|
62
|
-
const
|
|
63
|
-
const captureTurnAnchor = deps.resumeAnchorStore &&
|
|
63
|
+
const headOf = headReadOf(deps.sessionStorage);
|
|
64
|
+
const captureTurnAnchor = deps.resumeAnchorStore && headOf
|
|
64
65
|
? async (eventId) => {
|
|
65
|
-
const leaf = await
|
|
66
|
+
const leaf = (await headOf(sessionId))?.leafId;
|
|
66
67
|
if (leaf)
|
|
67
68
|
await deps.resumeAnchorStore.put(sessionId, eventId, leaf, anchorOwner);
|
|
68
69
|
}
|
|
@@ -84,10 +85,11 @@ export async function mintAndDriveDurableRun(ctx, runStore, args) {
|
|
|
84
85
|
toolApprovalEnabled: true,
|
|
85
86
|
streamApprovalEnabled: deps.config.streamApproval?.enabled === true,
|
|
86
87
|
backend: deps.backend,
|
|
87
|
-
|
|
88
|
+
checkpointStore: deps.checkpointStore,
|
|
88
89
|
}).active,
|
|
89
90
|
windowMs: deps.config.streamApproval?.windowMs,
|
|
90
91
|
windowMarginMs: deps.config.streamAskWindowMarginMs,
|
|
92
|
+
declaredFamilies: declaredApprovalFrameFamilies(args.prepared.body.settings),
|
|
91
93
|
}
|
|
92
94
|
: undefined, deps.checkpointStore, args.prepared.engineNotices, trustedInternals, deps.userInputLedger, args.prepared.acceptance);
|
|
93
95
|
return { status: 202, body: { taskId, sessionId, status: "running", ...(args.prepared.warnings !== undefined ? { warnings: args.prepared.warnings } : {}) } };
|
|
@@ -80,11 +80,11 @@ export declare function idemIdentityOf(caller: IdemCaller): string;
|
|
|
80
80
|
export declare function idemKeyOf(raw: string, caller: IdemCaller, family: IdemFamily): string;
|
|
81
81
|
/**
|
|
82
82
|
* 一次提交的**请求体指纹** —— HTTP 三条提交腿(`POST /v1/tasks` · `/v1/tasks/stream` · `/v1/runs`)同一只规范化函数:
|
|
83
|
-
* `sha256(
|
|
83
|
+
* `sha256(canonicalJsonStringify(体 − taskId))` 的 hex(定宽 64)。
|
|
84
84
|
*
|
|
85
85
|
* 幂等 = 同一调用方、同一键、**同一请求**:账本行记下绑定 `Idempotency-Key` 的那次请求的指纹(`task_run.idem_body_fingerprint`),
|
|
86
86
|
* 同键再投而指纹不同 ⇒ 唯一回执函数答 409(`http/submit-replay.ts`)。规范化只有两步:
|
|
87
|
-
* · JSON 按键递归排序(唯一序列化器 `
|
|
87
|
+
* · JSON 按键递归排序(唯一序列化器 core `canonicalJsonStringify`;值为 `undefined` 的键与缺席同义)—— 键序不同的同一份体是同一请求;
|
|
88
88
|
* · 去掉 `taskId` —— 它是同一条律的**另一把钥匙**(调用方自铸的主键),由回执函数的「钥匙指向别的行 ⇒ `conflict.run_exists`」判,
|
|
89
89
|
* 不是请求内容(换腿重投:流式腿不带 → durable 腿带回 `x-task-id`,仍是同一请求)。
|
|
90
90
|
* 头一概不进:身份已在键里(`idemKeyOf` 的身份位),其余头(`Idempotency-Key` 本身、`x-detach-on-disconnect` 一类连接语义)不是提交内容。
|
|
@@ -109,7 +109,7 @@ export declare function submissionIdemOf(raw: string, caller: IdemCaller, body:
|
|
|
109
109
|
*/
|
|
110
110
|
export declare function inflightKeyOf(idem: RunIdemBinding, face: SubmitReplayFace, clientTaskId?: string): string;
|
|
111
111
|
/**
|
|
112
|
-
* 提交腿的**运行结局**(在飞合流共享的那一只)—— `status` + `body` 是它一直以来的两位;
|
|
112
|
+
* 提交腿的**运行结局**(在飞合流共享的那一只)—— `status` + `body` 是它一直以来的两位;[ref] 起多一位
|
|
113
113
|
* `wiringManifest`。
|
|
114
114
|
*
|
|
115
115
|
* 🔴 **为什么回执挂在 outcome 上、不铸进 `body`**(codex 对抗复审 [medium],红先复现后修):在飞合流按资源族
|
|
@@ -132,7 +132,7 @@ export declare function inflightKeyOf(idem: RunIdemBinding, face: SubmitReplayFa
|
|
|
132
132
|
export interface SubmitOutcome {
|
|
133
133
|
status: number;
|
|
134
134
|
body: unknown;
|
|
135
|
-
/**
|
|
135
|
+
/** [ref]:本条 run 的起手接线回执(present-iff 引擎真产了 `wiring_manifest` 帧)。 */
|
|
136
136
|
wiringManifest?: WiringManifestReceipt;
|
|
137
137
|
}
|
|
138
138
|
//# sourceMappingURL=idempotency.d.ts.map
|
package/dist/http/idempotency.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import { canonicalJsonStringify } from "@sema-agent/core";
|
|
3
3
|
import { gatedPrincipal } from "./principal-gate.js";
|
|
4
4
|
export class IdempotencyCache {
|
|
5
5
|
ttlMs;
|
|
@@ -80,7 +80,7 @@ export function idemKeyOf(raw, caller, family) {
|
|
|
80
80
|
}
|
|
81
81
|
export function submissionFingerprintOf(body) {
|
|
82
82
|
const content = body !== null && typeof body === "object" && !Array.isArray(body) ? { ...body, taskId: undefined } : body;
|
|
83
|
-
return createHash("sha256").update(
|
|
83
|
+
return createHash("sha256").update(canonicalJsonStringify(content)).digest("hex");
|
|
84
84
|
}
|
|
85
85
|
export function submissionIdemOf(raw, caller, body) {
|
|
86
86
|
return { key: idemKeyOf(raw, caller, "run"), bodyFingerprint: submissionFingerprintOf(body) };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] —— 一条 HTTP 请求愿意等**一次远端 MCP 拨号**多久:**一只数、一只 helper**,两口共读。
|
|
3
3
|
*
|
|
4
4
|
* 同一类动作(连一台远端 MCP 服务器 + 列它的工具)在本仓有两张 HTTP 面:
|
|
5
5
|
* · `GET /v1/sessions/:id/mcp` 面板(`routes/sessions.ts`)—— 物化部署缺省场景的申报,到点答 200 `degraded:true`;
|
|
6
6
|
* · `POST /v1/sessions/:id/mcp/reconnect`(`routes/mcp-reconnect.ts`)—— 在飞 run 上重拨一台,到点答 503。
|
|
7
|
-
* 修前面板有期限、reconnect 是裸 `await`(
|
|
7
|
+
* 修前面板有期限、reconnect 是裸 `await`([ref]):同一件事两个读法,一台拨不通 / 半开的远端能把后者挂很久。
|
|
8
8
|
* 两口各自**到点答什么**不同(面板是只读的部署面,有一个诚实的空形;reconnect 是一次交易,没有结果就没有
|
|
9
9
|
* 一个能当 `outcome` 的词)—— 但**等多久**是一个事实,所以只有一个数。
|
|
10
10
|
*
|
|
@@ -26,9 +26,11 @@ export declare class DeadlineExceeded extends Error {
|
|
|
26
26
|
* 让**应答**不再等 `work`:`work` 先落定就原样交出(resolve / reject 都不变形),期限先到就 reject
|
|
27
27
|
* {@link DeadlineExceeded}。
|
|
28
28
|
*
|
|
29
|
-
* 🔴
|
|
30
|
-
* `materializeMcpTools`
|
|
31
|
-
*
|
|
29
|
+
* 🔴 **只界应答,本身不取消 `work`**:本函数不持有任何取消把手 —— 取消是调用点的事,两口各自读 core 动词的形:
|
|
30
|
+
* · 面板的 `materializeMcpTools` 自 core 7.55.0([ref])起收末位 `signal`:面板在期限到点时触发它,在飞的拨号就停、半开连接被关
|
|
31
|
+
* (`routes/sessions.ts`);
|
|
32
|
+
* · reconnect 的 `TaskStream.reconnectMcpServer(server)` 仍不收 `AbortSignal`(d.ts 逐字)⇒ 期限到点后底层重拨**继续跑**,落定时
|
|
33
|
+
* 才释放它占的连接 / 子进程。这一口必须把这句话交代给调用方(reconnect 的 503 文案、契约 §G.7c)。
|
|
32
34
|
* 迟到的落定(尤其迟到的 reject)挂一条吞掉,免得没人 await 它时变成未处理拒绝。
|
|
33
35
|
*/
|
|
34
36
|
export declare function raceDeadline<T>(work: Promise<T>, deadlineMs: number): Promise<T>;
|