@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.
Files changed (514) hide show
  1. package/MIGRATION.md +451 -0
  2. package/README.md +15 -3
  3. package/README.zh-CN.md +10 -2
  4. package/USAGE.md +144 -87
  5. package/deploy/sema-up/README.md +11 -4
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
  9. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
  10. package/deploy/sema-up/chart/templates/server.yaml +5 -3
  11. package/deploy/sema-up/chart/values-full-single.yaml +3 -1
  12. package/deploy/sema-up/chart/values.yaml +8 -1
  13. package/deploy/sema-up/cluster-up.sh +7 -6
  14. package/deploy/sema-up/kube-up.sh +6 -6
  15. package/deploy/sema-up/lib/flagshape.sh +36 -8
  16. package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
  17. package/deploy/sema-up/lib/helm-values-kube.py +2 -0
  18. package/deploy/sema-up/machines.example.yaml +3 -1
  19. package/deploy/sema-up/sema-up.sh +22 -16
  20. package/dist/adoption/import.js +3 -3
  21. package/dist/approval-ask-audit-store.d.ts +1 -1
  22. package/dist/approval-ask-machine.d.ts +4 -10
  23. package/dist/approval-ask-retention.d.ts +1 -1
  24. package/dist/approval-card.d.ts +12 -14
  25. package/dist/approval-gate-currency.d.ts +9 -9
  26. package/dist/approval-gate-currency.js +3 -4
  27. package/dist/approval-hmac.d.ts +17 -1
  28. package/dist/approval-hmac.js +7 -1
  29. package/dist/approval-queue-kind.d.ts +1 -1
  30. package/dist/approval.d.ts +2 -2
  31. package/dist/approval.js +2 -2
  32. package/dist/auth-bridge.d.ts +20 -0
  33. package/dist/auth-bridge.js +9 -0
  34. package/dist/background-session-reap.d.ts +1 -1
  35. package/dist/bake-runner/main.d.ts +4 -2
  36. package/dist/bind-host.d.ts +3 -6
  37. package/dist/bind-host.js +4 -7
  38. package/dist/boot/budget-tracing.js +1 -1
  39. package/dist/boot/coordinators.d.ts +1 -1
  40. package/dist/boot/coordinators.js +9 -10
  41. package/dist/boot/device-lane.js +2 -0
  42. package/dist/boot/engine-lease.d.ts +5 -0
  43. package/dist/boot/engine-lease.js +1 -0
  44. package/dist/boot/execution-env.d.ts +9 -14
  45. package/dist/boot/execution-env.js +85 -22
  46. package/dist/boot/execution-lane.js +32 -5
  47. package/dist/boot/late-binds.d.ts +8 -4
  48. package/dist/boot/late-binds.js +7 -1
  49. package/dist/boot/leader.d.ts +31 -30
  50. package/dist/boot/leader.js +38 -28
  51. package/dist/boot/leg-path-adjudication.d.ts +40 -0
  52. package/dist/boot/leg-path-adjudication.js +18 -0
  53. package/dist/boot/memory-consolidation.d.ts +3 -2
  54. package/dist/boot/memory-consolidation.js +6 -6
  55. package/dist/boot/parked-revive-gate.js +3 -15
  56. package/dist/boot/reapers.d.ts +6 -1
  57. package/dist/boot/reapers.js +13 -2
  58. package/dist/boot/resolve-spec.d.ts +3 -3
  59. package/dist/boot/resolve-spec.js +43 -48
  60. package/dist/boot/runner-deps.d.ts +46 -35
  61. package/dist/boot/runner-deps.js +94 -91
  62. package/dist/boot/session-age-out.d.ts +36 -0
  63. package/dist/boot/session-age-out.js +101 -0
  64. package/dist/boot/session-faces.d.ts +5 -14
  65. package/dist/boot/session-faces.js +9 -5
  66. package/dist/boot/shutdown.d.ts +6 -0
  67. package/dist/boot/shutdown.js +10 -4
  68. package/dist/boot/stage-01-config.js +2 -0
  69. package/dist/boot/stage-02-web-admin-pull.js +4 -5
  70. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  71. package/dist/boot/stage-05-execution-env.js +3 -2
  72. package/dist/boot/stage-06-runners.d.ts +9 -4
  73. package/dist/boot/stage-06-runners.js +24 -9
  74. package/dist/boot/stage-07-capability-layer.d.ts +8 -4
  75. package/dist/boot/stage-07-capability-layer.js +3 -2
  76. package/dist/boot/stage-08-reapers.d.ts +8 -4
  77. package/dist/boot/stage-08-reapers.js +4 -2
  78. package/dist/boot/stage-09-leader.d.ts +12 -5
  79. package/dist/boot/stage-09-leader.js +14 -5
  80. package/dist/boot/stage-10-http-server.d.ts +19 -5
  81. package/dist/boot/stage-10-http-server.js +14 -21
  82. package/dist/boot/stores.js +7 -4
  83. package/dist/boot/web-admin.js +5 -8
  84. package/dist/boot/workflow-orchestration.d.ts +7 -2
  85. package/dist/boot/workflow-orchestration.js +24 -7
  86. package/dist/bounded-rotation.d.ts +29 -0
  87. package/dist/bounded-rotation.js +24 -0
  88. package/dist/capabilities/approvals-push.d.ts +3 -3
  89. package/dist/capabilities/scenarios.d.ts +28 -13
  90. package/dist/capabilities/scenarios.js +2 -2
  91. package/dist/capability-facts.d.ts +43 -32
  92. package/dist/capability-facts.js +45 -51
  93. package/dist/card-rule-offers.d.ts +32 -0
  94. package/dist/card-rule-offers.js +130 -0
  95. package/dist/center-credential.d.ts +25 -6
  96. package/dist/center-credential.js +25 -5
  97. package/dist/config-catalog.d.ts +26 -7
  98. package/dist/config-catalog.js +26 -22
  99. package/dist/config-dir-trust.js +4 -2
  100. package/dist/config-invariants.d.ts +20 -8
  101. package/dist/config-invariants.js +55 -12
  102. package/dist/config-lkg.d.ts +5 -19
  103. package/dist/config-lkg.js +8 -62
  104. package/dist/config-provider.d.ts +1 -1
  105. package/dist/config-root-migration.d.ts +2 -2
  106. package/dist/config-types.d.ts +38 -42
  107. package/dist/config.d.ts +58 -7
  108. package/dist/config.js +90 -40
  109. package/dist/control-socket.d.ts +51 -0
  110. package/dist/control-socket.js +115 -0
  111. package/dist/deployment-governance.d.ts +2 -1
  112. package/dist/deployment-shape.d.ts +9 -1
  113. package/dist/deployment-shape.js +2 -1
  114. package/dist/device-protocol.d.ts +5 -4
  115. package/dist/device-protocol.js +1 -1
  116. package/dist/device-ws-hub.d.ts +7 -0
  117. package/dist/device-ws-hub.js +10 -3
  118. package/dist/device-ws-protocol.d.ts +63 -10
  119. package/dist/device-ws-protocol.js +56 -25
  120. package/dist/elicitation.js +2 -2
  121. package/dist/engine-identity.d.ts +19 -7
  122. package/dist/engine-identity.js +10 -2
  123. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  124. package/dist/entry-problems.d.ts +40 -3
  125. package/dist/entry-problems.js +3 -1
  126. package/dist/execution-env-refusal.d.ts +29 -0
  127. package/dist/execution-env-refusal.js +8 -0
  128. package/dist/execution-lane-caps.d.ts +3 -1
  129. package/dist/field-conflict.d.ts +1 -1
  130. package/dist/file-history-capture.d.ts +11 -4
  131. package/dist/file-history-capture.js +9 -6
  132. package/dist/file-history-disclosure.d.ts +7 -5
  133. package/dist/file-history-disclosure.js +7 -5
  134. package/dist/fleet/drain-entry.d.ts +4 -0
  135. package/dist/fleet/engine-signal.d.ts +12 -29
  136. package/dist/fleet/engine-signal.js +1 -7
  137. package/dist/fleet-client.js +2 -5
  138. package/dist/gate-settlement.d.ts +1 -8
  139. package/dist/gate-settlement.js +0 -4
  140. package/dist/history-anchor.js +1 -1
  141. package/dist/hitl-delivery.d.ts +2 -3
  142. package/dist/hitl-delivery.js +0 -2
  143. package/dist/hooks/hook-llm.js +4 -2
  144. package/dist/hooks/hook-runner.d.ts +3 -2
  145. package/dist/hooks/hook-runner.js +18 -3
  146. package/dist/host-decision.d.ts +11 -11
  147. package/dist/host-lsp-manager.d.ts +2 -2
  148. package/dist/http/active-run-conflict.d.ts +35 -2
  149. package/dist/http/active-run-conflict.js +48 -19
  150. package/dist/http/admission.js +17 -2
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +10 -7
  153. package/dist/http/checkpoint-ctx.d.ts +4 -0
  154. package/dist/http/checkpoint-ctx.js +2 -0
  155. package/dist/http/dispatch.d.ts +8 -3
  156. package/dist/http/dispatch.js +59 -32
  157. package/dist/http/durable-run-leg.js +16 -17
  158. package/dist/http/health-reader.d.ts +16 -9
  159. package/dist/http/health-reader.js +2 -1
  160. package/dist/http/health-self-report.d.ts +9 -1
  161. package/dist/http/health-self-report.js +3 -1
  162. package/dist/http/owner-access.d.ts +33 -14
  163. package/dist/http/owner-access.js +40 -10
  164. package/dist/http/principal-gate.d.ts +49 -21
  165. package/dist/http/principal-gate.js +61 -11
  166. package/dist/http/request-channel.d.ts +23 -0
  167. package/dist/http/request-channel.js +9 -0
  168. package/dist/http/request-guards.js +17 -2
  169. package/dist/http/resume-ctx-read.js +42 -3
  170. package/dist/http/resume-legs.d.ts +4 -3
  171. package/dist/http/resume-legs.js +367 -117
  172. package/dist/http/route-ctx.d.ts +91 -15
  173. package/dist/http/route-ctx.js +17 -0
  174. package/dist/http/route-table.d.ts +5 -1
  175. package/dist/http/route-table.js +4 -0
  176. package/dist/http/routes/admin-config-refresh.js +3 -3
  177. package/dist/http/routes/admin-drain.d.ts +3 -0
  178. package/dist/http/routes/admin-drain.js +7 -7
  179. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  180. package/dist/http/routes/admin-memory-optout.js +3 -3
  181. package/dist/http/routes/adoption.js +3 -5
  182. package/dist/http/routes/agents-roster.js +2 -3
  183. package/dist/http/routes/approvals-assistant.d.ts +2 -1
  184. package/dist/http/routes/approvals-assistant.js +99 -51
  185. package/dist/http/routes/background.d.ts +3 -3
  186. package/dist/http/routes/capabilities.d.ts +4 -0
  187. package/dist/http/routes/capabilities.js +38 -10
  188. package/dist/http/routes/config-catalog.js +2 -2
  189. package/dist/http/routes/devices.js +1 -1
  190. package/dist/http/routes/diagnostics.d.ts +3 -3
  191. package/dist/http/routes/diagnostics.js +19 -7
  192. package/dist/http/routes/fleet.js +10 -8
  193. package/dist/http/routes/images.js +10 -10
  194. package/dist/http/routes/memory-bundle.js +3 -3
  195. package/dist/http/routes/memory-compliance.js +3 -3
  196. package/dist/http/routes/memory-consolidation.js +2 -2
  197. package/dist/http/routes/memory-origin.js +3 -3
  198. package/dist/http/routes/memory-policy.js +2 -2
  199. package/dist/http/routes/observability.js +3 -3
  200. package/dist/http/routes/projects.d.ts +3 -2
  201. package/dist/http/routes/projects.js +4 -5
  202. package/dist/http/routes/retention-ops.js +3 -3
  203. package/dist/http/routes/rules.js +5 -5
  204. package/dist/http/routes/run-permission-mode.d.ts +2 -1
  205. package/dist/http/routes/run-permission-mode.js +2 -2
  206. package/dist/http/routes/runs.d.ts +4 -9
  207. package/dist/http/routes/runs.js +171 -65
  208. package/dist/http/routes/session-sync.d.ts +22 -9
  209. package/dist/http/routes/session-sync.js +204 -107
  210. package/dist/http/routes/sessions-list.js +13 -7
  211. package/dist/http/routes/sessions.js +30 -15
  212. package/dist/http/routes/tasks.js +46 -41
  213. package/dist/http/routes/trace-usage.js +2 -2
  214. package/dist/http/routes/workflows.js +1 -1
  215. package/dist/http/server.d.ts +30 -30
  216. package/dist/http/server.js +16 -4
  217. package/dist/http/submit-ctx.d.ts +1 -1
  218. package/dist/http/submit-ctx.js +7 -4
  219. package/dist/http/wire-types.d.ts +14 -4
  220. package/dist/human-facing-args.d.ts +33 -0
  221. package/dist/human-facing-args.js +33 -0
  222. package/dist/identity-source.d.ts +20 -3
  223. package/dist/identity-source.js +14 -0
  224. package/dist/index.d.ts +5 -1
  225. package/dist/k8s-api-credentials.d.ts +29 -0
  226. package/dist/k8s-api-credentials.js +25 -0
  227. package/dist/lane-home-probe.d.ts +3 -7
  228. package/dist/lane-home-probe.js +2 -2
  229. package/dist/leader/diffup.d.ts +19 -0
  230. package/dist/leader/diffup.js +7 -0
  231. package/dist/leader/leader.d.ts +116 -11
  232. package/dist/leader/leader.js +69 -5
  233. package/dist/leader/repair-wire.js +2 -2
  234. package/dist/leader/run-entry.d.ts +2 -1
  235. package/dist/leader/run-entry.js +1 -1
  236. package/dist/leader/wire.d.ts +42 -132
  237. package/dist/leader/wire.js +81 -67
  238. package/dist/leg-facts.d.ts +13 -5
  239. package/dist/leg-facts.js +2 -1
  240. package/dist/memory-scope.d.ts +23 -11
  241. package/dist/memory-scope.js +18 -6
  242. package/dist/memory-sync-client.d.ts +30 -2
  243. package/dist/memory-sync-client.js +16 -9
  244. package/dist/model-entry-headers.d.ts +9 -10
  245. package/dist/model-entry-headers.js +0 -4
  246. package/dist/model-entry-refusal.d.ts +7 -4
  247. package/dist/model-entry-refusal.js +11 -5
  248. package/dist/model-plane-face.d.ts +1 -1
  249. package/dist/model-plane-face.js +3 -1
  250. package/dist/model-route-endpoint.d.ts +13 -7
  251. package/dist/model-route-endpoint.js +14 -11
  252. package/dist/model-select.d.ts +22 -0
  253. package/dist/model-select.js +9 -0
  254. package/dist/model-unreachable-notice.d.ts +11 -0
  255. package/dist/model-unreachable-notice.js +4 -4
  256. package/dist/object-store-buckets.d.ts +640 -6
  257. package/dist/object-store-buckets.js +166 -0
  258. package/dist/observability/err-text.d.ts +7 -0
  259. package/dist/observability/err-text.js +5 -0
  260. package/dist/observability/fail-open.d.ts +25 -17
  261. package/dist/observability/fail-open.js +25 -17
  262. package/dist/observability/logger.js +3 -1
  263. package/dist/observability/metrics.js +1 -0
  264. package/dist/operator-roster.d.ts +68 -0
  265. package/dist/operator-roster.js +32 -0
  266. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  267. package/dist/orchestration/workflow-notify-journal.js +12 -1
  268. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  269. package/dist/orchestration/workflow-park-decision.js +49 -10
  270. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  271. package/dist/orchestration/workflow-park-holder.js +98 -0
  272. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  273. package/dist/orchestration/workflow-record-fence.js +42 -0
  274. package/dist/outbound-dispatcher.d.ts +71 -8
  275. package/dist/outbound-dispatcher.js +48 -7
  276. package/dist/owner-faces.d.ts +2 -2
  277. package/dist/parked-decide.d.ts +106 -55
  278. package/dist/parked-decide.js +153 -117
  279. package/dist/peer-directory.d.ts +2 -2
  280. package/dist/peer-inbound-face.d.ts +2 -6
  281. package/dist/peer-inbound-face.js +0 -3
  282. package/dist/permission-mode-admission.d.ts +74 -5
  283. package/dist/permission-mode-admission.js +56 -3
  284. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  285. package/dist/plugins/adoption-log-sql.js +7 -1
  286. package/dist/plugins/approval-ask-store-file.d.ts +14 -2
  287. package/dist/plugins/approval-ask-store-file.js +11 -0
  288. package/dist/plugins/approval-ask-store-memory.d.ts +10 -1
  289. package/dist/plugins/approval-ask-store-memory.js +35 -10
  290. package/dist/plugins/approval-ask-store-sql.d.ts +69 -4
  291. package/dist/plugins/approval-ask-store-sql.js +45 -5
  292. package/dist/plugins/approval-exemption-store.js +3 -0
  293. package/dist/plugins/approval-nonce-store.js +2 -0
  294. package/dist/plugins/blob-backend.d.ts +83 -7
  295. package/dist/plugins/blob-backend.js +57 -6
  296. package/dist/plugins/breaker-state-sql.js +2 -0
  297. package/dist/plugins/caching-session-store.d.ts +9 -15
  298. package/dist/plugins/caching-session-store.js +6 -0
  299. package/dist/plugins/checkpoint-index-columns.d.ts +20 -16
  300. package/dist/plugins/checkpoint-index-columns.js +3 -6
  301. package/dist/plugins/checkpoint-store-face.d.ts +119 -61
  302. package/dist/plugins/checkpoint-store-face.js +134 -55
  303. package/dist/plugins/device-store-sql.js +6 -0
  304. package/dist/plugins/error-origin.d.ts +18 -0
  305. package/dist/plugins/error-origin.js +10 -0
  306. package/dist/plugins/execution-placement-sql.js +6 -6
  307. package/dist/plugins/image-bake-store-sql.js +6 -0
  308. package/dist/plugins/image-index-sql.js +4 -0
  309. package/dist/plugins/landed-attendants.d.ts +212 -0
  310. package/dist/plugins/landed-attendants.js +161 -0
  311. package/dist/plugins/leader-run-store-sql.js +4 -0
  312. package/dist/plugins/local-checkpoint-store.d.ts +13 -3
  313. package/dist/plugins/local-checkpoint-store.js +38 -49
  314. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  315. package/dist/plugins/local-session-live-reference.js +39 -0
  316. package/dist/plugins/local-session-store.d.ts +71 -33
  317. package/dist/plugins/local-session-store.js +129 -27
  318. package/dist/plugins/memory-engine-pg.js +4 -0
  319. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  320. package/dist/plugins/memory-engine-tidb.js +4 -0
  321. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  322. package/dist/plugins/memory-sync-store-pg.js +5 -0
  323. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  324. package/dist/plugins/one-time-migrations.d.ts +104 -80
  325. package/dist/plugins/one-time-migrations.js +226 -132
  326. package/dist/plugins/org-delivery-quota-store.js +4 -1
  327. package/dist/plugins/outcome-ledger-sql.js +2 -0
  328. package/dist/plugins/permission-rule-store-sql.js +11 -4
  329. package/dist/plugins/pg-cost-quota.js +4 -0
  330. package/dist/plugins/pg-pool.js +35 -10
  331. package/dist/plugins/pg-rate-limiter.js +2 -0
  332. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  333. package/dist/plugins/posix-shell-fs.js +4 -1
  334. package/dist/plugins/remote-env-adb.d.ts +19 -15
  335. package/dist/plugins/remote-env-adb.js +41 -15
  336. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  337. package/dist/plugins/remote-env-connect-seat.js +72 -0
  338. package/dist/plugins/remote-env-device.d.ts +22 -5
  339. package/dist/plugins/remote-env-device.js +106 -8
  340. package/dist/plugins/remote-env-e2b.d.ts +15 -6
  341. package/dist/plugins/remote-env-e2b.js +42 -32
  342. package/dist/plugins/remote-env-file-error.js +6 -2
  343. package/dist/plugins/remote-env-host.d.ts +46 -10
  344. package/dist/plugins/remote-env-host.js +124 -52
  345. package/dist/plugins/remote-env-k8s.d.ts +109 -41
  346. package/dist/plugins/remote-env-k8s.js +160 -54
  347. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  348. package/dist/plugins/remote-env-local-docker.js +34 -41
  349. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  350. package/dist/plugins/remote-env-ssh.js +60 -59
  351. package/dist/plugins/remote-shell.d.ts +98 -1
  352. package/dist/plugins/remote-shell.js +218 -0
  353. package/dist/plugins/replica-registration.d.ts +1 -1
  354. package/dist/plugins/replica-registration.js +1 -1
  355. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  356. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  357. package/dist/plugins/retention-lane-store-sql.js +4 -0
  358. package/dist/plugins/retention-sql.d.ts +20 -2
  359. package/dist/plugins/retention-sql.js +11 -0
  360. package/dist/plugins/run-store-sql.d.ts +21 -2
  361. package/dist/plugins/run-store-sql.js +31 -7
  362. package/dist/plugins/s3-presign.d.ts +23 -0
  363. package/dist/plugins/s3-presign.js +37 -3
  364. package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
  365. package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
  366. package/dist/plugins/scheduler-support.d.ts +2 -2
  367. package/dist/plugins/scheduler-support.js +0 -3
  368. package/dist/plugins/schema-consistency.d.ts +4 -2
  369. package/dist/plugins/schema-consistency.js +19 -2
  370. package/dist/plugins/schema-indexes.js +2 -0
  371. package/dist/plugins/send-file-ledger.d.ts +2 -2
  372. package/dist/plugins/send-file-ledger.js +5 -2
  373. package/dist/plugins/send-user-file.d.ts +3 -4
  374. package/dist/plugins/send-user-file.js +56 -52
  375. package/dist/plugins/serving-requirement.d.ts +26 -7
  376. package/dist/plugins/serving-requirement.js +11 -4
  377. package/dist/plugins/session-birth.d.ts +6 -2
  378. package/dist/plugins/session-blob-claim-token.d.ts +15 -0
  379. package/dist/plugins/session-blob-claim-token.js +20 -0
  380. package/dist/plugins/session-blob-namespace.d.ts +46 -0
  381. package/dist/plugins/session-blob-namespace.js +116 -0
  382. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  383. package/dist/plugins/session-ext-table.d.ts +14 -1
  384. package/dist/plugins/session-ext-table.js +5 -1
  385. package/dist/plugins/session-row-sql.d.ts +49 -2
  386. package/dist/plugins/session-row-sql.js +56 -13
  387. package/dist/plugins/session-store-sql.d.ts +34 -18
  388. package/dist/plugins/session-store-sql.js +98 -17
  389. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  390. package/dist/plugins/shared-memory-store-sql.js +6 -2
  391. package/dist/plugins/snapshot-bucket-presence.d.ts +25 -2
  392. package/dist/plugins/snapshot-bucket-presence.js +8 -2
  393. package/dist/plugins/sql-driver.d.ts +2 -1
  394. package/dist/plugins/sql-driver.js +18 -3
  395. package/dist/plugins/sql-errors.d.ts +11 -6
  396. package/dist/plugins/sql-errors.js +5 -6
  397. package/dist/plugins/sql-json-column.d.ts +1 -1
  398. package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
  399. package/dist/plugins/stop-then-start-sentence.js +14 -10
  400. package/dist/plugins/stop-then-start.d.ts +109 -0
  401. package/dist/plugins/stop-then-start.js +104 -0
  402. package/dist/plugins/store-backend.d.ts +84 -15
  403. package/dist/plugins/store-backend.js +236 -72
  404. package/dist/plugins/store-boundary.d.ts +57 -0
  405. package/dist/plugins/store-boundary.js +139 -0
  406. package/dist/plugins/store-contracts.d.ts +17 -0
  407. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  408. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  409. package/dist/plugins/store-fault.d.ts +26 -7
  410. package/dist/plugins/store-fault.js +18 -2
  411. package/dist/plugins/task-attachment-store.d.ts +2 -1
  412. package/dist/plugins/task-attachment-store.js +14 -1
  413. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  414. package/dist/plugins/task-list-store-sql.js +10 -8
  415. package/dist/plugins/tidb-cost-quota.js +4 -0
  416. package/dist/plugins/tidb-pool.js +21 -25
  417. package/dist/plugins/tidb-rate-limiter.js +4 -0
  418. package/dist/plugins/user-input-ledger-sql.js +4 -0
  419. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  420. package/dist/plugins/workflow-run-store-sql.js +64 -4
  421. package/dist/plugins/workspace-custody.d.ts +4 -3
  422. package/dist/plugins/workspace-fill.d.ts +4 -7
  423. package/dist/plugins/workspace-fill.js +2 -1
  424. package/dist/plugins/write-behind-counter.js +5 -0
  425. package/dist/project-context.d.ts +0 -2
  426. package/dist/project-context.js +4 -8
  427. package/dist/project-registry.d.ts +46 -0
  428. package/dist/project-registry.js +44 -0
  429. package/dist/question.d.ts +2 -1
  430. package/dist/question.js +5 -13
  431. package/dist/request-form.d.ts +6 -1
  432. package/dist/request-form.js +4 -1
  433. package/dist/request-key-closure.js +1 -1
  434. package/dist/request-value-closure.d.ts +4 -0
  435. package/dist/request-value-closure.js +10 -0
  436. package/dist/rule-issue-reading.d.ts +1 -1
  437. package/dist/rules-consent.d.ts +1 -1
  438. package/dist/run-acceptance.d.ts +3 -2
  439. package/dist/run-acceptance.js +4 -6
  440. package/dist/run-local.js +9 -9
  441. package/dist/runs.d.ts +54 -16
  442. package/dist/runs.js +67 -13
  443. package/dist/runtime-governance.d.ts +5 -4
  444. package/dist/security.d.ts +30 -32
  445. package/dist/security.js +41 -7
  446. package/dist/sema-config-dir.d.ts +2 -1
  447. package/dist/server-secret-env.d.ts +12 -10
  448. package/dist/server-secret-env.js +24 -15
  449. package/dist/session-bindings.d.ts +82 -0
  450. package/dist/session-bindings.js +18 -0
  451. package/dist/session-children-retire.d.ts +2 -2
  452. package/dist/session-children-retire.js +2 -6
  453. package/dist/session-deletion.d.ts +16 -1
  454. package/dist/session-error-wire.d.ts +3 -3
  455. package/dist/session-error-wire.js +3 -3
  456. package/dist/session-incarnation.d.ts +10 -0
  457. package/dist/session-incarnation.js +10 -1
  458. package/dist/session-kind.d.ts +57 -0
  459. package/dist/session-kind.js +22 -0
  460. package/dist/session-row.d.ts +21 -1
  461. package/dist/session-row.js +7 -1
  462. package/dist/session-sync-kernel.d.ts +24 -14
  463. package/dist/session-sync-kernel.js +3 -6
  464. package/dist/session-sync.d.ts +25 -103
  465. package/dist/session-sync.js +14 -76
  466. package/dist/session-titler.d.ts +10 -3
  467. package/dist/session-titler.js +19 -6
  468. package/dist/ssh-host-key.d.ts +5 -0
  469. package/dist/ssh-host-key.js +3 -0
  470. package/dist/stores-sql/blob-index-sql.d.ts +30 -9
  471. package/dist/stores-sql/blob-index-sql.js +40 -21
  472. package/dist/stores-sql/checkpoint-store-sql.d.ts +54 -27
  473. package/dist/stores-sql/checkpoint-store-sql.js +70 -146
  474. package/dist/stores-sql/file-history-store-sql.d.ts +113 -15
  475. package/dist/stores-sql/file-history-store-sql.js +205 -95
  476. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  477. package/dist/stores-sql/pg-session-storage.js +37 -13
  478. package/dist/stores-sql/retention-store-sql.d.ts +1 -9
  479. package/dist/stores-sql/retention-store-sql.js +5 -19
  480. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  481. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  482. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  483. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  484. package/dist/stores-sql/tidb-session-store.js +37 -13
  485. package/dist/submission-exit.d.ts +3 -2
  486. package/dist/submission-exit.js +9 -1
  487. package/dist/task-cwd.d.ts +2 -2
  488. package/dist/task-settings.d.ts +7 -5
  489. package/dist/task-settings.js +3 -3
  490. package/dist/terminal.d.ts +33 -2
  491. package/dist/terminal.js +139 -9
  492. package/dist/tool-approval.d.ts +465 -507
  493. package/dist/tool-approval.js +606 -1222
  494. package/dist/trace/core-keyset-guard.d.ts +1 -1
  495. package/dist/trace/ledger-events.d.ts +3 -3
  496. package/dist/trace/project.d.ts +2 -3
  497. package/dist/trace/redact.js +3 -2
  498. package/dist/trace/self-minted-wire.d.ts +571 -178
  499. package/dist/trace/self-minted-wire.js +189 -56
  500. package/dist/web-admin-client/apply-effective.js +2 -2
  501. package/dist/web-admin-client/read-warnings.d.ts +2 -2
  502. package/dist/web-admin-client/read-warnings.js +1 -1
  503. package/dist/web-admin-client/types.d.ts +1 -1
  504. package/dist/workspace-space.d.ts +10 -4
  505. package/dist/workspace-space.js +4 -1
  506. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +79 -28
  507. package/package.json +7 -3
  508. package/scripts/embed-minimal.mjs +3 -3
  509. package/wire-changes/server@7.151.0.json +762 -0
  510. package/wire-changes/server@7.152.0.json +900 -0
  511. package/dist/config-d-migration.d.ts +0 -37
  512. package/dist/config-d-migration.js +0 -60
  513. package/dist/http/session-inherit-env.d.ts +0 -36
  514. package/dist/http/session-inherit-env.js +0 -6
