@sema-agent/server 7.132.0 → 7.134.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 +353 -0
- package/README.md +8 -9
- package/README.zh-CN.md +7 -6
- package/USAGE.md +301 -64
- package/deploy/sema-up/README.md +35 -1
- 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 +19 -2
- package/deploy/sema-up/chart/templates/server.yaml +19 -2
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- package/deploy/sema-up/stack/compose.yaml +3 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
- package/dist/adoption/plan.d.ts +3 -2
- package/dist/adoption/plan.js +7 -5
- package/dist/adoption/runner.js +3 -10
- package/dist/adoption/sql.d.ts +3 -2
- package/dist/adoption/sql.js +3 -5
- package/dist/adoption/wire.d.ts +4 -1
- package/dist/adoption/wire.js +1 -0
- package/dist/approval-ask-audit-store.d.ts +32 -14
- package/dist/approval-ask-audit-store.js +272 -74
- package/dist/approval-ask-machine.d.ts +15 -0
- package/dist/approval-ask-machine.js +6 -0
- package/dist/approval-ask-retention.d.ts +136 -0
- package/dist/approval-ask-retention.js +102 -0
- package/dist/approval-card.d.ts +83 -23
- package/dist/approval-card.js +45 -15
- package/dist/approval-content-kind.d.ts +5 -2
- package/dist/approval-content-kind.js +16 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +72 -0
- package/dist/approval-gate-currency.js +94 -0
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +55 -17
- package/dist/audit.d.ts +27 -10
- package/dist/audit.js +12 -16
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/coordinators.d.ts +6 -1
- package/dist/boot/coordinators.js +6 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/execution-env.js +9 -7
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.d.ts +2 -0
- package/dist/boot/leader.js +4 -1
- package/dist/boot/memory-boundary.js +2 -2
- package/dist/boot/memory-consolidation.d.ts +5 -4
- package/dist/boot/memory-consolidation.js +7 -6
- package/dist/boot/org-delivery.d.ts +28 -0
- package/dist/boot/org-delivery.js +20 -0
- package/dist/boot/read-deny-anchor-audit.js +2 -2
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +60 -81
- package/dist/boot/runner-deps.d.ts +18 -5
- package/dist/boot/runner-deps.js +10 -0
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-06-runners.d.ts +6 -3
- package/dist/boot/stage-06-runners.js +20 -4
- package/dist/boot/stage-07-capability-layer.d.ts +4 -1
- package/dist/boot/stage-07-capability-layer.js +24 -3
- package/dist/boot/stage-08-reapers.d.ts +4 -1
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +5 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +5 -1
- package/dist/boot/stage-10-http-server.js +6 -6
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -14
- package/dist/boot/web-admin.d.ts +10 -0
- package/dist/boot/web-admin.js +162 -65
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +8 -3
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +11 -6
- package/dist/caller-text-echo.js +10 -12
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +21 -0
- package/dist/capabilities/hands-lane.js +10 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -4
- package/dist/capabilities/mcp-probe.js +29 -6
- package/dist/capabilities/scenarios.d.ts +63 -7
- package/dist/capabilities/scenarios.js +39 -7
- package/dist/capability-facts.d.ts +36 -4
- package/dist/capability-facts.js +30 -4
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- 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 +16 -0
- package/dist/checkpoint-identity.js +19 -0
- package/dist/config-catalog.d.ts +17 -10
- package/dist/config-catalog.js +43 -28
- package/dist/config-d-migration.d.ts +3 -1
- package/dist/config-d-migration.js +2 -2
- package/dist/config-dir-trust.d.ts +114 -0
- package/dist/config-dir-trust.js +388 -0
- package/dist/config-invariants.d.ts +18 -5
- package/dist/config-invariants.js +35 -3
- package/dist/config-provider.d.ts +6 -1
- package/dist/config-provider.js +6 -2
- package/dist/config-types.d.ts +71 -14
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +121 -59
- package/dist/delegated-session-owner.d.ts +185 -0
- package/dist/delegated-session-owner.js +119 -0
- package/dist/device-protocol.d.ts +5 -3
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +21 -2
- package/dist/device-ws-protocol.d.ts +70 -6
- package/dist/device-ws-protocol.js +50 -23
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/execution-lane-caps.d.ts +49 -10
- package/dist/execution-lane-caps.js +43 -4
- package/dist/field-conflict.d.ts +44 -0
- package/dist/field-conflict.js +21 -0
- package/dist/file-history-disclosure.d.ts +34 -5
- package/dist/file-history-disclosure.js +2 -2
- package/dist/fleet/fleet-bus.d.ts +84 -6
- package/dist/fleet/fleet-bus.js +42 -9
- package/dist/hooks/classic-stations.d.ts +10 -5
- package/dist/hooks/classic-stations.js +4 -4
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.js +2 -2
- package/dist/hooks/hook-runner.d.ts +127 -25
- package/dist/hooks/hook-runner.js +668 -287
- package/dist/hooks/hook-source.d.ts +44 -0
- package/dist/hooks/hook-source.js +40 -0
- package/dist/http/active-run-conflict.d.ts +5 -13
- package/dist/http/active-run-conflict.js +17 -27
- package/dist/http/admission.js +111 -60
- package/dist/http/approval-sweeps.js +58 -19
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +173 -18
- package/dist/http/checkpoint-ctx.js +171 -12
- package/dist/http/claimed-run.d.ts +4 -3
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +2 -1
- package/dist/http/dispatch.js +13 -7
- package/dist/http/durable-run-leg.d.ts +4 -32
- package/dist/http/durable-run-leg.js +37 -12
- package/dist/http/idempotency.d.ts +2 -2
- package/dist/http/idempotency.js +2 -2
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +78 -27
- package/dist/http/principal-gate.js +64 -14
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +16 -32
- package/dist/http/request-guards.js +31 -30
- package/dist/http/resume-ctx-read.d.ts +50 -6
- package/dist/http/resume-ctx-read.js +33 -7
- package/dist/http/resume-legs.d.ts +5 -5
- package/dist/http/resume-legs.js +163 -91
- package/dist/http/retired-service-deps.d.ts +43 -0
- package/dist/http/retired-service-deps.js +18 -0
- package/dist/http/route-ctx.d.ts +44 -37
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.js +3 -4
- package/dist/http/routes/admin-config-refresh.js +1 -1
- package/dist/http/routes/admin-drain.js +1 -1
- package/dist/http/routes/admin-memory-optout.js +5 -1
- package/dist/http/routes/adoption.js +2 -9
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.js +91 -56
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +20 -4
- package/dist/http/routes/config-catalog.d.ts +3 -3
- package/dist/http/routes/config-catalog.js +1 -1
- package/dist/http/routes/devices.js +3 -17
- package/dist/http/routes/diagnostics.d.ts +3 -3
- package/dist/http/routes/diagnostics.js +6 -2
- package/dist/http/routes/fleet.js +4 -4
- package/dist/http/routes/images.js +6 -7
- package/dist/http/routes/leader.js +1 -8
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +3 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-consolidation.js +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/memory-policy.d.ts +1 -1
- package/dist/http/routes/memory-policy.js +3 -2
- package/dist/http/routes/notify-wake.js +8 -21
- package/dist/http/routes/observability.js +2 -2
- package/dist/http/routes/principal-inbox.d.ts +39 -0
- package/dist/http/routes/principal-inbox.js +76 -0
- package/dist/http/routes/retention-ops.js +2 -9
- package/dist/http/routes/rules.js +9 -22
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +63 -115
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +53 -48
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +3 -4
- package/dist/http/routes/sessions.js +33 -43
- package/dist/http/routes/side-query.js +6 -4
- package/dist/http/routes/tasks.js +71 -30
- package/dist/http/routes/trace-usage.js +7 -9
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/run-declared-families.d.ts +16 -0
- package/dist/http/run-declared-families.js +12 -0
- package/dist/http/send.d.ts +24 -3
- package/dist/http/send.js +14 -2
- package/dist/http/server.d.ts +23 -18
- package/dist/http/server.js +20 -15
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +4 -3
- package/dist/http/submit-ctx.js +23 -6
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +17 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/lane-home-probe.d.ts +78 -9
- package/dist/lane-home-probe.js +78 -12
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/leader/wire.d.ts +4 -0
- package/dist/leader/wire.js +8 -7
- package/dist/limit-refusal.d.ts +17 -5
- package/dist/limit-refusal.js +4 -1
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +31 -10
- package/dist/mcp-assertion-header.js +10 -3
- package/dist/memory-origin-fence.js +2 -2
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +23 -16
- package/dist/memory-scope.js +24 -8
- package/dist/memory-sync-client.d.ts +27 -13
- package/dist/memory-sync-client.js +107 -18
- package/dist/model-compat.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +9 -1
- package/dist/model-entry-refusal.js +6 -1
- package/dist/model-plane-face.d.ts +51 -0
- package/dist/model-plane-face.js +24 -0
- package/dist/model-provider.d.ts +5 -0
- package/dist/model-provider.js +4 -2
- package/dist/model-route-endpoint.d.ts +8 -11
- package/dist/model-route-endpoint.js +4 -7
- package/dist/model-route-env.d.ts +22 -0
- package/dist/model-route-env.js +2 -0
- package/dist/model-route-gap.d.ts +60 -30
- package/dist/model-route-gap.js +21 -15
- package/dist/observability/corrupt-read-seat.d.ts +7 -0
- package/dist/observability/corrupt-read-seat.js +9 -0
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +35 -9
- package/dist/observability/fail-open.js +35 -9
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/prompt-manifest.d.ts +22 -25
- package/dist/observability/prompt-manifest.js +54 -50
- package/dist/observability/tool-trace.js +9 -10
- package/dist/operator-ask.d.ts +10 -0
- package/dist/operator-ask.js +3 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
- package/dist/orchestration/workflow-agent-session-index.js +9 -13
- package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
- package/dist/orchestration/workflow-completion-inbox.js +13 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
- package/dist/orchestration/workflow-notify-journal.js +27 -34
- package/dist/orchestration/workflow-park-decision.d.ts +89 -0
- package/dist/orchestration/workflow-park-decision.js +119 -0
- package/dist/org-delivery-gate.d.ts +81 -0
- package/dist/org-delivery-gate.js +59 -0
- package/dist/panel-tool-names.d.ts +23 -0
- package/dist/panel-tool-names.js +8 -0
- package/dist/parked-decide.d.ts +43 -11
- package/dist/parked-decide.js +100 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/permission-rule-vocab.d.ts +1 -23
- package/dist/permission-rule-vocab.js +0 -13
- package/dist/plugins/approval-ask-store-file.d.ts +16 -1
- package/dist/plugins/approval-ask-store-file.js +21 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
- package/dist/plugins/approval-ask-store-memory.js +34 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
- package/dist/plugins/approval-ask-store-sql.js +37 -1
- package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- package/dist/plugins/blob-backend.d.ts +38 -25
- package/dist/plugins/blob-backend.js +29 -19
- package/dist/plugins/breaker-state-sql.d.ts +2 -2
- package/dist/plugins/breaker-state-sql.js +4 -4
- package/dist/plugins/caching-session-store.d.ts +4 -1
- package/dist/plugins/caching-session-store.js +7 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +36 -1
- package/dist/plugins/checkpoint-store-sql.js +65 -3
- package/dist/plugins/file-history-store-sql.d.ts +5 -2
- package/dist/plugins/file-history-store-sql.js +3 -1
- package/dist/plugins/file-run-store.d.ts +5 -13
- package/dist/plugins/file-run-store.js +9 -0
- package/dist/plugins/fork-routing-session-store.d.ts +9 -1
- package/dist/plugins/fork-routing-session-store.js +12 -1
- package/dist/plugins/host-platform.d.ts +2 -0
- package/dist/plugins/host-platform.js +2 -1
- package/dist/plugins/local-checkpoint-store.d.ts +15 -2
- package/dist/plugins/local-checkpoint-store.js +32 -1
- package/dist/plugins/local-session-store.d.ts +13 -10
- package/dist/plugins/local-session-store.js +23 -14
- package/dist/plugins/local-session-window.d.ts +45 -0
- package/dist/plugins/local-session-window.js +38 -0
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
- package/dist/plugins/mailbox-store-sql.d.ts +30 -48
- package/dist/plugins/mailbox-store-sql.js +77 -52
- package/dist/plugins/memory-embedder-fingerprint.js +2 -1
- package/dist/plugins/memory-run-store.d.ts +5 -13
- package/dist/plugins/memory-run-store.js +8 -0
- package/dist/plugins/one-time-migrations.d.ts +121 -5
- package/dist/plugins/one-time-migrations.js +332 -8
- package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
- package/dist/plugins/org-delivery-quota-store.js +228 -0
- package/dist/plugins/permission-rule-store-file.js +10 -6
- package/dist/plugins/permission-rule-store-sql.js +8 -8
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +18 -5
- package/dist/plugins/pg-session-storage.js +68 -23
- package/dist/plugins/remote-env-adb.d.ts +6 -12
- package/dist/plugins/remote-env-adb.js +12 -2
- package/dist/plugins/remote-env-device.d.ts +14 -7
- package/dist/plugins/remote-env-device.js +23 -15
- package/dist/plugins/remote-env-k8s.d.ts +8 -12
- package/dist/plugins/remote-env-k8s.js +23 -5
- package/dist/plugins/remote-env-local-docker.d.ts +10 -15
- package/dist/plugins/remote-env-local-docker.js +12 -9
- package/dist/plugins/remote-env-ssh.d.ts +10 -16
- package/dist/plugins/remote-env-ssh.js +17 -11
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-user-file.js +2 -2
- package/dist/plugins/session-epoch-anchor.d.ts +32 -6
- package/dist/plugins/session-epoch-anchor.js +2 -3
- package/dist/plugins/session-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-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/sql-driver.d.ts +74 -11
- package/dist/plugins/sql-driver.js +210 -12
- package/dist/plugins/sql-errors.d.ts +23 -0
- package/dist/plugins/sql-errors.js +21 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +40 -14
- package/dist/plugins/store-contracts.d.ts +42 -0
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/tidb-pool.d.ts +6 -1
- package/dist/plugins/tidb-pool.js +44 -10
- package/dist/plugins/tidb-session-storage.d.ts +3 -2
- package/dist/plugins/tidb-session-storage.js +2 -2
- package/dist/plugins/tidb-session-store.d.ts +25 -5
- package/dist/plugins/tidb-session-store.js +67 -21
- package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
- package/dist/plugins/workflow-journal-store-sql.js +19 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
- package/dist/plugins/workflow-run-store-sql.js +50 -9
- package/dist/posture-source.d.ts +18 -10
- package/dist/posture-source.js +4 -1
- package/dist/project-identity.d.ts +45 -6
- package/dist/project-identity.js +162 -8
- package/dist/project-layer-key.d.ts +28 -0
- package/dist/project-layer-key.js +29 -0
- package/dist/question.js +3 -2
- package/dist/read-deny-entry.d.ts +25 -0
- package/dist/read-deny-entry.js +12 -0
- package/dist/read-face-posture.d.ts +37 -11
- package/dist/read-face-posture.js +32 -3
- package/dist/request-key-closure.d.ts +7 -0
- package/dist/request-key-closure.js +9 -1
- package/dist/request-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +26 -2
- package/dist/rule-entry-list.js +72 -12
- package/dist/rules-consent.js +3 -4
- package/dist/run-acceptance.d.ts +19 -3
- package/dist/run-acceptance.js +13 -1
- package/dist/run-local.js +37 -6
- package/dist/runs.d.ts +12 -10
- package/dist/runs.js +25 -6
- package/dist/runtime-caps-resolver.d.ts +16 -6
- package/dist/runtime-caps-resolver.js +18 -5
- package/dist/sandbox-pkg-source.d.ts +19 -1
- package/dist/sandbox-pkg-source.js +29 -7
- package/dist/sealed-key.d.ts +32 -0
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +95 -15
- package/dist/security.js +52 -9
- package/dist/session-error-wire.d.ts +31 -7
- package/dist/session-error-wire.js +9 -2
- package/dist/session-sync-kernel.d.ts +37 -10
- package/dist/session-sync-kernel.js +10 -0
- package/dist/session-titled-frame.d.ts +33 -0
- package/dist/session-titled-frame.js +4 -0
- package/dist/session-titler.d.ts +9 -1
- package/dist/session-titler.js +15 -4
- package/dist/spec-fields.js +21 -2
- package/dist/sql-engine-posture.d.ts +3 -1
- package/dist/task-a2a.js +4 -3
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +5 -5
- package/dist/task-mcp.js +27 -74
- package/dist/task-settings.d.ts +93 -88
- package/dist/task-settings.js +71 -63
- package/dist/text-bidi.d.ts +0 -4
- package/dist/text-bidi.js +1 -3
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +451 -136
- package/dist/tool-approval.js +733 -256
- package/dist/tool-rule-names.d.ts +6 -0
- package/dist/trace/core-keyset-guard.d.ts +108 -25
- package/dist/trace/exit-seat.d.ts +40 -0
- package/dist/trace/exit-seat.js +130 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/project.d.ts +98 -13
- package/dist/trace/project.js +57 -32
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +57 -0
- package/dist/trace/redact.js +962 -168
- package/dist/trace/self-minted-wire.d.ts +349 -1
- package/dist/trace/self-minted-wire.js +118 -1
- package/dist/trace/wire-projection-faces.d.ts +304 -2
- package/dist/trace/wire-projection-faces.js +160 -13
- package/dist/url-refusal.js +2 -0
- package/dist/web-admin-client/apply-effective.d.ts +12 -0
- package/dist/web-admin-client/apply-effective.js +56 -5
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.js +6 -8
- package/dist/web-admin-client/types.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -2
- package/scripts/drain-check.mysql.sql +20 -2
- package/scripts/drain-check.pg.sql +20 -2
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -106
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一条 run 的**持久化声明**读口(H5):它声明了哪些审批开卡帧族(`settings.approvalFrameFamilies`)。
|
|
3
|
+
*
|
|
4
|
+
* 声明随受理过的提交体落盘 —— 提交腿(`POST /v1/tasks` 两腿 / `POST /v1/runs` / A2A)在 run 认领之后把整份提交体写进续跑输入(`checkpoint_ctx`,会话键,
|
|
5
|
+
* `http/submit-ctx.ts` 的 `persistSubmitCtx`),所以**事后**才发生的读(耐久事件流的开流 preamble)读得到「这条 run 当初声明了什么」。读法只有一个:
|
|
6
|
+
* `declaredApprovalFrameFamilies`(S-1914 的唯一读者;缺席 / 形坏 ⇒ 空集),本模块不另判声明的合法性。
|
|
7
|
+
*
|
|
8
|
+
* 失效方向是**不重放**:续跑输入不在 / 体读不出 ⇒ 空集 ⇒ preamble 零帧(与「未声明」同形;空集 = 这条腿没有活审批通道)。店与会话 id 由类型保证在场:
|
|
9
|
+
* 唯一的调用方(`routes/runs.ts` 事件流 preamble)只在上场门为真时读 —— 上场门的 park 设施项就是「checkpoint 店在场」,run 行的会话 id 是必填串。
|
|
10
|
+
* 体读不出(店的拒绝契约)时报一次 `onUnreadable(where)`,让「为什么这条 run 的卡没被重放」在运维日志里有迹可循;店抖动 / 连接错按读口的刻意保守折成「不在」(`readResumeCtx` 头注)。
|
|
11
|
+
* 读的是 `KEEP_SEALED` 形:`approvalFrameFamilies` 不是凭据位,不为一个声明位开封任何凭据。
|
|
12
|
+
*/
|
|
13
|
+
import type { ApprovalFrameFamily } from "../tool-approval.js";
|
|
14
|
+
import type { CheckpointStoreFull } from "../plugins/store-backend.js";
|
|
15
|
+
export declare function readRunDeclaredFamilies(cs: Pick<CheckpointStoreFull, "getCtx">, sessionId: string, onUnreadable?: (where: string) => void): Promise<ReadonlySet<ApprovalFrameFamily>>;
|
|
16
|
+
//# sourceMappingURL=run-declared-families.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { declaredApprovalFrameFamilies } from "../tool-approval.js";
|
|
2
|
+
import { KEEP_SEALED, readResumeCtx } from "./resume-ctx-read.js";
|
|
3
|
+
export async function readRunDeclaredFamilies(cs, sessionId, onUnreadable) {
|
|
4
|
+
const read = await readResumeCtx(cs.getCtx(sessionId), KEEP_SEALED);
|
|
5
|
+
if (read.kind === "corrupt")
|
|
6
|
+
onUnreadable?.(read.where);
|
|
7
|
+
if (read.kind !== "ok")
|
|
8
|
+
return new Set();
|
|
9
|
+
const body = read.ctx.body;
|
|
10
|
+
return declaredApprovalFrameFamilies(typeof body === "object" && body !== null ? Reflect.get(body, "settings") : undefined);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=run-declared-families.js.map
|
package/dist/http/send.d.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* no longer exists, so quoting its line numbers here would point at nothing). `server.ts`
|
|
8
8
|
* now imports them from here, so all ~500 existing `sendJson(...)` call sites are unchanged text.
|
|
9
9
|
*/
|
|
10
|
-
import type { ServerResponse } from "node:http";
|
|
10
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
11
11
|
import { type SessionErrorFace } from "../session-error-wire.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Logger } from "../observability/logger.js";
|
|
13
|
+
import { type HttpError } from "../security.js";
|
|
13
14
|
import { type Refusal, type RefusalBody } from "./refusal-body.js";
|
|
14
15
|
/**
|
|
15
16
|
* [ref](黑板 [ref]②)—— 一条响应「是 SSE 流」的**在场标记**。
|
|
@@ -72,6 +73,20 @@ export declare function sendJson(res: ServerResponse, status: number, body: unkn
|
|
|
72
73
|
* where `error`/`errorCode` aren't cleanly separable from the rest of the body, are left on raw
|
|
73
74
|
* `sendJson` (see the A6 migration notes for the callers still doing that on purpose). */
|
|
74
75
|
export declare function sendError(res: ServerResponse, status: number, errorCode: string, message: string, extra?: Readonly<Record<string, unknown>>): void;
|
|
76
|
+
/** `request.invalid_json` 的机读 `reason`(闭集两词):`not_json` = 体不是合法 JSON;`not_object` = 是合法 JSON,但这一口要的是对象。 */
|
|
77
|
+
export declare const INVALID_JSON_REASONS: readonly ["not_json", "not_object"];
|
|
78
|
+
export type InvalidJsonReason = (typeof INVALID_JSON_REASONS)[number];
|
|
79
|
+
/** 每个 `reason` 的句子(wire 文案,冻结在 `test/api-error-text-freeze.test.ts` 的常量锚格;句子由 `reason` 定,调用点不另写一句)。 */
|
|
80
|
+
export declare const INVALID_JSON_MESSAGES: {
|
|
81
|
+
readonly not_json: "invalid JSON body";
|
|
82
|
+
readonly not_object: "body must be a JSON object when present";
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* 请求体不是这一口要的 JSON ⇒ 400 `request.invalid_json` + `reason`。**全仓唯一铸这个码的地方**:请求体读取器(`request-guards.ts` 的 `readJson`,体不是合法 JSON)与要求对象体的口
|
|
86
|
+
* (体是合法 JSON、却不是对象)都经它抛 / 渲;路由域不再各自在本地 catch 里自铸同一个码(那些回落臂在读取器抛无码 `HttpError` 的年月里恒不可达,
|
|
87
|
+
* 且裸 catch 会把读取器的 413 一并折成「JSON 非法」)。
|
|
88
|
+
*/
|
|
89
|
+
export declare function invalidJsonError(reason: InvalidJsonReason): HttpError;
|
|
75
90
|
/** B7([ref] lens1 §C3):`HttpError` 的兜底 catch-all 站点没有自己的语义分支——`err.code` 在 42 个
|
|
76
91
|
* throw 点里只有 3 个带。为了让「errorCode 恒在」在这些站点也成立(而不是靠豁免表放行),按**状态码**
|
|
77
92
|
* 给一个诚实的粗码:它只声明「这类拒绝」,不冒充比 throw 点更细的语义。带 `code` 的 throw 点原样优先。 */
|
|
@@ -102,11 +117,17 @@ export declare function sendSessionPolicyError(res: ServerResponse, e: unknown,
|
|
|
102
117
|
* 回 `true` = 已应答,调用点 `return`;`false` = 不是 `SessionError`,或这个词在这一面上是登记过的留白(站点的既有
|
|
103
118
|
* 处置照旧 —— 通常是继续上抛到全局兜底)。
|
|
104
119
|
*
|
|
105
|
-
* 句子:属主给了固定句就发它(import 面 `invalid_session`
|
|
120
|
+
* 句子:属主给了固定句就发它(import 面 `invalid_session` / `placement_refused` 两句),否则发 core 的原句过既有脱敏(`redactErrorMessage`:
|
|
106
121
|
* 不抛、有上限)。core 的 `corrupt_session` 原句只点名会话 id 与跳过计数(「Session <id> is unreadable: its log has no
|
|
107
122
|
* meta header (N of M records skipped as corrupt)」),SQL 两店的原句点名 `<表>.<列>` 与行号 —— 两者都不含盘上路径
|
|
108
123
|
* (路径只进运维面:`server.session-repo.corrupt-record-skipped` 的探针行,S-990;SQL 两店走各自的拒绝句)。
|
|
109
124
|
*/
|
|
110
125
|
export declare function sendSessionError(res: ServerResponse, e: unknown, face: SessionErrorFace): boolean;
|
|
111
126
|
export declare function msg(e: unknown): string;
|
|
127
|
+
/**
|
|
128
|
+
* 路由抛出的未归类错误的运维行 `request_error` —— **唯一写者**。外层兜底(`server.ts`)与「就地经映射下发」的站点(会话同步的暂存提交 catch)同调它:
|
|
129
|
+
* 后者在兜底之前就把错误换成了有名字的应答,不经这一行的话,被映射接走的错误(如提交门抛的 `corrupt_session`,句子点名表列与行号)会从服务端日志里消失。
|
|
130
|
+
* codex r10 [high] 纵深:错误句可带凭据回显 ⇒ 先过 `redactHead`(有上限、不抛)。
|
|
131
|
+
*/
|
|
132
|
+
export declare function logRequestError(logger: Logger | undefined, req: IncomingMessage, err: unknown): void;
|
|
112
133
|
//# sourceMappingURL=send.d.ts.map
|
package/dist/http/send.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SessionError, SessionPolicyError } from "@sema-agent/core";
|
|
2
2
|
import { sessionPolicyErrorFacts, sessionPolicyErrorHttp, sessionPolicyErrorSentence } from "../session-policy-wire.js";
|
|
3
3
|
import { sessionErrorHttp } from "../session-error-wire.js";
|
|
4
|
-
import { redactErrorMessage } from "../observability/run-terminal.js";
|
|
4
|
+
import { redactErrorMessage, redactHead } from "../observability/run-terminal.js";
|
|
5
|
+
import { createCodedHttpError } from "../security.js";
|
|
5
6
|
import { refusalBody } from "./refusal-body.js";
|
|
6
7
|
export const SSE_RESPONSE_MARK = Symbol("sema.http.sse-response");
|
|
7
8
|
export function isSseResponse(res) {
|
|
@@ -34,6 +35,14 @@ export function sendJson(res, status, body) {
|
|
|
34
35
|
export function sendError(res, status, errorCode, message, extra) {
|
|
35
36
|
sendJson(res, status, refusalBody(extra === undefined ? { errorCode, message } : { errorCode, message, facts: extra }));
|
|
36
37
|
}
|
|
38
|
+
export const INVALID_JSON_REASONS = ["not_json", "not_object"];
|
|
39
|
+
export const INVALID_JSON_MESSAGES = {
|
|
40
|
+
not_json: "invalid JSON body",
|
|
41
|
+
not_object: "body must be a JSON object when present",
|
|
42
|
+
};
|
|
43
|
+
export function invalidJsonError(reason) {
|
|
44
|
+
return createCodedHttpError(400, "request.invalid_json", INVALID_JSON_MESSAGES[reason], { reason });
|
|
45
|
+
}
|
|
37
46
|
export function httpErrorCode(status, code) {
|
|
38
47
|
if (code)
|
|
39
48
|
return code;
|
|
@@ -73,10 +82,13 @@ export function sendSessionError(res, e, face) {
|
|
|
73
82
|
const wire = sessionErrorHttp(e.code, face);
|
|
74
83
|
if (wire === undefined)
|
|
75
84
|
return false;
|
|
76
|
-
sendError(res, wire.status, wire.errorCode, wire.sentence ?? redactErrorMessage(e.message) ?? "session store error");
|
|
85
|
+
sendError(res, wire.status, wire.errorCode, wire.sentence ?? redactErrorMessage(e.message) ?? "session store error", wire.detail === undefined ? undefined : { detail: wire.detail });
|
|
77
86
|
return true;
|
|
78
87
|
}
|
|
79
88
|
export function msg(e) {
|
|
80
89
|
return e instanceof Error ? e.message : String(e);
|
|
81
90
|
}
|
|
91
|
+
export function logRequestError(logger, req, err) {
|
|
92
|
+
logger?.error("request_error", { method: req.method, url: req.url, err: redactHead(msg(err), 2000) });
|
|
93
|
+
}
|
|
82
94
|
//# sourceMappingURL=send.js.map
|
package/dist/http/server.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { RunStore, ImageIndex, ImageBake, CheckpointStoreFull, ResumeAnchor
|
|
|
10
10
|
import type { RuleConsentLane } from "../rules-consent.js";
|
|
11
11
|
import { type MemorySyncRequest, type MemorySyncResponse } from "../memory-sync.js";
|
|
12
12
|
import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
|
|
13
|
-
import type { SqlBlobCapReading } from "../plugins/blob-backend.js";
|
|
14
13
|
import type { LeaderEndpoint } from "../leader/endpoint.js";
|
|
15
14
|
import { type WorkflowAgentRegistry } from "../orchestration/workflow-agent-steer.js";
|
|
16
15
|
import type { SubagentSteerRegistry } from "../orchestration/subagent-steer.js";
|
|
@@ -38,8 +37,8 @@ import { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHA
|
|
|
38
37
|
import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath } from "./route-table.js";
|
|
39
38
|
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
40
39
|
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|
|
41
|
-
import { explicitOperatorOk,
|
|
42
|
-
export { explicitOperatorOk
|
|
40
|
+
import { explicitOperatorOk, hasServiceAuth } from "./principal-gate.js";
|
|
41
|
+
export { explicitOperatorOk };
|
|
43
42
|
/** Per-request authorization context resolved before building the spec (identity, owned session). */
|
|
44
43
|
export interface RequestAuth {
|
|
45
44
|
principal?: string;
|
|
@@ -154,6 +153,12 @@ export interface ServiceStoreDeps {
|
|
|
154
153
|
/** Durable-checkpoint store ([ref], core 1.67): durable F4 suspend/resume. When present, the resume
|
|
155
154
|
* endpoint + suspended-run surfacing are active. Set only when DURABLE_APPROVAL + a TiDB pool. */
|
|
156
155
|
checkpointStore?: CheckpointStoreFull;
|
|
156
|
+
/** S-1907:停驻行凭据的**封签器**(`sealed-key.ts` `ensureCheckpointCtxSealing`,这一域自己的保管店 `<数据根>/sealed-key/checkpoint-ctx-keys/`;规则属主 = `checkpoint-ctx.ts` 末段
|
|
157
|
+
* 「凭据位密封」)。提交体里请求面凭据位上的值在 `checkpoint_ctx` 里只以封签存在:写 ctx 的每一笔经它封、续跑上下文读口经它开。
|
|
158
|
+
* 🔴 **与 `checkpointStore` 同在**:店在而它缺席 ⇒ `createHttpServer` 拒启(句子 = `CHECKPOINT_CTX_SEALING_REQUIRED`)—— 凭据只以封签落盘,
|
|
159
|
+
* 封不了就不落,没有「明文照写」的第二种装配。嵌入方:`checkpointCtxSealing: await ensureCheckpointCtxSealing(sealedKeyDir)`
|
|
160
|
+
* (保管目录要跨重启持久、多副本各副本是同一份钥匙,否则封它的那把钥匙不在 ⇒ 409 `conflict.checkpoint_ctx_unsealable` `reason:"key_not_held"`)。 */
|
|
161
|
+
checkpointCtxSealing?: import("./checkpoint-ctx.js").CheckpointCtxSealing;
|
|
157
162
|
/** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). Enables PUT/GET /v1/sessions/:id/policy
|
|
158
163
|
* when present; core reads the rules at prepare-time (subtract-only) via RunnerDeps.sessionPolicyStore (wired separately). */
|
|
159
164
|
sessionPolicyStore?: ServiceSessionPolicyStore;
|
|
@@ -209,6 +214,10 @@ export interface ServiceStoreDeps {
|
|
|
209
214
|
* (boot/workflow-orchestration.ts);任一缺席 = 那条车道不存在(workflow 出身的 park 落 legacy 腿,
|
|
210
215
|
* 与本批之前逐字同形)。契约与单写者纪律的属主 = orchestration/workflow-agent-session-index.ts。 */
|
|
211
216
|
workflowAgentSessionIndex?: import("../orchestration/workflow-agent-session-index.js").WorkflowAgentSessionIndex;
|
|
217
|
+
/** workflow 子代停驻卡的耐久决定行(一张卡一行,键 = 子代 checkpoint 的 token):写者 = `/decide` 的 workflow 车道,读者 = 每一只起跑器开跑前的那一只读者。
|
|
218
|
+
* 必须绑在 `runStore` 这一只上(与它同出一个 store backend:`run()` / `workflowParkDecisions()`);park 索引与 run 店都在时必填 ——
|
|
219
|
+
* 起服判官 `parkDecisionStoreRefusal` 判。契约与律的属主 = orchestration/workflow-park-decision.ts。 */
|
|
220
|
+
workflowParkDecisions?: import("../orchestration/workflow-park-decision.js").WorkflowParkDecisionStore;
|
|
212
221
|
/** [ref] journal 读面(PAIR-REVIEW 修车批):GET /v1/workflows/:runId/journal 的数据源——与 runner 侧
|
|
213
222
|
* workflowJournalStore 同一实例(main.ts backend.workflowJournal());缺席=501(与 workflowRunStore 同门)。 */
|
|
214
223
|
workflowJournalStore?: import("@sema-agent/core").WorkflowJournalStore;
|
|
@@ -315,9 +324,7 @@ export interface ServiceCoordinatorDeps {
|
|
|
315
324
|
* LEADER_ENABLED + the leader wiring (e2b workers + git push) is configured. */
|
|
316
325
|
leaderEndpoint?: LeaderEndpoint;
|
|
317
326
|
/** Fire-and-forget session auto-titler (first-submit hook; absent = feature dark). */
|
|
318
|
-
sessionTitler?:
|
|
319
|
-
maybeTitle(sessionId: string, objective: string, model?: string): void;
|
|
320
|
-
};
|
|
327
|
+
sessionTitler?: import("../session-titler.js").SessionTitler;
|
|
321
328
|
}
|
|
322
329
|
/** **函数/构件缝**:main.ts 把跨多个子系统的动作编译成一个可调用面交给路由(路由不该自己
|
|
323
330
|
* 重组零件——见 backend 的同款论证)。parked-revive 三件是同族的构件缝(boot 期从生产装配取的裸
|
|
@@ -567,6 +574,10 @@ export interface ServiceSeamDeps {
|
|
|
567
574
|
* 🔴 缺席 ⇒ `/v1/shared-memory/*` 整域不挂载(诚实缺席);挂载还另要 {@link orgMemoryDirectory}
|
|
568
575
|
* 在场 —— 没有成员性判据的读面只能全放或全拒,两个都比「这个面不存在」差。 */
|
|
569
576
|
sharedMemoryStore?: import("@sema-agent/core").SharedMemoryStoreProvider;
|
|
577
|
+
/** [ref] §10.2 —— 跨主体投递门(`createOrgDeliveryGate` 的产物,`boot/stage-06-runners.ts` 装配的唯一实例)。
|
|
578
|
+
* `POST /v1/principal-inbox/messages` 只经它投递;缺席 = 本部署没声明收件箱消费方(`PRINCIPAL_INBOX_ASSISTANT` 未设)⇒
|
|
579
|
+
* 那一口 501、能力位 `principalInboxDelivery` false(同读事实 `principalInboxDelivery`)。 */
|
|
580
|
+
orgDeliveryGate?: import("@sema-agent/core").OrgDeliveryGate;
|
|
570
581
|
/** WEB-SETUP-RECON 附B — org sessionMirror 治理态的 SERVICE 半场 = **观测面(audit),非执法面**。
|
|
571
582
|
* 裁定 (c):「该镜像而未镜像」发生在数据产生端(壳)——本 server 是镜像**目标**,只看得见到达的 push;
|
|
572
583
|
* 没到达的会话对 server 不存在(无客户端会话清单、无心跳契约),required 锁的真执法只能在壳(CC
|
|
@@ -726,6 +737,9 @@ export interface ServiceDeploymentDeps {
|
|
|
726
737
|
* `buildCenterCredentialHealthView` 铸形,只有闭集词 / 时刻 / 计数,不带路径与令牌)。缺席 / 返回 undefined = 健康或没有中心
|
|
727
738
|
* ⇒ `/health` 形状逐字不变(additive)。 */
|
|
728
739
|
centerCredentialState?: () => import("../center-credential-renewer.js").CenterCredentialHealthView | undefined;
|
|
740
|
+
/** S-667:`/health.centerIdentityNotice` —— 中心凭证换人后的**最近一条**两态通告(`center-config-tier.ts` 铸:`{ code, message, at }`,码闭集两词、句冻结)。取值口交出的
|
|
741
|
+
* 就是 wire 形,`/health` 不另投影;无鉴权面,只有码 / 冻结句 / 时刻。缺席 / 返回 undefined = 从未换过人或没有中心 ⇒ `/health` 形状逐字不变(additive)。 */
|
|
742
|
+
centerIdentityNoticeState?: () => import("../center-config-tier.js").CenterIdentityNotice | undefined;
|
|
729
743
|
/** S-768:模型拒因信号(`/health.modelRefusals`,settings-schema 6.2.0 `ModelRefusalsSignal` 形:名 → 码 + 组拒码)。fleet 心跳读**这同一只**
|
|
730
744
|
* (`boot/stage-10-http-server.ts` → `modelRefusals: () => deployment.modelRefusalsState?.()`)—— 一处铸、两出口。缺席 / 返回 undefined =
|
|
731
745
|
* 没有可报的拒或没有配置管道 ⇒ `/health` 形状逐字不变(additive)。 */
|
|
@@ -780,8 +794,8 @@ export interface ServiceDeploymentDeps {
|
|
|
780
794
|
/** S-131:SQL **引擎读口**(`sql-engine-posture.ts` 的单一推导点 —— boot 期借一条池连接触发驱动的连接初始化,交回本池的驱动:
|
|
781
795
|
* `dialect`(SQL 文本轴,恒在)+ 活的 `facts`(`SET` 之后**回读复核**过的真值;池重连后驱动会重新初始化并刷新,快照会说谎)。
|
|
782
796
|
* 读者:`GET /v1/diagnostics/wiring` 的 `sqlEngine` 段(operator-only,全量含版本与两堵墙)与 `GET /v1/capabilities` 的 `store.sql` 位(窄投影;
|
|
783
|
-
* 7.106.0 前是顶层 `sql`,S-866 ①)读 `facts`;提交受理口的 413 把整只读口交给唯一判官 `sql-driver.ts` `sqlWallsOf`(
|
|
784
|
-
* `
|
|
797
|
+
* 7.106.0 前是顶层 `sql`,S-866 ①)读 `facts`;提交受理口的 413 把整只读口交给唯一判官 `sql-driver.ts` `sqlWallsOf`(墙的方言只从这里来(与事实同出一只驱动),不另从店后端读);其中包墙是连接级事实 ——
|
|
798
|
+
* 这里的包墙是最近一次初始化的那条连接的读数,受理口那一腿是同一只规则的提前一跑,终判在将要执行写入的那条连接上(`sql-driver.ts` `connectJudged`;SQL 快照 blob 的店判与 `PUT /sync/blobs` 的 413 来自它)。
|
|
785
799
|
* 两种缺席、两个值:**席缺席** = 本部署没有 SQL 后端(env-only worker、local 文件后端);**`facts` 是 `null`** = 有 SQL 后端、但事实此刻没建立
|
|
786
800
|
* (池上最近一次连接初始化被拒,驱动当场作废了事实)。两者在两个读面上都报缺席(诚实缺席,不铸空壳);墙按方言读后者(MySQL 协议 ⇒ 最保守的假定墙)。
|
|
787
801
|
* 7.132.0 前这一席是 `sqlEngineFacts: () => SqlEngineFacts | null`(只给事实、不给方言);照旧传它 ⇒ `createHttpServer` 起服拒。
|
|
@@ -826,15 +840,6 @@ export interface ServiceDeploymentDeps {
|
|
|
826
840
|
}
|
|
827
841
|
/** **数值旋钮**:部署可调的上限/拍距。缺省值写在消费点(`?? 256` 之类),此处只承载覆写。 */
|
|
828
842
|
export interface ServiceKnobDeps {
|
|
829
|
-
/** (a)(clay 拍 a+c,2026-07-27)当快照 blob 走 SQL 默认店时(逃生口形/覆写形),该店的 per-blob
|
|
830
|
-
* 承载帽的**读口**——PUT /sync/blobs 面每个请求调一次、据此**前置 413**(typed `blob_too_large_for_sql`)。
|
|
831
|
-
* 键缺席=不前置(MinIO 形无帽);读口答 `undefined`=此刻没有墙(pg 形)=不前置。读口而非数字:帽由库报的墙推导,
|
|
832
|
-
* 库调墙、池连接换代后活事实会变,门限必须跟着变(与店写口 `SqlBlobBackend` 读同一份池级事实、同一只函数
|
|
833
|
-
* `sqlBlobCapOf`)。读口答的是**帽 + 它的出处**(`{ capBytes, source }`,`source` ∈ `operator` / `reported` / `assumed`,见 `SqlBlobCapReading`):
|
|
834
|
-
* 413 的句子与机读位 `wallSource` 按出处分三形(运维旋钮 / 库报的墙 / 假定的墙),不把假定或运维的旋钮说成库的上限。
|
|
835
|
-
* 为什么在 HTTP 面重复店里的检查:店的 never-throw 结果形把一切写失败折成 502,而 502
|
|
836
|
-
* 语义=可重试,对端会对一个永远过不去的 blob 无限重试——413 才是「别再送了」的诚实形。 */
|
|
837
|
-
snapshotBlobSqlCap?: () => SqlBlobCapReading | undefined;
|
|
838
843
|
/** [ref] SSE 连接帽(缺省 256/副本;超限 503+Retry-After=消费方回落 /head 轮询)。 */
|
|
839
844
|
sessionEventsMaxConnections?: number;
|
|
840
845
|
/** [ref] SSE 心跳/owner 复核拍距 ms(缺省 25s;测试注入用)。 */
|
|
@@ -862,7 +867,7 @@ export declare function flattenServiceDeps(deps: ServiceDeps): FlatServiceDeps;
|
|
|
862
867
|
/** The TRUSTED end-user principal for an owner-gated / per-tenant request. On a direct-door worker the
|
|
863
868
|
* trusted-header path is OFF (x-agent-principal is client-self-asserted), so identity comes from the crypto-VERIFIED
|
|
864
869
|
* principal JWT (`x-approval-principal-token`, principal-only proof — no cnf.bnd action binding); otherwise the
|
|
865
|
-
* BFF-minted trusted header. undefined when absent/invalid (fail-closed → callers map to 401
|
|
870
|
+
* BFF-minted trusted header. undefined when absent/invalid (fail-closed → callers map to 401, or to the anonymous scope `"_"` on the approval queue faces).
|
|
866
871
|
* 🔴 Use this for ANY endpoint that reads or gates PER-TENANT data — NOT `principalFrom` directly, which trusts
|
|
867
872
|
* the self-asserted header on a direct door (/v1/usage + the trace owner-gate
|
|
868
873
|
* had drifted to a bare principalFrom, unlike the leader/images/approvals identity paths). One source of truth
|
package/dist/http/server.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import { outwardPlane } from "../terminal.js";
|
|
3
|
-
import { redactHead } from "../observability/run-terminal.js";
|
|
4
3
|
import { validatePendingSteer } from "@sema-agent/core";
|
|
5
4
|
import {} from "../web-admin-client/facade.js";
|
|
6
5
|
import { describeValueShape } from "@sema-agent/settings-schema";
|
|
@@ -18,9 +17,12 @@ import { cascadeConfig } from "./run-meta.js";
|
|
|
18
17
|
export { cascadeConfig };
|
|
19
18
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
20
19
|
export { coarseStatusForState, errorCodeForExit };
|
|
21
|
-
import { sendError, sendHttpError, sendSessionError,
|
|
20
|
+
import { sendError, sendHttpError, sendSessionError, logRequestError } from "./send.js";
|
|
22
21
|
import { createRequestGuards } from "./request-guards.js";
|
|
23
22
|
import { sqlEngineSeatIssue } from "../sql-engine-posture.js";
|
|
23
|
+
import { parkDecisionStoreRefusal } from "../orchestration/workflow-park-decision.js";
|
|
24
|
+
import { CHECKPOINT_CTX_SEALING_REQUIRED } from "./checkpoint-ctx.js";
|
|
25
|
+
import { retiredServiceDepsRefusal } from "./retired-service-deps.js";
|
|
24
26
|
import { createAdmission, MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
25
27
|
import { createResumeLegs } from "./resume-legs.js";
|
|
26
28
|
import * as facts from "../capability-facts.js";
|
|
@@ -29,8 +31,8 @@ import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDis
|
|
|
29
31
|
import { createApprovalSweeps } from "./approval-sweeps.js";
|
|
30
32
|
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
31
33
|
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|
|
32
|
-
import { explicitOperatorOk,
|
|
33
|
-
export { explicitOperatorOk
|
|
34
|
+
import { explicitOperatorOk, hasServiceAuth } from "./principal-gate.js";
|
|
35
|
+
export { explicitOperatorOk };
|
|
34
36
|
class DrainYieldingPreemptBook extends Map {
|
|
35
37
|
drainingNow;
|
|
36
38
|
constructor(drainingNow) {
|
|
@@ -59,14 +61,10 @@ export function createHttpServer(rawDeps) {
|
|
|
59
61
|
if (typeof deps.runnerFor !== "function") {
|
|
60
62
|
throw new Error("createHttpServer: the runnerFor seat is required (it picks each task's Runner from its execution lane) — pass the hands-lane selector, or `runnerFor: () => runner` for a single-Runner embedding; refusing to start rather than run every task on the widest Runner");
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new Error(`createHttpServer: snapshotBlobSqlCap must be a reader \`() => { capBytes, source } | undefined\` (called on every PUT /v1/sessions/:id/sync/blobs/:hash), got ${typeof deps.snapshotBlobSqlCap} — pass the reader (or \`() => undefined\` for no cap), or leave it unset; refusing to start rather than answer every blob upload with a 500`);
|
|
67
|
-
}
|
|
68
|
-
if (deps.sqlEngineFacts !== undefined) {
|
|
69
|
-
throw new Error("createHttpServer: sqlEngineFacts was replaced by sqlEngine in 7.132.0 — pass the SQL pool's engine reading as sqlEngine: `{ dialect: \"tidb\" | \"pg\", facts }` where `facts` is read live (a getter) and is null while the pool's connection setup has not succeeded, or leave both unset when there is no SQL store; refusing to start rather than run the submit admission without the database's walls");
|
|
64
|
+
{
|
|
65
|
+
const retired = retiredServiceDepsRefusal(deps);
|
|
66
|
+
if (retired !== undefined)
|
|
67
|
+
throw new Error(retired);
|
|
70
68
|
}
|
|
71
69
|
{
|
|
72
70
|
const issue = sqlEngineSeatIssue(deps.backend, deps.sqlEngine);
|
|
@@ -83,6 +81,13 @@ export function createHttpServer(rawDeps) {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
}
|
|
84
|
+
{
|
|
85
|
+
const refusal = parkDecisionStoreRefusal(deps);
|
|
86
|
+
if (refusal !== undefined)
|
|
87
|
+
throw new Error(`createHttpServer: ${refusal}`);
|
|
88
|
+
}
|
|
89
|
+
if (deps.checkpointStore !== undefined && deps.checkpointCtxSealing === undefined)
|
|
90
|
+
throw new Error(`createHttpServer: ${CHECKPOINT_CTX_SEALING_REQUIRED}`);
|
|
86
91
|
const idemCache = new IdempotencyCache();
|
|
87
92
|
const inflightRuns = new Map();
|
|
88
93
|
const preemptableRuns = new DrainYieldingPreemptBook(() => deps.drainState?.draining === true);
|
|
@@ -138,9 +143,9 @@ export function createHttpServer(rawDeps) {
|
|
|
138
143
|
}
|
|
139
144
|
};
|
|
140
145
|
}
|
|
141
|
-
const { quotaExceeded, ownerCostQuotaDenied, ownerFleetLeaseDenied, ownerLeaseDenied, ownerQuotaDenied, leaseDenied, usageWindowDenialFor, usageWindowDenied, rateLimited, safeDecode,
|
|
146
|
+
const { quotaExceeded, ownerCostQuotaDenied, ownerFleetLeaseDenied, ownerLeaseDenied, ownerQuotaDenied, leaseDenied, usageWindowDenialFor, usageWindowDenied, rateLimited, safeDecode, runOwnerOk, sessionOwnerOk, runSessionAcceptOk, readJson, readRawBody } = createRequestGuards({ deps });
|
|
142
147
|
const { prepareSpec } = createAdmission({ deps, readJson, runnerFor });
|
|
143
|
-
const { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg, mayDiscloseRowError, resumePreempted, startFreshHostTurn, resumeWake } = createResumeLegs({ deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, safeDecode,
|
|
148
|
+
const { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg, mayDiscloseRowError, resumePreempted, startFreshHostTurn, resumeWake } = createResumeLegs({ 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 });
|
|
144
149
|
const { denyExpiredApprovals, redeemParkedAsk } = createApprovalSweeps({ deps, resumeCheckpoint, mayDiscloseRowError });
|
|
145
150
|
const { handle } = createDispatch({ deps, noteActivity, routeCtxBase, counters });
|
|
146
151
|
const server = http.createServer((req, res) => {
|
|
@@ -152,7 +157,7 @@ export function createHttpServer(rawDeps) {
|
|
|
152
157
|
res.end();
|
|
153
158
|
return;
|
|
154
159
|
}
|
|
155
|
-
deps.logger
|
|
160
|
+
logRequestError(deps.logger, req, err);
|
|
156
161
|
if (res.headersSent) {
|
|
157
162
|
res.end();
|
|
158
163
|
return;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { REQUEST_SETTINGS_REFUSAL_PREFIX, rulePolicyBucketsRefusal, settingsPermissionBucketIssue, storedBodyPermissionMode } from "../task-settings.js";
|
|
1
|
+
import { REQUEST_SETTINGS_REFUSAL_PREFIX, SETTINGS_RULE_REFUSAL_CODE, neverAutoNamesRefusal, rulePolicyBucketsRefusal, settingsPermissionBucketIssue, storedBodyPermissionMode } from "../task-settings.js";
|
|
2
|
+
import { readTightenOnlySeats, tightenOnlySeatField, tightenOnlySeatIssue } from "../tighten-only-seats.js";
|
|
3
|
+
import { entryProblemsFacts } from "../entry-problems.js";
|
|
2
4
|
import { autonomyModeFloor, entryPermissionMode } from "../runtime-governance.js";
|
|
3
5
|
import { inertToolListEntryOf, replayInertEntry } from "../rule-entry-list.js";
|
|
4
6
|
import { executionLaneHomeDir } from "../execution-lane-caps.js";
|
|
5
|
-
import { httpErrorCode } from "./send.js";
|
|
6
7
|
import { allowListReadingEraOf, allowListReadingUnstated, permissionModeReadingStated } from "./checkpoint-ctx.js";
|
|
7
8
|
export function permissionModeReadingUnstated(ctx, floor) {
|
|
8
9
|
if (floor === undefined || permissionModeReadingStated(ctx))
|
|
@@ -21,19 +22,31 @@ function storedPermissionBucketRefusal(body) {
|
|
|
21
22
|
return undefined;
|
|
22
23
|
return replayInertEntry(issue.fields.field, issue.fields.field === "settings.permissions.allow" ? "allow" : "deny", BUCKET_GATE_CODE, issue.message, { ...issue.fields });
|
|
23
24
|
}
|
|
25
|
+
function storedTightenOnlySeatRefusal(body) {
|
|
26
|
+
const issue = tightenOnlySeatIssue(body?.settings);
|
|
27
|
+
if (issue === null)
|
|
28
|
+
return undefined;
|
|
29
|
+
return replayInertEntry(tightenOnlySeatField(issue.seat), "deny", BUCKET_GATE_CODE, issue.message, { ...issue.fields });
|
|
30
|
+
}
|
|
24
31
|
function storedRulePolicyRefusal(body, deployment) {
|
|
25
32
|
const permissions = storedPermissions(body);
|
|
26
33
|
if (permissions === undefined)
|
|
27
34
|
return undefined;
|
|
28
35
|
const home = executionLaneHomeDir(deployment);
|
|
29
36
|
const refused = rulePolicyBucketsRefusal({ ...(Array.isArray(permissions["ask"]) ? { ask: permissions["ask"] } : {}), ...(Array.isArray(permissions["deny"]) ? { deny: permissions["deny"] } : {}) }, home !== undefined ? { home } : {});
|
|
30
|
-
|
|
37
|
+
if (refused !== undefined)
|
|
38
|
+
return replayInertEntry(`settings.permissions.${refused.bucket}`, "deny", SETTINGS_RULE_REFUSAL_CODE, `${REQUEST_SETTINGS_REFUSAL_PREFIX}${refused.message}`, { ...entryProblemsFacts(refused.problems) });
|
|
39
|
+
const neverAuto = readTightenOnlySeats({ permissions }).values.neverAuto;
|
|
40
|
+
if (neverAuto === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
const neverAutoRefused = neverAutoNamesRefusal(neverAuto);
|
|
43
|
+
return neverAutoRefused === undefined ? undefined : replayInertEntry(tightenOnlySeatField("neverAuto"), "deny", SETTINGS_RULE_REFUSAL_CODE, `${REQUEST_SETTINGS_REFUSAL_PREFIX}${neverAutoRefused.message}`, { ...entryProblemsFacts(neverAutoRefused.problems) });
|
|
31
44
|
}
|
|
32
45
|
export function storedBodyReplayRefusal(ctx, deployment) {
|
|
33
46
|
const writer = ctx.writerVersion !== undefined ? { writerVersion: ctx.writerVersion } : {};
|
|
34
47
|
if (allowListReadingUnstated(ctx))
|
|
35
48
|
return { kind: "allow_list_reading", era: allowListReadingEraOf(ctx), ...writer };
|
|
36
|
-
const entry = storedPermissionBucketRefusal(ctx.body) ?? inertToolListEntryOf(ctx.body, ["deny"]) ?? storedRulePolicyRefusal(ctx.body, deployment);
|
|
49
|
+
const entry = storedPermissionBucketRefusal(ctx.body) ?? storedTightenOnlySeatRefusal(ctx.body) ?? inertToolListEntryOf(ctx.body, ["deny"]) ?? storedRulePolicyRefusal(ctx.body, deployment);
|
|
37
50
|
if (entry !== undefined)
|
|
38
51
|
return { kind: "inert_tool_list", entry };
|
|
39
52
|
const mode = permissionModeReadingUnstated(ctx, autonomyModeFloor(deployment.autonomy));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
2
2
|
import type { Logger } from "../observability/logger.js";
|
|
3
3
|
import type { Metrics } from "../observability/metrics.js";
|
|
4
|
-
import { buildCheckpointCtx } from "./checkpoint-ctx.js";
|
|
4
|
+
import { buildCheckpointCtx, type CheckpointCtxSealer, type SealedCheckpointCtx } from "./checkpoint-ctx.js";
|
|
5
5
|
import { type RefusalBody } from "./refusal-body.js";
|
|
6
6
|
/** 写不进的那一种可答复的结局(各腿把它交回自己的出口:同步 / durable 腿直接回,活流腿编码成终帧)。 */
|
|
7
7
|
export interface SubmitCtxRefusal {
|
|
8
|
-
readonly status: 413;
|
|
8
|
+
readonly status: 413 | 409;
|
|
9
9
|
readonly body: RefusalBody;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -14,10 +14,11 @@ export interface SubmitCtxRefusal {
|
|
|
14
14
|
* 返回 `undefined` = 写进了,腿照常起跑。
|
|
15
15
|
*/
|
|
16
16
|
export declare function persistSubmitCtx(store: {
|
|
17
|
-
putCtx(sessionId: string, ctx:
|
|
17
|
+
putCtx(sessionId: string, ctx: SealedCheckpointCtx): Promise<void>;
|
|
18
18
|
}, deps: {
|
|
19
19
|
readonly logger?: Logger | undefined;
|
|
20
20
|
readonly metrics?: Metrics | undefined;
|
|
21
|
+
readonly checkpointCtxSealing?: CheckpointCtxSealer | undefined;
|
|
21
22
|
}, claim: {
|
|
22
23
|
readonly runStore: RunStore;
|
|
23
24
|
readonly taskId: string;
|
package/dist/http/submit-ctx.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { StoreRowTooLargeError } from "../plugins/sql-errors.js";
|
|
2
2
|
import { releaseClaimedRun } from "./claimed-run.js";
|
|
3
|
-
import { buildCheckpointCtx } from "./checkpoint-ctx.js";
|
|
3
|
+
import { buildCheckpointCtx, CheckpointCtxUnsealableError } from "./checkpoint-ctx.js";
|
|
4
4
|
import { refusalBody } from "./refusal-body.js";
|
|
5
|
+
import { limitFactsUnmeasured } from "../limit-refusal.js";
|
|
6
|
+
function unsealableRefusal(e) {
|
|
7
|
+
return {
|
|
8
|
+
status: 409,
|
|
9
|
+
body: refusalBody({
|
|
10
|
+
errorCode: "conflict.checkpoint_ctx_unsealable",
|
|
11
|
+
message: "this deployment cannot store this task's credentials (MCP / A2A headers or env values, settings.env, settings.webSearch.apiKey, or http hook headers) for resuming it: they are kept only sealed, and this server has no sealed-key store — nothing was run; ask whoever operates this deployment to give the service a writable sealed-key directory (<data root>/sealed-key/), or submit the task without those credentials",
|
|
12
|
+
facts: { field: e.field, reason: e.reason },
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
5
16
|
function rowTooLargeRefusal(tooLarge) {
|
|
6
17
|
switch (tooLarge.wall) {
|
|
7
18
|
case "row":
|
|
8
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's single-row limit (TiDB performance.txn-entry-size-limit)
|
|
19
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's single-row limit (TiDB performance.txn-entry-size-limit)`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
9
20
|
case "statement":
|
|
10
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's max_allowed_packet
|
|
21
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's max_allowed_packet`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
11
22
|
case "value":
|
|
12
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments
|
|
23
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
13
24
|
default: {
|
|
14
25
|
const unhandled = tooLarge.wall;
|
|
15
26
|
throw new Error(`row-too-large refusal without an HTTP answer: ${String(unhandled)}`);
|
|
@@ -18,18 +29,24 @@ function rowTooLargeRefusal(tooLarge) {
|
|
|
18
29
|
}
|
|
19
30
|
export async function persistSubmitCtx(store, deps, claim, sessionId, fields) {
|
|
20
31
|
try {
|
|
21
|
-
await store.putCtx(sessionId, buildCheckpointCtx(fields));
|
|
32
|
+
await store.putCtx(sessionId, buildCheckpointCtx(fields, deps.checkpointCtxSealing, sessionId));
|
|
22
33
|
return undefined;
|
|
23
34
|
}
|
|
24
35
|
catch (err) {
|
|
25
36
|
const tooLarge = err instanceof StoreRowTooLargeError ? err : undefined;
|
|
37
|
+
const unsealable = err instanceof CheckpointCtxUnsealableError ? err : undefined;
|
|
38
|
+
const known = tooLarge ?? unsealable;
|
|
26
39
|
if (claim !== undefined) {
|
|
27
|
-
const why =
|
|
40
|
+
const why = known !== undefined ? known.message : `the run's resume inputs could not be stored: ${err instanceof Error ? err.message : String(err)}`;
|
|
28
41
|
await releaseClaimedRun(claim.runStore, claim.taskId, why, (releaseErr, step) => {
|
|
29
42
|
deps.logger?.warn("submit_ctx_run_release_failed", { taskId: claim.taskId, sessionId, step, err: releaseErr instanceof Error ? releaseErr.message : String(releaseErr) });
|
|
30
43
|
deps.metrics?.inc("submit_ctx_run_release_failed_total", { step });
|
|
31
44
|
});
|
|
32
45
|
}
|
|
46
|
+
if (unsealable !== undefined) {
|
|
47
|
+
deps.logger?.warn("submit_ctx_unsealable", { sessionId, taskId: claim?.taskId, field: unsealable.field, reason: unsealable.reason });
|
|
48
|
+
return unsealableRefusal(unsealable);
|
|
49
|
+
}
|
|
33
50
|
if (tooLarge === undefined)
|
|
34
51
|
throw err;
|
|
35
52
|
deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall, db: tooLarge.dbMessage });
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* ## 判定(三条,按序;别的一律不放)
|
|
11
11
|
* · 这次提交自带 taskId 而命中的行**不是**那一条(`Idempotency-Key` 指向别的行)⇒ 冲突;
|
|
12
|
-
* · 调用方读不到这一行(属主门 = `runOwnerReadable`,「这个调用方读得到这一行 run
|
|
12
|
+
* · 调用方读不到这一行(属主门 = `runOwnerReadable`,「这个调用方读得到这一行 run 吗」的唯一谓词,经属主存取器 `owner-access.ts` 读)⇒ 冲突;
|
|
13
13
|
* 冲突 ⇒ `409 conflict.run_exists`,体里**不回显**那条行的任何标识(不给跨租户预言机)。先于下一条判:读不到的行不比体。
|
|
14
14
|
* · 这次提交带 `Idempotency-Key`(`caller.idem` 在场)、那一行绑的**就是这把键**,而它记着的请求体指纹与这次不同 ⇒
|
|
15
15
|
* `409 conflict.idempotency_payload_mismatch`(同形 `{ error, errorCode }`,不回显键与那一行);**不**回放首发、不新建、那一行不动。
|
|
@@ -26,12 +26,13 @@ import type { RunIdemBinding, RunRecord } from "../plugins/store-contracts.js";
|
|
|
26
26
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
27
27
|
import type { ServiceConfig } from "../config-types.js";
|
|
28
28
|
import type { SubmitOutcome } from "./idempotency.js";
|
|
29
|
+
import type { Principal } from "../security.js";
|
|
29
30
|
/** 提交腿的回执形(闭集;穷举 `switch`,加一形不写这里 = 编译红)。 */
|
|
30
31
|
export type SubmitReplayFace = "durable" | "sync";
|
|
31
32
|
/** 发起这次提交的一方。 */
|
|
32
33
|
export interface ReplayCaller {
|
|
33
|
-
/** 已验身份(`gatedPrincipal`)。 */
|
|
34
|
-
principal:
|
|
34
|
+
/** 已验身份(`gatedPrincipal` 的回值,`Principal` 品牌)。 */
|
|
35
|
+
principal: Principal | undefined;
|
|
35
36
|
/** 这次提交自带的 taskId(`body.taskId`;A2A 派生值)。缺席 = 只凭 `Idempotency-Key` 命中。 */
|
|
36
37
|
clientTaskId?: string;
|
|
37
38
|
/** 这次提交的账本绑定(键 + 请求体指纹;`RunIdemBinding`)。`undefined` = 这次提交没带 `Idempotency-Key`(只凭 `body.taskId`)⇒ 不比体。
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runRowReadable } from "./owner-access.js";
|
|
2
2
|
import { readRunFace } from "./run-read-face.js";
|
|
3
|
+
import { refusalBody } from "./refusal-body.js";
|
|
3
4
|
export function isRunExistsConflictBody(body) {
|
|
4
5
|
return typeof body === "object" && body !== null && body.errorCode === "conflict.run_exists";
|
|
5
6
|
}
|
|
6
7
|
export async function replayOfExistingRun(row, caller, face, deps, runStore) {
|
|
7
8
|
const sameRun = caller.clientTaskId === undefined || caller.clientTaskId === row.taskId;
|
|
8
|
-
if (!sameRun || !
|
|
9
|
-
return { status: 409, body: {
|
|
9
|
+
if (!sameRun || !runRowReadable(deps.config, caller.principal, row.owner, "owner")) {
|
|
10
|
+
return { status: 409, body: refusalBody({ errorCode: "conflict.run_exists", message: "a run already exists for this submission's taskId or Idempotency-Key" }) };
|
|
10
11
|
}
|
|
11
12
|
if (caller.idem !== undefined) {
|
|
12
13
|
const held = await runStore.bindIdemBodyFingerprint(row.taskId, caller.idem);
|
|
13
14
|
if (held !== null && held !== caller.idem.bodyFingerprint) {
|
|
14
|
-
return { status: 409, body: {
|
|
15
|
+
return { status: 409, body: refusalBody({ errorCode: "conflict.idempotency_payload_mismatch", message: "this Idempotency-Key was already used for a different request body — a retry must resend the same body; send a different request with a new Idempotency-Key" }) };
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
switch (face) {
|
|
@@ -10,11 +10,12 @@ import type { A2aServerSpec, AgentDefinition, ApprovalReach, PermissionMode, Ski
|
|
|
10
10
|
import type { RequestMcpServerSpec } from "../mcp-assertion-header.js";
|
|
11
11
|
import type { wiringManifestFaceEventData } from "../trace/project.js";
|
|
12
12
|
import type { buildSyncSubmitBody } from "./sync-submit-body.js";
|
|
13
|
+
import type { EntryProblem } from "../entry-problems.js";
|
|
13
14
|
export interface TaskRequestBody {
|
|
14
15
|
objective: string;
|
|
15
16
|
sessionId?: string;
|
|
16
17
|
/** Which deployment SCENARIO assembles this task's tools/prompt/skills (the keys of the worker's scenario
|
|
17
|
-
* table — e.g. "default"/"code"/"code-review"/"scan"). An INTENT bounded by the deployment's own table AND,
|
|
18
|
+
* table — e.g. "default"/"code"/"code-review"/"scan"/"cowork"). An INTENT bounded by the deployment's own table AND,
|
|
18
19
|
* on a governed worker, by the principal's center-resolved allowlist: an unknown name is a typed 400
|
|
19
20
|
* `scenario_unknown`, a known-but-not-allowed one a typed 400 `scenario_not_allowed`; absent ⇒ the ruling's
|
|
20
21
|
* assigned scenario, else `DEFAULT_SCENARIO` (consumed at `boot/resolve-spec.ts` via `gateScenarioRequest`). A name
|
|
@@ -260,7 +261,7 @@ export interface TaskRequestBody {
|
|
|
260
261
|
forwardSubagentEvents?: boolean;
|
|
261
262
|
/** G3([ref] 壳侧承诺③/[ref]③):壳供 per-session scratchpad 路径(壳 vendored getScratchpadDir 的
|
|
262
263
|
* 约定路径)。接受后优先于 server 自算,同源喂 envFacts.scratchpadDir 宣告(core 据它开根围栏的洞,
|
|
263
|
-
* S-842
|
|
264
|
+
* S-842 起是唯一写者,引擎的模式门也据它免问)—— 壳提示词与引擎的写根指同一个目录。验收 fail-closed(单用户 +
|
|
264
265
|
* host-semantics lane + 绝对路径/深度/长度门,规则在 env-facts.acceptShellScratchpadDir),拒收形
|
|
265
266
|
* warn 后回落自算——「没到货引擎忽略 = 无害 additive」的对偶:异形键忽略,任务照跑。 */
|
|
266
267
|
scratchpadDir?: string;
|
|
@@ -349,11 +350,11 @@ export interface TaskRequestBody {
|
|
|
349
350
|
toolMaterializeStrategy?: "static" | "swap";
|
|
350
351
|
/** R4 (CC parity): the LIGHT top-level per-turn permission-mode intent (CC `permissionMode`). The shell sends
|
|
351
352
|
* the RAW mode (axis-agnostic, no client-side interpretation); the SERVICE interprets it tighten-only vs the
|
|
352
|
-
* deployment baseline. All SIX core modes
|
|
353
|
-
* `
|
|
354
|
-
*
|
|
355
|
-
* `deniedBy:"mode"`)
|
|
356
|
-
*
|
|
353
|
+
* deployment baseline. All SIX core modes ride verbatim into `TaskSpec.permissionMode` and only the engine's mode table
|
|
354
|
+
* interprets them (`plan` asks at the call for writes and non-read-only calls; `acceptEdits` writes inside the write roots — the
|
|
355
|
+
* task root plus `additionalDirectories` — without asking; `dontAsk` refuses every ask by the mode, zero cards, the gate records
|
|
356
|
+
* `deniedBy:"mode"`); none can subtract from deployment/operator policy or the request's own deny / ask rules (tightenTaskSpec
|
|
357
|
+
* deny-wins). The top-level word wins over `settings.permissions.defaultMode` (the heavier bundle) — one precedence, read in one place.
|
|
357
358
|
* [ref]-②: CLOSED enum on the wire — an unknown word 400s at submit (`request.field_invalid`, sibling of
|
|
358
359
|
* promptProfile) instead of silently coercing to `default`; resume replay of a stored body stays lenient
|
|
359
360
|
* (coercePermissionMode).
|
|
@@ -401,10 +402,10 @@ export interface TaskRequestBody {
|
|
|
401
402
|
* 记忆面暗的部署(引擎未接线 / 多租户)上 `memory` 整键本就缺席,本声明无处落也无事可关。
|
|
402
403
|
* Rides the persisted body onto resume legs(与 `memoryWrite` 同姿势)。
|
|
403
404
|
* ✅ **子代地板自 core 7.22.0 到货,本仓零接线**:core 的 `parentSpecSeatOf` 从**这条 run 自己的**
|
|
404
|
-
* `spec.memory.enabled === false`
|
|
405
|
-
*
|
|
405
|
+
* `spec.memory.enabled === false` 铸座位的 `memory: { enabled: false }`(core 7.54.0 起是夹表座的一行;此前叫 `memoryOff`,已退役),
|
|
406
|
+
* `applyParentSpecSeat` 按表**夹**到子代上(改写成 `{ …子代自己的 scopes, enabled:false }`,永不删键;子代的 `enabled:true` 抬不起)⇒ 父关 ⇒ 子代 / 孙代 /
|
|
406
407
|
* workflow 子 spec / 跨 run 唤醒与保留 resume 一律无记忆面。🚧 **tier-3 耐久复活不带**(core 已记残余)。
|
|
407
|
-
* 链路的机器锚:`test/memory-off-request.test.ts` ⑥ 段(
|
|
408
|
+
* 链路的机器锚:`test/memory-off-request.test.ts` ⑥ 段(经 core 包根 `parentSpecSeatOf` / `applyParentSpecSeat` 读铸与施)。 */
|
|
408
409
|
memory?: "off";
|
|
409
410
|
/** 142-S4 projectId 线程化([ref] §2):这个 run 归属的项目(center 登记簿键,generic lowercase
|
|
410
411
|
* UUID — core S1 `resolveProjectId` marker 或 S3 无仓 mint 的产物;客户端只透传,零铸造权威)。是「哪个
|
|
@@ -571,6 +572,10 @@ export type DecideBinding = {
|
|
|
571
572
|
boundInputHash?: string;
|
|
572
573
|
/** [ref] edit: operator-corrected tool args, applied by core AFTER the binding check, on approve only. */
|
|
573
574
|
updatedInput?: unknown;
|
|
575
|
+
/** core 7.54.0: the words the approving person wrote on the card ("and tell the agent what to do next"). The decide door admits
|
|
576
|
+
* the key only on a person's `approve` (a `deny` or a policy decide with it is a 400 `request.field_conflict`), and the outcome
|
|
577
|
+
* mints carry it verbatim when present — the engine owns what counts as written (blank = nothing) and judges it again pre-CAS. */
|
|
578
|
+
feedback?: string;
|
|
574
579
|
};
|
|
575
580
|
/** [ref]([ref]④→[ref] 坐标轮换判定):409 `approval_stale` 拒体上的 additive 机读指路 ——
|
|
576
581
|
* **本会话当前 pending** 的 D-1 回显坐标,让持旧坐标的壳一跳重定位(免重拉列表)。
|
|
@@ -610,5 +615,7 @@ export type SyncSubmitBody = ReturnType<typeof buildSyncSubmitBody>;
|
|
|
610
615
|
export interface SyncSubmitExtraKeys {
|
|
611
616
|
notice?: string;
|
|
612
617
|
wiringManifest?: WiringManifestReceipt;
|
|
618
|
+
/** 受理告知(`entry-problems.ts` 的条目形):放行侧选择器清单里什么也不放的条目,**present-iff** 有话说;流式腿的同名键在 `meta` 帧、异步腿的在 202 回执。 */
|
|
619
|
+
warnings?: readonly EntryProblem[];
|
|
613
620
|
}
|
|
614
621
|
//# sourceMappingURL=wire-types.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -23,13 +23,15 @@ export { ensureTiDBTaskListSchema, ensurePgTaskListSchema } from "./plugins/task
|
|
|
23
23
|
export { createAuthorizer, principalFrom, HttpError, type AuthContext, type OwnerAwareSessionStore, } from "./security.js";
|
|
24
24
|
export { memoryScopeFor, memoryEngineBackendFor } from "./memory-scope.js";
|
|
25
25
|
export type { TaskRequestBody } from "./http/wire-types.js";
|
|
26
|
+
export { ensureCheckpointCtxSealing } from "./sealed-key.js";
|
|
27
|
+
export type { CheckpointCtxSealing } from "./http/checkpoint-ctx.js";
|
|
26
28
|
export { createHttpServer, type ServiceDeps, type RequestAuth, type FlatServiceDeps, type ServiceDepGroups, type ServiceCoreDeps, type ServiceStoreDeps, type ServiceCoordinatorDeps, type ServiceSeamDeps, type ServiceObservabilityDeps, type ServiceGovernanceDeps, type ServiceDeploymentDeps, type ServiceKnobDeps, } from "./http/server.js";
|
|
27
29
|
export { createSideQueryLane, type KeyResolver, type SideQueryLane, type SideQueryLaneCtx } from "./boot/side-query-lane.js";
|
|
28
30
|
export { createKeyResolver, resolveModelApiKey, type ModelKeyRef } from "./key-resolver.js";
|
|
29
31
|
export { isModelKeyPoison, ModelKeyPoisonedError, type ModelKeyPoison, type ModelKeyPoisonReason } from "./key-resolver.js";
|
|
30
32
|
export { CATALOG_ENTRY_HEADER_LANES, CATALOG_ENTRY_HEADER_NAMES, type CatalogEntryHeaderName } from "./model-entry-headers.js";
|
|
31
|
-
export { judgeModelRouteGap, type ModelRouteGapReading, type ModelRouteGapOptions } from "./model-route-gap.js";
|
|
32
33
|
export type { ModelRouteGap } from "./model-route-endpoint.js";
|
|
33
34
|
export { judgeServedModelRoute, type ServedModelRouteView, type ServedModelRouteOptions, type ModelRouteEndpointVerdict } from "./model-route-endpoint.js";
|
|
34
35
|
export type { UserInputLedgerStore, UserInputAcceptance, NewUserInputAcceptance, OpenScanCursor, OpenScanPage, SettleHow, WriterGoneEvidence } from "./user-input-ledger.js";
|
|
36
|
+
export type { OrgDeliveryQuotaStore, OrgDeliveryQuotaPolicy } from "./plugins/org-delivery-quota-store.js";
|
|
35
37
|
//# sourceMappingURL=index.d.ts.map
|