@sema-agent/server 7.145.0 → 7.147.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 +876 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +374 -99
- package/deploy/facts/CHANGES.json +25 -0
- package/deploy/facts/README.md +57 -0
- package/deploy/facts/lanes.json +61 -0
- package/deploy/facts/lanes.schema.json +57 -0
- package/deploy/facts/sandbox-rbac.json +113 -0
- package/deploy/facts/sandbox-rbac.schema.json +74 -0
- package/deploy/facts/sealed-key.json +9 -0
- package/deploy/facts/sealed-key.schema.json +52 -0
- package/deploy/sema-up/README.md +2 -2
- package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
- package/deploy/sema-up/chart/templates/server.yaml +9 -4
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +2 -1
- package/deploy/sema-up/lib/flagshape.sh +4 -0
- package/deploy/sema-up/lib/lanes.json +2 -5
- package/deploy/sema-up/sema-up.sh +12 -9
- package/deploy/sema-up/stack/compose.yaml +5 -4
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
- package/dist/adoption/import-limits.d.ts +6 -0
- package/dist/adoption/import-limits.js +7 -0
- package/dist/adoption/import.d.ts +62 -0
- package/dist/adoption/import.js +107 -0
- package/dist/adoption/wire.d.ts +52 -0
- package/dist/adoption/wire.js +9 -0
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +7 -16
- package/dist/approval-card.js +0 -4
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/approval-gate-currency.js +1 -1
- package/dist/approval-reconciler.d.ts +1 -1
- package/dist/approval.d.ts +3 -3
- package/dist/audit.js +2 -2
- package/dist/bench/s1/live-deps.js +3 -1
- package/dist/boot/crash-last.js +2 -1
- package/dist/boot/deployment-mods.d.ts +11 -1
- package/dist/boot/deployment-mods.js +15 -2
- package/dist/boot/device-lane.js +7 -5
- package/dist/boot/engine-lease.d.ts +195 -22
- package/dist/boot/engine-lease.js +146 -20
- package/dist/boot/execution-env.d.ts +5 -0
- package/dist/boot/execution-env.js +57 -33
- package/dist/boot/execution-lane.d.ts +37 -9
- package/dist/boot/execution-lane.js +74 -20
- package/dist/boot/exit-boundary.d.ts +50 -0
- package/dist/boot/exit-boundary.js +32 -0
- package/dist/boot/exit-last.d.ts +20 -4
- package/dist/boot/exit-last.js +23 -5
- package/dist/boot/governance-seams.d.ts +2 -2
- package/dist/boot/governance-seams.js +1 -0
- package/dist/boot/leader.js +1 -1
- package/dist/boot/memory-boundary.d.ts +11 -11
- package/dist/boot/memory-boundary.js +3 -3
- package/dist/boot/memory-consolidation.d.ts +42 -41
- package/dist/boot/memory-consolidation.js +26 -28
- package/dist/boot/org-memory.js +3 -2
- package/dist/boot/parked-revive-gate.d.ts +1 -1
- package/dist/boot/parked-revive-gate.js +1 -1
- package/dist/boot/reapers.d.ts +12 -4
- package/dist/boot/reapers.js +40 -16
- package/dist/boot/resolve-spec.d.ts +2 -0
- package/dist/boot/resolve-spec.js +126 -123
- package/dist/boot/retention-lane.d.ts +4 -42
- package/dist/boot/runner-deps.js +1 -1
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +11 -3
- package/dist/boot/shutdown.js +27 -9
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +7 -3
- package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
- package/dist/boot/stage-02-web-admin-pull.js +10 -8
- package/dist/boot/stage-03-store-backend.d.ts +2 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +2 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -1
- package/dist/boot/stage-05-execution-env.js +6 -6
- package/dist/boot/stage-06-runners.d.ts +5 -2
- package/dist/boot/stage-06-runners.js +12 -13
- package/dist/boot/stage-07-capability-layer.d.ts +5 -2
- package/dist/boot/stage-07-capability-layer.js +7 -7
- package/dist/boot/stage-08-reapers.d.ts +5 -2
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +6 -2
- package/dist/boot/stage-10-http-server.d.ts +6 -2
- package/dist/boot/stage-10-http-server.js +5 -3
- package/dist/boot/stores.d.ts +10 -0
- package/dist/boot/stores.js +53 -26
- package/dist/boot/web-admin.js +3 -3
- package/dist/boot/workflow-orchestration.d.ts +1 -1
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +6 -2
- package/dist/capabilities/composite-members.d.ts +4 -1
- package/dist/capabilities/composite-members.js +4 -1
- package/dist/capabilities/execution-lane.d.ts +7 -7
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +1 -1
- package/dist/capabilities/scenarios.d.ts +34 -20
- package/dist/capabilities/scenarios.js +13 -9
- package/dist/capabilities/settings-contract.d.ts +29 -0
- package/dist/capabilities/settings-contract.js +14 -0
- package/dist/capabilities/skills.d.ts +5 -5
- package/dist/capability-facts.d.ts +56 -1
- package/dist/capability-facts.js +59 -8
- package/dist/center-credential-renewer.js +3 -2
- package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
- package/dist/config-catalog.js +19 -9
- package/dist/config-invariants.d.ts +18 -3
- package/dist/config-invariants.js +36 -19
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-lkg.js +5 -6
- package/dist/config-provider.d.ts +2 -2
- package/dist/config-provider.js +2 -0
- package/dist/config-types.d.ts +228 -185
- package/dist/config.d.ts +74 -6
- package/dist/config.js +146 -64
- package/dist/degenerate-instrument.js +1 -1
- package/dist/deleted-session-ids.d.ts +19 -0
- package/dist/deleted-session-ids.js +26 -0
- package/dist/deploy-facts.d.ts +155 -0
- package/dist/deploy-facts.js +95 -0
- package/dist/deployment-shape.d.ts +21 -12
- package/dist/deployment-shape.js +24 -6
- package/dist/device-ws-hub.d.ts +48 -3
- package/dist/device-ws-hub.js +48 -2
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +10 -6
- package/dist/error-code-family.d.ts +35 -0
- package/dist/error-code-family.js +26 -0
- package/dist/execution-config-root.d.ts +5 -5
- package/dist/execution-config-root.js +5 -5
- package/dist/execution-env-purpose.d.ts +14 -0
- package/dist/execution-env-purpose.js +29 -0
- package/dist/execution-lane-caps.d.ts +49 -86
- package/dist/execution-lane-caps.js +52 -62
- package/dist/execution-placement.d.ts +18 -2
- package/dist/execution-placement.js +19 -0
- package/dist/file-history-disclosure.d.ts +2 -2
- package/dist/fleet/drain-entry.d.ts +46 -3
- package/dist/fleet/drain-entry.js +6 -0
- package/dist/fleet/fleet-bus.d.ts +2 -1
- package/dist/fleet/serving-lease.js +3 -4
- package/dist/history-anchor.d.ts +22 -0
- package/dist/history-anchor.js +14 -0
- package/dist/hooks/branch-transcript.d.ts +1 -1
- package/dist/hooks/branch-transcript.js +1 -0
- package/dist/hooks/classic-stations.d.ts +25 -8
- package/dist/hooks/classic-stations.js +29 -3
- package/dist/hooks/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-runner.d.ts +85 -24
- package/dist/hooks/hook-runner.js +326 -109
- package/dist/hooks/hook-source.d.ts +14 -2
- package/dist/hooks/hook-source.js +8 -0
- package/dist/http/active-run-conflict.d.ts +1 -1
- package/dist/http/active-run-conflict.js +1 -1
- package/dist/http/admission.js +11 -1
- package/dist/http/approval-sweeps.d.ts +2 -5
- package/dist/http/approval-sweeps.js +3 -2
- package/dist/http/checkpoint-ctx.d.ts +76 -71
- package/dist/http/checkpoint-ctx.js +40 -40
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/dispatch.js +19 -3
- package/dist/http/durable-run-leg.d.ts +5 -0
- package/dist/http/durable-run-leg.js +3 -1
- package/dist/http/execution-context.d.ts +7 -1
- package/dist/http/execution-context.js +13 -0
- package/dist/http/health-self-report.d.ts +6 -2
- package/dist/http/health-self-report.js +3 -2
- package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
- package/dist/http/memory-compliance-failure-reply.js +5 -15
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
- package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
- package/dist/http/memory-store-refusal-reply.d.ts +3 -3
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +7 -4
- package/dist/http/principal-gate.d.ts +28 -16
- package/dist/http/principal-gate.js +10 -19
- package/dist/http/request-guards.d.ts +2 -2
- package/dist/http/request-guards.js +5 -5
- package/dist/http/resume-legs.d.ts +29 -10
- package/dist/http/resume-legs.js +94 -56
- package/dist/http/rewind-files-reply.d.ts +34 -0
- package/dist/http/rewind-files-reply.js +36 -0
- package/dist/http/route-ctx.d.ts +43 -26
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/adoption.d.ts +11 -0
- package/dist/http/routes/adoption.js +80 -6
- package/dist/http/routes/agents-roster.js +1 -0
- package/dist/http/routes/approvals-assistant.js +7 -26
- package/dist/http/routes/background.js +1 -0
- package/dist/http/routes/capabilities.js +12 -3
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/diagnostics.d.ts +9 -14
- package/dist/http/routes/diagnostics.js +10 -20
- package/dist/http/routes/engine.d.ts +31 -0
- package/dist/http/routes/engine.js +81 -0
- package/dist/http/routes/memory-bundle.js +3 -0
- package/dist/http/routes/memory-consolidation.js +3 -5
- package/dist/http/routes/memory-origin.d.ts +2 -2
- package/dist/http/routes/memory-origin.js +2 -4
- package/dist/http/routes/memory-policy.js +5 -1
- package/dist/http/routes/notify-wake.js +2 -1
- package/dist/http/routes/observability.js +3 -6
- package/dist/http/routes/projects.d.ts +70 -0
- package/dist/http/routes/projects.js +86 -0
- package/dist/http/routes/rules.js +30 -2
- package/dist/http/routes/runs.js +15 -11
- package/dist/http/routes/session-sync.js +39 -35
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +108 -2
- package/dist/http/routes/tasks.js +32 -8
- package/dist/http/routes/trace-usage.js +1 -1
- package/dist/http/run-concurrency-cap.d.ts +86 -0
- package/dist/http/run-concurrency-cap.js +54 -0
- package/dist/http/server.d.ts +31 -14
- package/dist/http/server.js +29 -3
- package/dist/http/stored-body-replay.d.ts +12 -7
- package/dist/http/stored-body-replay.js +28 -5
- package/dist/http/wire-types.d.ts +27 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- package/dist/json-body-limit.d.ts +8 -0
- package/dist/json-body-limit.js +2 -0
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/local-data-root.d.ts +2 -2
- package/dist/memory-embedder-reembed.d.ts +38 -0
- package/dist/memory-embedder-reembed.js +20 -0
- package/dist/memory-incident-sink.d.ts +0 -28
- package/dist/memory-incident-sink.js +5 -0
- package/dist/memory-operator-faces.d.ts +9 -4
- package/dist/memory-scope-stores.d.ts +9 -7
- package/dist/memory-scope-stores.js +3 -14
- package/dist/memory-scope.d.ts +38 -2
- package/dist/memory-scope.js +33 -2
- package/dist/memory-store-refusal.d.ts +17 -4
- package/dist/memory-store-refusal.js +1 -1
- package/dist/memory-sync-client.d.ts +2 -0
- package/dist/memory-sync-client.js +13 -11
- package/dist/memory-sync.js +1 -1
- package/dist/model-compat.d.ts +35 -21
- package/dist/model-compat.js +49 -21
- package/dist/model-entry-refusal.d.ts +11 -1
- package/dist/model-entry-refusal.js +7 -0
- package/dist/namespaced-rule-name.d.ts +18 -1
- package/dist/namespaced-rule-name.js +12 -0
- package/dist/net-address.d.ts +53 -0
- package/dist/net-address.js +111 -0
- package/dist/observability/fail-open.d.ts +29 -17
- package/dist/observability/fail-open.js +29 -17
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +2 -0
- package/dist/observability/secret-env-scrub.d.ts +30 -4
- package/dist/observability/secret-env-scrub.js +15 -3
- package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
- package/dist/orchestration/workflow-agent-session-index.js +1 -6
- package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
- package/dist/orchestration/workflow-completion-inbox.js +63 -45
- package/dist/orchestration/workflow-notify-journal.js +2 -3
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +5 -2
- package/dist/org-memory-admission.js +25 -10
- package/dist/parked-decide.d.ts +33 -26
- package/dist/parked-decide.js +36 -44
- package/dist/peer-directory.d.ts +6 -12
- package/dist/peer-directory.js +5 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +37 -4
- package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
- package/dist/plugins/approval-ask-store-memory.js +11 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
- package/dist/plugins/approval-ask-store-sql.js +3 -1
- package/dist/plugins/blob-backend.d.ts +38 -195
- package/dist/plugins/blob-backend.js +33 -229
- package/dist/plugins/caching-session-store.d.ts +12 -5
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
- package/dist/plugins/checkpoint-index-columns.js +3 -2
- package/dist/plugins/checkpoint-store-face.d.ts +426 -0
- package/dist/plugins/checkpoint-store-face.js +152 -0
- package/dist/plugins/device-store-sql.d.ts +2 -2
- package/dist/plugins/device-store-sql.js +5 -10
- package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
- package/dist/plugins/execution-lane-rename-m40.js +10 -0
- package/dist/plugins/execution-placement-sql.d.ts +63 -88
- package/dist/plugins/execution-placement-sql.js +94 -54
- package/dist/plugins/file-run-store.d.ts +26 -18
- package/dist/plugins/file-run-store.js +64 -75
- package/dist/plugins/fork-routing-session-store.d.ts +6 -2
- package/dist/plugins/fork-routing-session-store.js +2 -2
- package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
- package/dist/plugins/imported-layer-root-retirement.js +4 -8
- package/dist/plugins/inbox-payload-column.d.ts +14 -0
- package/dist/plugins/inbox-payload-column.js +13 -0
- package/dist/plugins/local-checkpoint-store.d.ts +7 -2
- package/dist/plugins/local-checkpoint-store.js +13 -8
- package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
- package/dist/plugins/local-data-dir-modes-m39.js +182 -0
- package/dist/plugins/local-engine-high-water.d.ts +11 -0
- package/dist/plugins/local-engine-high-water.js +59 -0
- package/dist/plugins/local-session-store.d.ts +119 -30
- package/dist/plugins/local-session-store.js +156 -53
- package/dist/plugins/local-task-attachment-store.d.ts +2 -0
- package/dist/plugins/local-task-attachment-store.js +10 -11
- package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
- package/dist/plugins/memory-embedder-fingerprint.js +52 -12
- package/dist/plugins/memory-embedder.d.ts +1 -1
- package/dist/plugins/memory-embedder.js +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +30 -6
- package/dist/plugins/memory-engine-pg.js +96 -214
- package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
- package/dist/plugins/memory-engine-sql-apply.js +358 -0
- package/dist/plugins/memory-engine-tidb.d.ts +38 -9
- package/dist/plugins/memory-engine-tidb.js +99 -230
- package/dist/plugins/memory-key-guards.d.ts +1 -1
- package/dist/plugins/memory-origin-law.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +169 -83
- package/dist/plugins/one-time-migrations.js +295 -235
- package/dist/plugins/owner-only-file-mode.d.ts +29 -0
- package/dist/plugins/owner-only-file-mode.js +141 -0
- package/dist/plugins/permission-rule-store-file.d.ts +17 -3
- package/dist/plugins/permission-rule-store-file.js +20 -1
- package/dist/plugins/pg-pool.d.ts +2 -1
- package/dist/plugins/pg-pool.js +12 -5
- package/dist/plugins/release-version.d.ts +20 -0
- package/dist/plugins/release-version.js +28 -0
- package/dist/plugins/remote-env-adb.d.ts +20 -4
- package/dist/plugins/remote-env-adb.js +39 -11
- package/dist/plugins/remote-env-e2b.d.ts +12 -3
- package/dist/plugins/remote-env-e2b.js +6 -4
- package/dist/plugins/remote-env-host.d.ts +9 -1
- package/dist/plugins/remote-env-host.js +6 -5
- package/dist/plugins/remote-env-k8s.d.ts +5 -2
- package/dist/plugins/remote-env-k8s.js +15 -4
- package/dist/plugins/remote-env-local-docker.d.ts +4 -1
- package/dist/plugins/remote-env-local-docker.js +3 -3
- package/dist/plugins/remote-env-ssh.d.ts +8 -2
- package/dist/plugins/remote-env-ssh.js +26 -24
- package/dist/plugins/remote-shell.d.ts +59 -30
- package/dist/plugins/remote-shell.js +175 -62
- package/dist/plugins/retention-declaration.d.ts +37 -0
- package/dist/plugins/retention-declaration.js +9 -0
- package/dist/plugins/retention-deployment.d.ts +126 -0
- package/dist/plugins/retention-deployment.js +88 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
- package/dist/plugins/retention-lane-store-sql.js +103 -1
- package/dist/plugins/retention-sql.d.ts +29 -0
- package/dist/plugins/retention-sql.js +8 -0
- package/dist/plugins/run-store-sql.js +2 -2
- package/dist/plugins/schema-consistency.d.ts +0 -6
- package/dist/plugins/schema-consistency.js +1 -2
- package/dist/plugins/schema-ensure-legs.d.ts +1 -1
- package/dist/plugins/schema-ensure-legs.js +13 -3
- package/dist/plugins/session-ext-table.d.ts +74 -0
- package/dist/plugins/session-ext-table.js +121 -0
- package/dist/plugins/session-fork.d.ts +31 -9
- package/dist/plugins/session-fork.js +3 -2
- package/dist/plugins/session-placement.d.ts +4 -2
- package/dist/plugins/session-row-sql.d.ts +8 -7
- package/dist/plugins/session-row-sql.js +15 -7
- package/dist/plugins/session-store-sql.d.ts +131 -0
- package/dist/plugins/session-store-sql.js +298 -0
- package/dist/plugins/session-workspace-cell.d.ts +2 -2
- package/dist/plugins/session-workspace-cell.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
- package/dist/plugins/shared-memory-store-sql.js +13 -13
- package/dist/plugins/snapshot-bucket-presence.js +1 -1
- package/dist/plugins/sql-driver.d.ts +23 -7
- package/dist/plugins/sql-driver.js +41 -8
- package/dist/plugins/sql-errors.d.ts +5 -2
- package/dist/plugins/sql-errors.js +4 -0
- package/dist/plugins/sql-json-column.d.ts +5 -1
- package/dist/plugins/store-backend.d.ts +46 -16
- package/dist/plugins/store-backend.js +192 -69
- package/dist/plugins/store-contracts.d.ts +10 -13
- package/dist/plugins/store-contracts.js +1 -9
- package/dist/plugins/store-sweep.d.ts +63 -0
- package/dist/plugins/store-sweep.js +48 -0
- package/dist/plugins/task-attachment-store.d.ts +6 -8
- package/dist/plugins/task-attachment-store.js +15 -10
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/text-column-capacity.d.ts +21 -0
- package/dist/plugins/text-column-capacity.js +5 -0
- package/dist/plugins/tidb-pool.d.ts +3 -2
- package/dist/plugins/tidb-pool.js +20 -32
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- package/dist/prompt-screen.d.ts +6 -9
- package/dist/prompt-screen.js +2 -5
- package/dist/read-face-posture.d.ts +6 -6
- package/dist/read-face-posture.js +2 -2
- package/dist/request-value-closure.d.ts +5 -5
- package/dist/request-value-closure.js +1 -1
- package/dist/rules-consent.d.ts +48 -27
- package/dist/rules-consent.js +147 -23
- package/dist/run-cancel-context.d.ts +4 -1
- package/dist/run-cancel-context.js +2 -1
- package/dist/run-local.js +17 -13
- package/dist/runs.d.ts +48 -30
- package/dist/runs.js +27 -17
- package/dist/runtime-caps-resolver.d.ts +15 -8
- package/dist/runtime-caps-resolver.js +14 -10
- package/dist/sandbox-egress-policy.js +6 -11
- package/dist/sandbox-rbac-rules.d.ts +88 -0
- package/dist/sandbox-rbac-rules.js +80 -0
- package/dist/sealed-key-layout.d.ts +16 -0
- package/dist/sealed-key-layout.js +3 -0
- package/dist/sealed-key.js +8 -6
- package/dist/security.d.ts +43 -9
- package/dist/security.js +9 -2
- package/dist/sema-config-dir.js +2 -2
- package/dist/server-secret-env.d.ts +2 -0
- package/dist/service-version.d.ts +2 -1
- package/dist/service-version.js +2 -2
- package/dist/session-error-wire.d.ts +1 -1
- package/dist/session-incarnation.d.ts +8 -5
- package/dist/session-notify-door.d.ts +5 -3
- package/dist/session-resident-background.d.ts +110 -0
- package/dist/session-resident-background.js +88 -0
- package/dist/session-row.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +53 -14
- package/dist/session-sync-kernel.js +70 -1
- package/dist/session-sync.d.ts +5 -3
- package/dist/session-workspace.d.ts +12 -2
- package/dist/session-workspace.js +6 -0
- package/dist/sighup-idle.d.ts +9 -7
- package/dist/sighup-idle.js +4 -5
- package/dist/spec-fields.d.ts +16 -0
- package/dist/spec-fields.js +7 -0
- package/dist/store-posture.d.ts +2 -1
- package/dist/stored-request-env-credentials-m38.d.ts +3 -0
- package/dist/stored-request-env-credentials-m38.js +8 -0
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +19 -14
- package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
- package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
- package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
- package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
- package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
- package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
- package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
- package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
- package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
- package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
- package/dist/stores-sql/session-write-hooks.d.ts +59 -0
- package/dist/stores-sql/session-write-hooks.js +2 -0
- package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
- package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
- package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
- package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
- package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
- package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
- package/dist/stores-sql/windowed-session-storage.js +61 -0
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
- package/dist/task-a2a.d.ts +7 -1
- package/dist/task-a2a.js +15 -14
- package/dist/task-cwd.d.ts +11 -3
- package/dist/task-cwd.js +17 -1
- package/dist/task-mcp.d.ts +10 -2
- package/dist/task-mcp.js +13 -16
- package/dist/task-settings.d.ts +68 -8
- package/dist/task-settings.js +63 -6
- package/dist/tool-approval.d.ts +23 -10
- package/dist/tool-approval.js +10 -6
- package/dist/trace/core-keyset-guard.d.ts +17 -10
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -0
- package/dist/trace/exit-seat.d.ts +29 -1
- package/dist/trace/exit-seat.js +4 -0
- package/dist/trace/project.d.ts +33 -16
- package/dist/trace/project.js +21 -9
- package/dist/trace/redact.d.ts +13 -2
- package/dist/trace/redact.js +347 -78
- package/dist/trace/self-minted-wire.d.ts +587 -16
- package/dist/trace/self-minted-wire.js +215 -9
- package/dist/trace/sema-provenance.d.ts +45 -41
- package/dist/trace/sema-provenance.js +81 -10
- package/dist/trace/task-notification-facets.d.ts +70 -2
- package/dist/trace/task-notification-facets.js +71 -1
- package/dist/trace/wire-projection-faces.d.ts +39 -3
- package/dist/trace/wire-projection-faces.js +27 -2
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -0
- package/dist/usage-analytics.d.ts +4 -0
- package/dist/user-input-ledger.d.ts +2 -2
- package/dist/web-admin-client/apply-effective.js +22 -26
- package/dist/web-admin-client/candidate-gate.d.ts +35 -3
- package/dist/web-admin-client/candidate-gate.js +53 -5
- package/dist/web-admin-client/center-request.d.ts +4 -1
- package/dist/web-admin-client/center-request.js +2 -1
- package/dist/web-admin-client/effective-keys.js +0 -1
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/http-client.d.ts +1 -0
- package/dist/web-admin-client/http-client.js +17 -9
- package/dist/web-admin-client/restart-signal.js +5 -2
- package/dist/web-admin-client/skills-mcp.d.ts +20 -6
- package/dist/web-admin-client/skills-mcp.js +26 -21
- package/dist/web-admin-client/types.d.ts +34 -49
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
- package/package.json +22 -13
- package/scripts/drain-check-local.mjs +8 -55
- package/scripts/drain-check.mysql.sql +3 -40
- package/scripts/drain-check.pg.sql +3 -40
- package/skills/update-config.md +1 -1
- package/wire-changes/server@7.146.0.json +3221 -0
- package/wire-changes/server@7.147.0.json +813 -0
- package/dist/approval-batch-census.d.ts +0 -27
- package/dist/approval-batch-census.js +0 -27
|
@@ -1,16 +1,62 @@
|
|
|
1
1
|
import { loadRemoteExec } from "@sema-agent/settings-schema/node";
|
|
2
2
|
import { assertLocalConfigDirTrusted } from "../config-dir-trust.js";
|
|
3
3
|
import { crossInvariant } from "../config-invariants.js";
|
|
4
|
-
import {
|
|
4
|
+
import { entryDeclarableRemoteExec } from "../config.js";
|
|
5
|
+
import { ALL_EXECUTION_LANES, buildReadDenyFloorUnkeptNote, laneIsolated, laneWiresExecutionEnv } from "../execution-lane-caps.js";
|
|
5
6
|
import { buildReadFacePostureNotice, settleDerivedReadFace } from "../read-face-posture.js";
|
|
6
7
|
import { settleHostShellAtBoot } from "../plugins/host-platform.js";
|
|
7
8
|
import { seatText } from "../trace/exit-seat.js";
|
|
8
|
-
export const FILE_SOURCED_LANES = ["host", "local-docker"];
|
|
9
|
-
export
|
|
9
|
+
export const FILE_SOURCED_LANES = ["host", "local-docker", "none"];
|
|
10
|
+
export const EXECUTION_LANE_UNDECLARED_REFUSAL = (() => {
|
|
11
|
+
const sandboxLanes = ALL_EXECUTION_LANES.filter((lane) => laneIsolated(lane));
|
|
12
|
+
const otherHandLanes = ALL_EXECUTION_LANES.filter((lane) => lane !== "host" && laneWiresExecutionEnv(lane) && !laneIsolated(lane));
|
|
13
|
+
return ("No execution lane is declared — every deployment names its execution lane: set REMOTE_EXEC (with CONFIG_PROVIDER=local, config.d/remote-exec.json also declares it). " +
|
|
14
|
+
"To keep what this deployment did before 7.147.0: REMOTE_EXEC=none when CONFIG_PROVIDER is not \"local\" (no execution environment — the agent's tool hands never mount), " +
|
|
15
|
+
"REMOTE_EXEC=host when CONFIG_PROVIDER=local (tools run directly on this machine with no OS sandbox). " +
|
|
16
|
+
`Or name a sandbox lane (${sandboxLanes.join(" | ")}) or ${otherHandLanes.join(" | ")} with that lane's required env. ` +
|
|
17
|
+
"CONFIG_PROVIDER only selects where configuration is read from; it does not select an execution lane.");
|
|
18
|
+
})();
|
|
19
|
+
export const HTTP_SERVICE_LANE_ENTRY = { name: "the HTTP service", runs: ALL_EXECUTION_LANES };
|
|
20
|
+
function entryCannotRunLaneRefusal(entry, lane, source) {
|
|
21
|
+
return (`${source} declares the execution lane "${lane}", but ${entry.name} runs only ${entry.runs.join(" / ")} — it has no executor for "${lane}". ` +
|
|
22
|
+
`Refusing before any task starts rather than run on another lane: declare a lane ${entry.name} runs, or serve "${lane}" from an entry that runs it (the HTTP service runs every lane).`);
|
|
23
|
+
}
|
|
24
|
+
function fileLaneUnresolvableRefusal(entry, lane, envReading, root) {
|
|
25
|
+
return (`config.d/remote-exec.json under ${root} declares the execution lane "${lane}", but ${entry.name} reads "${lane}"'s coordinates only from REMOTE_EXEC env ` +
|
|
26
|
+
`(file-source name→value resolution is not wired yet), and ${envReading}. The file's declaration ends the lane selection: no other declaration may stand in for it. ` +
|
|
27
|
+
`Refusing before any task starts: set REMOTE_EXEC=${lane} with that lane's required env, or change the file to the lane you mean.`);
|
|
28
|
+
}
|
|
29
|
+
export async function composeExecutionLane(loaded, ctx) {
|
|
10
30
|
if (ctx.configSource === "local")
|
|
11
|
-
await applyRemoteExecFile(
|
|
12
|
-
|
|
31
|
+
await applyRemoteExecFile(loaded, ctx);
|
|
32
|
+
return composeDeclaredExecutionLane(loaded, ctx.logger, ctx.entry);
|
|
33
|
+
}
|
|
34
|
+
export function composeDeclaredExecutionLane(loaded, logger, entry) {
|
|
35
|
+
if (entry !== undefined)
|
|
36
|
+
settleEntryLane(loaded, entry);
|
|
37
|
+
const config = requireDeclaredExecutionLane(loaded);
|
|
38
|
+
settleReadFaceForFinalLane(config, logger);
|
|
13
39
|
assertExecutionLaneInvariants(config);
|
|
40
|
+
logger.info("exec_lane_selected", { lane: config.remoteExec.provider });
|
|
41
|
+
return config;
|
|
42
|
+
}
|
|
43
|
+
function requireDeclaredExecutionLane(loaded) {
|
|
44
|
+
if (!isComposed(loaded))
|
|
45
|
+
throw new Error(EXECUTION_LANE_UNDECLARED_REFUSAL);
|
|
46
|
+
return loaded;
|
|
47
|
+
}
|
|
48
|
+
function settleEntryLane(loaded, entry) {
|
|
49
|
+
const declaredByEntry = !isComposed(loaded) ? entry.declares : undefined;
|
|
50
|
+
if (declaredByEntry !== undefined)
|
|
51
|
+
loaded.remoteExec = entryDeclarableRemoteExec(declaredByEntry);
|
|
52
|
+
if (!isComposed(loaded))
|
|
53
|
+
return;
|
|
54
|
+
const lane = loaded.remoteExec.provider;
|
|
55
|
+
if (!entry.runs.includes(lane))
|
|
56
|
+
throw new Error(entryCannotRunLaneRefusal(entry, lane, declaredByEntry !== undefined ? `${entry.name} itself` : `REMOTE_EXEC=${lane}`));
|
|
57
|
+
}
|
|
58
|
+
function isComposed(config) {
|
|
59
|
+
return config.remoteExec !== undefined;
|
|
14
60
|
}
|
|
15
61
|
function settleReadFaceForFinalLane(config, logger) {
|
|
16
62
|
if (!settleDerivedReadFace(config, config.requirePrincipal !== true))
|
|
@@ -20,14 +66,14 @@ function settleReadFaceForFinalLane(config, logger) {
|
|
|
20
66
|
logger.info(notice.event, notice.fields);
|
|
21
67
|
}
|
|
22
68
|
export async function settleHostLaneShell(config, logger) {
|
|
23
|
-
if (config.remoteExec
|
|
69
|
+
if (config.remoteExec.provider !== "host")
|
|
24
70
|
return;
|
|
25
71
|
await settleHostShellAtBoot(logger);
|
|
26
72
|
}
|
|
27
73
|
export function warnReadDenyFloorUnkept(config, logger) {
|
|
28
74
|
const note = buildReadDenyFloorUnkeptNote(config);
|
|
29
75
|
if (note !== undefined)
|
|
30
|
-
logger.warn("read_deny_floor_required_unkept", { provider: config.remoteExec
|
|
76
|
+
logger.warn("read_deny_floor_required_unkept", { provider: config.remoteExec.provider, note });
|
|
31
77
|
}
|
|
32
78
|
export function assertExecutionLaneInvariants(config) {
|
|
33
79
|
const judge = (id) => crossInvariant(id).check({ live: config, next: config });
|
|
@@ -61,11 +107,12 @@ async function applyRemoteExecFile(config, ctx) {
|
|
|
61
107
|
}
|
|
62
108
|
if (!fileRx)
|
|
63
109
|
return;
|
|
64
|
-
const
|
|
65
|
-
const disclosePreemption = (winner) => {
|
|
110
|
+
const envDeclared = config.remoteExec?.provider;
|
|
111
|
+
const disclosePreemption = envDeclared === undefined ? (_winner) => { } : (winner) => {
|
|
112
|
+
const preemptedLane = envDeclared;
|
|
66
113
|
if (winner === preemptedLane)
|
|
67
114
|
return;
|
|
68
|
-
const downgrade = laneIsolated(preemptedLane) && !laneIsolated(winner);
|
|
115
|
+
const downgrade = laneIsolated(preemptedLane) && laneWiresExecutionEnv(winner) && !laneIsolated(winner);
|
|
69
116
|
logger.warn("remote_exec_lane_preempted_by_file", {
|
|
70
117
|
preemptedLane,
|
|
71
118
|
effectiveLane: winner,
|
|
@@ -76,7 +123,7 @@ async function applyRemoteExecFile(config, ctx) {
|
|
|
76
123
|
(downgrade ? `. This is an ISOLATION DOWNGRADE: tasks run on a non-isolated target. Delete/fix the file, or unset the lane env if the file is the intended source.` : `. Delete/fix the file, or unset the lane env if the file is the intended source.`),
|
|
77
124
|
});
|
|
78
125
|
};
|
|
79
|
-
const drives = (lane) => ctx.
|
|
126
|
+
const drives = (lane) => ctx.entry.runs.includes(lane);
|
|
80
127
|
if (fileRx.provider === "host" && drives("host")) {
|
|
81
128
|
config.remoteExec = {
|
|
82
129
|
provider: "host",
|
|
@@ -100,18 +147,25 @@ async function applyRemoteExecFile(config, ctx) {
|
|
|
100
147
|
logger.info("remote_exec_from_file", { provider: "local-docker", root: localRoot, image: fileRx.image });
|
|
101
148
|
return;
|
|
102
149
|
}
|
|
150
|
+
if (fileRx.provider === "none" && drives("none")) {
|
|
151
|
+
config.remoteExec = { provider: "none" };
|
|
152
|
+
disclosePreemption("none");
|
|
153
|
+
logger.info("remote_exec_from_file", { provider: "none", root: localRoot });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
103
156
|
const fileLane = fileRx.provider;
|
|
104
|
-
|
|
157
|
+
if (!ctx.entry.runs.includes(fileLane))
|
|
158
|
+
throw new Error(entryCannotRunLaneRefusal(ctx.entry, fileLane, `config.d/remote-exec.json under ${localRoot}`));
|
|
159
|
+
if (envDeclared !== fileLane) {
|
|
160
|
+
const envReading = envDeclared === undefined ? "REMOTE_EXEC is not set" : `REMOTE_EXEC declares "${envDeclared}"`;
|
|
161
|
+
throw new Error(fileLaneUnresolvableRefusal(ctx.entry, fileLane, envReading, localRoot));
|
|
162
|
+
}
|
|
105
163
|
logger.warn("remote_exec_file_isolated_lane_unwired", {
|
|
106
164
|
provider: fileLane,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
`from the file; the HTTP service drives ${FILE_SOURCED_LANES.join(" / ")}) — the env-derived lane above stays in force`
|
|
112
|
-
: `this entry drives ${ctx.drivesFromFile.join(" / ")} from config.d/remote-exec.json; "${fileLane}" (like the other isolated lanes ` +
|
|
113
|
-
`e2b / k8s / ssh / adb) is sourced from REMOTE_EXEC env until file-source NAME→value resolution lands (center field map) — the ` +
|
|
114
|
-
`env-derived lane above stays in force`,
|
|
165
|
+
reason: "needs-name-resolution",
|
|
166
|
+
note: `config.d/remote-exec.json and REMOTE_EXEC both declare "${fileLane}": this entry takes ${FILE_SOURCED_LANES.filter((lane) => ctx.entry.runs.includes(lane)).join(" / ")} ` +
|
|
167
|
+
`from the file; "${fileLane}" (like the other isolated lanes e2b / k8s / ssh / adb) takes its coordinates from REMOTE_EXEC env until file-source NAME→value ` +
|
|
168
|
+
`resolution lands (center field map) — the coordinates written in the file for it are not read`,
|
|
115
169
|
});
|
|
116
170
|
}
|
|
117
171
|
//# sourceMappingURL=execution-lane.js.map
|
|
@@ -1,4 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [ref] —— **进程退出边界**的装配器:全进程**一只**,两条车道(HTTP 服务 / `run-local` 一次性 CLI)同走。
|
|
3
|
+
*
|
|
4
|
+
* 不变量 = **本进程拥有的东西不得活过本进程**(自起的前台子进程组 + 自铸的 ephemeral host 工作区)。
|
|
5
|
+
* 它是**进程**的性质,不属于某一条退出路径,也不属于某一个入口 —— 所以收割挂 `process.once("exit")`,
|
|
6
|
+
* 而这只钩的**装配**从 `boot/shutdown.ts`(只有 HTTP 车道装得起:它的 ctx 绑着 server / backend / runner…)
|
|
7
|
+
* 抽到这里,变成一条只要一只 {@link Logger} 的函数。
|
|
8
|
+
*
|
|
9
|
+
* ── [ref] 的病(test 7.93.3 复验实测)────────────────────────────────────────────────────────────────
|
|
10
|
+
* [ref] 之后 HTTP 车道零孤儿,而 `src/run-local.ts` **一只 `process.on/once` 都没有** —— 它却经
|
|
11
|
+
* `hostExecutionEnvFactory` 走同一条 host exec 腿、同一本前台簿(`trackHostForegroundChild`)。Ctrl-C ⇒
|
|
12
|
+
* 进程在 12ms 内被信号**默认终止**,簿上的组留 `ppid=1` 跑满。用户面:一次 `sema run` 被 Ctrl-C 之后,
|
|
13
|
+
* 机器上留着它起的 `npm run build` / `sleep`,没有任何人会再去 kill。
|
|
14
|
+
*
|
|
15
|
+
* ── 为什么不是「run-local 也补一份」──────────────────────────────────────────────────────────────────
|
|
16
|
+
* 同一句不变量在两个入口各写一份 = 两个写者、两份会各自腐烂的注(CLAUDE.md 以点改面:修一个类,不是
|
|
17
|
+
* 修一个出口)。所以是**抽出**而不是复制:钩体、两条腿、哨兵读数、`dispose` 全在本文件,两条车道各自
|
|
18
|
+
* 只剩一行调用。HTTP 车道的行为**逐字不变**(函数体整段搬运,缩进外无一字改动)。
|
|
19
|
+
*
|
|
20
|
+
* 🔴 **光有本装配器治不了 run-local**:`exit` 事件在进程被信号**默认终止**时**不触发**。前台 CLI 的
|
|
21
|
+
* Ctrl-C 是常态 ⇒ run-local 必须同时装 SIGINT / SIGTERM 处理器,让信号落到一条显式 `process.exit` 上
|
|
22
|
+
* (见 `run-local.ts` 的 {@link installRunLocalExitBoundary} 注:退出码取 128+signo 的理由写在那里)。
|
|
23
|
+
* HTTP 车道的三只信号处理器留在 `boot/shutdown.ts`(它们承载的是 drain / SIGHUP 空闲窗这些**车道语义**,
|
|
24
|
+
* 不是退出边界)。
|
|
25
|
+
*/
|
|
26
|
+
import { type TaskRegistry } from "@sema-agent/core";
|
|
1
27
|
import type { Logger } from "../observability/logger.js";
|
|
28
|
+
/**
|
|
29
|
+
* 退出边界的硬收面**此刻**会收掉的后台 shell 行数(`background_bash` + `monitor`,在跑,整张进程级注册表,retain 行按
|
|
30
|
+
* {@link PROCESS_EXIT_INCLUDES_RETAINED} 跳过)—— 「引擎现在退,会不会把一条在跑的后台 shell 一起收掉」这一问的**唯一**读法。
|
|
31
|
+
*
|
|
32
|
+
* 一问一源:数与收读同一只 `includeRetained` 常量,core 的 `countRunningBackgroundShells` 与 `killAllBackgroundShellsNow` 又按同一只访问函数选行
|
|
33
|
+
* (core 注:the count and the walk cannot drift)⇒ 这只数就是硬收面会交出的 `killed` 收据数。
|
|
34
|
+
* **不是** `/health.inflightBreakdown.sessionResident`(`session-resident-background.ts`):那一项回答「引擎托管着多少会话驻留的 shell / monitor」,是总数里的一个分项 ——
|
|
35
|
+
* 只数围栏表里会话的、会话驻留的行(挂在 run 腿上的行算在 http 项里,数它是第二次;围栏外的会话它看不见);本函数整表数、不分会话,
|
|
36
|
+
* 腿上的行、围栏外会话的行都在内。两问的关系 = 读得出时本数 ≥ 驻留项(驻留项的每一行都是本数的一行)。
|
|
37
|
+
*
|
|
38
|
+
* 读不出(core:某行 env 的 retain 声明读抛 ⇒ 计数抛)⇒ 按 **1** 计并经 `onUnreadable` 报出 —— 读不出 ⇒ 非空闲,与驻留项同一条律;
|
|
39
|
+
* 本函数在租约拍(定时器回调)、`/health` 与交接口里被调,**不许抛**(定时器里一抛就是 uncaught,一台交接出去的引擎会因此崩掉并收掉它本该留着的 shell)——
|
|
40
|
+
* 报口自己再抛(抛出物转不成文本之类)也一样:落 `console.error`(不回同一只报口),读数照返 1。
|
|
41
|
+
* `registry` 只供测试换桩(只用到 `countRunningBackgroundShells`)。
|
|
42
|
+
*/
|
|
43
|
+
export declare function countShellsExitWouldKill(opts: {
|
|
44
|
+
readonly registry?: Pick<TaskRegistry, "countRunningBackgroundShells">;
|
|
45
|
+
readonly onUnreadable: (err: unknown) => void;
|
|
46
|
+
}): number;
|
|
2
47
|
/** {@link installProcessExitBoundary} 的把手。 */
|
|
3
48
|
export interface ProcessExitBoundary {
|
|
4
49
|
/**
|
|
@@ -8,6 +53,11 @@ export interface ProcessExitBoundary {
|
|
|
8
53
|
* 返回本次软停的后台行数(core `reapAllSessionBackground` 的返回;腿抛错 ⇒ 0,warn 已记)—— 调用方据此决定欠不欠宽限。
|
|
9
54
|
*/
|
|
10
55
|
reapChildProcessesEarly(): number;
|
|
56
|
+
/**
|
|
57
|
+
* 硬收面此刻会收掉的后台 shell 行数({@link countShellsExitWouldKill},进程级注册表)。读不出 ⇒ 按 1 计,运维行
|
|
58
|
+
* `engine_handover_shell_count_unreadable` 本装配**只响一次**(这只读口在租约拍里被调,逐次响会刷屏)。附着租约交接车道那一格工作谓词读它。
|
|
59
|
+
*/
|
|
60
|
+
shellsExitWouldKill(): number;
|
|
11
61
|
/** 摘掉本次装配的 `exit` 钩。幂等(同进程内反复装配的调用方=测试必须用它收尾)。 */
|
|
12
62
|
dispose(): void;
|
|
13
63
|
}
|
|
@@ -4,6 +4,21 @@ import { liveHostForegroundChildCount, reapHostForegroundChildren } from "../plu
|
|
|
4
4
|
import { liveEphemeralHostWorkspaceCount, reapEphemeralHostWorkspaces } from "../plugins/host-workspace-registry.js";
|
|
5
5
|
import { seatText } from "../trace/exit-seat.js";
|
|
6
6
|
const PROCESS_EXIT_INCLUDES_RETAINED = false;
|
|
7
|
+
export function countShellsExitWouldKill(opts) {
|
|
8
|
+
const registry = opts.registry ?? defaultTaskRegistry;
|
|
9
|
+
try {
|
|
10
|
+
return registry.countRunningBackgroundShells({ includeRetained: PROCESS_EXIT_INCLUDES_RETAINED });
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
try {
|
|
14
|
+
opts.onUnreadable(err);
|
|
15
|
+
}
|
|
16
|
+
catch (reportErr) {
|
|
17
|
+
console.error("engine_handover_shell_count_report_threw", reportErr);
|
|
18
|
+
}
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
7
22
|
export function installProcessExitBoundary({ logger }) {
|
|
8
23
|
const reapOwnChildProcesses = () => {
|
|
9
24
|
let backgroundSoftStopped = 0;
|
|
@@ -81,8 +96,25 @@ export function installProcessExitBoundary({ logger }) {
|
|
|
81
96
|
};
|
|
82
97
|
process.once("exit", onProcessExit);
|
|
83
98
|
let disposed = false;
|
|
99
|
+
let shellCountUnreadableReported = false;
|
|
100
|
+
const shellsExitWouldKill = () => countShellsExitWouldKill({
|
|
101
|
+
onUnreadable: (err) => {
|
|
102
|
+
if (shellCountUnreadableReported)
|
|
103
|
+
return;
|
|
104
|
+
shellCountUnreadableReported = true;
|
|
105
|
+
let text;
|
|
106
|
+
try {
|
|
107
|
+
text = String(err);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
text = Object.prototype.toString.call(err);
|
|
111
|
+
}
|
|
112
|
+
logger.warn("engine_handover_shell_count_unreadable", { counted: 1, err: seatText("operator-log-text", text) });
|
|
113
|
+
},
|
|
114
|
+
});
|
|
84
115
|
return {
|
|
85
116
|
reapChildProcessesEarly: reapOwnChildProcesses,
|
|
117
|
+
shellsExitWouldKill,
|
|
86
118
|
dispose: () => {
|
|
87
119
|
if (disposed)
|
|
88
120
|
return;
|
package/dist/boot/exit-last.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/** 本构建写的格式号([ref] 抬到 2;[ref] 抬到 3:必填 `lane`,退 `orphan` / `firstAttachWindowExpired`)。格式 1 = 无 `format` 键的旧形。 */
|
|
3
|
+
export declare const EXIT_LAST_FORMAT = 3;
|
|
2
4
|
/** 读回 schema(宪法 [ref] §2:边界读一律 safeParse,不裸铸)。写侧同形。 */
|
|
3
5
|
declare const ExitLastSchema: z.ZodObject<{
|
|
6
|
+
format: z.ZodLiteral<3>;
|
|
4
7
|
at: z.ZodString;
|
|
5
8
|
version: z.ZodString;
|
|
6
9
|
pid: z.ZodNumber;
|
|
7
|
-
|
|
10
|
+
lane: z.ZodEnum<{
|
|
11
|
+
orphan: "orphan";
|
|
12
|
+
handover: "handover";
|
|
13
|
+
awaitingFirstAttach: "awaitingFirstAttach";
|
|
14
|
+
owned: "owned";
|
|
15
|
+
}>;
|
|
8
16
|
reason: z.ZodString;
|
|
9
17
|
idleForMs: z.ZodNumber;
|
|
10
18
|
attached: z.ZodNumber;
|
|
@@ -15,9 +23,17 @@ declare const ExitLastSchema: z.ZodObject<{
|
|
|
15
23
|
export type ExitLastInfo = z.infer<typeof ExitLastSchema>;
|
|
16
24
|
export declare function exitLastPath(dataRoot: string): string;
|
|
17
25
|
/** 自退那一刻写留痕(同步;自身绝不抛 —— 留痕写失败不得阻塞停机)。 */
|
|
18
|
-
export declare function writeExitLast(dataRoot: string, info: Omit<ExitLastInfo, "at" | "pid">): void;
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
26
|
+
export declare function writeExitLast(dataRoot: string, info: Omit<ExitLastInfo, "format" | "at" | "pid">): void;
|
|
27
|
+
/** {@link readExitLast} 的读数:本构建格式读成了 ⇒ `found`;文件格式号不是 {@link EXIT_LAST_FORMAT} ⇒ `formatMismatch`(契约 6)。 */
|
|
28
|
+
export type ExitLastReading = {
|
|
29
|
+
readonly kind: "found";
|
|
30
|
+
readonly info: ExitLastInfo;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "formatMismatch";
|
|
33
|
+
readonly fileFormat: number;
|
|
34
|
+
};
|
|
35
|
+
/** boot 读回:本构建格式读回 `found`、别的格式号回 `formatMismatch`;缺席/坏字节/本格式坏形回 `undefined`(绝不抛 —— 留痕坏了不能挡启动)。 */
|
|
36
|
+
export declare function readExitLast(dataRoot: string): ExitLastReading | undefined;
|
|
21
37
|
/** 读回并报过之后即清(幂等,缺席零抛):在场 ⇔ **上一次**退出是自退。 */
|
|
22
38
|
export declare function clearExitLast(dataRoot: string): void;
|
|
23
39
|
export {};
|
package/dist/boot/exit-last.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { ENGINE_LANES } from "./engine-lease.js";
|
|
5
|
+
import { OWNER_ONLY_FILE_MODE } from "../plugins/owner-only-file-mode.js";
|
|
6
|
+
export const EXIT_LAST_FORMAT = 3;
|
|
4
7
|
const ExitLastSchema = z.object({
|
|
8
|
+
format: z.literal(EXIT_LAST_FORMAT),
|
|
5
9
|
at: z.string(),
|
|
6
10
|
version: z.string(),
|
|
7
11
|
pid: z.number(),
|
|
8
|
-
|
|
12
|
+
lane: z.enum(ENGINE_LANES),
|
|
9
13
|
reason: z.string(),
|
|
10
14
|
idleForMs: z.number(),
|
|
11
15
|
attached: z.number(),
|
|
@@ -18,19 +22,33 @@ export function exitLastPath(dataRoot) {
|
|
|
18
22
|
}
|
|
19
23
|
export function writeExitLast(dataRoot, info) {
|
|
20
24
|
try {
|
|
21
|
-
const body = { at: new Date().toISOString(), pid: process.pid, ...info };
|
|
22
|
-
writeFileSync(exitLastPath(dataRoot), JSON.stringify(body) + "\n");
|
|
25
|
+
const body = { format: EXIT_LAST_FORMAT, at: new Date().toISOString(), pid: process.pid, ...info };
|
|
26
|
+
writeFileSync(exitLastPath(dataRoot), JSON.stringify(body) + "\n", { mode: OWNER_ONLY_FILE_MODE });
|
|
23
27
|
}
|
|
24
28
|
catch {
|
|
25
29
|
}
|
|
26
30
|
}
|
|
31
|
+
function fileFormatOf(raw) {
|
|
32
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
33
|
+
return undefined;
|
|
34
|
+
if (!Object.hasOwn(raw, "format"))
|
|
35
|
+
return 1;
|
|
36
|
+
const f = raw.format;
|
|
37
|
+
return typeof f === "number" && Number.isSafeInteger(f) ? f : undefined;
|
|
38
|
+
}
|
|
27
39
|
export function readExitLast(dataRoot) {
|
|
28
40
|
try {
|
|
29
41
|
const p = exitLastPath(dataRoot);
|
|
30
42
|
if (!existsSync(p))
|
|
31
43
|
return undefined;
|
|
32
|
-
const
|
|
33
|
-
|
|
44
|
+
const raw = JSON.parse(readFileSync(p, "utf8"));
|
|
45
|
+
const fileFormat = fileFormatOf(raw);
|
|
46
|
+
if (fileFormat === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
if (fileFormat !== EXIT_LAST_FORMAT)
|
|
49
|
+
return { kind: "formatMismatch", fileFormat };
|
|
50
|
+
const parsed = ExitLastSchema.safeParse(raw);
|
|
51
|
+
return parsed.success ? { kind: "found", info: parsed.data } : undefined;
|
|
34
52
|
}
|
|
35
53
|
catch {
|
|
36
54
|
return undefined;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
*
|
|
49
49
|
* ## 件D 的边界(成文,别读成「数据会被删」)
|
|
50
50
|
*
|
|
51
|
-
* 三只被托管的 SQL 店(session / checkpoint / tool-result)的 `retention` 声明读一个事实 —— 留存扫车道开不开(`plugins/retention-
|
|
51
|
+
* 三只被托管的 SQL 店(session / checkpoint / tool-result)的 `retention` 声明读一个事实 —— 留存扫车道开不开(`plugins/retention-declaration.ts` 的
|
|
52
52
|
* `retentionSweepRuns`):开 ⇒ `managed`,关(缺省)⇒ `none`;local 形的店恒声明 `none`。删除的执行面是扫车道(`boot/retention-lane.ts`)与 SQL 店上的
|
|
53
53
|
* 执行器,不在本装配点。所以本装配点对件D 只做两件事:①把策略与执行器递给 core 的启动期校验
|
|
54
54
|
* (`assertRetentionCapability` —— 配对由引擎一个判官判:店声明 `managed` 而部署不跑执行器、执行器不是执行器,锁不锁都拒;锁着 + 店不能删 ⇒ 拒启,
|
|
@@ -83,7 +83,7 @@ export interface GovernanceSeamsCtx {
|
|
|
83
83
|
/**
|
|
84
84
|
* 交给引擎启动检查的留存执行器 —— 本部署跑扫车道 ⇒ 那只执行器(`backend.retention`),不跑 ⇒ `null`(必填:漏递即编译红,
|
|
85
85
|
* 引擎对 `undefined` 也拒启)。「店说 managed」与「有执行器」的配对由引擎一个判官判(引擎 7.58.0:锁不锁都判);
|
|
86
|
-
* 店的词与这一格读同一个事实(`retention-
|
|
86
|
+
* 店的词与这一格读同一个事实(`retention-declaration.ts` 的 `retentionSweepRuns`),本仓不再另判一遍。
|
|
87
87
|
*/
|
|
88
88
|
retentionExecutor: ManagedRetentionCapability | null;
|
|
89
89
|
}
|
package/dist/boot/leader.js
CHANGED
|
@@ -34,7 +34,7 @@ export function createLeaderFace(ctx) {
|
|
|
34
34
|
},
|
|
35
35
|
}
|
|
36
36
|
: {};
|
|
37
|
-
const leaderProvider = config.remoteExec
|
|
37
|
+
const leaderProvider = config.remoteExec.provider;
|
|
38
38
|
const leaderRunStore = ctx.backend?.leaderRun?.();
|
|
39
39
|
assertLeaderDurableStore(config.leaderEnabled, leaderRunStore !== undefined);
|
|
40
40
|
const minioGap = leaderK8sMinioGap(config.leaderEnabled, leaderProvider, "s3" in leaderMinio);
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* 这条链**结构上**走不通」——那句必须说出来。围栏根算不出来时**不说话**(判不了就闭嘴,别把猜测当告警)。
|
|
15
15
|
*
|
|
16
16
|
* 🔴 **已登记的判据限度(不在本批射程,别把它读成「判据已闭合」)**:② 号 warn 今天唯一算得出围栏根的
|
|
17
|
-
*
|
|
17
|
+
* 腿是无手的 `none` 形(`boot/stores.ts` 的 `containmentRoots`),而**恰恰是这条腿
|
|
18
18
|
* 没有文件工具** —— 亲读装的这台 core:`prepare-execution-env.js` 的
|
|
19
|
-
* `handsEnabled = ownedEnv !== undefined || deps.executionEnv !== undefined
|
|
19
|
+
* `handsEnabled = ownedEnv !== undefined || deps.executionEnv !== undefined`,`REMOTE_EXEC=none` 时
|
|
20
20
|
* `executionEnvFactory` 恒 `undefined` ⇒ `handsEnabled=false` ⇒ `prepareHandsMount` 整个不跑。所以这条
|
|
21
21
|
* warn 描述的失败形(「模型照提示词去 Write,拿回 `path_not_in_root`」)在该腿上并不成立:真相是**一只
|
|
22
22
|
* 文件工具都没有**,而按它给的第一条恢复路径(把根挪进 workspace)会让 warn 闭嘴却仍然写不成。
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
* `TaskSpec.memoryPersistenceCapable` 一条路进去(`boot/resolve-spec.ts` 直通),我方显式**不铸**受限会话、
|
|
55
55
|
* 也**不投**这个读面(硬造一个消费点 = 造给自己看的 wire 键)。哪天真要在诊断面露它,先有消费方需求。
|
|
56
56
|
*/
|
|
57
|
-
import { type ExecutionLane
|
|
57
|
+
import { type ExecutionLane } from "../execution-lane-caps.js";
|
|
58
58
|
import type { MemoryEngineBackend } from "@sema-agent/settings-schema/execution-lanes";
|
|
59
59
|
/** boot 期可知的全部事实。每一位都必须由调用点从真配置/真装配结果取,禁在本模块内重算(重算=第二真源)。 */
|
|
60
60
|
export interface MemoryWriteBoundaryFacts {
|
|
@@ -66,9 +66,9 @@ export interface MemoryWriteBoundaryFacts {
|
|
|
66
66
|
* core 7.16.0([ref])之后写家还要再深一层(`<平面>/<label>`),但 label 归引擎注册簿,boot 期说不出口;
|
|
67
67
|
* 平面是**包含关系上等价**的那一只(家恒为平面的直接子目录),所以判据停在平面,不猜 label。 */
|
|
68
68
|
memoryRoot: string | undefined;
|
|
69
|
-
/** 执行车道名,只进文案(
|
|
69
|
+
/** 执行车道名,只进文案(已合成配置上的车道词,直读)。 */
|
|
70
70
|
lane: ExecutionLane;
|
|
71
|
-
/** 该车道的路径是不是本机的文件(执行环境块 `hostLocalPaths
|
|
71
|
+
/** 该车道的路径是不是本机的文件(执行环境块 `hostLocalPaths`:`none` 的桩块 / `REMOTE_EXEC=host` 为真)。false = 沙箱 / 远端 / 设备盘,
|
|
72
72
|
* 与记忆根分平面 —— 引擎在这一形上不教 `# Memory` 写指令(除非部署声明 `memoryPersistenceCapable: true`),判的是同一键。 */
|
|
73
73
|
hostSemanticsLane: boolean;
|
|
74
74
|
/** 部署声明 `MEMORY_PERSISTENCE_CAPABLE`(三态)。两极都让本模块闭嘴,但理由不同 —— 见各臂注释。 */
|
|
@@ -84,16 +84,16 @@ export interface MemoryWriteBoundaryFacts {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* 审计的**车道三位**由本函数派生(boot/stores.ts 的装配点只调它,不就地手写):
|
|
87
|
-
* · `lane` ⇐
|
|
87
|
+
* · `lane` ⇐ 已合成配置上的车道词;
|
|
88
88
|
* · `hostSemanticsLane` ⇐ 执行环境块 `hostLocalPaths`(唯一作者 `capabilitiesFor`;引擎撤不撤写指令读的是同一键);
|
|
89
|
-
* · `containmentRoots` ⇐
|
|
89
|
+
* · `containmentRoots` ⇐ 只有无手车道(`none`)给得出(见下)。
|
|
90
90
|
* `processCwd` 由调用点传(stores 传 `process.cwd()`),本函数保持纯。
|
|
91
91
|
*/
|
|
92
92
|
export declare function buildMemoryBoundaryLaneFacts(config: {
|
|
93
|
-
readonly remoteExec
|
|
94
|
-
readonly provider:
|
|
93
|
+
readonly remoteExec: {
|
|
94
|
+
readonly provider: ExecutionLane;
|
|
95
95
|
readonly s3Snapshot?: unknown;
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
}, processCwd: string): Pick<MemoryWriteBoundaryFacts, "lane" | "hostSemanticsLane" | "containmentRoots">;
|
|
98
98
|
/** 一条启动告警:`tag` 进日志事件名(可被运维按名过滤/告警),`detail` 是给人读的整句(含恢复路径)。 */
|
|
99
99
|
export interface MemoryWriteBoundaryWarning {
|
|
@@ -106,7 +106,7 @@ export interface MemoryWriteBoundaryWarning {
|
|
|
106
106
|
* ① **路径不是本机的车道**(块 `hostLocalPaths` 为假:沙箱 / 远端 / 设备;记忆引擎在这里只可能因为 `MEMORY_ENGINE_REMOTE_LANE=allow`
|
|
107
107
|
* 或 DB 记忆面才在):引擎不教 `# Memory` 写指令(手带够不着本机的记忆根),官方恢复路径是声明 `memoryPersistenceCapable: true`。
|
|
108
108
|
* 未声明 ⇒ 点名 warn,把恢复旋钮写进句子里。
|
|
109
|
-
* ② **路径是本机的车道**(
|
|
109
|
+
* ② **路径是本机的车道**(none / host):记忆根不在任何一个已知围栏根内 ⇒ 模型被教着往一个 fs 工具够不到的路径写。
|
|
110
110
|
*
|
|
111
111
|
* 两极声明都让本模块闭嘴,但理由不同,别合并:
|
|
112
112
|
* · `true` = operator 自证有推断看不见的持久通道(共享挂载 / 自定义 writer),我们的结构判断本就不该
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import { capabilitiesFor
|
|
2
|
+
import { capabilitiesFor } from "../execution-lane-caps.js";
|
|
3
3
|
export function buildMemoryBoundaryLaneFacts(config, processCwd) {
|
|
4
|
-
const lane =
|
|
4
|
+
const lane = config.remoteExec.provider;
|
|
5
5
|
return {
|
|
6
6
|
lane,
|
|
7
7
|
hostSemanticsLane: capabilitiesFor(config).hostLocalPaths,
|
|
8
|
-
containmentRoots:
|
|
8
|
+
containmentRoots: capabilitiesFor(config).io ? [] : [processCwd],
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function isInside(child, root) {
|