@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/run-local.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { DEFAULT_MODEL_REF, pickUserModel } from "./model-select.js";
|
|
3
3
|
import { defaultModelRefusal, modelNotAllowedMessage, modelUnavailableMessage } from "./model-entry-refusal.js";
|
|
4
|
-
import { servedModelTableLeg } from "./model-select.js";
|
|
4
|
+
import { modelRefusalLegOf, servedModelTableLeg } from "./model-select.js";
|
|
5
5
|
import { outwardPlane, sealResultForExit } from "./terminal.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { realpathSync } from "node:fs";
|
|
@@ -22,12 +22,11 @@ import { buildUnpricedCeilingNotice, isRosterGateArmed, loadConfig, logConfigDia
|
|
|
22
22
|
import { admitLocalDataRoot } from "./plugins/local-data-root-admission.js";
|
|
23
23
|
import { openLocalBackend } from "./plugins/store-backend.js";
|
|
24
24
|
import { runAndLogOneTimeMigrations } from "./plugins/one-time-migrations.js";
|
|
25
|
-
import { configLocalRoot, createConfigProvider } from "./config-provider.js";
|
|
25
|
+
import { configLocalRoot, configSourceKind, createConfigProvider } from "./config-provider.js";
|
|
26
26
|
import { CONFIG_DOMAIN_INVALID_NOTE, buildCandidateRejectedFields, buildCandidateRejectionNotes, judgeConfigCandidate } from "./web-admin-client/candidate-gate.js";
|
|
27
27
|
import { buildUnreadConfigFileFields, buildUnreadConfigKeyFields } from "./web-admin-client/read-warnings.js";
|
|
28
28
|
import { composeExecutionLane, settleHostLaneShell, settleReadDenyFloor } from "./boot/execution-lane.js";
|
|
29
29
|
import { judgeConsolidationValve } from "./boot/memory-consolidation.js";
|
|
30
|
-
import { logConfigDirMigration, migrateLocalConfigDirectory } from "./config-d-migration.js";
|
|
31
30
|
import { logEnvModelsMigration, runEnvModelsMigration } from "./config-root-migration.js";
|
|
32
31
|
import { assertLocalConfigDirTrusted, ConfigDirUntrustedError } from "./config-dir-trust.js";
|
|
33
32
|
import { ConfigPullError, asConfigPullError, configPullFailureNote } from "./config-pull-failure.js";
|
|
@@ -376,7 +375,6 @@ export async function runLocal(argv, deps = {}) {
|
|
|
376
375
|
await printErr(err instanceof Error ? err.message : String(err));
|
|
377
376
|
return 2;
|
|
378
377
|
}
|
|
379
|
-
logConfigDirMigration(logger, await migrateLocalConfigDirectory(root));
|
|
380
378
|
let config;
|
|
381
379
|
try {
|
|
382
380
|
config = await composeExecutionLane(loaded, { configSource: "local", localRoot: root, logger, entry: RUN_LOCAL_LANE_ENTRY });
|
|
@@ -435,10 +433,11 @@ export async function runLocal(argv, deps = {}) {
|
|
|
435
433
|
else
|
|
436
434
|
logger.warn("config_apply_refused", { source: configProvider.kind, err: String(err), note: "the candidate failed to apply at boot — running on env (run-local has no LKG); none of the candidate's domains is adopted; this is not a reachability failure" });
|
|
437
435
|
}
|
|
438
|
-
const
|
|
436
|
+
const webAdminIsConfigSource = configSourceKind(config) === "remote";
|
|
437
|
+
const noDefaultModel = defaultModelRefusal({ models: config.models, modelRefusals: config.modelRefusals, candidateRejectionNotes }, modelRefusalLegOf(servedModelTableLeg(config), webAdminIsConfigSource));
|
|
439
438
|
if (noDefaultModel !== undefined)
|
|
440
439
|
throw new Error(noDefaultModel);
|
|
441
|
-
const routeVerdict = judgeServedModelRoute(config, { envTableIsPlaceholder: false });
|
|
440
|
+
const routeVerdict = judgeServedModelRoute(config, { envTableIsPlaceholder: false, webAdminIsConfigSource });
|
|
442
441
|
if (routeVerdict !== undefined)
|
|
443
442
|
throw new Error(routeVerdict.reason);
|
|
444
443
|
warnAssumedContextWindows(config, logger, { envTableIsPlaceholder: false });
|
|
@@ -612,6 +611,7 @@ export async function runLocal(argv, deps = {}) {
|
|
|
612
611
|
assertGovernanceAssemblable(config);
|
|
613
612
|
const { registrations: deploymentMods } = await assembleDeploymentMods({ metrics, brandIdentity: true, declaration: config.modsDeclaration, logger });
|
|
614
613
|
const sharedRunnerDeps = createSharedRunnerDeps({
|
|
614
|
+
onError: engineOnError,
|
|
615
615
|
metrics,
|
|
616
616
|
config,
|
|
617
617
|
engineDataRoot,
|
|
@@ -637,12 +637,12 @@ export async function runLocal(argv, deps = {}) {
|
|
|
637
637
|
sharedMemoryStores: undefined,
|
|
638
638
|
mcpRevocations: undefined,
|
|
639
639
|
peerDesk,
|
|
640
|
+
runtimeCapsResolver: undefined,
|
|
640
641
|
});
|
|
641
642
|
const runnerDeps = {
|
|
642
643
|
...sharedRunnerDeps,
|
|
643
644
|
sessionStore,
|
|
644
645
|
...(memoryEngine ? { memoryBackend: memoryEngine.backend } : {}),
|
|
645
|
-
onError: engineOnError,
|
|
646
646
|
onAsk,
|
|
647
647
|
...(config.projectMemoryEnabled
|
|
648
648
|
? {
|
|
@@ -652,7 +652,7 @@ export async function runLocal(argv, deps = {}) {
|
|
|
652
652
|
: {}),
|
|
653
653
|
};
|
|
654
654
|
const runner = new Runner(runnerDeps);
|
|
655
|
-
const subRunnerDeps = { ...sharedRunnerDeps, sessionStore: new ForkRoutingSessionStore(sessionStore, new TtlSessionStore({ defaultTtlDays: 1 / 24 })),
|
|
655
|
+
const subRunnerDeps = { ...sharedRunnerDeps, sessionStore: new ForkRoutingSessionStore(sessionStore, new TtlSessionStore({ defaultTtlDays: 1 / 24 })), onAsk };
|
|
656
656
|
const subRunner = new Runner(subRunnerDeps);
|
|
657
657
|
const handslessRunner = new Runner(withoutHands(runnerDeps));
|
|
658
658
|
const deploymentSkills = loadDeploymentSkills(config, logger);
|
|
@@ -676,7 +676,7 @@ export async function runLocal(argv, deps = {}) {
|
|
|
676
676
|
const sessionId = args.session ?? uuidv7();
|
|
677
677
|
let cap;
|
|
678
678
|
try {
|
|
679
|
-
scenarioName = await createScenarioGate({ config, scenarios, principalCaps: undefined, logger }, "enforce")(undefined, args.scenario);
|
|
679
|
+
scenarioName = (await createScenarioGate({ config, scenarios, principalCaps: undefined, logger }, "enforce")(undefined, args.scenario)).scenario;
|
|
680
680
|
cap = selectScenario(scenarios, scenarioName)({ scenario: scenarioName, objective: args.objective }, undefined, { sessionId });
|
|
681
681
|
}
|
|
682
682
|
catch (err) {
|
package/dist/runs.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ import type { RunAcceptance } from "./run-acceptance.js";
|
|
|
17
17
|
import type { SessionWorkspaceRecorder } from "./session-workspace.js";
|
|
18
18
|
import type { VerifyRoundsSpec } from "./http/verify-rounds.js";
|
|
19
19
|
import { type ParkLedgerEventType } from "./trace/ledger-events.js";
|
|
20
|
+
import type { LandedAttendantSeat } from "./plugins/landed-attendants.js";
|
|
21
|
+
import type { DelegationRootWitness } from "./delegated-session-owner.js";
|
|
22
|
+
import type { SessionFace } from "./session-incarnation.js";
|
|
20
23
|
import type { UserInputLedger } from "./user-input-ledger.js";
|
|
21
24
|
/**
|
|
22
25
|
* stoppedBy (core 1.252): a service cancel is a USER stop — mark the run's still-running background
|
|
@@ -27,8 +30,8 @@ import type { UserInputLedger } from "./user-input-ledger.js";
|
|
|
27
30
|
* cross-replica flag poll). Advisory only — the cancel itself must never fail on attribution.
|
|
28
31
|
*
|
|
29
32
|
* Access = TASK-scoped children ONLY: owner = the parent taskId (on a RESUME leg: the sessionId — core's
|
|
30
|
-
* canonical taskId there), scope =
|
|
31
|
-
*
|
|
33
|
+
* canonical taskId there), scope = the engine-identity cell `engineScopeOfOwner(subject)` (core registers
|
|
34
|
+
* children under its task scope, so an anonymous run's children live in scope "default" and an access
|
|
32
35
|
* WITHOUT scope matched nothing). Session-scoped children are DELIBERATELY not marked: a cancelled parent
|
|
33
36
|
* does NOT take them down (CC Backgrounded semantics — core's teardown reaps with skipSessionScoped), so
|
|
34
37
|
* pre-marking them "user" would misattribute a stop that isn't happening.
|
|
@@ -134,8 +137,14 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
134
137
|
releaseIdemKey(taskId: string): Promise<void>;
|
|
135
138
|
}, taskId: string, result: Pick<TaskResult, "terminal" | "stats">): Promise<void>;
|
|
136
139
|
/**
|
|
137
|
-
* E18 resume-at — per-turn anchor capture, shared by runInBackground, the resume-leg driveResume
|
|
138
|
-
* leg's plain form so the (single, tricky) capture rule can't drift between the stream-drain loops.
|
|
140
|
+
* E18 resume-at — per-turn anchor capture, shared by runInBackground, the resume-leg driveResume, the `POST /v1/tasks/stream`
|
|
141
|
+
* leg AND the sync `POST /v1/tasks` leg's plain form so the (single, tricky) capture rule can't drift between the stream-drain loops.
|
|
142
|
+
*
|
|
143
|
+
* **One write moment for every leg**: an anchor is written in the drain loop the moment the event that decides it arrives
|
|
144
|
+
* (the prompt anchor on its `message_committed`, a turn anchor on its `turn_end`) — never deferred to a leg's finish /
|
|
145
|
+
* disconnect branch. A process that is killed (SIGKILL / host crash / OOM) runs no finish branch, so a deferred write is a
|
|
146
|
+
* write that a killed run never makes; the engine's file-history boundary for the prompt is already on disk by then, and
|
|
147
|
+
* the anchor is the only thing that translates the caller's handle to it.
|
|
139
148
|
*
|
|
140
149
|
* A "turn" in core = ONE assistant message + its tool batch. resume-at is valid ONLY at a SETTLED rewindable boundary
|
|
141
150
|
* — core's prepare-task accepts "user messages or finished assistant-text turns" and REJECTS an assistant message that
|
|
@@ -153,8 +162,8 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
153
162
|
* observable instead of a silent feature outage.
|
|
154
163
|
*/
|
|
155
164
|
/**
|
|
156
|
-
* 「这一次用户消息提交是不是这个 run 的**开场提示**」的唯一读法 ——
|
|
157
|
-
*
|
|
165
|
+
* 「这一次用户消息提交是不是这个 run 的**开场提示**」的唯一读法 —— 四条腿(后台腿 / 续跑腿 / 同步腿 `POST /v1/tasks` / 流式腿 `POST /v1/tasks/stream`)的用户回退锚
|
|
166
|
+
* 都经 {@link TurnAnchorCapture} 调这一只;调用点零各自判、零按正文判,交出一次写一次(「最后一次交出的赢」= 锚店按键 upsert)。
|
|
158
167
|
*
|
|
159
168
|
* **回退锚 = 该轮开场提示,一个 run 一个(开场窗 + 闩)**:run 一开始就开着一个**开场窗**,收集第一次模型输出之前的 user 提交;窗关上之后(闩上),同 run 的 user-role 提交 ——
|
|
160
169
|
* 用户打断时引擎收尾追加的「[Request interrupted by user]」、第一次模型调用前后排进来的 steer 正文、答完之后再来的 steer —— 一律不交。这是 CC「rewind to the message that started this turn」的
|
|
@@ -177,7 +186,7 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
177
186
|
* · 带附件的提交,窗内又应用了一条别的输入(`human_input{applied}`,如第一次模型调用前排进来的 steer;事件先于它的正文提交到手)⇒ 窗里多了一条别人的消息,数 N 会落在帧后面的 steer 上 ⇒ 不猜。
|
|
178
187
|
* 不带附件的提交不看输入条数:多条 applied 输入可以合成一条提交(续跑把停驻的 steer 与 wake 文本并成一条续跑消息),按修前同读校正到窗内最后一条。排队未应用(`delivery: "queued"`)的输入不动窗。窗还开着时继续攒,直到被关上。
|
|
179
188
|
* · 「不猜」= 这个 run 不落(带附件)或不校正(不带附件),且窗关上之后闩上 —— 其后的 user 提交(steer 正文、打断标记)不是开场提示,不顶上来;拿这次 run 的 taskId 去 `resumeAt`
|
|
180
|
-
* 得 404 `resume_at.unknown_event`(
|
|
189
|
+
* 得 404 `resume_at.unknown_event`(文案说「它是一条没有锚的提问」,不点名成因 —— `history-anchor.ts`)。
|
|
181
190
|
* 窗关上之前一个 user 提交都没有就关了(续跑腿里先到的是工具结果 / 助手消息)⇒ 窗照开着,不闩:那一条之后第一条 user 提交才是这个 run 里的第一条。
|
|
182
191
|
*
|
|
183
192
|
* 已知边界(引擎在 `message_committed` 上带来源标 / 输入标之日见下):
|
|
@@ -186,7 +195,7 @@ export declare function releaseKeyIfZeroWorkRefusal(runStore: {
|
|
|
186
195
|
* · 不带附件、第一次模型输出之前就应用了一条 steer:校正到窗内最后一条 = steer 正文(与修前同读)。
|
|
187
196
|
*
|
|
188
197
|
* 退役条件:引擎在落盘的帧上(`message_committed`)带上来源标(附件标记 / 引擎消息标)之日,本读法整体换成「第一条非引擎消息」(零计数、无窗口、无校正、无拒臂),
|
|
189
|
-
* 窗口 / 严格吻合 /
|
|
198
|
+
* 窗口 / 严格吻合 / 不猜三臂一并删除,领头排队消息的边界随之消失。
|
|
190
199
|
*/
|
|
191
200
|
export declare function createPromptCommitReader(): (ev: {
|
|
192
201
|
readonly type: string;
|
|
@@ -197,14 +206,41 @@ export type ResumeAnchorLeg = "stream" | "sync" | "bg" | "resume";
|
|
|
197
206
|
* 回退锚的**唯一**写法(四条腿同一只):**有界** await 写入(单行店操作期限 {@link BASELINE_IO_DEADLINE_MS},与项目指令基线的
|
|
198
207
|
* 读写同一只数、同一只 {@link withinIoDeadline} —— 同为单行 PK 写、同在腿的关键路径上);写失败或到期 ⇒ 不抛(锚是这次提示词能不能
|
|
199
208
|
* 回退的手柄,不是 run 的成败),记一次登记过的 fail-open `server.resume-anchor.capture-failed`(`reason=error|timeout`;计数 + 探针行 + 一次性 warn)。
|
|
200
|
-
*
|
|
209
|
+
* 调用方在决定这只锚的那一帧到手时就 await 它({@link TurnAnchorCapture}:提示锚在开场提示的提交上,四条腿同一个时机)⇒ 早于本腿的终帧(流式腿的 `done`、同步腿的 200 应答)——
|
|
210
|
+
* 客户端拿到终帧时锚已落定或已知没落定,没有「锚晚到」的窗;进程在终帧之前被强杀,已到手的那一笔也已落定。锚店挂住至多让那一帧之后的处理晚一个期限。
|
|
201
211
|
* 到期只放手不取消:那次写照常在飞,迟到落定的锚照样可用(迟到的失败被吞,不重复计数)。
|
|
202
212
|
* 用户面的读数仍只有一处:会话视图用户消息行的 `taskId?`(present-iff 锚在)与 `resumeAt` 的 404 `resume_at.unknown_event`。
|
|
203
213
|
*/
|
|
204
|
-
export declare function settleResumeAnchor(write: () => Promise<void>, where: {
|
|
214
|
+
export declare function settleResumeAnchor(write: (held: () => boolean) => Promise<void>, where: {
|
|
205
215
|
readonly leg: ResumeAnchorLeg;
|
|
206
216
|
readonly kind: "prompt" | "turn";
|
|
207
217
|
}): Promise<void>;
|
|
218
|
+
/** 一条运行腿的两只回退锚写口(缺席 = 这条腿没有那一种锚:没有落定席位 / 没有提示手柄 / 没有叶子读)。 */
|
|
219
|
+
export interface RunAnchorWriter {
|
|
220
|
+
/** 用户提示锚:键 = 这条 run 的 id(客户端手里的回退手柄),值 = 那条用户提交的条目 id。 */
|
|
221
|
+
readonly prompt?: (entryId: string, held: () => boolean) => Promise<void>;
|
|
222
|
+
/** 助手文本锚:键 = 这一轮第一个 text 帧的 eventId,值 = 此刻会话的叶子。 */
|
|
223
|
+
readonly turn?: (eventId: string, held: () => boolean) => Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* **运行腿回退锚的唯一写法**(后台腿 / 同步腿 / 流式腿 / 续跑腿同一只):锚只经落定席位的 `putAnchors` 落(`plugins/landed-attendants.ts`:段首锁会话根行判住客),
|
|
227
|
+
* 住客 = **这条 run 自己的那一位** —— 受理时见证到的(`LegFacts.sessionWitness`,带化身);见证里还没有化身(这条腿新建了会话)⇒ 第一笔锚之前读一次头钉住。
|
|
228
|
+
* 钉住发生在腿还在等这一笔的期限之内(`held()`:腿被这一笔挡着 ⇒ run 在跑、认领在手 ⇒ 会话删不掉),到期之后才完成的钉住不发写;已发出的写到期只放手不取消
|
|
229
|
+
* (`settleResumeAnchor`),但它绑着钉住的那一位 —— run 收场、会话被删、同 id 被别人重建之后才落的那一笔落不进新住客,也落不进空闲 id(段判「不是那一位」⇒ 零写,
|
|
230
|
+
* 记一次同一只 fail-open,`reason=error`)。没有席位 ⇒ 两只都缺席(这台部署不存锚)。
|
|
231
|
+
*/
|
|
232
|
+
export declare function createRunAnchorWriter(args: {
|
|
233
|
+
readonly seat: Pick<LandedAttendantSeat, "putAnchors"> | undefined;
|
|
234
|
+
readonly sessionId: string;
|
|
235
|
+
readonly owner: string | null;
|
|
236
|
+
/** 用户提示锚的键(这条 run 的 id);缺 ⇒ 不写提示锚(没有手柄 / 续跑腿接着别的腿的 run)。 */
|
|
237
|
+
readonly promptKey: string | undefined;
|
|
238
|
+
readonly witness: DelegationRootWitness | undefined;
|
|
239
|
+
/** 头读投成的住客(属主存取器的 `sessionOccupantReadOf`);缺 ⇒ 见证里没有化身时钉不住 ⇒ 不写。 */
|
|
240
|
+
readonly occupantOf: ((sessionId: string) => Promise<SessionFace | undefined>) | undefined;
|
|
241
|
+
/** 会话此刻的叶子(属主存取器的 `sessionFactsReadOf` 投影);缺 ⇒ 不写助手文本锚。 */
|
|
242
|
+
readonly leafOf: ((sessionId: string) => Promise<string | null | undefined>) | undefined;
|
|
243
|
+
}): RunAnchorWriter;
|
|
208
244
|
export declare class TurnAnchorCapture {
|
|
209
245
|
private readonly capture;
|
|
210
246
|
/** 这只捕获器在哪条腿上(写失败的 fail-open 探针行带它)。 */
|
|
@@ -227,9 +263,11 @@ export declare class TurnAnchorCapture {
|
|
|
227
263
|
private turnHadTool;
|
|
228
264
|
/** 用户提交是不是开场提示的唯一读法({@link createPromptCommitReader};开场窗 + 闩 —— 开场提示之后打断标记 / steer 不改锚;附件帧不是提问)。 */
|
|
229
265
|
private readonly promptCommit;
|
|
230
|
-
|
|
266
|
+
/** 上一笔提示锚写的落定(临时锚 → 校正写同一把键;下一笔等它落定再发,见 {@link TurnAnchorCapture.onMessageCommitted})。从不拒。 */
|
|
267
|
+
private promptLanding;
|
|
268
|
+
constructor(capture: ((eventId: string, held: () => boolean) => Promise<void>) | undefined,
|
|
231
269
|
/** 这只捕获器在哪条腿上(写失败的 fail-open 探针行带它)。 */
|
|
232
|
-
leg:
|
|
270
|
+
leg: ResumeAnchorLeg,
|
|
233
271
|
/** R8 (CC-parity rewind): capture a USER-message anchor straight from the
|
|
234
272
|
* `message_committed{role:"user"}` event — its `entryId` is the persisted user-message `SessionTreeEntry.id`,
|
|
235
273
|
* ALWAYS a valid `resumeAt` target (core accepts a user message; it rejects a tool-result / mid-tool-call
|
|
@@ -242,7 +280,7 @@ export declare class TurnAnchorCapture {
|
|
|
242
280
|
* user-role commit in the same run — the interruption marker, a steer — never moves it. The capture instance is per
|
|
243
281
|
* run: a leg that CONTINUES an existing run (same taskId) wires no `captureUser` (its opening prompt was anchored
|
|
244
282
|
* by the first leg). */
|
|
245
|
-
captureUser?: ((entryId: string) => Promise<void>) | undefined);
|
|
283
|
+
captureUser?: ((entryId: string, held: () => boolean) => Promise<void>) | undefined);
|
|
246
284
|
/** A `human_input` arrived — the objective's declared attachments open the frame window of {@link createPromptCommitReader} (another applied input inside the window voids it). */
|
|
247
285
|
onHumanInput(ev: {
|
|
248
286
|
readonly type: string;
|
|
@@ -359,7 +397,7 @@ cascade?: CascadeConfig, instrumentDegenerate?: (result: TaskResult) => void, pl
|
|
|
359
397
|
elicitOwner?: string | null,
|
|
360
398
|
/** E18 resume-at: capture the turn's (firstTextEventId → leaf entryId) anchor at each turn_end. Built by the caller
|
|
361
399
|
* closing over {sessionId, owner, the session store's head read (`headOf(id)?.leafId`), resumeAnchorStore}; undefined ⇒ no anchor store wired. */
|
|
362
|
-
captureTurnAnchor?: (eventId: string) => Promise<void>,
|
|
400
|
+
captureTurnAnchor?: (eventId: string, held: () => boolean) => Promise<void>,
|
|
363
401
|
/** MF-Fleet (shell-host contract): the run-scoped fleet-row publisher. `onStart` adds the live row; `onEvent` accrues
|
|
364
402
|
* tokens (turn_end) + subagent child rows (task_progress); `onTerminal` flips/removes it. Fired for ALL legs
|
|
365
403
|
* (verify/cascade/plain-stream) so a background run TRANSITIONS its `GET /v1/fleet/stream` row exactly like the
|
|
@@ -367,7 +405,7 @@ captureTurnAnchor?: (eventId: string) => Promise<void>,
|
|
|
367
405
|
fleetPublisher?: FleetRunPublisher,
|
|
368
406
|
/** R8 (CC-parity rewind): capture a USER-message anchor (keyed by this run's taskId) from `message_committed{role:"user"}`
|
|
369
407
|
* — the CC "rewind to the prompt" target. undefined ⇒ no anchor store wired. */
|
|
370
|
-
captureUserMessageAnchor?: (entryId: string) => Promise<void>,
|
|
408
|
+
captureUserMessageAnchor?: (entryId: string, held: () => boolean) => Promise<void>,
|
|
371
409
|
/** §4④ : AskUserQuestion LIVE coordinator — establishes a per-run onQuestion ALS context (like `elicitation`)
|
|
372
410
|
* so an AskUserQuestion tool call routes to this run's stream + owner-gated respond. undefined ⇒ headless default. */
|
|
373
411
|
question?: QuestionCoordinator,
|
|
@@ -457,7 +495,7 @@ workspaceRecorder?: SessionWorkspaceRecorder,
|
|
|
457
495
|
*/
|
|
458
496
|
runSkills?: readonly RunSkillEntry[],
|
|
459
497
|
/**
|
|
460
|
-
*
|
|
498
|
+
* 这条腿跑在的工作目录(部署事实 `LegFacts.sessionBindings.cwd`)。只在两条组合腿(verify / cascade)上经 `compositionLegRoot` 交给引擎 ——
|
|
461
499
|
* 梯子的级 / 验证器腿跑在引擎现铸的会话里,工厂按会话读不到它;普通流形跑在根会话上,工厂自己读得到。缺席 = 没登记 ⇒ 每一条腿照旧落临时目录。
|
|
462
500
|
*/
|
|
463
501
|
registeredCwd?: string): Promise<void>;
|
package/dist/runs.js
CHANGED
|
@@ -9,9 +9,8 @@ import { TOOL_DECLARATION_HTTP_STATUS } from "./tool-declaration-http-status.js"
|
|
|
9
9
|
import { isSessionErrorCode, sessionErrorHttp } from "./session-error-wire.js";
|
|
10
10
|
import { redactErrorMessage } from "./observability/run-terminal.js";
|
|
11
11
|
import { withSubject } from "./observability/principal-context.js";
|
|
12
|
-
import { partsOf } from "./owner-brands.js";
|
|
13
12
|
import { recoveredSubject } from "./owner-faces.js";
|
|
14
|
-
import {
|
|
13
|
+
import { engineScopeOfOwner } from "./engine-identity.js";
|
|
15
14
|
import { withModelReachScope } from "./model-reach-scope.js";
|
|
16
15
|
import { createInstructionSelectionLeg } from "./instruction-selection.js";
|
|
17
16
|
import { redactSecrets } from "./trace/redact.js";
|
|
@@ -62,11 +61,10 @@ export async function taskHandleStop(registry, handle, access, agentStore) {
|
|
|
62
61
|
return registry.stopTask(handle, access);
|
|
63
62
|
}
|
|
64
63
|
export function markChildrenStoppedByUserOnAbort(signal, taskId, subject) {
|
|
65
|
-
const
|
|
66
|
-
const principal = taskSpecIdentityOf(recovered === undefined ? undefined : partsOf(recovered)).principal;
|
|
64
|
+
const scope = engineScopeOfOwner(subject);
|
|
67
65
|
const mark = () => {
|
|
68
66
|
try {
|
|
69
|
-
defaultTaskRegistry.markStopSourceForOwner({ owner: taskId, scope
|
|
67
|
+
defaultTaskRegistry.markStopSourceForOwner({ owner: taskId, scope }, "user", { skipSessionScoped: true });
|
|
70
68
|
}
|
|
71
69
|
catch {
|
|
72
70
|
}
|
|
@@ -79,6 +77,10 @@ export function markChildrenStoppedByUserOnAbort(signal, taskId, subject) {
|
|
|
79
77
|
}
|
|
80
78
|
const EXECUTION_ENV_REFUSAL_HTTP_STATUS = {
|
|
81
79
|
"env.home_unconfirmed": 409,
|
|
80
|
+
"env.snapshot_bucket_missing": 409,
|
|
81
|
+
"env.occupant_missing": 409,
|
|
82
|
+
"env.sandbox_refused": 409,
|
|
83
|
+
"env.host_key_rejected": 409,
|
|
82
84
|
};
|
|
83
85
|
const PREPARE_REFUSAL_HTTP_STATUS = {
|
|
84
86
|
"resume.session_not_found": 404,
|
|
@@ -234,13 +236,52 @@ export function createPromptCommitReader() {
|
|
|
234
236
|
};
|
|
235
237
|
}
|
|
236
238
|
export async function settleResumeAnchor(write, where) {
|
|
239
|
+
let open = true;
|
|
237
240
|
try {
|
|
238
|
-
await withinIoDeadline(write);
|
|
241
|
+
await withinIoDeadline(() => write(() => open));
|
|
239
242
|
}
|
|
240
243
|
catch (err) {
|
|
241
244
|
const why = err instanceof IoDeadlineExceeded ? `reason=timeout boundMs=${BASELINE_IO_DEADLINE_MS}` : `reason=error error=${err instanceof Error ? err.message : String(err)}`;
|
|
242
245
|
recordFailOpen("server.resume-anchor.capture-failed", `leg=${where.leg} kind=${where.kind} ${why}`);
|
|
243
246
|
}
|
|
247
|
+
finally {
|
|
248
|
+
open = false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export function createRunAnchorWriter(args) {
|
|
252
|
+
const { seat, sessionId, owner, promptKey, witness, occupantOf, leafOf } = args;
|
|
253
|
+
if (seat === undefined)
|
|
254
|
+
return {};
|
|
255
|
+
let pinned = witness !== undefined && witness.incarnation !== null ? { owner: witness.owner, incarnation: witness.incarnation } : undefined;
|
|
256
|
+
const pin = async () => (pinned ??= await occupantOf?.(sessionId));
|
|
257
|
+
const put = async (landed, eventId, entryId) => {
|
|
258
|
+
const out = await seat.putAnchors(sessionId, landed, [{ eventId, entryId }], owner);
|
|
259
|
+
if (!out.landed)
|
|
260
|
+
throw new Error("the session's occupant is no longer this run's — the anchor was not written");
|
|
261
|
+
};
|
|
262
|
+
return {
|
|
263
|
+
...(promptKey !== undefined
|
|
264
|
+
? {
|
|
265
|
+
prompt: async (entryId, held) => {
|
|
266
|
+
const landed = await pin();
|
|
267
|
+
if (landed !== undefined && held())
|
|
268
|
+
await put(landed, promptKey, entryId);
|
|
269
|
+
},
|
|
270
|
+
}
|
|
271
|
+
: {}),
|
|
272
|
+
...(leafOf !== undefined
|
|
273
|
+
? {
|
|
274
|
+
turn: async (eventId, held) => {
|
|
275
|
+
const landed = await pin();
|
|
276
|
+
if (landed === undefined || !held())
|
|
277
|
+
return;
|
|
278
|
+
const leaf = await leafOf(sessionId);
|
|
279
|
+
if (leaf)
|
|
280
|
+
await put(landed, eventId, leaf);
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
: {}),
|
|
284
|
+
};
|
|
244
285
|
}
|
|
245
286
|
export class TurnAnchorCapture {
|
|
246
287
|
capture;
|
|
@@ -249,6 +290,7 @@ export class TurnAnchorCapture {
|
|
|
249
290
|
firstTextEventId;
|
|
250
291
|
turnHadTool = false;
|
|
251
292
|
promptCommit = createPromptCommitReader();
|
|
293
|
+
promptLanding = Promise.resolve();
|
|
252
294
|
constructor(capture, leg, captureUser) {
|
|
253
295
|
this.capture = capture;
|
|
254
296
|
this.leg = leg;
|
|
@@ -261,8 +303,20 @@ export class TurnAnchorCapture {
|
|
|
261
303
|
const committed = { type: "message_committed", role, entryId };
|
|
262
304
|
const prompt = this.promptCommit(committed);
|
|
263
305
|
const captureUser = this.captureUser;
|
|
264
|
-
if (prompt
|
|
265
|
-
|
|
306
|
+
if (prompt === undefined || !captureUser)
|
|
307
|
+
return;
|
|
308
|
+
const prior = this.promptLanding;
|
|
309
|
+
let landed;
|
|
310
|
+
this.promptLanding = new Promise((resolve) => { landed = resolve; });
|
|
311
|
+
await settleResumeAnchor(async (held) => {
|
|
312
|
+
try {
|
|
313
|
+
await prior;
|
|
314
|
+
await captureUser(prompt, held);
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
landed();
|
|
318
|
+
}
|
|
319
|
+
}, { leg: this.leg, kind: "prompt" });
|
|
266
320
|
}
|
|
267
321
|
onText(eventId) {
|
|
268
322
|
if (this.firstTextEventId === undefined) {
|
|
@@ -278,7 +332,7 @@ export class TurnAnchorCapture {
|
|
|
278
332
|
const capture = this.capture;
|
|
279
333
|
const handle = this.firstTextEventId;
|
|
280
334
|
if (handle && !this.turnHadTool && capture)
|
|
281
|
-
await settleResumeAnchor(() => capture(handle), { leg: this.leg, kind: "turn" });
|
|
335
|
+
await settleResumeAnchor((held) => capture(handle, held), { leg: this.leg, kind: "turn" });
|
|
282
336
|
this.firstTextEventId = undefined;
|
|
283
337
|
this.turnHadTool = false;
|
|
284
338
|
}
|
|
@@ -388,6 +442,7 @@ export async function runInBackground(runner, spec, runStore, taskId, parkCommit
|
|
|
388
442
|
await sink.appendParked(word, grafted);
|
|
389
443
|
const sealed = sealResultForExit(grafted);
|
|
390
444
|
reached = { kind: word, result: sealed };
|
|
445
|
+
await acceptance?.settle(sealed);
|
|
391
446
|
const committed = await commitParkRow({
|
|
392
447
|
runStore, taskId, word, result: sealed, card: { token, sessionId: spec.sessionId }, cards: checkpointCards, leg: "bg",
|
|
393
448
|
legId: parkCommit.legId, staleWindowMs: parkCommit.runStaleSec === undefined ? undefined : parkCommit.runStaleSec * 1000,
|
|
@@ -396,7 +451,6 @@ export async function runInBackground(runner, spec, runStore, taskId, parkCommit
|
|
|
396
451
|
reached = undefined;
|
|
397
452
|
settledAsCancel = committed.row?.errorCode === CANCELLED_CODE;
|
|
398
453
|
}
|
|
399
|
-
acceptance?.settle(sealed);
|
|
400
454
|
};
|
|
401
455
|
const settleLegResult = async (engineResult) => {
|
|
402
456
|
const result = atHostBoundary(engineResult);
|
|
@@ -410,10 +464,10 @@ export async function runInBackground(runner, spec, runStore, taskId, parkCommit
|
|
|
410
464
|
const safe = await withModelUsage(sealResultForExit(settled));
|
|
411
465
|
await sink.appendDone(safe);
|
|
412
466
|
reached = { kind: "done", result: safe };
|
|
467
|
+
await acceptance?.settle(safe);
|
|
413
468
|
const plane = outwardPlane(safe.terminal);
|
|
414
469
|
await runStore.setTerminal(taskId, plane.status, safe, plane.errorMessage ?? null);
|
|
415
470
|
await releaseKeyIfZeroWorkRefusal(runStore, taskId, safe);
|
|
416
|
-
acceptance?.settle(safe);
|
|
417
471
|
};
|
|
418
472
|
const instructionLeg = createInstructionSelectionLeg();
|
|
419
473
|
const sink = createLedgerSink({ appendEvent: (seq, type, data) => runStore.appendEvent(taskId, seq, type, data), persistThinking, notifiedKeys, onActivity: (kind, statusData) => recordTurnActivity(taskId, kind, statusData), legSections: () => ({ instructions: instructionLeg.segment(), skills: runSkills }), usage: { modelUsage, taskId } });
|
|
@@ -609,12 +663,12 @@ export async function runInBackground(runner, spec, runStore, taskId, parkCommit
|
|
|
609
663
|
if (reached?.kind === "done") {
|
|
610
664
|
const plane = outwardPlane(reached.result.terminal);
|
|
611
665
|
settledAsCancel = failureCodeOf(reached.result.terminal) === CANCELLED_CODE;
|
|
666
|
+
await acceptance?.settle(reached.result);
|
|
612
667
|
await runStore.setTerminal(taskId, plane.status, reached.result, plane.errorMessage ?? null);
|
|
613
668
|
await releaseKeyIfZeroWorkRefusal(runStore, taskId, reached.result);
|
|
614
|
-
acceptance?.settle(reached.result);
|
|
615
669
|
}
|
|
616
670
|
else if (reached !== undefined) {
|
|
617
|
-
acceptance?.settle(reached.result);
|
|
671
|
+
await acceptance?.settle(reached.result);
|
|
618
672
|
}
|
|
619
673
|
else if (thrownCancelCause === undefined && observedDone !== undefined && heldParkOf(atHostBoundary(observedDone)) !== undefined) {
|
|
620
674
|
recordFailOpen("server.runs.terminal-ledger-write-failed", `arm=park-held ${message}`);
|
|
@@ -92,8 +92,9 @@ export declare function compileCommandPolicyLayers(rules: CommandRule[] | undefi
|
|
|
92
92
|
* `plan` 是有出口的**生命周期词**(`plan_review` 把计划带出 plan),不是围栏:它是**提交入口的模式词地板**({@link autonomyModeFloor}),
|
|
93
93
|
* 盖在每一个 spec 出生点一次(词 = {@link entryPermissionMode} 的 `effective`):受理门盖进存储的提交体(`task-settings.ts` `stampEntryPermissionMode`)、run-local 盖在它自建的 spec 上、
|
|
94
94
|
* leader run 盖在它出生时的入口体上(`leader/run-entry.ts`;入口词是 `plan` 的 leader run 进不了那条车道 —— worker 会话没有计划审阅通道 ⇒ 受理口响亮拒)。此后一条 run 的模式词
|
|
95
|
-
* 只有存储体一个源,写者是每一个出生点(新的持久化写都经 `http/checkpoint-ctx.ts` `buildCheckpointCtx`)
|
|
96
|
-
*
|
|
95
|
+
* 只有存储体一个源,写者是每一个出生点(新的持久化写都经 `http/checkpoint-ctx.ts` `buildCheckpointCtx`)、`plan_review` 写回与续跑口(停驻 run 的存储体被重放之前过一次**现**地板、
|
|
96
|
+
* 钳过的随 CAS 赢点写回;`permission-mode-admission.ts` `stampReplayEntryMode`,写据说那一格是地板的出口 —— `plan_review` 批准 —— 写下的且仍是它写下的那一格 ⇒ 原样读)。按段折一个模式词 = 第二个源:
|
|
97
|
+
* 被批准的计划会在下一次挂起→续跑被拉回 plan;续跑口不是按段折 —— 它与提交口同一只入口一步,写的是同一个源,且不碰出口写下的那一格。收紧入参的型上因此没有 `permissionMode`(`governance-overrides.ts`)。(上一个发布版本里本档不碰模式词,按段折的是只读手 +
|
|
97
98
|
* 写面 `roots`、与 `read-only` 同形 —— 运维 plan 那时根本不进 plan 模式,见下一段。)
|
|
98
99
|
*
|
|
99
100
|
* 🔴 **为什么 `plan` 不再与 `read-only` 同形**:修前两档同映「只读手 + roots」,外加 `resolve-spec.ts` 见只读手就剥委派工具 —— 于是 `plan` 有三套
|
|
@@ -145,8 +146,8 @@ export interface EntryPermissionMode<W extends PermissionMode | undefined = Perm
|
|
|
145
146
|
* 无人值守腿(`unattended-permission-mode.ts` `withUnattendedLeg`:`default` 钳在 spec 的词之下);
|
|
146
147
|
* · 「这个词会变成什么」的读者 —— 能力面写面开不开({@link autonomyKeepsOpenWriteFace}:bypass 声明过地板)、能力面 auto 读面
|
|
147
148
|
* (`auto-mode-face.ts` `judgeAutoModeArming`:意图过地板;`clamped` 且不是 auto ⇒ 未武装原因 `operator_floor`)、
|
|
148
|
-
*
|
|
149
|
-
* `test/entry-permission-mode.test.ts` 按语法树钉:core 钳在 `src/`
|
|
149
|
+
* 受理判官的入口一步(`permission-mode-admission.ts` `entryStep`:提交口盖章、在飞切档口、续跑口 —— 停驻 run 的存储体被重放之前过**现**地板 —— 三口同经这一处)。
|
|
150
|
+
* `test/entry-permission-mode.test.ts` 按语法树钉:core 钳在 `src/` 只此一处调用,本函数七处调用点各一次。
|
|
150
151
|
*/
|
|
151
152
|
export declare function entryPermissionMode<W extends PermissionMode | undefined>(word: W, floor: PermissionMode | undefined): EntryPermissionMode<W>;
|
|
152
153
|
/**
|
package/dist/security.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import type { EntriesStreamOptions } from "./session-sync-kernel.js";
|
|
2
3
|
import { type SessionHead, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
|
|
3
4
|
import type { ServiceConfig } from "./config-types.js";
|
|
4
5
|
import type { Logger } from "./observability/logger.js";
|
|
@@ -9,6 +10,8 @@ import type { TaskRequestBody } from "./http/wire-types.js";
|
|
|
9
10
|
import type { StagingHandle } from "./session-sync-kernel.js";
|
|
10
11
|
import type { SessionDeletionFace } from "./session-deletion.js";
|
|
11
12
|
import { type SessionBirth } from "./session-incarnation.js";
|
|
13
|
+
import { type IdleSession, type IdleSessionCursor, type SessionKind, type SessionKindReading } from "./session-kind.js";
|
|
14
|
+
import type { SessionListQuery } from "./plugins/store-contracts.js";
|
|
12
15
|
import type { ClientSessionRowWrite, ReplaySessionRowWrite, ReplaySessionRowWriteOutcome, SessionRowAnswer, SessionRowPatch, SessionRowWriteOutcome } from "./session-row.js";
|
|
13
16
|
import type { ExecutionPlacementSeat } from "./execution-placement.js";
|
|
14
17
|
import type { SessionUnreadable } from "./session-error-wire.js";
|
|
@@ -56,6 +59,10 @@ export interface SessionListItem {
|
|
|
56
59
|
* by a fork after lineage was recorded (an older fork is not backfilled: its source is unknown). OMIT-when-absent, never `null`. Additive key, passed
|
|
57
60
|
* through unprojected (`sessions-list.ts`). Same name and meaning as `SessionSummary.forkedFrom` in `plugins/store-contracts.ts`. */
|
|
58
61
|
forkedFrom?: string;
|
|
62
|
+
/** The session's kind (`session-kind.ts`): present-iff the session was created by a submission that declared `sessionKind`; a top-level session
|
|
63
|
+
* never carries it (OMIT-when-absent, never `null`). The default list view lists only top-level sessions; `?sessionKind=<word>` lists that kind.
|
|
64
|
+
* Additive key, passed through unprojected (`sessions-list.ts`). Same name and meaning as `SessionSummary.sessionKind` in `plugins/store-contracts.ts`. */
|
|
65
|
+
sessionKind?: SessionKind;
|
|
59
66
|
}
|
|
60
67
|
/**
|
|
61
68
|
* 会话店的行格写原语(规则与判序:`session-row.ts` 头注「写原语」)—— 按入口分两只重载:客户端写(PATCH)的结局闭集四员;行重放(2c 导入落定后的那一笔)
|
|
@@ -74,7 +81,7 @@ export interface SessionRowCellsWriter {
|
|
|
74
81
|
* 🔴 2026-08-01 复审逮到:守卫原本是**逐条路由白名单**(`PUT …/policy`、`POST …/sync/import`),
|
|
75
82
|
* 而 `DELETE /v1/sessions/:id`(删整条会话)不在其中 —— 同一风险形、爆炸半径**更大**,却没门。
|
|
76
83
|
*
|
|
77
|
-
* 风险形逐字同源(守卫自己的注释)
|
|
84
|
+
* 风险形逐字同源(守卫自己的注释):「请求没带凭据门认的凭据 + 未开 `ALLOW_UNAUTHED_WRITES`」这一形下
|
|
78
85
|
* fleet 写档(面表 fleet 列的 `dev_open` 格,`owner-faces.ts` 的 `listFilterOf`)判 fleet-wide ⇒ 集群内**任意**不报主体的调用方可对**任意** session 动手(报了主体的调用方只动得到那位主体的,`principal-gate.ts` 的 `actsForDeployment`)。
|
|
79
86
|
* policy 腿担心的是「forged principal 能 tighten/DoS 一个会话的工具」;DELETE 直接把会话删掉。
|
|
80
87
|
*
|
|
@@ -104,6 +111,10 @@ export type SessionOwnerCell = {
|
|
|
104
111
|
export declare function claimCallerOf(subject: Subject | undefined, config: DeploymentShapeInput<"principal">): Caller;
|
|
105
112
|
/** 提交挂接「没有这只会话」那一答的句子(requireExisting 缺行与认领面看不见同一句;投影 `attach_absent`)。 */
|
|
106
113
|
export declare const ATTACH_ABSENT_MESSAGE = "requireExistingSession: session does not exist (resume.session_not_found)";
|
|
114
|
+
/** 带种类的提交撞上一只种类不同的既有会话的 409(律 `session-kind.ts`):体上机读位 `sessionKind` = 行上的词(顶层行缺席)。句子不回显请求的词以外的任何行事实。 */
|
|
115
|
+
export declare const SESSION_KIND_MISMATCH_MESSAGE = "this session already exists with a different session kind \u2014 a session's kind is written once, when the session is created, and never changes; send the same sessionKind the session was created with, omit sessionKind to run the session as it is, or start a new session";
|
|
116
|
+
/** 部署记不了种类(会话店没有出生回执面 / 种类读)⇒ 400 `request.precondition_unmet`(受理门读同一只能力事实 `capability-facts.ts` 的 `sessionKinds`,先拒在那里;这里是纵深)。 */
|
|
117
|
+
export declare const SESSION_KIND_UNRECORDABLE_MESSAGE = "sessionKind requires a session store that records a session's kind and ages such sessions out (DB_BACKEND=mysql|pg|local) \u2014 this deployment cannot, so the session would be created as a top-level conversation; capabilities.sessionKinds lists the kinds a deployment accepts";
|
|
107
118
|
/** 读一只会话行的 {@link SessionOwnerCell}:有主行 = 属主那一格(`owner-faces.ts` 的 `ownerCellOf`,属主列读数的唯一铸法);无主时问一次店的 `placementOf`
|
|
108
119
|
* (既有读口;店不交它 = 不实现 placement = 没有 placed 行)。`owner` = 调用点那一读。 */
|
|
109
120
|
export declare function sessionOwnerCellOf(store: Pick<OwnerAwareSessionStore, "placementOf"> | undefined, sessionId: string, owner: string | null): Promise<SessionOwnerCell>;
|
|
@@ -141,29 +152,19 @@ export type OwnerAwareSessionStore = SessionStore & {
|
|
|
141
152
|
* `includeUnowned` = [ref] 窄互认第二臂的**第三条件**(`owner IS NULL`)的 SQL 承载位:置真时
|
|
142
153
|
* 谓词放宽为 `owner = ? OR owner IS NULL`。只在 `owner` 在场时有意义(路由已判①③);`owner` 缺席
|
|
143
154
|
* (fleet-wide)时本位无效——那一面本来就不钉 owner。 */
|
|
144
|
-
listSessions?: (opts:
|
|
145
|
-
owner?: string;
|
|
146
|
-
includeUnowned?: boolean;
|
|
147
|
-
cursor?: {
|
|
148
|
-
lastActivityAt: string;
|
|
149
|
-
sessionId: string;
|
|
150
|
-
};
|
|
151
|
-
limit: number;
|
|
152
|
-
q?: string;
|
|
153
|
-
}) => Promise<SessionListItem[]>;
|
|
155
|
+
listSessions?: (opts: SessionListQuery) => Promise<SessionListItem[]>;
|
|
154
156
|
/** The SAME list face as {@link listSessions} (same SELECT, same mapper, same predicate and keyset) with each row's occupant — the row's owner and
|
|
155
157
|
* incarnation as read in that one read. The incarnation never enters the row (it is not a wire fact: `session-incarnation.ts`); this pair is for the
|
|
156
158
|
* in-process reader that must address a row by occupant — the peer directory's `PeerSessionRecord.occupant`. `listSessions` is this face's rows. */
|
|
157
|
-
listSessionRows?: (opts:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
limit: number;
|
|
165
|
-
|
|
166
|
-
}) => Promise<Array<SessionRowAnswer<SessionListItem>>>;
|
|
159
|
+
listSessionRows?: (opts: SessionListQuery) => Promise<Array<SessionRowAnswer<SessionListItem>>>;
|
|
160
|
+
/** 按 id 的种类读(律 `session-kind.ts`;授权口的种类判与会话视图的 `sessionKind` 读它):读到它时行上的住客 + 种类。三只持久店都交,包装原样转发。 */
|
|
161
|
+
sessionKindOf?: (sessionId: string) => Promise<SessionKindReading | undefined>;
|
|
162
|
+
/** 老化候选面(律 `session-kind.ts`;唯一读者 = 维护拍的老化腿 `boot/session-age-out.ts`):种类为 `kind`、最后活动早于 `idleBefore`、当下无活引用的会话(在删的照交),
|
|
163
|
+
* 最老先出、`(lastActivityAt, sessionId)` 升序 keyset 续页(`after` = 上一页最后一条)。与 `listPlaced`、删除面 `pending()` 同族的用途专一枚举 —— 不出列表投影。 */
|
|
164
|
+
listIdleOfKind?: (kind: SessionKind, idleBefore: Date, page: {
|
|
165
|
+
readonly after?: IdleSessionCursor;
|
|
166
|
+
readonly limit: number;
|
|
167
|
+
}) => Promise<IdleSession[]>;
|
|
167
168
|
/** ONE session's list row — the SAME projection {@link listSessions} emits for it (same columns, same mapper). `undefined` = not a
|
|
168
169
|
* row of the list face (no such session, or a placed / delegation-transcript session, which never lists). Reader: the 2c
|
|
169
170
|
* manifest (`title` / `pinned`). */
|
|
@@ -215,10 +216,7 @@ export type OwnerAwareSessionStore = SessionStore & {
|
|
|
215
216
|
* `opts.batchSize` is the page size (default 500). Resolves to `null` (NOT an empty iterable) when the session does
|
|
216
217
|
* not exist (the existence probe is async — `session_meta` first, like {@link exportEntries} — so the method returns
|
|
217
218
|
* a Promise of the iterable-or-null; the iterable itself then pages lazily). The read half of exportEntries, paged. */
|
|
218
|
-
exportEntriesStream?: (sessionId: string, opts
|
|
219
|
-
afterSeq?: number;
|
|
220
|
-
batchSize?: number;
|
|
221
|
-
}) => Promise<AsyncIterable<SessionTreeEntry> | null>;
|
|
219
|
+
exportEntriesStream?: (sessionId: string, opts: EntriesStreamOptions) => Promise<AsyncIterable<SessionTreeEntry> | null>;
|
|
222
220
|
/** 2c session-sync — IMPORT a verbatim entry log into `sessionId`, re-stamping `owner` to the
|
|
223
221
|
* authenticated importing principal (never the bundle's). The log is passed through core's
|
|
224
222
|
* `validateEntriesForImport` (the single fail-closed invariant gate) before any write. */
|
|
@@ -303,7 +301,7 @@ export interface AuthContext {
|
|
|
303
301
|
* `PROJECT_ID_REGEX` 门后折小写回传;[ref]/[ref] 宽读严写 —— 词法带 /i 收下大写形,但派生 scope 键
|
|
304
302
|
* 与 config.projects 查表都只认这一个归一形,否则同一个项目会按大小写分成两只记忆盘)。
|
|
305
303
|
* 身份半场(scope 的 tenant 段)永远来自 verified principal — projectId 只选「哪个项目盘/哪条登记」
|
|
306
|
-
* (config.projects 查表键 + proj: 键的 projectId 段),不是 capability
|
|
304
|
+
* (config.projects 查表键 + proj: 键的 projectId 段),不是 capability。装配器拿它判 defaultScopes 种子项目(对提交者可见才算,`project-registry.ts`)。 */
|
|
307
305
|
resolvedProjectId?: string;
|
|
308
306
|
}
|
|
309
307
|
/** 授权口的入参:请求、体,与提交出口收候选的口(`submission-exit.ts`;只有登记了新行才调,传了也可能一次不调)。 */
|
|
@@ -385,9 +383,9 @@ export declare const CHECKPOINT_PUBLIC_SCOPE: "_";
|
|
|
385
383
|
*
|
|
386
384
|
* 写侧不是本仓能单方面改的:core 的 `treeScope = reviveClaim?.row.scope ?? ctx.principal ??
|
|
387
385
|
* opts.background?.scope` 同时喂**进程内** `defaultTaskRegistry` 与 **durable** 行,而本仓/`core` 全域的
|
|
388
|
-
*
|
|
389
|
-
* `sessionTenantScope`(删除协调器的子代 / 信箱 / 后台 shell 三腿)、`http/routes/runs.ts` 的 subagent
|
|
390
|
-
*
|
|
386
|
+
* 读侧经唯一换算 `engine-identity.ts` 的 `engineScopeOf` / `engineScopeOfOwner`(匿名 ⇒ `"default"`;读者:`runs.ts` markStopSourceForOwner、
|
|
387
|
+
* 会话的引擎租户分区 `session-children-retire.ts` `sessionTenantScope`(删除协调器的子代 / 信箱 / 后台 shell 三腿)、`http/routes/runs.ts` 的 subagent
|
|
388
|
+
* output/stream 与句柄三口、`agents-roster.ts`、`fleet.ts` 的工作流行)。⇒ **把铸点改成 `"_"` 会把这一整族读者一起打瞎**(本车实测:`subagent-tail-content-supply`
|
|
391
389
|
* 的 tail 建连当场 404)。所以归一只能发生在**读侧**:checkpoint 侧拿着 `"_"` 去查 bg 分区时,
|
|
392
390
|
* 显式把这两个键当同一格。
|
|
393
391
|
*/
|
|
@@ -396,9 +394,9 @@ export declare const BACKGROUND_REGISTRY_ANON_SCOPE: "default";
|
|
|
396
394
|
* checkpoint 的 scope → 该在哪些 **bg 注册簿分区**里找它的 parked 子代([ref])。
|
|
397
395
|
*
|
|
398
396
|
* 匿名(`"_"`)⇒ 两个都查:`"_"`(将来若统一了写侧)与 `"default"`(今天 core 真写下去的那个)。
|
|
399
|
-
* 其余 ⇒
|
|
400
|
-
*
|
|
401
|
-
*
|
|
397
|
+
* 其余 ⇒ 引擎那一格单查:停驻行的 scope 列是**主体**,bg 行是引擎按它的任务 scope 写的(落点今天只写人)⇒ 经唯一换算
|
|
398
|
+
* `engine-identity.ts` 的 `engineScopeOfOwner`:没带场景的主体逐字节同(两套约定折出同一个串),带场景的主体 ⇒ 那个人;
|
|
399
|
+
* 不存在第二个候选。多租户部署里一个**真名叫 `default`** 的租户只匹配自己那格 —— 所以别把别名做成双向。
|
|
402
400
|
*/
|
|
403
401
|
export declare function backgroundScopesForCheckpointScope(scope: string): readonly string[];
|
|
404
402
|
/** Encode a subject (the partition key — `owner-brands.ts`; or none) as the checkpoint `scope` column value. A row owner read back from a store is the
|