@@ -9,7 +9,7 @@ import { PgMemoryEngineBackend, ensurePgMemoryEngineSchema } from "../plugins/me
9
9
  import { TiDBMemoryEngineBackend, ensureTiDBMemoryEngineSchema } from "../plugins/memory-engine-tidb.js";
10
10
  import { PgMemoryHistoryStore, PgMemorySyncStore, ensurePgMemoryHistorySchema, ensurePgMemorySyncSchema } from "../plugins/memory-sync-store-pg.js";
11
11
  import { TiDBMemoryHistoryStore, TiDBMemorySyncStore, ensureTiDBMemoryHistorySchema, ensureTiDBMemorySyncSchema } from "../plugins/memory-sync-store-tidb.js";
12
- import { MinioBlobBackend } from "../plugins/blob-backend.js";
12
+ import { createSessionBlobBackend } from "../plugins/blob-backend.js";
13
13
  import { ensureSnapshotBuckets } from "../plugins/snapshot-bucket-presence.js";
14
14
  import { PgBackgroundAgentStore, TiDBBackgroundAgentStore, ensurePgBackgroundAgentSchema, ensureTiDBBackgroundAgentSchema } from "../stores-sql/background-agent-store-sql.js";
15
15
  import { recordFailOpen } from "../observability/fail-open.js";
