@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
package/dist/http/resume-legs.js
CHANGED
|
@@ -3,9 +3,10 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { uuidv7, resumeWithVerification, CheckpointError, defaultTaskRegistry, taskNotificationDedupKey, validatePendingSteer, GLOBAL_USAGE_KEY, PAUSE_REGISTRY } from "@sema-agent/core";
|
|
4
4
|
import { decideParkedAgent, denyWorkflowParkForked, denyWorkflowParksUnreadable, findParkOrigin, heldWorkflowParkDecisions, planWorkflowParkedDecide } from "../parked-decide.js";
|
|
5
5
|
import { parkDecisionFingerprint } from "../orchestration/workflow-park-decision.js";
|
|
6
|
+
import { headReadOf } from "../session-incarnation.js";
|
|
6
7
|
const DELIVERY_NOT_RECORDED = "workflow park decide: this delivery no longer holds the host session (its claim was released) — the decision was not recorded and this delivery was not started";
|
|
7
|
-
const
|
|
8
|
-
throw new Error(`parked decide cannot verify which occupant session ${sessionId} belongs to: this deployment's session store has no
|
|
8
|
+
const headUnavailable = async (sessionId) => {
|
|
9
|
+
throw new Error(`parked decide cannot verify which occupant session ${sessionId} belongs to: this deployment's session store has no head read (headOf; every built-in store has one) — refusing rather than resuming unverified`);
|
|
9
10
|
};
|
|
10
11
|
import { HttpError, decodeCheckpointScope, CHECKPOINT_PUBLIC_SCOPE } from "../security.js";
|
|
11
12
|
import { parkToolCallId, TurnAnchorCapture, HEARTBEAT_MS, markChildrenStoppedByUserOnAbort } from "../runs.js";
|
|
@@ -17,7 +18,8 @@ import { recordResumeResourceWindow } from "../resource-window.js";
|
|
|
17
18
|
import { emitPendingWorkflowCompletions, taskNotificationInboxEntry, taskNotificationStreamKeyOf, NotifiedKeys } from "../orchestration/workflow-completion-inbox.js";
|
|
18
19
|
import { fleetRunPublisher, fleetRunLabels, fleetRunResiduals, isFleetAgentTerminalNotification } from "../fleet/fleet-bus.js";
|
|
19
20
|
import { defaultSubagentTailBus } from "../fleet/subagent-tail-bus.js";
|
|
20
|
-
import {
|
|
21
|
+
import { currentApprovalGateToken } from "../approval-gate-currency.js";
|
|
22
|
+
import { createApprovalCardEmitter, declaredApprovalFrameFamilies, parkRowStandingAnswerFacts, resolveApprovalLeg, resolveStreamApprovalGate, standingAnswerDurablyRecordable } from "../tool-approval.js";
|
|
21
23
|
import { buildCheckpointAnchorHash } from "../approval-ask-audit-store.js";
|
|
22
24
|
import { APPROVAL_ENDING_CAUSES } from "../approval-deny-reasons.js";
|
|
23
25
|
import { serviceVersion } from "../service-version.js";
|
|
@@ -45,11 +47,11 @@ import { gatedPrincipal, explicitOperatorOk } from "./principal-gate.js";
|
|
|
45
47
|
import { buildActiveRunConflict, resumeEntryForGate } from "./active-run-conflict.js";
|
|
46
48
|
import { commitPlacement, devicePlacementErrorBody } from "./device-placement.js";
|
|
47
49
|
import { commitSessionInheritEnv } from "./session-inherit-env.js";
|
|
48
|
-
import { ASK_USER_QUESTION_TOOL_NAME } from "../approval-content-kind.js";
|
|
50
|
+
import { ASK_USER_QUESTION_TOOL_NAME, isApprovalGateKind } from "../approval-content-kind.js";
|
|
49
51
|
import { deploymentListAsks } from "../approval.js";
|
|
50
|
-
import { readResumeCtx, resumeCtxCorruptAnswer } from "./resume-ctx-read.js";
|
|
51
|
-
import { buildCheckpointVersionKeys, resumeBlockedByPolicyAnswer, resumeRefusalWithCard, storedBodyReplayAnswer, storedBodyReplayLogFields, withPermissionModeRewritten } from "./checkpoint-ctx.js";
|
|
52
|
-
import { refusalBody } from "./refusal-body.js";
|
|
52
|
+
import { readResumeCtx, resumeCtxCorruptAnswer, resumeCtxUnsealableAnswer } from "./resume-ctx-read.js";
|
|
53
|
+
import { buildCheckpointVersionKeys, resumeBlockedByPolicyAnswer, resumeRefusalWithCard, sealCheckpointCtx, storedBodyReplayAnswer, storedBodyReplayLogFields, withPermissionModeRewritten } from "./checkpoint-ctx.js";
|
|
54
|
+
import { refusalBody, resumeRefusalFacts } from "./refusal-body.js";
|
|
53
55
|
import { storedBodyReplayRefusal } from "./stored-body-replay.js";
|
|
54
56
|
import { httpErrorRefusal } from "./send.js";
|
|
55
57
|
import { createRunAcceptance } from "../run-acceptance.js";
|
|
@@ -91,6 +93,7 @@ const WORKER_SWAP_REDEEMABLE = {
|
|
|
91
93
|
registry_occupied: true,
|
|
92
94
|
unknown_model_ref: true,
|
|
93
95
|
not_a_model_ref: true,
|
|
96
|
+
unknown_role_word: true,
|
|
94
97
|
};
|
|
95
98
|
function checkpointRowRedeemableElsewhere(reason) {
|
|
96
99
|
return reason !== undefined && WORKER_SWAP_REDEEMABLE[reason] === true;
|
|
@@ -125,6 +128,9 @@ const CHECKPOINT_ERROR_DISPOSITION = {
|
|
|
125
128
|
"steering.invalid_content": "terminal",
|
|
126
129
|
"steering.queue_full": "terminal",
|
|
127
130
|
};
|
|
131
|
+
function windowZeroSeatOf(toolApproval) {
|
|
132
|
+
return (identity) => toolApproval.boundUnattendedAsk(identity, { arm: "window_zero" });
|
|
133
|
+
}
|
|
128
134
|
export function resumeRefusalDisposition(e) {
|
|
129
135
|
const word = Object.hasOwn(CHECKPOINT_ERROR_DISPOSITION, e.code) ? CHECKPOINT_ERROR_DISPOSITION[e.code] : undefined;
|
|
130
136
|
switch (word) {
|
|
@@ -149,6 +155,7 @@ const CHECKPOINT_ERROR_FIELD_ROLE = {
|
|
|
149
155
|
answer: "answer",
|
|
150
156
|
hostDecision: "outcome_cell",
|
|
151
157
|
approver: "outcome_cell",
|
|
158
|
+
feedback: "outcome_cell",
|
|
152
159
|
taskConfig: "config",
|
|
153
160
|
deps: "config",
|
|
154
161
|
inheritedGate: "config",
|
|
@@ -186,9 +193,7 @@ export function checkpointRefusalAnswer(e, at) {
|
|
|
186
193
|
errorCode: e.code === "checkpoint.invalid_outcome" ? (refusalCause !== undefined ? WIRE_CODE_OF_DECISION_REFUSAL[refusalCause] : UNCLASSIFIED_INVALID_OUTCOME_CODE) : e.code,
|
|
187
194
|
facts: {
|
|
188
195
|
...(at.taskId !== undefined ? { taskId: at.taskId } : {}),
|
|
189
|
-
...(detail
|
|
190
|
-
...(detail?.field ? { field: detail.field } : {}),
|
|
191
|
-
...(detail?.reason !== undefined ? { reason: detail.reason } : {}),
|
|
196
|
+
...resumeRefusalFacts(detail),
|
|
192
197
|
...((e.code === "resume.usage_window_exhausted" || e.code === "resume.preflight_rejected") && typeof detail?.retryAfterMs === "number" && Number.isFinite(detail.retryAfterMs) && detail.retryAfterMs > 0
|
|
193
198
|
? { retryAfterSec: Math.max(1, Math.ceil(detail.retryAfterMs / 1000)) }
|
|
194
199
|
: {}),
|
|
@@ -198,11 +203,12 @@ export function checkpointRefusalAnswer(e, at) {
|
|
|
198
203
|
}, at.retriable);
|
|
199
204
|
}
|
|
200
205
|
export function createResumeLegs(ctx) {
|
|
201
|
-
const { deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, safeDecode,
|
|
206
|
+
const { deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, safeDecode, runOwnerOk, sessionOwnerOk, runSessionAcceptOk, prepareSpec, finalizeTaskResult, ownerCostQuotaDenied, ownerFleetLeaseDenied, usageWindowDenialFor } = ctx;
|
|
207
|
+
const ctxOpening = (sessionId) => ({ sessionId, opener: deps.checkpointCtxSealing });
|
|
202
208
|
const resumeFleetScope = (req, auth) => req ? (gatedPrincipal(req, deps.config) ?? "default") : (auth.principal ?? "default");
|
|
203
209
|
async function resumeCheckpoint(sessionId, decision, reason, hostDecision, req, answer, binding, onResumeCommitted, acceptEarly, decider) {
|
|
204
210
|
const cs = deps.checkpointStore;
|
|
205
|
-
const token =
|
|
211
|
+
const token = await currentApprovalGateToken(cs, sessionId);
|
|
206
212
|
if (binding?.checkpointToken && binding.checkpointToken !== token) {
|
|
207
213
|
let seenUnreadable = false;
|
|
208
214
|
const seen = await cs.get(binding.checkpointToken).catch((e) => {
|
|
@@ -386,7 +392,7 @@ export function createResumeLegs(ctx) {
|
|
|
386
392
|
const parkedReq = {
|
|
387
393
|
token, scope: cp.scope, sessionId: cp.sessionId, pendingAction: cp.pendingAction,
|
|
388
394
|
decision, hostDecision, ...(reason !== undefined ? { reason } : {}),
|
|
389
|
-
...(binding !== undefined ? { binding:
|
|
395
|
+
...(binding !== undefined ? { binding: (({ checkpointToken: _staleGuardOnly, ...rest }) => rest)(binding) } : {}),
|
|
390
396
|
...(answer !== undefined ? { answer } : {}),
|
|
391
397
|
...(boundGrant ? { grantRemember: (rootSessionId) => boundGrant(rootSessionId) } : {}),
|
|
392
398
|
};
|
|
@@ -396,10 +402,10 @@ export function createResumeLegs(ctx) {
|
|
|
396
402
|
checkpointStore: cs,
|
|
397
403
|
registry: defaultTaskRegistry,
|
|
398
404
|
reviveSurface: parkedSurface,
|
|
399
|
-
|
|
405
|
+
headOf: headReadOf(deps.sessionStorage) ?? headUnavailable,
|
|
400
406
|
...(deps.parkedKnownAgentTypes ? { knownAgentTypes: deps.parkedKnownAgentTypes } : {}),
|
|
401
407
|
...(deps.parkedReviveInheritedGate ? { rebuildInheritedGate: deps.parkedReviveInheritedGate } : {}),
|
|
402
|
-
...(deps.toolApproval ? { approverSeatFor: deps.toolApproval
|
|
408
|
+
...(deps.toolApproval ? { approverSeatFor: windowZeroSeatOf(deps.toolApproval) } : {}),
|
|
403
409
|
...(deps.logger ? { warn: parkWarn } : {}),
|
|
404
410
|
}, parkedReq, { handle: origin.handle, row: origin.row }));
|
|
405
411
|
void ctxPromise.catch(() => { });
|
|
@@ -463,9 +469,11 @@ export function createResumeLegs(ctx) {
|
|
|
463
469
|
return out;
|
|
464
470
|
}
|
|
465
471
|
}
|
|
466
|
-
const ctxRead0 = await readResumeCtx(ctxPromise);
|
|
472
|
+
const ctxRead0 = await readResumeCtx(ctxPromise, ctxOpening(sessionId));
|
|
467
473
|
if (ctxRead0.kind === "corrupt")
|
|
468
474
|
return resumeCtxCorruptAnswer(ctxRead0.where);
|
|
475
|
+
if (ctxRead0.kind === "unsealable")
|
|
476
|
+
return resumeCtxUnsealableAnswer(ctxRead0);
|
|
469
477
|
const ctx = ctxRead0.kind === "ok" ? ctxRead0.ctx : null;
|
|
470
478
|
if (!ctx)
|
|
471
479
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
@@ -492,6 +500,7 @@ export function createResumeLegs(ctx) {
|
|
|
492
500
|
decision: decision === "approve" ? "allow" : "deny",
|
|
493
501
|
...(decision === "approve" && binding?.updatedInput !== undefined ? { updatedInput: binding.updatedInput } : {}),
|
|
494
502
|
...(reason ? { reason } : {}),
|
|
503
|
+
...(binding?.feedback !== undefined ? { feedback: binding.feedback } : {}),
|
|
495
504
|
...(answer !== undefined ? { answer } : {}),
|
|
496
505
|
hostDecision,
|
|
497
506
|
};
|
|
@@ -554,7 +563,7 @@ export function createResumeLegs(ctx) {
|
|
|
554
563
|
const resumeLegStartedAt = Date.now();
|
|
555
564
|
const { runner: legRunner, token, sessionId, principal, fleetScope, taskConfig, resumeObjective, outcome, verifyRounds, resumeCtx } = args;
|
|
556
565
|
const reparkStatus = outcome.gate === "plan_review" ? "needs_review" : "suspended";
|
|
557
|
-
const commitResumeCtx = () => deps.checkpointStore.putCtx(resumeCtx.sessionId, { ...resumeCtx.ctx, writerVersion: serviceVersion() }).catch((e) => {
|
|
566
|
+
const commitResumeCtx = () => Promise.resolve().then(() => deps.checkpointStore.putCtx(resumeCtx.sessionId, sealCheckpointCtx({ ...resumeCtx.ctx, writerVersion: serviceVersion() }, deps.checkpointCtxSealing, resumeCtx.sessionId))).catch((e) => {
|
|
558
567
|
deps.metrics?.inc("resume_ctx_not_persisted_total");
|
|
559
568
|
deps.logger?.warn?.("resume_ctx_not_persisted", { sessionId: resumeCtx.sessionId, gate: outcome.gate, error: errorText(e), note: "this continuation runs with the body it was given; the durable rebuild input still holds the PREVIOUS body, so the NEXT continuation of this session rebuilds from that one (never wider than this leg's)" });
|
|
560
569
|
});
|
|
@@ -563,7 +572,7 @@ export function createResumeLegs(ctx) {
|
|
|
563
572
|
toolApprovalEnabled: Boolean(deps.toolApproval),
|
|
564
573
|
streamApprovalEnabled: deps.config.streamApproval?.enabled === true,
|
|
565
574
|
backend: deps.backend,
|
|
566
|
-
|
|
575
|
+
checkpointStore: deps.checkpointStore,
|
|
567
576
|
}).active;
|
|
568
577
|
const approvalLeg = resolveApprovalLeg({
|
|
569
578
|
streamApprovalOn,
|
|
@@ -571,6 +580,7 @@ export function createResumeLegs(ctx) {
|
|
|
571
580
|
windowMarginMs: deps.config.streamAskWindowMarginMs,
|
|
572
581
|
...(typeof taskConfig.limits?.maxWalltimeMs === "number" ? { legWalltimeMs: taskConfig.limits.maxWalltimeMs } : {}),
|
|
573
582
|
nowMonotonicMs: performance.now(),
|
|
583
|
+
declaredFamilies: declaredApprovalFrameFamilies(resumeCtx.ctx.body.settings),
|
|
574
584
|
});
|
|
575
585
|
const legDeadlineMonotonic = approvalLeg.legDeadlineMonotonic;
|
|
576
586
|
const ownerQuotaDenial = args.callerInitiated === true ? ownerCostQuotaDenied(principal) : undefined;
|
|
@@ -609,8 +619,8 @@ export function createResumeLegs(ctx) {
|
|
|
609
619
|
const resumeTaskConfig = taskId ? { ...taskConfig, taskId } : taskConfig;
|
|
610
620
|
if (deps.toolApproval && taskId) {
|
|
611
621
|
const toolApproval = deps.toolApproval;
|
|
612
|
-
resumeTaskConfig.onAsk = approvalLeg.
|
|
613
|
-
? toolApproval.boundUnattendedAsk({ owner: principal ?? null, taskId, sessionId })
|
|
622
|
+
resumeTaskConfig.onAsk = approvalLeg.unattended
|
|
623
|
+
? toolApproval.boundUnattendedAsk({ owner: principal ?? null, taskId, sessionId }, approvalLeg.unattended)
|
|
614
624
|
: toolApproval.boundAsk({
|
|
615
625
|
owner: principal ?? null,
|
|
616
626
|
taskId,
|
|
@@ -849,9 +859,9 @@ export function createResumeLegs(ctx) {
|
|
|
849
859
|
if (deps.userInputLedger && taskId)
|
|
850
860
|
await deps.userInputLedger.announceUndrained({ sessionId, taskId });
|
|
851
861
|
const anchorOwner = principal ?? null;
|
|
852
|
-
const
|
|
853
|
-
const captureTurnAnchor = deps.resumeAnchorStore &&
|
|
854
|
-
? async (eventId) => { const leaf = await
|
|
862
|
+
const headOf = headReadOf(deps.sessionStorage);
|
|
863
|
+
const captureTurnAnchor = deps.resumeAnchorStore && headOf
|
|
864
|
+
? async (eventId) => { const leaf = (await headOf(sessionId))?.leafId; if (leaf)
|
|
855
865
|
await deps.resumeAnchorStore.put(sessionId, eventId, leaf, anchorOwner); }
|
|
856
866
|
: undefined;
|
|
857
867
|
const captureUserMessageAnchor = deps.resumeAnchorStore && taskId
|
|
@@ -1097,7 +1107,7 @@ export function createResumeLegs(ctx) {
|
|
|
1097
1107
|
const { type, ...rest } = frame;
|
|
1098
1108
|
return append(type, rest);
|
|
1099
1109
|
};
|
|
1100
|
-
const withApproval = () => deps.toolApproval && taskId && approvalLeg.active &&
|
|
1110
|
+
const withApproval = () => deps.toolApproval && taskId && approvalLeg.active && approvalLeg.unattended === undefined
|
|
1101
1111
|
? deps.toolApproval.runWithContext({
|
|
1102
1112
|
taskId,
|
|
1103
1113
|
owner: principal ?? null,
|
|
@@ -1274,9 +1284,11 @@ export function createResumeLegs(ctx) {
|
|
|
1274
1284
|
if (gateKind !== RESUMABLE_GATE_KIND) {
|
|
1275
1285
|
return { status: 409, body: refusalBody({ errorCode: "gate_not_resumable", message: `task is suspended on a '${gateKind ?? "unknown"}' gate, not a resumable resource/preempt suspension — an approval gate must be decided via POST /v1/approvals/:id/decide` }) };
|
|
1276
1286
|
}
|
|
1277
|
-
const ctxRead = await readResumeCtx(cs.getCtx(sessionId));
|
|
1287
|
+
const ctxRead = await readResumeCtx(cs.getCtx(sessionId), ctxOpening(sessionId));
|
|
1278
1288
|
if (ctxRead.kind === "corrupt")
|
|
1279
1289
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1290
|
+
if (ctxRead.kind === "unsealable")
|
|
1291
|
+
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1280
1292
|
if (ctxRead.kind === "absent")
|
|
1281
1293
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
1282
1294
|
const ctx = ctxRead.ctx;
|
|
@@ -1294,9 +1306,11 @@ export function createResumeLegs(ctx) {
|
|
|
1294
1306
|
if (!deps.runStore) {
|
|
1295
1307
|
return { status: 501, body: refusalBody({ errorCode: "capability.run_store_required", message: "delivering this decision requires a durable run store (DB_BACKEND=mysql|pg|local)" }) };
|
|
1296
1308
|
}
|
|
1297
|
-
const ctxRead = await readResumeCtx(cs.getCtx(sessionId));
|
|
1309
|
+
const ctxRead = await readResumeCtx(cs.getCtx(sessionId), ctxOpening(sessionId));
|
|
1298
1310
|
if (ctxRead.kind === "corrupt")
|
|
1299
1311
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1312
|
+
if (ctxRead.kind === "unsealable")
|
|
1313
|
+
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1300
1314
|
const ctx = ctxRead.kind === "ok" ? ctxRead.ctx : null;
|
|
1301
1315
|
if (!ctx) {
|
|
1302
1316
|
return {
|
|
@@ -1385,9 +1399,11 @@ export function createResumeLegs(ctx) {
|
|
|
1385
1399
|
throw e;
|
|
1386
1400
|
}
|
|
1387
1401
|
}
|
|
1388
|
-
const ctxRead = await readResumeCtx(cs.getCtx(sessionId));
|
|
1402
|
+
const ctxRead = await readResumeCtx(cs.getCtx(sessionId), ctxOpening(sessionId));
|
|
1389
1403
|
if (ctxRead.kind === "corrupt")
|
|
1390
1404
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1405
|
+
if (ctxRead.kind === "unsealable")
|
|
1406
|
+
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1391
1407
|
if (ctxRead.kind === "absent")
|
|
1392
1408
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
1393
1409
|
const ctx = ctxRead.ctx;
|
|
@@ -1474,9 +1490,11 @@ export function createResumeLegs(ctx) {
|
|
|
1474
1490
|
}),
|
|
1475
1491
|
});
|
|
1476
1492
|
}
|
|
1477
|
-
const ctxRead = await readResumeCtx(cs.getCtx(sessionId));
|
|
1493
|
+
const ctxRead = await readResumeCtx(cs.getCtx(sessionId), ctxOpening(sessionId));
|
|
1478
1494
|
if (ctxRead.kind === "corrupt")
|
|
1479
1495
|
return refuse(resumeCtxCorruptAnswer(ctxRead.where));
|
|
1496
|
+
if (ctxRead.kind === "unsealable")
|
|
1497
|
+
return refuse(resumeCtxUnsealableAnswer(ctxRead));
|
|
1480
1498
|
if (ctxRead.kind === "absent")
|
|
1481
1499
|
return refuse({ status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) });
|
|
1482
1500
|
const replay = storedBodyReplayRefusal(ctxRead.ctx, deps.config);
|
|
@@ -1514,7 +1532,7 @@ export function createResumeLegs(ctx) {
|
|
|
1514
1532
|
const routeCtxBase = {
|
|
1515
1533
|
deps,
|
|
1516
1534
|
registry: { idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters },
|
|
1517
|
-
helpers: { readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, safeDecode,
|
|
1535
|
+
helpers: { readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, safeDecode, runOwnerOk, sessionOwnerOk, runSessionAcceptOk },
|
|
1518
1536
|
local: { images: createImagesLocal(deps), sessions: createSessionsLocal(), sessionSync: createSessionSyncLocal(), capabilities: createCapabilitiesLocal() },
|
|
1519
1537
|
legs: { prepareSpec, finalizeTaskResult, resumeCheckpoint, driveResumeIntoRunLog, resumePreempted, resumeWake, preparePlanReview, drivePlanReview },
|
|
1520
1538
|
};
|
package/dist/http/route-ctx.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import type { PlanApprovePermissionModeAfter } from "../task-settings.js";
|
|
|
30
30
|
import type { VerifyRoundsSpec } from "./verify-rounds.js";
|
|
31
31
|
import type { RunAbort } from "../run-cancel-context.js";
|
|
32
32
|
/** 跨域可变状态 = lens1 §C2 实测的那 8 条「运行期登记簿」,一个对象。
|
|
33
|
-
*
|
|
33
|
+
* [ref]:`cancelledViaVerb`(按 taskId 键控的「这次是取消动词」旁表)删除 —— 中止成因改挂在每条腿自己的
|
|
34
34
|
* {@link RunAbort} 句柄上(`inflightRuns` 的值),同寿同删,不再有一张与腿不同寿的旁表。 */
|
|
35
35
|
export interface RunRegistry {
|
|
36
36
|
idemCache: IdempotencyCache<SubmitOutcome>;
|
|
@@ -73,21 +73,12 @@ export interface RouteHelpers {
|
|
|
73
73
|
/** [ref]-T1:治理窗 pre-admission(异步 202 车道的唯一 429 出路;key 公式与 core 单源)。 */
|
|
74
74
|
usageWindowDenied(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
|
|
75
75
|
safeDecode(seg: string): string | null;
|
|
76
|
-
isFleetWide(req: IncomingMessage): boolean;
|
|
77
76
|
/** run 面的属主门(谓词 `runOwnerReadable`;非属主 ⇒ 404 `not_found.run` + 长文,与 run 读口的 unknown 臂同码同串,[ref])。 */
|
|
78
77
|
runOwnerOk(req: IncomingMessage, res: ServerResponse, owner: string | null): boolean;
|
|
79
|
-
/** 会话面的属主门(谓词 `sessionOwnerReadable`,
|
|
80
|
-
* {@link SESSION_NOT_FOUND_MESSAGE},与会话读口的 unknown 臂同码同串 —— G52 [ref] /
|
|
81
|
-
* `cell` = 调用点经 `security.ts` 的 `sessionOwnerCellOf` 读出的那一格(
|
|
78
|
+
/** 会话面的属主门(谓词 `sessionOwnerReadable`,[ref]:没有身份边界的部署不钉人,与会话列表同读;非属主 ⇒ 404 `not_found.session` +
|
|
79
|
+
* {@link SESSION_NOT_FOUND_MESSAGE},与会话读口的 unknown 臂同码同串 —— G52 [ref] / [ref])。每一个按会话寻址的属主判都走它。
|
|
80
|
+
* `cell` = 调用点经 `security.ts` 的 `sessionOwnerCellOf` 读出的那一格([ref]:无主的委派子代 placed 行只对 fleet 调用方放行,判据 `ownerlessRowOpen`)。 */
|
|
82
81
|
sessionOwnerOk(req: IncomingMessage, res: ServerResponse, cell: SessionOwnerCell): boolean;
|
|
83
|
-
sessionOwnerScope(req: IncomingMessage): {
|
|
84
|
-
fleetWide: boolean;
|
|
85
|
-
gateOwner: string | null;
|
|
86
|
-
};
|
|
87
|
-
sessionOwnerScopeForWrite(req: IncomingMessage): {
|
|
88
|
-
fleetWide: boolean;
|
|
89
|
-
gateOwner: string | null;
|
|
90
|
-
};
|
|
91
82
|
runSessionAcceptOk(req: IncomingMessage, res: ServerResponse, run: {
|
|
92
83
|
sessionId: string | null;
|
|
93
84
|
}, face: string, notFoundError?: string): boolean;
|
|
@@ -96,7 +87,7 @@ export interface RouteHelpers {
|
|
|
96
87
|
* (模块级会把 rate-limiter / 缓存跨实例串味,测试里一个进程建几十个 server)。 */
|
|
97
88
|
export interface RouteLocals {
|
|
98
89
|
images: ImagesLocal;
|
|
99
|
-
/**
|
|
90
|
+
/** [ref]:`GET /v1/capabilities/mcp` / `POST /v1/capabilities/mcp/probe` 的 TTL 缓存与每 principal 限速窗。 */
|
|
100
91
|
capabilities: CapabilitiesLocal;
|
|
101
92
|
sessions: SessionsLocal;
|
|
102
93
|
sessionSync: SessionSyncLocal;
|
|
@@ -131,7 +122,7 @@ export interface PreparedTaskSubmission {
|
|
|
131
122
|
cascade?: boolean;
|
|
132
123
|
jobId?: string;
|
|
133
124
|
body: TaskRequestBody;
|
|
134
|
-
/**
|
|
125
|
+
/** [ref]:**装配期**铸下的、这条会话的用户面 `EngineNotice`(今天两族:请求腿 MCP 注入被丢弃;入口地板钳制 `permission.entry_mode_clamped`)。
|
|
135
126
|
* 装配跑在这条腿的通告口开张之前,所以铸点交不出去 —— 由腿在 `registerEngineNoticeLeg` 那一拍
|
|
136
127
|
* 经 `pending` 一起投(投递单点仍是那一只注册助手,不新开第二条机制)。缺席 = 本次装配没铸下任何通告。 */
|
|
137
128
|
engineNotices?: readonly EngineNotice[];
|
|
@@ -142,7 +133,7 @@ export interface PreparedTaskSubmission {
|
|
|
142
133
|
*/
|
|
143
134
|
warnings?: readonly EntryProblem[];
|
|
144
135
|
/**
|
|
145
|
-
*
|
|
136
|
+
* [ref](device lane 首绑写协议,design §4.3.2 两阶段 placement)—— **已校验、未写库**的 placement 意图。
|
|
146
137
|
*
|
|
147
138
|
* 缺席的两种含义都等价于「本腿没有 placement 要提交」:①本部署不是 device 车道(绝大多数);
|
|
148
139
|
* ②本腿不是 fresh 根提交(resume 家族根本不经 `prepareSpec`)。在场 ⇒ 每个 `runStore.createRun(`
|
|
@@ -159,7 +150,7 @@ export interface PreparedTaskSubmission {
|
|
|
159
150
|
/**
|
|
160
151
|
* 一条会话的**续跑重建输入**(`checkpoint_ctx` 的行体)—— 提交腿写一次,续跑腿读它重建 spec。
|
|
161
152
|
*
|
|
162
|
-
*
|
|
153
|
+
* [ref] F2 起命名化(此前是五处结构等价的内联字面 `{ body: TaskRequestBody; memoryScope?: string }`):
|
|
163
154
|
* 它同时是 {@link DriveResumeArgs.resumeCtx} 的形,而那一位是**写回**口 —— 读形与写形是同一件东西这句话
|
|
164
155
|
* 得由类型说,不能靠五处手抄碰巧一致。
|
|
165
156
|
*/
|
|
@@ -168,9 +159,9 @@ export interface CheckpointCtx {
|
|
|
168
159
|
/** 提交时这条会话绑定的记忆域(重建 `RequestAuth` 用);缺席 = 没有记忆面。 */
|
|
169
160
|
memoryScope?: string;
|
|
170
161
|
/**
|
|
171
|
-
* 🔴
|
|
162
|
+
* 🔴 [ref] 候裁 18(codex r3 F1)—— 这条会话的 run 是**无人值守腿**铸的(今天唯一的写者 = leader worker 的 durable 块,
|
|
172
163
|
* `leader/wire.ts`),**服务端写、不来自请求体**(`body` 是提交体;本位是它的兄弟键,客户端够不着)。
|
|
173
|
-
* 续跑家族据此请 `resolveSpec` 带 `unattendedLeg: true`,由它经首跑同一只合并口 `withUnattendedLeg` 重挂整条腿(
|
|
164
|
+
* 续跑家族据此请 `resolveSpec` 带 `unattendedLeg: true`,由它经首跑同一只合并口 `withUnattendedLeg` 重挂整条腿([ref] ①:`default` +
|
|
174
165
|
* 按类作答的 onAsk)—— onAsk 是活闭包、进不了 checkpoint,而 core 在 spec 不说模式时取 checkpoint 记下的那一个(`seat ?? recorded`),
|
|
175
166
|
* 不重挂 = 续跑落 checkpoint 记下的旧模式(7.106.0–7.108.0 的行记 `bypassPermissions`)而按类作答缺席。写回口(`DriveResumeArgs.resumeCtx`)
|
|
176
167
|
* 传原 ctx / 其展开 ⇒ 标随行。缺席 = 不是无人值守腿(HTTP 提交腿;7.106.0 前落盘的行 —— 那时这些腿不铸模式,checkpoint 里也没有)。
|
|
@@ -192,7 +183,7 @@ export interface CheckpointCtx {
|
|
|
192
183
|
*/
|
|
193
184
|
permissionModeReading?: import("./checkpoint-ctx.js").PermissionModeReading;
|
|
194
185
|
/**
|
|
195
|
-
* 🔴
|
|
186
|
+
* 🔴 [ref] —— **写这份上下文的服务版本**(`package.json` 的 `version`),**服务端写、不来自请求体**(与 {@link unattendedLeg} 同为 `body` 的兄弟键)。
|
|
196
187
|
* 写点两个:`buildCheckpointCtx`(每一次新的持久化写)与续跑腿的写回({@link DriveResumeArgs.resumeCtx} 的唯一写点,CAS 赢点盖本进程的版本 —— 接下来写下一张停车行的就是它)。
|
|
197
188
|
* 读者:`checkpoint.unsupported_version` 的 409 体 —— 原样带出 `writerVersion`,与本引擎的 `readerVersion` 并列(运维据此知道该回哪一版去决);
|
|
198
189
|
* 两键唯一铸法 `checkpoint-ctx.ts` `buildCheckpointVersionKeys`,本码每个铸点同调。它是**上下文**,不是拒因:成因与码都不读它。
|
|
@@ -226,9 +217,9 @@ export interface WorkflowDecisionDelivery {
|
|
|
226
217
|
export interface DriveResumeArgs {
|
|
227
218
|
token: CheckpointToken;
|
|
228
219
|
/**
|
|
229
|
-
* 🔴 **
|
|
220
|
+
* 🔴 **[ref] 合并复审 F2 [high] —— 「本次续跑真正用的那个体」,由本腿在赢下 CAS 之后写回耐久层**
|
|
230
221
|
* (验真后修;必填 —— `driveResumeIntoRunLog` 今天恰有**四个**调用点:legacy `/decide`(`resumeCheckpoint`)、
|
|
231
|
-
* `resumePreempted`、`resumeWake`、`drivePlanReview`(
|
|
222
|
+
* `resumePreempted`、`resumeWake`、`drivePlanReview`([ref] 前名 `resumePlanReview`),四条一视同仁)。
|
|
232
223
|
*
|
|
233
224
|
* 病(修前):`resumePlanReview` 在 `driveResumeIntoRunLog` **受理(2xx)之后**才 `putCtx(sessionId,
|
|
234
225
|
* {...ctx, body})`,而 `ctx` 是请求**开头** `getCtx` 读到的那一份,两个店的 `putCtx` 又都是按
|
|
@@ -270,7 +261,7 @@ export interface DriveResumeArgs {
|
|
|
270
261
|
outcome: ResumeOutcome;
|
|
271
262
|
verifyRounds: VerifyRoundsSpec | undefined;
|
|
272
263
|
/**
|
|
273
|
-
* **R-1**(车CJ 收车档 §10 R-1;
|
|
264
|
+
* **R-1**(车CJ 收车档 §10 R-1;[ref] 批落地)—— 本条 resume 腿**装配期**铸下的用户面通告
|
|
274
265
|
* (`PreparedTaskSubmission.engineNotices` 的 resume 孪生;今天唯一一族:`mcp.injection_dropped`)。
|
|
275
266
|
*
|
|
276
267
|
* 为什么 resume 腿也要投:一条 park 任务的 body 是**存量**的,它自己那几条丢弃在首跑那一拍确实已经
|
|
@@ -329,7 +320,7 @@ export interface DriveResumeArgs {
|
|
|
329
320
|
* 为什么系统腿必须豁免(亲核后改的判据,首版曾一并拦下 sweep):sweep 的活是把过了 SLA 的卡**结算掉**
|
|
330
321
|
* (graceful deny → 行收敛 → 释放 `task_active` claim)。拦住它并不能省钱,只会让超顶租户的卡**挂着**
|
|
331
322
|
* —— 而挂多久的兜底**比首版注释里写的差得多**:`checkpoint-store-sql.ts` 的 `reapExpired` 在
|
|
332
|
-
* **deadline
|
|
323
|
+
* **deadline 分支**上排除了读作 facet `A` 的审批门行(7.135.0 起是由 core 两张表生成的谓词;更早是门型 IN 字面 + 问答工具名臂),
|
|
333
324
|
* 所以一张过期的 human / irreversible_ask 卡根本不走那条腿;真正兜住它的只有绝对 backstop
|
|
334
325
|
* `terminal_at_ms`(`TERMINAL_BACKSTOP_MS` 默认 **30 天**)。于是「拦 sweep」= 把一个由
|
|
335
326
|
* `APPROVAL_TIMEOUT_SEC` 界定的 SLA 换成「等成本窗滚过(`COST_QUOTA_WINDOW_SEC` 默认 24h)、最坏等 30 天」,
|
|
@@ -367,7 +358,7 @@ export interface DriveResumeArgs {
|
|
|
367
358
|
ownerLeaseAdmitted?: boolean;
|
|
368
359
|
}
|
|
369
360
|
/**
|
|
370
|
-
*
|
|
361
|
+
* [ref](7.97.0):plan_review 纯读段全部过关后交给驱动段的那一份 —— **选中的那张卡**(token + 载入的行)与**它那一刻**
|
|
371
362
|
* 的续跑上下文。三者一起走:驱动段只认这张卡,ctx 读绑在它上面(读在选卡之后;之后任何 ctx 写都得先赢这张卡的
|
|
372
363
|
* CAS,于是一份过期的读只会让驱动段在 CAS 上败,不会被配给别的卡)。
|
|
373
364
|
*/
|
|
@@ -407,12 +398,12 @@ export interface RouteLegs {
|
|
|
407
398
|
* `hostDecision` = **这次结算的事实**(谁结束了这次等待 + 通道自报的归属),必填:本腿有两个调用方
|
|
408
399
|
* (HTTP `/decide` = 人;内部 D-D SLA deny-sweep = 窗到期),而函数内部分辨不出谁在叫它 —— 必填参数把
|
|
409
400
|
* 「漏报出处」变成编译错,不是一条下游把「没人答」渲染成「有人拒」的静默假出处。
|
|
410
|
-
* 🔴
|
|
401
|
+
* 🔴 [ref](core 7.6.0 S6-A):宿主报事实、core 铸词 —— server 不再传结算词(旧形传 core 的三词之一,
|
|
411
402
|
* 于是「哪个词配哪个 decision」这条相容规则要 server 自己记,而记错的方向恰是上面那句要防的)。 */
|
|
412
403
|
resumeCheckpoint(sessionId: string, decision: "approve" | "deny", reason: string | undefined, hostDecision: HostDecision, req?: IncomingMessage, answer?: QuestionAnswer, binding?: DecideBinding,
|
|
413
404
|
/** [ref] codex R4(验真后修):remember 豁免的 grant 挂点。**工具名不再由路由自己读**(那是与本函数
|
|
414
405
|
* 载入行分歧的第三次 scope-less 读,三读分歧下会给他人工具落豁免=提权)——由本函数把**已属主校验的
|
|
415
|
-
* 载入 cp** 的可记工具名(`rememberableToolName`,非 tool_approval / AskUserQuestion / legacy null /
|
|
406
|
+
* 载入 cp** 的可记工具名(`rememberableToolName`,非 tool_approval / AskUserQuestion / legacy null / [ref] 强制卡 ⇒ `null`
|
|
416
407
|
* = 无可记)一并回传,路由只对这个逐字落店。`overrideSessionId` = parked 腿的 root/host 会话 grant 锚。 */
|
|
417
408
|
onResumeCommitted?: (grant: {
|
|
418
409
|
overrideSessionId?: string;
|
|
@@ -451,7 +442,7 @@ export interface RouteLegs {
|
|
|
451
442
|
* 而两条腿共用这一条驱动路径正是 `notify-wake.ts` 那条「wake 会烧模型,所以复用 resume 家族的同一条腿」的成文纪律。 */
|
|
452
443
|
workflowDecision?: WorkflowDecisionDelivery): Promise<HostLegOutcome>;
|
|
453
444
|
/**
|
|
454
|
-
* assistant plan_review 三态腿的**纯读段**(
|
|
445
|
+
* assistant plan_review 三态腿的**纯读段**([ref],7.97.0):选卡 → 属主轻读 → 载入 → 行级 scope → 门类 → 这条决断
|
|
455
446
|
* 唯一的一次 ctx 读。任何一步拒 ⇒ `{ok:false, answer}`(不改任何状态;端点在消费一次性 nonce **之前**把它答出去);
|
|
456
447
|
* 全部过关 ⇒ `{ok:true, prepared}`,交给 {@link RouteLegs.drivePlanReview}。语义属主 = `resume-legs.ts` 同名函数顶注。
|
|
457
448
|
*/
|
|
@@ -476,13 +467,13 @@ export interface RouteLegs {
|
|
|
476
467
|
readonly ok: true;
|
|
477
468
|
readonly prepared: PreparedPlanReview;
|
|
478
469
|
}>;
|
|
479
|
-
/** plan_review 三态腿的**驱动段**(
|
|
470
|
+
/** plan_review 三态腿的**驱动段**([ref]):只吃 prepare 的结果,用它选定的 token,不再选卡、不再读 ctx。 */
|
|
480
471
|
drivePlanReview(prepared: PreparedPlanReview, decision: "approve" | "edit" | "reject", editedPlan: string | undefined, reason: string | undefined,
|
|
481
|
-
/** core 7.49.0
|
|
472
|
+
/** core 7.49.0 [ref]:决策事实(谁决定的 + 归属),语义属主 = `resume-legs.ts` 的同名形参顶注。 */
|
|
482
473
|
hostDecision: HostDecision, req: IncomingMessage | undefined,
|
|
483
474
|
/** [ref] 件 S-1:透传给 {@link DriveResumeArgs.acceptEarly}(200 受理语义)。HTTP `/plan_review` 腿传 `true`。 */
|
|
484
475
|
acceptEarly?: boolean,
|
|
485
|
-
/**
|
|
476
|
+
/** [ref]:批准之后这条会话继续用的 permission mode(闭集 `PLAN_APPROVE_PERMISSION_MODES_AFTER`;只在把计划带出 plan 的决定
|
|
486
477
|
* —— `approve` / `edit` —— 上有意义,缺席 ⇒ `"default"`)。语义与判据的唯一属主 = `resume-legs.ts` 的同名形参顶注。 */
|
|
487
478
|
permissionModeAfter?: PlanApprovePermissionModeAfter): Promise<{
|
|
488
479
|
status: number;
|
|
@@ -557,7 +548,7 @@ export interface RouteCtx extends RouteCtxBase {
|
|
|
557
548
|
req: RouteRequestState;
|
|
558
549
|
}
|
|
559
550
|
/**
|
|
560
|
-
* 域入口的签名(
|
|
551
|
+
* 域入口的签名([ref] 第三刀 车②)。
|
|
561
552
|
*
|
|
562
553
|
* 🔴 **`url` 与「已处理」布尔一并删掉**,零别名([ref] 硬 breaking):分派器已经**匹配过一次**并把
|
|
563
554
|
* 结果整个交进来(`match`),所以一只 handler 既不需要再判路,也不可能「没匹配上」——「返回 false
|
|
@@ -620,7 +611,7 @@ export interface RouteDeclFacts {
|
|
|
620
611
|
* 503 照旧罩着(它判的是「这台机能不能收写」,与方法无关,且必须在解析请求体之前)。 */
|
|
621
612
|
readonly methodDispatched?: true;
|
|
622
613
|
}
|
|
623
|
-
/** **可分派行**多出来的列(
|
|
614
|
+
/** **可分派行**多出来的列([ref] 第三刀):身份 + 它真认的方法(+ [ref] 的订阅类)。纯门行一列都没有(见下)。 */
|
|
624
615
|
interface RouteDeclIdentity {
|
|
625
616
|
/** **全表唯一**的行名(kebab 闭集词)。这是声明行的身份:域 handler 用
|
|
626
617
|
* `switch (match.decl.id)` 闭集分派(漏一口 = 编译红),所以它必须稳定、唯一、且与路径解耦
|
|
@@ -636,7 +627,7 @@ interface RouteDeclIdentity {
|
|
|
636
627
|
* tasks 的 POST;`/v1/memory/export` = memory-policy 的 GET + memory-bundle 的 POST)。 */
|
|
637
628
|
readonly methods: readonly RouteMethod[];
|
|
638
629
|
/**
|
|
639
|
-
* 「这条 GET 开的是一条**只读订阅**」—— 一条 SSE 读面(推送队列 / 账本 tail),它看着别人干活,自己不是活(
|
|
630
|
+
* 「这条 GET 开的是一条**只读订阅**」—— 一条 SSE 读面(推送队列 / 账本 tail),它看着别人干活,自己不是活([ref])。
|
|
640
631
|
* 在场 ⇒ 分派器不把它记进在飞(`drainState.inflight()`:排空等的、`/health` 报的、SIGHUP 空闲窗与附着租约读的那一只),只记进附着
|
|
641
632
|
* (`attachedStreams()`:壳还挂在这只引擎上);排空进入那一拍(以及硬停起点)由分派器发一帧 `draining` 终帧后关掉它
|
|
642
633
|
* (`drainState.endSubscriptions`)。闭集 = 八条 GET SSE 读面,逐行理由见各行注;**唯一**一条「在飞腿的流」`POST /v1/tasks/stream`
|
|
@@ -684,7 +675,7 @@ export type RouteDecl = RouteDispatchDecl | RouteGateDecl;
|
|
|
684
675
|
* 「中止抛穿」臂、一切 4xx / 拒绝出口一律**不铸**(缺席 ⇒ 证不出提交,读者按「没提交」读 —— fail-closed)。
|
|
685
676
|
*
|
|
686
677
|
* 读者:`/decide` 的两道「这次决定提交了没有」门 —— [ref] 迟到结算留痕(`noteLateSettleIfAccepted`)与 remember 豁免落店
|
|
687
|
-
* (`routes/approvals-assistant.ts`)。它们原先只读 wire 体的 `errorCode !== "cancelled"`(「取消 = 决定没提交」),
|
|
678
|
+
* (`routes/approvals-assistant.ts`)。它们原先只读 wire 体的 `errorCode !== "cancelled"`(「取消 = 决定没提交」),[ref] 给续跑腿补了
|
|
688
679
|
* 「引擎受理之后才被取消」的取消终局之后,`cancelled` 不再等价「没提交」⇒ 两门改读本位:`200 ∧ (errorCode≠cancelled ∨ decisionCommitted)`。
|
|
689
680
|
* 🔴 为什么不放进 `result.cancelContext`(主会话初稿的落点):那只快照的契约是「分诊材料,不是状态机输入:任何门 / CAS / resume 判定都不许
|
|
690
681
|
* 读它」(`plugins/store-contracts.ts` `RunCancelContext` 顶注)—— 这两道门正是判定;而且门读的是 `/decide` 的平面体、看不到结果对象。
|
|
@@ -696,7 +687,7 @@ export interface EngineLegOutcome {
|
|
|
696
687
|
decisionCommitted?: true;
|
|
697
688
|
}
|
|
698
689
|
/**
|
|
699
|
-
* **workflow 宿主腿的结局(wake / fresh)—— 型上就没有 `decisionCommitted`**(
|
|
690
|
+
* **workflow 宿主腿的结局(wake / fresh)—— 型上就没有 `decisionCommitted`**([ref] ②,7.113.0;`never` 让「这条路径不铸」成为**编译事实**,不是靠人记)。
|
|
700
691
|
*
|
|
701
692
|
* 为什么这条路径不该有该位:`/decide` 的 workflow 第三条车道(`resumeCheckpoint` 的 parked 分流,`planWorkflowParkedDecide` 之后)与 `POST /v1/sessions/:id/wake`
|
|
702
693
|
* 把决定 / 消息交给**宿主会话的下一跑**(`resumeWake` / `startFreshHostTurn`)。它们的 200 只到「已交给宿主的下一跑」—— 子代 checkpoint 的 resolve CAS 发生在
|
|
@@ -719,7 +710,7 @@ export declare function buildHostLegOutcome(out: {
|
|
|
719
710
|
body: object;
|
|
720
711
|
}): HostLegOutcome;
|
|
721
712
|
/**
|
|
722
|
-
* **「决定/续跑已受理」那一枚 200 收据的单一铸点**(
|
|
713
|
+
* **「决定/续跑已受理」那一枚 200 收据的单一铸点**([ref])。
|
|
723
714
|
*
|
|
724
715
|
* 两条腿投同一份体:①resume 家族的受理点(`driveResumeLeg`,宿主停在 park 上时);②`/decide` 的
|
|
725
716
|
* workflow 第三条车道在宿主**不在** park 上时新铸的那一跑。契约上这两条腿说的是同一句话 ——
|
|
@@ -743,7 +734,7 @@ export declare const RUN_NOT_FOUND_MESSAGE = "run not found \u2014 the id belong
|
|
|
743
734
|
* 会话资源面 404 的**唯一一句**(与 {@link RUN_NOT_FOUND_MESSAGE} 同一冻结纪律,常量锚在 `test/api-error-text-freeze.test.ts`)。
|
|
744
735
|
*
|
|
745
736
|
* 为什么是常量不是各点字面量:这句话要在**每一个**会话面的「不存在」臂与「非属主」臂上逐字节同串(G52 [ref] /
|
|
746
|
-
*
|
|
737
|
+
* [ref] —— 两臂差一个码或一个字就是单端点内的存在性 oracle)。十余个出站点各抄一份,漂开的那天没有任何东西会说话;
|
|
747
738
|
* 走一只常量 + `runOwnerOk(..., "session")` 的会话拼法,「改一处」就是改全域。
|
|
748
739
|
*/
|
|
749
740
|
export declare const SESSION_NOT_FOUND_MESSAGE = "session not found";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* **路由声明表**(
|
|
2
|
+
* **路由声明表**([ref],[ref] 波 2 第二刀)—— 「这是什么路由」这件事在本仓的**唯一属主**。
|
|
3
3
|
*
|
|
4
|
-
* ## 病(
|
|
4
|
+
* ## 病([ref] 债行原文的读数)
|
|
5
5
|
* 同一件事此前有五份写法、两道扫源码文本的对账门,而那两道门已经**反向塑形了源码**:表里必须写
|
|
6
6
|
* 字面量不许引常量(否则门的正则抓不到)、注释里不许出现某两个字符(否则门的非贪婪捕获提前收尾)。
|
|
7
7
|
* ① 分派序 = `handle()` 里 37 只 `if (await handleX(...)) return;`,鉴权/排空/破坏性写三道门按**行号**
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
* · `ROUTES` —— **行序 = 分派序**,`position` 说它在全局服务凭据门的哪一侧。门不再「按行号插在链中间」,
|
|
19
19
|
* 而是在 `pre` 段与 `post` 段之间**恒定一处**执行 ⇒ ① 与 ② 合一(名册就是分派序本身,两者再不可能漂),
|
|
20
20
|
* 那道「从 handle() 源码抽序对拍」的门随之删掉 —— 不是放松,是它守的事变成了结构上不可违反。
|
|
21
|
-
* 🔴
|
|
21
|
+
* 🔴 [ref] 第三刀 车②:**matcher 落地**。一行多了 `decls` 一列(本域真应答的口集合),而
|
|
22
22
|
* `ROUTE_DECLARATIONS` 就是这一列按行序摊平 ⇒「分派表」与「声明表」从此是同一份数据的两个投影,
|
|
23
23
|
* 不再是两份要对拍的名单;域 handler 不再看 url / method(见 route-ctx.ts `RouteHandler` 头注)。
|
|
24
24
|
* · `ROUTE_DECLARATIONS` —— ③④⑤ 合成一张;一行声明它的 `id`(全表唯一身份)、匹配式、它**真被响应**
|
|
25
25
|
* 的 `methods`、以及它**真有**的性质(`billable` / `credentialGated` / `methodDispatched`),
|
|
26
26
|
* 没有该性质就不写那一列(零默认值)。
|
|
27
|
-
* 🔴
|
|
27
|
+
* 🔴 [ref] 第三刀 车①:这 115 行的**行本体搬回各域**(`routes/x.ts` 的 `X_ROUTES`)—— 路径的
|
|
28
28
|
* 单一属主与 `*_PATH` 常量今天的属主对齐,本文件只做拼接与查找结构。`RouteDecl` / `RouteMethod`
|
|
29
29
|
* 两个类型住在 `route-ctx.js`(域模块本来就 import 的那只接缝模块),理由见那里的行注。
|
|
30
30
|
* 车②:行分两族 —— **可分派行**(`path` / `pattern`,带 `id` + `methods`)与**纯门行**
|
|
@@ -57,7 +57,7 @@ import type { RouteDecl, RouteDispatchDecl, RouteMatch, RouteCtx, RouteMethod }
|
|
|
57
57
|
import type { BillableKind } from "./readiness.js";
|
|
58
58
|
/** 一只域 handler 相对**全局服务凭据门**的位置。门前 = 未鉴权可达(每一只都要单独论证),门后 = 先过凭据。 */
|
|
59
59
|
/**
|
|
60
|
-
* 一行路由在全局服务凭据门的哪一侧、吃哪道门(闭集,三员;
|
|
60
|
+
* 一行路由在全局服务凭据门的哪一侧、吃哪道门(闭集,三员;[ref] 起由两员拆成三员):
|
|
61
61
|
* · `"read-credential"` —— 门**之前**,但过**一只**读路谓词(`dispatch.ts` 的 `readCredentialOk`:部署配了 service
|
|
62
62
|
* 凭据时要「服务凭据(含只读 TRACE_TOKEN)∨ 已验 principal」,没配时与全局门同样放行)。只读路才能坐这一段:
|
|
63
63
|
* 它们在门前只为收只读 TRACE_TOKEN 单凭据的调用方,不是为了对端口全开;
|
|
@@ -75,7 +75,7 @@ export interface RouteRow {
|
|
|
75
75
|
* 自己的窄 union 判穷尽。窄↔宽的**绑定**由 {@link row} 工厂在编译期钉死:`decls` 与 `handler` 配错
|
|
76
76
|
* (把 B 域的表配给 A 域的入口)就是红,不是运行期的静默全不命中。 */
|
|
77
77
|
handler(req: IncomingMessage, res: ServerResponse, match: RouteMatch, ctx: RouteCtx): Promise<void>;
|
|
78
|
-
/** 本域**真应答的那些口**(
|
|
78
|
+
/** 本域**真应答的那些口**([ref] 第三刀 车②)—— 一行 ROUTES = 一只域入口 = 它的口集合。
|
|
79
79
|
* `ROUTE_DECLARATIONS` 就是这一列按行序摊平,所以「声明表」与「分派表」再不可能是两份名单:
|
|
80
80
|
* 一只域忘了挂自己的声明 = 它一个口都分派不到,当场全红,而不是静默漂一行。 */
|
|
81
81
|
readonly decls: readonly RouteDecl[];
|
|
@@ -99,7 +99,7 @@ export declare const POST_CREDENTIAL_ROUTES: readonly RouteRow[];
|
|
|
99
99
|
/**
|
|
100
100
|
* **探针路径**(k8s / 编排器 / 抓取器的常态高频采样):不计 admission inflight、不推活性时钟(`http/server.ts`
|
|
101
101
|
* 的 `noteActivity`)、不入附着租约集 —— 常态采样噪音不许把 SIGHUP 空闲窗 / 引擎租约的「无人使用」判据永远撑开。
|
|
102
|
-
* 两处消费(`dispatch.ts` 的 admission 门、`server.ts` 的活性时钟)读这一只;
|
|
102
|
+
* 两处消费(`dispatch.ts` 的 admission 门、`server.ts` 的活性时钟)读这一只;[ref] 前是两份手抄
|
|
103
103
|
* (`url === "/health" || url.startsWith("/metrics")`),加 `/readyz` 时漏一份 = k8s 每 5-10s 一探就让副本永不空闲。
|
|
104
104
|
*/
|
|
105
105
|
export declare function isProbePath(url: string): boolean;
|
|
@@ -123,7 +123,7 @@ export declare function isProbePath(url: string): boolean;
|
|
|
123
123
|
*/
|
|
124
124
|
export declare const ROUTE_DECLARATIONS: readonly RouteDecl[];
|
|
125
125
|
/**
|
|
126
|
-
* **匹配一次**(
|
|
126
|
+
* **匹配一次**([ref] 第三刀 车②)—— 一条可分派行对一条 url:命中 ⇒ 具名捕获组表,不命中 ⇒ `null`。
|
|
127
127
|
*
|
|
128
128
|
* 🔴 `null` 与 `{}` 是**两件事**(`{}` = 命中且无参),所以返回值不是 `Record | undefined`。
|
|
129
129
|
* 没参与匹配的可选组不入表(`m.groups` 里它们是 `undefined`,原样留着 —— 域内判「这一段在不在」
|
|
@@ -141,7 +141,7 @@ export declare function billableKindOf(url: string): BillableKind | undefined;
|
|
|
141
141
|
* `billable=false`(零模型工作),塞进那张名单会让它们连带吃 drain 与 roster-pending 两道 503 ——
|
|
142
142
|
* 而收编与规则读写在排空期/roster 未落时做完全无害。 */
|
|
143
143
|
export declare function isCredentialGatedRewrite(method: string, url: string): boolean;
|
|
144
|
-
/**
|
|
144
|
+
/** [ref]:这次请求是不是一条**只读订阅**(`RouteDeclFacts.subscription` 那一列;方法也要对上 —— 订阅行恒只认 GET)。
|
|
145
145
|
* 分派器在 admission 那一拍(第一个 await 之前)同步判它:订阅不进在飞计数,只进附着集与订阅集。 */
|
|
146
146
|
export declare function isSubscriptionRequest(method: string, url: string): boolean;
|
|
147
147
|
/** 见 `RouteDeclFacts.methodDispatched` 的头注(单 URL 多方法端点)。 */
|
|
@@ -32,7 +32,7 @@ import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
|
32
32
|
export declare const ROSTER_SCAN_LIMIT = 500;
|
|
33
33
|
/**
|
|
34
34
|
* 后台子代在 wire 上的 **id 投影**(唯一一只):名册行的 `handle` 与 `DELETE /v1/sessions/:id` 的 409
|
|
35
|
-
* `conflict.session_children_alive` 体里 `remaining[]` 的每一项都经它出门(
|
|
35
|
+
* `conflict.session_children_alive` 体里 `remaining[]` 的每一项都经它出门([ref],裁定 2026-09-28)—— 两个面上
|
|
36
36
|
* 「同一只子代」必须是同一个串,消费方拿删除答复里的 id 才对得上名册里的行、才能去它运行的地方停它。
|
|
37
37
|
*/
|
|
38
38
|
export declare function rosterAgentId(row: Pick<BackgroundAgentRowSummary, "handle">): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sendJson, sendError } from "../send.js";
|
|
2
|
-
import { sendUnauthorized } from "../principal-gate.js";
|
|
2
|
+
import { fleetViewOf, sendUnauthorized } from "../principal-gate.js";
|
|
3
3
|
import { assertNever } from "../route-ctx.js";
|
|
4
4
|
import * as facts from "../../capability-facts.js";
|
|
5
5
|
export const ROSTER_SCAN_LIMIT = 500;
|
|
@@ -56,10 +56,9 @@ function decodeCursor(raw) {
|
|
|
56
56
|
}
|
|
57
57
|
export async function handleAgentRoster(req, res, match, ctx) {
|
|
58
58
|
const { deps } = ctx;
|
|
59
|
-
const { sessionOwnerScope } = ctx.helpers;
|
|
60
59
|
switch (match.decl.id) {
|
|
61
60
|
case "agents-roster": {
|
|
62
|
-
const { fleetWide, gateOwner } =
|
|
61
|
+
const { fleetWide, gateOwner } = fleetViewOf(req, deps, "read");
|
|
63
62
|
if (!fleetWide && gateOwner === null) {
|
|
64
63
|
sendUnauthorized(res, "identity");
|
|
65
64
|
return;
|