@sema-agent/server 7.150.0 → 7.152.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 +451 -0
- package/README.md +15 -3
- package/README.zh-CN.md +10 -2
- package/USAGE.md +144 -87
- package/deploy/sema-up/README.md +11 -4
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
- package/deploy/sema-up/chart/templates/server.yaml +5 -3
- package/deploy/sema-up/chart/values-full-single.yaml +3 -1
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +7 -6
- package/deploy/sema-up/kube-up.sh +6 -6
- package/deploy/sema-up/lib/flagshape.sh +36 -8
- package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
- package/deploy/sema-up/lib/helm-values-kube.py +2 -0
- package/deploy/sema-up/machines.example.yaml +3 -1
- package/deploy/sema-up/sema-up.sh +22 -16
- package/dist/adoption/import.js +3 -3
- package/dist/approval-ask-audit-store.d.ts +1 -1
- package/dist/approval-ask-machine.d.ts +4 -10
- package/dist/approval-ask-retention.d.ts +1 -1
- package/dist/approval-card.d.ts +12 -14
- package/dist/approval-gate-currency.d.ts +9 -9
- package/dist/approval-gate-currency.js +3 -4
- package/dist/approval-hmac.d.ts +17 -1
- package/dist/approval-hmac.js +7 -1
- package/dist/approval-queue-kind.d.ts +1 -1
- package/dist/approval.d.ts +2 -2
- package/dist/approval.js +2 -2
- package/dist/auth-bridge.d.ts +20 -0
- package/dist/auth-bridge.js +9 -0
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.d.ts +4 -2
- package/dist/bind-host.d.ts +3 -6
- package/dist/bind-host.js +4 -7
- package/dist/boot/budget-tracing.js +1 -1
- package/dist/boot/coordinators.d.ts +1 -1
- package/dist/boot/coordinators.js +9 -10
- package/dist/boot/device-lane.js +2 -0
- package/dist/boot/engine-lease.d.ts +5 -0
- package/dist/boot/engine-lease.js +1 -0
- package/dist/boot/execution-env.d.ts +9 -14
- package/dist/boot/execution-env.js +85 -22
- package/dist/boot/execution-lane.js +32 -5
- package/dist/boot/late-binds.d.ts +8 -4
- package/dist/boot/late-binds.js +7 -1
- package/dist/boot/leader.d.ts +31 -30
- package/dist/boot/leader.js +38 -28
- package/dist/boot/leg-path-adjudication.d.ts +40 -0
- package/dist/boot/leg-path-adjudication.js +18 -0
- package/dist/boot/memory-consolidation.d.ts +3 -2
- package/dist/boot/memory-consolidation.js +6 -6
- package/dist/boot/parked-revive-gate.js +3 -15
- package/dist/boot/reapers.d.ts +6 -1
- package/dist/boot/reapers.js +13 -2
- package/dist/boot/resolve-spec.d.ts +3 -3
- package/dist/boot/resolve-spec.js +43 -48
- package/dist/boot/runner-deps.d.ts +46 -35
- package/dist/boot/runner-deps.js +94 -91
- package/dist/boot/session-age-out.d.ts +36 -0
- package/dist/boot/session-age-out.js +101 -0
- package/dist/boot/session-faces.d.ts +5 -14
- package/dist/boot/session-faces.js +9 -5
- package/dist/boot/shutdown.d.ts +6 -0
- package/dist/boot/shutdown.js +10 -4
- package/dist/boot/stage-01-config.js +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +4 -5
- package/dist/boot/stage-05-execution-env.d.ts +5 -3
- package/dist/boot/stage-05-execution-env.js +3 -2
- package/dist/boot/stage-06-runners.d.ts +9 -4
- package/dist/boot/stage-06-runners.js +24 -9
- package/dist/boot/stage-07-capability-layer.d.ts +8 -4
- package/dist/boot/stage-07-capability-layer.js +3 -2
- package/dist/boot/stage-08-reapers.d.ts +8 -4
- package/dist/boot/stage-08-reapers.js +4 -2
- package/dist/boot/stage-09-leader.d.ts +12 -5
- package/dist/boot/stage-09-leader.js +14 -5
- package/dist/boot/stage-10-http-server.d.ts +19 -5
- package/dist/boot/stage-10-http-server.js +14 -21
- package/dist/boot/stores.js +7 -4
- package/dist/boot/web-admin.js +5 -8
- package/dist/boot/workflow-orchestration.d.ts +7 -2
- package/dist/boot/workflow-orchestration.js +24 -7
- package/dist/bounded-rotation.d.ts +29 -0
- package/dist/bounded-rotation.js +24 -0
- package/dist/capabilities/approvals-push.d.ts +3 -3
- package/dist/capabilities/scenarios.d.ts +28 -13
- package/dist/capabilities/scenarios.js +2 -2
- package/dist/capability-facts.d.ts +43 -32
- package/dist/capability-facts.js +45 -51
- package/dist/card-rule-offers.d.ts +32 -0
- package/dist/card-rule-offers.js +130 -0
- package/dist/center-credential.d.ts +25 -6
- package/dist/center-credential.js +25 -5
- package/dist/config-catalog.d.ts +26 -7
- package/dist/config-catalog.js +26 -22
- package/dist/config-dir-trust.js +4 -2
- package/dist/config-invariants.d.ts +20 -8
- package/dist/config-invariants.js +55 -12
- package/dist/config-lkg.d.ts +5 -19
- package/dist/config-lkg.js +8 -62
- package/dist/config-provider.d.ts +1 -1
- package/dist/config-root-migration.d.ts +2 -2
- package/dist/config-types.d.ts +38 -42
- package/dist/config.d.ts +58 -7
- package/dist/config.js +90 -40
- package/dist/control-socket.d.ts +51 -0
- package/dist/control-socket.js +115 -0
- package/dist/deployment-governance.d.ts +2 -1
- package/dist/deployment-shape.d.ts +9 -1
- package/dist/deployment-shape.js +2 -1
- package/dist/device-protocol.d.ts +5 -4
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.d.ts +7 -0
- package/dist/device-ws-hub.js +10 -3
- package/dist/device-ws-protocol.d.ts +63 -10
- package/dist/device-ws-protocol.js +56 -25
- package/dist/elicitation.js +2 -2
- package/dist/engine-identity.d.ts +19 -7
- package/dist/engine-identity.js +10 -2
- package/dist/entry-mode-clamp-notice.d.ts +2 -1
- package/dist/entry-problems.d.ts +40 -3
- package/dist/entry-problems.js +3 -1
- package/dist/execution-env-refusal.d.ts +29 -0
- package/dist/execution-env-refusal.js +8 -0
- package/dist/execution-lane-caps.d.ts +3 -1
- package/dist/field-conflict.d.ts +1 -1
- package/dist/file-history-capture.d.ts +11 -4
- package/dist/file-history-capture.js +9 -6
- package/dist/file-history-disclosure.d.ts +7 -5
- package/dist/file-history-disclosure.js +7 -5
- package/dist/fleet/drain-entry.d.ts +4 -0
- package/dist/fleet/engine-signal.d.ts +12 -29
- package/dist/fleet/engine-signal.js +1 -7
- package/dist/fleet-client.js +2 -5
- package/dist/gate-settlement.d.ts +1 -8
- package/dist/gate-settlement.js +0 -4
- package/dist/history-anchor.js +1 -1
- package/dist/hitl-delivery.d.ts +2 -3
- package/dist/hitl-delivery.js +0 -2
- package/dist/hooks/hook-llm.js +4 -2
- package/dist/hooks/hook-runner.d.ts +3 -2
- package/dist/hooks/hook-runner.js +18 -3
- package/dist/host-decision.d.ts +11 -11
- package/dist/host-lsp-manager.d.ts +2 -2
- package/dist/http/active-run-conflict.d.ts +35 -2
- package/dist/http/active-run-conflict.js +48 -19
- package/dist/http/admission.js +17 -2
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +10 -7
- package/dist/http/checkpoint-ctx.d.ts +4 -0
- package/dist/http/checkpoint-ctx.js +2 -0
- package/dist/http/dispatch.d.ts +8 -3
- package/dist/http/dispatch.js +59 -32
- package/dist/http/durable-run-leg.js +16 -17
- package/dist/http/health-reader.d.ts +16 -9
- package/dist/http/health-reader.js +2 -1
- package/dist/http/health-self-report.d.ts +9 -1
- package/dist/http/health-self-report.js +3 -1
- package/dist/http/owner-access.d.ts +33 -14
- package/dist/http/owner-access.js +40 -10
- package/dist/http/principal-gate.d.ts +49 -21
- package/dist/http/principal-gate.js +61 -11
- package/dist/http/request-channel.d.ts +23 -0
- package/dist/http/request-channel.js +9 -0
- package/dist/http/request-guards.js +17 -2
- package/dist/http/resume-ctx-read.js +42 -3
- package/dist/http/resume-legs.d.ts +4 -3
- package/dist/http/resume-legs.js +367 -117
- package/dist/http/route-ctx.d.ts +91 -15
- package/dist/http/route-ctx.js +17 -0
- package/dist/http/route-table.d.ts +5 -1
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/admin-config-refresh.js +3 -3
- package/dist/http/routes/admin-drain.d.ts +3 -0
- package/dist/http/routes/admin-drain.js +7 -7
- package/dist/http/routes/admin-memory-optout.d.ts +1 -1
- package/dist/http/routes/admin-memory-optout.js +3 -3
- package/dist/http/routes/adoption.js +3 -5
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +2 -1
- package/dist/http/routes/approvals-assistant.js +99 -51
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/capabilities.d.ts +4 -0
- package/dist/http/routes/capabilities.js +38 -10
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/diagnostics.d.ts +3 -3
- package/dist/http/routes/diagnostics.js +19 -7
- package/dist/http/routes/fleet.js +10 -8
- package/dist/http/routes/images.js +10 -10
- package/dist/http/routes/memory-bundle.js +3 -3
- package/dist/http/routes/memory-compliance.js +3 -3
- package/dist/http/routes/memory-consolidation.js +2 -2
- package/dist/http/routes/memory-origin.js +3 -3
- package/dist/http/routes/memory-policy.js +2 -2
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/projects.d.ts +3 -2
- package/dist/http/routes/projects.js +4 -5
- package/dist/http/routes/retention-ops.js +3 -3
- package/dist/http/routes/rules.js +5 -5
- package/dist/http/routes/run-permission-mode.d.ts +2 -1
- package/dist/http/routes/run-permission-mode.js +2 -2
- package/dist/http/routes/runs.d.ts +4 -9
- package/dist/http/routes/runs.js +171 -65
- package/dist/http/routes/session-sync.d.ts +22 -9
- package/dist/http/routes/session-sync.js +204 -107
- package/dist/http/routes/sessions-list.js +13 -7
- package/dist/http/routes/sessions.js +30 -15
- package/dist/http/routes/tasks.js +46 -41
- package/dist/http/routes/trace-usage.js +2 -2
- package/dist/http/routes/workflows.js +1 -1
- package/dist/http/server.d.ts +30 -30
- package/dist/http/server.js +16 -4
- package/dist/http/submit-ctx.d.ts +1 -1
- package/dist/http/submit-ctx.js +7 -4
- package/dist/http/wire-types.d.ts +14 -4
- package/dist/human-facing-args.d.ts +33 -0
- package/dist/human-facing-args.js +33 -0
- package/dist/identity-source.d.ts +20 -3
- package/dist/identity-source.js +14 -0
- package/dist/index.d.ts +5 -1
- package/dist/k8s-api-credentials.d.ts +29 -0
- package/dist/k8s-api-credentials.js +25 -0
- package/dist/lane-home-probe.d.ts +3 -7
- package/dist/lane-home-probe.js +2 -2
- package/dist/leader/diffup.d.ts +19 -0
- package/dist/leader/diffup.js +7 -0
- package/dist/leader/leader.d.ts +116 -11
- package/dist/leader/leader.js +69 -5
- package/dist/leader/repair-wire.js +2 -2
- package/dist/leader/run-entry.d.ts +2 -1
- package/dist/leader/run-entry.js +1 -1
- package/dist/leader/wire.d.ts +42 -132
- package/dist/leader/wire.js +81 -67
- package/dist/leg-facts.d.ts +13 -5
- package/dist/leg-facts.js +2 -1
- package/dist/memory-scope.d.ts +23 -11
- package/dist/memory-scope.js +18 -6
- package/dist/memory-sync-client.d.ts +30 -2
- package/dist/memory-sync-client.js +16 -9
- package/dist/model-entry-headers.d.ts +9 -10
- package/dist/model-entry-headers.js +0 -4
- package/dist/model-entry-refusal.d.ts +7 -4
- package/dist/model-entry-refusal.js +11 -5
- package/dist/model-plane-face.d.ts +1 -1
- package/dist/model-plane-face.js +3 -1
- package/dist/model-route-endpoint.d.ts +13 -7
- package/dist/model-route-endpoint.js +14 -11
- package/dist/model-select.d.ts +22 -0
- package/dist/model-select.js +9 -0
- package/dist/model-unreachable-notice.d.ts +11 -0
- package/dist/model-unreachable-notice.js +4 -4
- package/dist/object-store-buckets.d.ts +640 -6
- package/dist/object-store-buckets.js +166 -0
- package/dist/observability/err-text.d.ts +7 -0
- package/dist/observability/err-text.js +5 -0
- package/dist/observability/fail-open.d.ts +25 -17
- package/dist/observability/fail-open.js +25 -17
- package/dist/observability/logger.js +3 -1
- package/dist/observability/metrics.js +1 -0
- package/dist/operator-roster.d.ts +68 -0
- package/dist/operator-roster.js +32 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
- package/dist/orchestration/workflow-notify-journal.js +12 -1
- package/dist/orchestration/workflow-park-decision.d.ts +70 -18
- package/dist/orchestration/workflow-park-decision.js +49 -10
- package/dist/orchestration/workflow-park-holder.d.ts +65 -0
- package/dist/orchestration/workflow-park-holder.js +98 -0
- package/dist/orchestration/workflow-record-fence.d.ts +36 -0
- package/dist/orchestration/workflow-record-fence.js +42 -0
- package/dist/outbound-dispatcher.d.ts +71 -8
- package/dist/outbound-dispatcher.js +48 -7
- package/dist/owner-faces.d.ts +2 -2
- package/dist/parked-decide.d.ts +106 -55
- package/dist/parked-decide.js +153 -117
- package/dist/peer-directory.d.ts +2 -2
- package/dist/peer-inbound-face.d.ts +2 -6
- package/dist/peer-inbound-face.js +0 -3
- package/dist/permission-mode-admission.d.ts +74 -5
- package/dist/permission-mode-admission.js +56 -3
- package/dist/plugins/adoption-log-sql.d.ts +3 -1
- package/dist/plugins/adoption-log-sql.js +7 -1
- package/dist/plugins/approval-ask-store-file.d.ts +14 -2
- package/dist/plugins/approval-ask-store-file.js +11 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +10 -1
- package/dist/plugins/approval-ask-store-memory.js +35 -10
- package/dist/plugins/approval-ask-store-sql.d.ts +69 -4
- package/dist/plugins/approval-ask-store-sql.js +45 -5
- package/dist/plugins/approval-exemption-store.js +3 -0
- package/dist/plugins/approval-nonce-store.js +2 -0
- package/dist/plugins/blob-backend.d.ts +83 -7
- package/dist/plugins/blob-backend.js +57 -6
- package/dist/plugins/breaker-state-sql.js +2 -0
- package/dist/plugins/caching-session-store.d.ts +9 -15
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/checkpoint-index-columns.d.ts +20 -16
- package/dist/plugins/checkpoint-index-columns.js +3 -6
- package/dist/plugins/checkpoint-store-face.d.ts +119 -61
- package/dist/plugins/checkpoint-store-face.js +134 -55
- package/dist/plugins/device-store-sql.js +6 -0
- package/dist/plugins/error-origin.d.ts +18 -0
- package/dist/plugins/error-origin.js +10 -0
- package/dist/plugins/execution-placement-sql.js +6 -6
- package/dist/plugins/image-bake-store-sql.js +6 -0
- package/dist/plugins/image-index-sql.js +4 -0
- package/dist/plugins/landed-attendants.d.ts +212 -0
- package/dist/plugins/landed-attendants.js +161 -0
- package/dist/plugins/leader-run-store-sql.js +4 -0
- package/dist/plugins/local-checkpoint-store.d.ts +13 -3
- package/dist/plugins/local-checkpoint-store.js +38 -49
- package/dist/plugins/local-session-live-reference.d.ts +40 -0
- package/dist/plugins/local-session-live-reference.js +39 -0
- package/dist/plugins/local-session-store.d.ts +71 -33
- package/dist/plugins/local-session-store.js +129 -27
- package/dist/plugins/memory-engine-pg.js +4 -0
- package/dist/plugins/memory-engine-sql-apply.js +5 -2
- package/dist/plugins/memory-engine-tidb.js +4 -0
- package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
- package/dist/plugins/memory-sync-store-pg.js +5 -0
- package/dist/plugins/memory-sync-store-tidb.js +5 -0
- package/dist/plugins/one-time-migrations.d.ts +104 -80
- package/dist/plugins/one-time-migrations.js +226 -132
- package/dist/plugins/org-delivery-quota-store.js +4 -1
- package/dist/plugins/outcome-ledger-sql.js +2 -0
- package/dist/plugins/permission-rule-store-sql.js +11 -4
- package/dist/plugins/pg-cost-quota.js +4 -0
- package/dist/plugins/pg-pool.js +35 -10
- package/dist/plugins/pg-rate-limiter.js +2 -0
- package/dist/plugins/posix-shell-fs.d.ts +6 -1
- package/dist/plugins/posix-shell-fs.js +4 -1
- package/dist/plugins/remote-env-adb.d.ts +19 -15
- package/dist/plugins/remote-env-adb.js +41 -15
- package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
- package/dist/plugins/remote-env-connect-seat.js +72 -0
- package/dist/plugins/remote-env-device.d.ts +22 -5
- package/dist/plugins/remote-env-device.js +106 -8
- package/dist/plugins/remote-env-e2b.d.ts +15 -6
- package/dist/plugins/remote-env-e2b.js +42 -32
- package/dist/plugins/remote-env-file-error.js +6 -2
- package/dist/plugins/remote-env-host.d.ts +46 -10
- package/dist/plugins/remote-env-host.js +124 -52
- package/dist/plugins/remote-env-k8s.d.ts +109 -41
- package/dist/plugins/remote-env-k8s.js +160 -54
- package/dist/plugins/remote-env-local-docker.d.ts +13 -8
- package/dist/plugins/remote-env-local-docker.js +34 -41
- package/dist/plugins/remote-env-ssh.d.ts +18 -12
- package/dist/plugins/remote-env-ssh.js +60 -59
- package/dist/plugins/remote-shell.d.ts +98 -1
- package/dist/plugins/remote-shell.js +218 -0
- package/dist/plugins/replica-registration.d.ts +1 -1
- package/dist/plugins/replica-registration.js +1 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
- package/dist/plugins/resume-anchor-store-sql.js +12 -5
- package/dist/plugins/retention-lane-store-sql.js +4 -0
- package/dist/plugins/retention-sql.d.ts +20 -2
- package/dist/plugins/retention-sql.js +11 -0
- package/dist/plugins/run-store-sql.d.ts +21 -2
- package/dist/plugins/run-store-sql.js +31 -7
- package/dist/plugins/s3-presign.d.ts +23 -0
- package/dist/plugins/s3-presign.js +37 -3
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
- package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
- package/dist/plugins/scheduler-support.d.ts +2 -2
- package/dist/plugins/scheduler-support.js +0 -3
- package/dist/plugins/schema-consistency.d.ts +4 -2
- package/dist/plugins/schema-consistency.js +19 -2
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-file-ledger.d.ts +2 -2
- package/dist/plugins/send-file-ledger.js +5 -2
- package/dist/plugins/send-user-file.d.ts +3 -4
- package/dist/plugins/send-user-file.js +56 -52
- package/dist/plugins/serving-requirement.d.ts +26 -7
- package/dist/plugins/serving-requirement.js +11 -4
- package/dist/plugins/session-birth.d.ts +6 -2
- package/dist/plugins/session-blob-claim-token.d.ts +15 -0
- package/dist/plugins/session-blob-claim-token.js +20 -0
- package/dist/plugins/session-blob-namespace.d.ts +46 -0
- package/dist/plugins/session-blob-namespace.js +116 -0
- package/dist/plugins/session-capture-record-store-sql.js +2 -0
- package/dist/plugins/session-ext-table.d.ts +14 -1
- package/dist/plugins/session-ext-table.js +5 -1
- package/dist/plugins/session-row-sql.d.ts +49 -2
- package/dist/plugins/session-row-sql.js +56 -13
- package/dist/plugins/session-store-sql.d.ts +34 -18
- package/dist/plugins/session-store-sql.js +98 -17
- package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
- package/dist/plugins/shared-memory-store-sql.js +6 -2
- package/dist/plugins/snapshot-bucket-presence.d.ts +25 -2
- package/dist/plugins/snapshot-bucket-presence.js +8 -2
- package/dist/plugins/sql-driver.d.ts +2 -1
- package/dist/plugins/sql-driver.js +18 -3
- package/dist/plugins/sql-errors.d.ts +11 -6
- package/dist/plugins/sql-errors.js +5 -6
- package/dist/plugins/sql-json-column.d.ts +1 -1
- package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
- package/dist/plugins/stop-then-start-sentence.js +14 -10
- package/dist/plugins/stop-then-start.d.ts +109 -0
- package/dist/plugins/stop-then-start.js +104 -0
- package/dist/plugins/store-backend.d.ts +84 -15
- package/dist/plugins/store-backend.js +236 -72
- package/dist/plugins/store-boundary.d.ts +57 -0
- package/dist/plugins/store-boundary.js +139 -0
- package/dist/plugins/store-contracts.d.ts +17 -0
- package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
- package/dist/plugins/store-fault-sentence-m53.js +25 -0
- package/dist/plugins/store-fault.d.ts +26 -7
- package/dist/plugins/store-fault.js +18 -2
- package/dist/plugins/task-attachment-store.d.ts +2 -1
- package/dist/plugins/task-attachment-store.js +14 -1
- package/dist/plugins/task-list-store-sql.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.js +10 -8
- package/dist/plugins/tidb-cost-quota.js +4 -0
- package/dist/plugins/tidb-pool.js +21 -25
- package/dist/plugins/tidb-rate-limiter.js +4 -0
- package/dist/plugins/user-input-ledger-sql.js +4 -0
- package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
- package/dist/plugins/workflow-run-store-sql.js +64 -4
- package/dist/plugins/workspace-custody.d.ts +4 -3
- package/dist/plugins/workspace-fill.d.ts +4 -7
- package/dist/plugins/workspace-fill.js +2 -1
- package/dist/plugins/write-behind-counter.js +5 -0
- package/dist/project-context.d.ts +0 -2
- package/dist/project-context.js +4 -8
- package/dist/project-registry.d.ts +46 -0
- package/dist/project-registry.js +44 -0
- package/dist/question.d.ts +2 -1
- package/dist/question.js +5 -13
- package/dist/request-form.d.ts +6 -1
- package/dist/request-form.js +4 -1
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +4 -0
- package/dist/request-value-closure.js +10 -0
- package/dist/rule-issue-reading.d.ts +1 -1
- package/dist/rules-consent.d.ts +1 -1
- package/dist/run-acceptance.d.ts +3 -2
- package/dist/run-acceptance.js +4 -6
- package/dist/run-local.js +9 -9
- package/dist/runs.d.ts +54 -16
- package/dist/runs.js +67 -13
- package/dist/runtime-governance.d.ts +5 -4
- package/dist/security.d.ts +30 -32
- package/dist/security.js +41 -7
- package/dist/sema-config-dir.d.ts +2 -1
- package/dist/server-secret-env.d.ts +12 -10
- package/dist/server-secret-env.js +24 -15
- package/dist/session-bindings.d.ts +82 -0
- package/dist/session-bindings.js +18 -0
- package/dist/session-children-retire.d.ts +2 -2
- package/dist/session-children-retire.js +2 -6
- package/dist/session-deletion.d.ts +16 -1
- package/dist/session-error-wire.d.ts +3 -3
- package/dist/session-error-wire.js +3 -3
- package/dist/session-incarnation.d.ts +10 -0
- package/dist/session-incarnation.js +10 -1
- package/dist/session-kind.d.ts +57 -0
- package/dist/session-kind.js +22 -0
- package/dist/session-row.d.ts +21 -1
- package/dist/session-row.js +7 -1
- package/dist/session-sync-kernel.d.ts +24 -14
- package/dist/session-sync-kernel.js +3 -6
- package/dist/session-sync.d.ts +25 -103
- package/dist/session-sync.js +14 -76
- package/dist/session-titler.d.ts +10 -3
- package/dist/session-titler.js +19 -6
- package/dist/ssh-host-key.d.ts +5 -0
- package/dist/ssh-host-key.js +3 -0
- package/dist/stores-sql/blob-index-sql.d.ts +30 -9
- package/dist/stores-sql/blob-index-sql.js +40 -21
- package/dist/stores-sql/checkpoint-store-sql.d.ts +54 -27
- package/dist/stores-sql/checkpoint-store-sql.js +70 -146
- package/dist/stores-sql/file-history-store-sql.d.ts +113 -15
- package/dist/stores-sql/file-history-store-sql.js +205 -95
- package/dist/stores-sql/pg-session-storage.d.ts +34 -7
- package/dist/stores-sql/pg-session-storage.js +37 -13
- package/dist/stores-sql/retention-store-sql.d.ts +1 -9
- package/dist/stores-sql/retention-store-sql.js +5 -19
- package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
- package/dist/stores-sql/session-policy-store-sql.js +61 -44
- package/dist/stores-sql/session-write-hooks.d.ts +11 -0
- package/dist/stores-sql/tidb-session-store.d.ts +58 -7
- package/dist/stores-sql/tidb-session-store.js +37 -13
- package/dist/submission-exit.d.ts +3 -2
- package/dist/submission-exit.js +9 -1
- package/dist/task-cwd.d.ts +2 -2
- package/dist/task-settings.d.ts +7 -5
- package/dist/task-settings.js +3 -3
- package/dist/terminal.d.ts +33 -2
- package/dist/terminal.js +139 -9
- package/dist/tool-approval.d.ts +465 -507
- package/dist/tool-approval.js +606 -1222
- package/dist/trace/core-keyset-guard.d.ts +1 -1
- package/dist/trace/ledger-events.d.ts +3 -3
- package/dist/trace/project.d.ts +2 -3
- package/dist/trace/redact.js +3 -2
- package/dist/trace/self-minted-wire.d.ts +571 -178
- package/dist/trace/self-minted-wire.js +189 -56
- package/dist/web-admin-client/apply-effective.js +2 -2
- package/dist/web-admin-client/read-warnings.d.ts +2 -2
- package/dist/web-admin-client/read-warnings.js +1 -1
- package/dist/web-admin-client/types.d.ts +1 -1
- package/dist/workspace-space.d.ts +10 -4
- package/dist/workspace-space.js +4 -1
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +79 -28
- package/package.json +7 -3
- package/scripts/embed-minimal.mjs +3 -3
- package/wire-changes/server@7.151.0.json +762 -0
- package/wire-changes/server@7.152.0.json +900 -0
- package/dist/config-d-migration.d.ts +0 -37
- package/dist/config-d-migration.js +0 -60
- package/dist/http/session-inherit-env.d.ts +0 -36
- package/dist/http/session-inherit-env.js +0 -6
package/dist/boot/runner-deps.js
CHANGED
|
@@ -65,10 +65,6 @@ export function createEngineNoticeForwarder(logger, router = defaultEngineNotice
|
|
|
65
65
|
export function installDefaultEngineNoticeSeat(logger, metrics) {
|
|
66
66
|
setDefaultEngineNoticeSeat(createEngineNoticeForwarder(logger, defaultEngineNoticeRouter, metrics));
|
|
67
67
|
}
|
|
68
|
-
export function createEngineNoticeSeat(logger, router = defaultEngineNoticeRouter) {
|
|
69
|
-
const warn = logger?.warn?.bind(logger);
|
|
70
|
-
return warn ? { onNotice: createEngineNoticeForwarder({ warn }, router) } : {};
|
|
71
|
-
}
|
|
72
68
|
export const CROSS_BOUNDARY_POSTURE_REQUIRES_PRINCIPAL = { multi_tenant: true, single_user: false };
|
|
73
69
|
export function crossBoundaryPostureOf(requirePrincipal) {
|
|
74
70
|
for (const w of Object.keys(CROSS_BOUNDARY_POSTURE_REQUIRES_PRINCIPAL)) {
|
|
@@ -111,9 +107,8 @@ export function announceReadDenyRows(config, logger) {
|
|
|
111
107
|
announcedReadDenyRows.set(config, key);
|
|
112
108
|
auditReadDenyAnchoring({ rows: config.readDenyPatterns, logger });
|
|
113
109
|
}
|
|
114
|
-
export function
|
|
115
|
-
|
|
116
|
-
const shared = {
|
|
110
|
+
export function createDeploymentPlaneDeps(ctx, lane) {
|
|
111
|
+
const plane = {
|
|
117
112
|
brain: ctx.brain,
|
|
118
113
|
onNotice: createEngineNoticeForwarder(ctx.logger, defaultEngineNoticeRouter, ctx.metrics),
|
|
119
114
|
tiers: ctx.config.tiers,
|
|
@@ -123,28 +118,37 @@ export function createSharedRunnerDeps(ctx) {
|
|
|
123
118
|
tracer: ctx.tracer,
|
|
124
119
|
promptSource: ctx.promptSource,
|
|
125
120
|
...buildDeploymentPostureSeats(ctx.config),
|
|
121
|
+
mods: ctx.deploymentMods,
|
|
122
|
+
hands: buildHandsBand(ctx.config, lane.commitCoAuthor),
|
|
123
|
+
usageWindows: ctx.config.usageWindows ? ctx.config.usageWindows : undefined,
|
|
124
|
+
usageWindowStore: ctx.usageWindowStore ? ctx.usageWindowStore : undefined,
|
|
125
|
+
memoryEngineDir: ctx.engineDataRoot,
|
|
126
|
+
compliancePostureResolver: ctx.governanceSeams.compliancePostureResolver,
|
|
127
|
+
lockedConfig: ctx.governanceSeams.lockedConfig,
|
|
128
|
+
retentionPolicy: ctx.governanceSeams.retentionPolicy,
|
|
129
|
+
mcpRevocations: ctx.mcpRevocations ? ctx.mcpRevocations : undefined,
|
|
130
|
+
runtimeCapsResolver: ctx.runtimeCapsResolver ? ctx.runtimeCapsResolver : undefined,
|
|
131
|
+
onError: ctx.onError,
|
|
132
|
+
};
|
|
133
|
+
return plane;
|
|
134
|
+
}
|
|
135
|
+
export function createSharedRunnerDeps(ctx) {
|
|
136
|
+
announceReadDenyRows(ctx.config, ctx.logger);
|
|
137
|
+
const shared = {
|
|
138
|
+
...createDeploymentPlaneDeps(ctx, { commitCoAuthor: ctx.commitCoAuthor }),
|
|
126
139
|
executionEnvFactory: ctx.executionEnvFactory ? ctx.executionEnvFactory : undefined,
|
|
127
140
|
lspManager: ctx.lspManager ? ctx.lspManager : undefined,
|
|
128
141
|
backgroundAgentStore: ctx.backgroundAgentStore ? ctx.backgroundAgentStore : undefined,
|
|
129
142
|
mailboxStore: ctx.mailboxStore ? ctx.mailboxStore : undefined,
|
|
130
143
|
rosterStore: ctx.rosterStore ? ctx.rosterStore : undefined,
|
|
131
|
-
mods: ctx.deploymentMods,
|
|
132
|
-
hands: buildHandsBand(ctx.config, ctx.commitCoAuthor),
|
|
133
144
|
toolResultStore: ctx.toolResultStore,
|
|
134
145
|
checkpointStore: ctx.checkpointStore ? ctx.checkpointStore : undefined,
|
|
135
146
|
fileHistoryStore: ctx.fileHistoryStore ? ctx.fileHistoryStore : undefined,
|
|
136
|
-
fileHistoryCapture: coreFileHistoryCaptureSeat(ctx.fileHistoryStore, ctx.config.fileHistoryCapture),
|
|
147
|
+
fileHistoryCapture: coreFileHistoryCaptureSeat(ctx.fileHistoryStore !== undefined, ctx.config.fileHistoryCapture),
|
|
137
148
|
sessionPolicyStore: ctx.sessionPolicyStore ? ctx.sessionPolicyStore : undefined,
|
|
138
149
|
memoryScopeAdmission: ctx.orgMemoryAdmission.memoryScopeAdmission ? ctx.orgMemoryAdmission.memoryScopeAdmission : undefined,
|
|
139
150
|
deploymentMemoryScopes: ctx.orgMemoryAdmission.deploymentMemoryScopes && ctx.orgMemoryAdmission.deploymentMemoryScopes.length > 0 ? ctx.orgMemoryAdmission.deploymentMemoryScopes : undefined,
|
|
140
|
-
usageWindows: ctx.config.usageWindows ? ctx.config.usageWindows : undefined,
|
|
141
|
-
usageWindowStore: ctx.usageWindowStore ? ctx.usageWindowStore : undefined,
|
|
142
151
|
sharedMemoryStores: ctx.sharedMemoryStores ? ctx.sharedMemoryStores : undefined,
|
|
143
|
-
memoryEngineDir: ctx.engineDataRoot,
|
|
144
|
-
compliancePostureResolver: ctx.governanceSeams.compliancePostureResolver,
|
|
145
|
-
lockedConfig: ctx.governanceSeams.lockedConfig,
|
|
146
|
-
retentionPolicy: ctx.governanceSeams.retentionPolicy,
|
|
147
|
-
mcpRevocations: ctx.mcpRevocations ? ctx.mcpRevocations : undefined,
|
|
148
152
|
peerSeat: ctx.peerDesk.seat,
|
|
149
153
|
};
|
|
150
154
|
return shared;
|
|
@@ -153,10 +157,81 @@ export function localOwnerRulesDeclared(config, permissionRuleStore) {
|
|
|
153
157
|
return permissionRuleStore !== undefined && !DEPLOYMENT_SHAPE_PREDICATES.multiTenant.holds(config);
|
|
154
158
|
}
|
|
155
159
|
export function createRunnerDeps(ctx) {
|
|
156
|
-
const { config, logger, metrics, localRoot, outcomeSink, elicitation, question, toolApproval, sessionStore, memoryEngine, sessionCaptureRecords, memorySyncRunner,
|
|
160
|
+
const { config, logger, metrics, localRoot, outcomeSink, elicitation, question, toolApproval, sessionStore, memoryEngine, sessionCaptureRecords, memorySyncRunner, permissionRuleStore, fleetBus, workflowRunStore, workflowJournalStore, workflowAgentRegistry, workflowNotifyGate, deliverWorkflowCompletion, } = ctx;
|
|
157
161
|
const peerSessionLister = sessionStore.listSessionRows?.bind(sessionStore);
|
|
158
162
|
const memoryEngineIncident = createMemoryEngineIncidentSink({ logger, metrics });
|
|
159
|
-
const
|
|
163
|
+
const onError = (err, ctx) => {
|
|
164
|
+
const codeField = codeFieldOf(err);
|
|
165
|
+
if (ctx.phase === "degraded") {
|
|
166
|
+
logger.warn("task_degraded", { sessionId: ctx.sessionId, ...codeField, info: seatText("operator-log-text", String(err)) });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (ctx.phase === "prompt-constitution") {
|
|
170
|
+
logger.warn("prompt_composition_warning", { sessionId: ctx.sessionId, ...codeField, info: seatText("operator-log-text", String(err)) });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (ctx.phase === "rewind") {
|
|
174
|
+
const code = rewindFailureCode(err);
|
|
175
|
+
logger.warn("rewind_snapshot_failed", { sessionId: ctx.sessionId, code, info: seatText("operator-log-text", String(err)) });
|
|
176
|
+
metrics.inc("rewind_snapshot_failed_total", { code });
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (ctx.phase === "memory") {
|
|
180
|
+
memoryEngineIncident(err, ctx.sessionId !== undefined ? { sessionId: ctx.sessionId } : undefined);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (ctx.phase === "mcp") {
|
|
184
|
+
logger.warn("mcp_server_unavailable", { sessionId: ctx.sessionId, kind: errorKindOf(err), ...codeField, info: seatText("operator-log-text", buildShownUrlsInText(String(err))) });
|
|
185
|
+
metrics.inc("mcp_server_unavailable_total");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (ctx.phase === "a2a") {
|
|
189
|
+
logger.warn("a2a_peer_unavailable", { sessionId: ctx.sessionId, kind: errorKindOf(err), ...codeField, info: seatText("operator-log-text", buildShownUrlsInText(String(err))) });
|
|
190
|
+
metrics.inc("a2a_peer_unavailable_total");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (ctx.phase === "prompt-cache") {
|
|
194
|
+
const classification = ctx.classification;
|
|
195
|
+
const causeLevel = classification === undefined ? undefined : PROMPT_CACHE_BREAK_LEVELS.get(classification);
|
|
196
|
+
const level = classification === undefined ? "warn" : (causeLevel ?? "error");
|
|
197
|
+
const fields = {
|
|
198
|
+
sessionId: ctx.sessionId,
|
|
199
|
+
confirmed: classification !== undefined,
|
|
200
|
+
...(classification !== undefined ? { classification, classificationKnown: causeLevel !== undefined } : {}),
|
|
201
|
+
...codeField,
|
|
202
|
+
err: seatText("operator-log-text", String(err)),
|
|
203
|
+
};
|
|
204
|
+
metrics.inc("prompt_cache_low_hit_total", {
|
|
205
|
+
...(classification !== undefined ? { classification: causeLevel !== undefined ? classification : "unknown" } : {}),
|
|
206
|
+
level,
|
|
207
|
+
});
|
|
208
|
+
if (level === "warn")
|
|
209
|
+
logger.warn("prompt_cache_break", fields);
|
|
210
|
+
else
|
|
211
|
+
logger.error("prompt_cache_break", fields);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (ctx.phase === "config") {
|
|
215
|
+
const classification = ctx.classification;
|
|
216
|
+
const classificationKnown = classification === undefined ? undefined : CONFIG_ADVISORY_CLASSIFICATIONS.has(classification);
|
|
217
|
+
const fields = {
|
|
218
|
+
sessionId: ctx.sessionId,
|
|
219
|
+
...codeField,
|
|
220
|
+
...(classification !== undefined ? { classification, classificationKnown } : {}),
|
|
221
|
+
info: seatText("operator-log-text", String(err)),
|
|
222
|
+
};
|
|
223
|
+
logger.warn("runner_config_advisory", fields);
|
|
224
|
+
metrics.inc("runner_config_advisory_total", {
|
|
225
|
+
...codeField,
|
|
226
|
+
...(classification !== undefined ? { classification: classificationKnown ? classification : "unknown" } : {}),
|
|
227
|
+
level: "warn",
|
|
228
|
+
});
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
metrics.inc("runner_error_total", { phase: ctx.phase });
|
|
232
|
+
logger.error("runner_error", { phase: ctx.phase, sessionId: ctx.sessionId, ...codeField, err: seatText("operator-log-text", String(err)) });
|
|
233
|
+
};
|
|
234
|
+
const sharedRunnerDeps = createSharedRunnerDeps({ ...ctx, onError });
|
|
160
235
|
const workflowModelAllowlist = workflowModelAllowlistFor(config);
|
|
161
236
|
const selfOrchestrationDeps = config.selfOrchestrationEnabled
|
|
162
237
|
? {
|
|
@@ -237,7 +312,6 @@ export function createRunnerDeps(ctx) {
|
|
|
237
312
|
memorySyncRunner.trigger("harvest");
|
|
238
313
|
}
|
|
239
314
|
: undefined,
|
|
240
|
-
runtimeCapsResolver: runtimeCapsResolver ? runtimeCapsResolver : undefined,
|
|
241
315
|
permissionRuleStore: permissionRuleStore ? permissionRuleStore : undefined,
|
|
242
316
|
localOwnerRules: localOwnerRulesDeclared(config, permissionRuleStore),
|
|
243
317
|
onBackgroundChildEvent: fleetBackgroundChildPublisher(fleetBus, (msg, fields) => logger.info(msg, fields)),
|
|
@@ -248,77 +322,6 @@ export function createRunnerDeps(ctx) {
|
|
|
248
322
|
? makeProbeInstructionSources()
|
|
249
323
|
: undefined,
|
|
250
324
|
...selfOrchestrationDeps,
|
|
251
|
-
onError: (err, ctx) => {
|
|
252
|
-
const codeField = codeFieldOf(err);
|
|
253
|
-
if (ctx.phase === "degraded") {
|
|
254
|
-
logger.warn("task_degraded", { sessionId: ctx.sessionId, ...codeField, info: seatText("operator-log-text", String(err)) });
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (ctx.phase === "prompt-constitution") {
|
|
258
|
-
logger.warn("prompt_composition_warning", { sessionId: ctx.sessionId, ...codeField, info: seatText("operator-log-text", String(err)) });
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
if (ctx.phase === "rewind") {
|
|
262
|
-
const code = rewindFailureCode(err);
|
|
263
|
-
logger.warn("rewind_snapshot_failed", { sessionId: ctx.sessionId, code, info: seatText("operator-log-text", String(err)) });
|
|
264
|
-
metrics.inc("rewind_snapshot_failed_total", { code });
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (ctx.phase === "memory") {
|
|
268
|
-
memoryEngineIncident(err, ctx.sessionId !== undefined ? { sessionId: ctx.sessionId } : undefined);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (ctx.phase === "mcp") {
|
|
272
|
-
logger.warn("mcp_server_unavailable", { sessionId: ctx.sessionId, kind: errorKindOf(err), ...codeField, info: seatText("operator-log-text", buildShownUrlsInText(String(err))) });
|
|
273
|
-
metrics.inc("mcp_server_unavailable_total");
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (ctx.phase === "a2a") {
|
|
277
|
-
logger.warn("a2a_peer_unavailable", { sessionId: ctx.sessionId, kind: errorKindOf(err), ...codeField, info: seatText("operator-log-text", buildShownUrlsInText(String(err))) });
|
|
278
|
-
metrics.inc("a2a_peer_unavailable_total");
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (ctx.phase === "prompt-cache") {
|
|
282
|
-
const classification = ctx.classification;
|
|
283
|
-
const causeLevel = classification === undefined ? undefined : PROMPT_CACHE_BREAK_LEVELS.get(classification);
|
|
284
|
-
const level = classification === undefined ? "warn" : (causeLevel ?? "error");
|
|
285
|
-
const fields = {
|
|
286
|
-
sessionId: ctx.sessionId,
|
|
287
|
-
confirmed: classification !== undefined,
|
|
288
|
-
...(classification !== undefined ? { classification, classificationKnown: causeLevel !== undefined } : {}),
|
|
289
|
-
...codeField,
|
|
290
|
-
err: seatText("operator-log-text", String(err)),
|
|
291
|
-
};
|
|
292
|
-
metrics.inc("prompt_cache_low_hit_total", {
|
|
293
|
-
...(classification !== undefined ? { classification: causeLevel !== undefined ? classification : "unknown" } : {}),
|
|
294
|
-
level,
|
|
295
|
-
});
|
|
296
|
-
if (level === "warn")
|
|
297
|
-
logger.warn("prompt_cache_break", fields);
|
|
298
|
-
else
|
|
299
|
-
logger.error("prompt_cache_break", fields);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (ctx.phase === "config") {
|
|
303
|
-
const classification = ctx.classification;
|
|
304
|
-
const classificationKnown = classification === undefined ? undefined : CONFIG_ADVISORY_CLASSIFICATIONS.has(classification);
|
|
305
|
-
const fields = {
|
|
306
|
-
sessionId: ctx.sessionId,
|
|
307
|
-
...codeField,
|
|
308
|
-
...(classification !== undefined ? { classification, classificationKnown } : {}),
|
|
309
|
-
info: seatText("operator-log-text", String(err)),
|
|
310
|
-
};
|
|
311
|
-
logger.warn("runner_config_advisory", fields);
|
|
312
|
-
metrics.inc("runner_config_advisory_total", {
|
|
313
|
-
...codeField,
|
|
314
|
-
...(classification !== undefined ? { classification: classificationKnown ? classification : "unknown" } : {}),
|
|
315
|
-
level: "warn",
|
|
316
|
-
});
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
metrics.inc("runner_error_total", { phase: ctx.phase });
|
|
320
|
-
logger.error("runner_error", { phase: ctx.phase, sessionId: ctx.sessionId, ...codeField, err: seatText("operator-log-text", String(err)) });
|
|
321
|
-
},
|
|
322
325
|
...(ctx.consolidationSeat !== undefined
|
|
323
326
|
? {
|
|
324
327
|
memoryConsolidation: {},
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SessionAgeOutExpectation, SessionPurgeOutcome } from "../session-deletion.js";
|
|
2
|
+
import type { OwnerAwareSessionStore } from "../security.js";
|
|
3
|
+
import type { Logger } from "../observability/logger.js";
|
|
4
|
+
import type { Metrics } from "../observability/metrics.js";
|
|
5
|
+
/** 每拍至多碰这么多只(一拍的删除量有上界:维护拍上其余各腿不被本腿拖住)。 */
|
|
6
|
+
export declare const SESSION_AGE_OUT_CAP = 64;
|
|
7
|
+
/** 每拍的时间预算(同上一句的理由)。 */
|
|
8
|
+
export declare const SESSION_AGE_OUT_BUDGET_MS = 5000;
|
|
9
|
+
/** 跳过的理由(闭集;计数的标签):条件在锁里不再成立 / 围栏判到认领 / 子代预检拒 / 另一次删除持有它 / 抛。 */
|
|
10
|
+
export type SessionAgeOutSkip = "changed" | "active" | "children_alive" | "in_progress" | "failed";
|
|
11
|
+
/** 一拍的读数(调用方记日志;钉读它)。 */
|
|
12
|
+
export interface SessionAgeOutReading {
|
|
13
|
+
readonly deleted: number;
|
|
14
|
+
readonly skipped: Readonly<Record<SessionAgeOutSkip, number>>;
|
|
15
|
+
/** 本拍因帽或预算停下而候选还没看完。 */
|
|
16
|
+
readonly truncated: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionAgeOutDeps {
|
|
19
|
+
readonly store: Required<Pick<OwnerAwareSessionStore, "listIdleOfKind">>;
|
|
20
|
+
readonly purge: (sessionId: string, owner: string | null, opts: {
|
|
21
|
+
readonly ageOut: SessionAgeOutExpectation;
|
|
22
|
+
}) => Promise<SessionPurgeOutcome>;
|
|
23
|
+
/** 视界(`BG_AGENT_RETENTION_MS`;每拍现读 —— 热改下一拍生效)。 */
|
|
24
|
+
readonly retentionMs: () => number;
|
|
25
|
+
readonly logger: Pick<Logger, "info" | "warn">;
|
|
26
|
+
readonly metrics: Pick<Metrics, "inc">;
|
|
27
|
+
readonly now?: () => number;
|
|
28
|
+
readonly cap?: number;
|
|
29
|
+
readonly budgetMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 铸老化腿(一只闭包,带进程内的跨拍轮转起点与在飞守卫):每次调用跑一拍,交回读数;在飞时再调 ⇒ 立刻交回空读数(不叠拍)。
|
|
33
|
+
* 候选读抛 ⇒ 本拍停在那里(读数照交,下拍从同一起点再来);单行删除抛 ⇒ 计 `failed`、节流 warn,本拍继续下一行。
|
|
34
|
+
*/
|
|
35
|
+
export declare function createSessionAgeOut(deps: SessionAgeOutDeps): () => Promise<SessionAgeOutReading>;
|
|
36
|
+
//# sourceMappingURL=session-age-out.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { SESSION_KINDS, idleSessionAfter } from "../session-kind.js";
|
|
2
|
+
import { seatText } from "../trace/exit-seat.js";
|
|
3
|
+
export const SESSION_AGE_OUT_CAP = 64;
|
|
4
|
+
export const SESSION_AGE_OUT_BUDGET_MS = 5_000;
|
|
5
|
+
function outcomeOf(outcome) {
|
|
6
|
+
if ("deleted" in outcome)
|
|
7
|
+
return outcome.deleted ? "deleted" : "changed";
|
|
8
|
+
if ("active" in outcome)
|
|
9
|
+
return "active";
|
|
10
|
+
if ("childrenAlive" in outcome)
|
|
11
|
+
return "children_alive";
|
|
12
|
+
if ("inProgress" in outcome)
|
|
13
|
+
return "in_progress";
|
|
14
|
+
const unknownOutcome = outcome;
|
|
15
|
+
throw new Error(`session age-out: no arm for purge outcome ${JSON.stringify(unknownOutcome)}`);
|
|
16
|
+
}
|
|
17
|
+
export function createSessionAgeOut(deps) {
|
|
18
|
+
const cap = deps.cap ?? SESSION_AGE_OUT_CAP;
|
|
19
|
+
const budgetMs = deps.budgetMs ?? SESSION_AGE_OUT_BUDGET_MS;
|
|
20
|
+
const now = deps.now ?? Date.now;
|
|
21
|
+
const resumeAfter = new Map();
|
|
22
|
+
let inFlight = false;
|
|
23
|
+
const empty = () => ({ changed: 0, active: 0, children_alive: 0, in_progress: 0, failed: 0 });
|
|
24
|
+
return async () => {
|
|
25
|
+
if (inFlight)
|
|
26
|
+
return { deleted: 0, skipped: empty(), truncated: false };
|
|
27
|
+
inFlight = true;
|
|
28
|
+
const started = now();
|
|
29
|
+
const skipped = empty();
|
|
30
|
+
let deleted = 0;
|
|
31
|
+
let touched = 0;
|
|
32
|
+
let truncated = false;
|
|
33
|
+
try {
|
|
34
|
+
for (const kind of SESSION_KINDS) {
|
|
35
|
+
const idleBefore = new Date(now() - deps.retentionMs());
|
|
36
|
+
const origin = resumeAfter.get(kind);
|
|
37
|
+
let after = origin;
|
|
38
|
+
let wrapped = origin === undefined;
|
|
39
|
+
let circled = false;
|
|
40
|
+
for (;;) {
|
|
41
|
+
if (touched >= cap || (touched > 0 && now() - started >= budgetMs)) {
|
|
42
|
+
truncated = true;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
const page = await deps.store.listIdleOfKind(kind, idleBefore, { ...(after !== undefined ? { after } : {}), limit: cap - touched });
|
|
46
|
+
if (page.length === 0) {
|
|
47
|
+
if (wrapped) {
|
|
48
|
+
resumeAfter.delete(kind);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
wrapped = true;
|
|
52
|
+
after = undefined;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
for (const row of page) {
|
|
56
|
+
if (wrapped && origin !== undefined && !idleSessionAfter(origin, row)) {
|
|
57
|
+
circled = true;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (touched >= cap || (touched > 0 && now() - started >= budgetMs)) {
|
|
61
|
+
truncated = true;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
touched++;
|
|
65
|
+
after = { lastActivityAt: row.lastActivityAt, sessionId: row.sessionId };
|
|
66
|
+
resumeAfter.set(kind, after);
|
|
67
|
+
let verdict;
|
|
68
|
+
try {
|
|
69
|
+
verdict = outcomeOf(await deps.purge(row.sessionId, row.owner, { ageOut: { incarnation: row.incarnation, kind, idleBefore } }));
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
verdict = "failed";
|
|
73
|
+
deps.logger.warn("session_age_out_failed", { sessionId: row.sessionId, err: seatText("operator-log-text", String(err)), effect: "the session stays; the next maintenance tick judges it again" });
|
|
74
|
+
}
|
|
75
|
+
if (verdict === "deleted") {
|
|
76
|
+
deleted++;
|
|
77
|
+
deps.metrics.inc("sidechain_sessions_aged_out_total", {}, 1);
|
|
78
|
+
deps.logger.info("session_aged_out", { sessionId: row.sessionId, sessionKind: kind, lastActivityAt: row.lastActivityAt });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
skipped[verdict]++;
|
|
82
|
+
deps.metrics.inc("sidechain_age_out_skipped_total", { reason: verdict }, 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (truncated || circled)
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (truncated)
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
inFlight = false;
|
|
94
|
+
}
|
|
95
|
+
if (deleted > 0 || truncated || Object.values(skipped).some((n) => n > 0)) {
|
|
96
|
+
deps.logger.info("reaper_swept", { metric: "sidechain_sessions_aged_out_total", count: deleted, skipped, truncated });
|
|
97
|
+
}
|
|
98
|
+
return { deleted, skipped, truncated };
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=session-age-out.js.map
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [ref] A10:composition root 分段 —— session 只读/删除面(审计、watch 注册表、E21 purge 协调器、
|
|
3
|
-
* degenerate 仪表、plan-cache 探针)。
|
|
4
|
-
*
|
|
5
|
-
* 纯搬运:函数体逐字来自 `main.ts`(原 2967-3092 行),缩进不变;新增的只有 import 与包壳。
|
|
6
|
-
*
|
|
7
|
-
* ⚠️ **位置即契约**:
|
|
8
|
-
* 1. `sessionWatchRegistry` 必须在 `purgeSession` **之前**构造 —— purge 尾部的 `dropSession` 是
|
|
9
|
-
* 同副本租户轮转围栏(delete 即终结旧 owner 的 SSE 订阅),两者是一对;空间回收座在它**之后**起、且不在应答路径里。
|
|
10
|
-
* 2. `setLeafAdvanceListener(...)` 是**进程级单点**装载(leaf-bus 只有一个监听位),必须与
|
|
11
|
-
* registry 的构造同段发生,晚于它、早于任何会 append 的路由。
|
|
12
|
-
*/
|
|
13
1
|
import { type SessionAuditReadOpts } from "../audit.js";
|
|
14
2
|
import type { ServiceConfig } from "../config.js";
|
|
15
3
|
import type { Logger } from "../observability/logger.js";
|
|
@@ -25,7 +13,7 @@ import { SessionWatchRegistry } from "../session-watch.js";
|
|
|
25
13
|
import type { TaskListLane } from "./task-list-lane.js";
|
|
26
14
|
import { type RunnerDeps } from "@sema-agent/core";
|
|
27
15
|
import type { MailboxRecipientLifecycle } from "../plugins/mailbox-recipient-lifecycle.js";
|
|
28
|
-
import { type SessionPurgeOutcome } from "../session-deletion.js";
|
|
16
|
+
import { type SessionAgeOutExpectation, type SessionPurgeOutcome } from "../session-deletion.js";
|
|
29
17
|
import { type SessionEraser, type SessionEraseSettler } from "../session-erase.js";
|
|
30
18
|
import type { UserInputLedgerStore } from "../user-input-ledger.js";
|
|
31
19
|
import type { SpaceReclaimer } from "../workspace-space.js";
|
|
@@ -75,6 +63,7 @@ export interface SessionFacesCtx {
|
|
|
75
63
|
export declare function createSessionFaces(ctx: SessionFacesCtx): {
|
|
76
64
|
ownerAware: OwnerAwareSessionStore;
|
|
77
65
|
sessionAudit: ((sessionId: string, opts?: SessionAuditReadOpts) => Promise<{
|
|
66
|
+
sessionKind?: "sidechain" | undefined;
|
|
78
67
|
projectId?: string | undefined;
|
|
79
68
|
agent?: import("../session-agent.js").SessionAgent | undefined;
|
|
80
69
|
owner: string | null;
|
|
@@ -90,7 +79,9 @@ export declare function createSessionFaces(ctx: SessionFacesCtx): {
|
|
|
90
79
|
promptEpoch?: import("@sema-agent/core").StoredPromptEpoch;
|
|
91
80
|
} | undefined>) | undefined;
|
|
92
81
|
sessionWatchRegistry: SessionWatchRegistry | undefined;
|
|
93
|
-
purgeSession: ((sessionId: string, owner: string | null
|
|
82
|
+
purgeSession: ((sessionId: string, owner: string | null, opts?: {
|
|
83
|
+
readonly ageOut?: SessionAgeOutExpectation;
|
|
84
|
+
}) => Promise<SessionPurgeOutcome>) | undefined;
|
|
94
85
|
recoverPendingDeletions: (() => Promise<ReadonlyArray<{
|
|
95
86
|
readonly sessionId: string;
|
|
96
87
|
readonly outcome: SessionPurgeOutcome | {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sessionKindFaceOf } from "../session-kind.js";
|
|
1
2
|
import { buildRewindHandles, buildSessionAudit, buildSessionAuditLocal, buildSessionAuditPg } from "../audit.js";
|
|
2
3
|
import { readSessionAgent } from "../http/owner-access.js";
|
|
3
4
|
import { readSessionProjectId, sessionWorkspaceStoreOf } from "../session-workspace.js";
|
|
@@ -24,6 +25,7 @@ export function createSessionFaces(ctx) {
|
|
|
24
25
|
const ownerAware = sessionStore;
|
|
25
26
|
const headOf = headReadOf(sessionStore);
|
|
26
27
|
const workspaceStore = sessionWorkspaceStoreOf(sessionStore);
|
|
28
|
+
const kindFace = sessionKindFaceOf(sessionStore);
|
|
27
29
|
const readSessionView = async (sessionId, opts) => {
|
|
28
30
|
const handles = opts !== undefined && resumeAnchorStore !== undefined ? buildRewindHandles(await resumeAnchorStore.listBySession(sessionId), opts.reader) : undefined;
|
|
29
31
|
const audit = mysqlPool
|
|
@@ -33,13 +35,15 @@ export function createSessionFaces(ctx) {
|
|
|
33
35
|
: await buildSessionAuditLocal(auditLocalRows, sessionId, handles);
|
|
34
36
|
if (!audit)
|
|
35
37
|
return undefined;
|
|
36
|
-
const [head, agent, projectId] = await Promise.all([
|
|
38
|
+
const [head, agent, projectId, kindRead] = await Promise.all([
|
|
37
39
|
headOf?.(sessionId),
|
|
38
40
|
opts !== undefined ? readSessionAgent(ownerAware, sessionId) : undefined,
|
|
39
41
|
opts !== undefined ? readSessionProjectId(workspaceStore, sessionId) : undefined,
|
|
42
|
+
opts !== undefined ? kindFace?.sessionKindOf(sessionId) : undefined,
|
|
40
43
|
]);
|
|
41
44
|
const owner = head?.owner;
|
|
42
|
-
|
|
45
|
+
const sessionKind = kindRead !== undefined && head !== undefined && kindRead.incarnation === head.incarnation ? kindRead.kind : undefined;
|
|
46
|
+
return { ...audit, owner: owner ?? null, ...(agent !== undefined ? { agent } : {}), ...(projectId !== undefined ? { projectId } : {}), ...(sessionKind !== undefined ? { sessionKind } : {}) };
|
|
43
47
|
};
|
|
44
48
|
const sessionAudit = mysqlPool || auditPgPool || auditLocalRows ? readSessionView : undefined;
|
|
45
49
|
const probeWatchedHead = async (sid) => (headOf === undefined ? { owner: undefined, leafId: null } : ((await headOf(sid)) ?? { owner: undefined, leafId: null }));
|
|
@@ -64,7 +68,7 @@ export function createSessionFaces(ctx) {
|
|
|
64
68
|
const attempts = new Map();
|
|
65
69
|
const holder = (token) => attempts.get(token) ?? "elsewhere";
|
|
66
70
|
const purge = eraser !== undefined && deletion !== undefined
|
|
67
|
-
? async (sessionId, owner, expect) => {
|
|
71
|
+
? async (sessionId, owner, expect, ageOut) => {
|
|
68
72
|
const tenantScope = sessionTenantScope(owner);
|
|
69
73
|
const reach = await probeSessionChildren({ agentStore: backgroundAgentStore, checkpointStore, registry: defaultTaskRegistry }, sessionId, tenantScope);
|
|
70
74
|
if (!reach.reachable) {
|
|
@@ -73,7 +77,7 @@ export function createSessionFaces(ctx) {
|
|
|
73
77
|
}
|
|
74
78
|
let fence;
|
|
75
79
|
try {
|
|
76
|
-
fence = await deletion.fence(sessionId, owner, expect
|
|
80
|
+
fence = await deletion.fence(sessionId, owner, { holder, ...(expect !== undefined ? { expect } : {}), ...(ageOut !== undefined ? { ageOut } : {}) });
|
|
77
81
|
}
|
|
78
82
|
catch (err) {
|
|
79
83
|
if (err instanceof SessionActiveRunError)
|
|
@@ -143,7 +147,7 @@ export function createSessionFaces(ctx) {
|
|
|
143
147
|
return { deleted: true };
|
|
144
148
|
}
|
|
145
149
|
: undefined;
|
|
146
|
-
const purgeSession = purge !== undefined ? (sessionId, owner) => purge(sessionId, owner) : undefined;
|
|
150
|
+
const purgeSession = purge !== undefined ? (sessionId, owner, opts) => purge(sessionId, owner, undefined, opts?.ageOut) : undefined;
|
|
147
151
|
const recoverOne = async (sessionId, owner, token) => {
|
|
148
152
|
const unfinished = "the session stays in the deleting state (it reads as gone everywhere); the next start or a repeated DELETE by its owner finishes it";
|
|
149
153
|
try {
|
package/dist/boot/shutdown.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export interface ShutdownCtx {
|
|
|
39
39
|
version: string;
|
|
40
40
|
logger: Logger;
|
|
41
41
|
server: ReturnType<typeof createHttpServer>;
|
|
42
|
+
/**
|
|
43
|
+
* 本机控制 socket 那只 `http.Server`(`server.controlSocketServer`)—— present-iff 它在听(起服第 10 段 `openControlSocket` 的结局)。
|
|
44
|
+
* 🔴 收尾序承重:两只 server **都**关完(close 回调落地)才 `backend.close()`(数据根锁在那条链里放)。运行时关 unix socket 监听口时按路径名 unlink;
|
|
45
|
+
* 锁若先放、控制口还在听,接班的引擎可在此刻替换路径,随后这边关口就删掉接班者的 socket(`control-socket.ts` 头注前提律)。
|
|
46
|
+
*/
|
|
47
|
+
controlSocket?: import("node:http").Server | undefined;
|
|
42
48
|
reaper: NodeJS.Timeout;
|
|
43
49
|
/** [ref]:fleet 存活对账腿(60s 定时器 + 总线订阅)。与 `reaper` 同列文件头契约 3 —— 收尾期不该再有
|
|
44
50
|
* 对账 tick 打向正在关闭的池,订阅也要摘(否则 bus 的扇出还在往一个已停的观察者写)。 */
|
package/dist/boot/shutdown.js
CHANGED
|
@@ -19,7 +19,8 @@ export function backgroundGraceRemainingMs(a) {
|
|
|
19
19
|
return Math.max(0, Math.min(a.softStoppedAt + a.graceMs, a.deadlineMs) - a.now);
|
|
20
20
|
}
|
|
21
21
|
export function installShutdownHandlers(ctx) {
|
|
22
|
-
const { config, logger, server, reaper, fleetReconcile, retentionLane, releaseRetentionLease, otelExporter, breakerState, costQuota, rateLimiter, runner, subRunner, lspManager, workflowNotifyJournal, fleetClient, backend, drainState, storeLiveProbe, webAdmin, version, deviceHub, toolApproval, parkCommits, servingLease, peerInbound, } = ctx;
|
|
22
|
+
const { config, logger, server, controlSocket, reaper, fleetReconcile, retentionLane, releaseRetentionLease, otelExporter, breakerState, costQuota, rateLimiter, runner, subRunner, lspManager, workflowNotifyJournal, fleetClient, backend, drainState, storeLiveProbe, webAdmin, version, deviceHub, toolApproval, parkCommits, servingLease, peerInbound, } = ctx;
|
|
23
|
+
const httpListeners = controlSocket === undefined ? [server] : [server, controlSocket];
|
|
23
24
|
const dataRoot = config.localDataRoot;
|
|
24
25
|
if (dataRoot) {
|
|
25
26
|
const prior = readCrashLast(dataRoot);
|
|
@@ -161,7 +162,8 @@ export function installShutdownHandlers(ctx) {
|
|
|
161
162
|
rateLimiter.stop();
|
|
162
163
|
await fleetClient?.flushFinalUsage();
|
|
163
164
|
});
|
|
164
|
-
|
|
165
|
+
const listenersClosed = Promise.all(httpListeners.map((s) => new Promise((resolve) => s.close(() => resolve())))).then(() => undefined);
|
|
166
|
+
void listenersClosed.then(() => {
|
|
165
167
|
void Promise.all([retentionTeardown, ledgerStopped])
|
|
166
168
|
.then(() => (backend ? backend.close() : Promise.resolve()))
|
|
167
169
|
.then(() => routingStopped)
|
|
@@ -172,8 +174,12 @@ export function installShutdownHandlers(ctx) {
|
|
|
172
174
|
const finalExit = setTimeout(() => { logger.warn("hard_shutdown_final_deadline", { afterMs: FINAL_EXIT_MS }); process.exit(0); }, FINAL_EXIT_MS);
|
|
173
175
|
finalExit.unref?.();
|
|
174
176
|
drainState.endSubscriptions?.();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
for (const s of httpListeners)
|
|
178
|
+
s.closeIdleConnections?.();
|
|
179
|
+
const forceClose = setTimeout(() => {
|
|
180
|
+
for (const s of httpListeners)
|
|
181
|
+
s.closeAllConnections?.();
|
|
182
|
+
}, HARD_STOP_GRACE_MS);
|
|
177
183
|
forceClose.unref?.();
|
|
178
184
|
};
|
|
179
185
|
let draining = false;
|
|
@@ -12,6 +12,7 @@ import { installFileHistoryFailureRecorder } from "../file-history-disclosure.js
|
|
|
12
12
|
import { installSecretEnvScrubRecorder } from "../observability/secret-env-scrub.js";
|
|
13
13
|
import { setRunTerminalLogObserver } from "../observability/run-terminal.js";
|
|
14
14
|
import { setRedactionObserver } from "../trace/redact.js";
|
|
15
|
+
import { setStoreBoundaryObserver } from "../terminal.js";
|
|
15
16
|
import { installOutboundDispatcher } from "../outbound-dispatcher.js";
|
|
16
17
|
import { bindOwnCredentialsConfig, declareServerWithheldEnv } from "../server-secret-env.js";
|
|
17
18
|
import { admitLocalDataRoot } from "../plugins/local-data-root-admission.js";
|
|
@@ -53,6 +54,7 @@ export function runStage01() {
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
setRedactionObserver((pattern, n, meta) => metrics.inc("redactions_applied_total", { pattern, arm: meta.arm }, n));
|
|
57
|
+
setStoreBoundaryObserver((site, faultClass) => metrics.inc("store_boundary_fault_total", { site, class: faultClass }));
|
|
56
58
|
setWebSearchBadPayloadObserver((provider) => {
|
|
57
59
|
metrics.inc("web_search_bad_payload_total", { provider });
|
|
58
60
|
logger.warn("web_search_non_array_payload", { provider });
|
|
@@ -5,13 +5,12 @@ import { configSourceKind } from "../config-provider.js";
|
|
|
5
5
|
import { announceConfigRootEnclosingWorkspace } from "../sema-config-dir.js";
|
|
6
6
|
import { launchWorkspaceOf } from "../task-cwd.js";
|
|
7
7
|
import { buildCandidateRejectionNotes } from "../web-admin-client/candidate-gate.js";
|
|
8
|
-
import { logConfigDirMigration, migrateLocalConfigDirectory } from "../config-d-migration.js";
|
|
9
8
|
import { logEnvModelsMigration, runEnvModelsMigration } from "../config-root-migration.js";
|
|
10
9
|
import { assertLocalConfigDirTrusted } from "../config-dir-trust.js";
|
|
11
10
|
import { defaultModelRefusal, refusedNameMintedRefusal } from "../model-entry-refusal.js";
|
|
12
11
|
import { isRosterGateArmed } from "../config.js";
|
|
13
12
|
import { judgeServedModelRoute } from "../model-route-endpoint.js";
|
|
14
|
-
import { servedModelTableLeg } from "../model-select.js";
|
|
13
|
+
import { modelRefusalLegOf, servedModelTableLeg } from "../model-select.js";
|
|
15
14
|
import { warnAssumedContextWindows } from "../context-window-notice.js";
|
|
16
15
|
import { captureBootStoreEvidence } from "./store-evidence.js";
|
|
17
16
|
import { admitStoreDurability } from "../store-admission.js";
|
|
@@ -22,7 +21,6 @@ export async function runStage02(ctx) {
|
|
|
22
21
|
const configSource = configSourceKind(loaded);
|
|
23
22
|
if (configSource === "local") {
|
|
24
23
|
await assertLocalConfigDirTrusted({ root: localRoot, declaredOwnerUid: loaded.configLocalOwnerUid });
|
|
25
|
-
logConfigDirMigration(logger, await migrateLocalConfigDirectory(localRoot));
|
|
26
24
|
}
|
|
27
25
|
const config = await composeExecutionLane(loaded, { configSource, localRoot, logger, entry: HTTP_SERVICE_LANE_ENTRY });
|
|
28
26
|
admitStoreDurability(config, storeEvidence);
|
|
@@ -35,11 +33,12 @@ export async function runStage02(ctx) {
|
|
|
35
33
|
const webAdmin = await createWebAdminRuntime({ config, logger, metrics, localRoot });
|
|
36
34
|
const servedLeg = servedModelTableLeg(config);
|
|
37
35
|
const rejection = webAdmin.candidateRejectionState();
|
|
38
|
-
const
|
|
36
|
+
const webAdminIsConfigSource = configSource === "remote";
|
|
37
|
+
const noDefaultModel = defaultModelRefusal({ models: config.models, modelRefusals: config.modelRefusals, candidateRejectionNotes: rejection === undefined ? undefined : buildCandidateRejectionNotes(rejection) }, modelRefusalLegOf(servedLeg, webAdminIsConfigSource));
|
|
39
38
|
if (noDefaultModel !== undefined) {
|
|
40
39
|
throw new Error(noDefaultModel);
|
|
41
40
|
}
|
|
42
|
-
const routeVerdict = judgeServedModelRoute(config, { envTableIsPlaceholder: isRosterGateArmed(config.webAdmin) });
|
|
41
|
+
const routeVerdict = judgeServedModelRoute(config, { envTableIsPlaceholder: isRosterGateArmed(config.webAdmin), webAdminIsConfigSource });
|
|
43
42
|
if (routeVerdict !== undefined) {
|
|
44
43
|
throw new Error(routeVerdict.reason);
|
|
45
44
|
}
|
|
@@ -18,10 +18,12 @@ export declare function runStage05(ctx: Awaited<ReturnType<typeof runStage04>>):
|
|
|
18
18
|
perSessionCwd: Map<string, string>;
|
|
19
19
|
perTaskImage: import("../per-task-image.js").PerTaskImageRegistry;
|
|
20
20
|
sendUserFileTaskEnvs: import("../capabilities/sandbox-file-send.js").TaskEnvRegistry | undefined;
|
|
21
|
+
sessionBindings: {
|
|
22
|
+
commitSessionBindings: (sessionId: string, bindings: import("../session-bindings.js").SessionBindings) => import("../session-bindings.js").SessionBindingReceipt;
|
|
23
|
+
withdrawSessionBindings: (receipt: import("../session-bindings.js").SessionBindingReceipt) => boolean;
|
|
24
|
+
settleSessionBindings: (receipt: import("../session-bindings.js").SessionBindingReceipt) => boolean;
|
|
25
|
+
};
|
|
21
26
|
sessionEnvSelection: import("../capabilities/select-environment-tool.js").SessionEnvironmentSelection;
|
|
22
|
-
setSessionCwd: (sid: string, cwd: string) => void;
|
|
23
|
-
setSessionInheritEnv: (sid: string, policy: import("../request-value-closure.js").TaskInheritEnv | undefined) => void;
|
|
24
|
-
setSessionShellEnv: (sid: string, env: Record<string, string>) => void;
|
|
25
27
|
worktreeReap: (() => Promise<void>) | undefined;
|
|
26
28
|
brain: import("@sema-agent/core").Brain;
|
|
27
29
|
consolidationSeatWatch: import("./memory-consolidation.js").ConsolidationSeatWatch | undefined;
|
|
@@ -13,11 +13,12 @@ export async function runStage05(ctx) {
|
|
|
13
13
|
const deviceLane = config.remoteExec.provider === "device" ? createDeviceLane({ config, logger, metrics, backend, seat: sessionStore.executionPlacement, replicaId: instanceId }) : undefined;
|
|
14
14
|
const headOf = headReadOf(sessionStore);
|
|
15
15
|
const spaceCommits = backend !== undefined ? () => runStore : undefined;
|
|
16
|
-
const { perTaskImage, sessionEnvSelection, perSessionCwd,
|
|
16
|
+
const { perTaskImage, sessionEnvSelection, perSessionCwd, sessionBindings, fenceSessionOwner, dropSessionScoped, sessionResidentBackground, dropSessionScopedOf, executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxApiCredentialsGate, sandboxSecretSeatGate, sandboxReaper, sandboxGitPlane: sandboxGitPlaneSeat, sandboxCapacity, } = createExecutionEnv({ config, logger, metrics, taskAttachmentStore, ...(deviceLane ? { deviceLane } : {}), ...(spaceCommits !== undefined ? { spaceCommits } : {}), ...(headOf !== undefined ? { headOf } : {}), ...(backend !== undefined ? { runRows: () => runStore } : {}) });
|
|
17
17
|
assertDeviceLaneWired(config.remoteExec.provider === "device", deviceLane, executionEnvFactory !== undefined);
|
|
18
18
|
if (deviceLane !== undefined && config.remoteExec.provider === "device")
|
|
19
19
|
await noteDeviceRelayBindings(config.remoteExec.relay, deviceLane.store, logger);
|
|
20
20
|
assertWorkspaceSpaceReadable(facts.workspaceSpace(config), { headOf, spaceCommits }, facts.workspaceCache(config), sessionStoreLabelOf(config.sessionBackend, backend?.kind));
|
|
21
|
+
sandboxApiCredentialsGate?.();
|
|
21
22
|
if (sandboxSecretSeatGate !== undefined)
|
|
22
23
|
await sandboxSecretSeatGate();
|
|
23
24
|
await sandboxGitPlaneSeat.settle();
|
|
@@ -34,6 +35,6 @@ export async function runStage05(ctx) {
|
|
|
34
35
|
const peerDesk = createPeerDesk({ log: logger });
|
|
35
36
|
metrics.dynamicGauge("peer_registry_entries", "Peer desk entries (declared peer credentials registered for in-flight legs and the roster)", () => peerDesk.size().entries);
|
|
36
37
|
metrics.dynamicGauge("peer_registry_holders", "Peer desk holders of entries (host leases and engine holds), summed across entries", () => peerDesk.size().holders);
|
|
37
|
-
return { ...ctx, deploymentMods, deploymentModsLoaded, belowTaskChainPatterns, deviceLane, peerDesk, dropSessionScoped, dropSessionScopedOf, executionEnvFactory, fenceSessionOwner, sessionResidentBackground, lspManager, spaceReclaimer, sandboxReaper, sandboxGitPlane, sandboxCapacity, perSessionCwd, perTaskImage, sendUserFileTaskEnvs,
|
|
38
|
+
return { ...ctx, deploymentMods, deploymentModsLoaded, belowTaskChainPatterns, deviceLane, peerDesk, dropSessionScoped, dropSessionScopedOf, executionEnvFactory, fenceSessionOwner, sessionResidentBackground, lspManager, spaceReclaimer, sandboxReaper, sandboxGitPlane, sandboxCapacity, perSessionCwd, perTaskImage, sendUserFileTaskEnvs, sessionBindings, sessionEnvSelection, worktreeReap };
|
|
38
39
|
}
|
|
39
40
|
//# sourceMappingURL=stage-05-execution-env.js.map
|