@sema-agent/server 7.147.0 → 7.149.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 +1468 -24
- package/README.md +35 -7
- package/README.zh-CN.md +18 -8
- package/USAGE.md +444 -193
- package/deploy/sema-up/README.md +16 -5
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/_helpers.tpl +20 -4
- package/deploy/sema-up/chart/values.yaml +3 -2
- package/deploy/sema-up/cluster-up.sh +74 -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/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/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 +14 -39
- 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 +13 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +21 -0
- 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/approval-card.d.ts +36 -38
- package/dist/approval-gate-currency.js +3 -2
- package/dist/approval-leg-origin.d.ts +33 -0
- package/dist/approval-leg-origin.js +4 -0
- package/dist/approval-reconciler.d.ts +4 -13
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.d.ts +13 -11
- package/dist/approval.js +3 -3
- package/dist/audit.d.ts +10 -3
- package/dist/audit.js +15 -7
- package/dist/auth-bridge.d.ts +9 -15
- package/dist/auth-bridge.js +4 -11
- package/dist/auth-keys.d.ts +10 -1
- package/dist/auth-keys.js +8 -0
- 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 +5 -2
- 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/deployment-mods.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +17 -7
- package/dist/boot/execution-env.js +47 -42
- package/dist/boot/execution-lane.d.ts +6 -4
- package/dist/boot/execution-lane.js +3 -1
- package/dist/boot/exit-boundary.d.ts +2 -2
- package/dist/boot/exit-boundary.js +6 -5
- package/dist/boot/fatal-exit.d.ts +3 -5
- package/dist/boot/fatal-exit.js +2 -2
- package/dist/boot/leader.d.ts +15 -0
- package/dist/boot/leader.js +17 -15
- package/dist/boot/memory-consolidation.d.ts +37 -29
- package/dist/boot/memory-consolidation.js +11 -5
- package/dist/boot/org-delivery.d.ts +3 -2
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/parked-revive-gate.js +2 -2
- package/dist/boot/reapers.d.ts +4 -3
- package/dist/boot/reapers.js +19 -16
- package/dist/boot/resolve-spec.d.ts +5 -3
- package/dist/boot/resolve-spec.js +60 -70
- package/dist/boot/retention-lane.d.ts +4 -4
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +28 -7
- package/dist/boot/runner-deps.js +14 -5
- package/dist/boot/runtime-caps.d.ts +2 -2
- package/dist/boot/runtime-caps.js +16 -2
- package/dist/boot/session-faces.d.ts +16 -7
- package/dist/boot/session-faces.js +114 -94
- package/dist/boot/shutdown.d.ts +5 -4
- package/dist/boot/shutdown.js +6 -4
- package/dist/boot/stage-01-config.d.ts +1 -0
- package/dist/boot/stage-01-config.js +13 -4
- package/dist/boot/stage-02-web-admin-pull.d.ts +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +16 -3
- package/dist/boot/stage-03-store-backend.d.ts +4 -0
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +3 -0
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +8 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +12 -13
- package/dist/boot/stage-06-runners.js +23 -15
- package/dist/boot/stage-07-capability-layer.d.ts +13 -9
- package/dist/boot/stage-07-capability-layer.js +5 -3
- package/dist/boot/stage-08-reapers.d.ts +13 -9
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +14 -16
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +14 -16
- package/dist/boot/stage-10-http-server.js +7 -4
- package/dist/boot/store-evidence.d.ts +20 -0
- package/dist/boot/store-evidence.js +13 -0
- package/dist/boot/stores.d.ts +6 -0
- package/dist/boot/stores.js +41 -27
- 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 +55 -35
- 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 +7 -1
- package/dist/capabilities/center-plugins.js +32 -10
- package/dist/capabilities/center-wiring.js +1 -1
- package/dist/capabilities/composite-members.d.ts +2 -2
- package/dist/capabilities/composite-members.js +2 -2
- package/dist/capabilities/repo-tools.d.ts +2 -0
- package/dist/capabilities/repo-tools.js +14 -12
- package/dist/capabilities/scenarios.d.ts +6 -15
- package/dist/capabilities/scenarios.js +11 -16
- package/dist/capabilities/skills.d.ts +1 -1
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +39 -11
- package/dist/capability-facts.js +35 -7
- package/dist/card-settle-stored-scope.d.ts +56 -0
- package/dist/card-settle-stored-scope.js +27 -0
- package/dist/card-void.d.ts +8 -13
- package/dist/card-void.js +2 -7
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +7 -3
- package/dist/config-catalog.d.ts +28 -1
- package/dist/config-catalog.js +95 -85
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +43 -3
- package/dist/config-invariants.js +69 -5
- package/dist/config-lkg.d.ts +23 -1
- package/dist/config-lkg.js +17 -3
- package/dist/config-provider.d.ts +9 -9
- package/dist/config-provider.js +25 -110
- package/dist/config-pull-failure.d.ts +50 -0
- package/dist/config-pull-failure.js +48 -0
- package/dist/config-types.d.ts +62 -21
- package/dist/config.d.ts +14 -21
- package/dist/config.js +141 -64
- package/dist/context-window-notice.d.ts +31 -0
- package/dist/context-window-notice.js +28 -0
- package/dist/delegated-session-owner.d.ts +1 -1
- package/dist/deleted-session-ids.d.ts +3 -2
- package/dist/deployment-governance.d.ts +3 -3
- package/dist/deployment-shape.d.ts +46 -11
- package/dist/deployment-shape.js +8 -0
- 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.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +6 -5
- package/dist/env-name-allowlist-knobs.js +5 -0
- package/dist/env-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-lane-caps.d.ts +25 -23
- package/dist/execution-lane-caps.js +18 -26
- package/dist/execution-placement.d.ts +58 -18
- package/dist/execution-placement.js +41 -2
- 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.js +1 -0
- 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 +3 -3
- 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 +23 -3
- package/dist/history-anchor.js +24 -4
- 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 +7 -2
- package/dist/hooks/command-spawn.js +13 -6
- package/dist/hooks/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +72 -57
- package/dist/hooks/hook-runner.js +271 -193
- 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 +76 -79
- package/dist/http/approval-sweeps.d.ts +3 -3
- package/dist/http/approval-sweeps.js +56 -31
- package/dist/http/caller-trust.d.ts +8 -10
- package/dist/http/caller-trust.js +1 -2
- package/dist/http/claim-heartbeat.d.ts +49 -0
- package/dist/http/claim-heartbeat.js +46 -0
- package/dist/http/claimed-run.d.ts +16 -8
- package/dist/http/claimed-run.js +8 -0
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +78 -30
- package/dist/http/durable-run-leg.d.ts +11 -4
- package/dist/http/durable-run-leg.js +45 -21
- package/dist/http/execution-context.d.ts +122 -47
- package/dist/http/execution-context.js +135 -43
- 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 +4 -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 +1 -1
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +392 -67
- package/dist/http/owner-access.js +370 -35
- package/dist/http/principal-gate.d.ts +39 -89
- package/dist/http/principal-gate.js +26 -68
- package/dist/http/refusal-body.d.ts +35 -2
- package/dist/http/refusal-body.js +34 -0
- package/dist/http/request-guards.d.ts +9 -13
- 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 +46 -12
- package/dist/http/resume-ctx-read.js +31 -6
- package/dist/http/resume-legs.d.ts +54 -19
- package/dist/http/resume-legs.js +408 -196
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/route-ctx.d.ts +31 -32
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +60 -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 -67
- 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 +16 -19
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.d.ts +3 -3
- package/dist/http/routes/devices.js +4 -4
- package/dist/http/routes/diagnostics.d.ts +29 -3
- package/dist/http/routes/diagnostics.js +49 -18
- 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 +2 -0
- 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 +10 -19
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/principal-inbox.d.ts +4 -2
- package/dist/http/routes/principal-inbox.js +5 -4
- package/dist/http/routes/projects.d.ts +1 -1
- package/dist/http/routes/projects.js +3 -2
- package/dist/http/routes/retention-ops.js +6 -9
- package/dist/http/routes/rules.js +20 -5
- 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 +155 -237
- 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 +28 -7
- package/dist/http/routes/session-sync.js +63 -50
- package/dist/http/routes/sessions-list.d.ts +3 -3
- package/dist/http/routes/sessions-list.js +9 -9
- package/dist/http/routes/sessions.js +87 -124
- package/dist/http/routes/shared-memory.js +6 -6
- package/dist/http/routes/side-query.js +2 -2
- package/dist/http/routes/tasks.js +237 -187
- 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 +43 -45
- package/dist/http/server.js +61 -11
- 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 +12 -0
- package/dist/http/stored-body-replay.js +2 -2
- package/dist/http/submit-ctx.d.ts +17 -8
- package/dist/http/submit-ctx.js +8 -5
- 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 +4 -3
- package/dist/identity-source.d.ts +36 -5
- package/dist/identity-source.js +27 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- 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/leg-facts.d.ts +7 -2
- package/dist/leg-facts.js +1 -0
- package/dist/local-store-declaration.d.ts +54 -0
- package/dist/local-store-declaration.js +59 -0
- package/dist/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/mcp-assertion-header.js +1 -1
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-project-layer.js +1 -1
- package/dist/memory-scope.d.ts +33 -6
- package/dist/memory-scope.js +68 -19
- package/dist/memory-store-refusal.d.ts +5 -2
- package/dist/memory-sync-client.d.ts +3 -2
- package/dist/memory-sync-client.js +8 -5
- package/dist/model-compat.d.ts +17 -8
- package/dist/model-compat.js +6 -2
- package/dist/model-context-window.d.ts +57 -0
- package/dist/model-context-window.js +21 -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 +40 -20
- package/dist/model-entry-refusal.js +57 -30
- 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-reach-scope.d.ts +2 -1
- 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 +23 -14
- package/dist/namespaced-rule-name.js +8 -11
- 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 +72 -40
- package/dist/observability/fail-open.js +74 -40
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.js +4 -5
- 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 +6 -2
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- 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-completion-inbox.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.js +3 -2
- package/dist/org-delivery-gate.d.ts +36 -10
- package/dist/org-delivery-gate.js +12 -8
- 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 +532 -0
- package/dist/owner-faces.js +126 -0
- package/dist/park-row-commit.d.ts +67 -0
- package/dist/park-row-commit.js +76 -0
- package/dist/parked-decide.d.ts +76 -12
- package/dist/parked-decide.js +152 -11
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +7 -9
- 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 +3 -25
- package/dist/plugins/adoption-log-sql.js +23 -21
- 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 +18 -7
- package/dist/plugins/approval-ask-store-file.js +37 -14
- package/dist/plugins/approval-ask-store-memory.d.ts +12 -4
- package/dist/plugins/approval-ask-store-memory.js +24 -10
- package/dist/plugins/approval-ask-store-sql.d.ts +40 -21
- package/dist/plugins/approval-ask-store-sql.js +44 -15
- package/dist/plugins/approval-exemption-skill-cutoff.d.ts +64 -0
- package/dist/plugins/approval-exemption-skill-cutoff.js +122 -0
- package/dist/plugins/approval-exemption-skill-m46.d.ts +14 -0
- package/dist/plugins/approval-exemption-skill-m46.js +21 -0
- package/dist/plugins/approval-exemption-store.d.ts +32 -2
- package/dist/plugins/approval-exemption-store.js +42 -19
- 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 +2 -0
- package/dist/plugins/blob-backend.js +9 -6
- package/dist/plugins/caching-session-store.d.ts +13 -1
- package/dist/plugins/caching-session-store.js +43 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +32 -5
- package/dist/plugins/checkpoint-index-columns.js +36 -1
- package/dist/plugins/checkpoint-store-face.d.ts +83 -10
- package/dist/plugins/checkpoint-store-face.js +18 -1
- package/dist/plugins/device-store-sql.js +1 -0
- 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 +36 -18
- package/dist/plugins/ensure-schema-lock-policy.js +76 -9
- package/dist/plugins/file-run-store.d.ts +85 -32
- package/dist/plugins/file-run-store.js +177 -94
- 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 +2 -2
- 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 +62 -23
- package/dist/plugins/local-checkpoint-store.js +197 -77
- package/dist/plugins/local-data-dir-modes-m39.js +2 -1
- package/dist/plugins/local-data-root-admission.d.ts +52 -0
- package/dist/plugins/local-data-root-admission.js +100 -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 +29 -6
- package/dist/plugins/local-engine-high-water.js +27 -19
- package/dist/plugins/local-session-store.d.ts +458 -140
- package/dist/plugins/local-session-store.js +906 -292
- 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 +18 -1
- package/dist/plugins/local-task-attachment-store.js +22 -1
- package/dist/plugins/memory-embedder.js +9 -7
- package/dist/plugins/memory-engine-pg.d.ts +3 -2
- package/dist/plugins/memory-engine-pg.js +14 -5
- package/dist/plugins/memory-engine-sql-apply.d.ts +8 -4
- package/dist/plugins/memory-engine-sql-apply.js +6 -8
- package/dist/plugins/memory-engine-tidb.d.ts +4 -2
- package/dist/plugins/memory-engine-tidb.js +11 -2
- 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 +53 -36
- package/dist/plugins/memory-run-store.js +116 -88
- package/dist/plugins/one-time-migration-marker.d.ts +26 -0
- package/dist/plugins/one-time-migration-marker.js +13 -0
- package/dist/plugins/one-time-migrations.d.ts +214 -47
- package/dist/plugins/one-time-migrations.js +481 -135
- package/dist/plugins/org-delivery-quota-store.d.ts +34 -11
- package/dist/plugins/org-delivery-quota-store.js +31 -15
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +5 -64
- package/dist/plugins/permission-rule-store-sql.js +11 -95
- package/dist/plugins/pg-pool.d.ts +2 -32
- package/dist/plugins/pg-pool.js +24 -17
- package/dist/plugins/remote-env-device.d.ts +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +8 -32
- package/dist/plugins/remote-env-e2b.js +44 -32
- package/dist/plugins/remote-env-host.d.ts +51 -17
- package/dist/plugins/remote-env-host.js +111 -42
- package/dist/plugins/remote-env-k8s.d.ts +40 -45
- package/dist/plugins/remote-env-k8s.js +111 -60
- package/dist/plugins/remote-env-local-docker.d.ts +152 -15
- package/dist/plugins/remote-env-local-docker.js +352 -72
- package/dist/plugins/remote-scratchpad.js +4 -0
- package/dist/plugins/retention-deployment.d.ts +49 -17
- package/dist/plugins/retention-deployment.js +39 -8
- 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 +82 -75
- package/dist/plugins/run-store-sql.js +164 -125
- 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 +56 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +56 -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 +131 -14
- package/dist/plugins/schema-consistency.js +388 -18
- package/dist/plugins/schema-drift-sentence.d.ts +10 -6
- package/dist/plugins/schema-drift-sentence.js +15 -7
- package/dist/plugins/schema-ensure-legs.d.ts +9 -0
- package/dist/plugins/schema-ensure-legs.js +1 -1
- 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 +27 -3
- package/dist/plugins/session-ext-table.js +19 -6
- package/dist/plugins/session-fork.d.ts +15 -1
- package/dist/plugins/session-fork.js +3 -0
- package/dist/plugins/session-ownership.d.ts +1 -1
- package/dist/plugins/session-placement.d.ts +27 -20
- package/dist/plugins/session-placement.js +15 -12
- package/dist/plugins/session-row-sql.d.ts +12 -0
- package/dist/plugins/session-row-sql.js +3 -3
- 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 +38 -12
- package/dist/plugins/session-store-sql.js +130 -30
- package/dist/plugins/session-withdraw-sql.d.ts +36 -0
- package/dist/plugins/session-withdraw-sql.js +42 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +0 -69
- package/dist/plugins/shared-memory-store-sql.js +2 -1
- package/dist/plugins/shell-sentinel-owner-m48.d.ts +42 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +9 -0
- package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
- package/dist/plugins/sql-driver.d.ts +1 -1
- package/dist/plugins/sql-driver.js +2 -1
- package/dist/plugins/sql-errors.d.ts +32 -5
- package/dist/plugins/sql-errors.js +55 -7
- package/dist/plugins/sql-json-column.d.ts +8 -7
- package/dist/plugins/sql-json-column.js +10 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +16 -0
- package/dist/plugins/stop-then-start-sentence.js +7 -0
- package/dist/plugins/store-backend.d.ts +99 -16
- package/dist/plugins/store-backend.js +230 -65
- package/dist/plugins/store-contracts.d.ts +123 -33
- package/dist/plugins/store-contracts.js +38 -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 +15 -3
- package/dist/plugins/task-attachment-store.js +22 -9
- package/dist/plugins/tidb-pool.d.ts +11 -6
- package/dist/plugins/tidb-pool.js +39 -18
- 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/plugins/workspace-custody.d.ts +44 -0
- package/dist/plugins/workspace-custody.js +47 -0
- 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/project-identity.d.ts +8 -7
- package/dist/project-identity.js +40 -17
- package/dist/project-layer-key.d.ts +13 -2
- package/dist/project-layer-key.js +9 -1
- package/dist/question.d.ts +13 -23
- package/dist/question.js +21 -39
- package/dist/read-deny-floor-notice.d.ts +36 -0
- package/dist/read-deny-floor-notice.js +40 -0
- package/dist/{plain-string-record.d.ts → request-declaration-disposition.d.ts} +9 -23
- package/dist/request-declaration-disposition.js +39 -0
- 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/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 +5 -3
- package/dist/rules-consent.js +1 -0
- package/dist/run-acceptance.d.ts +3 -1
- package/dist/run-acceptance.js +3 -0
- package/dist/run-cancel-card.d.ts +28 -0
- package/dist/run-cancel-card.js +19 -0
- package/dist/run-cancel-context.d.ts +10 -0
- package/dist/run-cancel-context.js +1 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +117 -90
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +56 -21
- package/dist/runs.js +73 -43
- package/dist/runtime-caps-resolver.d.ts +21 -6
- package/dist/runtime-caps-resolver.js +17 -4
- package/dist/runtime-governance.d.ts +2 -2
- package/dist/runtime-governance.js +5 -3
- package/dist/sealed-key-layout.d.ts +12 -5
- package/dist/sealed-key-layout.js +5 -0
- package/dist/sealed-key.d.ts +12 -2
- package/dist/sealed-key.js +115 -27
- package/dist/security.d.ts +128 -158
- package/dist/security.js +163 -59
- package/dist/sema-config-dir.d.ts +20 -0
- package/dist/sema-config-dir.js +25 -0
- package/dist/server-secret-env.d.ts +55 -25
- package/dist/server-secret-env.js +75 -22
- package/dist/session-agent.d.ts +3 -2
- package/dist/session-children-retire.d.ts +13 -8
- package/dist/session-children-retire.js +9 -7
- 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 +5 -5
- package/dist/session-error-wire.js +1 -1
- package/dist/session-incarnation.d.ts +52 -5
- 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 +0 -71
- package/dist/session-resident-background.js +4 -3
- package/dist/session-row.d.ts +2 -1
- package/dist/session-rules-seat.d.ts +12 -0
- package/dist/session-rules-seat.js +19 -0
- package/dist/session-titler.d.ts +7 -15
- package/dist/session-titler.js +1 -1
- package/dist/session-workspace.d.ts +3 -3
- package/dist/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-admission.d.ts +33 -0
- package/dist/store-admission.js +49 -0
- package/dist/store-posture.d.ts +141 -20
- package/dist/store-posture.js +205 -3
- package/dist/stored-request-hooks-m20.js +2 -2
- 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/checkpoint-store-sql.d.ts +34 -29
- package/dist/stores-sql/checkpoint-store-sql.js +78 -49
- package/dist/stores-sql/file-history-store-sql.d.ts +1 -1
- package/dist/stores-sql/file-history-store-sql.js +3 -5
- package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
- package/dist/stores-sql/mailbox-store-sql.js +31 -32
- package/dist/stores-sql/pg-session-storage.d.ts +7 -5
- package/dist/stores-sql/pg-session-storage.js +54 -46
- package/dist/stores-sql/retention-store-sql.d.ts +87 -19
- package/dist/stores-sql/retention-store-sql.js +92 -27
- package/dist/stores-sql/session-policy-store-sql.d.ts +32 -10
- package/dist/stores-sql/session-policy-store-sql.js +44 -36
- package/dist/stores-sql/session-write-hooks.d.ts +12 -6
- package/dist/stores-sql/tidb-session-storage.d.ts +4 -4
- package/dist/stores-sql/tidb-session-storage.js +13 -8
- package/dist/stores-sql/tidb-session-store.d.ts +36 -17
- package/dist/stores-sql/tidb-session-store.js +69 -39
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +4 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +5 -0
- package/dist/stores-sql/windowed-session-storage.js +9 -0
- package/dist/submission-exit.d.ts +50 -0
- package/dist/submission-exit.js +108 -0
- package/dist/task-a2a.d.ts +3 -8
- package/dist/task-a2a.js +28 -30
- package/dist/task-cwd.d.ts +43 -7
- package/dist/task-cwd.js +11 -0
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +4 -4
- package/dist/task-settings.d.ts +14 -10
- package/dist/task-settings.js +19 -7
- package/dist/terminal.d.ts +27 -43
- package/dist/terminal.js +49 -14
- package/dist/tool-approval.d.ts +173 -163
- package/dist/tool-approval.js +247 -232
- package/dist/trace/core-keyset-guard.d.ts +13 -6
- 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 +24 -21
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +30 -4
- package/dist/trace/exit-seat.js +40 -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 +4 -31
- 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 +59 -44
- package/dist/trace/project.js +60 -26
- package/dist/trace/redact.d.ts +135 -27
- package/dist/trace/redact.js +884 -260
- package/dist/trace/self-minted-wire.d.ts +567 -20
- package/dist/trace/self-minted-wire.js +205 -24
- package/dist/trace/wire-projection-faces.d.ts +5 -6
- package/dist/trace/wire-projection-faces.js +2 -2
- 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 -23
- 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/center-request.d.ts +2 -2
- package/dist/web-admin-client/center-request.js +15 -15
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +1 -1
- 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/http-client.d.ts +1 -1
- package/dist/web-admin-client/http-client.js +23 -4
- 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 +8 -4
- package/dist/web-admin-client/skills-mcp.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +1 -2
- package/dist/workspace-space.d.ts +3 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
- package/docs/error-text-lexicon.json +317 -0
- package/package.json +8 -3
- package/scripts/drain-check-local.mjs +118 -147
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/scripts/embed-minimal.mjs +183 -0
- package/wire-changes/server@7.148.0.json +1517 -0
- package/wire-changes/server@7.149.0.json +372 -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/plain-string-record.js +0 -70
package/dist/runs.d.ts
CHANGED
|
@@ -9,12 +9,14 @@ import { type RunAbort } from "./run-cancel-context.js";
|
|
|
9
9
|
import type { ModelUsageTracker, PromptManifestTracker } from "./budget.js";
|
|
10
10
|
import type { ElicitationCoordinator } from "./elicitation.js";
|
|
11
11
|
import type { QuestionCoordinator } from "./question.js";
|
|
12
|
+
import type { ApprovalLegOrigin } from "./approval-leg-origin.js";
|
|
12
13
|
import { type ApprovalFrameFamily, type ToolApprovalCoordinator } from "./tool-approval.js";
|
|
13
14
|
import { type FleetRunPublisher } from "./fleet/fleet-bus.js";
|
|
14
15
|
import { type WorkflowCompletionInbox } from "./orchestration/workflow-completion-inbox.js";
|
|
15
16
|
import type { RunAcceptance } from "./run-acceptance.js";
|
|
16
17
|
import type { SessionWorkspaceRecorder } from "./session-workspace.js";
|
|
17
18
|
import type { VerifyRoundsSpec } from "./http/verify-rounds.js";
|
|
19
|
+
import { type ParkLedgerEventType } from "./trace/ledger-events.js";
|
|
18
20
|
import type { UserInputLedger } from "./user-input-ledger.js";
|
|
19
21
|
/**
|
|
20
22
|
* stoppedBy (core 1.252): a service cancel is a USER stop — mark the run's still-running background
|
|
@@ -94,7 +96,7 @@ export declare function taskHandleStop(registry: typeof defaultTaskRegistry, han
|
|
|
94
96
|
* 已 fire 的信号永不回调,那样一次真实的人为断连会被吞成「无归因」(子代 settle 时记成 system)。
|
|
95
97
|
* 语义上这两种时序是同一件事:本请求赢下了这条 session,而这条 session 的连接是被人断掉的。
|
|
96
98
|
*/
|
|
97
|
-
export declare function markChildrenStoppedByUserOnAbort(signal: AbortSignal, taskId: string,
|
|
99
|
+
export declare function markChildrenStoppedByUserOnAbort(signal: AbortSignal, taskId: string, subject: string | null | undefined): void;
|
|
98
100
|
export declare function resumeAtHttpStatus(result: {
|
|
99
101
|
terminal: TerminalCause;
|
|
100
102
|
}): number | undefined;
|
|
@@ -114,7 +116,7 @@ export declare function resumeAtHttpStatus(result: {
|
|
|
114
116
|
export declare function syncRefusalHttpStatus(result: Pick<TaskResult, "terminal" | "stats">): number | undefined;
|
|
115
117
|
/**
|
|
116
118
|
* 同步腿零工作拒体的机读事实(交 `refusalBody` 的 `facts`)—— 唯一一处。入参是**出口封口 + 脱敏后**的终局(调用方递 `redactTerminalResult(sealResultForExit(result)).terminal`,
|
|
117
|
-
* 与 run 记录读面 / 流式 `done.result` 上的 `terminal` 同一只来源),本函数只按码取它的 `detail.detail
|
|
119
|
+
* 与 run 记录读面 / 流式 `done.result` 上的 `terminal` 同一只来源),本函数只按码取它的 `detail.detail` 经闭集映射({@link attachmentCauseFacts}),不另读、不另脱。码不在登记表里、终局不是 `failed`、
|
|
118
120
|
* 引擎没给 `coded` 因由 ⇒ `{}`(缺席不造键)。
|
|
119
121
|
* 两张工具名清单的码({@link ENGINE_TOOL_LIST_REFUSAL_CODES})是另一臂:体事实不取引擎的因由,取 `admissionReadings`(受理口对放行侧选择器清单的读数,`PreparedTaskSubmission.warnings`)
|
|
120
122
|
* 去掉 `not_in_roster`、且 `code` 与终局的码相同(同一族清单)的那些 —— 与受理口 400 同一只机读位形;没有读数 ⇒ `{}`。
|
|
@@ -132,8 +134,8 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
132
134
|
releaseIdemKey(taskId: string): Promise<void>;
|
|
133
135
|
}, taskId: string, result: Pick<TaskResult, "terminal" | "stats">): Promise<void>;
|
|
134
136
|
/**
|
|
135
|
-
* E18 resume-at — per-turn anchor capture, shared by runInBackground
|
|
136
|
-
* tricky) capture rule can't drift between the
|
|
137
|
+
* E18 resume-at — per-turn anchor capture, shared by runInBackground, the resume-leg driveResume AND the sync `POST /v1/tasks`
|
|
138
|
+
* leg's plain form so the (single, tricky) capture rule can't drift between the stream-drain loops.
|
|
137
139
|
*
|
|
138
140
|
* A "turn" in core = ONE assistant message + its tool batch. resume-at is valid ONLY at a SETTLED rewindable boundary
|
|
139
141
|
* — core's prepare-task accepts "user messages or finished assistant-text turns" and REJECTS an assistant message that
|
|
@@ -151,7 +153,7 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
151
153
|
* observable instead of a silent feature outage.
|
|
152
154
|
*/
|
|
153
155
|
/**
|
|
154
|
-
* 「这一次用户消息提交是不是这个 run 的**开场提示**」的唯一读法 ——
|
|
156
|
+
* 「这一次用户消息提交是不是这个 run 的**开场提示**」的唯一读法 —— 四处用户回退锚(后台腿 / 续跑腿 / 同步腿 `POST /v1/tasks` 的 {@link TurnAnchorCapture}、`/v1/tasks/stream`
|
|
155
157
|
* 腿的 `userMsgEntryId`)同调这一只;调用点零各自判、零按正文判,且都是「最后一次交出的赢」。
|
|
156
158
|
*
|
|
157
159
|
* **回退锚 = 该轮开场提示,一个 run 一个(开场窗 + 闩)**:run 一开始就开着一个**开场窗**,收集第一次模型输出之前的 user 提交;窗关上之后(闩上),同 run 的 user-role 提交 ——
|
|
@@ -189,13 +191,13 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
189
191
|
export declare function createPromptCommitReader(): (ev: {
|
|
190
192
|
readonly type: string;
|
|
191
193
|
}) => string | undefined;
|
|
192
|
-
/** 回退锚写在哪条腿上(探针行的 `leg=`):流式腿 `POST /v1/tasks/stream
|
|
193
|
-
export type ResumeAnchorLeg = "stream" | "bg" | "resume";
|
|
194
|
+
/** 回退锚写在哪条腿上(探针行的 `leg=`):流式腿 `POST /v1/tasks/stream`、同步腿 `POST /v1/tasks`(非流式)、后台腿 `POST /v1/runs`、续跑腿。 */
|
|
195
|
+
export type ResumeAnchorLeg = "stream" | "sync" | "bg" | "resume";
|
|
194
196
|
/**
|
|
195
|
-
* 回退锚的**唯一**写法(
|
|
197
|
+
* 回退锚的**唯一**写法(四条腿同一只):**有界** await 写入(单行店操作期限 {@link BASELINE_IO_DEADLINE_MS},与项目指令基线的
|
|
196
198
|
* 读写同一只数、同一只 {@link withinIoDeadline} —— 同为单行 PK 写、同在腿的关键路径上);写失败或到期 ⇒ 不抛(锚是这次提示词能不能
|
|
197
199
|
* 回退的手柄,不是 run 的成败),记一次登记过的 fail-open `server.resume-anchor.capture-failed`(`reason=error|timeout`;计数 + 探针行 + 一次性 warn)。
|
|
198
|
-
* 调用方在本腿的终帧(流式腿的 `done
|
|
200
|
+
* 调用方在本腿的终帧(流式腿的 `done`、同步腿的 200 应答)**之前** await 它 ⇒ 客户端拿到终帧时锚已落定或已知没落定,没有「锚晚到」的窗;锚店挂住至多让终帧晚一个期限。
|
|
199
201
|
* 到期只放手不取消:那次写照常在飞,迟到落定的锚照样可用(迟到的失败被吞,不重复计数)。
|
|
200
202
|
* 用户面的读数仍只有一处:会话视图用户消息行的 `taskId?`(present-iff 锚在)与 `resumeAt` 的 404 `resume_at.unknown_event`。
|
|
201
203
|
*/
|
|
@@ -211,7 +213,7 @@ export declare class TurnAnchorCapture {
|
|
|
211
213
|
* `message_committed{role:"user"}` event — its `entryId` is the persisted user-message `SessionTreeEntry.id`,
|
|
212
214
|
* ALWAYS a valid `resumeAt` target (core accepts a user message; it rejects a tool-result / mid-tool-call
|
|
213
215
|
* assistant). This is the CC rewind target ("rewind to the prompt" = the code-restore parity path — a code
|
|
214
|
-
* change happens in a tool turn WITHIN a prompt's run, so rewinding to the prompt +
|
|
216
|
+
* change happens in a tool turn WITHIN a prompt's run, so rewinding to the prompt + restoreFiles undoes it).
|
|
215
217
|
* Keyed by the run's taskId (the handle the shell already holds from the POST response — no eventId→entryId
|
|
216
218
|
* side map / no leaf-read inference needed). The assistant-turn capture above stays as an additive bonus.
|
|
217
219
|
* The anchor is the run's OPENING prompt (the reader's opening window: provisional on the first user commit, corrected
|
|
@@ -232,7 +234,7 @@ export declare class TurnAnchorCapture {
|
|
|
232
234
|
* `message_committed{role:"user"}` event — its `entryId` is the persisted user-message `SessionTreeEntry.id`,
|
|
233
235
|
* ALWAYS a valid `resumeAt` target (core accepts a user message; it rejects a tool-result / mid-tool-call
|
|
234
236
|
* assistant). This is the CC rewind target ("rewind to the prompt" = the code-restore parity path — a code
|
|
235
|
-
* change happens in a tool turn WITHIN a prompt's run, so rewinding to the prompt +
|
|
237
|
+
* change happens in a tool turn WITHIN a prompt's run, so rewinding to the prompt + restoreFiles undoes it).
|
|
236
238
|
* Keyed by the run's taskId (the handle the shell already holds from the POST response — no eventId→entryId
|
|
237
239
|
* side map / no leaf-read inference needed). The assistant-turn capture above stays as an additive bonus.
|
|
238
240
|
* The anchor is the run's OPENING prompt (the reader's opening window: provisional on the first user commit, corrected
|
|
@@ -283,16 +285,24 @@ export declare function parkToolCallId(result: unknown, cs: ParkCheckpointReader
|
|
|
283
285
|
* 不塞进 `checkpointGate`——那是 core 的类型,server 不改其形)。非 park / 无 token / tool-less /
|
|
284
286
|
* 读失败 ⇒ **同一引用**原样返回(键缺席)。graft 不负责 strip——组合序恒为 graft → strip。 */
|
|
285
287
|
export declare function graftParkToolCallId<T>(result: T, cs: ParkCheckpointReader | undefined): Promise<T>;
|
|
288
|
+
/** 一份结果在等的那张卡与它停在的停驻词(暂停因由 ∧ 投影出口给的词是停驻词);不是停驻 ⇒ `undefined`。后台腿的停驻臂与兜底腿、续跑腿的兜底同读它。 */
|
|
289
|
+
export interface HeldPark {
|
|
290
|
+
readonly word: ParkLedgerEventType;
|
|
291
|
+
readonly token: CheckpointToken;
|
|
292
|
+
}
|
|
293
|
+
export declare function heldParkOf(result: TaskResult): HeldPark | undefined;
|
|
286
294
|
/**
|
|
287
|
-
* 🔴 [ref]
|
|
295
|
+
* 🔴 [ref] **手里握着已提交的卡却以终局收场的腿:卡的命运先于认领释放**(后台腿与续跑腿同读这一只;动词 = `card-void.ts` 的结算作废)。
|
|
288
296
|
*
|
|
289
|
-
*
|
|
297
|
+
* 腿要以终局收场(行 `failed`、认领释放),而手里的结果是宿主层停驻 —— 引擎交回结果之前已把卡落进 checkpoint 店,卡在本 run 的会话上 ——
|
|
290
298
|
* ⇒ 先把那张卡按它自己的 scope 作废,调用方再放认领。不作废 ⇒ 待决面上留一张卡,兑现它的 run 已经 `failed`、认领已放:决定口照样受理,
|
|
291
299
|
* 续跑在没有认领的会话上驱动(`resume-legs.ts` 认领缺席的成因清单)。顺序承重:先放认领、后作废 ⇒ 两步之间(作废没做成时一直)就是那一形。
|
|
292
|
-
*
|
|
300
|
+
* 走到这里的只剩「这条 run 真的不再等这张卡」的形:取消落在结果到手之后(两条腿)、暂停结果不是停驻词。
|
|
301
|
+
* 停驻簿记写抛(账本帧 / 用量差 / 结果到手之后的清单行与缓冲文本)**不**走到这里 —— 卡已提交 ⇒ 照常提交停驻({@link commitParkRow}),
|
|
302
|
+
* 簿记只留痕;行的停驻写被店答出拒(行已不是本腿的)由提交口自己作废那张卡。
|
|
293
303
|
*
|
|
294
|
-
* `held` = 手里那份结果过了宿主判官之后的形(
|
|
295
|
-
*
|
|
304
|
+
* `held` = 手里那份结果过了宿主判官之后的形(判官提上来的嵌套停驻同样算 —— verify 的实现腿 / 修复轮、cascade 的级上卡,都归本 run 的会话)。
|
|
305
|
+
* 不是停驻 ⇒ 零 I/O。不抛:作废没做成 ⇒ 卡回到「留在待决面上、由兜底收割收走」的形,响亮留痕。
|
|
296
306
|
*/
|
|
297
307
|
export declare function voidHeldParkCard(held: {
|
|
298
308
|
readonly terminal: TerminalCause;
|
|
@@ -328,11 +338,22 @@ export declare function voidHeldParkCard(held: {
|
|
|
328
338
|
* only — a suspended run is steered durably via the checkpoint's `setPendingSteer` instead, and only the
|
|
329
339
|
* plain-stream path holds a steerable stream (the verify/cascade branches return a result, not a stream).
|
|
330
340
|
*/
|
|
331
|
-
export declare function runInBackground(runner: Runner, spec: TaskSpec, runStore: RunStore, taskId: string,
|
|
341
|
+
export declare function runInBackground(runner: Runner, spec: TaskSpec, runStore: RunStore, taskId: string,
|
|
342
|
+
/**
|
|
343
|
+
* 本腿停驻的两条事实,只有一个读者 —— 停驻提交({@link commitParkRow}):`legId` = 本腿的持有腿(建行 `createRun` 交回的 `{ ok: true, legId }`,
|
|
344
|
+
* 停驻写只许它落下);`runStaleSec` = 判活窗(秒,`REAP_RUN_STALE_SEC`,活配置;路由层 `deps.config.runStaleSec`;缺席 ⇒ 缺省窗),店故障时再提交的上界。
|
|
345
|
+
* 必填:持有腿是认领交给本腿的,不是读来的 —— 调用方不交它,停驻就无从提交(编译期红,不留运行期的缺席臂)。
|
|
346
|
+
*/
|
|
347
|
+
parkCommit: {
|
|
348
|
+
readonly legId: string;
|
|
349
|
+
readonly runStaleSec: number | undefined;
|
|
350
|
+
}, metrics?: Metrics,
|
|
351
|
+
/** 本跑的属主主体(分区键;行属主 / ALS 读它)。 */
|
|
352
|
+
principal?: string, verify?: VerifyRoundsSpec, // 快审 F1:number 参升整对象——cost 顶随传
|
|
332
353
|
cascade?: CascadeConfig, instrumentDegenerate?: (result: TaskResult) => void, planCacheProbe?: {
|
|
333
354
|
record: (scope: string | undefined, objective: string, completed: boolean) => void;
|
|
334
355
|
}, persistThinking?: boolean, inflight?: Map<string, RunAbort>, preemptable?: Map<string, AbortController>, steerable?: Map<string, TaskStream>, modelUsage?: ModelUsageTracker, elicitation?: ElicitationCoordinator,
|
|
335
|
-
/** E23: the VERIFIED principal (
|
|
356
|
+
/** E23: the VERIFIED principal (gatedSubject) that may answer this run's elicitations — matches the respond
|
|
336
357
|
* owner-gate's identity source (NOT the cost-attribution `principal`, which on a direct door is the self-asserted
|
|
337
358
|
* header → can be null while a JWT principal exists). Falls back to the run owner when not supplied. */
|
|
338
359
|
elicitOwner?: string | null,
|
|
@@ -386,8 +407,8 @@ approval?: {
|
|
|
386
407
|
streamApprovalOn: boolean;
|
|
387
408
|
windowMs: number | undefined;
|
|
388
409
|
windowMarginMs: number;
|
|
389
|
-
declaredFamilies: ReadonlySet<ApprovalFrameFamily>; /**
|
|
390
|
-
|
|
410
|
+
declaredFamilies: ReadonlySet<ApprovalFrameFamily>; /** 出处带车道 + 化身:这条执行上下文的车道与那一读的住客(装配点 `durable-run-leg.ts` 经 `approvalLegOriginOf` 写)。 */
|
|
411
|
+
origin: ApprovalLegOrigin;
|
|
391
412
|
},
|
|
392
413
|
/** 本腿结算用的 checkpoint 店(`deps.checkpointStore`),两件事:①[ref] park 投影腿的读口 —— 在场时 durable park 的
|
|
393
414
|
* `suspended` 事件带 `toolCallId`(graft 见 {@link parkToolCallId});②停驻没落定就以失败收场时作废手里那张卡({@link voidHeldParkCard})。
|
|
@@ -434,7 +455,21 @@ workspaceRecorder?: SessionWorkspaceRecorder,
|
|
|
434
455
|
* 这条 run 交给引擎的技能名册(`wiring_manifest.skills` 段;部署事实 `LegFacts.skills`,`leg-facts.ts`:受理漏斗在复制之前读出)。
|
|
435
456
|
* 缺席 = 嵌入方自带的装配器没铸 ⇒ 账本行不带技能段。
|
|
436
457
|
*/
|
|
437
|
-
runSkills?: readonly RunSkillEntry[]
|
|
458
|
+
runSkills?: readonly RunSkillEntry[],
|
|
459
|
+
/**
|
|
460
|
+
* 这次提交登记的工作目录(部署事实 `LegFacts.registeredCwd`)。只在两条组合腿(verify / cascade)上经 `compositionLegRoot` 交给引擎 ——
|
|
461
|
+
* 梯子的级 / 验证器腿跑在引擎现铸的会话里,工厂按会话读不到它;普通流形跑在根会话上,工厂自己读得到。缺席 = 没登记 ⇒ 每一条腿照旧落临时目录。
|
|
462
|
+
*/
|
|
463
|
+
registeredCwd?: string): Promise<void>;
|
|
464
|
+
/** 一次心跳要的那一面(run 店的带属主刷新;交回「行还在 running 吗」)。 */
|
|
465
|
+
export interface RunHeartbeatStore {
|
|
466
|
+
heartbeat(taskId: string, owner: string | null): Promise<boolean>;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* 🔴 **一次心跳**(四条腿的心跳拍与认领心跳 `http/claim-heartbeat.ts` 同一只 —— 判法只在这里):刷新,店交回「这条 run 的行还在 running 吗」;不在 ⇒ `onLost()`,持有者停下自己的腿。
|
|
470
|
+
* 判死一条行(观察口 / 认领冲突 / 收割器)拦不住它的执行者 —— 心跳打空今天不报,两个执行者会同写一只会话;这一答补上那一半。刷新失败不抛(`onError` 计数),下一拍再刷。
|
|
471
|
+
*/
|
|
472
|
+
export declare function beatRunHeartbeat(runStore: RunHeartbeatStore, taskId: string, owner: string | null, onLost: () => void, onError: () => void): void;
|
|
438
473
|
/** How often a running instance refreshes its run's updated_at (liveness, independent of events).
|
|
439
474
|
* Must stay strictly below `runStaleSec` (asserted at startup AND on every hot config candidate) or the
|
|
440
475
|
* reaper would race live runs. [ref]:数值的单源是 `config-invariants.ts`(那条不变量的属主),两个消费面
|
package/dist/runs.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { runWithVerification, runCascade, defaultTaskRegistry, taskNotificationDedupKey, DURABLE_AGENT_HANDLE_RE } from "@sema-agent/core";
|
|
2
|
-
import { atHostBoundary, failureCodeOf, sealResultForExit, outwardPlane } from "./terminal.js";
|
|
2
|
+
import { atHostBoundary, failureCodeOf, sealResultForExit, outwardPlane, outwardThrownMessage } from "./terminal.js";
|
|
3
3
|
import { voidVerifierPauseCard } from "./verifier-pause-card.js";
|
|
4
4
|
import { voidPendingCard } from "./card-void.js";
|
|
5
|
+
import { commitParkRow } from "./park-row-commit.js";
|
|
5
6
|
import { NOT_IN_ROSTER, entryProblemsFacts } from "./entry-problems.js";
|
|
6
7
|
import { GOVERNANCE_HTTP_STATUS } from "./governance-http-status.js";
|
|
7
8
|
import { TOOL_DECLARATION_HTTP_STATUS } from "./tool-declaration-http-status.js";
|
|
8
9
|
import { isSessionErrorCode, sessionErrorHttp } from "./session-error-wire.js";
|
|
9
10
|
import { redactErrorMessage } from "./observability/run-terminal.js";
|
|
10
|
-
import {
|
|
11
|
+
import { withSubject } from "./observability/principal-context.js";
|
|
12
|
+
import { partsOf } from "./owner-brands.js";
|
|
13
|
+
import { recoveredSubject } from "./owner-faces.js";
|
|
14
|
+
import { taskSpecIdentityOf } from "./engine-identity.js";
|
|
11
15
|
import { withModelReachScope } from "./model-reach-scope.js";
|
|
12
16
|
import { createInstructionSelectionLeg } from "./instruction-selection.js";
|
|
13
17
|
import { redactSecrets } from "./trace/redact.js";
|
|
@@ -16,7 +20,8 @@ import { createLedgerSink } from "./trace/ledger-sink.js";
|
|
|
16
20
|
import { registerEngineNoticeLeg } from "./trace/engine-notice-wire.js";
|
|
17
21
|
import { recordTurnActivity } from "./turn-activity.js";
|
|
18
22
|
import { buildCancelledLedgerRow, CANCELLED_CODE, createRunAbort, mintCancelledResult } from "./run-cancel-context.js";
|
|
19
|
-
import {
|
|
23
|
+
import { resolveApprovalLeg } from "./tool-approval.js";
|
|
24
|
+
import { createHitlTransport } from "./hitl-delivery.js";
|
|
20
25
|
import { fleetRunResiduals } from "./fleet/fleet-bus.js";
|
|
21
26
|
import { defaultSubagentTailBus } from "./fleet/subagent-tail-bus.js";
|
|
22
27
|
import { emitPendingWorkflowCompletions, taskNotificationInboxEntry, taskNotificationStreamKeyOf, NotifiedKeys } from "./orchestration/workflow-completion-inbox.js";
|
|
@@ -25,6 +30,7 @@ import { recordFailOpen } from "./observability/fail-open.js";
|
|
|
25
30
|
import { BASELINE_IO_DEADLINE_MS, IoDeadlineExceeded, withinIoDeadline } from "./instruction-source-notice.js";
|
|
26
31
|
import { errorText as errText } from "./observability/err-text.js";
|
|
27
32
|
import { LIVENESS_HEARTBEAT_MS } from "./config-invariants.js";
|
|
33
|
+
import { compositionLegRoot } from "./task-cwd.js";
|
|
28
34
|
export async function backgroundAgentOutput(registry, handle, access, agentStore) {
|
|
29
35
|
const row = registry.getAccessibleTask(handle, access);
|
|
30
36
|
if (!row || row.type !== "background_agent") {
|
|
@@ -55,7 +61,9 @@ export async function taskHandleStop(registry, handle, access, agentStore) {
|
|
|
55
61
|
registry.markStopSource(handle, "user");
|
|
56
62
|
return registry.stopTask(handle, access);
|
|
57
63
|
}
|
|
58
|
-
export function markChildrenStoppedByUserOnAbort(signal, taskId,
|
|
64
|
+
export function markChildrenStoppedByUserOnAbort(signal, taskId, subject) {
|
|
65
|
+
const recovered = recoveredSubject(subject);
|
|
66
|
+
const principal = taskSpecIdentityOf(recovered === undefined ? undefined : partsOf(recovered)).principal;
|
|
59
67
|
const mark = () => {
|
|
60
68
|
try {
|
|
61
69
|
defaultTaskRegistry.markStopSourceForOwner({ owner: taskId, scope: principal ?? "default" }, "user", { skipSessionScoped: true });
|
|
@@ -85,6 +93,7 @@ const PREPARE_REFUSAL_HTTP_STATUS = {
|
|
|
85
93
|
"config.invalid_checkpoint_store": 400,
|
|
86
94
|
"config.skill_listing_budget_invalid": 400,
|
|
87
95
|
"config.user_invoked_skill_unknown": 400,
|
|
96
|
+
"config.skill_deny_unreadable": 409,
|
|
88
97
|
"config.image_invalid": 400,
|
|
89
98
|
"config.user_attachment_invalid": 400,
|
|
90
99
|
"config.tool_face_control": 400,
|
|
@@ -127,6 +136,15 @@ export function syncRefusalHttpStatus(result) {
|
|
|
127
136
|
return resumeAtHttpStatus(result);
|
|
128
137
|
}
|
|
129
138
|
const ZERO_WORK_REFUSAL_DETAIL_CODES = new Set(["config.user_attachment_invalid"]);
|
|
139
|
+
function attachmentCauseFacts(cause) {
|
|
140
|
+
if (cause === null || typeof cause !== "object")
|
|
141
|
+
return {};
|
|
142
|
+
const c = cause;
|
|
143
|
+
return {
|
|
144
|
+
...(typeof c.path === "string" && c.path !== "" ? { field: c.path } : {}),
|
|
145
|
+
...(typeof c.index === "number" && Number.isInteger(c.index) && c.index >= 0 ? { index: c.index } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
130
148
|
const ENGINE_ENTRY_SPELLING_REASONS = new Set(["near_miss", "unknown_name"]);
|
|
131
149
|
function engineReasonOf(detail) {
|
|
132
150
|
if (detail === null || typeof detail !== "object")
|
|
@@ -155,7 +173,7 @@ export function zeroWorkRefusalFacts(terminal, admissionReadings = []) {
|
|
|
155
173
|
if (cause === null || typeof cause !== "object")
|
|
156
174
|
return {};
|
|
157
175
|
const c = cause;
|
|
158
|
-
return c.kind === "coded"
|
|
176
|
+
return c.kind === "coded" ? attachmentCauseFacts(c.detail) : {};
|
|
159
177
|
}
|
|
160
178
|
const RETRY_CLASS_WORDS = { transient: true, terminal: true };
|
|
161
179
|
function engineRetryClassOf(terminal) {
|
|
@@ -286,12 +304,18 @@ export async function graftParkToolCallId(result, cs) {
|
|
|
286
304
|
const id = await parkToolCallId(result, cs);
|
|
287
305
|
return id === undefined ? result : { ...result, toolCallId: id };
|
|
288
306
|
}
|
|
307
|
+
export function heldParkOf(result) {
|
|
308
|
+
if (result.terminal.kind !== "paused")
|
|
309
|
+
return undefined;
|
|
310
|
+
const word = outwardPlane(result.terminal).status;
|
|
311
|
+
return isParkLedgerEventType(word) ? { word, token: result.terminal.token } : undefined;
|
|
312
|
+
}
|
|
289
313
|
export async function voidHeldParkCard(held, hostSessionId, cards, leg) {
|
|
290
314
|
if (held?.terminal.kind !== "paused")
|
|
291
315
|
return;
|
|
292
316
|
await voidPendingCard({ token: held.terminal.token, sessionId: hostSessionId }, cards, "server.park.held-card-void-failed", `leg=${leg}`);
|
|
293
317
|
}
|
|
294
|
-
export async function runInBackground(runner, spec, runStore, taskId, metrics, principal, verify, cascade, instrumentDegenerate, planCacheProbe, persistThinking = false, inflight, preemptable, steerable, modelUsage, elicitation, elicitOwner, captureTurnAnchor, fleetPublisher, captureUserMessageAnchor, question, workflowCompletionInbox, subagentSteer, completionDiagLog, sendUserFile, promptManifests, approval, checkpointCards, pendingEngineNotices, trustedInternals, userInputLedger, acceptance, workspaceRecorder, runSkills) {
|
|
318
|
+
export async function runInBackground(runner, spec, runStore, taskId, parkCommit, metrics, principal, verify, cascade, instrumentDegenerate, planCacheProbe, persistThinking = false, inflight, preemptable, steerable, modelUsage, elicitation, elicitOwner, captureTurnAnchor, fleetPublisher, captureUserMessageAnchor, question, workflowCompletionInbox, subagentSteer, completionDiagLog, sendUserFile, promptManifests, approval, checkpointCards, pendingEngineNotices, trustedInternals, userInputLedger, acceptance, workspaceRecorder, runSkills, registeredCwd) {
|
|
295
319
|
const startedAt = Date.now();
|
|
296
320
|
metrics?.addGauge("runs_active", 1);
|
|
297
321
|
fleetPublisher?.onStart();
|
|
@@ -329,17 +353,17 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
329
353
|
if (approval) {
|
|
330
354
|
const coordinator = approval.coordinator;
|
|
331
355
|
spec.onAsk = approvalLeg.unattended
|
|
332
|
-
? coordinator.boundUnattendedAsk({ owner: elicitOwner ?? owner, taskId, ...(spec.sessionId ? { sessionId: spec.sessionId } : {}),
|
|
356
|
+
? coordinator.boundUnattendedAsk({ owner: elicitOwner ?? owner, taskId, ...(spec.sessionId ? { sessionId: spec.sessionId } : {}), ...approval.origin }, approvalLeg.unattended)
|
|
333
357
|
: coordinator.boundAsk({
|
|
334
358
|
owner: elicitOwner ?? owner,
|
|
335
359
|
taskId,
|
|
336
360
|
...(spec.sessionId ? { sessionId: spec.sessionId } : {}),
|
|
337
|
-
|
|
361
|
+
...approval.origin,
|
|
338
362
|
...(approvalLeg.active ? { legKey: "", ...(legDeadlineMonotonic !== undefined ? { legDeadlineMonotonic } : {}) } : {}),
|
|
339
363
|
});
|
|
340
364
|
}
|
|
341
365
|
const heartbeat = setInterval(() => {
|
|
342
|
-
|
|
366
|
+
beatRunHeartbeat(runStore, taskId, owner, () => cancelCtrl.abort("stall_verdict"), () => { metrics?.inc("run_signal_poll_errors_total", { kind: "heartbeat" }); });
|
|
343
367
|
if (!cancelCtrl.signal.aborted) {
|
|
344
368
|
void runStore.isCancelRequested(taskId, owner).then((c) => { if (c)
|
|
345
369
|
cancelCtrl.abort("cancel_verb"); }).catch(() => { metrics?.inc("run_signal_poll_errors_total", { kind: "cancel" }); });
|
|
@@ -359,23 +383,26 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
359
383
|
let legLive = true;
|
|
360
384
|
const notifiedKeys = new NotifiedKeys();
|
|
361
385
|
const subagentHandleEvictions = [];
|
|
362
|
-
const
|
|
363
|
-
suspended: (sealed) => runStore.setSuspended(taskId, sealed),
|
|
364
|
-
needs_review: (sealed) => runStore.setNeedsReview(taskId, sealed),
|
|
365
|
-
};
|
|
366
|
-
const parkLeg = async (word, res) => {
|
|
386
|
+
const parkLeg = async ({ word, token }, res) => {
|
|
367
387
|
const grafted = await graftParkToolCallId(res, checkpointCards);
|
|
368
388
|
await sink.appendParked(word, grafted);
|
|
369
389
|
const sealed = sealResultForExit(grafted);
|
|
370
390
|
reached = { kind: word, result: sealed };
|
|
371
|
-
await
|
|
391
|
+
const committed = await commitParkRow({
|
|
392
|
+
runStore, taskId, word, result: sealed, card: { token, sessionId: spec.sessionId }, cards: checkpointCards, leg: "bg",
|
|
393
|
+
legId: parkCommit.legId, staleWindowMs: parkCommit.runStaleSec === undefined ? undefined : parkCommit.runStaleSec * 1000,
|
|
394
|
+
});
|
|
395
|
+
if (committed.kind === "ended") {
|
|
396
|
+
reached = undefined;
|
|
397
|
+
settledAsCancel = committed.row?.errorCode === CANCELLED_CODE;
|
|
398
|
+
}
|
|
372
399
|
acceptance?.settle(sealed);
|
|
373
400
|
};
|
|
374
401
|
const settleLegResult = async (engineResult) => {
|
|
375
|
-
const result = atHostBoundary(engineResult
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
await parkLeg(
|
|
402
|
+
const result = atHostBoundary(engineResult);
|
|
403
|
+
const held = heldParkOf(result);
|
|
404
|
+
if (held !== undefined) {
|
|
405
|
+
await parkLeg(held, result);
|
|
379
406
|
return;
|
|
380
407
|
}
|
|
381
408
|
const settled = causeAtDone !== undefined ? cancelledResult(causeAtDone, result) : result;
|
|
@@ -397,24 +424,16 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
397
424
|
modelUsage?.register(taskId);
|
|
398
425
|
const manifestSeat = createPromptManifestSeat(promptManifests, taskId);
|
|
399
426
|
const flushPromptManifest = () => manifestSeat.drain(append);
|
|
400
|
-
const
|
|
401
|
-
const { type, ...rest } = frame;
|
|
402
|
-
return append(type, rest);
|
|
403
|
-
};
|
|
404
|
-
const questionEmit = (frame) => {
|
|
405
|
-
const { type, ...rest } = frame;
|
|
406
|
-
return append(type, rest);
|
|
407
|
-
};
|
|
408
|
-
const approvalEmit = (frame) => {
|
|
409
|
-
const { type, ...rest } = frame;
|
|
410
|
-
return append(type, rest);
|
|
411
|
-
};
|
|
427
|
+
const hitlTransport = createHitlTransport({ ledger: append });
|
|
412
428
|
const unregisterEngineNotice = registerEngineNoticeLeg({
|
|
413
429
|
sessionId: spec.sessionId,
|
|
430
|
+
taskId,
|
|
414
431
|
...(pendingEngineNotices !== undefined ? { pending: pendingEngineNotices } : {}),
|
|
415
432
|
durable: (row) => append("engine_notice", row).then(() => true, () => (recordFailOpen("server.engine-notice.durable-append-failed", `leg=bg code=${row.code} task=${taskId}`), false)),
|
|
416
433
|
});
|
|
417
434
|
try {
|
|
435
|
+
if (typeof parkCommit?.legId !== "string" || parkCommit.legId === "")
|
|
436
|
+
throw new TypeError(`runInBackground: run ${taskId} was started without the holding leg its claim handed back (parkCommit.legId) — refusing to start a run whose park could never be committed`);
|
|
418
437
|
if (userInputLedger && spec.sessionId)
|
|
419
438
|
await userInputLedger.announceUndrained({ sessionId: spec.sessionId, taskId });
|
|
420
439
|
await emitPendingWorkflowCompletions(workflowCompletionInbox, spec.sessionId, elicitOwner ?? owner, (frame) => {
|
|
@@ -471,10 +490,11 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
471
490
|
void sink.appendStatus(e).catch((err) => completionDiagLog?.("status_event_append_failed", { route: "bg-run-composite", taskId, err: err instanceof Error ? err.message : String(err) }));
|
|
472
491
|
},
|
|
473
492
|
};
|
|
493
|
+
const compositeInternals = { ...fwdInternals, ...statusSeat, ...compositionLegRoot(registeredCwd) };
|
|
474
494
|
const compositeLeg = verify !== undefined
|
|
475
|
-
? () => runWithVerification(runner, { ...spec, taskId, signal: cancelCtrl.signal }, verify,
|
|
495
|
+
? () => runWithVerification(runner, { ...spec, taskId, signal: cancelCtrl.signal }, verify, compositeInternals)
|
|
476
496
|
: cascade !== undefined
|
|
477
|
-
? () => runCascade(runner, { ...spec, taskId, signal: cancelCtrl.signal }, cascade,
|
|
497
|
+
? () => runCascade(runner, { ...spec, taskId, signal: cancelCtrl.signal }, cascade, compositeInternals)
|
|
478
498
|
: undefined;
|
|
479
499
|
if (compositeLeg !== undefined) {
|
|
480
500
|
const result = await compositeLeg();
|
|
@@ -532,12 +552,12 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
532
552
|
await append("suggestions", { suggestions: suggestions.map((s) => redactSecrets(s)) });
|
|
533
553
|
}
|
|
534
554
|
};
|
|
535
|
-
await instructionLeg.run(spec.sessionId, () => withModelReachScope({ sessionId: spec.sessionId, taskId }, () =>
|
|
555
|
+
await instructionLeg.run(spec.sessionId, () => withModelReachScope({ sessionId: spec.sessionId, taskId }, () => withSubject(recoveredSubject(principal), () => {
|
|
536
556
|
const withElicit = elicitation
|
|
537
|
-
? () => elicitation.runWithContext({ taskId, owner: elicitOwner ?? owner,
|
|
557
|
+
? () => elicitation.runWithContext({ taskId, owner: elicitOwner ?? owner, transport: hitlTransport, abortSignal: cancelCtrl.signal }, runBody)
|
|
538
558
|
: runBody;
|
|
539
559
|
const withQuestion = () => question
|
|
540
|
-
? question.runWithContext({ taskId, owner: elicitOwner ?? owner,
|
|
560
|
+
? question.runWithContext({ taskId, owner: elicitOwner ?? owner, transport: hitlTransport, abortSignal: cancelCtrl.signal }, withElicit)
|
|
541
561
|
: withElicit();
|
|
542
562
|
const withApproval = () => approval && approvalLeg.active && approvalLeg.unattended === undefined
|
|
543
563
|
? approval.coordinator.runWithContext({
|
|
@@ -545,9 +565,9 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
545
565
|
owner: elicitOwner ?? owner,
|
|
546
566
|
abortSignal: cancelCtrl.signal,
|
|
547
567
|
...(spec.sessionId ? { sessionId: spec.sessionId } : {}),
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
568
|
+
...approval.origin,
|
|
569
|
+
family: "approval_request",
|
|
570
|
+
transport: hitlTransport,
|
|
551
571
|
legKey: "",
|
|
552
572
|
...(legDeadlineMonotonic !== undefined ? { legDeadlineMonotonic } : {}),
|
|
553
573
|
}, withQuestion)
|
|
@@ -594,9 +614,12 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
594
614
|
acceptance?.settle(reached.result);
|
|
595
615
|
}
|
|
596
616
|
else if (reached !== undefined) {
|
|
597
|
-
await parkRowWrite[reached.kind](reached.result);
|
|
598
617
|
acceptance?.settle(reached.result);
|
|
599
618
|
}
|
|
619
|
+
else if (thrownCancelCause === undefined && observedDone !== undefined && heldParkOf(atHostBoundary(observedDone)) !== undefined) {
|
|
620
|
+
recordFailOpen("server.runs.terminal-ledger-write-failed", `arm=park-held ${message}`);
|
|
621
|
+
await settleLegResult(observedDone);
|
|
622
|
+
}
|
|
600
623
|
else if (thrownCancelCause !== undefined && observedDone === undefined) {
|
|
601
624
|
const c = cancelledResult(thrownCancelCause);
|
|
602
625
|
settledAsCancel = failureCodeOf(c.terminal) === CANCELLED_CODE;
|
|
@@ -610,8 +633,9 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
610
633
|
}
|
|
611
634
|
else {
|
|
612
635
|
settledAsCancel = false;
|
|
613
|
-
const
|
|
614
|
-
|
|
636
|
+
const outwardMsg = outwardThrownMessage(err, message);
|
|
637
|
+
const safeMsg = redactErrorMessage(outwardMsg) ?? outwardMsg;
|
|
638
|
+
await voidHeldParkCard(observedDone === undefined ? undefined : atHostBoundary(observedDone), spec.sessionId, checkpointCards, "bg");
|
|
615
639
|
try {
|
|
616
640
|
await append("failed", { errorMessage: safeMsg });
|
|
617
641
|
}
|
|
@@ -644,7 +668,7 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
644
668
|
if (verdict.kind === "park")
|
|
645
669
|
fleetPublisher.onTerminal(verdict.word);
|
|
646
670
|
else if (verdict.result !== null)
|
|
647
|
-
fleetPublisher.onTerminal(verdict.label, fleetRunResiduals(verdict.result));
|
|
671
|
+
fleetPublisher.onTerminal(verdict.label, fleetRunResiduals(verdict.result, failureCodeOf(verdict.result.terminal)));
|
|
648
672
|
else
|
|
649
673
|
fleetPublisher.onTerminal(verdict.label, {
|
|
650
674
|
...(verdict.label === CANCELLED_CODE ? { stoppedBy: "user" } : {}),
|
|
@@ -667,5 +691,11 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
|
|
|
667
691
|
}
|
|
668
692
|
}
|
|
669
693
|
}
|
|
694
|
+
export function beatRunHeartbeat(runStore, taskId, owner, onLost, onError) {
|
|
695
|
+
void runStore.heartbeat(taskId, owner).then((running) => {
|
|
696
|
+
if (!running)
|
|
697
|
+
onLost();
|
|
698
|
+
}, onError);
|
|
699
|
+
}
|
|
670
700
|
export const HEARTBEAT_MS = LIVENESS_HEARTBEAT_MS;
|
|
671
701
|
//# sourceMappingURL=runs.js.map
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
* · `forceDurableGate`— prepare-task.js 的 durable/content mandate、活 content-ask 抑制、
|
|
24
24
|
* durable question face(该处合取 `resolveCheckpointStore(spec, deps) !== undefined`
|
|
25
25
|
* ⇒ **无 checkpoint 店的部署上这一面本就不成立**,该键在那里 inert)
|
|
26
|
-
* · `autoMode` —
|
|
27
|
-
*
|
|
26
|
+
* · `autoMode` — 武装式 `spec.permissionMode === "auto"` **∧** `deps.autoMode !== undefined` **∧** `runtimeCaps?.autoMode !== false`
|
|
27
|
+
* (部署需先具备分类器;三态 org deny 位:`true` 与缺席同义、只有 `false` 是拒,见 toCoreRuntimeCaps 头注)
|
|
28
28
|
* · `bypassPermissions` — `dist/core/mode-policy.js` 的模式折叠(请求 `bypassPermissions` ∧ 本位 `=== false` ⇒ 这条腿跑在
|
|
29
29
|
* `default`、发 `config.permission_mode_unavailable{by:"operator_deny"}`、回执 `foldedBy:"operator_deny"`);
|
|
30
30
|
* deny 形,缺席 = 不阻。[ref] D2 起由 center 的 `allowBypassPermissions` 写(此前本仓零写点)
|
|
@@ -107,6 +107,15 @@ export interface EntitlementsResolverOpts {
|
|
|
107
107
|
/** Observability hook for a resolve failure (defaults to a `runtime_caps_resolve_failed` warn). */
|
|
108
108
|
onError?: (err: Error, principal: string) => void;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* 中心拒了 auto 时**是哪一键拒的**(闭集)。中心的 entitlement 里 auto 的拒位今天有两个键(`autoMode` 与 `allowAutoMode`,settings-schema 里一个事实两个源 ——
|
|
112
|
+
* 折成一键归那个仓),引擎只有一只拒位;读者(`GET /v1/capabilities` 的 `permissionModeAuto.refusedBy`)靠这一词分清该去改中心的哪一键。
|
|
113
|
+
* 中心折成一键之后两词退役、本词集随之删(零别名)。
|
|
114
|
+
*/
|
|
115
|
+
export declare const AUTO_MODE_REFUSED_BY: readonly ["center.autoMode", "center.allowAutoMode", "both"];
|
|
116
|
+
export type AutoModeRefusedBy = (typeof AUTO_MODE_REFUSED_BY)[number];
|
|
117
|
+
/** 中心这一答拒没拒 auto、哪一键拒的 —— 拒位与来源词的**同一只判**({@link toCoreRuntimeCaps} 的拒位读它)。缺席 = 中心没拒(任一键的 `true` 都不是授予,不覆盖另一键的 `false`)。 */
|
|
118
|
+
export declare function autoModeRefusedByOf(ent: Pick<EntitlementRuntimeCaps, "autoMode" | "allowAutoMode">): AutoModeRefusedBy | undefined;
|
|
110
119
|
/** Map center's `EntitlementRuntimeCaps` → the subset core's engine enforces. `allowUltracode` (shell/UX) is
|
|
111
120
|
* dropped on purpose (not a core primitive); `allowWorkflows` / `forceDurableGate` / `allowFork` are **three of the
|
|
112
121
|
* six** the engine reads — the other three (`allowObservers` / `autoMode` / `allowMemoryOptOut`) are documented
|
|
@@ -151,6 +160,12 @@ export declare function toCoreRuntimeCaps(ent: EntitlementRuntimeCaps | null | u
|
|
|
151
160
|
* 所以本谓词为 false **不再**意味着 auto 不武装;「会不会武装」由 `auto-mode-face.ts` 的三项合取答。
|
|
152
161
|
*/
|
|
153
162
|
export declare function centerEntitlementSourceWired(config: Pick<ServiceConfig, "webAdmin">): boolean;
|
|
163
|
+
/** 只读腿的一次读数:拒位(caps)与中心拒 auto 的来源词出自**同一个**缓存项。 */
|
|
164
|
+
export interface RuntimeCapsReading {
|
|
165
|
+
readonly caps: RuntimeCaps | undefined;
|
|
166
|
+
/** 只在中心亲口拒了 auto 时在场({@link AutoModeRefusedBy})。 */
|
|
167
|
+
readonly autoModeRefusedBy?: AutoModeRefusedBy;
|
|
168
|
+
}
|
|
154
169
|
/** The two per-principal faces served off ONE caps fetch + cache. */
|
|
155
170
|
export interface PrincipalEntitlementsClient {
|
|
156
171
|
/** core's `RunnerDeps.runtimeCapsResolver` seam — FAIL-CLOSED on error (deny workflows/fork/autoMode/bypassPermissions;
|
|
@@ -171,7 +186,7 @@ export interface PrincipalEntitlementsClient {
|
|
|
171
186
|
*
|
|
172
187
|
* 🔴 **界画在「这句话是谁说的」**(codex r2 [high] 逐条核后的定界,不是「读面完全不碰缓存」):
|
|
173
188
|
* · **成功项 = center 亲口答的那份** —— 与提交腿自己抓到的**逐字同一份**、同一条 `ttlMs`、同一个**已验证**
|
|
174
|
-
* 身份(读面的 principal 走 `
|
|
189
|
+
* 身份(读面的 principal 走 `gatedSubject` → `verifiedPrincipal`,与提交腿同源,读不到别人的格)。读面
|
|
175
190
|
* 只是把这个 principal 自己那一格**预热**了一下;org 撤销后的陈旧窗由部署级 `ttlMs` 定义,与哪一腿预热
|
|
176
191
|
* 的无关(提交腿自己预热同样如此),本批**零改动**。
|
|
177
192
|
* · **降级项 = server 自铸的判决** —— center 从没说过这句 deny,是本层在故障时替它说的。让一次**读**铸的
|
|
@@ -185,17 +200,17 @@ export interface PrincipalEntitlementsClient {
|
|
|
185
200
|
* 而它硬失败 ⇒ 该降级项当场升格为执法项(codex r1 [medium]:否则一条总抢在提交前面的轮询会让每次提交
|
|
186
201
|
* 都重抓,denyTtl 的界对提交腿失效)。让它升格的是一次真提交自己吃到的硬失败,不是那次读。
|
|
187
202
|
*/
|
|
188
|
-
|
|
203
|
+
peekRuntimeCapsReading: (principal: string | undefined) => Promise<RuntimeCapsReading>;
|
|
189
204
|
/** The resolved per-principal scenario ruling for resolveSpec's gateScenarioRequest — a three-state read
|
|
190
205
|
* ({@link ScenarioRulingRead}): the ruling; `undefined` = absent (no principal ⇒ no center call; older center without
|
|
191
206
|
* the scenario keys) = no governance; `"unavailable"` = the center could not answer (hard fetch failure — same error entry
|
|
192
207
|
* as the caps face's fail-closed deny — or malformed ruling keys) ⇒ the gate refuses the run. */
|
|
193
208
|
scenarioRuling: (principal: string | undefined) => Promise<ScenarioRulingRead>;
|
|
194
209
|
/**
|
|
195
|
-
* {@link PrincipalEntitlementsClient.scenarioRuling} 的**只读**孪生(同 {@link PrincipalEntitlementsClient.
|
|
210
|
+
* {@link PrincipalEntitlementsClient.scenarioRuling} 的**只读**孪生(同 {@link PrincipalEntitlementsClient.peekRuntimeCapsReading} 的界):同一只缓存 / 同一条抓取 /
|
|
196
211
|
* 同一份三态读数(故障 ⇒ `"unavailable"`,读面与提交腿同拒),唯一的差别是 center 硬失败时本腿铸的降级项**只对读面自己算数**,提交腿不认、照常重抓。
|
|
197
212
|
* 读面(`GET /v1/capabilities/mcp?scenario=` 的场景门)问中心裁定时必须走这一只 —— 经 `scenarioRuling` 问,center 抖动的那一拍会替这个主体的**真提交**
|
|
198
|
-
* 留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面成了别人被拒的原因,与 `
|
|
213
|
+
* 留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面成了别人被拒的原因,与 `peekRuntimeCapsReading` 的病灶同一类)。
|
|
199
214
|
*/
|
|
200
215
|
peekScenarioRuling: (principal: string | undefined) => Promise<ScenarioRulingRead>;
|
|
201
216
|
/** (stage7 P5) The resolved per-principal execution-lane ruling for resolveSpec's
|
|
@@ -37,6 +37,12 @@ const CENTER_ENGINE_CAP_KEYS = [
|
|
|
37
37
|
"allowBypassPermissions",
|
|
38
38
|
"allowMemoryOptOut",
|
|
39
39
|
];
|
|
40
|
+
export const AUTO_MODE_REFUSED_BY = ["center.autoMode", "center.allowAutoMode", "both"];
|
|
41
|
+
export function autoModeRefusedByOf(ent) {
|
|
42
|
+
const byAutoMode = ent.autoMode === false;
|
|
43
|
+
const byAllowAutoMode = ent.allowAutoMode === false;
|
|
44
|
+
return byAutoMode && byAllowAutoMode ? "both" : byAutoMode ? "center.autoMode" : byAllowAutoMode ? "center.allowAutoMode" : undefined;
|
|
45
|
+
}
|
|
40
46
|
export function toCoreRuntimeCaps(ent) {
|
|
41
47
|
if (!ent)
|
|
42
48
|
return undefined;
|
|
@@ -53,7 +59,7 @@ export function toCoreRuntimeCaps(ent) {
|
|
|
53
59
|
caps.allowFork = ent.allowFork;
|
|
54
60
|
if (typeof ent.allowObservers === "boolean")
|
|
55
61
|
caps.allowObservers = ent.allowObservers;
|
|
56
|
-
if (ent
|
|
62
|
+
if (autoModeRefusedByOf(ent) !== undefined)
|
|
57
63
|
caps.autoMode = false;
|
|
58
64
|
else if (ent.autoMode === true)
|
|
59
65
|
caps.autoMode = true;
|
|
@@ -87,7 +93,6 @@ export function gateExecutionLane(ruling, ownLane, logger = defaultLogger) {
|
|
|
87
93
|
export function createPrincipalEntitlementsClient(opts) {
|
|
88
94
|
const ttlMs = opts.ttlMs ?? 60_000;
|
|
89
95
|
const denyTtlMs = opts.denyTtlMs ?? Math.min(ttlMs, 10_000);
|
|
90
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
91
96
|
const fetchCaps = opts.fetchCaps ?? fetchPrincipalCaps;
|
|
92
97
|
const now = opts.now ?? (() => Date.now());
|
|
93
98
|
const onError = opts.onError ?? ((err, principal) => defaultLogger.warn("runtime_caps_resolve_failed", { principal, err: String(err) }));
|
|
@@ -130,12 +135,13 @@ export function createPrincipalEntitlementsClient(opts) {
|
|
|
130
135
|
return dup;
|
|
131
136
|
const p = (async () => {
|
|
132
137
|
try {
|
|
133
|
-
const r = await fetchCaps(bin.center, principal, cached?.etag, fetchImpl, opts.worker);
|
|
138
|
+
const r = await fetchCaps(bin.center, principal, cached?.etag, opts.fetchImpl, opts.worker);
|
|
134
139
|
if (r === null) {
|
|
135
140
|
const entry = {
|
|
136
141
|
caps: cached?.caps,
|
|
137
142
|
...(cached?.scenario ? { scenario: cached.scenario } : {}),
|
|
138
143
|
...(cached?.execution ? { execution: cached.execution } : {}),
|
|
144
|
+
...(cached?.autoModeRefusedBy ? { autoModeRefusedBy: cached.autoModeRefusedBy } : {}),
|
|
139
145
|
...(cached?.etag ? { etag: cached.etag } : {}),
|
|
140
146
|
expiresAt: now() + ttlMs,
|
|
141
147
|
};
|
|
@@ -148,8 +154,10 @@ export function createPrincipalEntitlementsClient(opts) {
|
|
|
148
154
|
if (r.scenarioDrift) {
|
|
149
155
|
audit(new Error(`scenario ruling wire drift: ${r.scenarioDrift}`), principal);
|
|
150
156
|
}
|
|
157
|
+
const refusedBy = r.runtimeCaps ? autoModeRefusedByOf(r.runtimeCaps) : undefined;
|
|
151
158
|
const entry = {
|
|
152
159
|
caps: toCoreRuntimeCaps(r.runtimeCaps),
|
|
160
|
+
...(refusedBy !== undefined ? { autoModeRefusedBy: refusedBy } : {}),
|
|
153
161
|
...(r.scenarioDrift ? { scenario: "unavailable" } : r.scenario ? { scenario: r.scenario } : {}),
|
|
154
162
|
...(r.execution ? { execution: r.execution } : {}),
|
|
155
163
|
...(r.etag ? { etag: r.etag } : {}),
|
|
@@ -182,7 +190,12 @@ export function createPrincipalEntitlementsClient(opts) {
|
|
|
182
190
|
}
|
|
183
191
|
return {
|
|
184
192
|
resolveRuntimeCaps: async (principal) => (principal ? (await load(principal)).caps : undefined),
|
|
185
|
-
|
|
193
|
+
peekRuntimeCapsReading: async (principal) => {
|
|
194
|
+
if (!principal)
|
|
195
|
+
return { caps: undefined };
|
|
196
|
+
const entry = await load(principal, false);
|
|
197
|
+
return { caps: entry.caps, ...(entry.autoModeRefusedBy !== undefined ? { autoModeRefusedBy: entry.autoModeRefusedBy } : {}) };
|
|
198
|
+
},
|
|
186
199
|
scenarioRuling: async (principal) => (principal ? (await load(principal)).scenario : undefined),
|
|
187
200
|
peekScenarioRuling: async (principal) => (principal ? (await load(principal, false)).scenario : undefined),
|
|
188
201
|
executionRuling: async (principal) => (principal ? (await load(principal)).execution : undefined),
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* name). Real isolation is the `executionEnv` sandbox. Same caveat core documents on `createCoarseCommandNamePolicy`.
|
|
25
25
|
*/
|
|
26
26
|
import { type PermissionMode, type ShellGateDoctrine, type TaskSpec, type ToolPolicy } from "@sema-agent/core";
|
|
27
|
-
import { AUTONOMY_MODES,
|
|
27
|
+
import { AUTONOMY_MODES, GovernanceConfig } from "@sema-agent/settings-schema";
|
|
28
28
|
import { type GovernanceAskMarks } from "./governance-ask-marks.js";
|
|
29
29
|
import { type GovernanceOverrides } from "./governance-overrides.js";
|
|
30
30
|
/** 运维 autonomy 四档的**闭集**(契约成员表本尊,照旧从本模块转出)。`config.ts` 的 `parseAutonomy` 也从这里读 —— 四档词表全仓一份。 */
|
|
@@ -38,7 +38,7 @@ export type Autonomy = NonNullable<GovernanceConfig["autonomy"]>;
|
|
|
38
38
|
/** 导出给 `test/coarse-shell-tools-mirror.test.ts` 的同源钉用(见那里的顶注)。 */
|
|
39
39
|
export declare const COARSE_SHELL_TOOLS_MIRROR: readonly string[];
|
|
40
40
|
/** Validate `commandPolicy` rules — the shape (array of {command, decision}), the `command` (a bare argv[0] name,
|
|
41
|
-
* see {@link
|
|
41
|
+
* judged by the contract's own cell, see {@link commandNameRefused}), AND the `decision` enum. Returns the list of human-readable errors (empty =
|
|
42
42
|
* OK). Called at config-apply (web-admin-client/facade.ts `applyRuntimeHot`) so a malformed rule that BYPASSED the
|
|
43
43
|
* registry schema (a hand-edited config.d / a non-conformant publish) is rejected LOUDLY rather than
|
|
44
44
|
* silently mis-compiling — review MEDIUM: an out-of-enum `decision` (e.g. "DENY") would otherwise fall through
|