@sema-agent/server 7.146.0 → 7.148.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 +1423 -24
- package/README.md +21 -8
- package/README.zh-CN.md +15 -9
- package/USAGE.md +537 -216
- package/deploy/facts/lanes.json +7 -0
- package/deploy/sema-up/README.md +18 -7
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/_helpers.tpl +42 -4
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -4
- package/deploy/sema-up/chart/templates/server.yaml +5 -4
- package/deploy/sema-up/chart/values.yaml +4 -3
- package/deploy/sema-up/cluster-up.sh +75 -176
- package/deploy/sema-up/kube-up.sh +29 -49
- package/deploy/sema-up/lib/chart-run.sh +23 -0
- package/deploy/sema-up/lib/dataroot.sh +3 -3
- package/deploy/sema-up/lib/flagshape.sh +4 -0
- package/deploy/sema-up/lib/health.sh +62 -13
- package/deploy/sema-up/lib/helm-values-cluster.py +18 -0
- package/deploy/sema-up/lib/helm-values-kube.py +35 -0
- package/deploy/sema-up/lib/lanes.json +2 -5
- package/deploy/sema-up/lib/regcred.py +8 -0
- package/deploy/sema-up/lib/remote/helm-install.sh +3 -0
- package/deploy/sema-up/lib/remote/image-import.sh +6 -0
- package/deploy/sema-up/lib/remote/machine-precheck.sh +11 -0
- package/deploy/sema-up/lib/remote/region-probe.sh +3 -0
- package/deploy/sema-up/lib/remote/stack-ready.sh +26 -0
- package/deploy/sema-up/lib/remote/vxlan-guard.sh +8 -0
- package/deploy/sema-up/lib/render-stack.py +17 -0
- package/deploy/sema-up/lib/shell-text.sh +87 -0
- package/deploy/sema-up/lib/usage-flags.txt +10 -0
- package/deploy/sema-up/lib/usage-head.txt +1 -0
- package/deploy/sema-up/lib/usage-tail.txt +13 -0
- package/deploy/sema-up/preflight.sh +10 -8
- package/deploy/sema-up/sema-up.sh +26 -48
- package/deploy/sema-up/smoke.sh +7 -6
- package/deploy/sema-up/stack/compose.dataroot.yaml +3 -0
- package/deploy/sema-up/stack/compose.yaml +18 -5
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +25 -3
- package/dist/adoption/plan.d.ts +24 -0
- package/dist/adoption/plan.js +53 -1
- package/dist/adoption/runner.d.ts +10 -1
- package/dist/adoption/runner.js +36 -16
- package/dist/adoption/wire.d.ts +3 -3
- package/dist/approval-card.d.ts +32 -34
- package/dist/approval-gate-currency.js +3 -2
- package/dist/approval-reconciler.d.ts +4 -13
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.d.ts +16 -14
- package/dist/approval.js +3 -3
- package/dist/audit.d.ts +10 -3
- package/dist/audit.js +17 -9
- package/dist/auth-bridge.d.ts +0 -14
- package/dist/auth-bridge.js +0 -7
- package/dist/auto-mode-face.d.ts +10 -7
- package/dist/auto-mode-face.js +7 -4
- package/dist/background-agent-name.d.ts +19 -1
- package/dist/background-agent-name.js +12 -2
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.js +9 -6
- package/dist/bench/s1/arms.js +6 -5
- package/dist/bench/s1/live-deps.js +8 -3
- package/dist/bench/s1/run-firm.js +6 -5
- package/dist/bind-host.d.ts +25 -0
- package/dist/bind-host.js +25 -0
- package/dist/boot/adoption.d.ts +3 -0
- package/dist/boot/adoption.js +1 -0
- package/dist/boot/crash-last.js +2 -1
- package/dist/boot/deployment-mods.d.ts +1 -1
- package/dist/boot/device-lane.js +5 -5
- package/dist/boot/engine-lease.d.ts +12 -11
- package/dist/boot/execution-env.d.ts +19 -8
- package/dist/boot/execution-env.js +80 -62
- package/dist/boot/execution-lane.d.ts +37 -9
- package/dist/boot/execution-lane.js +74 -20
- package/dist/boot/exit-boundary.d.ts +3 -3
- package/dist/boot/exit-boundary.js +6 -5
- package/dist/boot/exit-last.js +2 -1
- package/dist/boot/fatal-exit.d.ts +3 -5
- package/dist/boot/fatal-exit.js +2 -2
- package/dist/boot/governance-seams.d.ts +2 -2
- package/dist/boot/leader.d.ts +15 -0
- package/dist/boot/leader.js +18 -16
- package/dist/boot/memory-boundary.d.ts +11 -11
- package/dist/boot/memory-boundary.js +3 -3
- package/dist/boot/memory-consolidation.d.ts +50 -53
- package/dist/boot/memory-consolidation.js +11 -18
- package/dist/boot/org-memory.js +4 -3
- package/dist/boot/parked-revive-gate.d.ts +1 -1
- package/dist/boot/parked-revive-gate.js +3 -3
- package/dist/boot/reapers.d.ts +4 -3
- package/dist/boot/reapers.js +20 -17
- package/dist/boot/resolve-spec.d.ts +5 -3
- package/dist/boot/resolve-spec.js +133 -165
- package/dist/boot/retention-lane.d.ts +7 -45
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +28 -7
- package/dist/boot/runner-deps.js +11 -4
- package/dist/boot/runtime-caps.d.ts +2 -2
- package/dist/boot/runtime-caps.js +16 -2
- package/dist/boot/session-faces.d.ts +17 -7
- package/dist/boot/session-faces.js +122 -96
- package/dist/boot/shutdown.d.ts +5 -4
- package/dist/boot/shutdown.js +6 -4
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +14 -2
- package/dist/boot/stage-02-web-admin-pull.d.ts +2 -1
- package/dist/boot/stage-02-web-admin-pull.js +15 -8
- package/dist/boot/stage-03-store-backend.d.ts +4 -1
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +3 -1
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +9 -5
- package/dist/boot/stage-05-execution-env.js +5 -5
- package/dist/boot/stage-06-runners.d.ts +13 -15
- package/dist/boot/stage-06-runners.js +24 -18
- package/dist/boot/stage-07-capability-layer.d.ts +14 -11
- package/dist/boot/stage-07-capability-layer.js +9 -12
- package/dist/boot/stage-08-reapers.d.ts +14 -11
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +16 -18
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +16 -18
- package/dist/boot/stage-10-http-server.js +9 -5
- package/dist/boot/store-evidence.d.ts +20 -0
- package/dist/boot/store-evidence.js +13 -0
- package/dist/boot/stores.d.ts +12 -0
- package/dist/boot/stores.js +39 -17
- package/dist/boot/task-list-lane.d.ts +4 -4
- package/dist/boot/web-admin.d.ts +4 -2
- package/dist/boot/web-admin.js +58 -38
- package/dist/boot/webfetch-summarize-lane.d.ts +1 -1
- package/dist/boot-reclaim.d.ts +3 -1
- package/dist/boot-reclaim.js +1 -1
- package/dist/brain.d.ts +7 -18
- package/dist/brain.js +5 -17
- package/dist/budget.js +6 -6
- package/dist/capabilities/center-plugins.d.ts +9 -1
- package/dist/capabilities/center-plugins.js +37 -11
- package/dist/capabilities/center-wiring.js +1 -1
- package/dist/capabilities/composite-members.d.ts +3 -2
- package/dist/capabilities/composite-members.js +3 -2
- package/dist/capabilities/execution-lane.d.ts +7 -7
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +1 -1
- package/dist/capabilities/repo-tools.d.ts +2 -0
- package/dist/capabilities/repo-tools.js +14 -12
- package/dist/capabilities/scenarios.d.ts +38 -33
- package/dist/capabilities/scenarios.js +24 -25
- package/dist/capabilities/settings-contract.d.ts +29 -0
- package/dist/capabilities/settings-contract.js +14 -0
- package/dist/capabilities/skills.d.ts +6 -6
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +69 -4
- package/dist/capability-facts.js +77 -5
- package/dist/card-void.d.ts +4 -4
- package/dist/card-void.js +1 -1
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +10 -5
- package/dist/config-catalog.d.ts +16 -1
- package/dist/config-catalog.js +68 -61
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +58 -4
- package/dist/config-invariants.js +104 -23
- package/dist/config-lkg.d.ts +24 -2
- package/dist/config-lkg.js +22 -9
- package/dist/config-provider.d.ts +9 -9
- package/dist/config-provider.js +25 -108
- package/dist/config-pull-failure.d.ts +50 -0
- package/dist/config-pull-failure.js +48 -0
- package/dist/config-types.d.ts +215 -202
- package/dist/config.d.ts +69 -14
- package/dist/config.js +188 -96
- package/dist/degenerate-instrument.js +1 -1
- package/dist/delegated-session-owner.d.ts +1 -1
- package/dist/deleted-session-ids.d.ts +3 -2
- package/dist/deploy-facts.js +3 -2
- package/dist/deployment-governance.d.ts +3 -3
- package/dist/deployment-shape.d.ts +51 -16
- package/dist/deployment-shape.js +31 -6
- package/dist/egress-redirect.d.ts +25 -7
- package/dist/egress-redirect.js +20 -2
- package/dist/elicitation.d.ts +6 -5
- package/dist/elicitation.js +23 -22
- package/dist/engine-identity.d.ts +28 -0
- package/dist/engine-identity.js +10 -0
- package/dist/entry-problems.d.ts +5 -7
- package/dist/entry-problems.js +1 -1
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +12 -7
- package/dist/env-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-config-root.d.ts +5 -5
- package/dist/execution-config-root.js +5 -5
- package/dist/execution-env-purpose.d.ts +14 -0
- package/dist/execution-env-purpose.js +29 -0
- package/dist/execution-lane-caps.d.ts +53 -103
- package/dist/execution-lane-caps.js +51 -83
- package/dist/execution-placement.d.ts +65 -9
- package/dist/execution-placement.js +58 -0
- package/dist/field-conflict.d.ts +7 -11
- package/dist/field-conflict.js +3 -3
- package/dist/file-history-capture.d.ts +3 -3
- package/dist/file-history-disclosure.d.ts +2 -2
- package/dist/file-history-disclosure.js +1 -0
- package/dist/fleet/drain-entry.d.ts +17 -10
- package/dist/fleet/drain-entry.js +1 -1
- package/dist/fleet/fleet-bus.d.ts +21 -3
- package/dist/fleet/fleet-bus.js +35 -25
- package/dist/fleet/fleet-reconciler.js +2 -2
- package/dist/fleet/serving-lease.js +6 -7
- package/dist/fleet-client.js +3 -3
- package/dist/fleet-lease.d.ts +0 -1
- package/dist/fleet-lease.js +4 -5
- package/dist/history-anchor.d.ts +42 -0
- package/dist/history-anchor.js +34 -0
- package/dist/hitl-delivery.d.ts +90 -0
- package/dist/hitl-delivery.js +98 -0
- package/dist/hooks/classic-stations.d.ts +8 -11
- package/dist/hooks/classic-stations.js +0 -7
- package/dist/hooks/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +119 -65
- package/dist/hooks/hook-runner.js +415 -217
- package/dist/host-lsp-manager.d.ts +22 -8
- package/dist/host-lsp-manager.js +4 -1
- package/dist/http/active-run-conflict.d.ts +2 -43
- package/dist/http/active-run-conflict.js +3 -7
- package/dist/http/admission.d.ts +4 -18
- package/dist/http/admission.js +75 -78
- package/dist/http/approval-sweeps.d.ts +5 -8
- package/dist/http/approval-sweeps.js +55 -30
- package/dist/http/caller-trust.d.ts +8 -10
- package/dist/http/caller-trust.js +1 -2
- package/dist/http/checkpoint-ctx.d.ts +17 -0
- package/dist/http/checkpoint-ctx.js +6 -0
- package/dist/http/claim-heartbeat.d.ts +49 -0
- package/dist/http/claim-heartbeat.js +46 -0
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/claimed-run.d.ts +4 -3
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +77 -31
- package/dist/http/durable-run-leg.d.ts +3 -3
- package/dist/http/durable-run-leg.js +18 -12
- package/dist/http/execution-context.d.ts +18 -42
- package/dist/http/execution-context.js +11 -5
- package/dist/http/health-reader.d.ts +36 -0
- package/dist/http/health-reader.js +21 -0
- package/dist/http/health-self-report.d.ts +9 -9
- package/dist/http/health-self-report.js +4 -4
- package/dist/http/idempotency.d.ts +9 -5
- package/dist/http/idempotency.js +4 -4
- package/dist/http/memory-compliance-failure-reply.d.ts +15 -16
- package/dist/http/memory-compliance-failure-reply.js +7 -2
- package/dist/http/memory-face-fault-reply.d.ts +67 -0
- package/dist/http/memory-face-fault-reply.js +71 -0
- package/dist/http/memory-store-refusal-reply.d.ts +3 -3
- package/dist/http/memory-store-refusal-reply.js +6 -0
- package/dist/http/owner-access.d.ts +391 -56
- package/dist/http/owner-access.js +372 -33
- package/dist/http/principal-gate.d.ts +26 -94
- package/dist/http/principal-gate.js +24 -81
- package/dist/http/refusal-body.d.ts +35 -2
- package/dist/http/refusal-body.js +34 -0
- package/dist/http/request-guards.d.ts +10 -14
- package/dist/http/request-guards.js +34 -68
- package/dist/http/resume-composition.d.ts +37 -0
- package/dist/http/resume-composition.js +18 -0
- package/dist/http/resume-ctx-read.d.ts +35 -12
- package/dist/http/resume-ctx-read.js +25 -6
- package/dist/http/resume-legs.d.ts +24 -24
- package/dist/http/resume-legs.js +260 -171
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/rewind-files-reply.d.ts +34 -0
- package/dist/http/rewind-files-reply.js +36 -0
- package/dist/http/route-ctx.d.ts +56 -47
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +58 -37
- package/dist/http/routes/admin-config-refresh.js +2 -2
- package/dist/http/routes/admin-drain.js +2 -2
- package/dist/http/routes/admin-memory-optout.js +4 -3
- package/dist/http/routes/adoption.d.ts +3 -0
- package/dist/http/routes/adoption.js +17 -10
- package/dist/http/routes/agents-roster.js +13 -7
- package/dist/http/routes/approvals-assistant.js +73 -88
- package/dist/http/routes/attachments.js +2 -2
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +9 -17
- package/dist/http/routes/capabilities.js +23 -20
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.d.ts +3 -3
- package/dist/http/routes/devices.js +5 -5
- package/dist/http/routes/diagnostics.d.ts +27 -3
- package/dist/http/routes/diagnostics.js +27 -21
- package/dist/http/routes/engine.js +2 -2
- package/dist/http/routes/fleet.js +5 -3
- package/dist/http/routes/images.js +10 -6
- package/dist/http/routes/leader.d.ts +7 -2
- package/dist/http/routes/leader.js +12 -3
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +7 -15
- package/dist/http/routes/memory-bundle.js +4 -7
- package/dist/http/routes/memory-compliance.js +4 -4
- package/dist/http/routes/memory-consolidation.js +6 -9
- package/dist/http/routes/memory-origin.d.ts +3 -1
- package/dist/http/routes/memory-origin.js +7 -8
- package/dist/http/routes/memory-policy.js +17 -12
- package/dist/http/routes/notify-wake.js +12 -20
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/principal-inbox.d.ts +1 -1
- package/dist/http/routes/principal-inbox.js +2 -2
- package/dist/http/routes/projects.d.ts +70 -0
- package/dist/http/routes/projects.js +87 -0
- package/dist/http/routes/retention-ops.js +6 -9
- package/dist/http/routes/rules.js +50 -7
- package/dist/http/routes/run-memory-capture.d.ts +2 -2
- package/dist/http/routes/run-memory-capture.js +6 -12
- package/dist/http/routes/run-permission-mode.d.ts +2 -2
- package/dist/http/routes/run-permission-mode.js +10 -17
- package/dist/http/routes/runs.js +148 -233
- package/dist/http/routes/session-memory-sync.d.ts +2 -2
- package/dist/http/routes/session-memory-sync.js +7 -13
- package/dist/http/routes/session-sync.d.ts +4 -2
- package/dist/http/routes/session-sync.js +48 -30
- package/dist/http/routes/sessions-list.d.ts +3 -3
- package/dist/http/routes/sessions-list.js +9 -9
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +177 -112
- package/dist/http/routes/shared-memory.js +6 -6
- package/dist/http/routes/side-query.js +2 -2
- package/dist/http/routes/tasks.js +144 -122
- package/dist/http/routes/trace-usage.d.ts +0 -12
- package/dist/http/routes/trace-usage.js +40 -46
- package/dist/http/routes/workflows.d.ts +39 -4
- package/dist/http/routes/workflows.js +42 -14
- package/dist/http/run-concurrency-cap.d.ts +20 -12
- package/dist/http/run-concurrency-cap.js +39 -26
- package/dist/http/run-read-face.d.ts +3 -5
- package/dist/http/run-read-face.js +8 -13
- package/dist/http/send.d.ts +12 -3
- package/dist/http/send.js +42 -6
- package/dist/http/server.d.ts +63 -50
- package/dist/http/server.js +52 -16
- package/dist/http/sse-log.d.ts +17 -10
- package/dist/http/sse-log.js +7 -7
- package/dist/http/stored-body-replay.d.ts +17 -3
- package/dist/http/stored-body-replay.js +11 -2
- package/dist/http/submit-ctx.d.ts +16 -8
- package/dist/http/submit-ctx.js +6 -2
- package/dist/http/submit-replay.d.ts +19 -6
- package/dist/http/submit-replay.js +18 -6
- package/dist/http/sync-submit-body.d.ts +3 -4
- package/dist/http/sync-submit-body.js +4 -5
- package/dist/http/wire-types.d.ts +23 -13
- package/dist/identity-source.d.ts +36 -5
- package/dist/identity-source.js +27 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- package/dist/key-resolver.d.ts +32 -0
- package/dist/key-resolver.js +23 -9
- package/dist/leader/diffup.js +2 -1
- package/dist/leader/endpoint.d.ts +26 -5
- package/dist/leader/endpoint.js +154 -14
- package/dist/leader/fanout.d.ts +3 -0
- package/dist/leader/fanout.js +78 -63
- package/dist/leader/leader.d.ts +16 -0
- package/dist/leader/leader.js +43 -3
- package/dist/leader/merge.d.ts +9 -1
- package/dist/leader/merge.js +16 -1
- package/dist/leader/repair-wire.js +1 -1
- package/dist/leader/wire.d.ts +36 -3
- package/dist/leader/wire.js +59 -18
- package/dist/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/memory-embedder-reembed.d.ts +38 -0
- package/dist/memory-embedder-reembed.js +20 -0
- package/dist/memory-incident-sink.d.ts +0 -28
- package/dist/memory-incident-sink.js +5 -0
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-scope.d.ts +31 -4
- package/dist/memory-scope.js +65 -16
- package/dist/memory-store-refusal.d.ts +20 -4
- package/dist/memory-store-refusal.js +1 -1
- package/dist/memory-sync-client.d.ts +5 -2
- package/dist/memory-sync-client.js +19 -14
- package/dist/memory-sync.js +1 -1
- package/dist/model-compat.d.ts +51 -28
- package/dist/model-compat.js +55 -23
- package/dist/model-context-window.d.ts +18 -0
- package/dist/model-context-window.js +2 -0
- package/dist/model-entry-headers.d.ts +46 -4
- package/dist/model-entry-headers.js +2 -2
- package/dist/model-entry-refusal.d.ts +46 -17
- package/dist/model-entry-refusal.js +47 -27
- package/dist/model-plane-face.d.ts +19 -11
- package/dist/model-plane-face.js +9 -1
- package/dist/model-plane-probe.d.ts +2 -0
- package/dist/model-plane-probe.js +17 -0
- package/dist/model-provider.d.ts +3 -3
- package/dist/model-route-endpoint.d.ts +9 -5
- package/dist/model-route-endpoint.js +29 -7
- package/dist/model-select.d.ts +16 -0
- package/dist/model-select.js +4 -0
- package/dist/mountinfo.d.ts +37 -0
- package/dist/mountinfo.js +47 -0
- package/dist/namespaced-rule-name.d.ts +28 -2
- package/dist/namespaced-rule-name.js +10 -1
- package/dist/net-address.d.ts +1 -1
- package/dist/observability/corrupt-read-seat.d.ts +4 -4
- package/dist/observability/corrupt-read-seat.js +5 -3
- package/dist/observability/fail-open.d.ts +75 -47
- package/dist/observability/fail-open.js +77 -47
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +5 -4
- package/dist/observability/otel-exporter.js +2 -1
- package/dist/observability/principal-context.d.ts +14 -7
- package/dist/observability/principal-context.js +8 -3
- package/dist/observability/run-terminal.d.ts +7 -1
- package/dist/observability/run-terminal.js +5 -2
- package/dist/observability/secret-env-scrub.d.ts +30 -4
- package/dist/observability/secret-env-scrub.js +15 -3
- package/dist/orchestration/hardened-vm-runner.d.ts +1 -0
- package/dist/orchestration/hardened-vm-runner.js +11 -5
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +0 -14
- package/dist/orchestration/hardened-vm-worker-runner.js +5 -0
- package/dist/orchestration/hardened-vm-worker.js +2 -1
- package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
- package/dist/orchestration/workflow-agent-session-index.js +1 -6
- package/dist/orchestration/workflow-completion-inbox.d.ts +29 -9
- package/dist/orchestration/workflow-completion-inbox.js +65 -46
- package/dist/org-delivery-gate.d.ts +5 -4
- package/dist/org-delivery-gate.js +7 -6
- package/dist/org-memory-admission.d.ts +5 -2
- package/dist/org-memory-admission.js +25 -10
- package/dist/outbound-dispatcher.d.ts +1 -1
- package/dist/outbound-dispatcher.js +6 -12
- package/dist/owner-brands.d.ts +81 -0
- package/dist/owner-brands.js +42 -0
- package/dist/owner-faces.d.ts +531 -0
- package/dist/owner-faces.js +126 -0
- package/dist/parked-decide.d.ts +100 -31
- package/dist/parked-decide.js +162 -48
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +6 -8
- package/dist/peer-directory.js +3 -2
- package/dist/permission-rule-vocab.d.ts +53 -8
- package/dist/permission-rule-vocab.js +30 -2
- package/dist/plugins/adoption-log-sql.d.ts +0 -22
- package/dist/plugins/adoption-log-sql.js +5 -3
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.d.ts +7 -0
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.js +17 -0
- package/dist/plugins/approval-ask-store-file.d.ts +28 -9
- package/dist/plugins/approval-ask-store-file.js +74 -18
- package/dist/plugins/approval-ask-store-memory.d.ts +17 -7
- package/dist/plugins/approval-ask-store-memory.js +35 -12
- package/dist/plugins/approval-ask-store-sql.d.ts +42 -20
- package/dist/plugins/approval-ask-store-sql.js +44 -11
- package/dist/plugins/approval-exemption-skill-m46.d.ts +20 -0
- package/dist/plugins/approval-exemption-skill-m46.js +25 -0
- package/dist/plugins/approval-exemption-store.d.ts +6 -1
- package/dist/plugins/approval-exemption-store.js +14 -0
- package/dist/plugins/approval-nonce-store.d.ts +39 -12
- package/dist/plugins/approval-nonce-store.js +72 -23
- package/dist/plugins/blob-backend.d.ts +40 -195
- package/dist/plugins/blob-backend.js +41 -234
- package/dist/plugins/caching-session-store.d.ts +22 -5
- package/dist/plugins/caching-session-store.js +43 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +33 -6
- package/dist/plugins/checkpoint-index-columns.js +39 -3
- package/dist/plugins/checkpoint-store-face.d.ts +84 -11
- package/dist/plugins/checkpoint-store-face.js +18 -1
- package/dist/plugins/device-store-sql.d.ts +2 -2
- package/dist/plugins/device-store-sql.js +6 -10
- package/dist/plugins/ensure-index.d.ts +13 -1
- package/dist/plugins/ensure-index.js +154 -21
- package/dist/plugins/ensure-schema-lock-policy.d.ts +0 -15
- package/dist/plugins/ensure-schema-lock-policy.js +3 -2
- package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
- package/dist/plugins/execution-lane-rename-m40.js +10 -0
- package/dist/plugins/execution-placement-sql.d.ts +63 -88
- package/dist/plugins/execution-placement-sql.js +94 -54
- package/dist/plugins/file-run-store.d.ts +89 -35
- package/dist/plugins/file-run-store.js +197 -142
- package/dist/plugins/host-platform.d.ts +24 -3
- package/dist/plugins/host-platform.js +15 -1
- package/dist/plugins/image-bake-store-sql.js +2 -0
- package/dist/plugins/imported-layer-root-retirement.d.ts +19 -10
- package/dist/plugins/imported-layer-root-retirement.js +4 -8
- package/dist/plugins/inbox-payload-column.d.ts +14 -0
- package/dist/plugins/inbox-payload-column.js +13 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +1 -3
- package/dist/plugins/k8s-pod-reaper.js +0 -1
- package/dist/plugins/leader-run-store-sql.d.ts +22 -0
- package/dist/plugins/leader-run-store-sql.js +34 -4
- package/dist/plugins/local-checkpoint-store.d.ts +63 -23
- package/dist/plugins/local-checkpoint-store.js +204 -81
- package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
- package/dist/plugins/local-data-dir-modes-m39.js +183 -0
- package/dist/plugins/local-docker-capacity.d.ts +93 -0
- package/dist/plugins/local-docker-capacity.js +194 -0
- package/dist/plugins/local-docker-reaper.d.ts +92 -0
- package/dist/plugins/local-docker-reaper.js +102 -0
- package/dist/plugins/local-engine-high-water.d.ts +13 -0
- package/dist/plugins/local-engine-high-water.js +62 -0
- package/dist/plugins/local-session-store.d.ts +442 -143
- package/dist/plugins/local-session-store.js +941 -289
- package/dist/plugins/local-session-window.d.ts +3 -2
- package/dist/plugins/local-session-window.js +3 -2
- package/dist/plugins/local-sidecar-quarantine.js +3 -2
- package/dist/plugins/local-task-attachment-store.d.ts +20 -1
- package/dist/plugins/local-task-attachment-store.js +32 -12
- package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
- package/dist/plugins/memory-embedder-fingerprint.js +52 -12
- package/dist/plugins/memory-embedder.d.ts +1 -1
- package/dist/plugins/memory-embedder.js +11 -9
- package/dist/plugins/memory-engine-pg.d.ts +7 -5
- package/dist/plugins/memory-engine-pg.js +18 -9
- package/dist/plugins/memory-engine-sql-apply.d.ts +21 -8
- package/dist/plugins/memory-engine-sql-apply.js +7 -9
- package/dist/plugins/memory-engine-tidb.d.ts +12 -7
- package/dist/plugins/memory-engine-tidb.js +18 -10
- package/dist/plugins/memory-optout-grant-store-sql.d.ts +1 -1
- package/dist/plugins/memory-optout-grant-store-sql.js +3 -3
- package/dist/plugins/memory-run-store.d.ts +39 -27
- package/dist/plugins/memory-run-store.js +72 -70
- package/dist/plugins/one-time-migration-marker.d.ts +10 -0
- package/dist/plugins/one-time-migration-marker.js +7 -0
- package/dist/plugins/one-time-migrations.d.ts +325 -74
- package/dist/plugins/one-time-migrations.js +705 -230
- package/dist/plugins/org-delivery-quota-store.js +2 -1
- package/dist/plugins/owner-only-file-mode.d.ts +29 -0
- package/dist/plugins/owner-only-file-mode.js +141 -0
- package/dist/plugins/permission-rule-store-file.d.ts +11 -11
- package/dist/plugins/permission-rule-store-file.js +14 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +4 -63
- package/dist/plugins/permission-rule-store-sql.js +6 -86
- package/dist/plugins/pg-pool.d.ts +3 -32
- package/dist/plugins/pg-pool.js +27 -11
- package/dist/plugins/release-version.d.ts +20 -0
- package/dist/plugins/release-version.js +28 -0
- package/dist/plugins/remote-env-adb.d.ts +20 -4
- package/dist/plugins/remote-env-adb.js +39 -11
- package/dist/plugins/remote-env-e2b.d.ts +19 -28
- package/dist/plugins/remote-env-e2b.js +40 -29
- package/dist/plugins/remote-env-host.d.ts +11 -10
- package/dist/plugins/remote-env-host.js +40 -27
- package/dist/plugins/remote-env-k8s.d.ts +45 -47
- package/dist/plugins/remote-env-k8s.js +122 -62
- package/dist/plugins/remote-env-local-docker.d.ts +152 -15
- package/dist/plugins/remote-env-local-docker.js +370 -75
- package/dist/plugins/remote-env-ssh.d.ts +8 -2
- package/dist/plugins/remote-env-ssh.js +26 -24
- package/dist/plugins/remote-scratchpad.js +4 -0
- package/dist/plugins/remote-shell.d.ts +59 -30
- package/dist/plugins/remote-shell.js +175 -62
- package/dist/plugins/retention-declaration.d.ts +37 -0
- package/dist/plugins/retention-declaration.js +9 -0
- package/dist/plugins/retention-deployment.d.ts +158 -0
- package/dist/plugins/retention-deployment.js +119 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
- package/dist/plugins/retention-lane-store-sql.js +103 -1
- package/dist/plugins/retention-sql.d.ts +29 -0
- package/dist/plugins/retention-sql.js +8 -0
- package/dist/plugins/run-preview-m45.d.ts +11 -0
- package/dist/plugins/run-preview-m45.js +19 -0
- package/dist/plugins/run-store-sql.d.ts +56 -68
- package/dist/plugins/run-store-sql.js +127 -116
- package/dist/plugins/s3-answer.d.ts +2 -1
- package/dist/plugins/sandbox-reaper.d.ts +26 -0
- package/dist/plugins/sandbox-reaper.js +2 -0
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +54 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +55 -0
- package/dist/plugins/scheduler-support.d.ts +16 -1
- package/dist/plugins/scheduler-support.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +42 -15
- package/dist/plugins/schema-consistency.js +213 -13
- package/dist/plugins/schema-drift-sentence.d.ts +4 -1
- package/dist/plugins/schema-drift-sentence.js +4 -4
- package/dist/plugins/schema-ensure-legs.d.ts +10 -1
- package/dist/plugins/schema-ensure-legs.js +12 -2
- package/dist/plugins/schema-indexes.js +3 -0
- package/dist/plugins/schema-live-columns.d.ts +14 -5
- package/dist/plugins/schema-live-columns.js +10 -10
- package/dist/plugins/send-user-file.js +2 -1
- package/dist/plugins/session-birth.d.ts +37 -0
- package/dist/plugins/session-birth.js +38 -0
- package/dist/plugins/session-epoch-anchor.d.ts +40 -12
- package/dist/plugins/session-epoch-anchor.js +33 -11
- package/dist/plugins/session-ext-table.d.ts +98 -0
- package/dist/plugins/session-ext-table.js +134 -0
- package/dist/plugins/session-fork.d.ts +16 -2
- package/dist/plugins/session-fork.js +3 -0
- package/dist/plugins/session-ownership.d.ts +1 -1
- package/dist/plugins/session-placement.d.ts +22 -16
- package/dist/plugins/session-placement.js +15 -12
- package/dist/plugins/session-row-sql.d.ts +20 -7
- package/dist/plugins/session-row-sql.js +16 -8
- package/dist/plugins/session-run-rollup.d.ts +29 -0
- package/dist/plugins/session-run-rollup.js +40 -0
- package/dist/plugins/session-store-sql.d.ts +157 -0
- package/dist/plugins/session-store-sql.js +398 -0
- package/dist/plugins/session-withdraw-sql.d.ts +36 -0
- package/dist/plugins/session-withdraw-sql.js +42 -0
- package/dist/plugins/session-workspace-cell.d.ts +2 -2
- package/dist/plugins/session-workspace-cell.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +10 -69
- package/dist/plugins/shared-memory-store-sql.js +15 -14
- package/dist/plugins/shell-sentinel-owner-m48.d.ts +20 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +3 -0
- package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
- package/dist/plugins/snapshot-bucket-presence.js +1 -1
- package/dist/plugins/sql-driver.d.ts +24 -8
- package/dist/plugins/sql-driver.js +43 -9
- package/dist/plugins/sql-errors.d.ts +35 -5
- package/dist/plugins/sql-errors.js +55 -3
- package/dist/plugins/sql-json-column.d.ts +8 -7
- package/dist/plugins/sql-json-column.js +10 -6
- package/dist/plugins/store-backend.d.ts +114 -18
- package/dist/plugins/store-backend.js +340 -87
- package/dist/plugins/store-contracts.d.ts +97 -30
- package/dist/plugins/store-contracts.js +23 -1
- package/dist/plugins/store-fault.d.ts +28 -2
- package/dist/plugins/store-fault.js +20 -2
- package/dist/plugins/task-attachment-store.d.ts +21 -11
- package/dist/plugins/task-attachment-store.js +37 -19
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/text-column-capacity.d.ts +21 -0
- package/dist/plugins/text-column-capacity.js +5 -0
- package/dist/plugins/tidb-pool.d.ts +3 -2
- package/dist/plugins/tidb-pool.js +42 -39
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- package/dist/plugins/web-search.js +5 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +6 -1
- package/dist/plugins/workflow-run-store-sql.js +11 -5
- package/dist/principal-jwt.d.ts +4 -4
- package/dist/principal-jwt.js +20 -5
- package/dist/principal-shape.d.ts +41 -0
- package/dist/principal-shape.js +19 -0
- package/dist/question.d.ts +13 -23
- package/dist/question.js +21 -39
- package/dist/read-face-posture.d.ts +6 -6
- package/dist/read-face-posture.js +2 -2
- package/dist/request-declaration-refusal.d.ts +35 -12
- package/dist/request-declaration-refusal.js +21 -9
- package/dist/request-form.d.ts +58 -0
- package/dist/request-form.js +72 -0
- package/dist/request-image-urls.d.ts +8 -2
- package/dist/request-image-urls.js +2 -1
- package/dist/request-images.d.ts +20 -0
- package/dist/request-images.js +59 -0
- package/dist/request-key-closure.d.ts +6 -7
- package/dist/request-key-closure.js +15 -2
- package/dist/request-value-closure.d.ts +5 -5
- package/dist/request-value-closure.js +1 -1
- package/dist/resource-suspend.d.ts +7 -16
- package/dist/resource-suspend.js +1 -1
- package/dist/retired-name-host-notice.d.ts +21 -0
- package/dist/retired-name-host-notice.js +12 -0
- package/dist/rule-entry-list.d.ts +2 -2
- package/dist/rule-entry-list.js +3 -4
- package/dist/rule-issue-reading.d.ts +58 -0
- package/dist/rule-issue-reading.js +14 -0
- package/dist/rules-consent.d.ts +46 -16
- package/dist/rules-consent.js +102 -53
- package/dist/run-acceptance.d.ts +3 -1
- package/dist/run-acceptance.js +3 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +109 -93
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +73 -44
- package/dist/runs.js +65 -43
- package/dist/runtime-caps-resolver.d.ts +36 -14
- package/dist/runtime-caps-resolver.js +31 -14
- package/dist/runtime-governance.d.ts +2 -2
- package/dist/runtime-governance.js +5 -3
- package/dist/sealed-key-layout.d.ts +12 -6
- package/dist/sealed-key-layout.js +5 -1
- package/dist/sealed-key.d.ts +12 -2
- package/dist/sealed-key.js +116 -26
- package/dist/security.d.ts +133 -161
- package/dist/security.js +163 -59
- package/dist/sema-config-dir.d.ts +20 -0
- package/dist/sema-config-dir.js +27 -2
- package/dist/server-secret-env.d.ts +23 -5
- package/dist/server-secret-env.js +14 -4
- package/dist/service-version.d.ts +2 -1
- package/dist/service-version.js +2 -2
- package/dist/session-children-retire.d.ts +7 -5
- package/dist/session-children-retire.js +7 -2
- package/dist/session-deletion.d.ts +88 -0
- package/dist/session-deletion.js +8 -0
- package/dist/session-erase.d.ts +145 -0
- package/dist/session-erase.js +115 -0
- package/dist/session-error-wire.d.ts +6 -6
- package/dist/session-error-wire.js +1 -1
- package/dist/session-incarnation.d.ts +60 -10
- package/dist/session-incarnation.js +19 -2
- package/dist/session-policy-wire.d.ts +6 -3
- package/dist/session-policy-wire.js +11 -1
- package/dist/session-resident-background.d.ts +29 -47
- package/dist/session-resident-background.js +77 -8
- package/dist/session-row.d.ts +3 -2
- package/dist/session-rules-seat.d.ts +12 -0
- package/dist/session-rules-seat.js +19 -0
- package/dist/session-sync-kernel.d.ts +1 -1
- package/dist/session-titler.d.ts +7 -15
- package/dist/session-titler.js +1 -1
- package/dist/session-workspace.d.ts +11 -2
- package/dist/session-workspace.js +5 -0
- package/dist/sighup-idle.d.ts +1 -1
- package/dist/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-posture.d.ts +138 -21
- package/dist/store-posture.js +188 -3
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +21 -16
- package/dist/stores-sql/background-agent-store-sql.d.ts +11 -2
- package/dist/stores-sql/background-agent-store-sql.js +73 -20
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/stores-sql/checkpoint-store-sql.d.ts +34 -29
- package/dist/stores-sql/checkpoint-store-sql.js +86 -71
- package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
- package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
- package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
- package/dist/stores-sql/mailbox-store-sql.js +31 -32
- package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +30 -81
- package/dist/{plugins → stores-sql}/pg-session-storage.js +123 -244
- package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +197 -223
- package/dist/{plugins → stores-sql}/retention-store-sql.js +148 -207
- package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
- package/dist/stores-sql/session-policy-store-sql.d.ts +33 -11
- package/dist/stores-sql/session-policy-store-sql.js +44 -36
- package/dist/stores-sql/session-write-hooks.d.ts +65 -0
- package/dist/stores-sql/session-write-hooks.js +2 -0
- package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +14 -15
- package/dist/{plugins → stores-sql}/tidb-session-storage.js +22 -28
- package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +67 -138
- package/dist/{plugins → stores-sql}/tidb-session-store.js +130 -200
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +1 -1
- package/dist/stores-sql/windowed-session-storage.d.ts +61 -0
- package/dist/stores-sql/windowed-session-storage.js +70 -0
- package/dist/submission-exit.d.ts +50 -0
- package/dist/submission-exit.js +108 -0
- package/dist/task-a2a.d.ts +7 -1
- package/dist/task-a2a.js +18 -17
- package/dist/task-cwd.d.ts +31 -3
- package/dist/task-cwd.js +25 -1
- package/dist/task-mcp.d.ts +11 -3
- package/dist/task-mcp.js +16 -19
- package/dist/task-settings.d.ts +23 -14
- package/dist/task-settings.js +35 -13
- package/dist/terminal.d.ts +25 -43
- package/dist/terminal.js +31 -11
- package/dist/tool-approval.d.ts +152 -137
- package/dist/tool-approval.js +199 -199
- package/dist/trace/core-keyset-guard.d.ts +22 -9
- package/dist/trace/core-vocab-wire.d.ts +95 -0
- package/dist/trace/core-vocab-wire.js +15 -0
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +52 -4
- package/dist/trace/exit-seat.js +43 -36
- package/dist/trace/extension-call-face.d.ts +3 -2
- package/dist/trace/extension-call-face.js +3 -1
- package/dist/trace/ledger-events.d.ts +4 -7
- package/dist/trace/ledger-sink.d.ts +1 -30
- package/dist/trace/ledger-sink.js +0 -11
- package/dist/trace/model-segment.d.ts +5 -5
- package/dist/trace/model-segment.js +5 -5
- package/dist/trace/project.d.ts +88 -58
- package/dist/trace/project.js +64 -28
- package/dist/trace/redact.d.ts +124 -28
- package/dist/trace/redact.js +936 -328
- package/dist/trace/self-minted-wire.d.ts +750 -29
- package/dist/trace/self-minted-wire.js +262 -25
- package/dist/trace/sema-provenance.d.ts +45 -41
- package/dist/trace/sema-provenance.js +81 -10
- package/dist/trace/task-notification-facets.d.ts +70 -2
- package/dist/trace/task-notification-facets.js +71 -1
- package/dist/trace/wire-projection-faces.d.ts +43 -8
- package/dist/trace/wire-projection-faces.js +28 -3
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -0
- package/dist/upstream-body.d.ts +23 -0
- package/dist/upstream-body.js +16 -0
- package/dist/url-refusal.d.ts +3 -3
- package/dist/url-refusal.js +11 -4
- package/dist/user-authored-text.d.ts +1 -1
- package/dist/user-input-ledger.d.ts +7 -8
- package/dist/user-input-ledger.js +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +6 -3
- package/dist/web-admin-client/apply-effective.js +33 -40
- package/dist/web-admin-client/apply-ledger.d.ts +16 -7
- package/dist/web-admin-client/apply-ledger.js +5 -2
- package/dist/web-admin-client/candidate-gate.d.ts +35 -3
- package/dist/web-admin-client/candidate-gate.js +53 -5
- package/dist/web-admin-client/center-request.d.ts +6 -3
- package/dist/web-admin-client/center-request.js +17 -16
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +1 -2
- package/dist/web-admin-client/entry-metadata.d.ts +8 -0
- package/dist/web-admin-client/entry-metadata.js +13 -0
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/http-client.d.ts +2 -1
- package/dist/web-admin-client/http-client.js +40 -13
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/mcp-revocation.js +2 -1
- package/dist/web-admin-client/read-warnings.d.ts +1 -0
- package/dist/web-admin-client/read-warnings.js +1 -0
- package/dist/web-admin-client/restart-signal.js +13 -6
- package/dist/web-admin-client/skills-mcp.d.ts +22 -8
- package/dist/web-admin-client/skills-mcp.js +26 -21
- package/dist/web-admin-client/types.d.ts +35 -51
- package/dist/workspace-space.d.ts +3 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
- package/package.json +16 -12
- package/scripts/drain-check-local.mjs +118 -173
- package/scripts/drain-check.mysql.sql +20 -16
- package/scripts/drain-check.pg.sql +20 -16
- package/wire-changes/server@7.147.0.json +813 -0
- package/wire-changes/server@7.148.0.json +1517 -0
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +0 -25
- package/dist/http/memory-control-plane-corrupt-reply.js +0 -19
- package/dist/http/memory-layer-reply.d.ts +0 -30
- package/dist/http/memory-layer-reply.js +0 -24
- package/dist/lsp/e2b-bridge.d.ts +0 -57
- package/dist/lsp/e2b-bridge.js +0 -139
- package/dist/lsp/e2b-manager.d.ts +0 -93
- package/dist/lsp/e2b-manager.js +0 -178
- package/dist/lsp/lsp-frames.d.ts +0 -14
- package/dist/lsp/lsp-frames.js +0 -25
- package/dist/lsp/manager.d.ts +0 -129
- package/dist/lsp/manager.js +0 -127
- package/dist/lsp/types.d.ts +0 -12
- package/dist/lsp/types.js +0 -2
- package/dist/lsp/ws-transport.d.ts +0 -40
- package/dist/lsp/ws-transport.js +0 -210
package/dist/http/resume-legs.js
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import { redactErrorMessage, redactHead } from "../observability/run-terminal.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import { uuidv7, resumeWithVerification, CheckpointError, judgeCheckpointRow, defaultTaskRegistry, taskNotificationDedupKey, validatePendingSteer, GLOBAL_USAGE_KEY } from "@sema-agent/core";
|
|
4
|
-
import { decideParkedAgent, denyWorkflowParkForked, denyWorkflowParksUnreadable, findParkOrigin, heldWorkflowParkDecisions, planWorkflowParkedDecide } from "../parked-decide.js";
|
|
3
|
+
import { uuidv7, resumeWithVerification, resumeCascade, CheckpointError, judgeCheckpointRow, defaultTaskRegistry, taskNotificationDedupKey, validatePendingSteer, GLOBAL_USAGE_KEY } from "@sema-agent/core";
|
|
4
|
+
import { decideParkedAgent, deliverToHoldingRun, denyWorkflowParkForked, denyWorkflowParksUnreadable, findParkOrigin, heldWorkflowParkDecisions, planWorkflowParkedDecide } from "../parked-decide.js";
|
|
5
5
|
import { parkDecisionFingerprint } from "../orchestration/workflow-park-decision.js";
|
|
6
6
|
import { headReadOf } from "../session-incarnation.js";
|
|
7
7
|
import { createSessionWorkspaceRecorder, sessionWorkspaceStoreOf } from "../session-workspace.js";
|
|
8
8
|
const DELIVERY_NOT_RECORDED = "workflow park decide: this delivery no longer holds the host session (its claim was released) — the decision was not recorded and this delivery was not started";
|
|
9
|
-
import { HttpError, decodeCheckpointScope, CHECKPOINT_PUBLIC_SCOPE } from "../security.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { HttpError, checkpointPartsOf, decodeCheckpointScope, scopeCellOf, CHECKPOINT_PUBLIC_SCOPE } from "../security.js";
|
|
10
|
+
import { keyAdmits } from "../owner-faces.js";
|
|
11
|
+
import { personOf } from "../owner-brands.js";
|
|
12
|
+
import { recoveredSubject } from "../owner-faces.js";
|
|
13
|
+
import { beatRunHeartbeat, graftParkToolCallId, parkToolCallId, TurnAnchorCapture, HEARTBEAT_MS, markChildrenStoppedByUserOnAbort, voidHeldParkCard } from "../runs.js";
|
|
14
|
+
import { atHostBoundary, failureCodeOf, nestedPauseOf, sealResultForExit, outwardPlane, outwardThrownMessage } from "../terminal.js";
|
|
12
15
|
import { voidVerifierPauseCard } from "../verifier-pause-card.js";
|
|
13
16
|
import { buildCancelledLedgerRow, CARD_SETTLED_BY_CANCEL_MESSAGE, createRunAbort, mintCancelledResult, withCardSettledByCancelMessage } from "../run-cancel-context.js";
|
|
14
|
-
import { isTerminalRunStatus } from "../plugins/store-contracts.js";
|
|
17
|
+
import { isTerminalRunStatus, runProvenElsewhere } from "../plugins/store-contracts.js";
|
|
15
18
|
import { readTurnActivityMs, recordTurnActivity } from "../turn-activity.js";
|
|
16
19
|
import { recordResumeResourceWindow } from "../resource-window.js";
|
|
17
20
|
import { emitPendingWorkflowCompletions, taskNotificationInboxEntry, taskNotificationStreamKeyOf, NotifiedKeys } from "../orchestration/workflow-completion-inbox.js";
|
|
18
21
|
import { fleetRunPublisher, fleetRunLabels, fleetRunResiduals } from "../fleet/fleet-bus.js";
|
|
19
22
|
import { defaultSubagentTailBus } from "../fleet/subagent-tail-bus.js";
|
|
20
23
|
import { currentApprovalGateToken, currentGateFacesOf, sightsCurrentGate } from "../approval-gate-currency.js";
|
|
21
|
-
import { approverFacingArgs,
|
|
24
|
+
import { approverFacingArgs, declaredApprovalFrameFamilies, parkRowStandingAnswerFacts, resolveApprovalLeg, resolveStreamApprovalGate, standingAnswerDurablyRecordable } from "../tool-approval.js";
|
|
25
|
+
import { createHitlTransport } from "../hitl-delivery.js";
|
|
22
26
|
import { buildCheckpointAnchorHash } from "../approval-ask-audit-store.js";
|
|
23
27
|
import { APPROVAL_ENDING_CAUSES } from "../approval-deny-reasons.js";
|
|
24
28
|
import { serviceVersion } from "../service-version.js";
|
|
25
29
|
import { TERMINAL_PARK_GATE_KINDS, UnreadableCheckpointRowError } from "../plugins/checkpoint-store-face.js";
|
|
26
|
-
import {
|
|
30
|
+
import { withSubject } from "../observability/principal-context.js";
|
|
27
31
|
import { withModelReachScope } from "../model-reach-scope.js";
|
|
28
32
|
import { legFactsOf } from "../leg-facts.js";
|
|
29
33
|
import { createInstructionSelectionLeg } from "../instruction-selection.js";
|
|
30
|
-
import { modelTextEventData, appendParkRow, turnEndEventData, contextUsageEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, appendModelUsageDelta,
|
|
34
|
+
import { modelTextEventData, appendParkRow, turnEndEventData, contextUsageEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, appendModelUsageDelta, attachModelUsage, createPromptManifestSeat } from "../trace/project.js";
|
|
31
35
|
import { redactSecrets } from "../trace/redact.js";
|
|
32
36
|
import { buildRunObjectivePreview } from "../user-authored-text.js";
|
|
33
37
|
import { createForwardAppendFailedNote, createLedgerSink, createSerialLedgerAppend } from "../trace/ledger-sink.js";
|
|
@@ -35,7 +39,7 @@ import { registerEngineNoticeLeg } from "../trace/engine-notice-wire.js";
|
|
|
35
39
|
import { blockText, reasoningDeltaBytes, reasoningSegmentEventId } from "../trace/model-segment.js";
|
|
36
40
|
import { errorText } from "../observability/err-text.js";
|
|
37
41
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
38
|
-
import {
|
|
42
|
+
import { resumeCompositionOf } from "./resume-composition.js";
|
|
39
43
|
import { planReviewDecisionExitsPlan, storedBodyPermissionMode } from "../task-settings.js";
|
|
40
44
|
import { acceptedResumingReceipt, acceptedTaskIdOf } from "./route-ctx.js";
|
|
41
45
|
import { heldFor } from "../peer-seat.js";
|
|
@@ -46,23 +50,28 @@ import { createSessionsLocal } from "./routes/sessions.js";
|
|
|
46
50
|
import { createSessionSyncLocal } from "./routes/session-sync.js";
|
|
47
51
|
import { createImagesLocal } from "./routes/images.js";
|
|
48
52
|
import { createCapabilitiesLocal } from "./routes/capabilities.js";
|
|
49
|
-
import {
|
|
53
|
+
import { gatedSubject, explicitOperatorOk, runIdentityOf } from "./principal-gate.js";
|
|
50
54
|
import { buildActiveRunConflict, resumeEntryForGate } from "./active-run-conflict.js";
|
|
51
55
|
import { commitExecutionContext, isRootSessionGoneError, resolveExecutionContext, rootSessionAbsentAnswer, stampSpecRoot } from "./execution-context.js";
|
|
56
|
+
import { timeClaim } from "./claim-latency.js";
|
|
52
57
|
import { commitSessionInheritEnv } from "./session-inherit-env.js";
|
|
53
58
|
import { ASK_USER_QUESTION_TOOL_NAME, isApprovalGateKind, isEngineQuestionRow } from "../approval-content-kind.js";
|
|
54
59
|
import { deploymentListAsks } from "../approval.js";
|
|
55
60
|
import { isParkLedgerEventType } from "../trace/ledger-events.js";
|
|
56
|
-
import { readResumeCtx, resumeCtxCorruptAnswer, resumeCtxUnsealableAnswer } from "./resume-ctx-read.js";
|
|
61
|
+
import { readResumeCtx, resumeCtxCorruptAnswer, resumeCtxUnreadableAnswer, resumeCtxUnsealableAnswer, resumeStoreReadFailureOf } from "./resume-ctx-read.js";
|
|
57
62
|
import { objectiveWithheldIn } from "./submit-ctx.js";
|
|
58
|
-
import { buildCheckpointVersionKeys,
|
|
63
|
+
import { buildCheckpointVersionKeys, resumeAssemblyRefusalAnswer, resumeRefusalWithCard, sealCheckpointCtx, storedBodyReplayAnswer, storedBodyReplayLogFields, withPermissionModeRewritten } from "./checkpoint-ctx.js";
|
|
59
64
|
import { refusalBody, resumeRefusalFacts } from "./refusal-body.js";
|
|
60
65
|
import { storedBodyReplayRefusal } from "./stored-body-replay.js";
|
|
61
66
|
import { restateResumeCtx } from "./resume-restatement.js";
|
|
62
67
|
import { httpErrorRefusal } from "./send.js";
|
|
63
68
|
import { createRunAcceptance } from "../run-acceptance.js";
|
|
69
|
+
import { createSubmissionSeat } from "../submission-exit.js";
|
|
64
70
|
import { fieldConflictFacts } from "../field-conflict.js";
|
|
65
71
|
import { createSessionNotifyDoor } from "../session-notify-door.js";
|
|
72
|
+
function compositionUnlinkedAnswer() {
|
|
73
|
+
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context does not match this card — the run is a cascade but the card records no ladder rung, so the ladder cannot be continued" }) };
|
|
74
|
+
}
|
|
66
75
|
function legMayHaveReopenedCheckpoint(r) {
|
|
67
76
|
return r.terminal.kind === "failed" && nestedPauseOf(r.terminal) === undefined;
|
|
68
77
|
}
|
|
@@ -184,13 +193,13 @@ const WIRE_CODE_OF_DECISION_REFUSAL = {
|
|
|
184
193
|
[APPROVAL_ENDING_CAUSES.ANSWER_INVALID]: "resume_outcome_invalid",
|
|
185
194
|
[APPROVAL_ENDING_CAUSES.OUTCOME_CELL_INVALID]: "resume_outcome_invalid",
|
|
186
195
|
};
|
|
187
|
-
const UNCLASSIFIED_INVALID_OUTCOME_CODE = WIRE_CODE_OF_DECISION_REFUSAL[APPROVAL_ENDING_CAUSES.BINDING_CHANGED];
|
|
188
196
|
function decisionRefusalCauseOf(e, gate) {
|
|
189
|
-
if (
|
|
190
|
-
return
|
|
197
|
+
if (e.detail?.reason !== undefined)
|
|
198
|
+
return undefined;
|
|
191
199
|
const field = e.detail?.field;
|
|
192
|
-
|
|
193
|
-
|
|
200
|
+
if (field !== undefined)
|
|
201
|
+
return Object.hasOwn(CHECKPOINT_ERROR_FIELD_ROLE, field) ? FIELD_ROLE_CAUSE[CHECKPOINT_ERROR_FIELD_ROLE[field]] : undefined;
|
|
202
|
+
return gate === "policy_ask" ? undefined : APPROVAL_ENDING_CAUSES.OUTCOME_CELL_INVALID;
|
|
194
203
|
}
|
|
195
204
|
function notResumableAnswer() {
|
|
196
205
|
return { status: 409, body: refusalBody({ errorCode: "conflict.not_resumable", message: "run is not in a resumable (suspended) state (already resumed, decided, or expired)" }) };
|
|
@@ -208,14 +217,17 @@ function approvalStaleAnswer(facts) {
|
|
|
208
217
|
}),
|
|
209
218
|
};
|
|
210
219
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
function rowRefusalAnswer(verdict, diagnostic, ctx) {
|
|
221
|
+
const refusal = new CheckpointError(verdict.code, diagnostic === undefined ? verdict.sentence : `${verdict.sentence} Diagnostic: ${diagnostic}`, verdict.reason === undefined ? undefined : { reason: verdict.reason });
|
|
222
|
+
return checkpointRefusalAnswer(refusal, { gate: "policy_ask", retriable: resumeRefusalDisposition(refusal) === "retriable", versionKeys: refusalVersionKeys(refusal, ctx) });
|
|
223
|
+
}
|
|
224
|
+
export function rowReadRefusalAnswer(e) {
|
|
225
|
+
if (e instanceof UnreadableCheckpointRowError && e.rowVerdict.kind !== "ok")
|
|
226
|
+
return rowRefusalAnswer(e.rowVerdict, errorText(e), {});
|
|
227
|
+
return { status: 409, body: refusalBody({ errorCode: "conflict.checkpoint_unreadable", message: errorText(e) }) };
|
|
215
228
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
218
|
-
return (e instanceof UnreadableCheckpointRowError ? rowRefusalMessageOf(e.rowVerdict, text) : undefined) ?? text;
|
|
229
|
+
function refusalVersionKeys(e, ctx) {
|
|
230
|
+
return e.code === "checkpoint.unsupported_version" ? buildCheckpointVersionKeys(ctx.writerVersion, serviceVersion()) : {};
|
|
219
231
|
}
|
|
220
232
|
function acceptableFormFacts(detail) {
|
|
221
233
|
const rewritten = detail !== null && typeof detail === "object" ? detail.editRewritten : undefined;
|
|
@@ -231,7 +243,7 @@ export function checkpointRefusalAnswer(e, at) {
|
|
|
231
243
|
status: e.code === "checkpoint.not_found" ? 404 : 409,
|
|
232
244
|
body: refusalBody({
|
|
233
245
|
message: e.message,
|
|
234
|
-
errorCode:
|
|
246
|
+
errorCode: refusalCause === undefined ? e.code : WIRE_CODE_OF_DECISION_REFUSAL[refusalCause],
|
|
235
247
|
facts: {
|
|
236
248
|
...(at.taskId !== undefined ? { taskId: at.taskId } : {}),
|
|
237
249
|
...resumeRefusalFacts(detail),
|
|
@@ -250,11 +262,36 @@ export function decidedActionOf(binding) {
|
|
|
250
262
|
return missingKeys.length === 0 ? { action: { boundCallId: boundCallId, boundInputHash: boundInputHash } } : { missingKeys };
|
|
251
263
|
}
|
|
252
264
|
export function createResumeLegs(ctx) {
|
|
253
|
-
const { deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode,
|
|
265
|
+
const { deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode, prepareSpec, finalizeTaskResult, ownerCostQuotaDenied, ownerFleetLeaseDenied, usageWindowDenialFor } = ctx;
|
|
254
266
|
const ctxOpening = (sessionId) => ({ sessionId, opener: deps.checkpointCtxSealing });
|
|
255
|
-
const resumeFleetScope = (req, auth) => req ? (
|
|
256
|
-
|
|
267
|
+
const resumeFleetScope = (req, auth) => req ? (gatedSubject(req, deps.config) ?? "default") : (auth.subject ?? "default");
|
|
268
|
+
function createRememberIntent(sessionId, remember) {
|
|
269
|
+
let pending;
|
|
270
|
+
return {
|
|
271
|
+
laneCannotRecord: remember.laneCannotRecord,
|
|
272
|
+
record: async (grant) => {
|
|
273
|
+
if (grant.rememberableToolName !== null)
|
|
274
|
+
pending = { sessionId: grant.overrideSessionId ?? sessionId, toolName: grant.rememberableToolName };
|
|
275
|
+
},
|
|
276
|
+
settle: async (committed) => {
|
|
277
|
+
const store = deps.approvalExemptionStore;
|
|
278
|
+
if (!committed || pending === undefined || store === undefined)
|
|
279
|
+
return false;
|
|
280
|
+
try {
|
|
281
|
+
await store.grant(pending.sessionId, pending.toolName, remember.grantedBy);
|
|
282
|
+
deps.logger?.info?.("approval_exemption_granted", { sessionId: pending.sessionId, toolName: pending.toolName, grantedBy: remember.grantedBy });
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
catch (e) {
|
|
286
|
+
deps.logger?.warn?.("approval_exemption_grant_failed", { sessionId: pending.sessionId, toolName: pending.toolName, error: String(e).slice(0, 200) });
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async function resumeCheckpoint(sessionId, decision, reason, hostDecision, req, answer, binding, remember, acceptEarly, decider, restatement) {
|
|
257
293
|
const cs = deps.checkpointStore;
|
|
294
|
+
const intent = remember !== undefined ? createRememberIntent(sessionId, remember) : undefined;
|
|
258
295
|
const token = await currentApprovalGateToken(cs, sessionId);
|
|
259
296
|
if (binding.checkpointToken && !sightsCurrentGate({ face: "checkpointToken", value: binding.checkpointToken }, token ? { checkpointToken: token } : null)) {
|
|
260
297
|
let seenUnreadable = false;
|
|
@@ -278,8 +315,7 @@ export function createResumeLegs(ctx) {
|
|
|
278
315
|
return null;
|
|
279
316
|
});
|
|
280
317
|
const curPa = cur?.pendingAction;
|
|
281
|
-
const
|
|
282
|
-
const scopeOk = cur !== null && (decider.explicitOperator || curOwner === undefined || curOwner === decider.principal);
|
|
318
|
+
const scopeOk = cur != null && (await decisionRowAdmits(cs, token, decider, cur.scope));
|
|
283
319
|
if (cur && cur.sessionId === sessionId && !scopeOk) {
|
|
284
320
|
deps.logger?.info?.("approval_decide_no_pending", { sessionId, staleTokenEchoed: true, foreignCurrentSuppressed: true });
|
|
285
321
|
return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
|
|
@@ -299,9 +335,24 @@ export function createResumeLegs(ctx) {
|
|
|
299
335
|
return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
|
|
300
336
|
}
|
|
301
337
|
const cpPromise = cs.get(token);
|
|
302
|
-
const
|
|
338
|
+
const runSessionPromise = cs.hostSessionOfCard(token).then((id) => (typeof id === "string" ? { kind: "owned", id } : { kind: "unowned" }), (e) => ({ kind: "failed", failure: resumeStoreReadFailureOf(e) }));
|
|
339
|
+
const runCtxOf = async () => {
|
|
340
|
+
const owner = await runSessionPromise;
|
|
341
|
+
if (owner.kind === "unowned")
|
|
342
|
+
return undefined;
|
|
343
|
+
const read = owner.kind === "failed" ? owner.failure : await readResumeCtx(cs.getCtx(owner.id), ctxOpening(owner.id));
|
|
344
|
+
if (read.kind === "corrupt")
|
|
345
|
+
return { refusal: resumeCtxCorruptAnswer(read.where) };
|
|
346
|
+
if (read.kind === "unsealable")
|
|
347
|
+
return { refusal: resumeCtxUnsealableAnswer(read) };
|
|
348
|
+
if (read.kind === "unreadable")
|
|
349
|
+
return { refusal: resumeCtxUnreadableAnswer() };
|
|
350
|
+
return owner.kind === "owned" ? { runSessionId: owner.id, ctx: read.kind === "ok" ? read.ctx : null } : undefined;
|
|
351
|
+
};
|
|
352
|
+
const ctxPromise = runCtxOf();
|
|
303
353
|
void ctxPromise.catch(() => { });
|
|
304
354
|
const noApproval = { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
|
|
355
|
+
const rowOwnRefusal = async (verdict) => rowRefusalAnswer(verdict, undefined, verdict.code === "checkpoint.unsupported_version" ? await ctxPromise.then((r) => (r !== undefined && "ctx" in r ? (r.ctx ?? {}) : {}), () => ({})) : {});
|
|
305
356
|
let cp;
|
|
306
357
|
try {
|
|
307
358
|
cp = await cpPromise;
|
|
@@ -312,29 +363,28 @@ export function createResumeLegs(ctx) {
|
|
|
312
363
|
deps.logger?.warn?.("approval_decide_unreadable_row_withheld", { sessionId, note: "row unreadable and the caller's ownership of THAT token is unproven — folded into the uniform 404" });
|
|
313
364
|
return noApproval;
|
|
314
365
|
}
|
|
315
|
-
return
|
|
366
|
+
return rowReadRefusalAnswer(e);
|
|
316
367
|
}
|
|
317
368
|
if (!cp) {
|
|
318
369
|
if (!(await mayDiscloseRowError(cs, token, decider)))
|
|
319
370
|
return noApproval;
|
|
320
371
|
return { status: 404, body: refusalBody({ errorCode: "not_found.checkpoint", message: "checkpoint not found" }) };
|
|
321
372
|
}
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
deps.logger?.warn?.("approval_decide_row_scope_mismatch", { sessionId, note: "loaded pending row is foreign to the verified caller — TOCTOU fold" });
|
|
326
|
-
return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
|
|
327
|
-
}
|
|
373
|
+
if (!(await decisionRowAdmits(cs, token, decider, cp.scope))) {
|
|
374
|
+
deps.logger?.warn?.("approval_decide_row_scope_mismatch", { sessionId, note: "loaded pending row is foreign to the verified caller — TOCTOU fold" });
|
|
375
|
+
return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
|
|
328
376
|
}
|
|
377
|
+
const verdict = judgeCheckpointRow(cp);
|
|
378
|
+
if (verdict.kind !== "ok")
|
|
379
|
+
return rowOwnRefusal(verdict);
|
|
329
380
|
const decideGateKind = cp.gate?.kind;
|
|
330
381
|
if (!isApprovalGateKind(decideGateKind)) {
|
|
331
382
|
if (typeof decideGateKind !== "string" || decideGateKind === "") {
|
|
332
|
-
const rowSentence = rowRefusalMessageOf(judgeCheckpointRow(cp));
|
|
333
|
-
if (rowSentence !== undefined)
|
|
334
|
-
return { status: 409, body: refusalBody({ errorCode: "gate_not_tool_approval", message: rowSentence }) };
|
|
335
383
|
return { status: 409, body: refusalBody({ errorCode: "gate_not_tool_approval", message: "task is suspended on a gate whose kind this engine cannot read, so it cannot say which endpoint resolves it" }) };
|
|
336
384
|
}
|
|
337
|
-
const
|
|
385
|
+
const ownerForPath = await runSessionPromise;
|
|
386
|
+
const runSessionForPath = ownerForPath.kind === "owned" ? ownerForPath.id : undefined;
|
|
387
|
+
const activeForPath = typeof runSessionForPath === "string" ? await deps.runStore?.getActiveTaskId(runSessionForPath).catch(() => undefined) : undefined;
|
|
338
388
|
const gnPath = activeForPath ? resumeEntryForGate(decideGateKind, { sessionId, taskId: activeForPath }) : null;
|
|
339
389
|
return {
|
|
340
390
|
status: 409,
|
|
@@ -379,8 +429,8 @@ export function createResumeLegs(ctx) {
|
|
|
379
429
|
standingAnswerDurablyRecordable(parkRowStandingAnswerFacts(paForGrant, cp.gate, deps.config, deploymentListAsks(deps.config, { toolName: paForGrant.toolName })))
|
|
380
430
|
? paForGrant.toolName
|
|
381
431
|
: null;
|
|
382
|
-
const boundGrant =
|
|
383
|
-
? (overrideSessionId) =>
|
|
432
|
+
const boundGrant = intent
|
|
433
|
+
? (overrideSessionId) => intent.record({ ...(overrideSessionId !== undefined ? { overrideSessionId } : {}), rememberableToolName: rememberableTool })
|
|
384
434
|
: undefined;
|
|
385
435
|
const lateSettleSink = deps.approvalLateSettle;
|
|
386
436
|
const lateSettleAnchor = lateSettleSink !== undefined && req !== undefined && token
|
|
@@ -390,8 +440,8 @@ export function createResumeLegs(ctx) {
|
|
|
390
440
|
checkpointTokenHash: buildCheckpointAnchorHash(token),
|
|
391
441
|
}
|
|
392
442
|
: undefined;
|
|
393
|
-
const noteLateSettleIfAccepted = (
|
|
394
|
-
if (lateSettleSink === undefined || lateSettleAnchor === undefined
|
|
443
|
+
const noteLateSettleIfAccepted = (committed) => {
|
|
444
|
+
if (!committed || lateSettleSink === undefined || lateSettleAnchor === undefined)
|
|
395
445
|
return;
|
|
396
446
|
try {
|
|
397
447
|
lateSettleSink.recordLateSettle({ ...lateSettleAnchor, outcome: decision === "approve" ? "allowed" : "denied", decidedBy: hostDecision.decidedBy, ...(hostDecision.approver !== undefined ? { approver: hostDecision.approver } : {}), settledAtMs: Date.now() });
|
|
@@ -400,10 +450,15 @@ export function createResumeLegs(ctx) {
|
|
|
400
450
|
recordFailOpen("server.approval-ask-audit.append-failed", `kind=late_settle err=${e instanceof Error ? e.message : String(e)}`);
|
|
401
451
|
}
|
|
402
452
|
};
|
|
403
|
-
const
|
|
453
|
+
const landAfterCommit = async (out) => {
|
|
454
|
+
const committed = decisionCommittedOf(out);
|
|
455
|
+
noteLateSettleIfAccepted(committed);
|
|
456
|
+
return intent === undefined ? out : { ...out, rememberApplied: await intent.settle(committed) };
|
|
457
|
+
};
|
|
458
|
+
const parkedForkQuotaDenial = req !== undefined ? ownerCostQuotaDenied(checkpointPartsOf(cp.scope)?.person) : undefined;
|
|
404
459
|
if (parkedForkQuotaDenial)
|
|
405
460
|
return parkedForkQuotaDenial;
|
|
406
|
-
const parkedForkLeaseDenial = req !== undefined ? await ownerFleetLeaseDenied(
|
|
461
|
+
const parkedForkLeaseDenial = req !== undefined ? await ownerFleetLeaseDenied(checkpointPartsOf(cp.scope)?.person) : undefined;
|
|
407
462
|
if (parkedForkLeaseDenial)
|
|
408
463
|
return parkedForkLeaseDenial;
|
|
409
464
|
const ownerLeaseAdmittedHere = req !== undefined;
|
|
@@ -425,28 +480,27 @@ export function createResumeLegs(ctx) {
|
|
|
425
480
|
binding: { ...(({ checkpointToken: _staleGuardOnly, ...rest }) => rest)(binding), ...action },
|
|
426
481
|
...(answer !== undefined ? { answer } : {}),
|
|
427
482
|
...(restatement !== undefined ? { restatement } : {}),
|
|
428
|
-
...(boundGrant ? {
|
|
483
|
+
...(boundGrant && intent ? { remember: { anchor: (rootSessionId) => boundGrant(rootSessionId), laneCannotRecord: intent.laneCannotRecord } } : {}),
|
|
429
484
|
};
|
|
430
485
|
if (origin?.kind === "background" && parkedAgentStore !== undefined && parkedSurface !== undefined) {
|
|
431
|
-
const parked = await
|
|
486
|
+
const parked = await withSubject(checkpointPartsOf(cp.scope)?.subject, () => decideParkedAgent({
|
|
432
487
|
agentStore: parkedAgentStore,
|
|
433
488
|
checkpointStore: cs,
|
|
434
489
|
registry: defaultTaskRegistry,
|
|
435
490
|
reviveSurface: parkedSurface,
|
|
436
|
-
...(deps.parkedKnownAgentTypes ? { knownAgentTypes: deps.parkedKnownAgentTypes } : {}),
|
|
437
491
|
...(deps.parkedReviveInheritedGate ? { rebuildInheritedGate: deps.parkedReviveInheritedGate } : {}),
|
|
438
492
|
...(deps.toolApproval ? { approverSeatFor: windowZeroSeatOf(deps.toolApproval) } : {}),
|
|
439
493
|
execution: {
|
|
440
494
|
resolve: async (root) => {
|
|
441
495
|
let ctx;
|
|
442
496
|
try {
|
|
443
|
-
ctx = await resolveExecutionContext(deps, { kind: "continuation", root, principal:
|
|
497
|
+
ctx = await resolveExecutionContext(deps, { kind: "continuation", root, principal: checkpointPartsOf(cp.scope)?.person });
|
|
444
498
|
}
|
|
445
499
|
catch (e) {
|
|
446
500
|
if (isRootSessionGoneError(e))
|
|
447
501
|
return { ok: false, gone: true };
|
|
448
502
|
if (e instanceof HttpError)
|
|
449
|
-
return { ok: false, gone: false, answer: resumeRefusalWithCard(
|
|
503
|
+
return { ok: false, gone: false, answer: resumeRefusalWithCard(resumeAssemblyRefusalAnswer(e.status, httpErrorRefusal(e)), true) };
|
|
450
504
|
throw e;
|
|
451
505
|
}
|
|
452
506
|
const occupant = ctx.occupant;
|
|
@@ -460,8 +514,7 @@ export function createResumeLegs(ctx) {
|
|
|
460
514
|
...(deps.logger ? { warn: parkWarn } : {}),
|
|
461
515
|
}, { ...parkedReq, selectedGate: captureSelectedGate() }, { handle: origin.handle, row: origin.row }));
|
|
462
516
|
void ctxPromise.catch(() => { });
|
|
463
|
-
|
|
464
|
-
return parked;
|
|
517
|
+
return await landAfterCommit(parked);
|
|
465
518
|
}
|
|
466
519
|
if (origin?.kind === "workflow_parks_unreadable") {
|
|
467
520
|
void ctxPromise.catch(() => { });
|
|
@@ -476,12 +529,15 @@ export function createResumeLegs(ctx) {
|
|
|
476
529
|
const plan = planWorkflowParkedDecide(origin, parkedReq);
|
|
477
530
|
if (!plan.ok)
|
|
478
531
|
return plan.deny;
|
|
532
|
+
const fingerprint = parkDecisionFingerprint(plan.outcome, restatement);
|
|
533
|
+
const live = await deliverToHoldingRun(origin, { token, outcome: plan.outcome, decision: parkedReq.decision, fingerprint, restated: restatement !== undefined });
|
|
534
|
+
if (live.kind === "answered")
|
|
535
|
+
return live.answer;
|
|
479
536
|
const decisions = deps.workflowParkDecisions;
|
|
480
537
|
const runStore = deps.runStore;
|
|
481
538
|
if (decisions === undefined || runStore === undefined) {
|
|
482
539
|
return { status: 501, body: refusalBody({ errorCode: "capability.run_store_required", message: "delivering this decision requires a durable run store (DB_BACKEND=mysql|pg|local)" }) };
|
|
483
540
|
}
|
|
484
|
-
const fingerprint = parkDecisionFingerprint(plan.outcome, restatement);
|
|
485
541
|
const liveReceiptOf = async (held) => {
|
|
486
542
|
if (held === null || held.fingerprint !== fingerprint)
|
|
487
543
|
return undefined;
|
|
@@ -511,8 +567,8 @@ export function createResumeLegs(ctx) {
|
|
|
511
567
|
.catch(() => undefined);
|
|
512
568
|
const admittedPayer = decodeCheckpointScope(cp.scope);
|
|
513
569
|
const out = hostToken
|
|
514
|
-
? await resumeWake(plan.hostSessionId, plan.message, decider?.
|
|
515
|
-
: await startFreshHostTurn(plan.hostSessionId, plan.message, admittedPayer, req, delivery, plan.runId, restatement);
|
|
570
|
+
? await resumeWake(plan.hostSessionId, plan.message, decider?.subject, req, acceptEarly, delivery, admittedPayer, restatement)
|
|
571
|
+
: await startFreshHostTurn(plan.hostSessionId, plan.message.text, admittedPayer, req, delivery, plan.runId, restatement);
|
|
516
572
|
if (recordFailure !== undefined)
|
|
517
573
|
throw recordFailure.err;
|
|
518
574
|
if (acceptedTaskIdOf(out) === undefined)
|
|
@@ -520,16 +576,14 @@ export function createResumeLegs(ctx) {
|
|
|
520
576
|
return out;
|
|
521
577
|
}
|
|
522
578
|
}
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
525
|
-
return
|
|
526
|
-
if (
|
|
527
|
-
return resumeCtxUnsealableAnswer(ctxRead0);
|
|
528
|
-
const storedCtx = ctxRead0.kind === "ok" ? ctxRead0.ctx : null;
|
|
529
|
-
if (!storedCtx)
|
|
579
|
+
const runCtx = await ctxPromise;
|
|
580
|
+
if (runCtx !== undefined && "refusal" in runCtx)
|
|
581
|
+
return runCtx.refusal;
|
|
582
|
+
if (runCtx === undefined || runCtx.ctx === null)
|
|
530
583
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
584
|
+
const { runSessionId, ctx: storedCtx } = runCtx;
|
|
531
585
|
const ctx = restateResumeCtx(storedCtx, restatement);
|
|
532
|
-
const auth = { sessionId:
|
|
586
|
+
const auth = { sessionId: runSessionId, subject: checkpointPartsOf(cp.scope)?.subject, memoryScope: ctx.memoryScope };
|
|
533
587
|
const resolved = await resolveResumeSpecOrBlocked(ctx, req, auth);
|
|
534
588
|
if (!resolved.ok)
|
|
535
589
|
return resolved.answer;
|
|
@@ -555,10 +609,11 @@ export function createResumeLegs(ctx) {
|
|
|
555
609
|
...(answer !== undefined ? { answer } : {}),
|
|
556
610
|
hostDecision,
|
|
557
611
|
};
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
612
|
+
const composition = resumeCompositionOf(ctx.body, cp, deps.config.cascadeLadder);
|
|
613
|
+
if (composition?.entry === "cascade_unlinked")
|
|
614
|
+
return compositionUnlinkedAnswer();
|
|
615
|
+
const driven = await driveResumeIntoRunLog({ peerLease: resolved.peerLease, execution: resolved.execution, runner: resolved.runner, legFacts: resolved.legFacts, token, sessionId: runSessionId, subject: auth.subject, fleetScope: resumeFleetScope(req, auth), taskConfig, resumeObjective, outcome, commitment: { kind: "gate_resolved", ...captureSelectedGate() }, composition, resumeCtx: { sessionId: runSessionId, ctx }, ...(engineNotices.length > 0 ? { engineNotices } : {}), ...(boundGrant ? { onResumeCommitted: boundGrant } : {}), ...(acceptEarly === true ? { acceptEarly: true } : {}), ...(req !== undefined ? { callerInitiated: true } : {}), ...(ownerLeaseAdmittedHere ? { ownerLeaseAdmitted: true } : {}) });
|
|
616
|
+
return await landAfterCommit(driven);
|
|
562
617
|
}
|
|
563
618
|
finally {
|
|
564
619
|
resolved.peerLease.release();
|
|
@@ -568,7 +623,7 @@ export function createResumeLegs(ctx) {
|
|
|
568
623
|
const ONE_SHOT_SUBMIT_STRIP = Object.fromEntries(ONE_SHOT_SUBMIT_KEYS.map((k) => [k, undefined]));
|
|
569
624
|
const resolveResumeSpec = async (ctx, req, auth, lease) => {
|
|
570
625
|
const engineNotices = [];
|
|
571
|
-
const execution = await resolveExecutionContext(deps, { kind: "continuation", root: auth.sessionId, principal: auth.
|
|
626
|
+
const execution = await resolveExecutionContext(deps, { kind: "continuation", root: auth.sessionId, principal: auth.subject === undefined ? undefined : personOf(recoveredSubject(auth.subject)) });
|
|
572
627
|
const resolved = await deps.resolveSpec({ ...ctx.body, ...ONE_SHOT_SUBMIT_STRIP }, req, auth, {
|
|
573
628
|
leg: "resume",
|
|
574
629
|
onNotice: (n) => engineNotices.push(n),
|
|
@@ -578,7 +633,7 @@ export function createResumeLegs(ctx) {
|
|
|
578
633
|
});
|
|
579
634
|
const legFacts = legFactsOf(resolved);
|
|
580
635
|
const runner = runnerFor(resolved);
|
|
581
|
-
const spec = stampSpecRoot(resolved, execution);
|
|
636
|
+
const spec = stampSpecRoot(resolved, execution, ctx.body);
|
|
582
637
|
return { spec, runner, legFacts, engineNotices, execution };
|
|
583
638
|
};
|
|
584
639
|
const refuseStoredBodyReplay = (sessionId, refusal) => {
|
|
@@ -597,7 +652,7 @@ export function createResumeLegs(ctx) {
|
|
|
597
652
|
catch (e) {
|
|
598
653
|
lease.release();
|
|
599
654
|
if (e instanceof HttpError) {
|
|
600
|
-
return { ok: false, answer: resumeRefusalWithCard(
|
|
655
|
+
return { ok: false, answer: resumeRefusalWithCard(resumeAssemblyRefusalAnswer(e.status, httpErrorRefusal(e)), true) };
|
|
601
656
|
}
|
|
602
657
|
throw e;
|
|
603
658
|
}
|
|
@@ -624,13 +679,22 @@ export function createResumeLegs(ctx) {
|
|
|
624
679
|
}
|
|
625
680
|
async function driveResumeLeg(args, onAccepted) {
|
|
626
681
|
const resumeLegStartedAt = Date.now();
|
|
627
|
-
const { runner: legRunner, token, sessionId,
|
|
682
|
+
const { runner: legRunner, token, sessionId, subject, fleetScope, taskConfig, resumeObjective, outcome, composition, resumeCtx, execution } = args;
|
|
683
|
+
const legSubject = recoveredSubject(subject);
|
|
684
|
+
const payer = legSubject === undefined ? undefined : personOf(legSubject);
|
|
628
685
|
const heldObjective = objectiveWithheldIn(resumeCtx.ctx) ? undefined : resumeObjective;
|
|
629
686
|
const reparkStatus = outcome.gate === "plan_review" ? "needs_review" : "suspended";
|
|
630
|
-
const
|
|
687
|
+
const resumeCtxNotPersisted = (why) => {
|
|
631
688
|
deps.metrics?.inc("resume_ctx_not_persisted_total");
|
|
632
|
-
deps.logger?.warn?.("resume_ctx_not_persisted", { sessionId: resumeCtx.sessionId, gate: outcome.gate, error:
|
|
633
|
-
}
|
|
689
|
+
deps.logger?.warn?.("resume_ctx_not_persisted", { sessionId: resumeCtx.sessionId, gate: outcome.gate, error: why, note: "this continuation runs with the body it was given; the durable rebuild input still holds the PREVIOUS body, so the NEXT continuation of this session rebuilds from that one — its permission mode is never wider than this leg's, but if this leg restated its MCP / A2A peer tables (mcpServers / a2aPeers on the resume request), a later continuation that does not restate them runs with the previous tables again" });
|
|
690
|
+
};
|
|
691
|
+
const commitResumeCtx = () => Promise.resolve().then(async () => {
|
|
692
|
+
const sealed = sealCheckpointCtx({ ...resumeCtx.ctx, writerVersion: serviceVersion() }, deps.checkpointCtxSealing, resumeCtx.sessionId);
|
|
693
|
+
const claim = claimedRow && taskId !== undefined && deps.runStore !== undefined ? { fence: deps.runStore, taskId, legHolds: (run) => !runProvenElsewhere(run, deps.instanceId) } : undefined;
|
|
694
|
+
const landed = await deps.checkpointStore.putCtx(resumeCtx.sessionId, sealed, claim);
|
|
695
|
+
if (landed === "claim_released")
|
|
696
|
+
resumeCtxNotPersisted("claim_released: this run no longer holds the session claim (settled or reaped before the write-back landed) — nothing written");
|
|
697
|
+
}).catch((e) => resumeCtxNotPersisted(errorText(e)));
|
|
634
698
|
const legKey = createHash("sha256").update(String(token)).digest("hex");
|
|
635
699
|
const streamApprovalOn = resolveStreamApprovalGate({
|
|
636
700
|
toolApprovalEnabled: Boolean(deps.toolApproval),
|
|
@@ -647,32 +711,32 @@ export function createResumeLegs(ctx) {
|
|
|
647
711
|
declaredFamilies: declaredApprovalFrameFamilies(resumeCtx.ctx.body.settings),
|
|
648
712
|
});
|
|
649
713
|
const legDeadlineMonotonic = approvalLeg.legDeadlineMonotonic;
|
|
650
|
-
const ownerQuotaDenial = args.callerInitiated === true ? ownerCostQuotaDenied(
|
|
714
|
+
const ownerQuotaDenial = args.callerInitiated === true ? ownerCostQuotaDenied(payer) : undefined;
|
|
651
715
|
if (ownerQuotaDenial)
|
|
652
716
|
return ownerQuotaDenial;
|
|
653
|
-
const ownerLeaseDenial = args.callerInitiated === true && args.ownerLeaseAdmitted !== true ? await ownerFleetLeaseDenied(
|
|
717
|
+
const ownerLeaseDenial = args.callerInitiated === true && args.ownerLeaseAdmitted !== true ? await ownerFleetLeaseDenied(payer) : undefined;
|
|
654
718
|
if (ownerLeaseDenial)
|
|
655
719
|
return ownerLeaseDenial;
|
|
656
720
|
const heldDecisions = await heldWorkflowParkDecisions(deps, sessionId, args.workflowDecision?.carried);
|
|
657
721
|
let taskId = await deps.runStore?.getActiveTaskId(sessionId);
|
|
658
722
|
let freshRunClaimed = false;
|
|
659
723
|
if (args.mintFreshRun && taskId && deps.runStore) {
|
|
660
|
-
return { status: 409, body: await buildActiveRunConflict({ runStore: deps.runStore, checkpointStore: deps.checkpointStore, governance: deps.config,
|
|
724
|
+
return { status: 409, body: await buildActiveRunConflict({ runStore: deps.runStore, checkpointStore: deps.checkpointStore, governance: deps.config, turnActivity: readTurnActivityMs }, sessionId, taskId) };
|
|
661
725
|
}
|
|
662
726
|
if (!taskId && args.mintFreshRun && deps.runStore) {
|
|
663
727
|
const freshId = uuidv7();
|
|
664
|
-
const created = await deps.runStore.createRun(freshId, sessionId,
|
|
728
|
+
const created = await timeClaim(deps.metrics, "run_claim", deps.runStore.createRun(freshId, sessionId, subject ?? null, deps.instanceId ?? "default", {
|
|
665
729
|
source: args.mintFreshRun.source,
|
|
666
730
|
identity: args.mintFreshRun.identity,
|
|
667
731
|
objectivePreview: heldObjective === undefined ? null : buildRunObjectivePreview(heldObjective),
|
|
668
|
-
});
|
|
732
|
+
}));
|
|
669
733
|
if (created.existing) {
|
|
670
734
|
throw new Error(`wake fresh run: createRun observed an existing row for the freshly minted taskId ${freshId} (no idempotency key was sent) — refusing to treat it as a busy session`);
|
|
671
735
|
}
|
|
672
736
|
if (created.sessionAbsent)
|
|
673
737
|
return rootSessionAbsentAnswer();
|
|
674
738
|
if (!created.ok) {
|
|
675
|
-
return { status: 409, body: await buildActiveRunConflict({ runStore: deps.runStore, checkpointStore: deps.checkpointStore, governance: deps.config,
|
|
739
|
+
return { status: 409, body: await buildActiveRunConflict({ runStore: deps.runStore, checkpointStore: deps.checkpointStore, governance: deps.config, turnActivity: readTurnActivityMs }, sessionId, created.activeTaskId) };
|
|
676
740
|
}
|
|
677
741
|
const placementReject = await commitExecutionContext(deps, { kind: "run", runStore: deps.runStore, taskId: freshId }, execution);
|
|
678
742
|
if (placementReject)
|
|
@@ -687,9 +751,9 @@ export function createResumeLegs(ctx) {
|
|
|
687
751
|
if (deps.toolApproval && taskId) {
|
|
688
752
|
const toolApproval = deps.toolApproval;
|
|
689
753
|
resumeTaskConfig.onAsk = approvalLeg.unattended
|
|
690
|
-
? toolApproval.boundUnattendedAsk({ owner:
|
|
754
|
+
? toolApproval.boundUnattendedAsk({ owner: subject ?? null, taskId, sessionId, executionLane: execution.lane }, approvalLeg.unattended)
|
|
691
755
|
: toolApproval.boundAsk({
|
|
692
|
-
owner:
|
|
756
|
+
owner: subject ?? null,
|
|
693
757
|
taskId,
|
|
694
758
|
sessionId,
|
|
695
759
|
executionLane: execution.lane,
|
|
@@ -721,6 +785,8 @@ export function createResumeLegs(ctx) {
|
|
|
721
785
|
}
|
|
722
786
|
};
|
|
723
787
|
const settleCardForCancel = async () => {
|
|
788
|
+
if (freshRunClaimed)
|
|
789
|
+
return false;
|
|
724
790
|
const cs2 = deps.checkpointStore;
|
|
725
791
|
if (!cs2)
|
|
726
792
|
return false;
|
|
@@ -751,12 +817,12 @@ export function createResumeLegs(ctx) {
|
|
|
751
817
|
return { reopened: pending, leg };
|
|
752
818
|
};
|
|
753
819
|
let resumeHeartbeat;
|
|
754
|
-
let
|
|
820
|
+
let resumeManifestSeat;
|
|
755
821
|
let resumeStreamRef;
|
|
756
822
|
let resumeLegLive = false;
|
|
757
823
|
const subagentHandleEvictions = [];
|
|
758
824
|
let claimedRow = false;
|
|
759
|
-
const cancelCtrl = createRunAbort(
|
|
825
|
+
const cancelCtrl = createRunAbort(subject ?? null);
|
|
760
826
|
let cancelLedgerAppend;
|
|
761
827
|
const preemptCtrl = new AbortController();
|
|
762
828
|
if (taskId && deps.runStore) {
|
|
@@ -768,14 +834,14 @@ export function createResumeLegs(ctx) {
|
|
|
768
834
|
if (placementReject)
|
|
769
835
|
return placementReject;
|
|
770
836
|
}
|
|
771
|
-
markChildrenStoppedByUserOnAbort(cancelCtrl.signal, taskId,
|
|
837
|
+
markChildrenStoppedByUserOnAbort(cancelCtrl.signal, taskId, subject);
|
|
772
838
|
fleetPub?.onStart();
|
|
773
839
|
const rs = deps.runStore;
|
|
774
|
-
const owner =
|
|
840
|
+
const owner = subject ?? null;
|
|
775
841
|
inflightRuns.set(taskId, cancelCtrl);
|
|
776
842
|
preemptableRuns.set(taskId, preemptCtrl);
|
|
777
843
|
resumeHeartbeat = setInterval(() => {
|
|
778
|
-
|
|
844
|
+
beatRunHeartbeat(rs, taskId, owner, () => cancelCtrl.abort("stall_verdict"), () => undefined);
|
|
779
845
|
if (!cancelCtrl.signal.aborted) {
|
|
780
846
|
void rs.isCancelRequested(taskId, owner).then((c) => { if (c)
|
|
781
847
|
cancelCtrl.abort("cancel_verb"); }).catch(() => undefined);
|
|
@@ -787,7 +853,7 @@ export function createResumeLegs(ctx) {
|
|
|
787
853
|
}, HEARTBEAT_MS);
|
|
788
854
|
resumeHeartbeat.unref?.();
|
|
789
855
|
deps.modelUsage?.register(taskId);
|
|
790
|
-
|
|
856
|
+
resumeManifestSeat = createPromptManifestSeat(deps.promptManifests, taskId);
|
|
791
857
|
}
|
|
792
858
|
if (args.workflowDecision !== undefined && taskId === undefined) {
|
|
793
859
|
throw new Error("workflow decision delivery: no run row was claimed for the delivering leg — refusing to start a delivery whose decision could not be recorded against it");
|
|
@@ -804,12 +870,12 @@ export function createResumeLegs(ctx) {
|
|
|
804
870
|
try {
|
|
805
871
|
const instructionLeg = createInstructionSelectionLeg();
|
|
806
872
|
const legWiringSections = () => ({ instructions: instructionLeg.segment(), skills: args.legFacts?.skills });
|
|
807
|
-
result = await instructionLeg.run(sessionId, () => withModelReachScope({ sessionId, taskId }, () =>
|
|
873
|
+
result = await instructionLeg.run(sessionId, () => withModelReachScope({ sessionId, taskId }, () => withSubject(legSubject, async () => {
|
|
808
874
|
const resumeNotifiedKeys = new NotifiedKeys();
|
|
809
875
|
if (deps.runStore && taskId) {
|
|
810
876
|
const rs0 = deps.runStore;
|
|
811
877
|
let drainSeq = (await rs0.maxSeq(taskId)) + 1;
|
|
812
|
-
await emitPendingWorkflowCompletions(deps.workflowCompletionInbox, sessionId,
|
|
878
|
+
await emitPendingWorkflowCompletions(deps.workflowCompletionInbox, sessionId, subject ?? null, (frame) => {
|
|
813
879
|
const { type, ...rest } = frame;
|
|
814
880
|
const f = frame;
|
|
815
881
|
const write = rs0.appendEvent(taskId, drainSeq++, type, rest);
|
|
@@ -819,7 +885,7 @@ export function createResumeLegs(ctx) {
|
|
|
819
885
|
return write;
|
|
820
886
|
}, { route: "resume-open", connection: "durable-append", log: (m, x) => deps.logger?.info?.(m, x) });
|
|
821
887
|
}
|
|
822
|
-
if (
|
|
888
|
+
if (composition !== undefined) {
|
|
823
889
|
const rsV = deps.runStore;
|
|
824
890
|
const vSeqBase = rsV && taskId ? await rsV.maxSeq(taskId) : 0;
|
|
825
891
|
const verifySink = createLedgerSink({
|
|
@@ -861,7 +927,7 @@ export function createResumeLegs(ctx) {
|
|
|
861
927
|
const parked = !resumeLegLive && Boolean(deps.workflowCompletionInbox && sessionId);
|
|
862
928
|
deps.logger?.info?.("task_notification_observed", { route: "resume-verify", taskId: n.task_id, taskType: n.task_type, status: n.status, legLive: resumeLegLive, parkedDurable: parked });
|
|
863
929
|
if (parked) {
|
|
864
|
-
void deps.workflowCompletionInbox.enqueue(taskNotificationInboxEntry(sessionId,
|
|
930
|
+
void deps.workflowCompletionInbox.enqueue(taskNotificationInboxEntry(sessionId, subject ?? null, n, Date.now(), taskId, opts?.priority)).catch((err) => deps.logger?.warn?.("park_enqueue_failed", { route: "resume-verify", taskId: n.task_id, err: err instanceof Error ? err.message : String(err) }));
|
|
865
931
|
}
|
|
866
932
|
else if (resumeLegLive) {
|
|
867
933
|
const key = taskNotificationDedupKey(n);
|
|
@@ -879,10 +945,23 @@ export function createResumeLegs(ctx) {
|
|
|
879
945
|
: {}),
|
|
880
946
|
};
|
|
881
947
|
resumeLegLive = true;
|
|
882
|
-
const
|
|
948
|
+
const legSpec = { ...resumeTaskConfig, signal: cancelCtrl.signal, preemptSignal: preemptCtrl.signal };
|
|
949
|
+
let vrEngine;
|
|
950
|
+
switch (composition.entry) {
|
|
951
|
+
case "verify":
|
|
952
|
+
vrEngine = await resumeWithVerification(legRunner, token, outcome, legSpec, resumeObjective, composition.rounds, verifyInternals);
|
|
953
|
+
break;
|
|
954
|
+
case "cascade":
|
|
955
|
+
vrEngine = await resumeCascade(legRunner, token, outcome, stampSpecRoot({ ...legSpec, ...composition.objectiveInputs, objective: resumeObjective }, execution, resumeCtx.ctx.body), composition.config, composition.parkedLeg, verifyInternals);
|
|
956
|
+
break;
|
|
957
|
+
default: {
|
|
958
|
+
const unhandled = composition;
|
|
959
|
+
throw new Error(`unhandled resume composition: ${JSON.stringify(unhandled)}`);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
883
962
|
const vrCause = cancelCtrl.cause();
|
|
884
963
|
await voidVerifierPauseCard(vrEngine, legRunner);
|
|
885
|
-
const vrJudged = atHostBoundary(vrEngine
|
|
964
|
+
const vrJudged = atHostBoundary(vrEngine);
|
|
886
965
|
if (vrJudged.terminal.kind === "paused")
|
|
887
966
|
heldPark = vrJudged;
|
|
888
967
|
const vrMinted = vrCause !== undefined && taskId !== undefined ? mintCancelledResult({ taskId, sessionId, startedAtMs: resumeLegStartedAt, message: "cancelled by user", engineResult: vrJudged, cause: vrCause }) : vrJudged;
|
|
@@ -899,7 +978,7 @@ export function createResumeLegs(ctx) {
|
|
|
899
978
|
const rs2 = deps.runStore;
|
|
900
979
|
try {
|
|
901
980
|
const ap = vAppend;
|
|
902
|
-
await
|
|
981
|
+
await resumeManifestSeat?.drain(ap);
|
|
903
982
|
if (reSuspended || vrReopened) {
|
|
904
983
|
const vrParkCallId = reSuspended ? await parkToolCallId(vr, deps.checkpointStore) : undefined;
|
|
905
984
|
await appendParkRow(ap, { modelUsage: deps.modelUsage, taskId }, reParkEvent ?? reparkStatus, { terminal: vrPaused, ...(vrParkCallId !== undefined ? { toolCallId: vrParkCallId } : {}) }, vrReopened ? (failureCodeOf(vr.terminal) ?? null) : undefined);
|
|
@@ -941,13 +1020,13 @@ export function createResumeLegs(ctx) {
|
|
|
941
1020
|
});
|
|
942
1021
|
if (deps.userInputLedger && taskId)
|
|
943
1022
|
await deps.userInputLedger.announceUndrained({ sessionId, taskId });
|
|
944
|
-
const anchorOwner =
|
|
1023
|
+
const anchorOwner = subject ?? null;
|
|
945
1024
|
const headOf = headReadOf(deps.sessionStorage);
|
|
946
1025
|
const captureTurnAnchor = deps.resumeAnchorStore && headOf
|
|
947
1026
|
? async (eventId) => { const leaf = (await headOf(sessionId))?.leafId; if (leaf)
|
|
948
1027
|
await deps.resumeAnchorStore.put(sessionId, eventId, leaf, anchorOwner); }
|
|
949
1028
|
: undefined;
|
|
950
|
-
const captureUserMessageAnchor = deps.resumeAnchorStore && taskId
|
|
1029
|
+
const captureUserMessageAnchor = deps.resumeAnchorStore && taskId && freshRunClaimed
|
|
951
1030
|
? async (entryId) => { await deps.resumeAnchorStore.put(sessionId, taskId, entryId, anchorOwner); }
|
|
952
1031
|
: undefined;
|
|
953
1032
|
const anchor = new TurnAnchorCapture(captureTurnAnchor, "resume", captureUserMessageAnchor);
|
|
@@ -1007,7 +1086,7 @@ export function createResumeLegs(ctx) {
|
|
|
1007
1086
|
const parked = !resumeLegLive && Boolean(deps.workflowCompletionInbox && sessionId);
|
|
1008
1087
|
deps.logger?.info?.("task_notification_observed", { route: "resume", taskId: n.task_id, taskType: n.task_type, status: n.status, legLive: resumeLegLive, parkedDurable: parked });
|
|
1009
1088
|
if (parked) {
|
|
1010
|
-
void deps.workflowCompletionInbox.enqueue(taskNotificationInboxEntry(sessionId,
|
|
1089
|
+
void deps.workflowCompletionInbox.enqueue(taskNotificationInboxEntry(sessionId, subject ?? null, n, Date.now(), taskId, opts?.priority)).catch((err) => deps.logger?.warn?.("park_enqueue_failed", { route: "resume", taskId: n.task_id, err: err instanceof Error ? err.message : String(err) }));
|
|
1011
1090
|
}
|
|
1012
1091
|
else if (resumeLegLive) {
|
|
1013
1092
|
const key = taskNotificationDedupKey(n);
|
|
@@ -1048,7 +1127,7 @@ export function createResumeLegs(ctx) {
|
|
|
1048
1127
|
fleetPub?.onEvent(ev);
|
|
1049
1128
|
await deps.userInputLedger?.observeLegEvent(stream, ev);
|
|
1050
1129
|
await resumeWorkspace.observe(ev);
|
|
1051
|
-
await
|
|
1130
|
+
await resumeManifestSeat?.drain(append);
|
|
1052
1131
|
switch (ev.type) {
|
|
1053
1132
|
case "text_delta":
|
|
1054
1133
|
block += ev.delta;
|
|
@@ -1197,25 +1276,22 @@ export function createResumeLegs(ctx) {
|
|
|
1197
1276
|
}
|
|
1198
1277
|
return safe;
|
|
1199
1278
|
};
|
|
1200
|
-
const
|
|
1201
|
-
const { type, ...rest } = frame;
|
|
1202
|
-
return append(type, rest);
|
|
1203
|
-
};
|
|
1279
|
+
const hitlTransport = createHitlTransport({ ledger: append });
|
|
1204
1280
|
const withApproval = () => deps.toolApproval && taskId && approvalLeg.active && approvalLeg.unattended === undefined
|
|
1205
1281
|
? deps.toolApproval.runWithContext({
|
|
1206
1282
|
taskId,
|
|
1207
|
-
owner:
|
|
1283
|
+
owner: subject ?? null,
|
|
1208
1284
|
abortSignal: cancelCtrl.signal,
|
|
1209
1285
|
sessionId,
|
|
1210
1286
|
executionLane: execution.lane,
|
|
1211
|
-
|
|
1212
|
-
|
|
1287
|
+
family: "approval_request",
|
|
1288
|
+
transport: hitlTransport,
|
|
1213
1289
|
legKey,
|
|
1214
1290
|
...(legDeadlineMonotonic !== undefined ? { legDeadlineMonotonic } : {}),
|
|
1215
1291
|
}, driveResume)
|
|
1216
1292
|
: driveResume();
|
|
1217
1293
|
const withElicitation = () => deps.elicitation && taskId
|
|
1218
|
-
? deps.elicitation.runWithContext({ taskId, owner:
|
|
1294
|
+
? deps.elicitation.runWithContext({ taskId, owner: subject ?? null, transport: hitlTransport, abortSignal: cancelCtrl.signal }, withApproval)
|
|
1219
1295
|
: withApproval();
|
|
1220
1296
|
return await (deps.sendUserFile && taskId
|
|
1221
1297
|
? deps.sendUserFile.runWithContext({ taskId, emit: async (frame) => { const { type, ...rest } = frame; await append(type, rest); } }, withElicitation)
|
|
@@ -1256,7 +1332,7 @@ export function createResumeLegs(ctx) {
|
|
|
1256
1332
|
settleFleet("failed");
|
|
1257
1333
|
}
|
|
1258
1334
|
}
|
|
1259
|
-
return checkpointRefusalAnswer(e, { gate: outcome.gate, retriable, ...(taskId !== undefined ? { taskId } : {}), versionKeys: e
|
|
1335
|
+
return checkpointRefusalAnswer(e, { gate: outcome.gate, retriable, ...(taskId !== undefined ? { taskId } : {}), versionKeys: refusalVersionKeys(e, resumeCtx.ctx) });
|
|
1260
1336
|
}
|
|
1261
1337
|
const thrownCause = cancelCtrl.cause();
|
|
1262
1338
|
if (thrownCause !== undefined) {
|
|
@@ -1271,7 +1347,7 @@ export function createResumeLegs(ctx) {
|
|
|
1271
1347
|
}
|
|
1272
1348
|
if (claimedRow && taskId && deps.runStore) {
|
|
1273
1349
|
await voidHeldParkCard(heldPark, sessionId, deps.checkpointStore, "resume");
|
|
1274
|
-
await deps.runStore.setTerminal(taskId, "failed", null, errorText(e)).catch(() => undefined);
|
|
1350
|
+
await deps.runStore.setTerminal(taskId, "failed", null, outwardThrownMessage(e, errorText(e))).catch(() => undefined);
|
|
1275
1351
|
}
|
|
1276
1352
|
settleFleet("failed");
|
|
1277
1353
|
throw e;
|
|
@@ -1290,7 +1366,7 @@ export function createResumeLegs(ctx) {
|
|
|
1290
1366
|
for (const evict of subagentHandleEvictions)
|
|
1291
1367
|
evict();
|
|
1292
1368
|
deps.modelUsage?.clear(taskId);
|
|
1293
|
-
|
|
1369
|
+
resumeManifestSeat?.release();
|
|
1294
1370
|
}
|
|
1295
1371
|
if (resumeHeartbeat)
|
|
1296
1372
|
clearInterval(resumeHeartbeat);
|
|
@@ -1309,7 +1385,7 @@ export function createResumeLegs(ctx) {
|
|
|
1309
1385
|
else
|
|
1310
1386
|
await deps.runStore.setTerminal(taskId, resumePlane.status, sealed, resumePlane.errorMessage ?? null);
|
|
1311
1387
|
}
|
|
1312
|
-
settleFleet(checkpointReopened ? reparkStatus : resumePlane.status, fleetRunResiduals(sealed));
|
|
1388
|
+
settleFleet(checkpointReopened ? reparkStatus : resumePlane.status, fleetRunResiduals(sealed, sealed ? failureCodeOf(sealed.terminal) : undefined));
|
|
1313
1389
|
return {
|
|
1314
1390
|
status: 200,
|
|
1315
1391
|
body: {
|
|
@@ -1323,7 +1399,7 @@ export function createResumeLegs(ctx) {
|
|
|
1323
1399
|
};
|
|
1324
1400
|
}
|
|
1325
1401
|
async function mayDiscloseRowError(cs, token, decider) {
|
|
1326
|
-
if (decider === undefined || decider.
|
|
1402
|
+
if (decider === undefined || decider.operator)
|
|
1327
1403
|
return true;
|
|
1328
1404
|
let scope;
|
|
1329
1405
|
try {
|
|
@@ -1335,24 +1411,28 @@ export function createResumeLegs(ctx) {
|
|
|
1335
1411
|
}
|
|
1336
1412
|
if (scope === undefined)
|
|
1337
1413
|
return false;
|
|
1338
|
-
|
|
1339
|
-
|
|
1414
|
+
return keyAdmits("scope.decide", decider, scopeCellOf(scope ?? CHECKPOINT_PUBLIC_SCOPE));
|
|
1415
|
+
}
|
|
1416
|
+
async function decisionRowAdmits(cs, token, who, bodyScope) {
|
|
1417
|
+
if (who === undefined)
|
|
1418
|
+
return true;
|
|
1419
|
+
const cell = bodyScope === undefined ? undefined : scopeCellOf(bodyScope);
|
|
1420
|
+
return cell !== undefined ? keyAdmits("scope.decide", who, cell) : mayDiscloseRowError(cs, token, who);
|
|
1340
1421
|
}
|
|
1341
1422
|
async function resumePreempted(sessionId, req, acceptEarly, decider, restatement) {
|
|
1342
1423
|
const cs = deps.checkpointStore;
|
|
1343
1424
|
const RESUMABLE_GATE_KIND = "resource_limit";
|
|
1344
|
-
const preemptBinding = { gateKinds: [RESUMABLE_GATE_KIND] };
|
|
1345
|
-
const token = (await cs.findPendingTokenBySession(sessionId, undefined, preemptBinding)) ?? (await cs.findPendingTokenBySession(sessionId));
|
|
1425
|
+
const preemptBinding = { gateKinds: [RESUMABLE_GATE_KIND], axis: "run" };
|
|
1426
|
+
const token = (await cs.findPendingTokenBySession(sessionId, undefined, preemptBinding)) ?? (await cs.findPendingTokenBySession(sessionId, undefined, { axis: "run" }));
|
|
1346
1427
|
const noSuspension = { status: 404, body: refusalBody({ errorCode: "not_found.suspension", message: "no resumable suspension for this task (already running, resumed, or expired)" }) };
|
|
1347
1428
|
if (!token)
|
|
1348
1429
|
return noSuspension;
|
|
1349
|
-
if (decider !== undefined && !decider.
|
|
1430
|
+
if (decider !== undefined && !decider.operator) {
|
|
1350
1431
|
const peeked = await cs
|
|
1351
1432
|
.peekPendingScope(sessionId, preemptBinding)
|
|
1352
|
-
.then((sc) => (sc === undefined ? cs.peekPendingScope(sessionId) : sc))
|
|
1433
|
+
.then((sc) => (sc === undefined ? cs.peekPendingScope(sessionId, { axis: "run" }) : sc))
|
|
1353
1434
|
.catch(() => undefined);
|
|
1354
|
-
|
|
1355
|
-
if (peekedOwner !== undefined && peekedOwner !== decider.principal) {
|
|
1435
|
+
if (!keyAdmits("scope.decide", decider, scopeCellOf(peeked ?? CHECKPOINT_PUBLIC_SCOPE))) {
|
|
1356
1436
|
deps.logger?.warn?.("assistant_resume_row_scope_mismatch", { sessionId, note: "pending row is foreign to the verified caller — owner gate ahead of the row load" });
|
|
1357
1437
|
return noSuspension;
|
|
1358
1438
|
}
|
|
@@ -1366,14 +1446,14 @@ export function createResumeLegs(ctx) {
|
|
|
1366
1446
|
deps.logger?.warn?.("assistant_resume_unreadable_row_withheld", { sessionId, note: "row unreadable and the caller's ownership of THAT token is unproven — folded into the uniform 404" });
|
|
1367
1447
|
return noSuspension;
|
|
1368
1448
|
}
|
|
1369
|
-
return
|
|
1449
|
+
return rowReadRefusalAnswer(e);
|
|
1370
1450
|
}
|
|
1371
1451
|
if (!cp) {
|
|
1372
1452
|
if (!(await mayDiscloseRowError(cs, token, decider)))
|
|
1373
1453
|
return noSuspension;
|
|
1374
1454
|
return { status: 404, body: refusalBody({ errorCode: "not_found.checkpoint", message: "checkpoint not found" }) };
|
|
1375
1455
|
}
|
|
1376
|
-
if (decider !== undefined && !
|
|
1456
|
+
if (decider !== undefined && !keyAdmits("scope.decide", decider, scopeCellOf(cp.scope))) {
|
|
1377
1457
|
deps.logger?.warn?.("assistant_resume_row_scope_mismatch", { sessionId, note: "loaded pending row is foreign to the verified caller — TOCTOU fold" });
|
|
1378
1458
|
return noSuspension;
|
|
1379
1459
|
}
|
|
@@ -1386,25 +1466,29 @@ export function createResumeLegs(ctx) {
|
|
|
1386
1466
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1387
1467
|
if (ctxRead.kind === "unsealable")
|
|
1388
1468
|
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1469
|
+
if (ctxRead.kind === "unreadable")
|
|
1470
|
+
return resumeCtxUnreadableAnswer();
|
|
1389
1471
|
if (ctxRead.kind === "absent")
|
|
1390
1472
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
1391
1473
|
const ctx = restateResumeCtx(ctxRead.ctx, restatement);
|
|
1392
|
-
const auth = { sessionId
|
|
1474
|
+
const auth = { sessionId, subject: checkpointPartsOf(cp.scope)?.subject, memoryScope: ctx.memoryScope };
|
|
1393
1475
|
const resolved = await resolveResumeSpecOrBlocked(ctx, req, auth);
|
|
1394
1476
|
if (!resolved.ok)
|
|
1395
1477
|
return resolved.answer;
|
|
1396
1478
|
try {
|
|
1397
1479
|
const { spec, engineNotices } = resolved;
|
|
1398
1480
|
const { objective: resumeObjective, sessionId: _sessionId, ...taskConfig } = spec;
|
|
1399
|
-
const
|
|
1481
|
+
const composition = resumeCompositionOf(ctx.body, cp, deps.config.cascadeLadder);
|
|
1482
|
+
if (composition?.entry === "cascade_unlinked")
|
|
1483
|
+
return compositionUnlinkedAnswer();
|
|
1400
1484
|
const selectedGate = durableRowIdentity("decision-receipt", cp.checkpointId, token);
|
|
1401
|
-
return await driveResumeIntoRunLog({ peerLease: resolved.peerLease, execution: resolved.execution, runner: resolved.runner, legFacts: resolved.legFacts, token, sessionId
|
|
1485
|
+
return await driveResumeIntoRunLog({ peerLease: resolved.peerLease, execution: resolved.execution, runner: resolved.runner, legFacts: resolved.legFacts, token, sessionId, subject: auth.subject, fleetScope: resumeFleetScope(req, auth), taskConfig, resumeObjective, outcome: { gate: "resource_limit", decision: "continue" }, commitment: { kind: "gate_resolved", ...selectedGate }, composition, resumeCtx: { sessionId, ctx }, ...(engineNotices.length > 0 ? { engineNotices } : {}), ...(acceptEarly === true ? { acceptEarly: true } : {}), ...(req !== undefined ? { callerInitiated: true } : {}) });
|
|
1402
1486
|
}
|
|
1403
1487
|
finally {
|
|
1404
1488
|
resolved.peerLease.release();
|
|
1405
1489
|
}
|
|
1406
1490
|
}
|
|
1407
|
-
async function startFreshHostTurn(sessionId, objective,
|
|
1491
|
+
async function startFreshHostTurn(sessionId, objective, subject, req, workflowDecision, runId, restatement) {
|
|
1408
1492
|
const cs = deps.checkpointStore;
|
|
1409
1493
|
if (!deps.runStore) {
|
|
1410
1494
|
return { status: 501, body: refusalBody({ errorCode: "capability.run_store_required", message: "delivering this decision requires a durable run store (DB_BACKEND=mysql|pg|local)" }) };
|
|
@@ -1414,6 +1498,8 @@ export function createResumeLegs(ctx) {
|
|
|
1414
1498
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1415
1499
|
if (ctxRead.kind === "unsealable")
|
|
1416
1500
|
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1501
|
+
if (ctxRead.kind === "unreadable")
|
|
1502
|
+
return resumeCtxUnreadableAnswer();
|
|
1417
1503
|
const storedCtx = ctxRead.kind === "ok" ? ctxRead.ctx : null;
|
|
1418
1504
|
if (!storedCtx) {
|
|
1419
1505
|
return {
|
|
@@ -1429,10 +1515,10 @@ export function createResumeLegs(ctx) {
|
|
|
1429
1515
|
};
|
|
1430
1516
|
}
|
|
1431
1517
|
const ctx = restateResumeCtx(storedCtx, restatement);
|
|
1432
|
-
const windowDenial = await usageWindowDenialFor(
|
|
1518
|
+
const windowDenial = await usageWindowDenialFor(subject === undefined ? undefined : personOf(recoveredSubject(subject)));
|
|
1433
1519
|
if (windowDenial)
|
|
1434
1520
|
return { status: windowDenial.status, body: windowDenial.body };
|
|
1435
|
-
const auth = { sessionId,
|
|
1521
|
+
const auth = { sessionId, subject, memoryScope: ctx.memoryScope };
|
|
1436
1522
|
const resolved = await resolveResumeSpecOrBlocked(ctx, req, auth);
|
|
1437
1523
|
if (!resolved.ok)
|
|
1438
1524
|
return resolved.answer;
|
|
@@ -1440,11 +1526,11 @@ export function createResumeLegs(ctx) {
|
|
|
1440
1526
|
const { spec, engineNotices } = resolved;
|
|
1441
1527
|
const hostSpec = { ...spec, objective };
|
|
1442
1528
|
const out = await mintAndDriveDurableRun(routeCtxBase, deps.runStore, {
|
|
1443
|
-
prepared: { spec: hostSpec, runner: resolved.runner, legFacts: resolved.legFacts, auth, body: ctx.body, ...(objectiveWithheldIn(ctx) ? { bodyFromScreenedCtx: true } : {}), acceptance: createRunAcceptance({}, { objective, screened: false }), peerLease: resolved.peerLease, execution: resolved.execution, ...(engineNotices.length > 0 ? { engineNotices } : {}) },
|
|
1529
|
+
prepared: { spec: hostSpec, runner: resolved.runner, legFacts: resolved.legFacts, auth, body: ctx.body, ...(objectiveWithheldIn(ctx) ? { bodyFromScreenedCtx: true } : {}), seat: createSubmissionSeat({ deployment: deps.config }), acceptance: createRunAcceptance({}, { objective, screened: false }), peerLease: resolved.peerLease, execution: resolved.execution, ...(engineNotices.length > 0 ? { engineNotices } : {}) },
|
|
1444
1530
|
fleetScope: resumeFleetScope(req, auth),
|
|
1445
|
-
elicitOwner:
|
|
1531
|
+
elicitOwner: subject ?? null,
|
|
1446
1532
|
source: "workflow_parked_decide",
|
|
1447
|
-
identity: runIdentityOf(req, deps.config,
|
|
1533
|
+
identity: runIdentityOf(req, deps.config, subject ?? null),
|
|
1448
1534
|
workflowDecision,
|
|
1449
1535
|
});
|
|
1450
1536
|
if (out.existing) {
|
|
@@ -1465,11 +1551,10 @@ export function createResumeLegs(ctx) {
|
|
|
1465
1551
|
const token = (await cs.findPendingTokenBySession(sessionId, undefined, wakeBinding)) ?? (await cs.findPendingTokenBySession(sessionId));
|
|
1466
1552
|
if (!token)
|
|
1467
1553
|
return { status: 404, body: refusalBody({ errorCode: "not_found.parked_checkpoint", message: "no parked checkpoint for this session (nothing to wake)" }) };
|
|
1468
|
-
const
|
|
1469
|
-
if (!operator) {
|
|
1554
|
+
const who = { subject: caller, operator: explicitOperatorOk(caller === undefined ? undefined : personOf(caller), deps.config) };
|
|
1555
|
+
if (!who.operator) {
|
|
1470
1556
|
const scope = await cs.peekPendingScope(sessionId, wakeBinding).then((s) => (s === undefined ? cs.peekPendingScope(sessionId) : s)).catch(() => undefined);
|
|
1471
|
-
|
|
1472
|
-
if (decodedScope !== undefined && decodedScope !== caller) {
|
|
1557
|
+
if (!keyAdmits("scope.decide", who, scopeCellOf(scope ?? CHECKPOINT_PUBLIC_SCOPE))) {
|
|
1473
1558
|
return { status: 404, body: refusalBody({ errorCode: "not_found.parked_checkpoint", message: "no parked checkpoint for this session (nothing to wake)" }) };
|
|
1474
1559
|
}
|
|
1475
1560
|
}
|
|
@@ -1478,29 +1563,28 @@ export function createResumeLegs(ctx) {
|
|
|
1478
1563
|
cp = await cs.get(token);
|
|
1479
1564
|
}
|
|
1480
1565
|
catch (e) {
|
|
1481
|
-
if (!(await mayDiscloseRowError(cs, token,
|
|
1566
|
+
if (!(await mayDiscloseRowError(cs, token, who))) {
|
|
1482
1567
|
deps.logger?.warn?.("wake_unreadable_row_withheld", { sessionId, note: "row unreadable and the caller's ownership of THAT token is unproven — folded into the uniform 404" });
|
|
1483
1568
|
return { status: 404, body: refusalBody({ errorCode: "not_found.parked_checkpoint", message: "no parked checkpoint for this session (nothing to wake)" }) };
|
|
1484
1569
|
}
|
|
1485
|
-
return
|
|
1570
|
+
return rowReadRefusalAnswer(e);
|
|
1486
1571
|
}
|
|
1487
1572
|
if (!cp) {
|
|
1488
|
-
if (!(await mayDiscloseRowError(cs, token,
|
|
1573
|
+
if (!(await mayDiscloseRowError(cs, token, who))) {
|
|
1489
1574
|
return { status: 404, body: refusalBody({ errorCode: "not_found.parked_checkpoint", message: "no parked checkpoint for this session (nothing to wake)" }) };
|
|
1490
1575
|
}
|
|
1491
1576
|
return { status: 404, body: refusalBody({ errorCode: "not_found.checkpoint", message: "checkpoint not found" }) };
|
|
1492
1577
|
}
|
|
1493
|
-
if (!
|
|
1578
|
+
if (!keyAdmits("scope.decide", who, scopeCellOf(cp.scope))) {
|
|
1494
1579
|
return { status: 404, body: refusalBody({ errorCode: "not_found.parked_checkpoint", message: "no parked checkpoint for this session (nothing to wake)" }) };
|
|
1495
1580
|
}
|
|
1496
1581
|
const gateKind = cp.gate?.kind;
|
|
1497
1582
|
if (gateKind !== "task_done") {
|
|
1498
1583
|
return { status: 409, body: refusalBody({ errorCode: "wake.gate_pending", message: `cannot wake: this session is waiting on a pending gate decision (gate "${gateKind ?? "unknown"}") — resolve it through its own decide entry` }) };
|
|
1499
1584
|
}
|
|
1500
|
-
const trusted = operator;
|
|
1501
1585
|
if (message !== undefined) {
|
|
1502
1586
|
try {
|
|
1503
|
-
validatePendingSteer(
|
|
1587
|
+
validatePendingSteer(message);
|
|
1504
1588
|
}
|
|
1505
1589
|
catch (e) {
|
|
1506
1590
|
if (e instanceof CheckpointError && e.code === "steering.invalid_content") {
|
|
@@ -1514,10 +1598,12 @@ export function createResumeLegs(ctx) {
|
|
|
1514
1598
|
return resumeCtxCorruptAnswer(ctxRead.where);
|
|
1515
1599
|
if (ctxRead.kind === "unsealable")
|
|
1516
1600
|
return resumeCtxUnsealableAnswer(ctxRead);
|
|
1601
|
+
if (ctxRead.kind === "unreadable")
|
|
1602
|
+
return resumeCtxUnreadableAnswer();
|
|
1517
1603
|
if (ctxRead.kind === "absent")
|
|
1518
1604
|
return { status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) };
|
|
1519
1605
|
const ctx = restateResumeCtx(ctxRead.ctx, restatement);
|
|
1520
|
-
const auth = { sessionId: cp.sessionId,
|
|
1606
|
+
const auth = { sessionId: cp.sessionId, subject: checkpointPartsOf(cp.scope)?.subject, memoryScope: ctx.memoryScope };
|
|
1521
1607
|
const resolved = await resolveResumeSpecOrBlocked(ctx, req, auth);
|
|
1522
1608
|
if (!resolved.ok)
|
|
1523
1609
|
return resolved.answer;
|
|
@@ -1531,27 +1617,27 @@ export function createResumeLegs(ctx) {
|
|
|
1531
1617
|
legFacts: resolved.legFacts,
|
|
1532
1618
|
token,
|
|
1533
1619
|
sessionId: cp.sessionId,
|
|
1534
|
-
|
|
1620
|
+
subject: auth.subject,
|
|
1535
1621
|
fleetScope: resumeFleetScope(req, auth),
|
|
1536
1622
|
taskConfig,
|
|
1537
1623
|
resumeObjective,
|
|
1538
|
-
outcome: { gate: "wake", ...(message !== undefined ? { message
|
|
1624
|
+
outcome: { gate: "wake", ...(message !== undefined ? { message } : {}) },
|
|
1539
1625
|
commitment: { kind: "delivered" },
|
|
1540
|
-
|
|
1626
|
+
composition: undefined,
|
|
1541
1627
|
resumeCtx: { sessionId, ctx },
|
|
1542
|
-
mintFreshRun: { source: "wake", identity: runIdentityOf(req, deps.config, auth.
|
|
1628
|
+
mintFreshRun: { source: "wake", identity: runIdentityOf(req, deps.config, auth.subject ?? null) },
|
|
1543
1629
|
...(workflowDecision !== undefined ? { workflowDecision } : {}),
|
|
1544
1630
|
...(engineNotices.length > 0 ? { engineNotices } : {}),
|
|
1545
1631
|
...(acceptEarly === true ? { acceptEarly: true } : {}),
|
|
1546
1632
|
...(req !== undefined ? { callerInitiated: true } : {}),
|
|
1547
|
-
...(ownerLeaseAdmittedFor !== undefined && auth.
|
|
1633
|
+
...(ownerLeaseAdmittedFor !== undefined && auth.subject === ownerLeaseAdmittedFor ? { ownerLeaseAdmitted: true } : {}),
|
|
1548
1634
|
});
|
|
1549
1635
|
}
|
|
1550
1636
|
finally {
|
|
1551
1637
|
resolved.peerLease.release();
|
|
1552
1638
|
}
|
|
1553
1639
|
}
|
|
1554
|
-
async function preparePlanReview(sessionId, log, decider, sighting) {
|
|
1640
|
+
async function preparePlanReview(sessionId, log, decider, sighting, restatement) {
|
|
1555
1641
|
const cs = deps.checkpointStore;
|
|
1556
1642
|
const refuse = (answer) => ({ ok: false, answer });
|
|
1557
1643
|
const log404 = (r) => deps.logger?.info?.("decide_404", {
|
|
@@ -1560,20 +1646,19 @@ export function createResumeLegs(ctx) {
|
|
|
1560
1646
|
...(log?.principalPresent !== undefined ? { principalPresent: log.principalPresent } : {}),
|
|
1561
1647
|
});
|
|
1562
1648
|
const PLAN_REVIEW_GATE_KIND = "plan_review";
|
|
1563
|
-
const planReviewBinding = { gateKinds: [PLAN_REVIEW_GATE_KIND] };
|
|
1564
|
-
const token = (await cs.findPendingTokenBySession(sessionId, undefined, planReviewBinding)) ?? (await cs.findPendingTokenBySession(sessionId));
|
|
1649
|
+
const planReviewBinding = { gateKinds: [PLAN_REVIEW_GATE_KIND], axis: "run" };
|
|
1650
|
+
const token = (await cs.findPendingTokenBySession(sessionId, undefined, planReviewBinding)) ?? (await cs.findPendingTokenBySession(sessionId, undefined, { axis: "run" }));
|
|
1565
1651
|
const noPending = { status: 404, body: refusalBody({ errorCode: "not_found.plan_review", message: "no pending plan_review for this session (already decided or expired)" }) };
|
|
1566
1652
|
if (!token) {
|
|
1567
1653
|
log404("no-pending-checkpoint");
|
|
1568
1654
|
return refuse(noPending);
|
|
1569
1655
|
}
|
|
1570
|
-
if (decider !== undefined && !decider.
|
|
1656
|
+
if (decider !== undefined && !decider.operator) {
|
|
1571
1657
|
const peeked = await cs
|
|
1572
1658
|
.peekPendingScope(sessionId, planReviewBinding)
|
|
1573
|
-
.then((sc) => (sc === undefined ? cs.peekPendingScope(sessionId) : sc))
|
|
1659
|
+
.then((sc) => (sc === undefined ? cs.peekPendingScope(sessionId, { axis: "run" }) : sc))
|
|
1574
1660
|
.catch(() => undefined);
|
|
1575
|
-
|
|
1576
|
-
if (peekedOwner !== undefined && peekedOwner !== decider.principal) {
|
|
1661
|
+
if (!keyAdmits("scope.decide", decider, scopeCellOf(peeked ?? CHECKPOINT_PUBLIC_SCOPE))) {
|
|
1577
1662
|
deps.logger?.warn?.("plan_review_row_scope_mismatch", { sessionId, note: "pending row is foreign to the verified caller — owner gate ahead of the row load" });
|
|
1578
1663
|
return refuse(noPending);
|
|
1579
1664
|
}
|
|
@@ -1587,7 +1672,7 @@ export function createResumeLegs(ctx) {
|
|
|
1587
1672
|
deps.logger?.warn?.("plan_review_unreadable_row_withheld", { sessionId, note: "row unreadable and the caller's ownership of THAT token is unproven — folded into the uniform 404" });
|
|
1588
1673
|
return refuse(noPending);
|
|
1589
1674
|
}
|
|
1590
|
-
return refuse(
|
|
1675
|
+
return refuse(rowReadRefusalAnswer(e));
|
|
1591
1676
|
}
|
|
1592
1677
|
if (!cp) {
|
|
1593
1678
|
log404("checkpoint-missing");
|
|
@@ -1595,7 +1680,7 @@ export function createResumeLegs(ctx) {
|
|
|
1595
1680
|
return refuse(noPending);
|
|
1596
1681
|
return refuse({ status: 404, body: refusalBody({ errorCode: "not_found.checkpoint", message: "checkpoint not found" }) });
|
|
1597
1682
|
}
|
|
1598
|
-
if (decider !== undefined && !
|
|
1683
|
+
if (decider !== undefined && !keyAdmits("scope.decide", decider, scopeCellOf(cp.scope))) {
|
|
1599
1684
|
deps.logger?.warn?.("plan_review_row_scope_mismatch", { sessionId, note: "loaded pending row is foreign to the verified caller — TOCTOU fold" });
|
|
1600
1685
|
return refuse(noPending);
|
|
1601
1686
|
}
|
|
@@ -1621,19 +1706,21 @@ export function createResumeLegs(ctx) {
|
|
|
1621
1706
|
return refuse(resumeCtxCorruptAnswer(ctxRead.where));
|
|
1622
1707
|
if (ctxRead.kind === "unsealable")
|
|
1623
1708
|
return refuse(resumeCtxUnsealableAnswer(ctxRead));
|
|
1709
|
+
if (ctxRead.kind === "unreadable")
|
|
1710
|
+
return refuse(resumeCtxUnreadableAnswer());
|
|
1624
1711
|
if (ctxRead.kind === "absent")
|
|
1625
1712
|
return refuse({ status: 409, body: refusalBody({ errorCode: "conflict.resume_context_unavailable", message: "resume context missing — cannot rebuild task config" }) });
|
|
1626
|
-
const
|
|
1713
|
+
const ctx = restateResumeCtx(ctxRead.ctx, restatement);
|
|
1714
|
+
const replay = storedBodyReplayRefusal(ctx, deps.config);
|
|
1627
1715
|
if (replay !== undefined)
|
|
1628
1716
|
return refuse(refuseStoredBodyReplay(sessionId, replay));
|
|
1629
|
-
return { ok: true, prepared: { sessionId, token, cp, ctx
|
|
1717
|
+
return { ok: true, prepared: { sessionId, token, cp, ctx } };
|
|
1630
1718
|
}
|
|
1631
|
-
async function drivePlanReview(prepared, decision, editedPlan, reason, hostDecision, req, acceptEarly, permissionModeAfter
|
|
1632
|
-
const { sessionId, token, cp } = prepared;
|
|
1633
|
-
|
|
1634
|
-
if ((await deps.checkpointStore.findPendingTokenBySession(sessionId, undefined, { gateKinds: ["plan_review"] })) !== token)
|
|
1719
|
+
async function drivePlanReview(prepared, decision, editedPlan, reason, hostDecision, req, acceptEarly, permissionModeAfter) {
|
|
1720
|
+
const { sessionId, token, cp, ctx } = prepared;
|
|
1721
|
+
if ((await deps.checkpointStore.findPendingTokenBySession(sessionId, undefined, { gateKinds: ["plan_review"], axis: "run" })) !== token)
|
|
1635
1722
|
return notResumableAnswer();
|
|
1636
|
-
const auth = { sessionId
|
|
1723
|
+
const auth = { sessionId, subject: checkpointPartsOf(cp.scope)?.subject, memoryScope: ctx.memoryScope };
|
|
1637
1724
|
const effMode = storedBodyPermissionMode(ctx.body);
|
|
1638
1725
|
if (permissionModeAfter !== undefined && effMode !== "plan") {
|
|
1639
1726
|
throw new Error("drivePlanReview: permissionModeAfter was passed for a task whose stored permission mode is not \"plan\" — the caller must refuse this before any state changes (see the plan_review route's pre-nonce gate)");
|
|
@@ -1646,7 +1733,9 @@ export function createResumeLegs(ctx) {
|
|
|
1646
1733
|
try {
|
|
1647
1734
|
const { spec, engineNotices } = resolved;
|
|
1648
1735
|
const { objective: resumeObjective, sessionId: _sessionId, ...taskConfig } = spec;
|
|
1649
|
-
const
|
|
1736
|
+
const composition = resumeCompositionOf(ctx.body, cp, deps.config.cascadeLadder);
|
|
1737
|
+
if (composition?.entry === "cascade_unlinked")
|
|
1738
|
+
return compositionUnlinkedAnswer();
|
|
1650
1739
|
const outcome = {
|
|
1651
1740
|
gate: "plan_review",
|
|
1652
1741
|
decision,
|
|
@@ -1655,7 +1744,7 @@ export function createResumeLegs(ctx) {
|
|
|
1655
1744
|
hostDecision,
|
|
1656
1745
|
};
|
|
1657
1746
|
const selectedGate = durableRowIdentity("decision-receipt", cp.checkpointId, token);
|
|
1658
|
-
const out = await driveResumeIntoRunLog({ peerLease: resolved.peerLease, execution: resolved.execution, runner: resolved.runner, legFacts: resolved.legFacts, token, sessionId
|
|
1747
|
+
const out = await driveResumeIntoRunLog({ peerLease: resolved.peerLease, execution: resolved.execution, runner: resolved.runner, legFacts: resolved.legFacts, token, sessionId, subject: auth.subject, fleetScope: resumeFleetScope(req, auth), taskConfig, resumeObjective, outcome, commitment: { kind: "gate_resolved", ...selectedGate }, composition, resumeCtx: { sessionId, ctx: rebuildCtx }, ...(engineNotices.length > 0 ? { engineNotices } : {}), ...(acceptEarly === true ? { acceptEarly: true } : {}), ...(req !== undefined ? { callerInitiated: true } : {}) });
|
|
1659
1748
|
return out;
|
|
1660
1749
|
}
|
|
1661
1750
|
finally {
|
|
@@ -1671,10 +1760,10 @@ export function createResumeLegs(ctx) {
|
|
|
1671
1760
|
const routeCtxBase = {
|
|
1672
1761
|
deps,
|
|
1673
1762
|
registry: { idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters },
|
|
1674
|
-
helpers: { readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode
|
|
1763
|
+
helpers: { readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode },
|
|
1675
1764
|
local: { images: createImagesLocal(deps), sessions: createSessionsLocal(), sessionSync: createSessionSyncLocal(), capabilities: createCapabilitiesLocal() },
|
|
1676
1765
|
legs: { prepareSpec, finalizeTaskResult, resumeCheckpoint, driveResumeIntoRunLog, resumePreempted, resumeWake, preparePlanReview, drivePlanReview, sessionNotify: sessionNotifyDoor },
|
|
1677
1766
|
};
|
|
1678
|
-
return { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg,
|
|
1767
|
+
return { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg, decisionRowAdmits, resumePreempted, startFreshHostTurn, resumeWake, preparePlanReview, drivePlanReview, sessionNotifyDoor };
|
|
1679
1768
|
}
|
|
1680
1769
|
//# sourceMappingURL=resume-legs.js.map
|