@sema-agent/server 7.149.0 → 7.151.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 +307 -9
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +92 -40
- package/deploy/sema-up/README.md +7 -1
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
- package/deploy/sema-up/chart/templates/server.yaml +5 -3
- package/deploy/sema-up/chart/values-full-single.yaml +3 -1
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +1 -0
- package/deploy/sema-up/kube-up.sh +1 -1
- package/deploy/sema-up/lib/flagshape.sh +1 -1
- package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
- package/deploy/sema-up/lib/helm-values-kube.py +2 -0
- package/dist/adoption/import.js +3 -3
- package/dist/approval-ask-machine.d.ts +1 -1
- package/dist/approval-card.d.ts +3 -3
- package/dist/approval-gate-currency.d.ts +2 -2
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +2 -2
- package/dist/auth-bridge.d.ts +20 -0
- package/dist/auth-bridge.js +9 -0
- package/dist/background-session-reap.d.ts +2 -2
- package/dist/bake-runner/main.d.ts +4 -2
- package/dist/bind-host.d.ts +2 -3
- package/dist/bind-host.js +2 -4
- package/dist/boot/budget-tracing.js +1 -1
- package/dist/boot/deferred-sandbox-path-env.d.ts +5 -3
- package/dist/boot/deferred-sandbox-path-env.js +1 -2
- package/dist/boot/engine-lease.d.ts +5 -0
- package/dist/boot/engine-lease.js +1 -0
- package/dist/boot/execution-env.d.ts +8 -14
- package/dist/boot/execution-env.js +54 -17
- package/dist/boot/execution-lane.js +32 -5
- package/dist/boot/late-binds.d.ts +8 -4
- package/dist/boot/late-binds.js +7 -1
- package/dist/boot/memory-consolidation.d.ts +3 -2
- package/dist/boot/memory-consolidation.js +6 -6
- package/dist/boot/parked-revive-gate.d.ts +5 -5
- package/dist/boot/parked-revive-gate.js +2 -3
- package/dist/boot/reapers.d.ts +5 -0
- package/dist/boot/reapers.js +12 -1
- package/dist/boot/resolve-spec.d.ts +7 -8
- package/dist/boot/resolve-spec.js +80 -35
- package/dist/boot/retention-lane.d.ts +1 -1
- package/dist/boot/runner-deps.d.ts +9 -2
- package/dist/boot/runner-deps.js +3 -3
- package/dist/boot/session-age-out.d.ts +36 -0
- package/dist/boot/session-age-out.js +101 -0
- package/dist/boot/session-faces.d.ts +5 -14
- package/dist/boot/session-faces.js +28 -24
- package/dist/boot/stage-01-config.js +2 -0
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +5 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +7 -4
- package/dist/boot/stage-06-runners.js +16 -8
- package/dist/boot/stage-07-capability-layer.d.ts +7 -4
- package/dist/boot/stage-07-capability-layer.js +3 -2
- package/dist/boot/stage-08-reapers.d.ts +7 -4
- package/dist/boot/stage-08-reapers.js +4 -2
- package/dist/boot/stage-09-leader.d.ts +11 -5
- package/dist/boot/stage-09-leader.js +12 -3
- package/dist/boot/stage-10-http-server.d.ts +44 -6
- package/dist/boot/stage-10-http-server.js +12 -10
- package/dist/boot/web-admin.d.ts +1 -1
- package/dist/boot/web-admin.js +3 -1
- package/dist/boot/workflow-orchestration.d.ts +7 -2
- package/dist/boot/workflow-orchestration.js +24 -7
- package/dist/bounded-rotation.d.ts +29 -0
- package/dist/bounded-rotation.js +24 -0
- package/dist/capability-facts.d.ts +84 -66
- package/dist/capability-facts.js +58 -41
- package/dist/center-credential.d.ts +25 -6
- package/dist/center-credential.js +25 -5
- package/dist/config-catalog.d.ts +26 -7
- package/dist/config-catalog.js +15 -12
- package/dist/config-invariants.d.ts +2 -1
- package/dist/config-invariants.js +4 -4
- package/dist/config-types.d.ts +22 -15
- package/dist/config.d.ts +51 -2
- package/dist/config.js +35 -24
- package/dist/deployment-governance.d.ts +7 -28
- package/dist/deployment-governance.js +1 -14
- package/dist/deployment-shape.d.ts +9 -1
- package/dist/deployment-shape.js +2 -1
- package/dist/device-protocol.d.ts +5 -4
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.d.ts +1 -0
- package/dist/device-ws-hub.js +66 -29
- package/dist/device-ws-protocol.d.ts +79 -12
- package/dist/device-ws-protocol.js +64 -26
- package/dist/engine-identity.d.ts +23 -5
- package/dist/engine-identity.js +13 -0
- package/dist/entry-mode-clamp-notice.d.ts +2 -1
- package/dist/execution-env-refusal.d.ts +23 -0
- package/dist/execution-env-refusal.js +5 -0
- package/dist/execution-lane-caps.d.ts +3 -1
- package/dist/field-conflict.d.ts +3 -3
- package/dist/file-history-capture.d.ts +11 -4
- package/dist/file-history-capture.js +9 -6
- package/dist/file-history-disclosure.d.ts +7 -5
- package/dist/file-history-disclosure.js +7 -5
- package/dist/fleet/drain-entry.d.ts +4 -0
- package/dist/fleet/engine-signal.d.ts +14 -1
- package/dist/fleet/engine-signal.js +5 -1
- package/dist/fleet/fleet-reconciler.d.ts +1 -1
- package/dist/fleet/serving-lease.d.ts +18 -3
- package/dist/fleet/serving-lease.js +81 -35
- package/dist/fleet-client.d.ts +13 -11
- package/dist/fleet-client.js +53 -33
- package/dist/history-anchor.js +1 -1
- package/dist/hitl-delivery.d.ts +1 -3
- package/dist/hitl-delivery.js +1 -1
- package/dist/hooks/hook-runner.js +2 -2
- package/dist/host-lsp-manager.d.ts +2 -2
- package/dist/http/active-run-conflict.d.ts +3 -7
- package/dist/http/active-run-conflict.js +2 -2
- package/dist/http/admission.js +19 -4
- package/dist/http/approval-sweeps.js +7 -6
- package/dist/http/caller-trust.d.ts +2 -2
- package/dist/http/caller-trust.js +3 -3
- package/dist/http/checkpoint-ctx.d.ts +20 -63
- package/dist/http/checkpoint-ctx.js +2 -24
- package/dist/http/claim-heartbeat.d.ts +4 -4
- package/dist/http/claim-heartbeat.js +3 -3
- package/dist/http/dispatch.d.ts +2 -1
- package/dist/http/dispatch.js +36 -29
- package/dist/http/durable-run-leg.js +17 -17
- package/dist/http/health-self-report.d.ts +9 -1
- package/dist/http/health-self-report.js +2 -0
- package/dist/http/owner-access.d.ts +264 -20
- package/dist/http/owner-access.js +215 -5
- package/dist/http/readiness.d.ts +4 -2
- package/dist/http/resume-ctx-read.js +38 -1
- package/dist/http/resume-legs.d.ts +2 -1
- package/dist/http/resume-legs.js +273 -89
- package/dist/http/route-ctx.d.ts +41 -19
- package/dist/http/route-table.d.ts +1 -1
- package/dist/http/routes/a2a-serve.js +15 -14
- package/dist/http/routes/admin-memory-optout.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +3 -2
- package/dist/http/routes/approvals-assistant.js +12 -12
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/capabilities.js +10 -6
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/fleet.js +10 -8
- package/dist/http/routes/mcp-reconnect.js +2 -2
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -3
- package/dist/http/routes/projects.d.ts +4 -2
- package/dist/http/routes/projects.js +7 -6
- package/dist/http/routes/retention-ops.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.d.ts +1 -1
- package/dist/http/routes/run-permission-mode.js +2 -2
- package/dist/http/routes/runs.d.ts +1 -1
- package/dist/http/routes/runs.js +125 -66
- package/dist/http/routes/session-memory-sync.js +4 -5
- package/dist/http/routes/session-sync.d.ts +4 -3
- package/dist/http/routes/session-sync.js +174 -83
- package/dist/http/routes/sessions-list.js +13 -7
- package/dist/http/routes/sessions.d.ts +1 -1
- package/dist/http/routes/sessions.js +26 -48
- package/dist/http/routes/tasks.js +38 -23
- package/dist/http/routes/trace-usage.js +14 -14
- package/dist/http/routes/workflows.d.ts +1 -0
- package/dist/http/routes/workflows.js +20 -38
- package/dist/http/server.d.ts +28 -30
- package/dist/http/server.js +7 -3
- package/dist/http/stored-body-replay.d.ts +3 -24
- package/dist/http/stored-body-replay.js +2 -12
- package/dist/http/submit-ctx.d.ts +1 -2
- package/dist/http/submit-ctx.js +8 -6
- package/dist/http/submit-replay.d.ts +15 -2
- package/dist/http/submit-replay.js +10 -4
- package/dist/http/wire-types.d.ts +19 -6
- package/dist/identity-source.d.ts +20 -3
- package/dist/identity-source.js +14 -0
- package/dist/index.d.ts +4 -0
- package/dist/lane-home-probe.d.ts +3 -7
- package/dist/lane-home-probe.js +0 -1
- package/dist/leader/endpoint.js +9 -8
- package/dist/leader/leader.d.ts +2 -1
- package/dist/leg-facts.d.ts +19 -5
- package/dist/leg-facts.js +3 -1
- package/dist/mcp-authorization-face.d.ts +18 -14
- package/dist/mcp-authorization-face.js +3 -2
- package/dist/memory-scope.d.ts +5 -4
- package/dist/memory-scope.js +4 -4
- package/dist/memory-store-refusal.d.ts +1 -1
- package/dist/memory-sync-client.d.ts +30 -2
- package/dist/memory-sync-client.js +16 -9
- package/dist/observability/corrupt-read-seat.d.ts +1 -1
- package/dist/observability/err-text.d.ts +7 -0
- package/dist/observability/err-text.js +5 -0
- package/dist/observability/fail-open.d.ts +12 -8
- package/dist/observability/fail-open.js +12 -8
- package/dist/observability/logger.d.ts +7 -0
- package/dist/observability/logger.js +3 -1
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/run-terminal.d.ts +1 -1
- package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
- package/dist/orchestration/workflow-notify-journal.js +12 -1
- package/dist/orchestration/workflow-park-decision.d.ts +70 -18
- package/dist/orchestration/workflow-park-decision.js +49 -10
- package/dist/orchestration/workflow-park-holder.d.ts +65 -0
- package/dist/orchestration/workflow-park-holder.js +98 -0
- package/dist/orchestration/workflow-record-fence.d.ts +36 -0
- package/dist/orchestration/workflow-record-fence.js +42 -0
- package/dist/owner-faces.d.ts +28 -4
- package/dist/owner-faces.js +2 -0
- package/dist/parked-decide.d.ts +104 -53
- package/dist/parked-decide.js +153 -117
- package/dist/peer-directory.d.ts +2 -2
- package/dist/peer-inbound-face.d.ts +2 -6
- package/dist/peer-inbound-face.js +0 -3
- package/dist/peer-seat.d.ts +1 -1
- package/dist/peer-seat.js +52 -59
- package/dist/permission-mode-admission.d.ts +41 -5
- package/dist/permission-mode-admission.js +29 -3
- package/dist/plugins/adoption-log-sql.d.ts +3 -1
- package/dist/plugins/adoption-log-sql.js +7 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +8 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +6 -1
- package/dist/plugins/approval-ask-store-memory.js +28 -9
- package/dist/plugins/approval-ask-store-sql.d.ts +43 -2
- package/dist/plugins/approval-ask-store-sql.js +34 -5
- package/dist/plugins/approval-exemption-store.js +3 -0
- package/dist/plugins/approval-nonce-store.js +2 -0
- package/dist/plugins/breaker-state-sql.js +2 -0
- package/dist/plugins/caching-session-store.d.ts +9 -15
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/device-store-sql.js +6 -0
- package/dist/plugins/error-origin.d.ts +18 -0
- package/dist/plugins/error-origin.js +10 -0
- package/dist/plugins/exec-path-law.d.ts +34 -0
- package/dist/plugins/exec-path-law.js +13 -0
- package/dist/plugins/execution-placement-sql.js +6 -6
- package/dist/plugins/file-run-store.js +1 -1
- package/dist/plugins/image-bake-store-sql.js +6 -0
- package/dist/plugins/image-index-sql.js +4 -0
- package/dist/plugins/landed-attendants.d.ts +212 -0
- package/dist/plugins/landed-attendants.js +161 -0
- package/dist/plugins/leader-run-store-sql.js +4 -0
- package/dist/plugins/local-checkpoint-store.d.ts +4 -1
- package/dist/plugins/local-checkpoint-store.js +3 -0
- package/dist/plugins/local-session-live-reference.d.ts +40 -0
- package/dist/plugins/local-session-live-reference.js +39 -0
- package/dist/plugins/local-session-store.d.ts +71 -33
- package/dist/plugins/local-session-store.js +129 -27
- package/dist/plugins/memory-engine-pg.js +4 -0
- package/dist/plugins/memory-engine-sql-apply.js +5 -2
- package/dist/plugins/memory-engine-tidb.js +4 -0
- package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
- package/dist/plugins/memory-run-store.js +1 -1
- package/dist/plugins/memory-sync-store-pg.js +5 -0
- package/dist/plugins/memory-sync-store-tidb.js +5 -0
- package/dist/plugins/one-time-migrations.d.ts +80 -61
- package/dist/plugins/one-time-migrations.js +241 -104
- package/dist/plugins/org-delivery-quota-store.js +4 -1
- package/dist/plugins/outcome-ledger-sql.js +2 -0
- package/dist/plugins/permission-rule-store-sql.js +11 -4
- package/dist/plugins/pg-cost-quota.js +4 -0
- package/dist/plugins/pg-pool.js +28 -1
- package/dist/plugins/pg-rate-limiter.js +2 -0
- package/dist/plugins/posix-shell-fs.d.ts +6 -1
- package/dist/plugins/posix-shell-fs.js +8 -3
- package/dist/plugins/remote-env-adb.d.ts +19 -15
- package/dist/plugins/remote-env-adb.js +44 -17
- package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
- package/dist/plugins/remote-env-connect-seat.js +72 -0
- package/dist/plugins/remote-env-device.d.ts +22 -5
- package/dist/plugins/remote-env-device.js +114 -14
- package/dist/plugins/remote-env-e2b.d.ts +18 -7
- package/dist/plugins/remote-env-e2b.js +53 -40
- package/dist/plugins/remote-env-file-error.js +6 -2
- package/dist/plugins/remote-env-host.d.ts +18 -1
- package/dist/plugins/remote-env-host.js +48 -47
- package/dist/plugins/remote-env-k8s.d.ts +41 -39
- package/dist/plugins/remote-env-k8s.js +56 -32
- package/dist/plugins/remote-env-local-docker.d.ts +13 -8
- package/dist/plugins/remote-env-local-docker.js +37 -43
- package/dist/plugins/remote-env-ssh.d.ts +18 -12
- package/dist/plugins/remote-env-ssh.js +64 -62
- package/dist/plugins/remote-shell.d.ts +101 -2
- package/dist/plugins/remote-shell.js +221 -3
- package/dist/plugins/replica-registration.d.ts +35 -0
- package/dist/plugins/replica-registration.js +48 -0
- package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
- package/dist/plugins/resume-anchor-store-sql.js +12 -5
- package/dist/plugins/retention-lane-store-sql.d.ts +1 -1
- package/dist/plugins/retention-lane-store-sql.js +4 -0
- package/dist/plugins/retention-sql.d.ts +20 -2
- package/dist/plugins/retention-sql.js +11 -0
- package/dist/plugins/run-store-sql.d.ts +22 -3
- package/dist/plugins/run-store-sql.js +33 -9
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +6 -12
- package/dist/plugins/scenario-prefix-switch-m42.js +7 -5
- package/dist/plugins/schema-consistency.d.ts +9 -5
- package/dist/plugins/schema-consistency.js +48 -18
- package/dist/plugins/schema-drift-sentence.js +1 -1
- package/dist/plugins/send-file-ledger.js +3 -0
- package/dist/plugins/serving-requirement.d.ts +68 -0
- package/dist/plugins/serving-requirement.js +60 -0
- package/dist/plugins/session-birth.d.ts +6 -2
- package/dist/plugins/session-capture-record-store-sql.js +2 -0
- package/dist/plugins/session-ext-table.d.ts +14 -1
- package/dist/plugins/session-ext-table.js +5 -1
- package/dist/plugins/session-row-sql.d.ts +49 -2
- package/dist/plugins/session-row-sql.js +56 -13
- package/dist/plugins/session-store-sql.d.ts +34 -18
- package/dist/plugins/session-store-sql.js +98 -17
- package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
- package/dist/plugins/shared-memory-store-sql.js +6 -2
- package/dist/plugins/sql-driver.d.ts +2 -1
- package/dist/plugins/sql-driver.js +18 -3
- package/dist/plugins/sql-errors.d.ts +11 -6
- package/dist/plugins/sql-errors.js +5 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +48 -3
- package/dist/plugins/stop-then-start-sentence.js +48 -0
- package/dist/plugins/stop-then-start.d.ts +109 -0
- package/dist/plugins/stop-then-start.js +104 -0
- package/dist/plugins/store-backend.d.ts +40 -13
- package/dist/plugins/store-backend.js +169 -27
- package/dist/plugins/store-boundary.d.ts +57 -0
- package/dist/plugins/store-boundary.js +139 -0
- package/dist/plugins/store-contracts.d.ts +29 -2
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
- package/dist/plugins/store-fault-sentence-m53.js +25 -0
- package/dist/plugins/store-fault.d.ts +26 -7
- package/dist/plugins/store-fault.js +18 -2
- package/dist/plugins/task-attachment-store.js +9 -0
- package/dist/plugins/task-list-store-sql.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.js +10 -8
- package/dist/plugins/tidb-cost-quota.js +4 -0
- package/dist/plugins/tidb-pool.js +6 -1
- package/dist/plugins/tidb-rate-limiter.js +4 -0
- package/dist/plugins/user-input-ledger-sql.js +4 -0
- package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
- package/dist/plugins/workflow-run-store-sql.js +64 -4
- package/dist/plugins/workspace-fill.d.ts +4 -7
- package/dist/plugins/workspace-fill.js +2 -1
- package/dist/plugins/write-behind-counter.js +5 -0
- package/dist/process-instance.d.ts +3 -0
- package/dist/process-instance.js +7 -0
- package/dist/project-context.d.ts +64 -0
- package/dist/project-context.js +66 -0
- package/dist/project-registry.d.ts +46 -0
- package/dist/project-registry.js +44 -0
- package/dist/question.d.ts +9 -21
- package/dist/question.js +28 -19
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +4 -0
- package/dist/request-value-closure.js +10 -0
- package/dist/run-acceptance.d.ts +3 -2
- package/dist/run-acceptance.js +4 -6
- package/dist/run-cancel-card.d.ts +1 -1
- package/dist/run-cancel-card.js +2 -1
- package/dist/run-local.js +1 -0
- package/dist/runs.d.ts +37 -8
- package/dist/runs.js +53 -12
- package/dist/runtime-governance.d.ts +5 -4
- package/dist/security.d.ts +31 -33
- package/dist/security.js +41 -7
- package/dist/server-secret-env.d.ts +12 -10
- package/dist/server-secret-env.js +24 -15
- package/dist/session-agent.d.ts +1 -10
- package/dist/session-agent.js +0 -6
- package/dist/session-bindings.d.ts +82 -0
- package/dist/session-bindings.js +18 -0
- package/dist/session-children-retire.d.ts +2 -2
- package/dist/session-children-retire.js +2 -6
- package/dist/session-deletion.d.ts +16 -1
- package/dist/session-error-wire.d.ts +3 -3
- package/dist/session-error-wire.js +3 -3
- package/dist/session-incarnation.d.ts +28 -4
- package/dist/session-incarnation.js +14 -2
- package/dist/session-kind.d.ts +57 -0
- package/dist/session-kind.js +22 -0
- package/dist/session-notify-door.d.ts +4 -4
- package/dist/session-notify-door.js +5 -6
- package/dist/session-row.d.ts +21 -1
- package/dist/session-row.js +7 -1
- package/dist/session-rules-seat.d.ts +4 -3
- package/dist/session-rules-seat.js +3 -11
- package/dist/session-sync-kernel.d.ts +24 -14
- package/dist/session-sync-kernel.js +3 -6
- package/dist/session-sync.d.ts +4 -98
- package/dist/session-sync.js +4 -74
- package/dist/session-titler.d.ts +10 -3
- package/dist/session-titler.js +19 -6
- package/dist/ssh-host-key.d.ts +5 -0
- package/dist/ssh-host-key.js +3 -0
- package/dist/stores-sql/checkpoint-store-sql.d.ts +21 -2
- package/dist/stores-sql/checkpoint-store-sql.js +106 -18
- package/dist/stores-sql/file-history-store-sql.d.ts +52 -2
- package/dist/stores-sql/file-history-store-sql.js +108 -70
- package/dist/stores-sql/pg-session-storage.d.ts +34 -7
- package/dist/stores-sql/pg-session-storage.js +37 -13
- package/dist/stores-sql/retention-store-sql.d.ts +2 -10
- package/dist/stores-sql/retention-store-sql.js +2 -10
- package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
- package/dist/stores-sql/session-policy-store-sql.js +61 -44
- package/dist/stores-sql/session-write-hooks.d.ts +11 -0
- package/dist/stores-sql/tidb-session-store.d.ts +58 -7
- package/dist/stores-sql/tidb-session-store.js +37 -13
- package/dist/submission-exit.d.ts +3 -2
- package/dist/submission-exit.js +9 -1
- package/dist/task-cwd.d.ts +6 -5
- package/dist/task-settings.d.ts +19 -5
- package/dist/task-settings.js +13 -7
- package/dist/terminal.d.ts +33 -2
- package/dist/terminal.js +139 -9
- package/dist/tool-approval.d.ts +147 -12
- package/dist/tool-approval.js +206 -109
- package/dist/trace/engine-notice-wire.d.ts +14 -0
- package/dist/trace/engine-notice-wire.js +18 -1
- package/dist/trace/project.d.ts +4 -3
- package/dist/trace/project.js +3 -2
- package/dist/trace/projection-table.d.ts +33 -2
- package/dist/trace/self-minted-wire.d.ts +422 -26
- package/dist/trace/self-minted-wire.js +149 -23
- package/dist/trace/tool-card.d.ts +3 -0
- package/dist/trace/tool-card.js +24 -0
- package/dist/trace/tool-output-media.d.ts +2 -1
- package/dist/unattended-permission-mode.d.ts +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/skills-mcp.d.ts +1 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +120 -41
- package/package.json +3 -3
- package/wire-changes/server@7.150.0.json +335 -0
- package/wire-changes/server@7.151.0.json +762 -0
- package/dist/http/session-inherit-env.d.ts +0 -36
- package/dist/http/session-inherit-env.js +0 -6
package/dist/parked-decide.js
CHANGED
|
@@ -30,36 +30,39 @@ export async function findParkOrigin(sources, cp) {
|
|
|
30
30
|
if (index === undefined || runStore === undefined)
|
|
31
31
|
return undefined;
|
|
32
32
|
try {
|
|
33
|
-
|
|
34
|
-
if (pointers.length === 0)
|
|
35
|
-
return undefined;
|
|
36
|
-
const runs = [];
|
|
37
|
-
for (const runId of new Set(pointers.map((p) => p.runId))) {
|
|
38
|
-
const run = await runStore.get(runId);
|
|
39
|
-
if (run !== null)
|
|
40
|
-
runs.push(run);
|
|
41
|
-
}
|
|
42
|
-
const route = routeWorkflowPark(cp.sessionId, runs);
|
|
43
|
-
switch (route.kind) {
|
|
44
|
-
case "held":
|
|
45
|
-
return route.park.token === cp.token ? { kind: "workflow", runId: route.runId, run: route.run, park: route.park } : undefined;
|
|
46
|
-
case "forked":
|
|
47
|
-
return { kind: "workflow_park_forked", runIds: route.runIds };
|
|
48
|
-
case "unproven":
|
|
49
|
-
return { kind: "workflow_parks_unreadable", runId: route.runId, run: route.run, ...(route.readableHolderRunId !== undefined ? { readableHolderRunId: route.readableHolderRunId } : {}) };
|
|
50
|
-
case "none":
|
|
51
|
-
return undefined;
|
|
52
|
-
default: {
|
|
53
|
-
const unhandled = route;
|
|
54
|
-
throw new Error(`unhandled workflow park route: ${JSON.stringify(unhandled)}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
33
|
+
return await routeWorkflowOrigin(index, runStore, cp);
|
|
57
34
|
}
|
|
58
35
|
catch (e) {
|
|
59
36
|
quiet(sources.warn, "workflow_park_probe_failed", { error: e instanceof Error ? e.message : String(e) });
|
|
60
37
|
return undefined;
|
|
61
38
|
}
|
|
62
39
|
}
|
|
40
|
+
async function routeWorkflowOrigin(index, runStore, cp) {
|
|
41
|
+
const pointers = await index.listByAgentSession(cp.sessionId);
|
|
42
|
+
if (pointers.length === 0)
|
|
43
|
+
return undefined;
|
|
44
|
+
const runs = [];
|
|
45
|
+
for (const runId of new Set(pointers.map((p) => p.runId))) {
|
|
46
|
+
const run = await runStore.get(runId);
|
|
47
|
+
if (run !== null)
|
|
48
|
+
runs.push(run);
|
|
49
|
+
}
|
|
50
|
+
const route = routeWorkflowPark(cp.sessionId, runs);
|
|
51
|
+
switch (route.kind) {
|
|
52
|
+
case "held":
|
|
53
|
+
return route.park.token === cp.token ? { kind: "workflow", runId: route.runId, run: route.run, park: route.park } : undefined;
|
|
54
|
+
case "forked":
|
|
55
|
+
return { kind: "workflow_park_forked", runIds: route.runIds };
|
|
56
|
+
case "unproven":
|
|
57
|
+
return { kind: "workflow_parks_unreadable", runId: route.runId, run: route.run, ...(route.readableHolderRunId !== undefined ? { readableHolderRunId: route.readableHolderRunId } : {}) };
|
|
58
|
+
case "none":
|
|
59
|
+
return undefined;
|
|
60
|
+
default: {
|
|
61
|
+
const unhandled = route;
|
|
62
|
+
throw new Error(`unhandled workflow park route: ${JSON.stringify(unhandled)}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
63
66
|
export async function heldWorkflowParkDecisions(sources, hostSessionId, carried) {
|
|
64
67
|
const entries = [...(carried ?? [])];
|
|
65
68
|
const { workflowParkDecisions: decisions, checkpointStore: cs, workflowAgentSessionIndex: workflowIndex, workflowRunStore } = sources;
|
|
@@ -73,20 +76,38 @@ export async function heldWorkflowParkDecisions(sources, hostSessionId, carried)
|
|
|
73
76
|
for (const row of held.rows) {
|
|
74
77
|
if (own.has(String(row.token)))
|
|
75
78
|
continue;
|
|
76
|
-
const
|
|
77
|
-
if ("
|
|
78
|
-
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (card.cp === null || card.cp.status !== "pending")
|
|
82
|
-
continue;
|
|
83
|
-
const origin = await findParkOrigin({ workflowIndex, workflowRunStore }, { token: row.token, scope: card.cp.scope, sessionId: card.cp.sessionId });
|
|
84
|
-
if (origin?.kind === "workflow")
|
|
85
|
-
entries.push({ runId: origin.runId, token: row.token, outcome: row.outcome });
|
|
79
|
+
const deliverable = await deliverableEntryOf({ checkpointStore: cs, workflowAgentSessionIndex: workflowIndex, workflowRunStore }, row);
|
|
80
|
+
if (deliverable.kind === "deliverable")
|
|
81
|
+
entries.push(deliverable.entry);
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
return entries.length > 0 ? { workflowParkedResume: entries } : {};
|
|
89
85
|
}
|
|
86
|
+
export async function deliverableEntryOf(sources, row) {
|
|
87
|
+
const unreadable = (step, err) => {
|
|
88
|
+
recordFailOpen("server.workflow-park-decision.card-unreadable", `step=${step} runId=${row.runId} err=${err instanceof Error ? err.message : String(err)}`);
|
|
89
|
+
return { kind: "unreadable" };
|
|
90
|
+
};
|
|
91
|
+
let cp;
|
|
92
|
+
try {
|
|
93
|
+
cp = await sources.checkpointStore.get(row.token);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
return unreadable("card", err);
|
|
97
|
+
}
|
|
98
|
+
if (cp === null || cp.status !== "pending")
|
|
99
|
+
return { kind: "not_deliverable" };
|
|
100
|
+
let origin;
|
|
101
|
+
try {
|
|
102
|
+
origin = await routeWorkflowOrigin(sources.workflowAgentSessionIndex, sources.workflowRunStore, { token: row.token, sessionId: cp.sessionId });
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return unreadable("holder", err);
|
|
106
|
+
}
|
|
107
|
+
if (origin?.kind !== "workflow")
|
|
108
|
+
return { kind: "not_deliverable" };
|
|
109
|
+
return { kind: "deliverable", entry: { runId: origin.runId, token: row.token, outcome: row.outcome }, origin, card: { scope: cp.scope, sessionId: cp.sessionId } };
|
|
110
|
+
}
|
|
90
111
|
function quiet(warn, event, fields) {
|
|
91
112
|
try {
|
|
92
113
|
warn?.(event, fields);
|
|
@@ -224,63 +245,87 @@ export function planWorkflowParkedDecide(origin, req) {
|
|
|
224
245
|
},
|
|
225
246
|
};
|
|
226
247
|
}
|
|
227
|
-
const verdict = req.decision === "approve" ? "APPROVED" : "DENIED";
|
|
228
248
|
return {
|
|
229
249
|
ok: true,
|
|
230
250
|
hostSessionId,
|
|
231
251
|
runId: origin.runId,
|
|
232
252
|
outcome: buildParkedResumeOutcome(req),
|
|
233
|
-
message:
|
|
234
|
-
text: `The human approval that workflow run "${origin.runId}" parked on (agent callKey "${origin.park.callKey}") has been ${verdict}. ` +
|
|
235
|
-
`Resume that run now: re-invoke Workflow with the SAME script source you launched it from (script / name / scriptPath) ` +
|
|
236
|
-
`AND resumeFromRunId: "${origin.runId}" — the decision is already held by the deployment and will be applied to the parked ` +
|
|
237
|
-
`agent; completed steps replay from the journal. Do not re-issue the original call.`,
|
|
238
|
-
trusted: true,
|
|
239
|
-
},
|
|
253
|
+
message: workflowParkGuidance(origin.runId, origin.park.callKey, req.decision),
|
|
240
254
|
};
|
|
241
255
|
}
|
|
256
|
+
export function workflowParkGuidance(runId, callKey, decision) {
|
|
257
|
+
const verdict = decision === "approve" ? "APPROVED" : "DENIED";
|
|
258
|
+
return {
|
|
259
|
+
text: `The human approval that workflow run "${runId}" parked on (agent callKey "${callKey}") has been ${verdict}. ` +
|
|
260
|
+
`Resume that run now: re-invoke Workflow with the SAME script source you launched it from (script / name / scriptPath) ` +
|
|
261
|
+
`AND resumeFromRunId: "${runId}" — the decision is already held by the deployment and will be applied to the parked ` +
|
|
262
|
+
`agent; completed steps replay from the journal. Do not re-issue the original call.`,
|
|
263
|
+
trusted: true,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export function redeemHere(runId, scope, d) {
|
|
267
|
+
return redeemWorkflowParks(runId, scope, [{ token: d.token, outcome: d.outcome }]);
|
|
268
|
+
}
|
|
242
269
|
function parkedChildResumedReceipt(taskId, decision, evidence) {
|
|
243
270
|
return { status: 200, body: { taskId, status: "resuming", decision, ...evidence } };
|
|
244
271
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
272
|
+
export function answerOfHolderFence(verdict, runId) {
|
|
273
|
+
switch (verdict) {
|
|
274
|
+
case "not_held":
|
|
275
|
+
return { status: 409, body: refusalBody({ errorCode: "decide.gate_moved", message: "the approval gate moved under this decide (re-parked or already settled) — re-check the pending list", facts: { runId } }) };
|
|
276
|
+
case "restated":
|
|
277
|
+
return {
|
|
278
|
+
status: 400,
|
|
279
|
+
body: refusalBody({
|
|
280
|
+
errorCode: "decide.parked_restatement_unsupported",
|
|
281
|
+
message: "mcpServers / a2aPeers cannot be applied: the run this approval belongs to is still running, and its waiting step continues with the MCP / A2A tables the run already has — re-issue the decide without them to continue it that way",
|
|
282
|
+
facts: { runId },
|
|
283
|
+
}),
|
|
284
|
+
};
|
|
285
|
+
case "other_decision":
|
|
286
|
+
return {
|
|
287
|
+
status: 409,
|
|
288
|
+
body: refusalBody({
|
|
289
|
+
errorCode: "decide.claim_lost",
|
|
290
|
+
message: "another decision for this approval was already handed to the run that is waiting on it and is being applied — re-check the pending list",
|
|
291
|
+
facts: { runId },
|
|
292
|
+
}),
|
|
293
|
+
};
|
|
294
|
+
default: {
|
|
295
|
+
const unhandled = verdict;
|
|
296
|
+
throw new Error(`unhandled workflow holder fence verdict: ${String(unhandled)}`);
|
|
297
|
+
}
|
|
265
298
|
}
|
|
266
|
-
byToken.set(token, { fingerprint, answer });
|
|
267
299
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const entry = d.restated ? { token: d.token } : { token: d.token, outcome: d.outcome };
|
|
271
|
-
const scope = origin.run.scope;
|
|
272
|
-
return answerOfParkDelivery(await redeemWorkflowParks(origin.runId, scope, [entry]), { id: origin.runId, ended: () => runChannelEnded(origin.runId, scope) }, d);
|
|
300
|
+
export function holderFenceFaultAnswer(runId) {
|
|
301
|
+
return { status: 503, body: refusalBody({ errorCode: "decide.store_unreachable", message: "the state of this approval could not be read just now, so the run waiting on it kept waiting and nothing was decided — retry", facts: { runId } }) };
|
|
273
302
|
}
|
|
274
|
-
export
|
|
275
|
-
const
|
|
303
|
+
export function answerOfHolderRedeem(delivery, runId, decision) {
|
|
304
|
+
const receipt = () => parkedChildResumedReceipt(runId, decision, NO_SETTLEMENT_EVIDENCE);
|
|
276
305
|
switch (delivery.kind) {
|
|
277
|
-
case "live":
|
|
278
|
-
|
|
306
|
+
case "live": {
|
|
307
|
+
const word = delivery.results[0];
|
|
308
|
+
if (word === undefined)
|
|
309
|
+
throw new Error(`workflow run ${runId} answered a live delivery without a result for the one decision it was handed`);
|
|
310
|
+
switch (word) {
|
|
311
|
+
case "driving":
|
|
312
|
+
case "already_taken":
|
|
313
|
+
case "not_parked_here":
|
|
314
|
+
case "unreadable":
|
|
315
|
+
return receipt();
|
|
316
|
+
case "settled":
|
|
317
|
+
return answerOfHolderFence("not_held", runId);
|
|
318
|
+
case "kept_parked":
|
|
319
|
+
throw new Error(`workflow run ${runId} kept a parked call that was handed a decision — the engine keeps a park only on an acknowledgement`);
|
|
320
|
+
default: {
|
|
321
|
+
const unhandled = word;
|
|
322
|
+
throw new Error(`unhandled workflow park delivery result: ${String(unhandled)}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
279
326
|
case "suspending":
|
|
280
|
-
await delivery.ended;
|
|
281
|
-
return { kind: "resume_lane" };
|
|
282
327
|
case "not_active":
|
|
283
|
-
return
|
|
328
|
+
return receipt();
|
|
284
329
|
case "not_armed":
|
|
285
330
|
throw new Error(`workflow run ${runId} answered not_armed to a decision for a card it holds — a run without a checkpoint seat cannot have parked one; refusing to guess where the decision goes`);
|
|
286
331
|
default: {
|
|
@@ -289,53 +334,44 @@ export async function answerOfParkDelivery(delivery, run, d) {
|
|
|
289
334
|
}
|
|
290
335
|
}
|
|
291
336
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
facts: { runId },
|
|
314
|
-
}),
|
|
315
|
-
};
|
|
337
|
+
export function holderPullDisposition(delivery, runId) {
|
|
338
|
+
switch (delivery.kind) {
|
|
339
|
+
case "live": {
|
|
340
|
+
const word = delivery.results[0];
|
|
341
|
+
if (word === undefined)
|
|
342
|
+
throw new Error(`workflow run ${runId} answered a live delivery without a result for the one decision it was handed`);
|
|
343
|
+
switch (word) {
|
|
344
|
+
case "driving":
|
|
345
|
+
case "already_taken":
|
|
346
|
+
case "settled":
|
|
347
|
+
return "delivered";
|
|
348
|
+
case "not_parked_here":
|
|
349
|
+
case "unreadable":
|
|
350
|
+
return "next_beat";
|
|
351
|
+
case "kept_parked":
|
|
352
|
+
throw new Error(`workflow run ${runId} kept a parked call that was handed a decision — the engine keeps a park only on an acknowledgement`);
|
|
353
|
+
default: {
|
|
354
|
+
const unhandled = word;
|
|
355
|
+
throw new Error(`unhandled workflow park delivery result: ${String(unhandled)}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
316
358
|
}
|
|
317
|
-
case "
|
|
318
|
-
case "
|
|
319
|
-
return
|
|
320
|
-
case "
|
|
321
|
-
|
|
322
|
-
case "kept_parked":
|
|
323
|
-
if (!d.restated)
|
|
324
|
-
throw new Error(`workflow run ${runId} kept a parked call that was handed a decision — the engine keeps a park only on an acknowledgement`);
|
|
325
|
-
return {
|
|
326
|
-
status: 400,
|
|
327
|
-
body: refusalBody({
|
|
328
|
-
errorCode: "decide.parked_restatement_unsupported",
|
|
329
|
-
message: "mcpServers / a2aPeers cannot be applied: the run this approval belongs to is still running, and its waiting step continues with the MCP / A2A tables the run already has — re-issue the decide without them to continue it that way",
|
|
330
|
-
facts: { runId },
|
|
331
|
-
}),
|
|
332
|
-
};
|
|
359
|
+
case "suspending":
|
|
360
|
+
case "not_active":
|
|
361
|
+
return "left";
|
|
362
|
+
case "not_armed":
|
|
363
|
+
throw new Error(`workflow run ${runId} answered not_armed to a decision for a card it holds — a run without a checkpoint seat cannot have parked one`);
|
|
333
364
|
default: {
|
|
334
|
-
const unhandled =
|
|
335
|
-
throw new Error(`unhandled workflow park delivery
|
|
365
|
+
const unhandled = delivery;
|
|
366
|
+
throw new Error(`unhandled workflow park delivery: ${JSON.stringify(unhandled)}`);
|
|
336
367
|
}
|
|
337
368
|
}
|
|
338
369
|
}
|
|
370
|
+
export async function runChannelEnded(runId, scope) {
|
|
371
|
+
const channel = subscribeWorkflow(runId, scope)[Symbol.asyncIterator]();
|
|
372
|
+
while (!(await channel.next()).done) {
|
|
373
|
+
}
|
|
374
|
+
}
|
|
339
375
|
function sessionGone(taskId) {
|
|
340
376
|
return {
|
|
341
377
|
status: 409,
|
package/dist/peer-directory.d.ts
CHANGED
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
*
|
|
38
38
|
* ## scope 轴
|
|
39
39
|
*
|
|
40
|
-
* core 递进来的 `access.scope` =
|
|
41
|
-
*
|
|
40
|
+
* core 递进来的 `access.scope` = 引擎的任务 scope(core 写侧规则与本仓的唯一换算见 `engine-identity.ts` 的 `engineScopeOf` 头注)
|
|
41
|
+
* × 落点 `taskSpecIdentityOf` 只写人 ⇒ **裸 principal 串**,
|
|
42
42
|
* 无 principal 的部署上是字面量 `"default"`,而同一情形下 `session_meta.owner` 是 SQL NULL ——
|
|
43
43
|
* 这正是窄互认臂(`LEGACY_UNOWNED_AMNESTY_TENANT === "default"`)要接住的那一格,不必另铸编解码。
|
|
44
44
|
*
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* receipt / 投递 / 到期计时都是 core 绑在队列上的 sink(引擎在 run 的 drain 里自己 `configure`,宿主**不**接 sink —— 接了就是第二个写者)。
|
|
12
12
|
* 本面只做两件事:把队列里等人审的卡(见下「只有人能答的卡」)投成 `pending[]` 的 `peer_inbound` 行;把决断口的 approve / deny 原样交给 `settle`。
|
|
13
13
|
* 没有行店、没有落账:一张卡在不在、谁赢了 CAS、结局是什么,全是 core 的读数。
|
|
14
|
-
* · **属主 = 收信方**:列与决都只在调用方**自己**的信箱 scope 里找队列(`peerHeldQueueIfAny(调用方 scope, …)`;
|
|
15
|
-
* `
|
|
14
|
+
* · **属主 = 收信方**:列与决都只在调用方**自己**的信箱 scope 里找队列(`peerHeldQueueIfAny(调用方 scope, …)`;core 按收信 run 的任务 scope 开队列,
|
|
15
|
+
* 调用方那一格只经唯一换算 `engine-identity.ts` 的 `engineScopeOfOwner` 读,路由在调用点换好再交进来)—— 别人的卡结构上取不到,决断口答的 404 与「没有这张卡」同码同文。
|
|
16
16
|
* 显式 operator **没有**额外射程:一封信是收信人的,不是运维治理面(与停驻门「operator 可决任意行」刻意不同,决断口按族分臂)。
|
|
17
17
|
* · **只有人能答的卡才进审批席**(core `PEER_HELD_REVIEW_CAUSES`:`mode-mismatch` / `no-mode-asserted` / `invalid-mode-attestation` —— 权限档
|
|
18
18
|
* 对等判扣下的信;CC 只对这几个成因开审阅框与到期计时,cli309.js:36111–36116 的句子逐条:`managed-setting` / `repo-setting` / `explicit-setting`
|
|
@@ -41,10 +41,6 @@
|
|
|
41
41
|
*/
|
|
42
42
|
import { type PeerHeldEntry, type PeerHeldSettleOutcome } from "@sema-agent/core";
|
|
43
43
|
import { type PeerInboundLane } from "./org-delivery-gate.js";
|
|
44
|
-
/**
|
|
45
|
-
* 调用方 principal 的信箱 scope —— core 写侧 `taskScope = spec.principal ?? "default"` 的同一条读法(无主 ⇒ `"default"`)。列 / 决都按它找队列。
|
|
46
|
-
*/
|
|
47
|
-
export declare function peerBoxScope(principal: string | null | undefined): string;
|
|
48
44
|
/** 决断口 id 的坐标(id 是它的唯一拼法,见 {@link peerInboundIdOf})。 */
|
|
49
45
|
export interface PeerInboundCoord {
|
|
50
46
|
readonly sessionId: string;
|
|
@@ -3,9 +3,6 @@ import { PEER_INBOUND_LANES, boxOfLane, laneOfBox } from "./org-delivery-gate.js
|
|
|
3
3
|
import { PEER_INBOUND_ID_PREFIX } from "./approval-queue-kind.js";
|
|
4
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
5
5
|
import { seatText } from "./trace/exit-seat.js";
|
|
6
|
-
export function peerBoxScope(principal) {
|
|
7
|
-
return principal ?? "default";
|
|
8
|
-
}
|
|
9
6
|
export function peerInboundIdOf(c) {
|
|
10
7
|
return `${PEER_INBOUND_ID_PREFIX}${c.sessionId}:${c.lane}:${c.seq}`;
|
|
11
8
|
}
|
package/dist/peer-seat.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type PeerBinding = {
|
|
|
66
66
|
readonly url: string;
|
|
67
67
|
readonly cardUrl?: string;
|
|
68
68
|
};
|
|
69
|
-
/** Why the seat refused a question. Closed: a
|
|
69
|
+
/** Why the seat refused a question. Closed: a word belongs to a row of the seat's per-kind table (or to the handle row's own two refusals). */
|
|
70
70
|
export type PeerSeatRefusalReason = "handle_not_held" | "binding_mismatch" | "kind_env" | "kind_vault" | "kind_assertion" | "kind_unknown";
|
|
71
71
|
/**
|
|
72
72
|
* The desk's own failures, each loud:
|
package/dist/peer-seat.js
CHANGED
|
@@ -151,67 +151,60 @@ export function createPeerDesk(opts = {}) {
|
|
|
151
151
|
return { kind: "carry", env: entry.pieces };
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
case "handle":
|
|
157
|
-
return ref.id;
|
|
158
|
-
case "env":
|
|
159
|
-
case "vault":
|
|
160
|
-
case "assertion":
|
|
161
|
-
return undefined;
|
|
162
|
-
default: {
|
|
163
|
-
const unknownKind = ref;
|
|
164
|
-
void unknownKind;
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
154
|
+
const notMintedHold = () => {
|
|
155
|
+
throw new Error("peer desk: hold of a reference this desk did not mint — not held");
|
|
168
156
|
};
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
157
|
+
const notMintedRelease = () => {
|
|
158
|
+
throw new Error("peer desk: release of a reference this desk did not mint — nothing released");
|
|
159
|
+
};
|
|
160
|
+
const notMinted = (reason) => ({
|
|
161
|
+
answer: (_ref, question) => refuse(question.peer, reason),
|
|
162
|
+
hold: notMintedHold,
|
|
163
|
+
release: notMintedRelease,
|
|
164
|
+
});
|
|
165
|
+
const seatKinds = {
|
|
166
|
+
handle: {
|
|
167
|
+
answer: (ref, question) => {
|
|
168
|
+
const target = question.peer;
|
|
169
|
+
const entry = table.get(ref.id);
|
|
170
|
+
if (entry === undefined)
|
|
171
|
+
return refuse(target, "handle_not_held");
|
|
172
|
+
if (!sameBinding(entry.binding, bindingOf(target)))
|
|
173
|
+
return refuse(target, "binding_mismatch");
|
|
174
|
+
return carry(entry);
|
|
175
|
+
},
|
|
176
|
+
hold: (ref) => {
|
|
177
|
+
const id = ref.id;
|
|
178
|
+
if (id === undefined)
|
|
179
|
+
return notMintedHold();
|
|
180
|
+
const entry = table.get(id);
|
|
181
|
+
if (entry === undefined)
|
|
182
|
+
throw new Error("peer desk: hold of a handle whose entry is gone — not held (a hold never revives an entry)");
|
|
183
|
+
entry.engineHolds += 1;
|
|
184
|
+
},
|
|
185
|
+
release: (ref) => {
|
|
186
|
+
const id = ref.id;
|
|
187
|
+
if (id === undefined)
|
|
188
|
+
return notMintedRelease();
|
|
189
|
+
const entry = table.get(id);
|
|
190
|
+
if (entry === undefined || entry.engineHolds === 0)
|
|
191
|
+
throw new Error("peer desk: release of a handle with no counted engine hold — nothing released");
|
|
192
|
+
entry.engineHolds -= 1;
|
|
193
|
+
dropIfUnheld(id, entry);
|
|
194
|
+
},
|
|
188
195
|
},
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return carry(entry);
|
|
202
|
-
}
|
|
203
|
-
case "env":
|
|
204
|
-
return refuse(target, "kind_env");
|
|
205
|
-
case "vault":
|
|
206
|
-
return refuse(target, "kind_vault");
|
|
207
|
-
case "assertion":
|
|
208
|
-
return refuse(target, "kind_assertion");
|
|
209
|
-
default: {
|
|
210
|
-
const unknownKind = ref;
|
|
211
|
-
void unknownKind;
|
|
212
|
-
return refuse(target, "kind_unknown");
|
|
213
|
-
}
|
|
214
|
-
}
|
|
196
|
+
env: notMinted("kind_env"),
|
|
197
|
+
vault: notMinted("kind_vault"),
|
|
198
|
+
assertion: notMinted("kind_assertion"),
|
|
199
|
+
};
|
|
200
|
+
const unknownKind = notMinted("kind_unknown");
|
|
201
|
+
const rowOf = (ref) => (Object.hasOwn(seatKinds, ref.kind) ? seatKinds[ref.kind] : unknownKind);
|
|
202
|
+
const seat = Object.freeze({
|
|
203
|
+
hold: (ref) => rowOf(ref).hold(ref),
|
|
204
|
+
release: (ref) => rowOf(ref).release(ref),
|
|
205
|
+
answer: async (question, signal) => {
|
|
206
|
+
const ref = question.peer.credentials;
|
|
207
|
+
return ref === undefined ? { kind: "carry" } : rowOf(ref).answer(ref, question, signal);
|
|
215
208
|
},
|
|
216
209
|
});
|
|
217
210
|
return Object.freeze({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* **一个进入 run 的权限模式词(调用方交来的,或停驻 run 的存储体被重放时体上的),本部署收不收、收成什么** —— 唯一的受理判官(规则一处、三只属主各一处、序一处)。
|
|
3
3
|
*
|
|
4
4
|
* ## 一条规则,三只属主,本模块只排序
|
|
5
5
|
* ① 本任务 settings 的 kill-switch 折叠(`task-settings.ts` `foldDisableAutoMode`:`disableAutoMode` 在 ⇒ `auto` 折 `default`);
|
|
@@ -8,12 +8,30 @@
|
|
|
8
8
|
* ①② 是**入口一步**({@link entryStep}:改词、不拒),③ 是**托管一步**(只拒、不改词)。顺序承重的只有「② 在 ③ 之前」(地板把 bypass 钳成 plan 之后就不开写面,不拒);
|
|
9
9
|
* ① 只动 `auto`、③ 只看开写面的词,两者互不相交。
|
|
10
10
|
*
|
|
11
|
-
* ##
|
|
11
|
+
* ## 三口的调用形(同一组函数、同一个序;提交口与切档口:同一个词 × 同一份部署事实 × 同一份任务 settings ⇒ 同一个结果,钉 `test/run-permission-mode-admission.test.ts` 的两口表;
|
|
12
|
+
* 续跑口与它们只差地板的出口词一个事实,钉 `test/entry-permission-mode.test.ts` 的续跑口表)
|
|
12
13
|
* · 在飞 run 的切档口(`http/routes/run-permission-mode.ts`:`POST /v1/runs/:id/permission-mode` 的 `mode`,本任务 settings 读存储体)调整只判官 {@link admitPermissionModeWord}。
|
|
13
14
|
* · 提交口(`POST /v1/tasks|/v1/tasks/stream|/v1/runs` 的词 = 顶层 `permissionMode` ?? bundle `settings.permissions.defaultMode`)把两步落在**上一版就在的两处**:
|
|
14
15
|
* 入口一步在受理门盖章({@link stampSubmissionEntryMode},`http/admission.ts`:值形门之后、装配之前 —— 首跑装配与 `buildCheckpointCtx` 读的都是盖过章的体);
|
|
15
16
|
* 托管一步是装配期那一处判(`boot/resolve-spec.ts`,对盖过章的词调同一只 ③;提交腿与续跑重放腿同经)。不把整只判官提前到受理门:那会让托管拒抢在
|
|
16
|
-
* 属主 / 会话 / 执行上下文与装配期其余值判之前答(拒序变了 —— 钉同一文件的拒序组)
|
|
17
|
+
* 属主 / 会话 / 执行上下文与装配期其余值判之前答(拒序变了 —— 钉同一文件的拒序组)。
|
|
18
|
+
* · 续跑口(一条 HTTP 车道停驻 run 的存储体被重放之前;`http/resume-legs.ts` 的 `replayCtxOf`,五个续跑读点同调;leader 车道的行按那条车道「一 run 一读」照写下的体重放,
|
|
19
|
+
* 规则在 `replayCtxOf` 头注)调 {@link stampReplayEntryMode}:体上的词过与提交口**同一只**入口一步
|
|
20
|
+
* ({@link bodyEntry}:同一只折叠、同一只 `entryPermissionMode`、地板读同一份**活** config)、盖同一只章 —— 提交之后运维把 `AUTONOMY` 改严,或体是更早的写者留下的请求原词,
|
|
21
|
+
* 重放照**现**地板钳;被钳 = 钳到地板放行(与提交口同形,不拒、不新增码),生效词由这条腿的 `wiring_manifest.permissionMode` 说;钳过的体随 CAS 赢点写回,
|
|
22
|
+
* 存储体仍是这条 run 模式词唯一的源。与提交口只差一个**事实**(不是续跑专用臂,见下一节):体**顶层** `permissionMode` 上写着的是这块地板的出口词({@link floorExitWords})⇒ 原样读。
|
|
23
|
+
* 托管一步照旧在装配期判。
|
|
24
|
+
*
|
|
25
|
+
* ## 为什么地板的出口词在续跑口原样读
|
|
26
|
+
* 存储体上的模式词有三个写者:提交口(盖过地板)、切档口(盖过地板)、`plan_review` 的批准 / 编辑写回(`http/resume-legs.ts` `drivePlanReview`:把计划带出 plan,
|
|
27
|
+
* 写 `PLAN_APPROVE_PERMISSION_MODES_AFTER` 里的词 —— 这就是 plan 地板的出口:一个人批了这份计划)。提交口与切档口收的是**调用方**的词,出口词照钳(没有人批过计划);
|
|
28
|
+
* 续跑口读的是**存储体**的词,出口词是批准写下的 ⇒ 对它也钳 = 每一次挂起→续跑都把批过的计划拉回 plan(上一版撤掉按段重钳模式词的那条理由,`runtime-governance.ts`
|
|
29
|
+
* `autonomyOverrides` 顶注)。出口词以外的词(`bypassPermissions` / `auto` / `dontAsk` / 缺席)在这块地板下没有任何写者写得出来 —— 只能是更松的地板(改严之前)
|
|
30
|
+
* 或更早的写者(7.121.x 及以前的请求原词)留下的 ⇒ 照现地板钳。出口写者只写**顶层** `permissionMode`(`drivePlanReview` 的写回;bundle 的 `defaultMode` 不动),
|
|
31
|
+
* 所以出口判读的是顶层那一格的**原字**(严格读):只在 bundle 拼法里的词、经本任务 kill-switch 折出来的词(顶层 `auto` × `disableAutoMode` ⇒ `default`)、
|
|
32
|
+
* 词表外的串(重放的宽读把它折成 `default`)都不是出口写下的,照钳。
|
|
33
|
+
* ⚠️ 射程如实:顶层的出口词本身读不出是谁写的 —— 改严之前提交的顶层 `default` / `acceptEdits`、7.121.x 及以前的同字原词与批准写回逐字相同,原样重放
|
|
34
|
+
* (MIGRATION 如实写);要分开它们得给行补一个「谁写的」事实,本模块不猜。
|
|
17
35
|
*
|
|
18
36
|
* ## 为什么切档口必须经这只判官(而不是靠引擎的 deny 位)
|
|
19
37
|
* 引擎在根腿上只认两只模式拒位(`RuntimeCaps.bypassPermissions` / `RuntimeCaps.autoMode`,本仓由 center 与本地 kill-switch 写);上面三问
|
|
@@ -55,8 +73,8 @@ export type PermissionModeAdmission = {
|
|
|
55
73
|
export declare function admitPermissionModeWord(word: PermissionMode | undefined, facts: PermissionModeAdmissionFacts): PermissionModeAdmission;
|
|
56
74
|
/**
|
|
57
75
|
* 提交口的入口一步(`http/admission.ts` 唯一调用;直调装配腿的测试夹具也调它 —— 少了这一步的体是部署上到不了的体):
|
|
58
|
-
*
|
|
59
|
-
*
|
|
76
|
+
* 体上的词过 {@link bodyEntry};入口词盖进体(`task-settings.ts` `stampEntryPermissionMode`:地板在场时写顶层 `permissionMode`,缺席原物)。
|
|
77
|
+
* 不拒 —— 托管一步在装配期判(见顶注「三口的调用形」)。
|
|
60
78
|
*/
|
|
61
79
|
export declare function stampSubmissionEntryMode<B extends {
|
|
62
80
|
permissionMode?: unknown;
|
|
@@ -65,4 +83,22 @@ export declare function stampSubmissionEntryMode<B extends {
|
|
|
65
83
|
readonly body: B;
|
|
66
84
|
readonly entry: EntryPermissionMode;
|
|
67
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* 一块入口地板的**出口词** —— 存储体上由地板自己的出口写下的词(续跑口原样读它们,理由见顶注「为什么地板的出口词在续跑口原样读」)。
|
|
88
|
+
* 闭集穷尽 switch:引擎的模式词表加一词 ⇒ 编译红,逼着回答「这个词当地板时靠什么出口」。`plan` 的出口是人审(`plan_review` 的批准 / 编辑把计划带出 plan,
|
|
89
|
+
* 写回的词表 = `task-settings.ts` `PLAN_APPROVE_PERMISSION_MODES_AFTER`,那张表是唯一的源);其余五词今天不是任何档的地板(`runtime-governance.ts` `autonomyModeFloor`
|
|
90
|
+
* 只答 `plan` 或缺席),当地板也没有出口 ⇒ 空(失效关闭:比它松的词照钳)。
|
|
91
|
+
*/
|
|
92
|
+
export declare function floorExitWords(floor: PermissionMode): readonly PermissionMode[];
|
|
93
|
+
/**
|
|
94
|
+
* 续跑口的入口一步:一条停驻 run 的存储体被重放之前,体上的词过 {@link bodyEntry}(与提交口同一只,地板读此刻的活 config),入口词盖进体
|
|
95
|
+
* (同一只 `stampEntryPermissionMode`);体顶层 `permissionMode` 的原字是 `bodyEntry` 读到的那块地板的出口词({@link floorExitWords})⇒ 体**原物**交回
|
|
96
|
+
* (出口写者只写顶层;那个词已经过了地板)。
|
|
97
|
+
* 地板缺席 ⇒ 体原物(零字节变化)。不拒:钳到地板放行,与提交口同形(见顶注「三口的调用形」)。
|
|
98
|
+
* 唯一调用点:`http/resume-legs.ts` 的 `replayCtxOf`(五个续跑读点同调;之后的存体预判、重建、plan_review 的模式词门与驱动段、CAS 赢点的写回读的都是它交回的那一份)。
|
|
99
|
+
*/
|
|
100
|
+
export declare function stampReplayEntryMode<B extends {
|
|
101
|
+
permissionMode?: unknown;
|
|
102
|
+
settings?: unknown;
|
|
103
|
+
}>(body: B, deployment: PermissionModeAdmissionFacts["deployment"]): B;
|
|
68
104
|
//# sourceMappingURL=permission-mode-admission.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { autonomyModeFloor, entryPermissionMode } from "./runtime-governance.js";
|
|
2
2
|
import { HOST_POSTURE_REFUSED_CODE, permissionModeWriteFaceRefusal } from "./hosted-posture.js";
|
|
3
|
-
import { foldDisableAutoMode, parseTaskSettings, requestedPermissionMode, stampEntryPermissionMode } from "./task-settings.js";
|
|
3
|
+
import { PLAN_APPROVE_PERMISSION_MODES_AFTER, coercePermissionModeStrict, foldDisableAutoMode, parseTaskSettings, requestedPermissionMode, stampEntryPermissionMode } from "./task-settings.js";
|
|
4
4
|
export const PERMISSION_MODE_ADMISSION_FOLDS = ["entry_floor", "disable_auto_mode"];
|
|
5
5
|
function entryStep(word, facts) {
|
|
6
6
|
const folded = foldDisableAutoMode(word, facts.settings);
|
|
@@ -15,9 +15,35 @@ export function admitPermissionModeWord(word, facts) {
|
|
|
15
15
|
return { kind: "refused", status: 422, code: HOST_POSTURE_REFUSED_CODE, message: why };
|
|
16
16
|
return { kind: "admitted", requested: word, admitted: entry.effective, entry, ...(foldedBy !== undefined ? { foldedBy } : {}) };
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
function bodyEntry(body, deployment) {
|
|
19
19
|
const settings = parseTaskSettings(body.settings).settings;
|
|
20
|
-
|
|
20
|
+
return entryStep(requestedPermissionMode(body, settings), { deployment, settings }).entry;
|
|
21
|
+
}
|
|
22
|
+
export function stampSubmissionEntryMode(body, deployment) {
|
|
23
|
+
const entry = bodyEntry(body, deployment);
|
|
21
24
|
return { body: stampEntryPermissionMode(body, entry), entry };
|
|
22
25
|
}
|
|
26
|
+
export function floorExitWords(floor) {
|
|
27
|
+
switch (floor) {
|
|
28
|
+
case "plan":
|
|
29
|
+
return PLAN_APPROVE_PERMISSION_MODES_AFTER;
|
|
30
|
+
case "default":
|
|
31
|
+
case "acceptEdits":
|
|
32
|
+
case "auto":
|
|
33
|
+
case "bypassPermissions":
|
|
34
|
+
case "dontAsk":
|
|
35
|
+
return [];
|
|
36
|
+
default: {
|
|
37
|
+
const unhandled = floor;
|
|
38
|
+
throw new Error(`entry floor "${String(unhandled)}" has no exit arm`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function stampReplayEntryMode(body, deployment) {
|
|
43
|
+
const entry = bodyEntry(body, deployment);
|
|
44
|
+
const top = coercePermissionModeStrict(body.permissionMode);
|
|
45
|
+
if (entry.floor !== undefined && top !== undefined && floorExitWords(entry.floor).includes(top))
|
|
46
|
+
return body;
|
|
47
|
+
return stampEntryPermissionMode(body, entry);
|
|
48
|
+
}
|
|
23
49
|
//# sourceMappingURL=permission-mode-admission.js.map
|