@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/parked-decide.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { FORK_SUBAGENT_TYPE, redeemWorkflowParks, subscribeWorkflow } from "@sema-agent/core";
|
|
1
2
|
import { readClosedWordSeat } from "./approval-card.js";
|
|
2
3
|
import { routeWorkflowPark } from "./orchestration/workflow-agent-session-index.js";
|
|
3
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
4
5
|
import { defaultSubagentTailBus } from "./fleet/subagent-tail-bus.js";
|
|
5
6
|
import { backgroundScopesForCheckpointScope, decodeCheckpointScope, ownerOfCheckpointScope } from "./security.js";
|
|
6
7
|
import { ASK_USER_QUESTION_TOOL_NAME, isEngineQuestionRow } from "./approval-content-kind.js";
|
|
8
|
+
import { approvalLegOriginOf } from "./approval-leg-origin.js";
|
|
7
9
|
import { refusalBody, resumeRefusalFacts } from "./http/refusal-body.js";
|
|
8
10
|
import { backgroundAgentNameOf } from "./background-agent-name.js";
|
|
9
|
-
import { buildSettlementEvidence } from "./gate-settlement.js";
|
|
10
|
-
import {
|
|
11
|
+
import { buildSettlementEvidence, NO_SETTLEMENT_EVIDENCE } from "./gate-settlement.js";
|
|
12
|
+
import { CARD_EXPIRE_OUTCOME, expireCardUnderStoredScope } from "./card-settle-stored-scope.js";
|
|
13
|
+
import { cardWaitingRefusalAnswer, commitExecutionContext, faultedAnswerOf, isRootSessionGoneRefusal } from "./http/execution-context.js";
|
|
11
14
|
import { EXECUTION_PLACEMENT_SEAT_CARRIERS } from "./execution-placement.js";
|
|
12
15
|
export const PARKED_REVIVE_EXECUTION_SEAT_REQUIRED = `the parked-agent revive leg (parkedReviveSurface) needs a session store with an execution placement seat (sessionStorage.executionPlacement) — after the claim, the root session's occupant is judged only by the write on that seat; ${EXECUTION_PLACEMENT_SEAT_CARRIERS}; refusing to start rather than revive parked agents with nobody judging the root session's occupant after the claim`;
|
|
13
16
|
export async function findParkOrigin(sources, cp) {
|
|
@@ -122,13 +125,32 @@ function refusesWhereUnrecordable(remember) {
|
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
|
-
function
|
|
128
|
+
function reviveDefinitionOf(row, reviveTool) {
|
|
129
|
+
if (row.agentType === undefined)
|
|
130
|
+
return { kind: "revivable", agentType: undefined };
|
|
131
|
+
const revivable = (reviveTool.ruleFace?.nameValues ?? []).filter((t) => t !== FORK_SUBAGENT_TYPE);
|
|
132
|
+
return revivable.includes(row.agentType) ? { kind: "revivable", agentType: row.agentType } : { kind: "unavailable" };
|
|
133
|
+
}
|
|
134
|
+
function denyAgentDefinitionUnavailable(taskId, rollback) {
|
|
135
|
+
return {
|
|
136
|
+
status: 409,
|
|
137
|
+
body: refusalBody({
|
|
138
|
+
errorCode: "decide.agent_definition_unavailable",
|
|
139
|
+
message: "this approval belongs to a background agent that was started from an agent definition the revive path cannot supply again: a definition sent on the request that started the run is not kept with the approval card, and a deployment definition may have been withdrawn since the agent stopped. Reviving the agent without it would resume it as a general-purpose agent, with a wider tool surface than its definition allowed, so the decision is NOT applied and nothing was resumed. The rollback field says what became of the approval: rolled_back means the card is still pending (it ends by expiry, or when the session's background agents are retired), failed means it had already ended, retry and lost mean read the pending list for its fate. Start the work from a built-in or deployment definition to get an agent whose approval can be decided here",
|
|
140
|
+
facts: {
|
|
141
|
+
taskId,
|
|
142
|
+
rollback,
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function mintReviveArgs(row, agentType) {
|
|
126
148
|
return {
|
|
127
149
|
prompt: row.description ?? "resume parked agent",
|
|
128
150
|
run_in_background: true,
|
|
129
151
|
name: backgroundAgentNameOf(row),
|
|
130
152
|
description: row.description ?? "revived agent",
|
|
131
|
-
...(
|
|
153
|
+
...(agentType !== undefined ? { subagent_type: agentType } : {}),
|
|
132
154
|
};
|
|
133
155
|
}
|
|
134
156
|
export function buildParkedResumeOutcome(req) {
|
|
@@ -217,6 +239,103 @@ export function planWorkflowParkedDecide(origin, req) {
|
|
|
217
239
|
},
|
|
218
240
|
};
|
|
219
241
|
}
|
|
242
|
+
function parkedChildResumedReceipt(taskId, decision, evidence) {
|
|
243
|
+
return { status: 200, body: { taskId, status: "resuming", decision, ...evidence } };
|
|
244
|
+
}
|
|
245
|
+
const LIVE_REDEEM_RECEIPTS = new Map();
|
|
246
|
+
async function runChannelEnded(runId, scope) {
|
|
247
|
+
const channel = subscribeWorkflow(runId, scope)[Symbol.asyncIterator]();
|
|
248
|
+
while (!(await channel.next()).done) {
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function holdLiveReceipt(run, token, fingerprint, answer) {
|
|
252
|
+
let byToken = LIVE_REDEEM_RECEIPTS.get(run.id);
|
|
253
|
+
if (byToken === undefined) {
|
|
254
|
+
byToken = new Map();
|
|
255
|
+
LIVE_REDEEM_RECEIPTS.set(run.id, byToken);
|
|
256
|
+
const book = byToken;
|
|
257
|
+
const drop = () => {
|
|
258
|
+
if (LIVE_REDEEM_RECEIPTS.get(run.id) === book)
|
|
259
|
+
LIVE_REDEEM_RECEIPTS.delete(run.id);
|
|
260
|
+
};
|
|
261
|
+
void run.ended().then(drop, (err) => {
|
|
262
|
+
recordFailOpen("server.workflow-live-receipt.channel-unreadable", `runId=${run.id} err=${err instanceof Error ? err.message : String(err)}`);
|
|
263
|
+
drop();
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
byToken.set(token, { fingerprint, answer });
|
|
267
|
+
}
|
|
268
|
+
const copyOf = (r) => ({ status: r.status, body: { ...r.body } });
|
|
269
|
+
export async function deliverToHoldingRun(origin, d) {
|
|
270
|
+
const entry = d.restated ? { token: d.token } : { token: d.token, outcome: d.outcome };
|
|
271
|
+
const scope = origin.run.scope;
|
|
272
|
+
return answerOfParkDelivery(await redeemWorkflowParks(origin.runId, scope, [entry]), { id: origin.runId, ended: () => runChannelEnded(origin.runId, scope) }, d);
|
|
273
|
+
}
|
|
274
|
+
export async function answerOfParkDelivery(delivery, run, d) {
|
|
275
|
+
const runId = run.id;
|
|
276
|
+
switch (delivery.kind) {
|
|
277
|
+
case "live":
|
|
278
|
+
return { kind: "answered", answer: answerOfLiveResult(delivery.results[0], run, d) };
|
|
279
|
+
case "suspending":
|
|
280
|
+
await delivery.ended;
|
|
281
|
+
return { kind: "resume_lane" };
|
|
282
|
+
case "not_active":
|
|
283
|
+
return { kind: "resume_lane" };
|
|
284
|
+
case "not_armed":
|
|
285
|
+
throw new Error(`workflow run ${runId} answered not_armed to a decision for a card it holds — a run without a checkpoint seat cannot have parked one; refusing to guess where the decision goes`);
|
|
286
|
+
default: {
|
|
287
|
+
const unhandled = delivery;
|
|
288
|
+
throw new Error(`unhandled workflow park delivery: ${JSON.stringify(unhandled)}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function answerOfLiveResult(word, run, d) {
|
|
293
|
+
const runId = run.id;
|
|
294
|
+
if (word === undefined)
|
|
295
|
+
throw new Error(`workflow run ${runId} answered a live delivery without a result for the one decision it was handed`);
|
|
296
|
+
switch (word) {
|
|
297
|
+
case "driving": {
|
|
298
|
+
if (d.restated)
|
|
299
|
+
throw new Error(`workflow run ${runId} drove a parked call on an acknowledgement — an acknowledgement never authorizes a drive`);
|
|
300
|
+
const answer = parkedChildResumedReceipt(runId, d.decision, NO_SETTLEMENT_EVIDENCE);
|
|
301
|
+
holdLiveReceipt(run, d.token, d.fingerprint, answer);
|
|
302
|
+
return copyOf(answer);
|
|
303
|
+
}
|
|
304
|
+
case "already_taken": {
|
|
305
|
+
const held = LIVE_REDEEM_RECEIPTS.get(runId)?.get(d.token);
|
|
306
|
+
if (held !== undefined && held.fingerprint === d.fingerprint)
|
|
307
|
+
return copyOf(held.answer);
|
|
308
|
+
return {
|
|
309
|
+
status: 409,
|
|
310
|
+
body: refusalBody({
|
|
311
|
+
errorCode: "decide.claim_lost",
|
|
312
|
+
message: "another decision for this approval was already handed to the run that is waiting on it and is being applied — re-check the pending list",
|
|
313
|
+
facts: { runId },
|
|
314
|
+
}),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
case "settled":
|
|
318
|
+
case "not_parked_here":
|
|
319
|
+
return { status: 409, body: refusalBody({ errorCode: "decide.gate_moved", message: "the approval gate moved under this decide (re-parked or already settled) — re-check the pending list", facts: { runId } }) };
|
|
320
|
+
case "unreadable":
|
|
321
|
+
return { status: 503, body: refusalBody({ errorCode: "decide.store_unreachable", message: "the state of this approval could not be read just now, so the run waiting on it kept waiting and nothing was decided — retry", facts: { runId } }) };
|
|
322
|
+
case "kept_parked":
|
|
323
|
+
if (!d.restated)
|
|
324
|
+
throw new Error(`workflow run ${runId} kept a parked call that was handed a decision — the engine keeps a park only on an acknowledgement`);
|
|
325
|
+
return {
|
|
326
|
+
status: 400,
|
|
327
|
+
body: refusalBody({
|
|
328
|
+
errorCode: "decide.parked_restatement_unsupported",
|
|
329
|
+
message: "mcpServers / a2aPeers cannot be applied: the run this approval belongs to is still running, and its waiting step continues with the MCP / A2A tables the run already has — re-issue the decide without them to continue it that way",
|
|
330
|
+
facts: { runId },
|
|
331
|
+
}),
|
|
332
|
+
};
|
|
333
|
+
default: {
|
|
334
|
+
const unhandled = word;
|
|
335
|
+
throw new Error(`unhandled workflow park delivery result: ${String(unhandled)}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
220
339
|
function sessionGone(taskId) {
|
|
221
340
|
return {
|
|
222
341
|
status: 409,
|
|
@@ -229,6 +348,15 @@ function sessionGone(taskId) {
|
|
|
229
348
|
}),
|
|
230
349
|
};
|
|
231
350
|
}
|
|
351
|
+
function parkedClaimFaultAnswer(taskId) {
|
|
352
|
+
return { status: 503, body: refusalBody({ errorCode: "decide.store_unreachable", message: "the stored state this decision needs could not be read or written just now (the store failed) — nothing was decided and the agent is still waiting for it; retry", facts: { taskId } }) };
|
|
353
|
+
}
|
|
354
|
+
function parkedRedeemFace(taskId) {
|
|
355
|
+
return {
|
|
356
|
+
refused: (refusal) => (isRootSessionGoneRefusal(refusal) ? sessionGone(taskId) : cardWaitingRefusalAnswer(refusal)),
|
|
357
|
+
faulted: () => parkedClaimFaultAnswer(taskId),
|
|
358
|
+
};
|
|
359
|
+
}
|
|
232
360
|
function gateMoved(taskId) {
|
|
233
361
|
return { status: 409, body: refusalBody({ errorCode: "decide.gate_moved", message: "the approval gate moved under this decide (re-parked or already settled) — re-check the pending list", facts: { taskId } }) };
|
|
234
362
|
}
|
|
@@ -239,7 +367,7 @@ function revivabilityOf(row, taskId) {
|
|
|
239
367
|
return { kind: "revivable", root: row.rootSessionId };
|
|
240
368
|
}
|
|
241
369
|
async function voidUnrevivableCard(deps, req, match) {
|
|
242
|
-
const voided = await deps.checkpointStore
|
|
370
|
+
const voided = (await expireCardUnderStoredScope(deps.checkpointStore, req.token)) === CARD_EXPIRE_OUTCOME.expired;
|
|
243
371
|
if (!voided) {
|
|
244
372
|
return gateMoved(match.handle);
|
|
245
373
|
}
|
|
@@ -268,7 +396,8 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
268
396
|
if (revivability.kind === "unrevivable")
|
|
269
397
|
return req.decision === "deny" ? voidUnrevivableCard(deps, req, match) : revivability.approveRefusal;
|
|
270
398
|
const root = revivability.root;
|
|
271
|
-
const
|
|
399
|
+
const face = parkedRedeemFace(match.handle);
|
|
400
|
+
const resolved = await deps.execution.resolve(root, face);
|
|
272
401
|
if (!resolved.ok)
|
|
273
402
|
return resolved.gone ? sessionGone(match.handle) : resolved.answer;
|
|
274
403
|
const execution = resolved.ctx;
|
|
@@ -278,7 +407,7 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
278
407
|
if (!claim.ok) {
|
|
279
408
|
switch (claim.reason) {
|
|
280
409
|
case "store_unreachable":
|
|
281
|
-
return
|
|
410
|
+
return face.faulted();
|
|
282
411
|
case "claim_lost":
|
|
283
412
|
return { status: 409, body: refusalBody({ errorCode: "decide.claim_lost", message: "the parked agent is already claimed — either a concurrent decide won (re-check the pending list), or a stale claim is pending automatic cleanup (retry after the stale-claim window)", facts: { taskId: match.handle } }) };
|
|
284
413
|
case "binding_broken":
|
|
@@ -311,7 +440,14 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
311
440
|
await rollback("claimed_token_moved");
|
|
312
441
|
return gateMoved(match.handle);
|
|
313
442
|
}
|
|
314
|
-
|
|
443
|
+
let placementRefusal;
|
|
444
|
+
try {
|
|
445
|
+
const refusal = await commitExecutionContext(deps.execution.commitDeps, { kind: "parked", taskId: match.handle, rollback }, execution);
|
|
446
|
+
placementRefusal = refusal === null ? null : face.refused(refusal);
|
|
447
|
+
}
|
|
448
|
+
catch (e) {
|
|
449
|
+
placementRefusal = faultedAnswerOf(e, face.faulted);
|
|
450
|
+
}
|
|
315
451
|
if (placementRefusal)
|
|
316
452
|
return placementRefusal;
|
|
317
453
|
let surface;
|
|
@@ -322,6 +458,10 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
322
458
|
await rollback("revive_surface_threw");
|
|
323
459
|
throw e;
|
|
324
460
|
}
|
|
461
|
+
const definition = reviveDefinitionOf(row, surface.reviveTool);
|
|
462
|
+
if (definition.kind === "unavailable") {
|
|
463
|
+
return denyAgentDefinitionUnavailable(match.handle, await rollback("agent_definition_unavailable"));
|
|
464
|
+
}
|
|
325
465
|
if (req.remember !== undefined && rememberRoot !== undefined) {
|
|
326
466
|
try {
|
|
327
467
|
await req.remember.anchor(rememberRoot);
|
|
@@ -334,8 +474,9 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
334
474
|
const ctx = {
|
|
335
475
|
toolCallId: `drv-${ticket.claimId}`,
|
|
336
476
|
...(surface.mountsCallerTool !== undefined ? { mountsCallerTool: surface.mountsCallerTool } : {}),
|
|
477
|
+
...(surface.onBackgroundChildEvent !== undefined ? { onBackgroundChildEvent: surface.onBackgroundChildEvent } : {}),
|
|
337
478
|
...(deps.approverSeatFor !== undefined && seatRoot !== undefined
|
|
338
|
-
? { onAsk: deps.approverSeatFor({ owner: ownerOfCheckpointScope(req.scope), taskId: match.handle, sessionId: seatRoot,
|
|
479
|
+
? { onAsk: deps.approverSeatFor({ owner: ownerOfCheckpointScope(req.scope), taskId: match.handle, sessionId: seatRoot, ...approvalLegOriginOf(execution) }) }
|
|
339
480
|
: {}),
|
|
340
481
|
reviveClaim: {
|
|
341
482
|
row: { ...ticket.row, parkClaimId: ticket.claimId },
|
|
@@ -350,7 +491,7 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
350
491
|
defaultSubagentTailBus.forgetHandle(match.handle);
|
|
351
492
|
let receipt;
|
|
352
493
|
try {
|
|
353
|
-
receipt = await surface.reviveTool.execute(mintReviveArgs(row,
|
|
494
|
+
receipt = await surface.reviveTool.execute(mintReviveArgs(row, definition.agentType), ctx);
|
|
354
495
|
}
|
|
355
496
|
catch (e) {
|
|
356
497
|
const disp = await rollback("execute_threw");
|
|
@@ -399,6 +540,6 @@ export async function decideParkedAgent(deps, req, match) {
|
|
|
399
540
|
}),
|
|
400
541
|
};
|
|
401
542
|
}
|
|
402
|
-
return
|
|
543
|
+
return parkedChildResumedReceipt(match.handle, req.decision, buildSettlementEvidence({ at: "agent_revived", gate: req.selectedGate }));
|
|
403
544
|
}
|
|
404
545
|
//# sourceMappingURL=parked-decide.js.map
|
|
@@ -30,14 +30,20 @@
|
|
|
30
30
|
* 一层行)以 `{ delegationRoot }` 重解 —— 只喂 relay,不挂任何会话级设施、不带 principal,交座判据(上面三条)一个字不动。行上没有根 ⇒ boot 期那只裸 Agent(没有根可交 ⇒ 不接 relay)。
|
|
31
31
|
* 复活的子代再要审批时的停驻挂点(`plugins/session-store.ts`)不读见证:引擎交它那一行自己的属主,挂点只比对(core 7.62.0 [ref];根见证在挂点的读法随 [ref] P-5 退役)。
|
|
32
32
|
*/
|
|
33
|
-
import { type BackgroundAgentRecord, type ToolSpec } from "@sema-agent/core";
|
|
33
|
+
import { type BackgroundAgentRecord, type ToolExecuteContext, type ToolSpec } from "@sema-agent/core";
|
|
34
34
|
import type { Scenario } from "./capabilities/scenarios.js";
|
|
35
35
|
import type { SessionFace } from "./session-incarnation.js";
|
|
36
|
-
/** 一次赎回用的面:驱动的 Agent 工具(它的完成 relay 绑着行上的根)+ (交座时)
|
|
36
|
+
/** 一次赎回用的面:驱动的 Agent 工具(它的完成 relay 绑着行上的根)+ (交座时)与它同出一张列表的继承座 + 进程级后台子代观察者。 */
|
|
37
37
|
export interface ParkedReviveSurface {
|
|
38
38
|
readonly reviveTool: ToolSpec;
|
|
39
39
|
/** 缺席 = 不交座(core fail-closed:复活的子代不继承任何场景层工具)。 */
|
|
40
40
|
readonly mountsCallerTool?: (tool: ToolSpec) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 进程级后台子代观察者 —— 与 `RunnerDeps.onBackgroundChildEvent` **同一只实例**(fleet 的后台子代发布器,行的 spawn / tick / 终态帧与 `bg_notification` 只经它)。
|
|
43
|
+
* 引擎经 Runner 起跑的工具调用由 Runner 把它填进 `ToolExecuteContext`;赎回腿自己驱动 `execute`、ctx 由赎回腿铸 ⇒ 由本面带进去,复活的那一轮与首轮
|
|
44
|
+
* 进同一只发布器(发布器按实例持每只子代的溯源,换一只实例 = 终态找不到 spawn 时记下的行)。缺席 = 这条部署没有观察者(Runner 那一侧同样缺席)。
|
|
45
|
+
*/
|
|
46
|
+
readonly onBackgroundChildEvent?: NonNullable<ToolExecuteContext["onBackgroundChildEvent"]>;
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
49
|
* 按行解析赎回面的入参身份:`principal` = 权威 principal(取 checkpoint 的 scope 列,不取行上有损的 `row.scope`);`rootOccupant` = 写口放行的那一位
|
|
@@ -50,8 +56,12 @@ export interface ParkedReviveSurfaceIdentity {
|
|
|
50
56
|
/** 按行解析赎回面。 */
|
|
51
57
|
export type ParkedReviveSurfaceFactory = (row: BackgroundAgentRecord, identity: ParkedReviveSurfaceIdentity) => ParkedReviveSurface;
|
|
52
58
|
/**
|
|
53
|
-
* 赎回面工厂。入参 = **内建** default 场景工厂(stage-07 在 center overlay 盖名之前取的那一只;赎回要的是与 spawn 同源的生产装配)
|
|
59
|
+
* 赎回面工厂。入参 = **内建** default 场景工厂(stage-07 在 center overlay 盖名之前取的那一只;赎回要的是与 spawn 同源的生产装配)+ 进程级后台子代观察者
|
|
60
|
+
* (`RunnerDeps.onBackgroundChildEvent` 那一只,见 {@link ParkedReviveSurface.onBackgroundChildEvent};每一行的面都带它,与交不交座无关)。键必填、值可为 `undefined`:
|
|
61
|
+
* 调用方必须表态这条部署有没有观察者 —— 修前正是「没人交」静默成了复活轮零帧。
|
|
54
62
|
* 内建 bundle 里没有 Agent 工具 ⇒ `undefined`(park 本就不可达,赎回腿不接线)。
|
|
55
63
|
*/
|
|
56
|
-
export declare function createParkedReviveSurface(defaultScenario: Scenario
|
|
64
|
+
export declare function createParkedReviveSurface(defaultScenario: Scenario, observer: {
|
|
65
|
+
readonly onBackgroundChildEvent: ParkedReviveSurface["onBackgroundChildEvent"] | undefined;
|
|
66
|
+
}): ParkedReviveSurfaceFactory | undefined;
|
|
57
67
|
//# sourceMappingURL=parked-revive-surface.d.ts.map
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { DEFAULT_SUBAGENT_TOOL_NAME } from "@sema-agent/core";
|
|
2
2
|
const agentOf = (tools) => tools.find((t) => t.name === DEFAULT_SUBAGENT_TOOL_NAME);
|
|
3
|
-
export function createParkedReviveSurface(defaultScenario) {
|
|
3
|
+
export function createParkedReviveSurface(defaultScenario, observer) {
|
|
4
4
|
const bootTool = agentOf(defaultScenario({}).tools);
|
|
5
5
|
if (bootTool === undefined)
|
|
6
6
|
return undefined;
|
|
7
|
+
const observed = observer.onBackgroundChildEvent !== undefined ? { onBackgroundChildEvent: observer.onBackgroundChildEvent } : {};
|
|
7
8
|
return (row, identity) => {
|
|
8
9
|
const root = row.rootSessionId;
|
|
9
10
|
if (root === undefined)
|
|
10
|
-
return { reviveTool: bootTool };
|
|
11
|
+
return { reviveTool: bootTool, ...observed };
|
|
11
12
|
const seated = holdsSeat(row.parentSessionId === root, identity);
|
|
12
13
|
const delegationRoot = { sessionId: root, owner: identity.rootOccupant.owner, incarnation: identity.rootOccupant.incarnation };
|
|
13
14
|
const tools = (seated ? defaultScenario({}, identity.principal, { sessionId: root, delegationRoot }) : defaultScenario({}, undefined, { delegationRoot })).tools;
|
|
14
15
|
const reviveTool = agentOf(tools);
|
|
15
16
|
if (reviveTool === undefined)
|
|
16
|
-
return { reviveTool: bootTool };
|
|
17
|
-
return seated ? { reviveTool, mountsCallerTool: (t) => tools.includes(t) } : { reviveTool };
|
|
17
|
+
return { reviveTool: bootTool, ...observed };
|
|
18
|
+
return seated ? { reviveTool, mountsCallerTool: (t) => tools.includes(t), ...observed } : { reviveTool, ...observed };
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
function holdsSeat(oneLevel, identity) {
|
package/dist/peer-directory.d.ts
CHANGED
|
@@ -18,24 +18,22 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ⚠️ **共享的是谓词,不是最终集合**(codex 对抗复审 r1 ② 采纳,如实收窄 —— 稿里与本注初版都写成了
|
|
20
20
|
* 「两面集合相等」,那是**过度承诺**):两面在下面这些地方按设计给出不同的集合,逐条都不是 bug ——
|
|
21
|
-
* · **fleet-wide 调用方**:`GET /v1/sessions`
|
|
21
|
+
* · **fleet-wide 调用方**:`GET /v1/sessions` 对不报主体的 service-token / dev-open 调用方不钉 owner、还认 `?owner=`
|
|
22
22
|
* (运维视图);目录**只**按 core 递进来的那一个 scope 分区,永不跨;
|
|
23
23
|
* · **分页与搜索**:那条路由有 `?limit`/`?cursor`/`?q=`,目录是一次定量读(见 {@link PEER_DIRECTORY_CAP});
|
|
24
24
|
* · **peer 可寻址性过滤**:语法外 / 非小写规范形 / 与别条会话折到同一只箱的 id 都不入目录(下面那道
|
|
25
25
|
* 单射门),那条路由照列;
|
|
26
26
|
* · **墓碑**:目录会多出「正在删除中」的 `deleted` 记录,那条路由不列;
|
|
27
|
-
* ·
|
|
27
|
+
* · **席位差**:无。那条路由与本席读同一只会话店 lister(run 店不列会话,路由没有兜底)。
|
|
28
28
|
* 机器钉因此只钉「同一 principal、无 q、无分页、量在 cap 内」那一格的集合相等(它是那条承重条款的
|
|
29
29
|
* 可执行投影),别把它读成两面恒等。
|
|
30
30
|
*
|
|
31
|
-
* ⚠️ 与设计稿的第二处收紧(亲读实现推翻稿面):稿里把谓词写成 `principal-gate.ts
|
|
32
|
-
* 亲读两只函数后不成立 —— `
|
|
31
|
+
* ⚠️ 与设计稿的第二处收紧(亲读实现推翻稿面):稿里把谓词写成 `principal-gate.ts qualsOf`。
|
|
32
|
+
* 亲读两只函数后不成立 —— `qualsOf(p, owner, cfg)` 对 `owner === null` **无条件**放行
|
|
33
33
|
* (`principal-gate.ts:136-137`,函数体第一行),而**列表面**的第三条件由 store 的
|
|
34
|
-
* `owner = ? OR owner IS NULL`
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* 拿 `runOwnerReadable` 当列表谓词会让目录比 `GET /v1/sessions` **多列出**别人的无主会话 —— 正好违反
|
|
38
|
-
* 稿子自己那条对拍。所以这里用的是列表面那一只:`legacyUnownedAmnestyOpen` + 同一个 lister。
|
|
34
|
+
* `owner = ? OR owner IS NULL` 承载,开关是面表列表面 `session.list` 的 `j4` 格(`owner-faces.ts` 的 `listFilterOf` 派生 `includeUnowned`)。
|
|
35
|
+
* 拿单行读面的放行集当列表谓词会让目录比 `GET /v1/sessions` **多列出**别人的无主会话 —— 正好违反
|
|
36
|
+
* 稿子自己那条对拍。所以这里用的是列表面那一行:`listFilterOf("session.list", …)` + 同一个 lister(与 `GET /v1/sessions` 同一行面表)。
|
|
39
37
|
*
|
|
40
38
|
* ## scope 轴
|
|
41
39
|
*
|
package/dist/peer-directory.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PEER_SESSION_RECORD_SCHEMA_VERSION, isPeerSessionId, normalizePeerName, peerSessionBoxHandle, SESSION_BOX_PREFIX, } from "@sema-agent/core";
|
|
2
2
|
import { sessionTempoOfRunStatus } from "./plugins/store-contracts.js";
|
|
3
|
-
import {
|
|
3
|
+
import { claimCallerOf } from "./security.js";
|
|
4
|
+
import { listFilterOf, recoveredSubject } from "./owner-faces.js";
|
|
4
5
|
export const PEER_DIRECTORY_CAP = 200;
|
|
5
6
|
function displayNameOf(candidate, sessionId) {
|
|
6
7
|
return candidate != null && normalizePeerName(candidate) !== "" ? candidate : `session-${sessionId.slice(0, 8)}`;
|
|
@@ -13,7 +14,7 @@ export function createPeerDirectory(ctx) {
|
|
|
13
14
|
return {
|
|
14
15
|
listPeerSessions: async (access) => {
|
|
15
16
|
const scope = access.scope;
|
|
16
|
-
const includeUnowned =
|
|
17
|
+
const { includeUnowned } = listFilterOf("session.list", claimCallerOf(recoveredSubject(scope), { requirePrincipal }));
|
|
17
18
|
const answers = await lister({ owner: scope, ...(includeUnowned ? { includeUnowned: true } : {}), limit: PEER_DIRECTORY_CAP + 1 });
|
|
18
19
|
const rows = answers.map((a) => a.row);
|
|
19
20
|
const occupantOf = new Map(answers.map((a) => [a.row.sessionId, a.occupant.incarnation ?? null]));
|
|
@@ -1,14 +1,59 @@
|
|
|
1
|
-
import type { RuleBehavior } from "@sema-agent/core";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* [ref] + [ref](core `e298c9e0`,随 7.2.x 提货生效;[ref])—— 规则车道**闭词表的单一属主**。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要一个模块而不是各处各写一份 `z.enum([...])`:同一张词表此前在四处各抄一份字面量
|
|
5
|
+
* (`approval-card.ts` 两腿的 offer schema、`http/routes/rules.ts` 的直通票口行形、
|
|
6
|
+
* `plugins/permission-rule-store-sql.ts` 的 `rules_json` 读/写形),core 给 `PersistedRuleMatch` 加两员
|
|
7
|
+
* (wildcard / subpath)、给 `PersistedRuleTool` 加 Read 时,四份抄件**没有一份**会编译红 —— zod 的 enum
|
|
8
|
+
* 只是运行期的一个 Set,静默把一次上游语义扩张翻成一整类合法行的拒收([ref] 词表纪律说的正是这形:
|
|
9
|
+
* 未知词必须是**编译**错,不是运行期一个安静的 false)。
|
|
10
|
+
*
|
|
11
|
+
* (7.53.x 及以前:每张表在这里转录一份、各带一条双向全等钉;7.54.0 起值本身由 core 导出,见下一段。)
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ 转录**不是**判据:一个词在表里只说「这是 core 定义的一员」,不说「本仓每条腿都接受它」。逐腿的收窄
|
|
14
|
+
* (例如卡编辑臂对 `subpath` 的拒)写在那条腿自己的穷举 `switch` 里,并各带理由。
|
|
6
15
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
16
|
+
* 🔴 **core 7.54.0([ref] 阶段一 K1 / K1b)起,词表的值本身是 core 的包根导出**(`PERSISTED_RULE_MATCHES` / `RULE_OFFER_BATCH_MEMBER_KINDS` /
|
|
17
|
+
* `UNCOVERED_SEGMENT_REASONS` / `EDITED_RULE_BREADTH_WARNING_CODES` / `RULE_APPROVAL_RECORD_SCHEMA`,以及 `RULE_APPROVAL_KINDS` / `RULE_APPROVAL_STATES` /
|
|
18
|
+
* `IMPORTED_SETTINGS_LAYERS` / `RULE_ADD_ORIGINS`)—— 本模块此前的五份转录(各带一条 `Exact<>` 全等钉)随之退役,各消费点直接
|
|
19
|
+
* import core 的值(一个词一处拼写,在引擎里)。本模块只留**不是词表**的那几件:卡形(工具的卡形与匹配词的逐员表态)、直接写口的逐员表态、撤销后的存活词。
|
|
20
|
+
*
|
|
21
|
+
* 持久规则行的工具位**没有**本仓的谓词:「一条持久规则能点名哪只工具」由引擎的校验器从规则文本重投影答(两只店的读写腿、直通票口、直写口都经它);
|
|
22
|
+
* 整工具形(`match: "tool"`,`command: ""`)对任何引擎认得的工具名成立。此前这里有一只「工具有没有规则文法」的谓词,
|
|
23
|
+
* 引擎把裸工具名读成整工具规则之后它与校验器分家(无文法工具的整工具行写不进 SQL 店、导不进直通票口)—— 已退役。
|
|
10
24
|
*/
|
|
11
|
-
|
|
25
|
+
import { ruleToolGrammarOf } from "@sema-agent/core";
|
|
26
|
+
import type { RuleBehavior } from "@sema-agent/core";
|
|
27
|
+
/**
|
|
28
|
+
* 一张审批卡的**卡形** —— 卡上那格「不再询问」说的是哪一种规则。词与定义取自 core 的卡形(`CardRuleForm`,offer 工厂与同意入口共读的那一答):
|
|
29
|
+
* 命令规则词(`Bash`)的卡铸命令规则;名字文法 / 主机文法工具的卡铸**那一条精确值规则**(`Skill(<名>)` / `WebFetch(domain:<主机>)`);
|
|
30
|
+
* 没有任何规则词替它说话的工具的卡铸整工具规则(`tool`);其余 —— 路径工具(不铸路径候选)、shell 面上命令规则词的兄弟(`Monitor`:它的命令按 `Bash(…)` 规则判,
|
|
31
|
+
* 一张 shell 卡上的一键整工具同意 = 对每一个程序的常驻许可)—— 没有卡形。型从 core 的文法词派生(路径文法不是卡形,`tool` 是 core 的第四个词),本仓不抄词表。
|
|
32
|
+
*/
|
|
33
|
+
export type CardRuleForm = Exclude<NonNullable<ReturnType<typeof ruleToolGrammarOf>>, "path"> | "tool";
|
|
34
|
+
/**
|
|
35
|
+
* 这只工具的卡形(core 判官 `cardRuleFormOf` 不在包根导出面上 —— 依赖方向门禁深路径 —— 本函数按它的同一份定义读包根导出的 `ruleToolGrammarOf`)。
|
|
36
|
+
* 读者:卡素材铸点的派生事实一致性(`tool-approval.ts`:一只候选的匹配词的卡形 ≠ 这张卡的工具的卡形 ⇒ 丢整只候选,卡上不渲一格按不动的「不再询问」)。
|
|
37
|
+
* 卡编辑面不读它:引擎的编辑门只改命令规则,编辑面的形闭集(`rules-consent.ts`)对其余各形恒拒。方向 fail-closed:答不出 ⇒ 没有卡形。
|
|
38
|
+
*/
|
|
39
|
+
export declare function cardRuleFormOf(tool: string): CardRuleForm | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* 每个持久规则匹配词属于哪一种卡形 —— `undefined` = 引擎从不为一张卡铸这一形(名字前缀 / 子域:名字 / 主机工具的卡只铸那一条精确值规则;路径两形:路径工具的卡不铸候选)。
|
|
42
|
+
* `Record` 穷举:core 给 `PersistedRuleMatch` 加员时这里编译红,新词由人表态([ref] 词表纪律);表态成 `undefined` 是恒丢,不会悄悄放宽。
|
|
43
|
+
*/
|
|
44
|
+
export declare const CARD_RULE_FORM_OF_MATCH: {
|
|
45
|
+
readonly exact: "command";
|
|
46
|
+
readonly prefix: "command";
|
|
47
|
+
readonly wildcard: "command";
|
|
48
|
+
readonly pattern: "command";
|
|
49
|
+
readonly tool: "tool";
|
|
50
|
+
readonly name: "name";
|
|
51
|
+
readonly host: "domain";
|
|
52
|
+
readonly name_prefix: undefined;
|
|
53
|
+
readonly subdomain: undefined;
|
|
54
|
+
readonly path: undefined;
|
|
55
|
+
readonly subpath: undefined;
|
|
56
|
+
};
|
|
12
57
|
/**
|
|
13
58
|
* [ref] —— `RuleBehavior` 每一员在**无同意仪式的直接写口**(`POST /v1/rules`)上的逐员表态。
|
|
14
59
|
*
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import { COARSE_SHELL_TOOLS, ruleToolGrammarOf } from "@sema-agent/core";
|
|
2
|
-
export function
|
|
3
|
-
|
|
2
|
+
export function cardRuleFormOf(tool) {
|
|
3
|
+
const grammar = ruleToolGrammarOf(tool);
|
|
4
|
+
switch (grammar) {
|
|
5
|
+
case "command":
|
|
6
|
+
case "name":
|
|
7
|
+
case "domain":
|
|
8
|
+
return grammar;
|
|
9
|
+
case "path":
|
|
10
|
+
return undefined;
|
|
11
|
+
case undefined:
|
|
12
|
+
return COARSE_SHELL_TOOLS.includes(tool) ? undefined : "tool";
|
|
13
|
+
default: {
|
|
14
|
+
const unknown = grammar;
|
|
15
|
+
void unknown;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
4
19
|
}
|
|
20
|
+
export const CARD_RULE_FORM_OF_MATCH = {
|
|
21
|
+
exact: "command",
|
|
22
|
+
prefix: "command",
|
|
23
|
+
wildcard: "command",
|
|
24
|
+
pattern: "command",
|
|
25
|
+
tool: "tool",
|
|
26
|
+
name: "name",
|
|
27
|
+
host: "domain",
|
|
28
|
+
name_prefix: undefined,
|
|
29
|
+
subdomain: undefined,
|
|
30
|
+
path: undefined,
|
|
31
|
+
subpath: undefined,
|
|
32
|
+
};
|
|
5
33
|
export const DIRECT_RULE_WRITE_ADMITS = {
|
|
6
34
|
allow: false,
|
|
7
35
|
deny: true,
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [ref] I2(form b 位)—— **SQL 收编日志**:phase 真源与被迁的行**同库**。
|
|
3
|
-
*
|
|
4
|
-
* 🔴 为什么 phase 必须住 SQL 而不是一个 sidecar 文件(183 r3 按 codex r2-F2):发起收编的那个 pod 在两条
|
|
5
|
-
* 腿之间被摧毁时,进程本地的标记会与已经半迁移的 SQL 状态**分家** —— 接棒副本读不到「迁到哪了」。
|
|
6
|
-
* 标记与行同事务 ⇒ 崩溃后接棒副本按日志续跑,分家形不存在。
|
|
7
|
-
*
|
|
8
|
-
* ── 幂等身份 = DB 约束,不是「查了再插」(小票 v2/F2)────────────────────────────────────────────
|
|
9
|
-
* `from_principal` 上有 **UNIQUE**(183 D7「拒二次收编」的 DB 强形)。发起走 **insert-or-fetch 原子形**:
|
|
10
|
-
* 一条 `INSERT … ON CONFLICT DO NOTHING` / `INSERT IGNORE`,再按 `from_principal` 读回行。
|
|
11
|
-
* **禁 SELECT-then-INSERT** —— 那两句之间的窗正是两个并发同参 POST 各插一行(或各读到空)的地方,
|
|
12
|
-
* 而 UNIQUE 让「谁插进去了」由数据库仲裁,`affected` 就是判别式。
|
|
13
|
-
* 同 from 异 to ⇒ 读回的行 `to_principal` 不等 ⇒ typed conflict(调用方看到的是 409,不是「成功」)。
|
|
14
|
-
*
|
|
15
|
-
* ── 列的口径 ────────────────────────────────────────────────────────────────────────────────────
|
|
16
|
-
* · `legs` / `configs` / `report` 是 **TEXT 不是 JSON 列**:`report` 是 `immutableReport` 的落库形,
|
|
17
|
-
* 契约是「逐字节恒同」;JSON 列会按引擎自己的规范形重排键序,而 TEXT 是「存什么读什么」。
|
|
18
|
-
* (workflow_run.run / workflow_journal.result 同款先例,理由同源:String()→JSON.parse 的字节面。)
|
|
19
|
-
* · 时间列一律 `_ms BIGINT`(schema-naming 门 ② 咬 `_at BIGINT`)。
|
|
20
|
-
* · `phase` 是**单调**推进的阶段号,不是乐观锁计数 —— 但它的推进走的就是 CAS(`WHERE phase = :expect`),
|
|
21
|
-
* 所以它同时是那把锁。命名不叫 `rev`,因为它不守卫「行内容有没有变」,而守卫「弧走到哪了」。
|
|
22
|
-
*/
|
|
23
1
|
import type { Pool as MySqlPool } from "mysql2/promise";
|
|
24
2
|
import type { Pool as PgPool } from "pg";
|
|
25
3
|
import { type SqlDriver, type SqlExec, type SqlTxConn } from "./sql-driver.js";
|
|
@@ -215,9 +193,9 @@ export declare class SqlAdoptionLogStore implements AdoptionLogStore {
|
|
|
215
193
|
/**
|
|
216
194
|
* 收编弧的 advisory 锁(183 I1 的 form b 形:「与任何活写互斥」在 SQL 侧 = 一次只有一个副本在推这条弧)。
|
|
217
195
|
*
|
|
218
|
-
* **非阻塞取 + 有界轮询**(
|
|
219
|
-
*
|
|
220
|
-
* 返回 `undefined`,调用方按「在飞」应答 —— **不假装成功,也不无限等**。
|
|
196
|
+
* **非阻塞取 + 有界轮询**(阻塞式 GET_LOCK 会把并发调用方全部 park 在 TiDB 的悲观锁行上,既耗它的重试预算又饿死应用自己的 FOR UPDATE 路)。
|
|
197
|
+
* 取锁走本仓**唯一的取锁器**(`ensure-schema-lock-policy.ts` 的 {@link acquireAdvisoryLockWithin}):探针句、答案读法、TiDB「悲观锁重试上限」
|
|
198
|
+
* 读成「别人持着」、坏连接计数全在那里,本店不自带第二只探针。取不到 ⇒ 返回 `undefined`,调用方按「在飞」应答 —— **不假装成功,也不无限等**。
|
|
221
199
|
*
|
|
222
200
|
* 🔴 入参 `name` 是**逻辑**锁名(`adoptionLockName(fromPrincipal)`);真正发给引擎的是它被
|
|
223
201
|
* {@link qualifyAdoptionLockName} 限定到本库之后的形([ref]:两方言键空间不等价)。限定发生在
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { writeLogText } from "../observability/logger.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
4
|
+
import { acquireAdvisoryLockWithin, releaseAdvisoryLock } from "./ensure-schema-lock-policy.js";
|
|
3
5
|
import { ensureIndexes } from "./ensure-index.js";
|
|
4
6
|
export const ADOPTION_LOG_TABLE = "adoption_log";
|
|
5
7
|
export const ADOPTION_PHASE = {
|
|
@@ -32,6 +34,7 @@ export const TIDB_ADOPTION_LOG_STATEMENTS = [
|
|
|
32
34
|
) COLLATE utf8mb4_bin`,
|
|
33
35
|
];
|
|
34
36
|
export const ADOPTION_LOG_INDEXES = [
|
|
37
|
+
{ table: `${ADOPTION_LOG_TABLE}`, name: "uq_adoption_log_from", columns: ["from_principal"], unique: true },
|
|
35
38
|
{ table: `${ADOPTION_LOG_TABLE}`, name: "idx_adoption_log_state", columns: ["state"] },
|
|
36
39
|
];
|
|
37
40
|
export async function ensurePgAdoptionLogSchema(q) {
|
|
@@ -75,6 +78,18 @@ const PG_ADOPTION_LOCK_CLASS = 4907;
|
|
|
75
78
|
function pgLockObjectKey(name) {
|
|
76
79
|
return createHash("sha256").update(name).digest().readInt32BE(0);
|
|
77
80
|
}
|
|
81
|
+
function arcLockId(dialect, qualifiedName) {
|
|
82
|
+
switch (dialect) {
|
|
83
|
+
case "mysql":
|
|
84
|
+
return { dialect, name: qualifiedName };
|
|
85
|
+
case "pg":
|
|
86
|
+
return { dialect, keys: [PG_ADOPTION_LOCK_CLASS, pgLockObjectKey(qualifiedName)] };
|
|
87
|
+
default: {
|
|
88
|
+
const unreachable = dialect;
|
|
89
|
+
throw new Error(`unreachable SQL dialect: ${String(unreachable)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
78
93
|
export function adoptionLockName(fromPrincipal) {
|
|
79
94
|
return `sema_adoption:${createHash("sha256").update(fromPrincipal).digest("hex").slice(0, 32)}`;
|
|
80
95
|
}
|
|
@@ -130,7 +145,7 @@ export class SqlAdoptionLogStore {
|
|
|
130
145
|
await conn.rollback();
|
|
131
146
|
}
|
|
132
147
|
catch (rollbackErr) {
|
|
133
|
-
|
|
148
|
+
writeLogText("stderr", "[adoption-log] rollback after a failed rebind transaction also failed:", rollbackErr);
|
|
134
149
|
}
|
|
135
150
|
throw err;
|
|
136
151
|
}
|
|
@@ -147,7 +162,7 @@ export class SqlAdoptionLogStore {
|
|
|
147
162
|
await conn.rollback();
|
|
148
163
|
}
|
|
149
164
|
catch (rollbackErr) {
|
|
150
|
-
|
|
165
|
+
writeLogText("stderr", "[adoption-log] rollback after a failed sweep transaction also failed:", rollbackErr);
|
|
151
166
|
}
|
|
152
167
|
throw err;
|
|
153
168
|
}
|
|
@@ -186,30 +201,17 @@ export class SqlAdoptionLogStore {
|
|
|
186
201
|
}
|
|
187
202
|
async withLock(name, fn, attempts = 20, sleepMs = 100) {
|
|
188
203
|
const conn = await this.db.connect();
|
|
189
|
-
let held
|
|
190
|
-
let lockName = "";
|
|
204
|
+
let held;
|
|
191
205
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const res = await conn.query(this.q("SELECT GET_LOCK(?, 0) AS got", "SELECT pg_try_advisory_lock($1, $2) AS got"), this.db.dialect === "mysql" ? [lockName] : [PG_ADOPTION_LOCK_CLASS, pgLockObjectKey(lockName)]);
|
|
195
|
-
const got = res.rows[0]?.got;
|
|
196
|
-
held = got === 1 || got === true || got === "1";
|
|
197
|
-
if (!held)
|
|
198
|
-
await new Promise((r) => setTimeout(r, sleepMs));
|
|
199
|
-
}
|
|
200
|
-
if (!held)
|
|
206
|
+
const lock = arcLockId(this.db.dialect, qualifyAdoptionLockName(await this.resolveLockKeyspace(conn), name));
|
|
207
|
+
if (!(await acquireAdvisoryLockWithin(conn, lock, "adoption-log", attempts, sleepMs)))
|
|
201
208
|
return undefined;
|
|
209
|
+
held = lock;
|
|
202
210
|
return await fn(conn);
|
|
203
211
|
}
|
|
204
212
|
finally {
|
|
205
|
-
if (held)
|
|
206
|
-
|
|
207
|
-
await conn.query(this.q("SELECT RELEASE_LOCK(?) AS released", "SELECT pg_advisory_unlock($1, $2) AS released"), this.db.dialect === "mysql" ? [lockName] : [PG_ADOPTION_LOCK_CLASS, pgLockObjectKey(lockName)]);
|
|
208
|
-
}
|
|
209
|
-
catch (releaseErr) {
|
|
210
|
-
console.warn("[adoption-log] releasing the adoption arc lock failed (it auto-frees when the connection closes):", releaseErr);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
+
if (held !== undefined)
|
|
214
|
+
await releaseAdvisoryLock(conn, held, "adoption-log");
|
|
213
215
|
conn.release();
|
|
214
216
|
}
|
|
215
217
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** 退役的那只账本动词(只在重放认它;写口不会再写)。 */
|
|
2
|
+
export declare const RETIRED_DELETE_BY_TASK_OP_M50 = "deleteByTask";
|
|
3
|
+
/** M50 的窗在 `today`(UTC 日历日 YYYY-MM-DD)开着没有:开 ⇒ 按旧读法重放;关 ⇒ {@link retiredDeleteByTaskClosedWhyM50} 那一句拒。 */
|
|
4
|
+
export declare function retiredDeleteByTaskReplayOpenM50(today: string): boolean;
|
|
5
|
+
/** 窗关之后的拒因(接在账本拒句里,拒句本身带账本路径与通用出路):点名本条、窗的最后一天与那一版之前的出路 —— 版本与日期都读登记行,不手写第二份。 */
|
|
6
|
+
export declare function retiredDeleteByTaskClosedWhyM50(): string;
|
|
7
|
+
//# sourceMappingURL=approval-ask-retired-delete-by-task-m50.d.ts.map
|