@@ -304,14 +304,17 @@ export async function openStores(ctx) {
304
304
  const mysqlPool = backend?.mysqlPool?.();
305
305
  const pgPool = backend?.pgPool?.();
306
306
  if (pgPool || mysqlPool) {
307
- const minio = config.snapshotBlobStore;
308
- if (!minio) {
307
+ const namespace = backend?.sessionBlobNamespace?.();
308
+ if (!config.snapshotBlobStore) {
309
309
  logger.error("attachments_disabled_object_store_required", {
310
310
  hint: "cloud deployments must configure object storage (MINIO_ENDPOINT/MINIO_ACCESS_KEY/MINIO_SECRET_KEY) — attachment routes will 501 until it is set",
311
311
  });
312
312
  }
313
+ else if (!namespace) {
314
+ throw new Error("object storage is configured but the store backend holds no session blob namespace — the attachment store's bytes have no namespace proven to be this database's (a store backend that does not implement sessionBlobNamespace())");
315
+ }
313
316
  else {
314
- const bytes = new MinioBlobBackend({ ...minio, keyPrefix: `${minio.keyPrefix ?? ""}attachments/` });
317
+ const bytes = createSessionBlobBackend(namespace, "attachments");
315
318
  if (pgPool) {
316
319
  const q = async (text, params) => { const r = await pgPool.query(text, params); return { rows: r.rows }; };
317
320
  await ensurePgTaskAttachmentSchema(q);
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { readFile as fsReadFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
- import { WEB_ADMIN_ENV, formatConfigPath } from "@sema-agent/settings-schema";
5
+ import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
6
6
  import { stableStringify } from "@sema-agent/settings-schema/hash";
7
7
  import { buildModelRefusalsSignal } from "../model-entry-refusal.js";
8
8
  import { CenterPromptSource, FilePromptArtifactStore, FilePromptSourceStateStore, MemoryPromptArtifactStore, MemoryPromptSourceStateStore, } from "@sema-agent/core";
@@ -13,7 +13,7 @@ import { centerScenarios, centerScenarioDetails } from "../capabilities/scenario
13
13
  import { isRosterGateArmed } from "../config.js";
14
14
  import { DEPLOYMENT_SHAPE_PREDICATES } from "../deployment-shape.js";
15
15
  import { defaultLkgPath, defaultSkillCacheDir, saveLkg, loadLkg, preIdentityLkgLeftover, PRE_IDENTITY_LKG_REASON } from "../config-lkg.js";
16
- import { answerStillCurrent, centerStateBin, credentialIdentityNow, judgeCenterCredentialAtBoot } from "../center-credential.js";
16
+ import { answerStillCurrent, buildAssertionTokenBootFields, centerStateBin, credentialIdentityNow, judgeCenterCredentialAtBoot } from "../center-credential.js";
17
17
  import { createCenterConfigTier } from "../center-config-tier.js";
18
18
  import { buildCenterCredentialHealthView, createCenterCredentialRenewer } from "../center-credential-renewer.js";
19
19
  import { centerManagedConfigKeys } from "../web-admin-client/apply-effective.js";
@@ -103,6 +103,8 @@ export async function createWebAdminRuntime(ctx) {
103
103
  if (bootVerdict?.verdict === "loud") {
104
104
  logger.error("center_credential_unreadable", { key: WEB_ADMIN_ENV.tokenFile, failure: bootVerdict.failure, reason: bootVerdict.reason, effect: bootVerdict.effect });
105
105
  }
106
+ if (cc !== undefined)
107
+ logger.info("center_assertion_token", buildAssertionTokenBootFields(cc.assertionToken));
106
108
  const credentialRenewer = cc !== undefined && cc.credential.origin.from === "file"
107
109
  ? createCenterCredentialRenewer({ source: cc.credential, centerUrl: cc.baseUrl, leadMs: config.centerCredentialRenewLeadMs, logger })
108
110
  : undefined;
@@ -521,12 +523,7 @@ export async function createWebAdminRuntime(ctx) {
521
523
  }
522
524
  if (read.migrated !== undefined) {
523
525
  const m = read.migrated;
524
- logger.info("config_lkg_migrated", {
525
- to: lkgPath,
526
- fromFormat: m.fromFormat,
527
- ...(m.note !== undefined ? { note: m.note } : {}),
528
- receipts: m.receipts.map((r) => ({ migration: r.migration, document: r.document, path: formatConfigPath(r.path), appliedAs: r.appliedAs })),
529
- });
526
+ logger.info("config_lkg_migrated", { to: lkgPath, fromFormat: m.fromFormat, note: m.note });
530
527
  try {
531
528
  await saveLkg(lkgPath, cc?.worker, identity, read.lkg.effective, read.lkg.etag);
532
529
  }
@@ -11,11 +11,12 @@
11
11
  * → `workflowRunStore`(包装体)的顺序是数据依赖链,不可重排。
12
12
  * 3. `getRunStore()` 是晚绑取值(runStore 在本段之后构造),原文靠同作用域前向引用。
13
13
  */
14
- import { type WorkflowRun, type WorkflowRunStore } from "@sema-agent/core";
14
+ import { type WorkflowRun } from "@sema-agent/core";
15
15
  import type { ServiceConfig } from "../config.js";
16
16
  import { FleetEventBus } from "../fleet/fleet-bus.js";
17
17
  import { type WorkflowAgentSessionIndex } from "../orchestration/workflow-agent-session-index.js";
18
18
  import type { WorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
19
+ import { HeldParksHere } from "../orchestration/workflow-park-holder.js";
19
20
  import type { Logger } from "../observability/logger.js";
20
21
  import type { Metrics } from "../observability/metrics.js";
21
22
  import { type WorkflowCompletionInbox } from "../orchestration/workflow-completion-inbox.js";
@@ -31,9 +32,12 @@ export interface WorkflowOrchestrationCtx {
31
32
  backend: StoreBackend | undefined;
32
33
  /** 晚绑(runStore 在本段之后构造)——见文件头「位置即契约」③。 */
33
34
  getRunStore: () => ReturnType<StoreBackend["run"]> | undefined;
35
+ /** 晚绑(HTTP 服务的产物,第 10 段之后才有):run 收场送达里把「带着已受理、未交付的决定收场」的那条 run 的行交给续跑车道的那一手。
36
+ * 抛 = 需要重投(会话正忙 / 店瞬态 / 收编弧在跑 / 本座还没绑)⇒ 不 ack、`recover` 在维护拍上重投。契约属主 = `http/resume-legs.ts` 的 `handOverRunEndedDecisions`。 */
37
+ getRunEndedHandoff: () => ((runId: string) => Promise<void>) | undefined;
34
38
  }
35
39
  export declare function createWorkflowOrchestration(ctx: WorkflowOrchestrationCtx): {
36
- sqlWorkflowRunStore: WorkflowRunStore | undefined;
40
+ sqlWorkflowRunStore: import("../plugins/workflow-run-store-sql.js").SqlWorkflowRunStore | undefined;
37
41
  workflowNotifyJournal: import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore | undefined;
38
42
  workflowCompletionInbox: WorkflowCompletionInbox | undefined;
39
43
  deliverWorkflowCompletion: (p: WorkflowCompletionPayload) => Promise<void>;
@@ -51,5 +55,6 @@ export declare function createWorkflowOrchestration(ctx: WorkflowOrchestrationCt
51
55
  };
52
56
  workflowAgentSessionIndex: WorkflowAgentSessionIndex | undefined;
53
57
  workflowParkDecisions: WorkflowParkDecisionStore | undefined;
58
+ heldParksHere: HeldParksHere | undefined;
54
59
  };
55
60
  //# sourceMappingURL=workflow-orchestration.d.ts.map
@@ -2,6 +2,8 @@ import { FileWorkflowRunStore, InMemoryWorkflowRunStore } from "@sema-agent/core
2
2
  import { join } from "node:path";
3
3
  import { FleetEventBus } from "../fleet/fleet-bus.js";
4
4
  import { LocalWorkflowAgentSessionIndex } from "../orchestration/workflow-agent-session-index.js";
5
+ import { FencedWorkflowRecordStore } from "../orchestration/workflow-record-fence.js";
6
+ import { HeldParksHere } from "../orchestration/workflow-park-holder.js";
5
7
  import { createCorruptReadFailOpenSeat } from "../observability/corrupt-read-seat.js";
6
8
  import { FileWorkflowCompletionInbox, InMemoryWorkflowCompletionInbox, buildWorkflowCompleteInboxEntry, resolveCompletionRoute } from "../orchestration/workflow-completion-inbox.js";
7
9
  import { FileWorkflowNotifyJournalStore, JournalingWorkflowRunStore, WorkflowNotifyGate } from "../orchestration/workflow-notify-journal.js";
@@ -10,16 +12,16 @@ import { WorkflowAgentRegistry } from "../orchestration/workflow-agent-steer.js"
10
12
  import { workflowJournalOf } from "../plugins/store-backend.js";
11
13
  import { seatText } from "../trace/exit-seat.js";
12
14
  export function createWorkflowOrchestration(ctx) {
13
- const { config, logger, metrics, localRoot, backend, getRunStore } = ctx;
15
+ const { config, logger, metrics, localRoot, backend, getRunStore, getRunEndedHandoff } = ctx;
14
16
  const workflowBootAtMs = Date.now();
15
17
  const sqlWorkflowRunStore = config.workflowRunStoreBackend === "auto" ? backend?.workflowRun?.((msg, meta) => logger.warn(msg, meta)) : undefined;
16
18
  const baseWorkflowRunStore = config.selfOrchestrationEnabled
17
19
  ? config.workflowRunStoreBackend === "memory"
18
- ? new InMemoryWorkflowRunStore()
20
+ ? new FencedWorkflowRecordStore(new InMemoryWorkflowRunStore())
19
21
  : (sqlWorkflowRunStore ??
20
- new FileWorkflowRunStore(join(config.localDataRoot ?? localRoot, "workflows"), {
22
+ new FencedWorkflowRecordStore(new FileWorkflowRunStore(join(config.localDataRoot ?? localRoot, "workflows"), {
21
23
  onCorruptRead: createCorruptReadFailOpenSeat("server.workflow-run.corrupt-record-skipped"),
22
- }))
24
+ })))
23
25
  : undefined;
24
26
  const workflowNotifyJournal = config.selfOrchestrationEnabled && config.workflowRunStoreBackend !== "memory"
25
27
  ? (sqlWorkflowRunStore ? backend.notifyJournal() : new FileWorkflowNotifyJournalStore(join(config.localDataRoot ?? localRoot, "workflows"), undefined))
@@ -36,6 +38,20 @@ export function createWorkflowOrchestration(ctx) {
36
38
  ...(p.sourceTaskId ? { sourceTaskId: p.sourceTaskId } : {}),
37
39
  });
38
40
  metrics.inc("workflow_runs_total", { status: p.status });
41
+ if (workflowParkDecisions !== undefined) {
42
+ const handOver = getRunEndedHandoff();
43
+ try {
44
+ if (handOver === undefined)
45
+ throw new Error(`workflow run ${p.runId}: the run-ended decision handoff is not bound yet (the HTTP server is not up) — leaving the completion pending for the next recovery sweep`);
46
+ await handOver(p.runId);
47
+ }
48
+ catch (err) {
49
+ if (workflowNotifyGate !== undefined)
50
+ throw err;
51
+ metrics.inc("workflow_park_handoff_total", { result: "not_redelivered" });
52
+ logger.warn("workflow_park_handoff_not_redelivered", { runId: p.runId, err: seatText("operator-log-text", String(err)) });
53
+ }
54
+ }
39
55
  if (!workflowCompletionInbox)
40
56
  return;
41
57
  try {
@@ -61,9 +77,10 @@ export function createWorkflowOrchestration(ctx) {
61
77
  ? backend.workflowAgentSessionIndex()
62
78
  : new LocalWorkflowAgentSessionIndex(join(config.localDataRoot ?? localRoot, "workflows"), undefined))
63
79
  : undefined;
64
- const workflowParkDecisions = config.selfOrchestrationEnabled && backend !== undefined && (sqlWorkflowRunStore !== undefined || backend.kind === "local") ? backend.workflowParkDecisions?.() : undefined;
80
+ const workflowParkDecisions = config.selfOrchestrationEnabled && backend !== undefined && baseWorkflowRunStore !== undefined && (sqlWorkflowRunStore !== undefined || backend.kind === "local") ? backend.workflowParkDecisions?.(baseWorkflowRunStore) : undefined;
81
+ const heldParksHere = workflowParkDecisions !== undefined ? new HeldParksHere() : undefined;
65
82
  const workflowRunStore = baseWorkflowRunStore
66
- ? new JournalingWorkflowRunStore(baseWorkflowRunStore, workflowNotifyGate, fleetBus, workflowAgentSessionIndex)
83
+ ? new JournalingWorkflowRunStore(baseWorkflowRunStore, workflowNotifyGate, fleetBus, workflowAgentSessionIndex, heldParksHere)
67
84
  : undefined;
68
85
  const replicaLocalNotifyJournal = workflowNotifyJournal instanceof FileWorkflowNotifyJournalStore;
69
86
  const workflowRecoverOpts = {
@@ -78,7 +95,7 @@ export function createWorkflowOrchestration(ctx) {
78
95
  return {
79
96
  sqlWorkflowRunStore, workflowNotifyJournal, workflowCompletionInbox, deliverWorkflowCompletion,
80
97
  workflowNotifyGate, fleetBus, workflowRunStore, workflowJournalStore, outcomeSink,
81
- workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex, workflowParkDecisions,
98
+ workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex, workflowParkDecisions, heldParksHere,
82
99
  };
83
100
  }
84
101
  //# sourceMappingURL=workflow-orchestration.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * **维护拍上有界轮转扫一组候选**的唯一实现(两个调用方:审批族悬挂 ask 的跨副本执行通知 `ToolApprovalCoordinator.pollSuspendedDecisions`、
3
+ * workflow 停驻卡持有进程的拉取腿 `orchestration/workflow-park-holder.ts`)。
4
+ *
5
+ * 判据(审批族 codex R3 / R5 的两条修,原样搬来):
6
+ * · **帽**:每拍最多 `maxPerTick` 条;**预算**:每拍最多 `budgetMs` 墙钟,超了当场停(剩下的下拍接着扫)—— 串行点读在慢店上不许把「一拍的延迟」变成分钟级;
7
+ * · **轮转**:起点是「上一拍扫到第几个」的下一位 —— 没有它,帽把同样的前 N 条锁成永久前缀,后面的永远轮不到;
8
+ * · 游标是**整数偏移**,不是条目身份:上一拍最后碰的那条恰好消失时,按身份找位置会塌回队首(永久饥饿);偏移只回答「扫到第几个」,集合变了也只是近似。
9
+ * 多层(`tiers`):按层序扫,每层各一只游标;前一层吃满帽 / 预算,后一层这一拍轮不到。截断的那一拍由调用方响亮报(`truncated` / `backlog`)。
10
+ */
11
+ /** 一层候选的轮转游标(调用方持有,跨拍存活)。 */
12
+ export interface RotationCursor {
13
+ offset: number;
14
+ }
15
+ export interface RotationLimits {
16
+ readonly maxPerTick: number;
17
+ readonly budgetMs: number;
18
+ }
19
+ /** 一拍的读数:`visited` = 本拍真处理的条数;`backlog` = 还没轮到的(下界 0);`truncated` = 帽 / 预算截断位。 */
20
+ export interface RotationTally {
21
+ readonly visited: number;
22
+ readonly backlog: number;
23
+ readonly truncated: boolean;
24
+ }
25
+ export declare function boundedRotation<T>(tiers: ReadonlyArray<{
26
+ readonly items: readonly T[];
27
+ readonly cursor: RotationCursor;
28
+ }>, limits: RotationLimits, visit: (item: T) => Promise<void>, now?: () => number): Promise<RotationTally>;
29
+ //# sourceMappingURL=bounded-rotation.d.ts.map
@@ -0,0 +1,24 @@
1
+ export async function boundedRotation(tiers, limits, visit, now = Date.now) {
2
+ const ordered = [];
3
+ tiers.forEach(({ items, cursor }, tier) => {
4
+ const start = items.length > 0 ? cursor.offset % items.length : 0;
5
+ for (const item of [...items.slice(start), ...items.slice(0, start)])
6
+ ordered.push({ item, tier, start });
7
+ });
8
+ const deadlineMs = now() + limits.budgetMs;
9
+ const visitedPerTier = tiers.map(() => 0);
10
+ let visited = 0;
11
+ let truncated = false;
12
+ for (const { item, tier, start } of ordered) {
13
+ if (visited >= limits.maxPerTick || now() >= deadlineMs) {
14
+ truncated = true;
15
+ break;
16
+ }
17
+ visited++;
18
+ tiers[tier].cursor.offset = start + ++visitedPerTier[tier];
19
+ await visit(item);
20
+ }
21
+ const total = tiers.reduce((n, t) => n + t.items.length, 0);
22
+ return { visited, backlog: Math.max(0, total - visited), truncated };
23
+ }
24
+ //# sourceMappingURL=bounded-rotation.js.map
@@ -22,9 +22,9 @@
22
22
  *
23
23
  * 🔴 **刻意不合并进 `approvals` 或 `toolApproval`**:
24
24
  * · `approvals` 答的是「这条车道在不在」(它为真而本位为假的部署是**常态**:没开工具审批的那些);
25
- * · `toolApproval` 答的是「活体工具审批 HITL 在不在」,与「那条 SSE 推不推 live 行」不是一回事 ——
26
- * 没有 checkpoint 底座的部署上它可以为真而**根本没有这条流**。
27
- * 任一位单读都会对一半部署说谎,所以本位是它们的合取、而不是其中之一的别名。
25
+ * · `toolApproval` 答的是「活体工具审批 HITL 在不在」。协调器只在呈卡协议上场(含 park 设施 = checkpoint 底座)时构造,
26
+ * 所以生产装配上 `toolApproval` 为真蕴含 ①,本位与 `toolApproval` 同值;本位仍逐项对着腿的判据写合取(不读另一位的投影)。
27
+ * 三位(`toolApproval` / `streamApproval` / 本位)如今说的是同一件事 —— 合并成一位是另一件 wire 变更,不在这里做。
28
28
  *
29
29
  * ⚠️ **位为真只保证这条源在场**,不保证这一次有任何悬挂 ask、也不保证跨副本可见:live 半场是**进程内
30
30
  * 投影**(与 `GET /v1/approvals` 的 `livePending` 逐字同限,非本件引入),durable park 行那一半才是
@@ -347,12 +347,26 @@ export interface ScenarioRuling {
347
347
  */
348
348
  export type ScenarioRulingRead = ScenarioRuling | "unavailable" | undefined;
349
349
  /**
350
- * 一个场景名的**来源**(闭集:新增一词 ⇒ {@link danglingScenarioRefusal} 的穷尽 switch 编译红)。
351
- * · `ruling` —— 中心按主体指派的场景(`ScenarioRuling.scenario`);
352
- * · `deployment` —— 部署自己写的缺省(`DEFAULT_SCENARIO` / config `defaultScenario`)。
353
- * 请求体显式给的名字不在此列:那是调用方的话,不在册 ⇒ 400 `scenario_unknown`(见 {@link gateScenarioRequest})。
350
+ * 一次请求生效的场景名**从哪一层来**(闭集,唯一属主;wire 上 `GET /v1/capabilities/scenario` 的 `source`、`state.scenario_assignment_unknown` 拒体的 `source` 读的都是它):
351
+ * · `request` —— 这次请求点了名(体 `scenario` / 场景头 `x-agent-scenario` / 读面的 `?scenario=`;点名读法 `request-form.ts` `scenarioRequestedBy`);
352
+ * · `ruling` —— 没点名,中心按主体指派的场景(`ScenarioRuling.scenario`);
353
+ * · `deployment` —— 没点名、也没有指派,部署自己写的缺省(`DEFAULT_SCENARIO` / config `defaultScenario`)。
354
+ * 新增一词 ⇒ 自铸登记 `selfMinted.scenarioSource` 的 `satisfies Record<ScenarioSource, …>` 编译红;链上两层另由 {@link danglingScenarioRefusal} 的穷尽 switch 判。
354
355
  */
355
- export type ScenarioNameSource = "ruling" | "deployment";
356
+ export type ScenarioSource = "request" | "ruling" | "deployment";
357
+ /**
358
+ * 指派链上的两层(请求没点名时走的链)—— 「名字悬空」只在这两层上成立:点名的不在册名是调用方的错,门先答 400 `scenario_unknown`,不走悬空判据。
359
+ * 所以 `state.scenario_assignment_unknown` 拒体的 `source` 只会是这两词。
360
+ */
361
+ export type ScenarioChainSource = Exclude<ScenarioSource, "request">;
362
+ /**
363
+ * **门的答**(唯一一种形):这次请求生效的场景名(一定在册)与它来自哪一层。提交腿、`run-local` 与每一张读面读的都是这一只答;
364
+ * `GET /v1/capabilities/scenario` 的 200 体就是它(键名同 wire)。
365
+ */
366
+ export interface ScenarioChoice {
367
+ readonly scenario: string;
368
+ readonly source: ScenarioSource;
369
+ }
356
370
  /**
357
371
  * 🔴 **悬空场景名的判据与拒句 —— 全仓唯一属主。**
358
372
  *
@@ -365,10 +379,10 @@ export type ScenarioNameSource = "ruling" | "deployment";
365
379
  * 返回 `undefined` = 在册;否则是**拒句**(点名名字与来源、给在册词表、说怎么修)。判据按**自有键**(`known` 是场景表的
366
380
  * `Object.keys`,`constructor` / `__proto__` 不是场景名)。
367
381
  */
368
- export declare function danglingScenarioRefusal(name: string, source: ScenarioNameSource, known: readonly string[]): string | undefined;
382
+ export declare function danglingScenarioRefusal(name: string, source: ScenarioChainSource, known: readonly string[]): string | undefined;
369
383
  /**
370
- * resolveSpec 的执法入口(指派为默认、body.scenario 可换但限 allowlist)。返回本请求的
371
- * **在册**生效场景名 —— 返回值一定在 `known` 里:下游直接按它取场景,没有「未知名 → default」的回退臂。
384
+ * resolveSpec 的执法入口(指派为默认、body.scenario 可换但限 allowlist)。返回本请求的**门的答**({@link ScenarioChoice}):
385
+ * **在册**生效场景名 + 它来自哪一层 —— 名字一定在 `known` 里:下游直接按它取场景,没有「未知名 → default」的回退臂;来层在铸名的那一臂上同时写下,读面不另算。
372
386
  * 读数 `ruling` 三态各一条出路({@link ScenarioRulingRead}),判序:
373
387
  *
374
388
  * 1. body.scenario 显式给出而不在册 ⇒ typed 400 `scenario_unknown`(调用方的错;词表面先于治理面,不等中心)。
@@ -383,7 +397,7 @@ export declare function danglingScenarioRefusal(name: string, source: ScenarioNa
383
397
  *
384
398
  * `principal` 只进运维日志,不参与判定。
385
399
  */
386
- export declare function gateScenarioRequest(ruling: ScenarioRulingRead, bodyScenario: unknown, defaultScenario: string, known: readonly string[], logger?: Logger, principal?: string): string;
400
+ export declare function gateScenarioRequest(ruling: ScenarioRulingRead, bodyScenario: unknown, defaultScenario: string, known: readonly string[], logger?: Logger, principal?: string): ScenarioChoice;
387
401
  /**
388
402
  * 一条请求的场景名过门 —— {@link gateScenarioRequest} 的**唯一一处实参装配**。
389
403
  *
@@ -393,8 +407,9 @@ export declare function gateScenarioRequest(ruling: ScenarioRulingRead, bodyScen
393
407
  * 每个读口自己拼一遍这六个实参 = 第二只门:两口对「在册」「放行」「缺席取谁」各判各的,读口就开始对不上 run。
394
408
  * 所以装配只在这里,读口持有的是**绑好的门**;凡回答这类问题的口,场景名都由门给 —— 点名与缺席都问。
395
409
  *
396
- * 契约:`(principal, requested) => 在册的场景名`(返回值一定在册;被拒 ⇒ 抛 {@link gateScenarioRequest} 的那几只 typed 错,
397
- * 读口不改写)。`requested` 非串(缺席)⇒ 门走指派链(ruling 胜者,否则部署缺省),与 run 时同一读法。
410
+ * 契约:`(principal, requested) => 门的答 { scenario, source }`({@link ScenarioChoice};名字一定在册;被拒 ⇒ 抛 {@link gateScenarioRequest} 的那几只 typed 错,
411
+ * 读口不改写)。`requested` 非串(缺席)⇒ 门走指派链(ruling 胜者,否则部署缺省),与 run 时同一读法。`requested` 由调用方经 `scenarioRequestedBy`
412
+ * (`request-form.ts`,场景头 × 点名的唯一读法)取 —— 提交腿与读面同调。
398
413
  * `principalCaps` 缺席(无中心 / 干跑 / 嵌入方 / `run-local`)⇒ 读数恒缺席,门走「请求名或部署缺省」那条链;
399
414
  * 在场 ⇒ 它的读数三态({@link ScenarioRulingRead})原样交门,故障态由门拒。
400
415
  */
@@ -411,14 +426,14 @@ export interface ScenarioGateSources {
411
426
  readonly logger?: Logger;
412
427
  }
413
428
  export interface ScenarioGate {
414
- (principal: string | undefined, requested: unknown): Promise<string>;
429
+ (principal: string | undefined, requested: unknown): Promise<ScenarioChoice>;
415
430
  /** 在册词表 —— 门判「在不在册」读的**同一张**场景表的自有键(活读,不抄快照)。请求的场景头在分派层判在册读它(读面没有体,不过整只门)。 */
416
431
  readonly known: () => readonly string[];
417
432
  }
418
433
  /**
419
434
  * 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `peekRuntimeCapsReading` 是同一对:
420
435
  * · `enforce` —— 任务提交腿:中心裁定走执法腿,center 硬失败铸下的 fail-closed 降级项两腿都认;
421
- * · `peek` —— 读面(`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份读数(中心答不出 ⇒ 读面同拒),但硬失败铸的降级项只对读面自己算数,
436
+ * · `peek` —— 读面(`GET /v1/capabilities/scenario` 生效场景面、`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份读数(中心答不出 ⇒ 读面同拒),但硬失败铸的降级项只对读面自己算数,
422
437
  * 不替这个主体的真提交留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面不许成为别人被拒的原因)。
423
438
  */
424
439
  export type ScenarioGateLeg = "enforce" | "peek";
@@ -315,7 +315,7 @@ export function gateScenarioRequest(ruling, bodyScenario, defaultScenario, known
315
315
  extra: { allowlist: allowed },
316
316
  });
317
317
  }
318
- return bodyScenario;
318
+ return { scenario: bodyScenario, source: "request" };
319
319
  }
320
320
  const [name, source] = ruling?.scenario != null ? [ruling.scenario, "ruling"] : [defaultScenario, "deployment"];
321
321
  const refusal = danglingScenarioRefusal(name, source, known);
@@ -323,7 +323,7 @@ export function gateScenarioRequest(ruling, bodyScenario, defaultScenario, known
323
323
  logger?.warn("scenario_assignment_unknown", { scenario: name, source, ...(principal !== undefined ? { principal } : {}) });
324
324
  throw createCodedHttpError(503, "state.scenario_assignment_unknown", refusal, { scenario: name, source });
325
325
  }
326
- return name;
326
+ return { scenario: name, source };
327
327
  }
328
328
  export function createScenarioGate(sources, leg) {
329
329
  const rulingOf = (principal) => {
@@ -21,8 +21,10 @@
21
21
  import type { FlatServiceDeps } from "./http/server.js";
22
22
  import type { ServiceConfig } from "./config.js";
23
23
  import type { OwnerAwareSessionStore } from "./security.js";
24
- import type { ServiceBlobExchange, ServiceFileHistoryStore } from "./plugins/store-backend.js";
24
+ import type { ServiceFileHistoryStore, StoreBackend } from "./plugins/store-backend.js";
25
+ import type { OperatorPower, OperatorRoster } from "./operator-roster.js";
25
26
  import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
27
+ import { type LandingBlobFaces } from "./session-sync.js";
26
28
  import { type WorkspaceSyncCapability } from "./workspace-space.js";
27
29
  import type { WorkspaceCacheCapability } from "./workspace-cache.js";
28
30
  import type { HistoryAnchorReaders } from "./history-anchor.js";
@@ -42,7 +44,7 @@ export declare const CAPABILITY_FACT_WHY: {
42
44
  readonly session_fork_face_absent: "the session store has no fork face";
43
45
  readonly session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)";
44
46
  readonly session_purge_absent: "no session purge coordinator is wired";
45
- readonly session_policy_store_absent: "no session policy store is wired";
47
+ readonly session_kind_faces_absent: "the session store cannot record a session kind (it needs the birth receipt face that takes a kind, sessionKindOf, listSessions and listIdleOfKind) or no session purge coordinator is wired to age such sessions out";
46
48
  readonly store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)";
47
49
  readonly file_history_store_absent: "no file-history store is wired";
48
50
  readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through, with the run store an unknown handle is checked against — both come from the store backend)";
@@ -53,7 +55,7 @@ export declare const CAPABILITY_FACT_WHY: {
53
55
  readonly session_export_absent: "the session store has no entry export faces (exportEntries / exportEntriesStream)";
54
56
  readonly session_import_staging_absent: "the session store has no staged-import face (beginImportStaging)";
55
57
  readonly policy_purge_absent: "the session policy store has no deleteBySession purge verb";
56
- readonly blob_exchange_absent: "the file-history store carries no blob exchange (FileHistoryStore.blobExchange — SQL backends only)";
58
+ readonly blob_exchange_absent: "the file-history store carries no complete blob face (the blob exchange FileHistoryStore.blobExchange together with the per-landing provenance face blobLanding — SQL backends only)";
57
59
  readonly device_hub_absent: "the device lane hub is not wired";
58
60
  readonly device_store_absent: "the device store is not wired";
59
61
  readonly device_enrollment_absent: "device enrollment is not wired";
@@ -82,8 +84,7 @@ export declare const CAPABILITY_FACT_WHY: {
82
84
  readonly a2a_serve_off: "A2A_SERVE_ENABLED is off";
83
85
  readonly elicitation_disabled: "inbound MCP elicitation is off (MCP_ELICITATION_ENABLED)";
84
86
  readonly ask_question_disabled: "AskUserQuestion live HITL is off (ASK_QUESTION_ENABLED)";
85
- readonly tool_approval_disabled: "live tool approval is off (TOOL_APPROVAL_ENABLED)";
86
- readonly stream_approval_disabled: "the stream approval protocol is off (STREAM_APPROVAL_ENABLED)";
87
+ readonly tool_approval_disabled: "this worker presents no approval cards (needs TOOL_APPROVAL_ENABLED, a store backend (DB_BACKEND) and DURABLE_APPROVAL)";
87
88
  readonly read_root_grant_posture_refused: "this is not a single-user host-lane deployment (REMOTE_EXEC=host without REQUIRE_PRINCIPAL), the only posture that honors a read-directory grant";
88
89
  readonly background_agent_store_absent: "no background-agent store is wired";
89
90
  readonly sendfile_ledger_absent: "no SendUserFile ledger is wired";
@@ -187,6 +188,12 @@ type SessionLister = NonNullable<OwnerAwareSessionStore["listSessions"]>;
187
188
  export declare function sessionList(d: Pick<Deps, "sessionStorage">): Fact<"session_lister_absent", {
188
189
  lister: SessionLister;
189
190
  }>;
191
+ /**
192
+ * 会话种类在场(律 `session-kind.ts`):会话店交「带种类的出生回执」(`registerWithReceipt` 的第三参;授权口登记新行的那一笔)∧ 按 id 的种类读 `sessionKindOf`(既有会话上的比对)
193
+ * ∧ 列表面 `listSessions`(视图谓词在店里)∧ 老化候选面 `listIdleOfKind` ∧ 删除协调器(老化删走它)。读者三只、同读这一只:能力位 `capabilities.sessionKinds`、
194
+ * 受理门的 `request.precondition_unmet`、授权口的种类判。三只持久店恒在;内存店不在。
195
+ */
196
+ export declare function sessionKinds(d: Pick<Deps, "sessionStorage" | "purgeSession">): Fact<"session_kind_faces_absent">;
190
197
  export declare function sessionFork<D extends SessionDeps>(d: D): Fact<"session_fork_face_absent" | "session_head_face_absent", {
191
198
  sessionStorage: SessionWith<D, "headOf" | "fork">;
192
199
  }>;
@@ -204,40 +211,42 @@ export declare function sessionDelete<D extends Pick<Deps, "purgeSession" | "ses
204
211
  purge: Store<"purgeSession">;
205
212
  sessionStorage: HeadReadingSessionStore<D>;
206
213
  }>;
207
- export declare function sessionPolicy<D extends Pick<Deps, "sessionPolicyStore" | "sessionStorage">>(d: D): Fact<"session_policy_store_absent" | "session_head_face_absent", {
208
- policyStore: Store<"sessionPolicyStore">;
214
+ /** 会话规则面(`GET` / `PUT /v1/sessions/:id/policy`):后端 ∧ 会话头读。见证交后端:`GET` 读 `backend.sessionPolicy()`(恒同一只 —— 引擎的规则席读同一只),
215
+ * `PUT` 写经同一只后端的落定席位 `landedAttendants()`(段首锁会话根行判门读的那一位住客,门后会话被删 / 同 id 重建 ⇒ 零写)写进的就是那一只。读与写同出一只后端,没有第二个店源。 */
216
+ export declare function sessionPolicy<D extends Pick<Deps, "sessionStorage" | "backend">>(d: D): Fact<"session_head_face_absent" | "store_backend_absent", {
209
217
  sessionStorage: HeadReadingSessionStore<D>;
218
+ backend: StoreBackend;
210
219
  }>;
211
220
  type SyncSessionStore<D extends SessionDeps> = SessionWith<D, "exportEntries" | "exportEntriesStream" | "beginImportStaging" | "headOf" | "sessionSummaryOf" | "writeSessionRowCells">;
212
- type SessionSyncWhy = "store_backend_absent" | "file_history_store_absent" | "session_export_absent" | "session_import_staging_absent" | "session_row_faces_absent" | "policy_purge_absent";
213
- /** 会话对等同步的**对话半族**(manifest / entries / plan / import 两相):后端 ∧ 文件历史店 ∧ 导出两面 ∧ staged 导入面 ∧
221
+ type SessionSyncWhy = "store_backend_absent" | "session_export_absent" | "session_import_staging_absent" | "session_row_faces_absent" | "policy_purge_absent";
222
+ /** 会话对等同步的**对话半族**(manifest / entries / plan / import 两相):后端(文件历史店 / 规则店 / 锚店都是它恒交的那一只,落定席位写的同一只)∧ 导出两面 ∧ staged 导入面 ∧
214
223
  * 会话行三口(门读头 `headOf` —— 属主 + 化身一次读,属主判门、化身给 identical 短路腿;manifest 带 `title` / `pinned`;导入经行格写原语以 `replay` 写者
215
224
  * 按导入落定的那一位住客重放它们)∧ policy 店能清(overwrite-dst 的 commit 要擦目的端旧 policy 行)。
216
225
  * 文件历史的 blob 搬运是另一只事实。 */
217
- export declare function sessionSync<D extends Pick<Deps, "backend" | "sessionStorage" | "fileHistoryStore" | "sessionPolicyStore">>(d: D): Fact<SessionSyncWhy, {
226
+ export declare function sessionSync<D extends Pick<Deps, "backend" | "sessionStorage">>(d: D): Fact<SessionSyncWhy, {
218
227
  backend: Held<D, "backend">;
219
228
  sessionStorage: SyncSessionStore<D>;
220
229
  historyStore: ServiceFileHistoryStore;
221
230
  }>;
222
- /** 会话同步的**文件历史半族**:对话半族 ∧ 文件历史店带 blob 交换组(只有 SQL 两只店有)。「店能不能交换 blob」只在 `blobExchangeOf` 判一次(core 判官),
223
- * blob 取值口 `blobGetterOf` 读的是同一只 —— 本事实为真 ⟺ 取值口通到 `blobExchange.get`;判过的组随事实交出,路由的 GET / PUT / 在场预检只读它。 */
224
- export declare function sessionSyncFileHistory(d: Pick<Deps, "backend" | "sessionStorage" | "fileHistoryStore" | "sessionPolicyStore">): Fact<SessionSyncWhy | "blob_exchange_absent", {
231
+ /** 会话同步的**文件历史半族**:对话半族 ∧ 文件历史店带完整的 blob 面 —— 交换组 + 按落点来历面(只有 SQL 两只店有)。「店有没有这只面」只在 `landingBlobFacesOf` 判一次
232
+ * (交换组经 core 判官),判过的面随事实交出:路由的 PUT / 在场预检 / 重放取值 / GET 只读它(按落点,没有全局读者)。 */
233
+ export declare function sessionSyncFileHistory(d: Pick<Deps, "backend" | "sessionStorage">): Fact<SessionSyncWhy | "blob_exchange_absent", {
225
234
  historyStore: ServiceFileHistoryStore;
226
- blobExchange: ServiceBlobExchange;
235
+ blobs: LandingBlobFaces;
227
236
  }>;
228
237
  type RewindFilesWhy = "file_history_store_absent" | "session_head_face_absent" | "resume_anchor_store_absent" | "execution_lane_handless" | "workspace_rebuilt_per_task" | "session_store_shared";
229
238
  /**
230
239
  * run 外的「只恢复代码」口(`POST /v1/sessions/:id/rewind-files`,[ref])这台部署**解不解得出** —— 能力位 `sessionRewindFiles` 与该口的 501 读这一只。
231
- * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(引擎 `Runner.rewindFiles` 读的同一只;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、不摘店,
232
- * 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
233
- * `history-anchor.ts`;两只同出存储后端,所以是同一格)∧ 执行车道有手
240
+ * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(后端恒交的那一只 —— 引擎 `Runner.rewindFiles` 读的同一只;没有后端 ⇒ 没有它;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、
241
+ * 不摘店,所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
242
+ * `history-anchor.ts`;锚店是后端恒交的那一只,run 店同出存储后端,所以是同一格)∧ 执行车道有手
234
243
  * (无手车道上引擎恒拒 `rewind.files_env_unsupported`:没有工作区可回退 —— 位说有而口恒拒不许发生)∧ 即时回退的工作区活过一次执行(部署形表行 `rewindableWorkspace`;
235
244
  * 否则恢复的结果到不了下一次执行)∧ 会话店由本进程独占(local 后端:数据根被一个活进程锁住 ⇒ 引擎的进程内会话锁就是全局互斥;
236
245
  * SQL 后端被多副本共用,而 run 外回退还没有一只跨副本的持久认领 —— 「先查认领再交引擎」只是检查不是互斥,所以在共享店上位为假、口 501,不留「检查即放行」)。
237
246
  * 动词本身是引擎 `Runner` 的必有成员(型上必在),不是一格。
238
247
  * 见证 = 判过在场的设施(历史店 · 手柄翻译的两只读店 · 会话店);路由在拒臂之后只读见证。
239
248
  */
240
- export declare function sessionRewindFiles<D extends Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">>(d: D): Fact<RewindFilesWhy, {
249
+ export declare function sessionRewindFiles<D extends Pick<Deps, "runStore" | "sessionStorage" | "config" | "backend">>(d: D): Fact<RewindFilesWhy, {
241
250
  historyStore: ServiceFileHistoryStore;
242
251
  anchors: HistoryAnchorReaders & {
243
252
  readonly runs: Held<D, "runStore">;
@@ -250,7 +259,7 @@ export declare function sessionRewindFiles<D extends Pick<Deps, "fileHistoryStor
250
259
  * `previewFileDelta` 不在 core 包根导出面上,本仓不另写一份 —— 等 core 导出它,SQL 店补这一座、本位随之转真,路由零改)。本位为假**不是**口不收 `dryRun`:口照收,答 `preview: null`
251
260
  * (「这台给不出统计」≠「什么都不会变」);所以本事实没有 501 拒点,只有能力位读它。
252
261
  */
253
- export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
262
+ export declare function sessionRewindFilesPreview(d: Pick<Deps, "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
254
263
  /** 持久审批底座(checkpoint 店)在场 —— `/v1/approvals/*` 与 `/v1/assistant/*` 整条车道、会话 wake 都站在它上面。 */
255
264
  export declare function checkpointPark(d: Pick<Deps, "checkpointStore">): Fact<"checkpoint_store_absent", {
256
265
  checkpointStore: Store<"checkpointStore">;
@@ -264,17 +273,18 @@ export declare function askUserQuestion(d: Pick<Deps, "question">): Fact<"ask_qu
264
273
  export declare function toolApproval(d: Pick<Deps, "toolApproval">): Fact<"tool_approval_disabled", {
265
274
  coordinator: Store<"toolApproval">;
266
275
  }>;
267
- type StreamApprovalWhy = "tool_approval_disabled" | "stream_approval_disabled" | "store_backend_absent" | "checkpoint_store_absent";
276
+ type StreamApprovalWhy = "tool_approval_disabled" | "store_backend_absent" | "checkpoint_store_absent";
268
277
  type ActiveStreamApproval = Extract<ReturnType<typeof resolveStreamApprovalGate>, {
269
278
  active: true;
270
279
  }>;
271
280
  /** 流内审批协议在场 —— 判据的属主仍是 `resolveStreamApprovalGate`(三条执行腿的装配也读它);本事实把它的拒因译进 why 闭集。 */
272
281
  export declare function streamApproval(d: Pick<Deps, "toolApproval" | "config" | "backend" | "checkpointStore">): Fact<StreamApprovalWhy, {
273
282
  askStore: ActiveStreamApproval["askStore"];
283
+ coordinator: Store<"toolApproval">;
274
284
  }>;
275
285
  /**
276
286
  * 读根授权(「Yes, and add directory」)这台部署**受理不受理** —— `GET /v1/capabilities` 的 `approvalReadRootGrant` 位,与
277
- * `POST /v1/tool-approvals/:id/respond` 对应答体 `readRootGrant` 的受理门**读同一只**(位说不受理而口照收,就是「位说 X、行为不是 X」)。
287
+ * 决断口 `POST /v1/tasks/:taskId/asks/:askId/decision` 对决定体 `readRootGrant` 的受理门**读同一只**(位说不受理而口照收,就是「位说 X、行为不是 X」)。
278
288
  *
279
289
  * 判据 = 部署形表行 `callerOwnsWorkerDisk`(手在本 worker 盘上 ∧ 单主;与调用方附加目录同一条信任边界):授权把一个**宿主目录**加进本 run 的读目录,
280
290
  * 只有「这台机器一个可信主人」的姿态才有这个授权的语义;多租户与云上 / 容器车道的读面另有归宿(沙箱内的读面档位见 `READ_FACE`)。
@@ -285,14 +295,13 @@ export declare function readRootGrant(d: Pick<Deps, "config">): Fact<"read_root_
285
295
  /**
286
296
  * 审批开卡帧的族 —— `GET /v1/capabilities` 的 `approvalFrameFamilies` 位。**值族投影**(出形是闭集词数组,不是 `{ available }`;同
287
297
  * `engineCapabilityBits` 一类),入参是 {@link streamApproval} **已求出的那一份事实**而不是 deps:一次请求里 `streamApproval` 位与本位读同一次判据求值
288
- * (判据读活配置与 backend,两次求值在开关热改的窗口里会撕出 `streamApproval:true` 配旧族的应答;也多取一次 ask 店)。
298
+ * (判据读活配置与 backend,两次求值会撕出两位互相矛盾的应答;也多取一次 ask 店)。
289
299
  * · 流内审批在场(呈卡协议上场)⇒ `["approval_request"]`;
290
- * · 活卡协调器在、协议没上场(开关关 / 无 store backend / 无 park 设施)⇒ `["tool_approval"]`;
291
- * · 活卡协调器缺席 ⇒ `[]`(没有审批卡可呈)。
292
- * 对 why 闭集穷举:`streamApproval` 的拒因多一个 ⇒ 这里编译红,逼着给新拒因定族。三条执行腿选族读的是同一只判据的 `active`,
293
- * 与本映射的「在场 ⇒ 呈卡族」是同一条规则(真腿对拍钉在 `test/stream-approval-on-e2e.test.ts`)。没有端点按它拒:它是消费方分派帧族的读点,`streamApproval` 的词义不变。
294
- * [ref]:它也是壳**声明**的依据 —— 一条 run 只在 `settings.approvalFrameFamilies` 含本位那一个族时有活审批通道(三条腿判的是同一只映射
295
- * `presentedApprovalFrameFamily`);不含 ⇒ 这条腿不呈卡,问当场交无人值守政策口。本位的值不因声明而变。
300
+ * · 其余每一形(审批席缺席 / 无 store backend / 无 park 设施)⇒ `[]`:这台 worker 不呈卡,每条腿的问当场交无人值守政策口
301
+ * (审批只有一个帧族,没有「协议没上场就回退发另一族活卡」的腿)。
302
+ * 族词由 `presentedApprovalFrameFamily` 一处映射(三条执行腿判「这台 worker 呈不呈卡 / 这条 run 声明了没有」读同一只 —— 壳照本位声明,服务端照同一只函数判;
303
+ * 真腿对拍钉在 `test/stream-approval-on-e2e.test.ts`)。没有端点按它拒:它是消费方分派帧族与声明的读点,`streamApproval` 的词义不变。
304
+ * [ref]:一条 run 只在 `settings.approvalFrameFamilies` 含本位那一个族时有活审批通道;本位为空 ⇒ 这台 worker 上没有 run 有。本位的值不因声明而变。
296
305
  */
297
306
  export declare function approvalFrameFamilies(stream: ReturnType<typeof streamApproval>): readonly ApprovalFrameFamily[];
298
307
  export declare function deviceLane(d: Pick<Deps, "deviceHub">): Fact<"device_hub_absent", {
@@ -368,14 +377,16 @@ export declare function principalInboxDelivery(d: Pick<Deps, "orgDeliveryGate">)
368
377
  export declare function engineHandover(d: Pick<Deps, "drainState">): Fact<"engine_handover_lane_absent" | "engine_lease_stopped", {
369
378
  door: EngineHandoverDoor;
370
379
  }>;
371
- /** 这台部署有运维名册(名单非空 ∨ 单用户声明 `OPERATOR_SINGLE_USER`;唯一读法 `operatorRosterPresent`)。没有时 `explicitOperatorOk` 对任何身份恒假
372
- * ⇒ 这一族的口对谁都打不通 = 部署不可用(不是鉴权拒)。
380
+ /** 这台部署上有人能持这只运维权力(档表里持 `power` 的某档名单非空 ∨ 单用户声明 `OPERATOR_SINGLE_USER`;唯一读法 `operatorRosterPresent`)。没有时 `explicitOperatorOk(…, power)`
381
+ * 对任何身份恒假 ⇒ 这一族的口对谁都打不通 = 部署不可用(不是鉴权拒)。`power` 必填:运维面族传 `"operate"`,排空口传它声明行的 `power`。
382
+ * 原因词只有 `operator_principals_empty` 一个:全运维档持每一只权力,所以「没人持 `power`」恒蕴含「没有全运维」—— 这个词的义对每只权力都真;
383
+ * 各权力的完整出路句由 `sendOperatorPrincipalsRequired(res, power)` 在拒发口说。
373
384
  *
374
385
  * operator 族的复合事实**先判名单、再判设施**:门序是「身份 → 名单空(501)→ 授权(403)→ 设施缺席(501)」——
375
386
  * 名单空时没有人过得了授权,不先判它,这一形就永远答成 403;设施缺席则留在授权之后答(不对非 operator 透露部署形态)。 */
376
387
  export declare function operatorLane(d: {
377
- readonly config: Pick<ServiceConfig, "operatorPrincipals" | "operatorSingleUser">;
378
- }): Fact<"operator_principals_empty">;
388
+ readonly config: OperatorRoster;
389
+ }, power: OperatorPower): Fact<"operator_principals_empty">;
379
390
  /** 带收编日志的后端(见证随调用方的 deps:路由层的后端视图上店工厂照样封着)。 */
380
391
  type AdoptionCapableBackend<D extends Pick<Deps, "backend">> = Held<D, "backend"> & {
381
392
  adoptionLog(): ReturnType<NonNullable<Store<"backend">["adoptionLog"]>>;