@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
|
@@ -87,6 +87,8 @@ export type DrainEntryAnswer = DrainReceipt | DrainDeadlineRefusal;
|
|
|
87
87
|
* `session-resident-background.ts` 头注)· retain 的后台 shell · 只读订阅流(只进 `attachedStreams`)。
|
|
88
88
|
* 四项在同一次读里求出(`http/server.ts` 的 `inflightBreakdown` 是唯一的分项函数,两个和都读它),`/health` 的 `inflight` 与 `inflightBreakdown` 因此永远自洽,
|
|
89
89
|
* 判停与 `/health` 也不会各有一份算法。只有这两个函数各写一次这两个和,没有第三张计法表。
|
|
90
|
+
* 第三个读数 `/health.engineLease.attached`(附着流条数,[ref])进的是**同一张**计法表(契约「附着」一列:每一类活进不进它),不是第二套计数:
|
|
91
|
+
* 它读 {@link DrainState.attachedStreams} —— 自退判据第一合取读的那一只(`http/dispatch.ts` 的开放响应集 × SSE 章,定义只此一处)。
|
|
90
92
|
*/
|
|
91
93
|
export interface InflightBreakdown {
|
|
92
94
|
readonly http: number;
|
|
@@ -128,6 +130,8 @@ export interface DrainState {
|
|
|
128
130
|
/** [ref]:首个**非探针**请求的单调时刻(`null` = 还没有过)。与 `lastActivityAt` 同一个写者(`http/server.ts` 的活性打点)、写一次就定;
|
|
129
131
|
* 读者 = 租约腿的候首触态(`boot/engine-lease.ts`)与 `/health.engineLease.firstAttach.attachedAt`。 */
|
|
130
132
|
firstActivityAt?: () => number | null;
|
|
133
|
+
/** 本副本此刻打开着的 SSE 流条数(`createHttpServer` 自赋;定义只此一处)。读者:附着租约自退判据的第一合取、`/health.engineLease.attached`(经租约腿的读数)—— 同一只读口,
|
|
134
|
+
* 不另数。语义是**附着流条数,不是活跃调用方**:订阅流与流式提交腿算,后台腿 / 无流同步腿不算(契约计法表「附着」列);纯轮询壳读到 0 合法。 */
|
|
131
135
|
attachedStreams?: () => number;
|
|
132
136
|
lastAttachEndedAt?: () => number;
|
|
133
137
|
/** [ref]:附着租约窗的读口(`/health.engineLease`)。收尾链在**装了租约腿**时才装它,读口现读租约腿的把手 —— 腿还在观察才有读数,未装配的盒子里根本没有这只口。 */
|
|
@@ -20,22 +20,17 @@
|
|
|
20
20
|
* 注入了读数也不读;所以「`/health` 不报 `leaseState` 而准入照按租约拒」这一形构造不出来。
|
|
21
21
|
* **身份不是引擎态**:`instanceId`(本进程起步自铸的那一只,`boot/stage-03` 的 uuidv7)是体的身份,只在两出口体的**顶层**说一次,
|
|
22
22
|
* 铸点不读它、契约形里不重复它。
|
|
23
|
-
* 5.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* 是构造出来的,不靠「唯一入口整组写四键」这条运行时不变量(那条不变量只管就绪原因与事实一致)。
|
|
29
|
-
* 心跳体 = 契约 `InstanceAnnouncement` + 嵌套键这一只:契约包 10.x 的心跳形还没有它的座位,10.x 中心按默认 strip 解析丢掉它、照收心跳;
|
|
30
|
-
* 世代账扁平两键契约心跳形没有座位,只上 `/health`(嵌套形里有,两出口都带)。非 fleet 部署的扁平键与 7.122.0 逐字同。
|
|
31
|
-
* 收缩:扁平布尔对(`draining` / `drainingSince`)settings-schema 12.0.0 从契约形删、本引擎 7.124.0+ 删发(届时删它们的投影);嵌套键名在
|
|
32
|
-
* 契约包自有这只常量的那一版提货时改读它。
|
|
23
|
+
* 5. **一形**:引擎态只在体上的一只键 `engineSignal`(契约包 `ENGINE_SIGNAL_KEY`,本仓不另拼)下说,值 = 契约 `EngineSignal` 整只({@link buildEngineSignal})。
|
|
24
|
+
* 心跳体 = 契约 `InstanceAnnouncement`(身份 + `modelRefusals`)+ 这一只键 —— 8.0 扁平方言(平铺 `ready` / 布尔 `draining` / `restart` / 成员三键)
|
|
25
|
+
* 随契约包 26.0.0 从心跳形删除,本引擎同版停发;`/health` 的平铺排空对(布尔 `draining` + `drainingSince`)同版停发。`/health` 上其余与信号同名的顶层键
|
|
26
|
+
* (`restart` / 成员三键 / 世代账)是本仓自己的诊断面 wire(契约 `InstanceHealth` 从未给它们座位,读方是 sdk 的 `/health` 读型),投影仍全在本模块
|
|
27
|
+
* ({@link fleetMembershipKeys} / {@link healthConfigLedgerKeys}),出口文件不拼引擎态的键。
|
|
33
28
|
* 6. **租约四态的词表属主是契约包**(`LeaseState`):本模块的读数型 {@link ServingLeaseView} 按它逐词对齐(下面的编译期断言两向钉),
|
|
34
29
|
* 契约加一个词 ⇒ 本仓编译红,不会悄悄多出一个本仓读不出的态。
|
|
35
30
|
*
|
|
36
|
-
* 模块形:纯函数(
|
|
31
|
+
* 模块形:纯函数(契约包只取型与键名常量 `ENGINE_SIGNAL_KEY`;本仓值 import 只有两只纯叶 `http/readiness.ts` 与 `fleet/drain-entry.ts`)—— `http/` 与 `fleet-client.ts` 都读它,不许长出回环。
|
|
37
32
|
*/
|
|
38
|
-
import type
|
|
33
|
+
import { ENGINE_SIGNAL_KEY, type EngineDraining, type EngineSignal, type LeaseState, type RestartSignal } from "@sema-agent/settings-schema/fleet";
|
|
39
34
|
import { type ReadinessInputs, type ReadinessVerdict } from "../http/readiness.js";
|
|
40
35
|
/**
|
|
41
36
|
* 租约此刻的读数(租约客户端交出;纯数据)。态的词表 = 契约 `LeaseState`(四词的语义在契约注里:`none` 不生效 / `granted` 持有 /
|
|
@@ -52,8 +47,8 @@ export type ServingLeaseView = {
|
|
|
52
47
|
} | {
|
|
53
48
|
readonly state: Extract<LeaseState, "denied">;
|
|
54
49
|
};
|
|
55
|
-
/**
|
|
56
|
-
export type FleetMembershipKeys = Pick<
|
|
50
|
+
/** `/health` 上的 fleet 成员三键 —— 类型取自契约 `EngineSignal` 的同名键(拼法与值域只有契约一个写者)。 */
|
|
51
|
+
export type FleetMembershipKeys = Pick<EngineSignal, "generation" | "leaseState" | "leaseUntil">;
|
|
57
52
|
/** 非 fleet 成员 / 没装租约客户端时的读数(唯一拼法)。成员的推定围栏只住在租约客户端里,不进这只缺省值。 */
|
|
58
53
|
export declare const LEASE_NONE: ServingLeaseView;
|
|
59
54
|
/**
|
|
@@ -148,12 +143,7 @@ export interface EngineSignalFacts {
|
|
|
148
143
|
}
|
|
149
144
|
/** **唯一**铸点(活判,每次调用现读输入)。 */
|
|
150
145
|
export declare function mintEngineSignal(deps: EngineSignalInputs): EngineSignalFacts;
|
|
151
|
-
/**
|
|
152
|
-
* 两出口体上嵌套引擎信号的键名(规则 5;两出口同一只拼法)。契约包 10.x 没有这只常量(它的心跳形也没有这一座位);契约包自有它的那一版
|
|
153
|
-
* 提货时,本常量删、改读契约包的。
|
|
154
|
-
*/
|
|
155
|
-
export declare const ENGINE_SIGNAL_KEY = "engineSignal";
|
|
156
|
-
/** 体上的嵌套引擎信号:键 {@link ENGINE_SIGNAL_KEY},值 = 契约 `EngineSignal`。 */
|
|
146
|
+
/** 体上的嵌套引擎信号:键 = 契约包的 `ENGINE_SIGNAL_KEY`(两出口同一只拼法,本仓不另拼),值 = 契约 `EngineSignal`。 */
|
|
157
147
|
export type EngineSignalCarrier = {
|
|
158
148
|
readonly [ENGINE_SIGNAL_KEY]: EngineSignal;
|
|
159
149
|
};
|
|
@@ -163,18 +153,11 @@ export type EngineSignalCarrier = {
|
|
|
163
153
|
*/
|
|
164
154
|
export declare function buildEngineSignal(s: EngineSignalFacts): EngineSignal;
|
|
165
155
|
/**
|
|
166
|
-
* fleet 成员身份三键的**唯一**投影(
|
|
167
|
-
* 在场律:非 fleet 成员(无 `generation`)⇒
|
|
156
|
+
* fleet 成员身份三键的**唯一**投影(嵌套信号与 `/health` 顶层同调,同值同序):`generation` / `leaseState` / `leaseUntil`。
|
|
157
|
+
* 在场律:非 fleet 成员(无 `generation`)⇒ 空对象;成员 ⇒ `generation` + `leaseState` 恒在,
|
|
168
158
|
* `leaseUntil` 只在 `granted`。
|
|
169
159
|
*/
|
|
170
160
|
export declare function fleetMembershipKeys(s: EngineSignalFacts): FleetMembershipKeys;
|
|
171
|
-
/** 心跳的 8.0 扁平方言 `ready` / `draining`(恒带,`false` 也带):`ready` = 就绪判,`draining` = 排空事实在场(规则 5,与嵌套形读同一个字段)。 */
|
|
172
|
-
export declare function heartbeatReadinessKeys(s: EngineSignalFacts): Pick<InstanceAnnouncement, "ready" | "draining">;
|
|
173
|
-
/** `/health` 的 8.0 扁平排空对:只在排空中带 —— `draining: true` + `drainingSince` = 排空事实的 `since`(规则 5,与嵌套形读同一个字段)。 */
|
|
174
|
-
export declare function healthDrainingKeys(s: EngineSignalFacts): {
|
|
175
|
-
readonly draining?: true;
|
|
176
|
-
readonly drainingSince?: number;
|
|
177
|
-
};
|
|
178
161
|
/**
|
|
179
162
|
* `/health` 的世代账扁平键(未接线 ⇒ 全缺席):target / applied 两版本(与嵌套形同一次读数)+ 两只收货序数(进程内单调,「见过多少代 / 停在哪一代」
|
|
180
163
|
* 的推进判据)+ `configApplyStaleMs`(两者持续不等的时长,收敛即缺席)。只上 `/health`(契约心跳形没有这些座位)。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ENGINE_SIGNAL_KEY } from "@sema-agent/settings-schema/fleet";
|
|
1
2
|
import { readinessOf } from "../http/readiness.js";
|
|
2
3
|
import { drainingFactOf } from "./drain-entry.js";
|
|
3
4
|
export const LEASE_NONE = Object.freeze({ state: "none" });
|
|
@@ -37,7 +38,6 @@ export function mintEngineSignal(deps) {
|
|
|
37
38
|
...(configApply !== undefined ? { configApply } : {}),
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
export const ENGINE_SIGNAL_KEY = "engineSignal";
|
|
41
41
|
export function buildEngineSignal(s) {
|
|
42
42
|
return {
|
|
43
43
|
ready: s.verdict.ready,
|
|
@@ -64,12 +64,6 @@ export function fleetMembershipKeys(s) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
export function heartbeatReadinessKeys(s) {
|
|
68
|
-
return { ready: s.verdict.ready, draining: s.draining !== undefined };
|
|
69
|
-
}
|
|
70
|
-
export function healthDrainingKeys(s) {
|
|
71
|
-
return s.draining === undefined ? {} : { draining: true, drainingSince: s.draining.since };
|
|
72
|
-
}
|
|
73
67
|
export function healthConfigLedgerKeys(s) {
|
|
74
68
|
const g = s.configApply;
|
|
75
69
|
if (g === undefined)
|
package/dist/fleet-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InstanceAnnouncement, UsageReport, DEFAULT_HEARTBEAT_MS, readCapabilityReading } from "@sema-agent/settings-schema/fleet";
|
|
2
|
-
import {
|
|
1
|
+
import { ENGINE_SIGNAL_KEY, InstanceAnnouncement, UsageReport, DEFAULT_HEARTBEAT_MS, readCapabilityReading } from "@sema-agent/settings-schema/fleet";
|
|
2
|
+
import { buildEngineSignal } from "./fleet/engine-signal.js";
|
|
3
3
|
import { centerFetch, centerLaneConfigured } from "./web-admin-client/center-request.js";
|
|
4
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
5
5
|
import { createIdentityBins, pinAccountingIdentity } from "./center-credential.js";
|
|
@@ -153,11 +153,8 @@ export function startFleetClient(opts) {
|
|
|
153
153
|
worker: opts.center.worker,
|
|
154
154
|
address,
|
|
155
155
|
version: opts.version,
|
|
156
|
-
...heartbeatReadinessKeys(signal),
|
|
157
156
|
heartbeatMs,
|
|
158
|
-
...(signal.restart !== undefined ? { restart: signal.restart } : {}),
|
|
159
157
|
...(modelRefusals !== undefined ? { modelRefusals } : {}),
|
|
160
|
-
...fleetMembershipKeys(signal),
|
|
161
158
|
[ENGINE_SIGNAL_KEY]: engineSignal,
|
|
162
159
|
};
|
|
163
160
|
sending = true;
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
* 调用方对一条引擎续跑腿的分类({@link GateCommitment})只说「这条腿到边界时能证什么」,**从不单独铸位** —— 位要有边界作证。
|
|
13
13
|
* 不铸的出口(都在调用点成文):`checkpoint.resume_aborted` 取消(拿不到 resolve 的返回值 ⇒ 证不出)、抛出臂的取消(受理之后也可能走到 ⇒
|
|
14
14
|
* **刻意不带**证据,fail-closed)、4xx、交给宿主 / 新铸一跑 / 同一决定重投的回执(`delivered`,门由别人结清或仍待决)、停驻子代认领到的
|
|
15
|
-
* token 不是选中的那一张(⇒ `409 decide.gate_moved`,不复活)
|
|
16
|
-
* ({@link withoutSettlementEvidence})。
|
|
15
|
+
* token 不是选中的那一张(⇒ `409 decide.gate_moved`,不复活)。
|
|
17
16
|
*
|
|
18
17
|
* ## 读法(三句,契约 §4a「结清证据」同句)
|
|
19
18
|
* · 位在场 ⇒ 门已以此决定结清过(历史证据;与 `errorCode:"cancelled"` 或 `retriable:true` 并存时同样成立 —— 它不证明卡的**当前**状态、
|
|
@@ -57,12 +56,6 @@ export interface GateSettlementEvidence {
|
|
|
57
56
|
export declare const NO_SETTLEMENT_EVIDENCE: GateSettlementEvidence;
|
|
58
57
|
/** **唯一铸点**:一次边界跨越 → 体上的证据片段。 */
|
|
59
58
|
export declare function buildSettlementEvidence(crossing: SettlementCrossing): GateSettlementEvidence;
|
|
60
|
-
/**
|
|
61
|
-
* 一张已带证据的回执被拿去答**另一个**决定(停驻赎回席的反向重试:回放首次受理的那一向、不改判)⇒ 证据两键都摘掉 ——
|
|
62
|
-
* 证据说的是当初被结清的那次决定,这一次请求的决定从没被结清。同向重试是同一次请求的回放,体原样(证据随它)。
|
|
63
|
-
* 只摘、不铸:本模块之外没有第二个写这两键的地方。
|
|
64
|
-
*/
|
|
65
|
-
export declare function withoutSettlementEvidence<B extends Record<string, unknown>>(body: B): Omit<B, keyof GateSettlementEvidence>;
|
|
66
59
|
/** **唯一读法**:这张回决应答说「门已以此决定结清过」吗(`200` 且体上的位为真)。两个读者同调这一只。 */
|
|
67
60
|
export declare function decisionCommittedOf(out: {
|
|
68
61
|
readonly status: number;
|
package/dist/gate-settlement.js
CHANGED
|
@@ -30,10 +30,6 @@ export function buildSettlementEvidence(crossing) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
export function withoutSettlementEvidence(body) {
|
|
34
|
-
const { decisionCommitted: _committed, checkpointId: _identity, ...rest } = body;
|
|
35
|
-
return rest;
|
|
36
|
-
}
|
|
37
33
|
export function decisionCommittedOf(out) {
|
|
38
34
|
return out.status === 200 && out.body.decisionCommitted === true;
|
|
39
35
|
}
|
package/dist/history-anchor.js
CHANGED
|
@@ -2,7 +2,7 @@ import { HttpError } from "./security.js";
|
|
|
2
2
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
3
3
|
import { protocolEntry, readVisibleRun } from "./http/owner-access.js";
|
|
4
4
|
const NO_ANCHOR = "no rewind anchor is recorded under that handle";
|
|
5
|
-
const PROMPT_WITHOUT_ANCHOR = `${NO_ANCHOR}: it names a prompt of this session that recorded none
|
|
5
|
+
const PROMPT_WITHOUT_ANCHOR = `${NO_ANCHOR}: it names a prompt of this session that recorded none`;
|
|
6
6
|
export function anchorReaderOf(req, w, caller) {
|
|
7
7
|
return protocolEntry(req, w, "run.anchor", caller);
|
|
8
8
|
}
|
package/dist/hitl-delivery.d.ts
CHANGED
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
import type { QuestionFrame } from "./question.js";
|
|
17
17
|
import type { ElicitationFrame } from "./elicitation.js";
|
|
18
18
|
import type { ApprovalCardLegFrame, ApprovalRevokeFrame } from "./approval-card.js";
|
|
19
|
-
import type { ToolApprovalFrame } from "./tool-approval.js";
|
|
20
19
|
import type { LedgerEventType } from "./trace/ledger-events.js";
|
|
21
|
-
/** 三族的人在环帧(开 / 收 / 撤)
|
|
22
|
-
export type HitlFrame = QuestionFrame | ElicitationFrame | ApprovalCardLegFrame | ApprovalRevokeFrame
|
|
20
|
+
/** 三族的人在环帧(开 / 收 / 撤)。七个帧型全在账本闭集里(下面那条编译期断言)。 */
|
|
21
|
+
export type HitlFrame = QuestionFrame | ElicitationFrame | ApprovalCardLegFrame | ApprovalRevokeFrame;
|
|
23
22
|
/**
|
|
24
23
|
* 一次投递在各只 sink 上的接下与否 —— **只有这一次投递涉及的 sink 才有键**(不在场 / 不在 `onto` 里的没有键)。
|
|
25
24
|
* 也是 {@link HitlTransport.deliver} 的 `onto` 入参形:值为 `true` 的 sink 才写。
|
package/dist/hitl-delivery.js
CHANGED
|
@@ -17,8 +17,6 @@ function frameKey(frame) {
|
|
|
17
17
|
return `elicitation=${frame.elicitationId}`;
|
|
18
18
|
case "approval_request":
|
|
19
19
|
case "approval_complete":
|
|
20
|
-
case "tool_approval":
|
|
21
|
-
case "tool_approval_complete":
|
|
22
20
|
return `approval=${frame.approvalId}`;
|
|
23
21
|
case "approval_revoke":
|
|
24
22
|
return `batch=${frame.batchId}`;
|
package/dist/hooks/hook-llm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { admitRouteRequest, applyReasoningToRequest, AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS, BrainError, joinRequestUrl, lowestReasoningSeat, mergeReasoningHeaders, resolveRouteCredential, routeKeyOf } from "@sema-agent/core";
|
|
2
|
-
import { matchCatalogModel, refusedCatalogEntry, servedModelTableLeg } from "../model-select.js";
|
|
2
|
+
import { modelRefusalLegOf, matchCatalogModel, refusedCatalogEntry, servedModelTableLeg } from "../model-select.js";
|
|
3
|
+
import { configSourceKind } from "../config-provider.js";
|
|
3
4
|
import { echoModelRef, modelUnavailableMessage } from "../model-entry-refusal.js";
|
|
4
5
|
import { resolveOpenaiRouteEndpoint } from "../model-route-endpoint.js";
|
|
5
6
|
import { anthropicLaneCredentialOf } from "../model-route-gap.js";
|
|
@@ -47,6 +48,7 @@ function routeCredentialHeader(credential) {
|
|
|
47
48
|
}
|
|
48
49
|
export function createHookLlm(deps) {
|
|
49
50
|
const { config, metrics } = deps;
|
|
51
|
+
const webAdminIsConfigSource = configSourceKind(config) === "remote";
|
|
50
52
|
const anthropicRouteBaseUrl = () => anthropicRouteRoot(config.anthropic ?? {});
|
|
51
53
|
const shapeFrom = (m, providerModelId = m.id) => {
|
|
52
54
|
const catalogRef = m.name;
|
|
@@ -55,7 +57,7 @@ export function createHookLlm(deps) {
|
|
|
55
57
|
case "anthropic":
|
|
56
58
|
return { ok: true, catalogRef, providerModelId, baseUrl: m.baseUrl || anthropicRouteBaseUrl(), api: "anthropic-messages", model: m };
|
|
57
59
|
case "gateway": {
|
|
58
|
-
const endpoint = resolveOpenaiRouteEndpoint(catalogRef, m, config.gatewayBaseUrl, servedModelTableLeg(config));
|
|
60
|
+
const endpoint = resolveOpenaiRouteEndpoint(catalogRef, m, config.gatewayBaseUrl, modelRefusalLegOf(servedModelTableLeg(config), webAdminIsConfigSource));
|
|
59
61
|
return endpoint.ok ? { ok: true, catalogRef, providerModelId, baseUrl: endpoint.baseUrl, api: "openai-completions", model: m } : unresolvedPick(endpoint.refusal);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -37,7 +37,7 @@ export declare const MAX_HOOK_OUTPUT_BYTES: number;
|
|
|
37
37
|
* 且 4096 的单条帽保证**前两条**钩子的话仍整段进得去(截断是配置广度的代价,不是常态)。
|
|
38
38
|
*/
|
|
39
39
|
export declare const MAX_HOOK_CONTEXT_TOTAL_CHARS = 10000;
|
|
40
|
-
/** 契约里**引擎属主**的 `settings.hooks` 事件(
|
|
40
|
+
/** 契约里**引擎属主**的 `settings.hooks` 事件(契约包的十员字面量元组;壳属主的事件引擎不跑,owner-single)。 */
|
|
41
41
|
export type EngineOwnedHookEvent = (typeof ENGINE_OWNED_HOOK_EVENTS)[number];
|
|
42
42
|
/**
|
|
43
43
|
* 律二 · **事件对位只有一张表,一事件一站**:引擎属主的每个 `settings.hooks` 事件 → 它挂的那一个 `classic.*` 站(同名站)。
|
|
@@ -56,6 +56,7 @@ export declare const SETTINGS_HOOK_STATIONS: {
|
|
|
56
56
|
readonly StopFailure: "classic.StopFailure";
|
|
57
57
|
readonly PreCompact: "classic.PreCompact";
|
|
58
58
|
readonly PostCompact: "classic.PostCompact";
|
|
59
|
+
readonly PermissionDenied: "classic.PermissionDenied";
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
62
|
* **一条车道一张注册**:每张的名字 —— wire 可见(`wiring_manifest.mods[].name`、`allowRuleShadowed[].entries`、问因项 `askReasons[].registration`),
|
|
@@ -170,7 +171,7 @@ export type ParseHooksConfigResult = {
|
|
|
170
171
|
* 升级前被拦的 Bash 升级后放行(安全轴上的回退)。所以这条规则住在 fresh 专用的判据里,与 `taskSettingsKeyIssue` 同姿势
|
|
171
172
|
* (「fresh 400 / resume 宽容」双层:会砖存量的规则只咬 fresh)。resume 照旧整只采纳,别名那一组继续永不命中(与 7.111.0 逐字同),其余照跑。
|
|
172
173
|
* · **哪些事件** = 契约 `HOOK_EVENT_MATCHER_FIELD[event] === "tool_name"` ∧ 引擎属主 `HOOK_EVENT_OWNER[event] === "engine"`
|
|
173
|
-
* (
|
|
174
|
+
* (今天 = 上面三个 + `PermissionDenied`(settings-schema 26.0.0 起引擎属主,名 = 同一次调用在门上的 wire 名,派生自动带上);`PermissionRequest` 也匹配 `tool_name` 但属壳,壳自己跑,不是本 runner 的读法)。**不手抄事件表**([ref])。
|
|
174
175
|
* · **哪些名字算别名** = core 静态目录(`describeToolCatalog()`)里某条 `face.aliases` 的成员,且它自己不是另一条目的 wire 名({@link engineToolAliases})。
|
|
175
176
|
* **只读这一只真源**([ref])。本仓自身不声明带别名的工具;嵌入方经 `resolveSpec` 席挂的别名与 MCP 工具名在受理面看不见(名册是每任务装配的),**不在射程**。
|
|
176
177
|
* · **正名同在则不拒**:`正名|别名` / `List.*` 会命中正名,不是「静默不命中」,且正是 7.107.0 CHANGELOG 给的「滚动期两名都写」补偿形。
|
|
@@ -56,12 +56,13 @@ export const SETTINGS_HOOK_STATIONS = {
|
|
|
56
56
|
StopFailure: "classic.StopFailure",
|
|
57
57
|
PreCompact: "classic.PreCompact",
|
|
58
58
|
PostCompact: "classic.PostCompact",
|
|
59
|
+
PermissionDenied: "classic.PermissionDenied",
|
|
59
60
|
};
|
|
60
61
|
function chainsBelowTaskOn(patterns, station) {
|
|
61
62
|
return patterns.some((p) => p === station || (p.endsWith(".*") && station.startsWith(p.slice(0, -1))));
|
|
62
63
|
}
|
|
63
|
-
const REQUEST_HOOK_REWRITE_UNSHOWN_REASON = "a request PreToolUse hook rewrote this call's input, but
|
|
64
|
-
const REQUEST_HOOK_ALLOW_UNJUDGED_REASON = "a request PreToolUse hook allowed this call, but
|
|
64
|
+
const REQUEST_HOOK_REWRITE_UNSHOWN_REASON = "a request PreToolUse hook rewrote this call's input, but a deployment-seat handler is admitted at the PreToolUse site below the request's hooks (admission is per site; whether its matcher fits this call is not read), and such a handler never sees a rewrite made above it, so request-hook rewrites are refused at this site and the call was not executed";
|
|
65
|
+
const REQUEST_HOOK_ALLOW_UNJUDGED_REASON = "a request PreToolUse hook allowed this call, but a deployment-seat handler is admitted at the PreToolUse site below the request's hooks (admission is per site; whether its matcher fits this call is not read), and a request hook's allow does not stand in for that handler's judgment, so request-hook allows are refused at this site and the call was not executed";
|
|
65
66
|
function hangTranslator(on, event, translators) {
|
|
66
67
|
const translate = translators[event];
|
|
67
68
|
if (translate === undefined)
|
|
@@ -1664,7 +1665,8 @@ function createLaneRegistration(lane, config, ctx, budgetMs) {
|
|
|
1664
1665
|
const stopFailureEntries = lit("StopFailure");
|
|
1665
1666
|
const preCompactEntries = lit("PreCompact");
|
|
1666
1667
|
const postCompactEntries = lit("PostCompact");
|
|
1667
|
-
|
|
1668
|
+
const permissionDeniedEntries = lit("PermissionDenied");
|
|
1669
|
+
if (!pre && !post && !postFailure && !postBatch && !promptSubmit && !stopEntries && !stopFailureEntries && !preCompactEntries && !postCompactEntries && !permissionDeniedEntries) {
|
|
1668
1670
|
return undefined;
|
|
1669
1671
|
}
|
|
1670
1672
|
const onceSpent = new Set();
|
|
@@ -2178,6 +2180,19 @@ function createLaneRegistration(lane, config, ctx, budgetMs) {
|
|
|
2178
2180
|
await runObserveOnlyEvent("PostCompact", postCompactEntries, cctx.trigger, payload, ctx, once, halt);
|
|
2179
2181
|
});
|
|
2180
2182
|
}
|
|
2183
|
+
if (permissionDeniedEntries) {
|
|
2184
|
+
translators.PermissionDenied = (dctx, halt) => settleOnce(onceSpent, async (once) => {
|
|
2185
|
+
const payload = {
|
|
2186
|
+
...basePayload(ctx, dctx.permissionMode),
|
|
2187
|
+
hook_event_name: "PermissionDenied",
|
|
2188
|
+
tool_name: dctx.toolName,
|
|
2189
|
+
tool_input: dctx.input,
|
|
2190
|
+
tool_use_id: dctx.toolCallId,
|
|
2191
|
+
reason: clipDataText(dctx.reason, MAX_HOOK_FEEDBACK_CHARS),
|
|
2192
|
+
};
|
|
2193
|
+
await runObserveOnlyEvent("PermissionDenied", permissionDeniedEntries, dctx.toolName, payload, ctx, once, halt);
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2181
2196
|
const events = Object.keys(translators);
|
|
2182
2197
|
return {
|
|
2183
2198
|
name: SETTINGS_HOOKS_REGISTRATIONS[lane],
|
package/dist/host-decision.d.ts
CHANGED
|
@@ -71,8 +71,8 @@ export type HostDecision = Extract<ResumeOutcome, {
|
|
|
71
71
|
* ══ 决定体的出处位 `decidedBy`:一只闭集、一只读法、一只映射 ═══════════════════════════════════════════════
|
|
72
72
|
*
|
|
73
73
|
* 规则一句话:**一个审批决定用一只键说是谁做的** —— `decidedBy ∈ {"person","policy"}`,缺席 = `"person"`;读它的只有
|
|
74
|
-
* {@link readDecider}(
|
|
75
|
-
* `POST /v1/tasks/:
|
|
74
|
+
* {@link readDecider}(两条工具审批决定口共读:决断口
|
|
75
|
+
* `POST /v1/tasks/:taskId/asks/:askId/decision`、耐久 `POST /v1/approvals/:sessionId/decide`),把它交给引擎的只有
|
|
76
76
|
* {@link liveHostSource}(同步座 `AskOutcome.settledBy`)与 {@link hostDecisionFacts}(停驻座 `hostDecision.decidedBy`)。
|
|
77
77
|
* · 词与决定动词**正交**:策略可以放行也可以拒(core 7.39.0 起引擎铸 `policy_allowed` / `policy_refused`)。唯一的例外是
|
|
78
78
|
* 引擎自己的那一条 —— 一张要人的卡(`requiresRealApproval`)不归策略答,见 {@link heldAskOf}(判官是 core 的 `policyCannotAnswer`)。
|
|
@@ -103,14 +103,14 @@ export declare const DECIDED_BY_NOT_IN_PROOF = "decidedBy is not supported on a
|
|
|
103
103
|
/** 一张要人的卡上策略的放行(两条决定口同一句;判官 core `policyCannotAnswer`,问形见 {@link heldAskOf})。 */
|
|
104
104
|
export declare const POLICY_CANNOT_ALLOW_PERSON_ASK = "decidedBy \"policy\" cannot allow this ask \u2014 it demands a person's approval (risk.requiresRealApproval), and a policy's answer is not a person's; answer it as a person, or refuse it as the policy";
|
|
105
105
|
/**
|
|
106
|
-
* 退役键 `settledBy`(7.93.3–7.117.x 的「只配 deny」那一位)
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
106
|
+
* 退役键 `settledBy`(7.93.3–7.117.x 的「只配 deny」那一位)的拒句。决定口共用这一句,出句的铸点是 {@link retiredDecisionKeyFacts}(各口不直接引用本常量)。
|
|
107
|
+
* 这只键不是随便一个未知键:它是调用方在**明确陈述**「这是策略答的」—— 忽略它就是把缺席律(person)套在一个说了话的体上(旧壳的策略拒记成人拒;
|
|
108
|
+
* 一张要人的卡上旧形的放行被读成人的放行,绕过「要人的卡不归策略答」那一判)。各口在键闭集 / strict 体上拒它,句子由同一铸点出
|
|
109
|
+
* (7.151.x 及以前的 live 应答口体不是键闭集的、在裁决之前专门拒它;那条口 7.152.0 起已删)。
|
|
110
110
|
*/
|
|
111
111
|
export declare const SETTLED_BY_RETIRED = "settledBy is retired \u2014 send decidedBy: \"person\" | \"policy\" (who made this decision; absent = \"person\"); ignoring it would record a policy's answer as a person's";
|
|
112
112
|
/**
|
|
113
|
-
* 退役键 `settledBy` 的**拒绝事实** ——
|
|
113
|
+
* 退役键 `settledBy` 的**拒绝事实** —— 两条工具审批决定口(决断口
|
|
114
114
|
* `POST /v1/tasks/:taskId/asks/:askId/decision`、`POST /v1/approvals/:sessionId/decide`)对它的拒,**句**与**机读位**同出自这一处:
|
|
115
115
|
* · `error` = {@link SETTLED_BY_RETIRED}(三口同一句,没有哪一口自说一句 —— 此前耐久 ask 账说 strict 体的通用句、`/decide` 说键闭集句);
|
|
116
116
|
* · `extra` = `{ field: "settledBy" }`,直接作 `sendError` 的 `extra` / 并进 400 体。`field` 是 400 体上既有的那一把键(`request.field_invalid` 的
|
|
@@ -152,7 +152,7 @@ export type DeciderReading = {
|
|
|
152
152
|
* 决定体决定者两格(`decidedBy` + `decidedVia`)的**唯一读法**。次序即契约:
|
|
153
153
|
* ① `decidedBy` 缺席 ⇒ `"person"`(缺席律:一条不说话的决定就是一个人按的 —— 与修前逐字同形);
|
|
154
154
|
* ② 直连门在场且 `decidedBy` 在场 ⇒ `not_in_proof`(不论值:它不在签名载荷里,能改线上字节的一方可以把人翻成策略;
|
|
155
|
-
*
|
|
155
|
+
* 各调用点交部署的 `directDoorActive`;7.151.x 及以前的 live 应答口没有决策证明、给字面 `false`,那条口 7.152.0 起已删);
|
|
156
156
|
* ③ `decidedBy` 闭集外(`"sla_timeout"`、结算词、别的串、非串、`null`)⇒ `outside_closed_set`({@link DECIDED_BY_OUTSIDE_CLOSED_SET});
|
|
157
157
|
* ④ `decidedVia` 在场(`undefined` 之外一律算在场,`null` 也是 —— 与 `decidedBy` 同一条在场口径)而它不在 core `DECIDED_VIA` 里,或旁边的决定者
|
|
158
158
|
* 没有座位(人;含 ① 落成的缺席 person ⇒ 直连门上只带 `decidedVia` 也走这一臂,直连门从不受理它)⇒ `outside_closed_set`({@link DECIDED_VIA_OUTSIDE_SEAT});
|
|
@@ -176,11 +176,11 @@ export declare function readDecider(body: {
|
|
|
176
176
|
export declare function liveHostSource(decider: ApprovalDecider): HostSource | undefined;
|
|
177
177
|
/**
|
|
178
178
|
* 引擎自己的那一条例外:**一张要人的卡不归策略答** —— 判官是 core 的 `policyCannotAnswer(question, decidedBy)`([ref] 包根导出;引擎的续跑入口、
|
|
179
|
-
* 执行带与同步座读同一条)
|
|
180
|
-
*
|
|
179
|
+
* 执行带与同步座读同一条)。本仓**只在自己的副作用先于引擎落地的那一条口**上于裁决之前问它(决断口 `POST /v1/tasks/:taskId/asks/:askId/decision`:
|
|
180
|
+
* 会话放行 / 常驻规则 / 一条宣称 approve 的 DECIDED 行;7.151.x 及以前的 live 应答口也问,那条口 7.152.0 起已删),并且只问**放行**那一向(与引擎续跑入口同:拒永远答得了)。耐久 `/decide` 不判:
|
|
181
181
|
* 引擎在 CAS 之前就拒(`checkpoint.invalid_outcome`,卡留 pending),本口的副作用全在引擎受理之后 —— 在那里再问一次就是第二个判官。
|
|
182
182
|
*
|
|
183
|
-
* 交给判官的「问」= {@link heldAskOf}
|
|
183
|
+
* 交给判官的「问」= {@link heldAskOf}:决断口两形持有的都不是引擎的原物(活卡条目记的是铸条目那一次从 `AskRequest` 读定的那一位;ask 账行上是
|
|
184
184
|
* 卡面 `risk.requiresRealApproval`,读不出按要人读),以引擎的问形(core `HeldQuestion` 的 `ask` 决定臂)交过去 —— 「谁答不了」只在引擎那一处判。
|
|
185
185
|
*/
|
|
186
186
|
export declare function heldAskOf(demandsAPerson: boolean): Extract<PermissionResult, {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* `LSP_HOST_ENABLED`。理由:core 的 `NodeLspManager` 在 worker 上起本机子进程、在 worker 盘上找根,问的正是「这块盘是不是调用方的」;
|
|
7
7
|
* 车道能力表不另存一位(同一个答案的第二个写者)。两个入口(服务装配 `boot/execution-env.ts`、纯本地 CLI `run-local.ts`)的 `lspManager`
|
|
8
8
|
* 就是本函数的返回值,不再有任何条件(结构钉 `test/secret-env-scrub-disclosure.test.ts` 的 P1,逐格钉 `test/lsp-host-manager.test.ts` 的 P2)。
|
|
9
|
-
* 「绑得住读」(`openBound`)
|
|
10
|
-
*
|
|
9
|
+
* 「绑得住读」(`openBound`)不是本铸点的判据:它是每条有手车道的结构前提(对拍钉 `test/host-env-open-bound.test.ts` P3;本版 ssh 缓装),
|
|
10
|
+
* 运行期的不可绑由那一答答(远端目标给不出那一次观测 ⇒ `not_supported`,引擎读作缺席)。
|
|
11
11
|
*
|
|
12
12
|
* ## 子进程 env:病([ref],core 7.30.1 [ref] 提货;DEBTS [ref] 同轴的第二条,7.99.0 修复验证 opus 腿普查带出)
|
|
13
13
|
* core 的 `NodeLspManager` 默认 spawn(`defaultLspSpawn`)在 7.30.1 之前**不带 env** ⇒ 语言服务器整份继承本进程的
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { type GovernancePosture } from "../runtime-governance.js";
|
|
17
17
|
import type { ShellGateDoctrine } from "@sema-agent/core";
|
|
18
|
+
import { type ParkedRunStatus } from "../plugins/store-contracts.js";
|
|
18
19
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
19
20
|
import { type PendingRowBinding } from "../plugins/checkpoint-store-face.js";
|
|
20
21
|
/** 与 runs.ts/tasks.ts 三个 409 位共享的旧文案(byte-frozen:api-error-text-freeze 门认这句)。 */
|
|
@@ -71,11 +72,43 @@ export interface PendingGateMaterial {
|
|
|
71
72
|
* 报的是同一行。残余如实记:这一位仍不是**跨 run** 的去重键 —— activeTaskId 换了,门自然也换。 */
|
|
72
73
|
checkpointId?: string;
|
|
73
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* 持有者的状态词:run 状态表判为在跑或停驻的词(在跑 `running` ∪ 停驻词 —— 停驻词从表派生,今天 `suspended` / `needs_review`)。
|
|
77
|
+
* 收场词(完成 / 失败 / 阻断)不在其中:持有者行已收场而认领还在(收尾窗 / 崩溃残留),状态键不写。
|
|
78
|
+
*/
|
|
79
|
+
export type OccupantRunStatus = "running" | ParkedRunStatus;
|
|
80
|
+
/**
|
|
81
|
+
* **会话占用两键**(wire):`activeTaskId` = 这只会话的单活认领此刻的持有者(认领已放 ⇒ `null`,键恒在);`activeTaskStatus` = 那条 run 行存着的状态,
|
|
82
|
+
* 在跑 / 停驻才写键({@link OccupantRunStatus})。唯一铸法 = {@link occupantOf};出现面:409 `conflict.session_active_run` 各体(提交 / 续跑 / 删除 / run 外回退)
|
|
83
|
+
* 与 SSE 冲突 done 帧、会话头探针 `GET /v1/sessions/:id/head` 的 200 体 —— 同一时刻两边的两键逐字相等。
|
|
84
|
+
*/
|
|
85
|
+
export type SessionOccupant = {
|
|
86
|
+
readonly activeTaskId: string | null;
|
|
87
|
+
readonly activeTaskStatus?: OccupantRunStatus;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 🔴 **占用两键的唯一投影**:认领持有者(任一处读到的那一格 —— 写口认领冲突里观察到的、删除围栏判到的、按会话读的认领)→ {@link SessionOccupant}。
|
|
91
|
+
* 状态 = 持有者那一行(不带属主的一格事实,经属主存取器 `runFactsOf` 读),在跑 / 停驻才写键。没有 run 店 ⇒ 只有持有者。
|
|
92
|
+
* 读店故障原样抛 —— 失败方向归调用方:提交面的 409 体降级成只带持有者({@link buildActiveRunConflict} 的留痕臂),读面响亮(500,不答一个看似诚实的少键体)。
|
|
93
|
+
*/
|
|
94
|
+
export declare function occupantOf(runStore: Pick<RunStore, "getRun"> | undefined, holder: string | null | undefined): Promise<SessionOccupant>;
|
|
95
|
+
/**
|
|
96
|
+
* 拒体上的占用两键(409 的失败方向:拒体本身绝不被材料挡住):{@link occupantOf},持有者行读不出 ⇒ 只剩持有者 + F 类留痕(与提交面材料同一只 tag)。
|
|
97
|
+
* 读者:提交 / 续跑面的铸式({@link buildActiveRunConflict})、删除口与 run 外回退口的 409。
|
|
98
|
+
*/
|
|
99
|
+
export declare function refusalOccupantOf(runStore: Pick<RunStore, "getRun"> | undefined, holder: string | null | undefined): Promise<SessionOccupant>;
|
|
100
|
+
/**
|
|
101
|
+
* 按会话读的那一读:run 店的单活认领(`getActiveTaskId`,跨副本 = 共享店里的那一格)→ {@link occupantOf}。读者:会话头探针(读面:任一读故障响亮)。
|
|
102
|
+
* 读的是存着的认领,不落死亡判决:心跳过期而还没被收割 / 观察的持有者照它行上存着的状态答(与「其余按认领判的门不判存活」同一条;
|
|
103
|
+
* 写口的认领冲突判官先判死它、所以提交不会因它 409)。
|
|
104
|
+
*/
|
|
105
|
+
export declare function readSessionOccupant(runStore: Pick<RunStore, "getActiveTaskId" | "getRun">, sessionId: string): Promise<SessionOccupant>;
|
|
74
106
|
export interface ActiveRunConflictBody {
|
|
75
107
|
error: string;
|
|
76
108
|
errorCode: "conflict.session_active_run";
|
|
109
|
+
/** 占用两键({@link SessionOccupant},唯一投影 {@link occupantOf})。 */
|
|
77
110
|
activeTaskId: string | null;
|
|
78
|
-
activeTaskStatus?:
|
|
111
|
+
activeTaskStatus?: OccupantRunStatus;
|
|
79
112
|
/** [ref] S1([ref]):running 形专属的**活性证据**——本副本 ledger sink 最后一次 durable append 距今
|
|
80
113
|
* 的毫秒数(「turn 真在推进」的判别材料;与行 updatedAt 的进程心跳语义刻意分离)。**同副本
|
|
81
114
|
* best-effort**:缺席 = 无法证明(跨副本/重启后),不是「不活」——诚实缺席,绝不铸 0。消费端
|
|
@@ -100,7 +133,7 @@ export interface ActiveRunConflictDoneResult {
|
|
|
100
133
|
errorCode: "conflict.session_active_run";
|
|
101
134
|
errorMessage: string;
|
|
102
135
|
activeTaskId: string | null;
|
|
103
|
-
activeTaskStatus?:
|
|
136
|
+
activeTaskStatus?: OccupantRunStatus;
|
|
104
137
|
/** [ref] S1:与 409 body 同键同语义(见 {@link ActiveRunConflictBody.msSinceLastActivity})。 */
|
|
105
138
|
msSinceLastActivity?: number;
|
|
106
139
|
pendingGate?: PendingGateMaterial;
|
|
@@ -6,6 +6,28 @@ import { recordFailOpen } from "../observability/fail-open.js";
|
|
|
6
6
|
import { refusalBody } from "./refusal-body.js";
|
|
7
7
|
import { trustedCheckpointId } from "../checkpoint-identity.js";
|
|
8
8
|
export const ACTIVE_RUN_CONFLICT_BASE_TEXT = "session already has an active run — POST /v1/runs/{activeTaskId}/cancel stops it (same-instance interactive runs abort immediately)";
|
|
9
|
+
function holderOf(holder) {
|
|
10
|
+
return holder ? holder : null;
|
|
11
|
+
}
|
|
12
|
+
export async function occupantOf(runStore, holder) {
|
|
13
|
+
const activeTaskId = holderOf(holder);
|
|
14
|
+
if (activeTaskId === null || runStore === undefined)
|
|
15
|
+
return { activeTaskId };
|
|
16
|
+
const status = (await runFactsOf(runStore, activeTaskId))?.status;
|
|
17
|
+
return status !== undefined && (status === "running" || isParkedRunStatus(status)) ? { activeTaskId, activeTaskStatus: status } : { activeTaskId };
|
|
18
|
+
}
|
|
19
|
+
export async function refusalOccupantOf(runStore, holder) {
|
|
20
|
+
try {
|
|
21
|
+
return await occupantOf(runStore, holder);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
recordFailOpen("server.approvals.active-run-conflict-material-unavailable");
|
|
25
|
+
return { activeTaskId: holderOf(holder) };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function readSessionOccupant(runStore, sessionId) {
|
|
29
|
+
return occupantOf(runStore, await runStore.getActiveTaskId(sessionId));
|
|
30
|
+
}
|
|
9
31
|
export function resumeEntryForGate(kind, ids) {
|
|
10
32
|
switch (kind) {
|
|
11
33
|
case "human":
|
|
@@ -42,24 +64,31 @@ function activeRunConflictBody(message, facts) {
|
|
|
42
64
|
return body;
|
|
43
65
|
}
|
|
44
66
|
export async function buildActiveRunConflict(deps, sessionId, activeTaskId) {
|
|
45
|
-
const baseFacts = { activeTaskId: activeTaskId
|
|
67
|
+
const baseFacts = { activeTaskId: holderOf(activeTaskId) };
|
|
46
68
|
const base = activeRunConflictBody(ACTIVE_RUN_CONFLICT_BASE_TEXT, baseFacts);
|
|
47
|
-
if (
|
|
69
|
+
if (baseFacts.activeTaskId === null)
|
|
48
70
|
return base;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
const holder = baseFacts.activeTaskId;
|
|
72
|
+
const occupant = await refusalOccupantOf(deps.runStore, holder);
|
|
73
|
+
const status = occupant.activeTaskStatus;
|
|
74
|
+
if (status === undefined)
|
|
75
|
+
return activeRunConflictBody(ACTIVE_RUN_CONFLICT_BASE_TEXT, occupant);
|
|
76
|
+
if (status === "running") {
|
|
77
|
+
let lastAt;
|
|
78
|
+
try {
|
|
79
|
+
lastAt = deps.turnActivity?.(holder);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
recordFailOpen("server.approvals.active-run-conflict-material-unavailable");
|
|
60
83
|
}
|
|
84
|
+
return activeRunConflictBody("session already has an active run — POST /v1/runs/{activeTaskId}/steer injects a message into the running turn (queued, applied at the next turn boundary), or POST /v1/runs/{activeTaskId}/cancel stops it (same-instance interactive runs abort immediately)", {
|
|
85
|
+
...occupant,
|
|
86
|
+
...(lastAt !== undefined ? { msSinceLastActivity: Math.max(0, Date.now() - lastAt) } : {}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
let pendingGate;
|
|
90
|
+
try {
|
|
61
91
|
const cs = deps.checkpointStore;
|
|
62
|
-
let pendingGate;
|
|
63
92
|
if (cs?.findPendingTokenBySession) {
|
|
64
93
|
const runBinding = { gateKinds: LIVE_RUN_GATE_KINDS, axis: "run" };
|
|
65
94
|
const scope = (await cs.peekPendingScope?.(sessionId, runBinding)) ?? undefined;
|
|
@@ -68,7 +97,7 @@ export async function buildActiveRunConflict(deps, sessionId, activeTaskId) {
|
|
|
68
97
|
const gate = row?.gate;
|
|
69
98
|
const kind = gate?.kind;
|
|
70
99
|
const cardSessionId = row?.sessionId;
|
|
71
|
-
const decidePath = kind && cardSessionId ? resumeEntryForGate(kind, { sessionId: cardSessionId, taskId:
|
|
100
|
+
const decidePath = kind && cardSessionId ? resumeEntryForGate(kind, { sessionId: cardSessionId, taskId: holder }) : null;
|
|
72
101
|
const governanceForced = governanceOriginOf(gate, deps.governance);
|
|
73
102
|
const checkpointId = trustedCheckpointId(row?.checkpointId, token);
|
|
74
103
|
if (kind && decidePath) {
|
|
@@ -80,13 +109,13 @@ export async function buildActiveRunConflict(deps, sessionId, activeTaskId) {
|
|
|
80
109
|
};
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
|
-
return activeRunConflictBody(pendingGate
|
|
84
|
-
? `session already has an active run — it is parked waiting for a decision (${status}); resolve it via POST ${pendingGate.decidePath}, or POST /v1/runs/{activeTaskId}/cancel abandons it`
|
|
85
|
-
: `session already has an active run — it is parked (${status}); POST /v1/runs/{activeTaskId}/cancel abandons it (its pending decision could not be located on this instance)`, { ...baseFacts, activeTaskStatus: status, ...(pendingGate ? { pendingGate } : {}) });
|
|
86
112
|
}
|
|
87
113
|
catch {
|
|
88
114
|
recordFailOpen("server.approvals.active-run-conflict-material-unavailable");
|
|
89
|
-
|
|
115
|
+
pendingGate = undefined;
|
|
90
116
|
}
|
|
117
|
+
return activeRunConflictBody(pendingGate
|
|
118
|
+
? `session already has an active run — it is parked waiting for a decision (${status}); resolve it via POST ${pendingGate.decidePath}, or POST /v1/runs/{activeTaskId}/cancel abandons it`
|
|
119
|
+
: `session already has an active run — it is parked (${status}); POST /v1/runs/{activeTaskId}/cancel abandons it (its pending decision could not be located on this instance)`, { ...occupant, ...(pendingGate ? { pendingGate } : {}) });
|
|
91
120
|
}
|
|
92
121
|
//# sourceMappingURL=active-run-conflict.js.map
|
package/dist/http/admission.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APPROVAL_REACH, IMAGE_ADMISSION, isApprovalReach, isPermissionMode, isThinkingLevel, expandTiers } from "@sema-agent/core";
|
|
2
2
|
import { isAtMentionable, matchCatalogModel, refusedCatalogEntry, selectableCatalog } from "../model-select.js";
|
|
3
3
|
import { echoModelRef, modelUnavailableMessage } from "../model-entry-refusal.js";
|
|
4
|
-
import { HttpError, sessionIdShapeIssue } from "../security.js";
|
|
4
|
+
import { HttpError, SESSION_KIND_UNRECORDABLE_MESSAGE, sessionIdShapeIssue } from "../security.js";
|
|
5
5
|
import { MAX_SETTINGS_OUTPUT_STYLE_CHARS, MAX_SETTINGS_ENV_VARS, appendFold, MAX_SETTINGS_ENV_KEY_CHARS, MAX_SETTINGS_ENV_VALUE_CHARS, PERMISSION_MODE_WORDS, autoCompactEnabledOk, parseTaskSettings, readSettingsEnv, settingsEnvComposeIssue, settingsEnvCredentialIssue, settingsPermissionBucketIssue, skillListingBudgetFractionOk, skillListingMaxDescOk, hooksKeyIssue, taskHooksHonored, taskSettingsKeyIssue } from "../task-settings.js";
|
|
6
6
|
import { serverCredentialValueSources } from "../server-secret-env.js";
|
|
7
7
|
import { tightenOnlySeatIssue } from "../tighten-only-seats.js";
|
|
@@ -9,7 +9,7 @@ import { approvalFrameFamiliesIssue } from "../tool-approval.js";
|
|
|
9
9
|
import { buildEntryModeClampNotice } from "../entry-mode-clamp-notice.js";
|
|
10
10
|
import { stampSubmissionEntryMode } from "../permission-mode-admission.js";
|
|
11
11
|
import { taskBodyKeyIssue } from "../request-key-closure.js";
|
|
12
|
-
import { FILE_HISTORY_DISABLED_NO_RESTORE, fileHistoryRestoreConflict, fileHistoryRestoreKeysInBody, inheritEnvFieldIssue, singleMemberOffFieldIssue } from "../request-value-closure.js";
|
|
12
|
+
import { FILE_HISTORY_DISABLED_NO_RESTORE, fileHistoryRestoreConflict, fileHistoryRestoreKeysInBody, inheritEnvFieldIssue, sessionKindFieldIssue, singleMemberOffFieldIssue } from "../request-value-closure.js";
|
|
13
13
|
import * as facts from "../capability-facts.js";
|
|
14
14
|
import { buildHooksRefusal, buildHooksUrlCredentialRefusal, parseHooksConfig, hooksMatcherIssue, hooksUrlCredentialIssue } from "../hooks/hook-runner.js";
|
|
15
15
|
import { judgeFreshRequestWebSearch } from "../plugins/web-search.js";
|
|
@@ -404,6 +404,10 @@ export function createAdmission(ctx) {
|
|
|
404
404
|
return null;
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
+
if (body.cascade === true && fileHistoryRestoreKeysInBody(body).includes("rewindFilesTo")) {
|
|
408
|
+
sendError(res, 400, "request.field_conflict", "rewindFilesTo is not supported with cascade (every rung starts a fresh session, so there is no history to restore files from)", fieldConflictFacts("cascade_verify", ["rewindFilesTo", "cascade"]));
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
407
411
|
if (body.resumeAtMode !== undefined) {
|
|
408
412
|
if (body.resumeAtMode !== "at" && body.resumeAtMode !== "before") {
|
|
409
413
|
sendError(res, 400, "request.field_invalid", 'resumeAtMode must be "at" or "before"');
|
|
@@ -454,6 +458,17 @@ export function createAdmission(ctx) {
|
|
|
454
458
|
return null;
|
|
455
459
|
}
|
|
456
460
|
}
|
|
461
|
+
{
|
|
462
|
+
const kindIssue = sessionKindFieldIssue(body);
|
|
463
|
+
if (kindIssue) {
|
|
464
|
+
sendError(res, 400, "request.field_invalid", kindIssue);
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (body.sessionKind !== undefined && !facts.sessionKinds(deps).available) {
|
|
468
|
+
sendError(res, 400, "request.precondition_unmet", SESSION_KIND_UNRECORDABLE_MESSAGE);
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
457
472
|
if (fileHistoryRestoreConflict(body)) {
|
|
458
473
|
sendError(res, 400, "request.field_conflict", FILE_HISTORY_DISABLED_NO_RESTORE, fieldConflictFacts("file_history_restore", ["fileHistory", ...fileHistoryRestoreKeysInBody(body)]));
|
|
459
474
|
return null;
|