@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
|
@@ -60,9 +60,9 @@ import { summarizeWorkflowRun, type CheckpointToken, type WorkflowRunStore } fro
|
|
|
60
60
|
import { type WorkflowCompletionInbox, type WorkflowCompletionInboxEntry } from "../orchestration/workflow-completion-inbox.js";
|
|
61
61
|
import type { WorkflowNotifyJournalStore, WorkflowNotifyJournalEntry } from "../orchestration/workflow-notify-journal.js";
|
|
62
62
|
import { type WorkflowAgentSessionIndex, type WorkflowAgentSessionRow } from "../orchestration/workflow-agent-session-index.js";
|
|
63
|
-
import { type WorkflowParkDecision, type WorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
|
|
63
|
+
import { type HolderFenceVerdict, type RecordFenced, type WorkflowParkDecision, type WorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
|
|
64
64
|
import type { SqlRunStore } from "./run-store-sql.js";
|
|
65
|
-
import { type SqlDialect, type SqlDriver, type SqlExec } from "./sql-driver.js";
|
|
65
|
+
import { type SqlDialect, type SqlDriver, type SqlExec, type SqlTxConn } from "./sql-driver.js";
|
|
66
66
|
type WorkflowRun = Parameters<WorkflowRunStore["put"]>[1];
|
|
67
67
|
/** Row cap guard: a run blob beyond this is NOT stored on update (the prior revision stays) — TiDB's
|
|
68
68
|
* ~6 MiB txn-entry limit would otherwise throw the (best-effort) progress write into the workflow loop.
|
|
@@ -126,6 +126,14 @@ export declare class SqlWorkflowRunStore implements WorkflowRunStore {
|
|
|
126
126
|
private q;
|
|
127
127
|
put(id: string, run: WorkflowRun): Promise<void>;
|
|
128
128
|
get(id: string): Promise<WorkflowRun | null>;
|
|
129
|
+
/**
|
|
130
|
+
* **记录栅栏(SQL 形)**:一个事务 —— 锁读这条 run 的记录行且它读作 `running`(`workflow_run … FOR UPDATE`,行体经本店唯一列读者 {@link readRunColumn} 解、
|
|
131
|
+
* `rev` 列覆盖),读到 ⇒ `fn` 在**同一个事务连接**上跑(收锁住的那份记录);没读到(终态 / 不在)⇒ `fn` 不调、答 `{ running: false }`。提交即放锁;`fn` 抛或提交失败 ⇒ 整只抛。
|
|
132
|
+
* 引擎的记录写是同一行的 CAS `UPDATE`({@link update}),notify 门的收养翻转同一条 ⇒ 与本段在这一行锁上串行:本段先拿锁 ⇒ 段里落的写先于终态提交;
|
|
133
|
+
* 终态先提交 ⇒ 本段读不到 `running`。决定行的写就落在这里(契约属主 = `orchestration/workflow-park-decision.ts` 文件头)。
|
|
134
|
+
* 取锁序 = `workflow_run` → `workflow_park_decision`(段里只碰这两张表;认领栅栏那一形先锁 `task_run` / `task_active` 再碰 `workflow_park_decision`,两序不成环)。
|
|
135
|
+
*/
|
|
136
|
+
whileRunning<T>(id: string, fn: (tx: SqlTxConn, run: WorkflowRun) => Promise<T>): Promise<RecordFenced<T>>;
|
|
129
137
|
update(id: string, scope: string, run: WorkflowRun, expect?: {
|
|
130
138
|
rev: number;
|
|
131
139
|
}): Promise<boolean>;
|
|
@@ -212,24 +220,34 @@ export declare class SqlWorkflowAgentSessionIndex implements WorkflowAgentSessio
|
|
|
212
220
|
/**
|
|
213
221
|
* workflow 子代停驻卡的耐久决定行 —— SQL 双生(契约与律的唯一属主 =
|
|
214
222
|
* {@link import("../orchestration/workflow-park-decision.js").WorkflowParkDecisionStore} 的文件头,这里只记方言差)。
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* run 行与认领行的锁直到提交),读走那只 run 店的池(`claims.db`)—— 决定行、认领、读写同一只池,池只有这一处来源。
|
|
223
|
+
* 写在两只栅栏之一的事务里:记录栅栏(`records`:{@link SqlWorkflowRunStore.whileRunning} 交出的那条事务连接 —— 栅栏攥着 `workflow_run` 行锁直到提交)
|
|
224
|
+
* 或认领栅栏(`claims`:`SqlRunStore.whileHoldingClaim` 交出的那条事务连接 —— 攥着 run 行与认领行的锁直到提交);读走 run 店的池(`claims.db`)。
|
|
225
|
+
* 两只栅栏、决定行、读写同一只池(后端交出的三只店同出一只池)。删除只有 run 收割的级联({@link SqlWorkflowRunStore.reap})。
|
|
219
226
|
*
|
|
220
227
|
* ── 方言差,保持显式 ──────────────────────────────────────────────────────────────────────────
|
|
221
228
|
* - `?` 占位 vs `$n`。
|
|
222
|
-
* -
|
|
223
|
-
*
|
|
229
|
+
* - 认领栅栏下的整行 upsert(主键 `token`):TiDB `INSERT … ON DUPLICATE KEY UPDATE col = VALUES(col)` vs PG `INSERT … ON CONFLICT (token) DO UPDATE SET col = EXCLUDED.col`。
|
|
230
|
+
* 序由认领栅栏定,`accepted_at_ms` 只是记下的值。
|
|
231
|
+
* - 记录栅栏下的「没有才插」(先受理者立):TiDB `INSERT … ON DUPLICATE KEY UPDATE token = token` vs PG `INSERT … ON CONFLICT (token) DO NOTHING`;
|
|
232
|
+
* 之后**锁定读**行上的指纹(`SELECT … FOR UPDATE`)判立没立 —— TiDB 悲观事务里的普通读走事务起点的快照,一只等锁等过对方提交的事务用普通读会读不到
|
|
233
|
+
* 对方刚落的行;锁定读读最新提交。PG READ COMMITTED 每句新快照,锁定读同样成立。收场转交的条件读同此(认领栅栏里锁定读指纹再写)。
|
|
224
234
|
* - `outcome` 是 JSON 承载的文本列(TiDB MEDIUMTEXT / PG TEXT,与 `workflow_run.run` 同形:两方言同一条 `JSON.stringify` 绑定),
|
|
225
235
|
* 读腿按文本投影、恰好解一次({@link jsonColumnText} / {@link decodeJsonColumn})。
|
|
226
236
|
* - schema 属主同店内其余表:TiDB DDL 在 tidb-pool.ts,PG DDL 在 pg-pool.ts(店不建表)。
|
|
227
237
|
*/
|
|
228
238
|
export declare class SqlWorkflowParkDecisionStore implements WorkflowParkDecisionStore {
|
|
229
239
|
readonly claims: SqlRunStore;
|
|
230
|
-
|
|
240
|
+
readonly records: SqlWorkflowRunStore;
|
|
241
|
+
constructor(claims: SqlRunStore, records: SqlWorkflowRunStore);
|
|
231
242
|
private q;
|
|
232
|
-
|
|
243
|
+
/** 事务里锁定读这张卡行上的指纹(没有行 ⇒ `undefined`)。 */
|
|
244
|
+
private lockedFingerprint;
|
|
245
|
+
record(d: WorkflowParkDecision, condition?: {
|
|
246
|
+
readonly expect: string;
|
|
247
|
+
}): Promise<boolean>;
|
|
248
|
+
recordForRunningHolder(d: WorkflowParkDecision, request: {
|
|
249
|
+
readonly restated: boolean;
|
|
250
|
+
}): Promise<HolderFenceVerdict>;
|
|
233
251
|
get(token: CheckpointToken): Promise<WorkflowParkDecision | null>;
|
|
234
252
|
listByHostSession(hostSessionId: string): Promise<WorkflowParkDecision[]>;
|
|
235
253
|
}
|
|
@@ -2,10 +2,12 @@ import { redactErrorMessage, redactHead } from "../observability/run-terminal.js
|
|
|
2
2
|
import { summarizeWorkflowRun, isTerminalWorkflowStatus, WorkflowRunStoreError } from "@sema-agent/core";
|
|
3
3
|
import { foldKeyFamily, MAX_PENDING_PER_SESSION, PURGE_FENCE_MS, SERVED_FENCE_MS, } from "../orchestration/workflow-completion-inbox.js";
|
|
4
4
|
import {} from "../orchestration/workflow-agent-session-index.js";
|
|
5
|
-
import { readWorkflowParkOutcome } from "../orchestration/workflow-park-decision.js";
|
|
5
|
+
import { holderFenceAdmits, readWorkflowParkOutcome } from "../orchestration/workflow-park-decision.js";
|
|
6
6
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
7
7
|
import { createObjectColumnReader, decodeJsonColumn, foldJsonColumn, jsonColumnText } from "./sql-json-column.js";
|
|
8
8
|
import { isDupKeyError } from "./sql-errors.js";
|
|
9
|
+
import { storeBoundaryFault } from "../terminal.js";
|
|
10
|
+
import { sealStoreClass } from "./store-boundary.js";
|
|
9
11
|
export const MAX_RUN_BLOB_BYTES = 4 * 1024 * 1024;
|
|
10
12
|
const SLIM_HEADER_MAX = 200;
|
|
11
13
|
const onWarnType = (msg, meta) => void [msg, meta];
|
|
@@ -81,6 +83,37 @@ export class SqlWorkflowRunStore {
|
|
|
81
83
|
run.rev = Number(r.rev);
|
|
82
84
|
return run;
|
|
83
85
|
}
|
|
86
|
+
async whileRunning(id, fn) {
|
|
87
|
+
const conn = await this.db.connect();
|
|
88
|
+
try {
|
|
89
|
+
await conn.begin();
|
|
90
|
+
try {
|
|
91
|
+
const { rows } = await conn.query(this.q(`SELECT ${jsonColumnText("mysql", "run")}, rev FROM workflow_run WHERE id = ? AND status = 'running' FOR UPDATE`, `SELECT ${jsonColumnText("pg", "run")}, rev FROM workflow_run WHERE id = $1 AND status = 'running' FOR UPDATE`), [id]);
|
|
92
|
+
const r = rows[0];
|
|
93
|
+
let fenced = { running: false };
|
|
94
|
+
if (r !== undefined) {
|
|
95
|
+
const run = readRunColumn(r.run, id);
|
|
96
|
+
run.rev = Number(r.rev);
|
|
97
|
+
fenced = { running: true, value: await fn(conn, run) };
|
|
98
|
+
}
|
|
99
|
+
await conn.commit();
|
|
100
|
+
return fenced;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
try {
|
|
104
|
+
await conn.rollback();
|
|
105
|
+
}
|
|
106
|
+
catch (rollbackErr) {
|
|
107
|
+
const rollbackFault = storeBoundaryFault(rollbackErr, "sql-workflow-run-store.whileRunning");
|
|
108
|
+
throw new Error(`workflow record fence on ${id}: the segment failed and its rollback failed too (${rollbackFault instanceof Error ? rollbackFault.message : String(rollbackFault)})`, { cause: err });
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
conn.release();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
84
117
|
async update(id, scope, run, expect) {
|
|
85
118
|
run = withRedactedError(run);
|
|
86
119
|
let blob = JSON.stringify({ ...run, id, scope });
|
|
@@ -166,6 +199,7 @@ export class SqlWorkflowRunStore {
|
|
|
166
199
|
return res.affected;
|
|
167
200
|
}
|
|
168
201
|
}
|
|
202
|
+
sealStoreClass(SqlWorkflowRunStore, "sql-workflow-run-store", { put: "exit", get: "exit", update: "exit", whileRunning: "exit", listByScope: "exit", reapAllScopes: "exit", reap: "exit" });
|
|
169
203
|
const KIND_SERVED = "served";
|
|
170
204
|
const KIND_PURGE = "purge";
|
|
171
205
|
export async function writeInboxPurgeFenceOn(exec, dialect, sessionId, purgedOwner, now) {
|
|
@@ -264,6 +298,7 @@ export class SqlWorkflowCompletionInbox {
|
|
|
264
298
|
await this.db.query(this.q("DELETE FROM workflow_completion_inbox WHERE session_id = ? AND run_id <> ? AND REGEXP_REPLACE(run_id, '#[0-9]+$', '') = ?", "DELETE FROM workflow_completion_inbox WHERE session_id = $1 AND run_id <> $2 AND regexp_replace(run_id, '#[0-9]+$', '') = $3"), [sessionId, runId, runId]);
|
|
265
299
|
}
|
|
266
300
|
}
|
|
301
|
+
sealStoreClass(SqlWorkflowCompletionInbox, "sql-workflow-completion-inbox", { enqueue: "exit", pending: "exit", ack: "exit", purge: "exit", markTerminalServed: "exit" });
|
|
267
302
|
export class SqlWorkflowNotifyJournalStore {
|
|
268
303
|
db;
|
|
269
304
|
constructor(db) {
|
|
@@ -309,6 +344,7 @@ export class SqlWorkflowNotifyJournalStore {
|
|
|
309
344
|
};
|
|
310
345
|
}
|
|
311
346
|
}
|
|
347
|
+
sealStoreClass(SqlWorkflowNotifyJournalStore, "sql-workflow-notify-journal-store", { record: "exit", ack: "exit", listPending: "exit", reapAcked: "exit", get: "exit" });
|
|
312
348
|
export class SqlWorkflowAgentSessionIndex {
|
|
313
349
|
db;
|
|
314
350
|
constructor(db) {
|
|
@@ -328,6 +364,7 @@ export class SqlWorkflowAgentSessionIndex {
|
|
|
328
364
|
return rows.map((r) => ({ sessionId: String(r.session_id), runId: String(r.run_id), agentKey: String(r.agent_key), scope: String(r.scope) }));
|
|
329
365
|
}
|
|
330
366
|
}
|
|
367
|
+
sealStoreClass(SqlWorkflowAgentSessionIndex, "sql-workflow-agent-session-index", { ensurePointers: "exit", listByAgentSession: "exit" });
|
|
331
368
|
function readParkDecisionOutcomeColumn(v, where) {
|
|
332
369
|
try {
|
|
333
370
|
return decodeJsonColumn(v, readWorkflowParkOutcome, `workflow_park_decision.outcome ${where}`);
|
|
@@ -338,19 +375,41 @@ function readParkDecisionOutcomeColumn(v, where) {
|
|
|
338
375
|
}
|
|
339
376
|
export class SqlWorkflowParkDecisionStore {
|
|
340
377
|
claims;
|
|
341
|
-
|
|
378
|
+
records;
|
|
379
|
+
constructor(claims, records) {
|
|
342
380
|
this.claims = claims;
|
|
381
|
+
this.records = records;
|
|
343
382
|
}
|
|
344
383
|
q(mysql, pg) {
|
|
345
384
|
return this.claims.db.dialect === "mysql" ? mysql : pg;
|
|
346
385
|
}
|
|
347
|
-
async
|
|
386
|
+
async lockedFingerprint(tx, token) {
|
|
387
|
+
const { rows } = await tx.query(this.q("SELECT fingerprint FROM workflow_park_decision WHERE token = ? FOR UPDATE", "SELECT fingerprint FROM workflow_park_decision WHERE token = $1 FOR UPDATE"), [token]);
|
|
388
|
+
const r = rows[0];
|
|
389
|
+
return r === undefined ? undefined : String(r.fingerprint);
|
|
390
|
+
}
|
|
391
|
+
async record(d, condition) {
|
|
348
392
|
const fenced = await this.claims.whileHoldingClaim(d.hostSessionId, d.deliveredTaskId, async (tx) => {
|
|
393
|
+
if (condition !== undefined && (await this.lockedFingerprint(tx, d.token)) !== condition.expect)
|
|
394
|
+
return false;
|
|
349
395
|
await tx.query(this.q(`INSERT INTO workflow_park_decision (token, run_id, host_session_id, outcome, fingerprint, delivered_task_id, accepted_at_ms) VALUES (?,?,?,?,?,?,?)
|
|
350
396
|
ON DUPLICATE KEY UPDATE ${PARK_DECISION_REPLACED_COLUMNS.map((c) => `${c} = VALUES(${c})`).join(", ")}`, `INSERT INTO workflow_park_decision (token, run_id, host_session_id, outcome, fingerprint, delivered_task_id, accepted_at_ms) VALUES ($1,$2,$3,$4,$5,$6,$7)
|
|
351
397
|
ON CONFLICT (token) DO UPDATE SET ${PARK_DECISION_REPLACED_COLUMNS.map((c) => `${c} = EXCLUDED.${c}`).join(", ")}`), [d.token, d.runId, d.hostSessionId, JSON.stringify(d.outcome), d.fingerprint, d.deliveredTaskId, d.acceptedAtMs]);
|
|
398
|
+
return true;
|
|
399
|
+
});
|
|
400
|
+
return fenced.held && fenced.value;
|
|
401
|
+
}
|
|
402
|
+
async recordForRunningHolder(d, request) {
|
|
403
|
+
const fenced = await this.records.whileRunning(d.runId, async (tx, run) => {
|
|
404
|
+
const admits = holderFenceAdmits(run, d, request.restated);
|
|
405
|
+
if (admits !== "land")
|
|
406
|
+
return admits;
|
|
407
|
+
await tx.query(this.q(`INSERT INTO workflow_park_decision (token, run_id, host_session_id, outcome, fingerprint, delivered_task_id, accepted_at_ms) VALUES (?,?,?,?,?,?,?)
|
|
408
|
+
ON DUPLICATE KEY UPDATE token = token`, `INSERT INTO workflow_park_decision (token, run_id, host_session_id, outcome, fingerprint, delivered_task_id, accepted_at_ms) VALUES ($1,$2,$3,$4,$5,$6,$7)
|
|
409
|
+
ON CONFLICT (token) DO NOTHING`), [d.token, d.runId, d.hostSessionId, JSON.stringify(d.outcome), d.fingerprint, d.deliveredTaskId, d.acceptedAtMs]);
|
|
410
|
+
return (await this.lockedFingerprint(tx, d.token)) === d.fingerprint ? "stands" : "other_decision";
|
|
352
411
|
});
|
|
353
|
-
return fenced.
|
|
412
|
+
return fenced.running ? fenced.value : "not_running";
|
|
354
413
|
}
|
|
355
414
|
async get(token) {
|
|
356
415
|
const { rows } = await this.claims.db.query(this.q(`SELECT token, run_id, host_session_id, ${jsonColumnText("mysql", "outcome")}, fingerprint, delivered_task_id, accepted_at_ms FROM workflow_park_decision WHERE token = ?`, `SELECT token, run_id, host_session_id, ${jsonColumnText("pg", "outcome")}, fingerprint, delivered_task_id, accepted_at_ms FROM workflow_park_decision WHERE token = $1`), [token]);
|
|
@@ -362,6 +421,7 @@ export class SqlWorkflowParkDecisionStore {
|
|
|
362
421
|
return rows.map(rowToParkDecision);
|
|
363
422
|
}
|
|
364
423
|
}
|
|
424
|
+
sealStoreClass(SqlWorkflowParkDecisionStore, "sql-workflow-park-decision-store", { record: "exit", recordForRunningHolder: "exit", get: "exit", listByHostSession: "exit" });
|
|
365
425
|
const PARK_DECISION_REPLACED_COLUMNS = ["run_id", "host_session_id", "outcome", "fingerprint", "delivered_task_id", "accepted_at_ms"];
|
|
366
426
|
function rowToParkDecision(r) {
|
|
367
427
|
const token = String(r.token);
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
* (停驻腿的环境引擎还拿着,续跑腿拿到的就是它);那一只正在收场 ⇒ 等它的收场落定再铸,它欠着的账交给新的这只;没有 ⇒ 铸一只入表。
|
|
9
9
|
* 同一身份同一时刻只有一条腿(会话锁 + run 认领),交回同一只不会让两条腿同时用它。
|
|
10
10
|
* · **工作区的生命归持有它的环境,不归铸它的那一只**:表里每一只成员自己说它此刻持有哪只工作区;一只工作区能不能删 = 表里除问者之外还有没有成员持有它
|
|
11
|
-
* ({@link WorkspaceCustody.holder})——
|
|
11
|
+
* ({@link WorkspaceCustody.holder})—— 没有才删,有就把删交给最后放手的那一只(host 车道另问一句「此刻谁在里面」,见下)。
|
|
12
12
|
*
|
|
13
13
|
* ## 两条车道怎么读同一张表
|
|
14
14
|
* · local-docker:工作区 = 身份派生名的那只容器;一只身份同一时刻只有一只没收场的成员(上面的交回律),容器名又由身份派生 ⇒ 不可能有第二个持有者,成员收场即删
|
|
15
15
|
* (读 {@link WorkspaceCustody.envOf};欠账 = 删除没证实的那只容器,交给同一身份的下一只)。
|
|
16
|
-
* · host:工作区 = 本服务铸的临时根;委派子代按父的工作目录落根 ⇒ 子代的环境与父的共持那只根(铸时问 {@link WorkspaceCustody.holder}
|
|
17
|
-
*
|
|
16
|
+
* · host:工作区 = 本服务铸的临时根;委派子代按父的工作目录落根 ⇒ 子代的环境与父的共持那只根(铸时问 {@link WorkspaceCustody.holder}「谁持有包含这一处的根」,
|
|
17
|
+
* 只能多记持有者)。删只在最后一只持有者放手那一拍、同一同步段里问同一只 `holder`「还有谁持有它,或此刻还没离场、工作目录读得出地在它里面」之后发生 ——
|
|
18
|
+
* 有 ⇒ 不删(在里面的那一只当场接过删除);读不出 ⇒ 不删不交接,留给退出边界;没人才删。父收场时子代还停驻在里面 ⇒ 父不删,子代最后一条腿收场时再判。
|
|
18
19
|
*
|
|
19
20
|
* ## 出表
|
|
20
21
|
* 成员收场落定、什么都不欠、什么都不持有({@link CustodyMember.settled})⇒ 出表;没收场的成员(停驻腿的环境)一直在表里(停驻中被店层取消 / 过期的,引擎不销毁它,它持有的工作区
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ExecutionEnvFactoryContext } from "@sema-agent/core";
|
|
2
|
+
import { type ConnectRefusal } from "./remote-env-connect-seat.js";
|
|
2
3
|
import type { Logger } from "../observability/logger.js";
|
|
3
4
|
import { type TaskAttachmentStore } from "./task-attachment-store.js";
|
|
4
5
|
/** 车道一次固定命令的读数(适配器自己的起动身份 —— 与引擎命令同一个执行用户;从不抛)。 */
|
|
@@ -29,14 +30,10 @@ export interface WorkspaceChannel {
|
|
|
29
30
|
}
|
|
30
31
|
/** 恢复点交出的工作区从哪来:`minted` = 车道刚铸出的新工作区(没有可恢复的树 —— 含恢复点指的归档不在:`latest` 悬空、停驻快照的归档不在);`restored` = 恢复出来的(空间 `latest` / 停驻快照的树真回来了)。 */
|
|
31
32
|
export type WorkspaceOrigin = "minted" | "restored";
|
|
32
|
-
/**
|
|
33
|
+
/** 一次填充的结局。拒的那一臂是一只建连的拒:`standing` = 这只执行环境此后每一次恢复点都会得到同一个答(适配器的建连座记住它,不再建机器)。 */
|
|
33
34
|
export type FillOutcome = {
|
|
34
35
|
readonly ok: true;
|
|
35
|
-
} |
|
|
36
|
-
readonly ok: false;
|
|
37
|
-
readonly error: RemoteExecutionError;
|
|
38
|
-
readonly standing: boolean;
|
|
39
|
-
};
|
|
36
|
+
} | ConnectRefusal;
|
|
40
37
|
/** 恢复点的填充座(按 run 由工厂装配交给适配器;适配器只在恢复点调它、只说工作区从哪来,不判内容)。 */
|
|
41
38
|
export interface WorkspaceFill {
|
|
42
39
|
/** 往恢复点即将交出的工作区(根 = `root`,适配器的工作根;来处 = `origin`)里放内容。 */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { RemoteExecutionError } from "@sema-agent/core";
|
|
4
|
+
import { connectRefusal } from "./remote-env-connect-seat.js";
|
|
4
5
|
import { readProjectBundle } from "../project-bundle.js";
|
|
5
6
|
import { attachmentBytesOf, attachmentPlacementsOf, seedOfSession } from "./task-attachment-store.js";
|
|
6
7
|
import { shellQuote } from "./remote-shell.js";
|
|
7
8
|
const FILLED = { ok: true };
|
|
8
9
|
function refused(message, standing = false) {
|
|
9
|
-
return { ok: false, error: new RemoteExecutionError("connect_failed", message), standing };
|
|
10
|
+
return standing ? connectRefusal("workspace_fill_refused", message) : { ok: false, error: new RemoteExecutionError("connect_failed", message), standing: false };
|
|
10
11
|
}
|
|
11
12
|
function errText(e) {
|
|
12
13
|
return e instanceof Error ? e.message : String(e);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { alignedWindow, retryAfterSecUntil } from "../observability/cost-quota.js";
|
|
2
|
+
import { sealStoreClass } from "./store-boundary.js";
|
|
2
3
|
const SEP = "\u0000";
|
|
3
4
|
export const DEFAULT_COUNTER_QUERY_TIMEOUT_MS = 30_000;
|
|
4
5
|
export class SqlWriteBehindCounter {
|
|
@@ -173,6 +174,10 @@ export class SqlWriteBehindCounter {
|
|
|
173
174
|
this.windowMs = windowMs;
|
|
174
175
|
}
|
|
175
176
|
}
|
|
177
|
+
sealStoreClass(SqlWriteBehindCounter, "sql-write-behind-counter", {
|
|
178
|
+
window: "exit", bucket: "exit", usedIn: "exit", used: "exit", addLocal: "exit", retryAfterSec: "exit", flush: "exit", refresh: "exit", reap: "exit",
|
|
179
|
+
startRefresh: "exit", stop: "exit", refreshRunning: "exit", setWindowMs: "exit",
|
|
180
|
+
});
|
|
176
181
|
export class WriteBehindCounter extends SqlWriteBehindCounter {
|
|
177
182
|
constructor(pool, t, windowMs, now, onDegraded, queryTimeoutMs) {
|
|
178
183
|
super("mysql", pool, t, windowMs, now, onDegraded, queryTimeoutMs);
|
|
@@ -37,8 +37,6 @@ export interface ProjectContextDecision {
|
|
|
37
37
|
readonly context: ProjectContext | undefined;
|
|
38
38
|
readonly withheldPathItems: number;
|
|
39
39
|
}
|
|
40
|
-
/** 一只登记对这位观者可见吗(读面与继承同调的唯一判):全舰队视域看全部;否则只看 `registeredBy` 恰是自己的。看不见与不存在同答。 */
|
|
41
|
-
export declare function projectVisible(registration: Pick<ProjectRegistration, "registeredBy">, viewer: ListFilter): boolean;
|
|
42
40
|
/**
|
|
43
41
|
* 项目简报的唯一铸点(纯串;各段缺席不出,全缺席 ⇒ 无简报)。只读 {@link PROJECT_BRIEF_FIELDS};路径两段只在 `pathsHonored` 时出,且只列名字 ——
|
|
44
42
|
* `file` 条目未附上,段名写明「相关时去读」。首行点名来源与项目 id(不带 `displayName`:身份字段不进提示)。
|
package/dist/project-context.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { PROJECT_ID_REGEX } from "@sema-agent/core";
|
|
2
2
|
import { isAbsoluteHostPath } from "@sema-agent/settings-schema";
|
|
3
|
+
import { visibleProjectOf } from "./project-registry.js";
|
|
3
4
|
import { MAX_SETTINGS_OUTPUT_STYLE_CHARS } from "./task-settings.js";
|
|
4
5
|
export const PROJECT_BRIEF_FIELDS = ["goal", "notes", "contextItems"];
|
|
5
6
|
export const PROJECT_CONTENT_ATTESTATION_FIELD = "contentAttestedAt";
|
|
6
|
-
export function projectVisible(registration, viewer) {
|
|
7
|
-
return viewer.fleetWide || registration.registeredBy === viewer.gateOwner;
|
|
8
|
-
}
|
|
9
7
|
export function buildProjectBrief(projectId, registration, pathsHonored) {
|
|
10
8
|
const sections = [];
|
|
11
9
|
if (registration.goal !== undefined && registration.goal.length > 0)
|
|
@@ -29,11 +27,9 @@ export function buildProjectBrief(projectId, registration, pathsHonored) {
|
|
|
29
27
|
return [`# Project context (from this deployment's project registry; project ${projectId})`, ...sections].join("\n\n");
|
|
30
28
|
}
|
|
31
29
|
export function projectContextOf(input) {
|
|
32
|
-
const { projectId
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const registration = Object.hasOwn(registry, projectId) ? registry[projectId] : undefined;
|
|
36
|
-
if (registration === undefined || !projectVisible(registration, viewer))
|
|
30
|
+
const { projectId } = input;
|
|
31
|
+
const registration = visibleProjectOf(input.registry, projectId, input.viewer);
|
|
32
|
+
if (projectId === undefined || registration === undefined)
|
|
37
33
|
return { context: undefined, withheldPathItems: 0 };
|
|
38
34
|
if (registration[PROJECT_CONTENT_ATTESTATION_FIELD] === undefined)
|
|
39
35
|
return { context: undefined, withheldPathItems: 0 };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ProjectRegistration } from "@sema-agent/settings-schema";
|
|
2
|
+
import type { ListFilter } from "./owner-faces.js";
|
|
3
|
+
/** 一张登记簿(键 = 小写规范 UUID;值至少带可见性的属主键)。缺席 = 本部署没有登记簿(`capability-facts.ts` `projectRegistry` 答 no)。 */
|
|
4
|
+
export type ProjectRegistryTable<R> = Readonly<Record<string, R>> | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* 谓词读的观者事实(列表面视域 {@link ListFilter} 里与登记可见性有关的两格)。`gateOwner` 只拿来与登记的 `registeredBy`(settings-schema 的纯串)逐字节比,
|
|
7
|
+
* 所以这里收纯串:新提交腿交来的是读面推导出的主体(品牌串,天然是串),续跑腿交来的是冻结时落成字节的那一串(不重铸品牌 —— 它不进任何属主门,只比这一格)。
|
|
8
|
+
*/
|
|
9
|
+
export interface ProjectViewer {
|
|
10
|
+
readonly fleetWide: ListFilter["fleetWide"];
|
|
11
|
+
readonly gateOwner: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** 一只登记对这位观者可见吗(唯一判):全舰队视域看全部;否则只看 `registeredBy` 恰是自己的(无身份的观者 `gateOwner = null` 恒看不见)。 */
|
|
14
|
+
export declare function projectVisibleTo(viewer: ProjectViewer, registration: Pick<ProjectRegistration, "registeredBy">): boolean;
|
|
15
|
+
/** 这位观者看得见的那只登记(唯一取法):未登记 / 看不见 / 没有观者 / 本部署没有登记簿 ⇒ 同答 `undefined`。按 id 只认自有键。 */
|
|
16
|
+
export declare function visibleProjectOf<R extends Pick<ProjectRegistration, "registeredBy">>(registry: ProjectRegistryTable<R>, projectId: string | undefined, viewer: ProjectViewer | undefined): R | undefined;
|
|
17
|
+
/** 一条 run 的登记簿默认读层种子:种子项目(这次提交带的、提交者看得见的那只)+ 判出它的那一位观者。随 run 冻结(续跑重建输入 `CheckpointCtx.memorySeed`)。 */
|
|
18
|
+
export interface MemorySeed {
|
|
19
|
+
readonly projectId: string;
|
|
20
|
+
readonly viewer: ProjectViewer;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 新提交腿的种子判(一条 run 一次):这次**提交**没带项目 ⇒ `undefined`(没什么可判);带了而对提交者可见 ⇒ 种子;带了而判不出(未登记 / 看不见 / 没有观者 / 没有登记簿)
|
|
24
|
+
* ⇒ `null`(判过,无 —— 冻结下来,续跑腿据它与「停驻在种子判出现之前」分开)。
|
|
25
|
+
*/
|
|
26
|
+
export declare function memorySeedOf(registry: ProjectRegistryTable<Pick<ProjectRegistration, "registeredBy">>, submittedProjectId: string | undefined, viewer: ProjectViewer | undefined): MemorySeed | null | undefined;
|
|
27
|
+
/** 种子的词(两腿同调):种子的那一位观者此刻仍看得见的那只登记声明的 `defaultScopes`;没有种子 / 判过无 / 登记已不在 / 不再对他可见 ⇒ 缺席。 */
|
|
28
|
+
export declare function memorySeedScopesOf(registry: ProjectRegistryTable<Pick<ProjectRegistration, "registeredBy" | "defaultScopes">>, seed: MemorySeed | null | undefined): string[] | undefined;
|
|
29
|
+
/** 续跑重建输入里冻结的种子的读数:缺席(提交没带项目 / 本格出现之前写下的行)· 判过无(`null`)· 读得出 · 形不对。 */
|
|
30
|
+
export type FrozenMemorySeedReading = {
|
|
31
|
+
readonly kind: "absent";
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: "none";
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "ok";
|
|
36
|
+
readonly seed: MemorySeed;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: "malformed";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 冻结的种子的**唯一读法**(读者 = `http/resume-ctx-read.ts` 的续跑上下文读口,开封之后、任何续跑消费者之前)。服务端写下的形是闭集({@link memorySeedOf} 铸、经部署事实落盘):
|
|
42
|
+
* `null`(判过,无)或 `{ projectId, viewer: { fleetWide, gateOwner } }` —— `projectId` = 规范小写 UUID;`fleetWide` 布尔;`gateOwner` = 非空串(冻结时落成字节的主体,原样)或 `null`;
|
|
43
|
+
* 观者至少看得见点什么(`fleetWide` 或 `gateOwner` 在场 —— 看不见的提交不冻结种子)。别的形 ⇒ `malformed`(读口答坏体:续跑不按它挑种子)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function frozenMemorySeedOf(stored: unknown): FrozenMemorySeedReading;
|
|
46
|
+
//# sourceMappingURL=project-registry.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PROJECT_ID_REGEX } from "@sema-agent/core";
|
|
2
|
+
export function projectVisibleTo(viewer, registration) {
|
|
3
|
+
return viewer.fleetWide || registration.registeredBy === viewer.gateOwner;
|
|
4
|
+
}
|
|
5
|
+
export function visibleProjectOf(registry, projectId, viewer) {
|
|
6
|
+
if (registry === undefined || projectId === undefined || viewer === undefined || !Object.hasOwn(registry, projectId))
|
|
7
|
+
return undefined;
|
|
8
|
+
const registration = registry[projectId];
|
|
9
|
+
return registration !== undefined && projectVisibleTo(viewer, registration) ? registration : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function memorySeedOf(registry, submittedProjectId, viewer) {
|
|
12
|
+
if (submittedProjectId === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (viewer === undefined || visibleProjectOf(registry, submittedProjectId, viewer) === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
return { projectId: submittedProjectId, viewer: { fleetWide: viewer.fleetWide, gateOwner: viewer.gateOwner } };
|
|
17
|
+
}
|
|
18
|
+
export function memorySeedScopesOf(registry, seed) {
|
|
19
|
+
return visibleProjectOf(registry, seed?.projectId, seed?.viewer)?.defaultScopes;
|
|
20
|
+
}
|
|
21
|
+
export function frozenMemorySeedOf(stored) {
|
|
22
|
+
if (stored === undefined)
|
|
23
|
+
return { kind: "absent" };
|
|
24
|
+
if (stored === null)
|
|
25
|
+
return { kind: "none" };
|
|
26
|
+
const own = (o, k) => (Object.hasOwn(o, k) ? o[k] : undefined);
|
|
27
|
+
const closedObject = (v, keys) => typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).every((k) => keys.includes(k));
|
|
28
|
+
if (!closedObject(stored, ["projectId", "viewer"]))
|
|
29
|
+
return { kind: "malformed" };
|
|
30
|
+
const projectId = own(stored, "projectId");
|
|
31
|
+
const viewer = own(stored, "viewer");
|
|
32
|
+
if (typeof projectId !== "string" || !PROJECT_ID_REGEX.test(projectId) || projectId !== projectId.toLowerCase())
|
|
33
|
+
return { kind: "malformed" };
|
|
34
|
+
if (!closedObject(viewer, ["fleetWide", "gateOwner"]))
|
|
35
|
+
return { kind: "malformed" };
|
|
36
|
+
const fleetWide = own(viewer, "fleetWide");
|
|
37
|
+
const gateOwner = own(viewer, "gateOwner");
|
|
38
|
+
if (typeof fleetWide !== "boolean" || (gateOwner !== null && (typeof gateOwner !== "string" || gateOwner.length === 0)))
|
|
39
|
+
return { kind: "malformed" };
|
|
40
|
+
if (!fleetWide && gateOwner === null)
|
|
41
|
+
return { kind: "malformed" };
|
|
42
|
+
return { kind: "ok", seed: { projectId, viewer: { fleetWide, gateOwner } } };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=project-registry.js.map
|
package/dist/question.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface QuestionFrame {
|
|
|
7
7
|
type: "question" | "question_complete";
|
|
8
8
|
questionId: string;
|
|
9
9
|
/** "question" only: the model's structured questions, secret-redacted. UNTRUSTED-for-display (shell renders; never
|
|
10
|
-
* re-feeds a model).
|
|
10
|
+
* re-feeds a model). Always the WHOLE questions — no size cap (the question IS the decision; the same bytes already ride
|
|
11
|
+
* `tool_start.args` uncapped). An unserializable payload emits no frame at all (the ask then reports unavailable). */
|
|
11
12
|
questions?: AskQuestion[];
|
|
12
13
|
/** "question_complete" only: whether the human answered (`answered`) or the ask closed without an answer
|
|
13
14
|
* (`unanswered` — window elapsed / abort / leg-exit sweep). Cosmetic dialog-dismiss. */
|
package/dist/question.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { uuidv7 } from "@sema-agent/core";
|
|
3
|
-
import {
|
|
3
|
+
import { humanFacingArgs } from "./human-facing-args.js";
|
|
4
4
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
5
5
|
import { refusalBody } from "./http/refusal-body.js";
|
|
6
6
|
import { keyAdmits, ownerCellOf, recoveredSubject } from "./owner-faces.js";
|
|
7
7
|
import { createHitlOpenRace } from "./hitl-delivery.js";
|
|
8
|
-
const MAX_QUESTIONS_BYTES = 16384;
|
|
9
8
|
export const DEFAULT_QUESTION_THROTTLE = {
|
|
10
9
|
maxConcurrentPerRun: 2,
|
|
11
10
|
maxTotalPerRun: 20,
|
|
@@ -48,16 +47,9 @@ export function parseQuestionResponse(body) {
|
|
|
48
47
|
}
|
|
49
48
|
return { ok: true, value: { answers: out } };
|
|
50
49
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
if (JSON.stringify(redacted).length > MAX_QUESTIONS_BYTES)
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
return redacted;
|
|
50
|
+
function presentableQuestions(questions) {
|
|
51
|
+
const shown = humanFacingArgs(questions, "question");
|
|
52
|
+
return shown.kind === "whole" ? shown.value : undefined;
|
|
61
53
|
}
|
|
62
54
|
export class QuestionCoordinator {
|
|
63
55
|
als = new AsyncLocalStorage();
|
|
@@ -90,7 +82,7 @@ export class QuestionCoordinator {
|
|
|
90
82
|
const rc = this.countersFor(ctx.taskId);
|
|
91
83
|
if (rc.inflight >= this.throttle.maxConcurrentPerRun || rc.total >= this.throttle.maxTotalPerRun)
|
|
92
84
|
return UNAVAILABLE;
|
|
93
|
-
const questions =
|
|
85
|
+
const questions = presentableQuestions(req.questions);
|
|
94
86
|
if (!questions)
|
|
95
87
|
return UNAVAILABLE;
|
|
96
88
|
const id = uuidv7();
|
package/dist/request-form.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { IncomingMessage } from "node:http";
|
|
17
17
|
import { type TaskHostPostureScope, type TaskWriteFaceInput } from "./hosted-posture.js";
|
|
18
18
|
import { type ToolListSide } from "./rule-entry-list.js";
|
|
19
|
-
import { type Scenario } from "./owner-brands.js";
|
|
19
|
+
import { type Scenario, type Subject } from "./owner-brands.js";
|
|
20
20
|
import type { PermissionMode } from "@sema-agent/core";
|
|
21
21
|
import type { ServiceConfig } from "./config-types.js";
|
|
22
22
|
import type { TaskRequestBody } from "./http/wire-types.js";
|
|
@@ -25,6 +25,11 @@ import type { TaskRequestBody } from "./http/wire-types.js";
|
|
|
25
25
|
* (只在提交腿:读面没有体)。没带头 ⇒ 体原样(缺席 ⇒ 门走指派链)。
|
|
26
26
|
*/
|
|
27
27
|
export declare function scenarioRequestedBy(headerScenario: Scenario | undefined, bodyScenario: unknown): unknown;
|
|
28
|
+
/**
|
|
29
|
+
* {@link scenarioRequestedBy} 的主体形:场景头读**验过的主体**带的那一格(分派层判过在册,判决已记忆化),显式点名 = 体 `scenario`(提交受理门)或读面的 `?scenario=`。
|
|
30
|
+
* 受理门与读面(`GET /v1/capabilities/scenario` · `GET /v1/capabilities/mcp` · 两张会话面板)同调这一只 —— 同一只请求形在读面上点到的场景与提交时逐字同。
|
|
31
|
+
*/
|
|
32
|
+
export declare function scenarioRequestedBySubject(subject: Subject | undefined, named: unknown): unknown;
|
|
28
33
|
/**
|
|
29
34
|
* `inheritEnv:"all"` 的车道与射程两判(值形判在 `request-value-closure.ts` 的 `inheritEnvFieldIssue`,先于本函数):只有 host 车道消费这一位 ⇒ 别的车道 400 + 机读位
|
|
30
35
|
* `reason: lane_not_host`;射程读写容纳面那一只谓词(`hosted-posture.ts` 腿④)⇒ 托管 422 `request.host_posture_refused`。`"scrub"` 是缺省,任何车道受理。
|
package/dist/request-form.js
CHANGED
|
@@ -16,6 +16,9 @@ export function scenarioRequestedBy(headerScenario, bodyScenario) {
|
|
|
16
16
|
}
|
|
17
17
|
return headerScenario;
|
|
18
18
|
}
|
|
19
|
+
export function scenarioRequestedBySubject(subject, named) {
|
|
20
|
+
return scenarioRequestedBy(subject === undefined ? undefined : partsOf(subject).scenario, named);
|
|
21
|
+
}
|
|
19
22
|
export function assertInheritEnvServed(body, config) {
|
|
20
23
|
if (body.inheritEnv !== "all")
|
|
21
24
|
return;
|
|
@@ -61,7 +64,7 @@ export function assertRequestFormBeforeMint(body, req, config) {
|
|
|
61
64
|
assertToolListsReadable(body);
|
|
62
65
|
assertRequestA2aEntries(snapshotRequestA2a(body.a2aPeers, { reread: false }));
|
|
63
66
|
assertRequestImages(body.images);
|
|
64
|
-
|
|
67
|
+
scenarioRequestedBySubject(subject, body.scenario);
|
|
65
68
|
assertAttachmentIdsShape(body.attachmentIds);
|
|
66
69
|
assertWriteFaceAdmitted(effectivePermissionMode(body, parseTaskSettings(body.settings).settings), config);
|
|
67
70
|
const ruleTables = ruleTablesRefusalWithoutTaskRoot(body, config);
|
|
@@ -29,7 +29,7 @@ const TASK_BODY_DECLARED_KEYS = [
|
|
|
29
29
|
"outputSchema", "permissionMode", "projectId", "projectMemory", "promptLean", "reasoningEffort", "requireExistingSession",
|
|
30
30
|
"resilience", "restoreFiles", "resumeAt", "resumeAtMode", "retainBackgroundProcesses", "retainSubagentSessions",
|
|
31
31
|
"rewindFilesTo", "sandboxImageProfile", "scenario", "scratchpadDir", "selfOrchestration",
|
|
32
|
-
"sessionId", "settings", "skills", "suggestNextPrompts", "systemPrompt", "taskId", "toolMaterializeStrategy",
|
|
32
|
+
"sessionId", "sessionKind", "settings", "skills", "suggestNextPrompts", "systemPrompt", "taskId", "toolMaterializeStrategy",
|
|
33
33
|
"userAttachments", "userInvokedSkills", "verify", "verifyRounds",
|
|
34
34
|
];
|
|
35
35
|
const TASK_BODY_SCENARIO_KEYS = ["repo"];
|
|
@@ -148,5 +148,9 @@ export interface InheritEnvFieldIssue {
|
|
|
148
148
|
* 句子对两种坏值形是同一句(点名两词与「名单不是请求值」);`reason` 区分它们。
|
|
149
149
|
*/
|
|
150
150
|
export declare function inheritEnvFieldIssue(raw: unknown): InheritEnvFieldIssue | null;
|
|
151
|
+
/** 词表外的拒句(wire 可见、字节冻结在 `test/api-error-text-freeze.test.ts` 的常量锚格)。 */
|
|
152
|
+
export declare const SESSION_KIND_VALUE_MESSAGE: string;
|
|
153
|
+
/** `sessionKind` 在场且不在闭集里 ⇒ 拒句;缺席或合法 ⇒ `null`(只在 fresh 受理门调)。 */
|
|
154
|
+
export declare function sessionKindFieldIssue(raw: unknown): string | null;
|
|
151
155
|
export {};
|
|
152
156
|
//# sourceMappingURL=request-value-closure.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SESSION_KINDS, isSessionKind } from "./session-kind.js";
|
|
1
2
|
export const MEMORY_CAPTURE_SPELLING_MESSAGE = "memoryCapture must be the string 'off' when present (the session-level memory-capture opt-out declaration; absent = capture as usual — there is no 'on' spelling)";
|
|
2
3
|
export const MEMORY_OFF_SPELLING_MESSAGE = "memory must be the string 'off' when present (the request-level declaration that this run mounts no memory face at all; absent = memory as usual — there is no 'on' spelling; to keep memory mounted but stop this session's content from entering long-term memory, send memoryCapture: 'off' instead)";
|
|
3
4
|
export const FILE_HISTORY_OFF_SPELLING_MESSAGE = "fileHistory must be the string 'disabled' when present (the request-level declaration that this run records no file history — no backup of an edited file, and no file restore in the same request; absent = the deployment's setting — there is no 'enabled' spelling)";
|
|
@@ -49,4 +50,13 @@ export function inheritEnvFieldIssue(raw) {
|
|
|
49
50
|
return null;
|
|
50
51
|
return { message: INHERIT_ENV_VALUE_MESSAGE, facts: inheritEnvFacts(typeof value === "string" ? "unknown_word" : "not_a_string") };
|
|
51
52
|
}
|
|
53
|
+
export const SESSION_KIND_VALUE_MESSAGE = `sessionKind must be one of ${SESSION_KINDS.map((w) => JSON.stringify(w)).join(" | ")} when present ` +
|
|
54
|
+
`("sidechain" = the session this submission creates is a client-placed sub-conversation: it is not listed by GET /v1/sessions unless asked for with ?sessionKind=sidechain, ` +
|
|
55
|
+
`and it is deleted after BG_AGENT_RETENTION_MS of inactivity; absent = a top-level conversation) — the kind is written once, when the session is created`;
|
|
56
|
+
export function sessionKindFieldIssue(raw) {
|
|
57
|
+
if (raw === null || raw === undefined || typeof raw !== "object" || Array.isArray(raw))
|
|
58
|
+
return null;
|
|
59
|
+
const value = raw.sessionKind;
|
|
60
|
+
return value === undefined || isSessionKind(value) ? null : SESSION_KIND_VALUE_MESSAGE;
|
|
61
|
+
}
|
|
52
62
|
//# sourceMappingURL=request-value-closure.js.map
|
|
@@ -51,7 +51,7 @@ export type PersonFacingRuleIssue = {
|
|
|
51
51
|
* 码与句逐字是 core 的;`libraryOption` 不进句子、也不进出口(出口只有 `code` / `guidance`)。
|
|
52
52
|
*/
|
|
53
53
|
export declare function deploymentRuleRefusal(issue: PermissionRuleIssue): {
|
|
54
|
-
readonly code:
|
|
54
|
+
readonly code: PermissionRuleIssue["code"];
|
|
55
55
|
readonly guidance: string;
|
|
56
56
|
};
|
|
57
57
|
export {};
|
package/dist/rules-consent.d.ts
CHANGED
|
@@ -467,7 +467,7 @@ export type CardRulePersisted = {
|
|
|
467
467
|
* 导出成一只纯函数 —— 在本层照抄一个更严的校验器会把 `Bash(adb *)` 这条**成因形**当场误拒。」
|
|
468
468
|
*
|
|
469
469
|
* 现况:那只纯函数到货了,于是**文本能独立判定的那一半**({@link precheckEditedRuleText} 的语法门
|
|
470
|
-
* + 覆盖门)
|
|
470
|
+
* + 覆盖门)搬到了**裁决之前**—— 决断口 `POST /v1/tasks/:taskId/asks/:askId/decision` 在结算之前就 400,卡**还在**
|
|
471
471
|
* (与 `persistRule.rule` 的形/上限 400 同一姿势,那条 400 早就是这个形)。所以壳今天可以渲
|
|
472
472
|
* 「改一下再来」,而且真能来。
|
|
473
473
|
*
|
package/dist/run-acceptance.d.ts
CHANGED
|
@@ -76,12 +76,13 @@ export interface RunAcceptance {
|
|
|
76
76
|
observe(ev: {
|
|
77
77
|
type: string;
|
|
78
78
|
}): Promise<void>;
|
|
79
|
-
/**
|
|
79
|
+
/** 结果到手、**放掉这条 run 的认领之前**(收场写 / 停驻提交之前):还没在流上见过受理帧、而结果里跑过 turn(只回结果的腿)⇒ 受理。只读 `stats.turns`。不抛;
|
|
80
|
+
* 交回的那一拍等标题器钉住要起名的住客(有界一读;认领在手 ⇒ 会话删不掉 ⇒ 住客就是这条 run 的)与补写落定 —— 腿 await 它再放认领。 */
|
|
80
81
|
settle(result: {
|
|
81
82
|
readonly stats: {
|
|
82
83
|
readonly turns: number;
|
|
83
84
|
};
|
|
84
|
-
}): void
|
|
85
|
+
}): Promise<void>;
|
|
85
86
|
/** 提交那一刻就知道的交付文本(腿上没有屏 ⇒ 请求原文);腿上有屏 ⇒ 缺席:各面提交时不写,交付时经 {@link onDelivered} 补。 */
|
|
86
87
|
readonly objectiveAtSubmit: string | undefined;
|
|
87
88
|
/**
|
package/dist/run-acceptance.js
CHANGED
|
@@ -35,11 +35,10 @@ export function createRunAcceptance(deps, input) {
|
|
|
35
35
|
delivered = objective;
|
|
36
36
|
if (objective === undefined)
|
|
37
37
|
return Promise.resolve();
|
|
38
|
-
|
|
39
|
-
deps.sessionTitler?.maybeTitle(input.sessionId, objective, input.model, deliver);
|
|
38
|
+
const titled = input.sessionId ? (deps.sessionTitler?.maybeTitle(input.sessionId, objective, input.model, deliver) ?? Promise.resolve()) : Promise.resolve();
|
|
40
39
|
if (!input.screened)
|
|
41
|
-
return
|
|
42
|
-
return Promise.all(fills.map(({ face, fill }) => runFill(face, fill, objective))).then(() => undefined);
|
|
40
|
+
return titled;
|
|
41
|
+
return Promise.all([titled, ...fills.map(({ face, fill }) => runFill(face, fill, objective))]).then(() => undefined);
|
|
43
42
|
};
|
|
44
43
|
return {
|
|
45
44
|
objectiveAtSubmit: input.screened ? undefined : input.objective,
|
|
@@ -51,8 +50,7 @@ export function createRunAcceptance(deps, input) {
|
|
|
51
50
|
return Promise.resolve();
|
|
52
51
|
},
|
|
53
52
|
settle(result) {
|
|
54
|
-
|
|
55
|
-
void accept(input.screened ? undefined : input.objective);
|
|
53
|
+
return result.stats.turns > 0 ? accept(input.screened ? undefined : input.objective) : Promise.resolve();
|
|
56
54
|
},
|
|
57
55
|
onDelivered(face, fill) {
|
|
58
56
|
if (!input.screened)
|