@sema-agent/server 7.131.0 → 7.133.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 +575 -0
- package/README.md +12 -9
- package/README.zh-CN.md +9 -6
- package/USAGE.md +326 -98
- package/deploy/sema-up/README.md +19 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
- package/deploy/sema-up/chart/templates/server.yaml +5 -2
- 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 +31 -13
- 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 +82 -20
- package/dist/approval-card.js +46 -16
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval.d.ts +9 -0
- package/dist/approval.js +24 -3
- package/dist/audit.d.ts +33 -19
- package/dist/audit.js +12 -16
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/deployment-mods.d.ts +31 -0
- package/dist/boot/deployment-mods.js +26 -0
- package/dist/boot/execution-env.d.ts +1 -1
- package/dist/boot/execution-env.js +27 -12
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.js +2 -0
- package/dist/boot/memory-boundary.d.ts +2 -2
- 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.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +4 -5
- package/dist/boot/resolve-spec.js +74 -123
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +15 -2
- package/dist/boot/session-faces.d.ts +2 -7
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -4
- package/dist/boot/stage-05-execution-env.js +7 -10
- package/dist/boot/stage-06-runners.d.ts +4 -2
- package/dist/boot/stage-06-runners.js +11 -7
- package/dist/boot/stage-07-capability-layer.d.ts +4 -2
- package/dist/boot/stage-07-capability-layer.js +27 -6
- package/dist/boot/stage-08-reapers.d.ts +4 -2
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +6 -9
- package/dist/boot/stage-10-http-server.d.ts +6 -9
- package/dist/boot/stage-10-http-server.js +7 -9
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +7 -8
- package/dist/boot/web-admin.d.ts +4 -3
- package/dist/boot/web-admin.js +186 -98
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +25 -25
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +23 -0
- package/dist/caller-text-echo.js +21 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +32 -59
- package/dist/capabilities/center-prompts.js +18 -32
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +30 -6
- package/dist/capabilities/hands-lane.js +11 -1
- package/dist/capabilities/mcp-probe.d.ts +48 -3
- package/dist/capabilities/mcp-probe.js +47 -135
- package/dist/capabilities/scenarios.d.ts +95 -45
- package/dist/capabilities/scenarios.js +53 -38
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capability-facts.d.ts +34 -4
- package/dist/capability-facts.js +28 -2
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -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 +47 -32
- 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-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +9 -2
- package/dist/config-provider.js +18 -6
- package/dist/config-types.d.ts +75 -20
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +137 -62
- 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 -22
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/env-name-allowlist-knobs.d.ts +12 -2
- package/dist/env-name-allowlist-knobs.js +5 -4
- package/dist/exec-bounds.d.ts +15 -3
- package/dist/exec-bounds.js +4 -0
- package/dist/execution-lane-caps.d.ts +56 -10
- package/dist/execution-lane-caps.js +50 -0
- package/dist/field-conflict.d.ts +43 -0
- package/dist/field-conflict.js +20 -0
- package/dist/fleet/fleet-bus.d.ts +80 -6
- package/dist/fleet/fleet-bus.js +41 -9
- package/dist/hooks/classic-stations.d.ts +91 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +79 -36
- package/dist/hooks/hook-runner.d.ts +349 -95
- package/dist/hooks/hook-runner.js +855 -568
- 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.d.ts +8 -2
- package/dist/http/admission.js +188 -101
- package/dist/http/approval-sweeps.js +99 -21
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +41 -24
- package/dist/http/checkpoint-ctx.js +23 -16
- package/dist/http/claimed-run.d.ts +14 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +7 -11
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +15 -13
- package/dist/http/durable-run-leg.d.ts +6 -33
- package/dist/http/durable-run-leg.js +36 -10
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +70 -28
- package/dist/http/principal-gate.js +61 -15
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +43 -23
- package/dist/http/request-guards.js +53 -17
- package/dist/http/resume-ctx-read.d.ts +2 -5
- package/dist/http/resume-ctx-read.js +7 -4
- package/dist/http/resume-legs.d.ts +28 -4
- package/dist/http/resume-legs.js +169 -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 -28
- 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/approvals-assistant.js +49 -48
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +21 -5
- 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.js +6 -2
- 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.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 +5 -18
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +34 -107
- package/dist/http/routes/session-sync.js +15 -26
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +8 -7
- package/dist/http/routes/tasks.js +67 -21
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +33 -10
- package/dist/http/send.js +21 -4
- package/dist/http/server.d.ts +27 -18
- package/dist/http/server.js +34 -6
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +40 -0
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +11 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/lane-home-probe.d.ts +112 -0
- package/dist/lane-home-probe.js +101 -0
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/limit-refusal.d.ts +59 -0
- package/dist/limit-refusal.js +15 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +32 -19
- package/dist/mcp-assertion-header.js +10 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +6 -4
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +24 -17
- 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-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 +44 -12
- package/dist/model-provider.js +21 -2
- package/dist/model-route-endpoint.d.ts +9 -12
- package/dist/model-route-endpoint.js +8 -11
- 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/cost-taxonomy.d.ts +7 -7
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +76 -14
- package/dist/observability/fail-open.js +76 -14
- package/dist/observability/metrics.js +4 -1
- package/dist/observability/prompt-manifest.d.ts +33 -82
- package/dist/observability/prompt-manifest.js +122 -17
- package/dist/observability/run-terminal.js +14 -6
- package/dist/observability/secret-env-scrub.d.ts +13 -1
- package/dist/observability/secret-env-scrub.js +13 -1
- package/dist/observability/tool-trace.d.ts +16 -21
- package/dist/observability/tool-trace.js +58 -49
- 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 +118 -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 +39 -6
- package/dist/parked-decide.js +98 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- 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/blob-backend.d.ts +83 -15
- package/dist/plugins/blob-backend.js +68 -15
- 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 +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +28 -4
- package/dist/plugins/checkpoint-store-sql.js +59 -28
- 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/k8s-bg-scripts.d.ts +11 -0
- package/dist/plugins/k8s-bg-scripts.js +22 -0
- package/dist/plugins/local-checkpoint-store.d.ts +2 -0
- package/dist/plugins/local-checkpoint-store.js +11 -3
- package/dist/plugins/local-session-store.d.ts +1 -1
- package/dist/plugins/local-session-store.js +1 -1
- package/dist/plugins/local-session-window.d.ts +39 -0
- package/dist/plugins/local-session-window.js +54 -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 +245 -93
- package/dist/plugins/one-time-migrations.js +668 -207
- 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-sql.d.ts +13 -7
- package/dist/plugins/permission-rule-store-sql.js +4 -18
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +20 -8
- package/dist/plugins/pg-session-storage.js +34 -21
- package/dist/plugins/remote-env-adb.d.ts +12 -12
- package/dist/plugins/remote-env-adb.js +21 -6
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +1 -1
- package/dist/plugins/remote-env-e2b.js +21 -9
- package/dist/plugins/remote-env-host.d.ts +9 -9
- package/dist/plugins/remote-env-host.js +10 -32
- package/dist/plugins/remote-env-k8s.d.ts +103 -38
- package/dist/plugins/remote-env-k8s.js +288 -95
- package/dist/plugins/remote-env-local-docker.d.ts +27 -13
- package/dist/plugins/remote-env-local-docker.js +82 -11
- package/dist/plugins/remote-env-ssh.d.ts +21 -12
- package/dist/plugins/remote-env-ssh.js +117 -5
- package/dist/plugins/remote-shell.d.ts +0 -1
- package/dist/plugins/remote-shell.js +1 -2
- package/dist/plugins/retention-store-sql.js +6 -2
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- 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 +39 -0
- package/dist/plugins/session-epoch-anchor.js +22 -0
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
- package/dist/plugins/shared-memory-store-sql.js +5 -16
- package/dist/plugins/sql-driver.d.ts +205 -1
- package/dist/plugins/sql-driver.js +325 -13
- package/dist/plugins/sql-errors.d.ts +64 -0
- package/dist/plugins/sql-errors.js +57 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +42 -15
- 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 +8 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.d.ts +24 -4
- package/dist/plugins/tidb-session-store.js +29 -5
- 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/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- 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 +9 -2
- package/dist/request-key-closure.js +11 -5
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +38 -11
- package/dist/rule-entry-list.js +106 -30
- 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 +54 -24
- package/dist/runs.d.ts +15 -8
- package/dist/runs.js +35 -1
- 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/security.d.ts +87 -9
- package/dist/security.js +52 -9
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- 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 +27 -6
- package/dist/spec-fields.d.ts +28 -16
- package/dist/spec-fields.js +66 -54
- package/dist/sql-engine-posture.d.ts +31 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-tool-axes-m19.d.ts +19 -4
- package/dist/stored-request-tool-axes-m19.js +30 -2
- package/dist/task-a2a.d.ts +9 -1
- package/dist/task-a2a.js +73 -47
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +46 -58
- package/dist/task-mcp.js +82 -107
- package/dist/task-settings.d.ts +95 -108
- package/dist/task-settings.js +77 -98
- package/dist/text-bidi.d.ts +1 -48
- package/dist/text-bidi.js +3 -5
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +304 -88
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +122 -20
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/ledger-sink.js +4 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +98 -17
- package/dist/trace/project.js +98 -50
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +54 -0
- package/dist/trace/redact.js +778 -152
- package/dist/trace/self-minted-wire.d.ts +345 -1
- package/dist/trace/self-minted-wire.js +117 -1
- package/dist/trace/wire-projection-faces.d.ts +377 -3
- package/dist/trace/wire-projection-faces.js +164 -1
- 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/candidate-gate.d.ts +6 -6
- package/dist/web-admin-client/candidate-gate.js +3 -3
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/read-warnings.d.ts +13 -0
- package/dist/web-admin-client/read-warnings.js +10 -0
- package/dist/web-admin-client/skills-mcp.d.ts +3 -0
- package/dist/web-admin-client/skills-mcp.js +11 -9
- package/dist/web-admin-client/types.d.ts +2 -3
- package/dist/workspace-cache.d.ts +35 -0
- package/dist/workspace-cache.js +36 -0
- package/dist/workspace-space.d.ts +3 -2
- package/dist/workspace-space.js +2 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +65 -10
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -1
- package/scripts/drain-check.mysql.sql +30 -2
- package/scripts/drain-check.pg.sql +29 -2
- package/dist/capabilities/memory-notice.d.ts +0 -138
- package/dist/capabilities/memory-notice.js +0 -64
- package/dist/capabilities/prompt.d.ts +0 -17
- package/dist/capabilities/prompt.js +0 -6
- package/dist/mcp-content-origin.d.ts +0 -34
- package/dist/mcp-content-origin.js +0 -10
- package/dist/tool-axis-words.d.ts +0 -27
- package/dist/tool-axis-words.js +0 -9
- package/dist/wire-name-bound.d.ts +0 -14
- package/dist/wire-name-bound.js +0 -13
package/dist/http/send.d.ts
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
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";
|
|
14
|
+
import { type Refusal, type RefusalBody } from "./refusal-body.js";
|
|
13
15
|
/**
|
|
14
16
|
* [ref](黑板 [ref]②)—— 一条响应「是 SSE 流」的**在场标记**。
|
|
15
17
|
*
|
|
@@ -70,19 +72,34 @@ export declare function sendJson(res: ServerResponse, status: number, body: unkn
|
|
|
70
72
|
* change), not a new response shape. Sites where the two machine-code channels genuinely disagree, or
|
|
71
73
|
* where `error`/`errorCode` aren't cleanly separable from the rest of the body, are left on raw
|
|
72
74
|
* `sendJson` (see the A6 migration notes for the callers still doing that on purpose). */
|
|
73
|
-
export declare function sendError(res: ServerResponse, status: number, errorCode: string, message: string, extra?: Record<string, unknown
|
|
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;
|
|
74
90
|
/** B7([ref] lens1 §C3):`HttpError` 的兜底 catch-all 站点没有自己的语义分支——`err.code` 在 42 个
|
|
75
91
|
* throw 点里只有 3 个带。为了让「errorCode 恒在」在这些站点也成立(而不是靠豁免表放行),按**状态码**
|
|
76
92
|
* 给一个诚实的粗码:它只声明「这类拒绝」,不冒充比 throw 点更细的语义。带 `code` 的 throw 点原样优先。 */
|
|
77
93
|
export declare function httpErrorCode(status: number, code?: string): string;
|
|
78
94
|
/**
|
|
79
|
-
* 一只 `HttpError`
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* 同一只错在两处渲出的成员逐字同,面板不自己拼 `{ errorCode, error }`(拼了就丢 `extra`:壳分不出这次门拒是中心指派漂了还是部署缺省悬空)。
|
|
95
|
+
* 一只 `HttpError` 读成 {@link Refusal}:码经 {@link httpErrorCode}(带码的 throw 原样优先,否则按状态给粗码),句 = `message`,机读事实 = `extra`
|
|
96
|
+
* (如场景门的 `detail: { scenario, source }`、条数帽的 `field` / `reason` / `count` / `cap`)。**拆 `HttpError` 的唯一一处** —— 别的站点自己拆
|
|
97
|
+
* `status` / `code` / `message` 拼体就丢了 `extra`(`test/refusal-one-composer.test.ts` 的静态门钉着)。
|
|
83
98
|
*/
|
|
84
|
-
export declare function
|
|
85
|
-
/**
|
|
99
|
+
export declare function httpErrorRefusal(e: HttpError): Refusal;
|
|
100
|
+
/** 一只 `HttpError` 的拒体成员 = {@link refusalBody}({@link httpErrorRefusal})。 */
|
|
101
|
+
export declare function httpErrorBody(e: HttpError): RefusalBody;
|
|
102
|
+
/** 整面拒:状态 = `e.status`,体 = {@link httpErrorBody}。手里拿着一只 `HttpError` 的路由站点一律调它。 */
|
|
86
103
|
export declare function sendHttpError(res: ServerResponse, e: HttpError): void;
|
|
87
104
|
/**
|
|
88
105
|
* 🔴 B1 / S-535 —— `SessionPolicyError` → 应答,经 {@link sessionPolicyErrorHttp} 那**一只**映射
|
|
@@ -100,11 +117,17 @@ export declare function sendSessionPolicyError(res: ServerResponse, e: unknown,
|
|
|
100
117
|
* 回 `true` = 已应答,调用点 `return`;`false` = 不是 `SessionError`,或这个词在这一面上是登记过的留白(站点的既有
|
|
101
118
|
* 处置照旧 —— 通常是继续上抛到全局兜底)。
|
|
102
119
|
*
|
|
103
|
-
* 句子:属主给了固定句就发它(import 面 `invalid_session`
|
|
120
|
+
* 句子:属主给了固定句就发它(import 面 `invalid_session` / `placement_refused` 两句),否则发 core 的原句过既有脱敏(`redactErrorMessage`:
|
|
104
121
|
* 不抛、有上限)。core 的 `corrupt_session` 原句只点名会话 id 与跳过计数(「Session <id> is unreadable: its log has no
|
|
105
122
|
* meta header (N of M records skipped as corrupt)」),SQL 两店的原句点名 `<表>.<列>` 与行号 —— 两者都不含盘上路径
|
|
106
123
|
* (路径只进运维面:`server.session-repo.corrupt-record-skipped` 的探针行,S-990;SQL 两店走各自的拒绝句)。
|
|
107
124
|
*/
|
|
108
125
|
export declare function sendSessionError(res: ServerResponse, e: unknown, face: SessionErrorFace): boolean;
|
|
109
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;
|
|
110
133
|
//# sourceMappingURL=send.d.ts.map
|
package/dist/http/send.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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";
|
|
6
|
+
import { refusalBody } from "./refusal-body.js";
|
|
5
7
|
export const SSE_RESPONSE_MARK = Symbol("sema.http.sse-response");
|
|
6
8
|
export function isSseResponse(res) {
|
|
7
9
|
return res[SSE_RESPONSE_MARK] === true;
|
|
@@ -31,7 +33,15 @@ export function sendJson(res, status, body) {
|
|
|
31
33
|
res.end(JSON.stringify(body));
|
|
32
34
|
}
|
|
33
35
|
export function sendError(res, status, errorCode, message, extra) {
|
|
34
|
-
sendJson(res, status, {
|
|
36
|
+
sendJson(res, status, refusalBody(extra === undefined ? { errorCode, message } : { errorCode, message, facts: extra }));
|
|
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 });
|
|
35
45
|
}
|
|
36
46
|
export function httpErrorCode(status, code) {
|
|
37
47
|
if (code)
|
|
@@ -48,8 +58,12 @@ export function httpErrorCode(status, code) {
|
|
|
48
58
|
default: return status >= 500 ? "internal.error" : "request.rejected";
|
|
49
59
|
}
|
|
50
60
|
}
|
|
61
|
+
export function httpErrorRefusal(e) {
|
|
62
|
+
const errorCode = httpErrorCode(e.status, e.code);
|
|
63
|
+
return e.extra === undefined ? { errorCode, message: e.message } : { errorCode, message: e.message, facts: e.extra };
|
|
64
|
+
}
|
|
51
65
|
export function httpErrorBody(e) {
|
|
52
|
-
return
|
|
66
|
+
return refusalBody(httpErrorRefusal(e));
|
|
53
67
|
}
|
|
54
68
|
export function sendHttpError(res, e) {
|
|
55
69
|
sendJson(res, e.status, httpErrorBody(e));
|
|
@@ -68,10 +82,13 @@ export function sendSessionError(res, e, face) {
|
|
|
68
82
|
const wire = sessionErrorHttp(e.code, face);
|
|
69
83
|
if (wire === undefined)
|
|
70
84
|
return false;
|
|
71
|
-
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 });
|
|
72
86
|
return true;
|
|
73
87
|
}
|
|
74
88
|
export function msg(e) {
|
|
75
89
|
return e instanceof Error ? e.message : String(e);
|
|
76
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
|
+
}
|
|
77
94
|
//# sourceMappingURL=send.js.map
|
package/dist/http/server.d.ts
CHANGED
|
@@ -34,12 +34,11 @@ export { cascadeConfig };
|
|
|
34
34
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
35
35
|
export { coarseStatusForState, errorCodeForExit };
|
|
36
36
|
import { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
37
|
-
import { hasServiceAuth } from "./dispatch.js";
|
|
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;
|
|
@@ -209,6 +208,10 @@ export interface ServiceStoreDeps {
|
|
|
209
208
|
* (boot/workflow-orchestration.ts);任一缺席 = 那条车道不存在(workflow 出身的 park 落 legacy 腿,
|
|
210
209
|
* 与本批之前逐字同形)。契约与单写者纪律的属主 = orchestration/workflow-agent-session-index.ts。 */
|
|
211
210
|
workflowAgentSessionIndex?: import("../orchestration/workflow-agent-session-index.js").WorkflowAgentSessionIndex;
|
|
211
|
+
/** workflow 子代停驻卡的耐久决定行(一张卡一行,键 = 子代 checkpoint 的 token):写者 = `/decide` 的 workflow 车道,读者 = 每一只起跑器开跑前的那一只读者。
|
|
212
|
+
* 必须绑在 `runStore` 这一只上(与它同出一个 store backend:`run()` / `workflowParkDecisions()`);park 索引与 run 店都在时必填 ——
|
|
213
|
+
* 起服判官 `parkDecisionStoreRefusal` 判。契约与律的属主 = orchestration/workflow-park-decision.ts。 */
|
|
214
|
+
workflowParkDecisions?: import("../orchestration/workflow-park-decision.js").WorkflowParkDecisionStore;
|
|
212
215
|
/** [ref] journal 读面(PAIR-REVIEW 修车批):GET /v1/workflows/:runId/journal 的数据源——与 runner 侧
|
|
213
216
|
* workflowJournalStore 同一实例(main.ts backend.workflowJournal());缺席=501(与 workflowRunStore 同门)。 */
|
|
214
217
|
workflowJournalStore?: import("@sema-agent/core").WorkflowJournalStore;
|
|
@@ -315,9 +318,7 @@ export interface ServiceCoordinatorDeps {
|
|
|
315
318
|
* LEADER_ENABLED + the leader wiring (e2b workers + git push) is configured. */
|
|
316
319
|
leaderEndpoint?: LeaderEndpoint;
|
|
317
320
|
/** Fire-and-forget session auto-titler (first-submit hook; absent = feature dark). */
|
|
318
|
-
sessionTitler?:
|
|
319
|
-
maybeTitle(sessionId: string, objective: string, model?: string): void;
|
|
320
|
-
};
|
|
321
|
+
sessionTitler?: import("../session-titler.js").SessionTitler;
|
|
321
322
|
}
|
|
322
323
|
/** **函数/构件缝**:main.ts 把跨多个子系统的动作编译成一个可调用面交给路由(路由不该自己
|
|
323
324
|
* 重组零件——见 backend 的同款论证)。parked-revive 三件是同族的构件缝(boot 期从生产装配取的裸
|
|
@@ -567,6 +568,10 @@ export interface ServiceSeamDeps {
|
|
|
567
568
|
* 🔴 缺席 ⇒ `/v1/shared-memory/*` 整域不挂载(诚实缺席);挂载还另要 {@link orgMemoryDirectory}
|
|
568
569
|
* 在场 —— 没有成员性判据的读面只能全放或全拒,两个都比「这个面不存在」差。 */
|
|
569
570
|
sharedMemoryStore?: import("@sema-agent/core").SharedMemoryStoreProvider;
|
|
571
|
+
/** [ref] §10.2 —— 跨主体投递门(`createOrgDeliveryGate` 的产物,`boot/stage-06-runners.ts` 装配的唯一实例)。
|
|
572
|
+
* `POST /v1/principal-inbox/messages` 只经它投递;缺席 = 本部署没声明收件箱消费方(`PRINCIPAL_INBOX_ASSISTANT` 未设)⇒
|
|
573
|
+
* 那一口 501、能力位 `principalInboxDelivery` false(同读事实 `principalInboxDelivery`)。 */
|
|
574
|
+
orgDeliveryGate?: import("@sema-agent/core").OrgDeliveryGate;
|
|
570
575
|
/** WEB-SETUP-RECON 附B — org sessionMirror 治理态的 SERVICE 半场 = **观测面(audit),非执法面**。
|
|
571
576
|
* 裁定 (c):「该镜像而未镜像」发生在数据产生端(壳)——本 server 是镜像**目标**,只看得见到达的 push;
|
|
572
577
|
* 没到达的会话对 server 不存在(无客户端会话清单、无心跳契约),required 锁的真执法只能在壳(CC
|
|
@@ -726,6 +731,9 @@ export interface ServiceDeploymentDeps {
|
|
|
726
731
|
* `buildCenterCredentialHealthView` 铸形,只有闭集词 / 时刻 / 计数,不带路径与令牌)。缺席 / 返回 undefined = 健康或没有中心
|
|
727
732
|
* ⇒ `/health` 形状逐字不变(additive)。 */
|
|
728
733
|
centerCredentialState?: () => import("../center-credential-renewer.js").CenterCredentialHealthView | undefined;
|
|
734
|
+
/** S-667:`/health.centerIdentityNotice` —— 中心凭证换人后的**最近一条**两态通告(`center-config-tier.ts` 铸:`{ code, message, at }`,码闭集两词、句冻结)。取值口交出的
|
|
735
|
+
* 就是 wire 形,`/health` 不另投影;无鉴权面,只有码 / 冻结句 / 时刻。缺席 / 返回 undefined = 从未换过人或没有中心 ⇒ `/health` 形状逐字不变(additive)。 */
|
|
736
|
+
centerIdentityNoticeState?: () => import("../center-config-tier.js").CenterIdentityNotice | undefined;
|
|
729
737
|
/** S-768:模型拒因信号(`/health.modelRefusals`,settings-schema 6.2.0 `ModelRefusalsSignal` 形:名 → 码 + 组拒码)。fleet 心跳读**这同一只**
|
|
730
738
|
* (`boot/stage-10-http-server.ts` → `modelRefusals: () => deployment.modelRefusalsState?.()`)—— 一处铸、两出口。缺席 / 返回 undefined =
|
|
731
739
|
* 没有可报的拒或没有配置管道 ⇒ `/health` 形状逐字不变(additive)。 */
|
|
@@ -777,12 +785,18 @@ export interface ServiceDeploymentDeps {
|
|
|
777
785
|
* `GET /v1/capabilities` 的 `memoryEngine` 位(窄投影)。缺席 = 这个进程不是由 composition root 装
|
|
778
786
|
* 起来的(测试夹具形)⇒ 诊断面报 null、能力位取诚实下限 false。 */
|
|
779
787
|
memoryPosture?: import("../memory-posture.js").MemoryPosture;
|
|
780
|
-
/** S-131:SQL
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
|
|
788
|
+
/** S-131:SQL **引擎读口**(`sql-engine-posture.ts` 的单一推导点 —— boot 期借一条池连接触发驱动的连接初始化,交回本池的驱动:
|
|
789
|
+
* `dialect`(SQL 文本轴,恒在)+ 活的 `facts`(`SET` 之后**回读复核**过的真值;池重连后驱动会重新初始化并刷新,快照会说谎)。
|
|
790
|
+
* 读者:`GET /v1/diagnostics/wiring` 的 `sqlEngine` 段(operator-only,全量含版本与两堵墙)与 `GET /v1/capabilities` 的 `store.sql` 位(窄投影;
|
|
791
|
+
* 7.106.0 前是顶层 `sql`,S-866 ①)读 `facts`;提交受理口的 413 把整只读口交给唯一判官 `sql-driver.ts` `sqlWallsOf`(墙的方言只从这里来(与事实同出一只驱动),不另从店后端读);其中包墙是连接级事实 ——
|
|
792
|
+
* 这里的包墙是最近一次初始化的那条连接的读数,受理口那一腿是同一只规则的提前一跑,终判在将要执行写入的那条连接上(`sql-driver.ts` `connectJudged`;SQL 快照 blob 的店判与 `PUT /sync/blobs` 的 413 来自它)。
|
|
793
|
+
* 两种缺席、两个值:**席缺席** = 本部署没有 SQL 后端(env-only worker、local 文件后端);**`facts` 是 `null`** = 有 SQL 后端、但事实此刻没建立
|
|
794
|
+
* (池上最近一次连接初始化被拒,驱动当场作废了事实)。两者在两个读面上都报缺席(诚实缺席,不铸空壳);墙按方言读后者(MySQL 协议 ⇒ 最保守的假定墙)。
|
|
795
|
+
* 7.132.0 前这一席是 `sqlEngineFacts: () => SqlEngineFacts | null`(只给事实、不给方言);照旧传它 ⇒ `createHttpServer` 起服拒。
|
|
796
|
+
* 🔴 **SQL 后端在场(`backend` 交出了 `mysqlPool()` / `pgPool()`)⇒ 本席必填**,缺席 ⇒ `createHttpServer` 起服拒(席缺席只表示「没有 SQL 后端」,不能是「忘了给」);
|
|
797
|
+
* 本服务自己的装配(`boot/stores.ts` → `stage-10`)按同一个谓词(`sqlPoolsOf`)建立它,恒给。值形也在起服时判(同一只判官 `sqlEngineSeatIssue` 的另一臂):
|
|
798
|
+
* `{ dialect: "tidb" | "pg", facts }`,`facts` 是 `null` 或带 `maxRowBytes` / `maxPacketBytes` / `wallSources` 的引擎事实;只改了键名的 `() => facts` 之类 ⇒ 起服拒。 */
|
|
799
|
+
sqlEngine?: import("../plugins/sql-driver.js").SqlEngineReading;
|
|
786
800
|
/** S-138:**写保护名表**的姿态(`write-protection.ts` 的 boot 期单一推导点 —— 与递给每只 Runner 的
|
|
787
801
|
* `writeProtectedPaths` 座同一份 config 决定)。两个读面共用:`GET /v1/diagnostics/wiring` 的
|
|
788
802
|
* `writeProtection` 段(operator-only,**逐行**表 + 来源 + 被丢的缺省行名)与 `GET /v1/capabilities`
|
|
@@ -820,11 +834,6 @@ export interface ServiceDeploymentDeps {
|
|
|
820
834
|
}
|
|
821
835
|
/** **数值旋钮**:部署可调的上限/拍距。缺省值写在消费点(`?? 256` 之类),此处只承载覆写。 */
|
|
822
836
|
export interface ServiceKnobDeps {
|
|
823
|
-
/** (a)(clay 拍 a+c,2026-07-27)当快照 blob 走 SQL 默认店时(逃生口形/覆写形),该店的 per-blob
|
|
824
|
-
* 承载帽——PUT /sync/blobs 面据此**前置 413**(typed `blob_too_large_for_sql`)。不设=不前置(MinIO
|
|
825
|
-
* 形无帽)。为什么在 HTTP 面重复店里的检查:店的 never-throw 结果形把一切写失败折成 502,而 502
|
|
826
|
-
* 语义=可重试,对端会对一个永远过不去的 blob 无限重试——413 才是「别再送了」的诚实形。 */
|
|
827
|
-
snapshotBlobSqlCapBytes?: number;
|
|
828
837
|
/** [ref] SSE 连接帽(缺省 256/副本;超限 503+Retry-After=消费方回落 /head 轮询)。 */
|
|
829
838
|
sessionEventsMaxConnections?: number;
|
|
830
839
|
/** [ref] SSE 心跳/owner 复核拍距 ms(缺省 25s;测试注入用)。 */
|
|
@@ -852,7 +861,7 @@ export declare function flattenServiceDeps(deps: ServiceDeps): FlatServiceDeps;
|
|
|
852
861
|
/** The TRUSTED end-user principal for an owner-gated / per-tenant request. On a direct-door worker the
|
|
853
862
|
* trusted-header path is OFF (x-agent-principal is client-self-asserted), so identity comes from the crypto-VERIFIED
|
|
854
863
|
* principal JWT (`x-approval-principal-token`, principal-only proof — no cnf.bnd action binding); otherwise the
|
|
855
|
-
* BFF-minted trusted header. undefined when absent/invalid (fail-closed → callers map to 401
|
|
864
|
+
* BFF-minted trusted header. undefined when absent/invalid (fail-closed → callers map to 401, or to the anonymous scope `"_"` on the approval queue faces).
|
|
856
865
|
* 🔴 Use this for ANY endpoint that reads or gates PER-TENANT data — NOT `principalFrom` directly, which trusts
|
|
857
866
|
* the self-asserted header on a direct door (/v1/usage + the trace owner-gate
|
|
858
867
|
* had drifted to a bare principalFrom, unlike the leader/images/approvals identity paths). One source of truth
|
package/dist/http/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
5
|
+
import { describeValueShape } from "@sema-agent/settings-schema";
|
|
6
6
|
import { HttpError } from "../security.js";
|
|
7
7
|
import {} from "../memory-sync.js";
|
|
8
8
|
import {} from "../orchestration/workflow-agent-steer.js";
|
|
@@ -17,18 +17,21 @@ import { cascadeConfig } from "./run-meta.js";
|
|
|
17
17
|
export { cascadeConfig };
|
|
18
18
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
19
19
|
export { coarseStatusForState, errorCodeForExit };
|
|
20
|
-
import { sendError, sendHttpError, sendSessionError,
|
|
20
|
+
import { sendError, sendHttpError, sendSessionError, logRequestError } from "./send.js";
|
|
21
21
|
import { createRequestGuards } from "./request-guards.js";
|
|
22
|
+
import { sqlEngineSeatIssue } from "../sql-engine-posture.js";
|
|
23
|
+
import { parkDecisionStoreRefusal } from "../orchestration/workflow-park-decision.js";
|
|
24
|
+
import { retiredServiceDepsRefusal } from "./retired-service-deps.js";
|
|
22
25
|
import { createAdmission, MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
23
26
|
import { createResumeLegs } from "./resume-legs.js";
|
|
24
27
|
import * as facts from "../capability-facts.js";
|
|
25
|
-
import { createDispatch
|
|
28
|
+
import { createDispatch } from "./dispatch.js";
|
|
26
29
|
import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, isProbePath } from "./route-table.js";
|
|
27
30
|
import { createApprovalSweeps } from "./approval-sweeps.js";
|
|
28
31
|
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
29
32
|
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|
|
30
|
-
import { explicitOperatorOk,
|
|
31
|
-
export { explicitOperatorOk
|
|
33
|
+
import { explicitOperatorOk, hasServiceAuth } from "./principal-gate.js";
|
|
34
|
+
export { explicitOperatorOk };
|
|
32
35
|
class DrainYieldingPreemptBook extends Map {
|
|
33
36
|
drainingNow;
|
|
34
37
|
constructor(drainingNow) {
|
|
@@ -57,6 +60,31 @@ export function createHttpServer(rawDeps) {
|
|
|
57
60
|
if (typeof deps.runnerFor !== "function") {
|
|
58
61
|
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");
|
|
59
62
|
}
|
|
63
|
+
{
|
|
64
|
+
const retired = retiredServiceDepsRefusal(deps);
|
|
65
|
+
if (retired !== undefined)
|
|
66
|
+
throw new Error(retired);
|
|
67
|
+
}
|
|
68
|
+
{
|
|
69
|
+
const issue = sqlEngineSeatIssue(deps.backend, deps.sqlEngine);
|
|
70
|
+
if (issue !== undefined) {
|
|
71
|
+
switch (issue) {
|
|
72
|
+
case "required":
|
|
73
|
+
throw new Error("createHttpServer: sqlEngine is required when a SQL store backend is wired (the backend hands out a SQL pool) — pass the 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; refusing to start rather than read the database's row and statement limits as absent and admit task bodies the database cannot store");
|
|
74
|
+
case "bad_shape":
|
|
75
|
+
throw new Error(`createHttpServer: sqlEngine must be the SQL pool's engine reading \`{ dialect: "tidb" | "pg", facts }\` where \`facts\` is read live (a getter) and is null while the pool's connection setup has not succeeded, otherwise the engine facts object (maxRowBytes, maxPacketBytes and wallSources included) — got ${typeof deps.sqlEngine === "function" ? "a function (the 7.131.x reader \`() => facts\` goes in as \`{ dialect, get facts() { return f(); } }\`)" : describeValueShape(deps.sqlEngine)}; refusing to start rather than answer every task submission with a 500`);
|
|
76
|
+
default: {
|
|
77
|
+
const unhandled = issue;
|
|
78
|
+
throw new Error(`sqlEngine seat issue without a refusal: ${String(unhandled)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
{
|
|
84
|
+
const refusal = parkDecisionStoreRefusal(deps);
|
|
85
|
+
if (refusal !== undefined)
|
|
86
|
+
throw new Error(`createHttpServer: ${refusal}`);
|
|
87
|
+
}
|
|
60
88
|
const idemCache = new IdempotencyCache();
|
|
61
89
|
const inflightRuns = new Map();
|
|
62
90
|
const preemptableRuns = new DrainYieldingPreemptBook(() => deps.drainState?.draining === true);
|
|
@@ -126,7 +154,7 @@ export function createHttpServer(rawDeps) {
|
|
|
126
154
|
res.end();
|
|
127
155
|
return;
|
|
128
156
|
}
|
|
129
|
-
deps.logger
|
|
157
|
+
logRequestError(deps.logger, req, err);
|
|
130
158
|
if (res.headersSent) {
|
|
131
159
|
res.end();
|
|
132
160
|
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));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RunStore } from "../plugins/store-backend.js";
|
|
2
|
+
import type { Logger } from "../observability/logger.js";
|
|
3
|
+
import type { Metrics } from "../observability/metrics.js";
|
|
4
|
+
import { buildCheckpointCtx } from "./checkpoint-ctx.js";
|
|
5
|
+
import { type RefusalBody } from "./refusal-body.js";
|
|
6
|
+
/** 写不进的那一种可答复的结局(各腿把它交回自己的出口:同步 / durable 腿直接回,活流腿编码成终帧)。 */
|
|
7
|
+
export interface SubmitCtxRefusal {
|
|
8
|
+
readonly status: 413;
|
|
9
|
+
readonly body: RefusalBody;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 写这一笔(行体经续跑输入的唯一构造口 `buildCheckpointCtx` 铸 —— 新的持久化写都经它,读法记号随之盖上);写不进 ⇒ 撤掉
|
|
13
|
+
* `claim` 指的那条刚认领的 run(无 run 店的部署没有认领 ⇒ `undefined`),再按成因答复(见文件头)。
|
|
14
|
+
* 返回 `undefined` = 写进了,腿照常起跑。
|
|
15
|
+
*/
|
|
16
|
+
export declare function persistSubmitCtx(store: {
|
|
17
|
+
putCtx(sessionId: string, ctx: object): Promise<void>;
|
|
18
|
+
}, deps: {
|
|
19
|
+
readonly logger?: Logger | undefined;
|
|
20
|
+
readonly metrics?: Metrics | undefined;
|
|
21
|
+
}, claim: {
|
|
22
|
+
readonly runStore: RunStore;
|
|
23
|
+
readonly taskId: string;
|
|
24
|
+
} | undefined, sessionId: string, fields: Parameters<typeof buildCheckpointCtx>[0]): Promise<SubmitCtxRefusal | undefined>;
|
|
25
|
+
//# sourceMappingURL=submit-ctx.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StoreRowTooLargeError } from "../plugins/sql-errors.js";
|
|
2
|
+
import { releaseClaimedRun } from "./claimed-run.js";
|
|
3
|
+
import { buildCheckpointCtx } from "./checkpoint-ctx.js";
|
|
4
|
+
import { refusalBody } from "./refusal-body.js";
|
|
5
|
+
import { limitFactsUnmeasured } from "../limit-refusal.js";
|
|
6
|
+
function rowTooLargeRefusal(tooLarge) {
|
|
7
|
+
switch (tooLarge.wall) {
|
|
8
|
+
case "row":
|
|
9
|
+
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") }) };
|
|
10
|
+
case "statement":
|
|
11
|
+
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") }) };
|
|
12
|
+
case "value":
|
|
13
|
+
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") }) };
|
|
14
|
+
default: {
|
|
15
|
+
const unhandled = tooLarge.wall;
|
|
16
|
+
throw new Error(`row-too-large refusal without an HTTP answer: ${String(unhandled)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function persistSubmitCtx(store, deps, claim, sessionId, fields) {
|
|
21
|
+
try {
|
|
22
|
+
await store.putCtx(sessionId, buildCheckpointCtx(fields));
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const tooLarge = err instanceof StoreRowTooLargeError ? err : undefined;
|
|
27
|
+
if (claim !== undefined) {
|
|
28
|
+
const why = tooLarge !== undefined ? tooLarge.message : `the run's resume inputs could not be stored: ${err instanceof Error ? err.message : String(err)}`;
|
|
29
|
+
await releaseClaimedRun(claim.runStore, claim.taskId, why, (releaseErr, step) => {
|
|
30
|
+
deps.logger?.warn("submit_ctx_run_release_failed", { taskId: claim.taskId, sessionId, step, err: releaseErr instanceof Error ? releaseErr.message : String(releaseErr) });
|
|
31
|
+
deps.metrics?.inc("submit_ctx_run_release_failed_total", { step });
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (tooLarge === undefined)
|
|
35
|
+
throw err;
|
|
36
|
+
deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall, db: tooLarge.dbMessage });
|
|
37
|
+
return rowTooLargeRefusal(tooLarge);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=submit-ctx.js.map
|
|
@@ -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;
|
|
@@ -322,7 +323,7 @@ export interface TaskRequestBody {
|
|
|
322
323
|
* `mcp__srv` / `mcp__srv__*` / 工具段通配;`"*"` = 本层不设名单;`[]` = 什么都不给)。宿主**原样透传**进 `TaskSpec.allowTools`:
|
|
323
324
|
* 不算补集、不过滤、不与 `settings.permissions.allow`(免问)混词;真未知名(拼写合法、没有近似也没有退役对应:懒挂载的合法形)照跑(原样保留,今天什么都不准,之后挂上同名工具即生效;引擎告知运维一次),
|
|
324
325
|
* 任何工具名都不可能有的拼法由引擎开跑前拒(`config.tool_face_control`,同步腿 400);7.131.0 起受理口另拒近似名(大小写孪生 `BASH`:想放的什么也没放 = 静默收窄,句子点名现名);
|
|
325
|
-
*
|
|
326
|
+
* 放行侧的内容形(`Agent(Explore)`)、文法读不出与没有后继的退役名(`MultiEdit`)照旧受理、交引擎既有通告;有后继的退役名(`bash` · `Task`)引擎开跑前拒 `config.tool_face_control`(core 7.52.0 起,同步腿 400)。
|
|
326
327
|
* `excludeTools` 是同一只运算的减项(deny 赢)。值形:字符串数组(受理门 400 `request.field_invalid`,与 `excludeTools` 同一只门);
|
|
327
328
|
* 装着的引擎不认该座 ⇒ 400 `request.field_invalid` 点名所需引擎版本(不静默丢)。无租户门(收窄)。 */
|
|
328
329
|
allowTools?: 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).
|
|
@@ -610,5 +611,7 @@ export type SyncSubmitBody = ReturnType<typeof buildSyncSubmitBody>;
|
|
|
610
611
|
export interface SyncSubmitExtraKeys {
|
|
611
612
|
notice?: string;
|
|
612
613
|
wiringManifest?: WiringManifestReceipt;
|
|
614
|
+
/** 受理告知(`entry-problems.ts` 的条目形):放行侧选择器清单里什么也不放的条目,**present-iff** 有话说;流式腿的同名键在 `meta` 帧、异步腿的在 202 回执。 */
|
|
615
|
+
warnings?: readonly EntryProblem[];
|
|
613
616
|
}
|
|
614
617
|
//# sourceMappingURL=wire-types.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { composeExecutionLane, assertExecutionLaneInvariants, type ExecutionLane
|
|
|
3
3
|
export { createBrain } from "./brain.js";
|
|
4
4
|
export { createSessionStore } from "./plugins/session-store.js";
|
|
5
5
|
export { createStoreBackend, type StoreBackend, type SessionCaptureRecordSource } from "./plugins/store-backend.js";
|
|
6
|
-
export { RetiredSchemaPresentError } from "./plugins/
|
|
6
|
+
export { RetiredSchemaPresentError } from "./plugins/schema-consistency.js";
|
|
7
7
|
export { CachingSessionStore, type CachingOptions } from "./plugins/caching-session-store.js";
|
|
8
8
|
export type { RunRecord, RunEvent } from "./plugins/store-contracts.js";
|
|
9
9
|
export { runInBackground } from "./runs.js";
|
|
@@ -28,8 +28,8 @@ export { createSideQueryLane, type KeyResolver, type SideQueryLane, type SideQue
|
|
|
28
28
|
export { createKeyResolver, resolveModelApiKey, type ModelKeyRef } from "./key-resolver.js";
|
|
29
29
|
export { isModelKeyPoison, ModelKeyPoisonedError, type ModelKeyPoison, type ModelKeyPoisonReason } from "./key-resolver.js";
|
|
30
30
|
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
31
|
export type { ModelRouteGap } from "./model-route-endpoint.js";
|
|
33
32
|
export { judgeServedModelRoute, type ServedModelRouteView, type ServedModelRouteOptions, type ModelRouteEndpointVerdict } from "./model-route-endpoint.js";
|
|
34
33
|
export type { UserInputLedgerStore, UserInputAcceptance, NewUserInputAcceptance, OpenScanCursor, OpenScanPage, SettleHow, WriterGoneEvidence } from "./user-input-ledger.js";
|
|
34
|
+
export type { OrgDeliveryQuotaStore, OrgDeliveryQuotaPolicy } from "./plugins/org-delivery-quota-store.js";
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { composeExecutionLane, assertExecutionLaneInvariants } from "./boot/exec
|
|
|
3
3
|
export { createBrain } from "./brain.js";
|
|
4
4
|
export { createSessionStore } from "./plugins/session-store.js";
|
|
5
5
|
export { createStoreBackend } from "./plugins/store-backend.js";
|
|
6
|
-
export { RetiredSchemaPresentError } from "./plugins/
|
|
6
|
+
export { RetiredSchemaPresentError } from "./plugins/schema-consistency.js";
|
|
7
7
|
export { CachingSessionStore } from "./plugins/caching-session-store.js";
|
|
8
8
|
export { runInBackground } from "./runs.js";
|
|
9
9
|
export { createHardenedVmRunner, runInHardenedVm } from "./orchestration/hardened-vm-runner.js";
|
|
@@ -25,6 +25,5 @@ export { createSideQueryLane } from "./boot/side-query-lane.js";
|
|
|
25
25
|
export { createKeyResolver, resolveModelApiKey } from "./key-resolver.js";
|
|
26
26
|
export { isModelKeyPoison, ModelKeyPoisonedError } from "./key-resolver.js";
|
|
27
27
|
export { CATALOG_ENTRY_HEADER_LANES, CATALOG_ENTRY_HEADER_NAMES } from "./model-entry-headers.js";
|
|
28
|
-
export { judgeModelRouteGap } from "./model-route-gap.js";
|
|
29
28
|
export { judgeServedModelRoute } from "./model-route-endpoint.js";
|
|
30
29
|
//# sourceMappingURL=index.js.map
|