@sema-agent/server 7.149.0 → 7.151.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 (441) hide show
  1. package/MIGRATION.md +307 -9
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +92 -40
  5. package/deploy/sema-up/README.md +7 -1
  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 +1 -0
  14. package/deploy/sema-up/kube-up.sh +1 -1
  15. package/deploy/sema-up/lib/flagshape.sh +1 -1
  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/dist/adoption/import.js +3 -3
  19. package/dist/approval-ask-machine.d.ts +1 -1
  20. package/dist/approval-card.d.ts +3 -3
  21. package/dist/approval-gate-currency.d.ts +2 -2
  22. package/dist/audit.d.ts +1 -1
  23. package/dist/audit.js +2 -2
  24. package/dist/auth-bridge.d.ts +20 -0
  25. package/dist/auth-bridge.js +9 -0
  26. package/dist/background-session-reap.d.ts +2 -2
  27. package/dist/bake-runner/main.d.ts +4 -2
  28. package/dist/bind-host.d.ts +2 -3
  29. package/dist/bind-host.js +2 -4
  30. package/dist/boot/budget-tracing.js +1 -1
  31. package/dist/boot/deferred-sandbox-path-env.d.ts +5 -3
  32. package/dist/boot/deferred-sandbox-path-env.js +1 -2
  33. package/dist/boot/engine-lease.d.ts +5 -0
  34. package/dist/boot/engine-lease.js +1 -0
  35. package/dist/boot/execution-env.d.ts +8 -14
  36. package/dist/boot/execution-env.js +54 -17
  37. package/dist/boot/execution-lane.js +32 -5
  38. package/dist/boot/late-binds.d.ts +8 -4
  39. package/dist/boot/late-binds.js +7 -1
  40. package/dist/boot/memory-consolidation.d.ts +3 -2
  41. package/dist/boot/memory-consolidation.js +6 -6
  42. package/dist/boot/parked-revive-gate.d.ts +5 -5
  43. package/dist/boot/parked-revive-gate.js +2 -3
  44. package/dist/boot/reapers.d.ts +5 -0
  45. package/dist/boot/reapers.js +12 -1
  46. package/dist/boot/resolve-spec.d.ts +7 -8
  47. package/dist/boot/resolve-spec.js +80 -35
  48. package/dist/boot/retention-lane.d.ts +1 -1
  49. package/dist/boot/runner-deps.d.ts +9 -2
  50. package/dist/boot/runner-deps.js +3 -3
  51. package/dist/boot/session-age-out.d.ts +36 -0
  52. package/dist/boot/session-age-out.js +101 -0
  53. package/dist/boot/session-faces.d.ts +5 -14
  54. package/dist/boot/session-faces.js +28 -24
  55. package/dist/boot/stage-01-config.js +2 -0
  56. package/dist/boot/stage-03-store-backend.js +2 -2
  57. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  58. package/dist/boot/stage-05-execution-env.js +2 -2
  59. package/dist/boot/stage-06-runners.d.ts +7 -4
  60. package/dist/boot/stage-06-runners.js +16 -8
  61. package/dist/boot/stage-07-capability-layer.d.ts +7 -4
  62. package/dist/boot/stage-07-capability-layer.js +3 -2
  63. package/dist/boot/stage-08-reapers.d.ts +7 -4
  64. package/dist/boot/stage-08-reapers.js +4 -2
  65. package/dist/boot/stage-09-leader.d.ts +11 -5
  66. package/dist/boot/stage-09-leader.js +12 -3
  67. package/dist/boot/stage-10-http-server.d.ts +44 -6
  68. package/dist/boot/stage-10-http-server.js +12 -10
  69. package/dist/boot/web-admin.d.ts +1 -1
  70. package/dist/boot/web-admin.js +3 -1
  71. package/dist/boot/workflow-orchestration.d.ts +7 -2
  72. package/dist/boot/workflow-orchestration.js +24 -7
  73. package/dist/bounded-rotation.d.ts +29 -0
  74. package/dist/bounded-rotation.js +24 -0
  75. package/dist/capability-facts.d.ts +84 -66
  76. package/dist/capability-facts.js +58 -41
  77. package/dist/center-credential.d.ts +25 -6
  78. package/dist/center-credential.js +25 -5
  79. package/dist/config-catalog.d.ts +26 -7
  80. package/dist/config-catalog.js +15 -12
  81. package/dist/config-invariants.d.ts +2 -1
  82. package/dist/config-invariants.js +4 -4
  83. package/dist/config-types.d.ts +22 -15
  84. package/dist/config.d.ts +51 -2
  85. package/dist/config.js +35 -24
  86. package/dist/deployment-governance.d.ts +7 -28
  87. package/dist/deployment-governance.js +1 -14
  88. package/dist/deployment-shape.d.ts +9 -1
  89. package/dist/deployment-shape.js +2 -1
  90. package/dist/device-protocol.d.ts +5 -4
  91. package/dist/device-protocol.js +1 -1
  92. package/dist/device-ws-hub.d.ts +1 -0
  93. package/dist/device-ws-hub.js +66 -29
  94. package/dist/device-ws-protocol.d.ts +79 -12
  95. package/dist/device-ws-protocol.js +64 -26
  96. package/dist/engine-identity.d.ts +23 -5
  97. package/dist/engine-identity.js +13 -0
  98. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  99. package/dist/execution-env-refusal.d.ts +23 -0
  100. package/dist/execution-env-refusal.js +5 -0
  101. package/dist/execution-lane-caps.d.ts +3 -1
  102. package/dist/field-conflict.d.ts +3 -3
  103. package/dist/file-history-capture.d.ts +11 -4
  104. package/dist/file-history-capture.js +9 -6
  105. package/dist/file-history-disclosure.d.ts +7 -5
  106. package/dist/file-history-disclosure.js +7 -5
  107. package/dist/fleet/drain-entry.d.ts +4 -0
  108. package/dist/fleet/engine-signal.d.ts +14 -1
  109. package/dist/fleet/engine-signal.js +5 -1
  110. package/dist/fleet/fleet-reconciler.d.ts +1 -1
  111. package/dist/fleet/serving-lease.d.ts +18 -3
  112. package/dist/fleet/serving-lease.js +81 -35
  113. package/dist/fleet-client.d.ts +13 -11
  114. package/dist/fleet-client.js +53 -33
  115. package/dist/history-anchor.js +1 -1
  116. package/dist/hitl-delivery.d.ts +1 -3
  117. package/dist/hitl-delivery.js +1 -1
  118. package/dist/hooks/hook-runner.js +2 -2
  119. package/dist/host-lsp-manager.d.ts +2 -2
  120. package/dist/http/active-run-conflict.d.ts +3 -7
  121. package/dist/http/active-run-conflict.js +2 -2
  122. package/dist/http/admission.js +19 -4
  123. package/dist/http/approval-sweeps.js +7 -6
  124. package/dist/http/caller-trust.d.ts +2 -2
  125. package/dist/http/caller-trust.js +3 -3
  126. package/dist/http/checkpoint-ctx.d.ts +20 -63
  127. package/dist/http/checkpoint-ctx.js +2 -24
  128. package/dist/http/claim-heartbeat.d.ts +4 -4
  129. package/dist/http/claim-heartbeat.js +3 -3
  130. package/dist/http/dispatch.d.ts +2 -1
  131. package/dist/http/dispatch.js +36 -29
  132. package/dist/http/durable-run-leg.js +17 -17
  133. package/dist/http/health-self-report.d.ts +9 -1
  134. package/dist/http/health-self-report.js +2 -0
  135. package/dist/http/owner-access.d.ts +264 -20
  136. package/dist/http/owner-access.js +215 -5
  137. package/dist/http/readiness.d.ts +4 -2
  138. package/dist/http/resume-ctx-read.js +38 -1
  139. package/dist/http/resume-legs.d.ts +2 -1
  140. package/dist/http/resume-legs.js +273 -89
  141. package/dist/http/route-ctx.d.ts +41 -19
  142. package/dist/http/route-table.d.ts +1 -1
  143. package/dist/http/routes/a2a-serve.js +15 -14
  144. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  145. package/dist/http/routes/agents-roster.js +2 -3
  146. package/dist/http/routes/approvals-assistant.d.ts +3 -2
  147. package/dist/http/routes/approvals-assistant.js +12 -12
  148. package/dist/http/routes/background.d.ts +3 -3
  149. package/dist/http/routes/capabilities.js +10 -6
  150. package/dist/http/routes/config-catalog.d.ts +1 -1
  151. package/dist/http/routes/fleet.js +10 -8
  152. package/dist/http/routes/mcp-reconnect.js +2 -2
  153. package/dist/http/routes/memory-origin.d.ts +1 -1
  154. package/dist/http/routes/notify-wake.js +2 -3
  155. package/dist/http/routes/projects.d.ts +4 -2
  156. package/dist/http/routes/projects.js +7 -6
  157. package/dist/http/routes/retention-ops.d.ts +1 -1
  158. package/dist/http/routes/run-permission-mode.d.ts +1 -1
  159. package/dist/http/routes/run-permission-mode.js +2 -2
  160. package/dist/http/routes/runs.d.ts +1 -1
  161. package/dist/http/routes/runs.js +125 -66
  162. package/dist/http/routes/session-memory-sync.js +4 -5
  163. package/dist/http/routes/session-sync.d.ts +4 -3
  164. package/dist/http/routes/session-sync.js +174 -83
  165. package/dist/http/routes/sessions-list.js +13 -7
  166. package/dist/http/routes/sessions.d.ts +1 -1
  167. package/dist/http/routes/sessions.js +26 -48
  168. package/dist/http/routes/tasks.js +38 -23
  169. package/dist/http/routes/trace-usage.js +14 -14
  170. package/dist/http/routes/workflows.d.ts +1 -0
  171. package/dist/http/routes/workflows.js +20 -38
  172. package/dist/http/server.d.ts +28 -30
  173. package/dist/http/server.js +7 -3
  174. package/dist/http/stored-body-replay.d.ts +3 -24
  175. package/dist/http/stored-body-replay.js +2 -12
  176. package/dist/http/submit-ctx.d.ts +1 -2
  177. package/dist/http/submit-ctx.js +8 -6
  178. package/dist/http/submit-replay.d.ts +15 -2
  179. package/dist/http/submit-replay.js +10 -4
  180. package/dist/http/wire-types.d.ts +19 -6
  181. package/dist/identity-source.d.ts +20 -3
  182. package/dist/identity-source.js +14 -0
  183. package/dist/index.d.ts +4 -0
  184. package/dist/lane-home-probe.d.ts +3 -7
  185. package/dist/lane-home-probe.js +0 -1
  186. package/dist/leader/endpoint.js +9 -8
  187. package/dist/leader/leader.d.ts +2 -1
  188. package/dist/leg-facts.d.ts +19 -5
  189. package/dist/leg-facts.js +3 -1
  190. package/dist/mcp-authorization-face.d.ts +18 -14
  191. package/dist/mcp-authorization-face.js +3 -2
  192. package/dist/memory-scope.d.ts +5 -4
  193. package/dist/memory-scope.js +4 -4
  194. package/dist/memory-store-refusal.d.ts +1 -1
  195. package/dist/memory-sync-client.d.ts +30 -2
  196. package/dist/memory-sync-client.js +16 -9
  197. package/dist/observability/corrupt-read-seat.d.ts +1 -1
  198. package/dist/observability/err-text.d.ts +7 -0
  199. package/dist/observability/err-text.js +5 -0
  200. package/dist/observability/fail-open.d.ts +12 -8
  201. package/dist/observability/fail-open.js +12 -8
  202. package/dist/observability/logger.d.ts +7 -0
  203. package/dist/observability/logger.js +3 -1
  204. package/dist/observability/metrics.js +1 -0
  205. package/dist/observability/run-terminal.d.ts +1 -1
  206. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  207. package/dist/orchestration/workflow-notify-journal.js +12 -1
  208. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  209. package/dist/orchestration/workflow-park-decision.js +49 -10
  210. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  211. package/dist/orchestration/workflow-park-holder.js +98 -0
  212. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  213. package/dist/orchestration/workflow-record-fence.js +42 -0
  214. package/dist/owner-faces.d.ts +28 -4
  215. package/dist/owner-faces.js +2 -0
  216. package/dist/parked-decide.d.ts +104 -53
  217. package/dist/parked-decide.js +153 -117
  218. package/dist/peer-directory.d.ts +2 -2
  219. package/dist/peer-inbound-face.d.ts +2 -6
  220. package/dist/peer-inbound-face.js +0 -3
  221. package/dist/peer-seat.d.ts +1 -1
  222. package/dist/peer-seat.js +52 -59
  223. package/dist/permission-mode-admission.d.ts +41 -5
  224. package/dist/permission-mode-admission.js +29 -3
  225. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  226. package/dist/plugins/adoption-log-sql.js +7 -1
  227. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  228. package/dist/plugins/approval-ask-store-file.js +8 -0
  229. package/dist/plugins/approval-ask-store-memory.d.ts +6 -1
  230. package/dist/plugins/approval-ask-store-memory.js +28 -9
  231. package/dist/plugins/approval-ask-store-sql.d.ts +43 -2
  232. package/dist/plugins/approval-ask-store-sql.js +34 -5
  233. package/dist/plugins/approval-exemption-store.js +3 -0
  234. package/dist/plugins/approval-nonce-store.js +2 -0
  235. package/dist/plugins/breaker-state-sql.js +2 -0
  236. package/dist/plugins/caching-session-store.d.ts +9 -15
  237. package/dist/plugins/caching-session-store.js +6 -0
  238. package/dist/plugins/device-store-sql.js +6 -0
  239. package/dist/plugins/error-origin.d.ts +18 -0
  240. package/dist/plugins/error-origin.js +10 -0
  241. package/dist/plugins/exec-path-law.d.ts +34 -0
  242. package/dist/plugins/exec-path-law.js +13 -0
  243. package/dist/plugins/execution-placement-sql.js +6 -6
  244. package/dist/plugins/file-run-store.js +1 -1
  245. package/dist/plugins/image-bake-store-sql.js +6 -0
  246. package/dist/plugins/image-index-sql.js +4 -0
  247. package/dist/plugins/landed-attendants.d.ts +212 -0
  248. package/dist/plugins/landed-attendants.js +161 -0
  249. package/dist/plugins/leader-run-store-sql.js +4 -0
  250. package/dist/plugins/local-checkpoint-store.d.ts +4 -1
  251. package/dist/plugins/local-checkpoint-store.js +3 -0
  252. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  253. package/dist/plugins/local-session-live-reference.js +39 -0
  254. package/dist/plugins/local-session-store.d.ts +71 -33
  255. package/dist/plugins/local-session-store.js +129 -27
  256. package/dist/plugins/memory-engine-pg.js +4 -0
  257. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  258. package/dist/plugins/memory-engine-tidb.js +4 -0
  259. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  260. package/dist/plugins/memory-run-store.js +1 -1
  261. package/dist/plugins/memory-sync-store-pg.js +5 -0
  262. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  263. package/dist/plugins/one-time-migrations.d.ts +80 -61
  264. package/dist/plugins/one-time-migrations.js +241 -104
  265. package/dist/plugins/org-delivery-quota-store.js +4 -1
  266. package/dist/plugins/outcome-ledger-sql.js +2 -0
  267. package/dist/plugins/permission-rule-store-sql.js +11 -4
  268. package/dist/plugins/pg-cost-quota.js +4 -0
  269. package/dist/plugins/pg-pool.js +28 -1
  270. package/dist/plugins/pg-rate-limiter.js +2 -0
  271. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  272. package/dist/plugins/posix-shell-fs.js +8 -3
  273. package/dist/plugins/remote-env-adb.d.ts +19 -15
  274. package/dist/plugins/remote-env-adb.js +44 -17
  275. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  276. package/dist/plugins/remote-env-connect-seat.js +72 -0
  277. package/dist/plugins/remote-env-device.d.ts +22 -5
  278. package/dist/plugins/remote-env-device.js +114 -14
  279. package/dist/plugins/remote-env-e2b.d.ts +18 -7
  280. package/dist/plugins/remote-env-e2b.js +53 -40
  281. package/dist/plugins/remote-env-file-error.js +6 -2
  282. package/dist/plugins/remote-env-host.d.ts +18 -1
  283. package/dist/plugins/remote-env-host.js +48 -47
  284. package/dist/plugins/remote-env-k8s.d.ts +41 -39
  285. package/dist/plugins/remote-env-k8s.js +56 -32
  286. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  287. package/dist/plugins/remote-env-local-docker.js +37 -43
  288. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  289. package/dist/plugins/remote-env-ssh.js +64 -62
  290. package/dist/plugins/remote-shell.d.ts +101 -2
  291. package/dist/plugins/remote-shell.js +221 -3
  292. package/dist/plugins/replica-registration.d.ts +35 -0
  293. package/dist/plugins/replica-registration.js +48 -0
  294. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  295. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  296. package/dist/plugins/retention-lane-store-sql.d.ts +1 -1
  297. package/dist/plugins/retention-lane-store-sql.js +4 -0
  298. package/dist/plugins/retention-sql.d.ts +20 -2
  299. package/dist/plugins/retention-sql.js +11 -0
  300. package/dist/plugins/run-store-sql.d.ts +22 -3
  301. package/dist/plugins/run-store-sql.js +33 -9
  302. package/dist/plugins/scenario-prefix-switch-m42.d.ts +6 -12
  303. package/dist/plugins/scenario-prefix-switch-m42.js +7 -5
  304. package/dist/plugins/schema-consistency.d.ts +9 -5
  305. package/dist/plugins/schema-consistency.js +48 -18
  306. package/dist/plugins/schema-drift-sentence.js +1 -1
  307. package/dist/plugins/send-file-ledger.js +3 -0
  308. package/dist/plugins/serving-requirement.d.ts +68 -0
  309. package/dist/plugins/serving-requirement.js +60 -0
  310. package/dist/plugins/session-birth.d.ts +6 -2
  311. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  312. package/dist/plugins/session-ext-table.d.ts +14 -1
  313. package/dist/plugins/session-ext-table.js +5 -1
  314. package/dist/plugins/session-row-sql.d.ts +49 -2
  315. package/dist/plugins/session-row-sql.js +56 -13
  316. package/dist/plugins/session-store-sql.d.ts +34 -18
  317. package/dist/plugins/session-store-sql.js +98 -17
  318. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  319. package/dist/plugins/shared-memory-store-sql.js +6 -2
  320. package/dist/plugins/sql-driver.d.ts +2 -1
  321. package/dist/plugins/sql-driver.js +18 -3
  322. package/dist/plugins/sql-errors.d.ts +11 -6
  323. package/dist/plugins/sql-errors.js +5 -6
  324. package/dist/plugins/stop-then-start-sentence.d.ts +48 -3
  325. package/dist/plugins/stop-then-start-sentence.js +48 -0
  326. package/dist/plugins/stop-then-start.d.ts +109 -0
  327. package/dist/plugins/stop-then-start.js +104 -0
  328. package/dist/plugins/store-backend.d.ts +40 -13
  329. package/dist/plugins/store-backend.js +169 -27
  330. package/dist/plugins/store-boundary.d.ts +57 -0
  331. package/dist/plugins/store-boundary.js +139 -0
  332. package/dist/plugins/store-contracts.d.ts +29 -2
  333. package/dist/plugins/store-contracts.js +3 -0
  334. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  335. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  336. package/dist/plugins/store-fault.d.ts +26 -7
  337. package/dist/plugins/store-fault.js +18 -2
  338. package/dist/plugins/task-attachment-store.js +9 -0
  339. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  340. package/dist/plugins/task-list-store-sql.js +10 -8
  341. package/dist/plugins/tidb-cost-quota.js +4 -0
  342. package/dist/plugins/tidb-pool.js +6 -1
  343. package/dist/plugins/tidb-rate-limiter.js +4 -0
  344. package/dist/plugins/user-input-ledger-sql.js +4 -0
  345. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  346. package/dist/plugins/workflow-run-store-sql.js +64 -4
  347. package/dist/plugins/workspace-fill.d.ts +4 -7
  348. package/dist/plugins/workspace-fill.js +2 -1
  349. package/dist/plugins/write-behind-counter.js +5 -0
  350. package/dist/process-instance.d.ts +3 -0
  351. package/dist/process-instance.js +7 -0
  352. package/dist/project-context.d.ts +64 -0
  353. package/dist/project-context.js +66 -0
  354. package/dist/project-registry.d.ts +46 -0
  355. package/dist/project-registry.js +44 -0
  356. package/dist/question.d.ts +9 -21
  357. package/dist/question.js +28 -19
  358. package/dist/request-key-closure.js +1 -1
  359. package/dist/request-value-closure.d.ts +4 -0
  360. package/dist/request-value-closure.js +10 -0
  361. package/dist/run-acceptance.d.ts +3 -2
  362. package/dist/run-acceptance.js +4 -6
  363. package/dist/run-cancel-card.d.ts +1 -1
  364. package/dist/run-cancel-card.js +2 -1
  365. package/dist/run-local.js +1 -0
  366. package/dist/runs.d.ts +37 -8
  367. package/dist/runs.js +53 -12
  368. package/dist/runtime-governance.d.ts +5 -4
  369. package/dist/security.d.ts +31 -33
  370. package/dist/security.js +41 -7
  371. package/dist/server-secret-env.d.ts +12 -10
  372. package/dist/server-secret-env.js +24 -15
  373. package/dist/session-agent.d.ts +1 -10
  374. package/dist/session-agent.js +0 -6
  375. package/dist/session-bindings.d.ts +82 -0
  376. package/dist/session-bindings.js +18 -0
  377. package/dist/session-children-retire.d.ts +2 -2
  378. package/dist/session-children-retire.js +2 -6
  379. package/dist/session-deletion.d.ts +16 -1
  380. package/dist/session-error-wire.d.ts +3 -3
  381. package/dist/session-error-wire.js +3 -3
  382. package/dist/session-incarnation.d.ts +28 -4
  383. package/dist/session-incarnation.js +14 -2
  384. package/dist/session-kind.d.ts +57 -0
  385. package/dist/session-kind.js +22 -0
  386. package/dist/session-notify-door.d.ts +4 -4
  387. package/dist/session-notify-door.js +5 -6
  388. package/dist/session-row.d.ts +21 -1
  389. package/dist/session-row.js +7 -1
  390. package/dist/session-rules-seat.d.ts +4 -3
  391. package/dist/session-rules-seat.js +3 -11
  392. package/dist/session-sync-kernel.d.ts +24 -14
  393. package/dist/session-sync-kernel.js +3 -6
  394. package/dist/session-sync.d.ts +4 -98
  395. package/dist/session-sync.js +4 -74
  396. package/dist/session-titler.d.ts +10 -3
  397. package/dist/session-titler.js +19 -6
  398. package/dist/ssh-host-key.d.ts +5 -0
  399. package/dist/ssh-host-key.js +3 -0
  400. package/dist/stores-sql/checkpoint-store-sql.d.ts +21 -2
  401. package/dist/stores-sql/checkpoint-store-sql.js +106 -18
  402. package/dist/stores-sql/file-history-store-sql.d.ts +52 -2
  403. package/dist/stores-sql/file-history-store-sql.js +108 -70
  404. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  405. package/dist/stores-sql/pg-session-storage.js +37 -13
  406. package/dist/stores-sql/retention-store-sql.d.ts +2 -10
  407. package/dist/stores-sql/retention-store-sql.js +2 -10
  408. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  409. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  410. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  411. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  412. package/dist/stores-sql/tidb-session-store.js +37 -13
  413. package/dist/submission-exit.d.ts +3 -2
  414. package/dist/submission-exit.js +9 -1
  415. package/dist/task-cwd.d.ts +6 -5
  416. package/dist/task-settings.d.ts +19 -5
  417. package/dist/task-settings.js +13 -7
  418. package/dist/terminal.d.ts +33 -2
  419. package/dist/terminal.js +139 -9
  420. package/dist/tool-approval.d.ts +147 -12
  421. package/dist/tool-approval.js +206 -109
  422. package/dist/trace/engine-notice-wire.d.ts +14 -0
  423. package/dist/trace/engine-notice-wire.js +18 -1
  424. package/dist/trace/project.d.ts +4 -3
  425. package/dist/trace/project.js +3 -2
  426. package/dist/trace/projection-table.d.ts +33 -2
  427. package/dist/trace/self-minted-wire.d.ts +422 -26
  428. package/dist/trace/self-minted-wire.js +149 -23
  429. package/dist/trace/tool-card.d.ts +3 -0
  430. package/dist/trace/tool-card.js +24 -0
  431. package/dist/trace/tool-output-media.d.ts +2 -1
  432. package/dist/unattended-permission-mode.d.ts +1 -1
  433. package/dist/web-admin-client/apply-effective.d.ts +1 -1
  434. package/dist/web-admin-client/effective-keys.d.ts +1 -1
  435. package/dist/web-admin-client/skills-mcp.d.ts +1 -1
  436. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +120 -41
  437. package/package.json +3 -3
  438. package/wire-changes/server@7.150.0.json +335 -0
  439. package/wire-changes/server@7.151.0.json +762 -0
  440. package/dist/http/session-inherit-env.d.ts +0 -36
  441. package/dist/http/session-inherit-env.js +0 -6
@@ -31,18 +31,18 @@ import { bindServerLateSeats } from "./late-binds.js";
31
31
  import { serviceVersion } from "../service-version.js";
32
32
  import { buildDisplaySafeUrl } from "../trace/redact.js";
33
33
  import { seatText } from "../trace/exit-seat.js";
34
+ function exactListeningLine(line) {
35
+ return line;
36
+ }
34
37
  export async function runStage10(ctx) {
35
- const { peerDesk, approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, checkpointCtxSealing, parkCommits, config, webAdmin, consolidationValve, costQuota, belowTaskChainPatterns, deploymentMods, deploymentModsLoaded, deviceLane, drainState, dropSessionScopedOf, durableEnabled, elicitation, fenceSessionOwner, fileHistoryStore, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, loadedSkills, localRoot, logger, lspManager, mcpRevocations, sandboxCapacity, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportStores, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, memorySyncRunner, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekReading, sandboxGitPlane, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionPolicyStore, sessionTitler, sessionWatchRegistry, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, sessionResidentBackground, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowParkDecisions, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable, orgDeliveryGate } = ctx;
38
+ const { peerDesk, approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, checkpointCtxSealing, parkCommits, config, webAdmin, consolidationValve, costQuota, belowTaskChainPatterns, deploymentMods, deploymentModsLoaded, deviceLane, drainState, dropSessionScopedOf, durableEnabled, elicitation, fenceSessionOwner, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, loadedSkills, localRoot, logger, lspManager, mcpRevocations, sandboxCapacity, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportStores, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, memorySyncRunner, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekReading, sandboxGitPlane, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionTitler, sessionWatchRegistry, sessionBindings, sessionResidentBackground, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowParkDecisions, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable, orgDeliveryGate } = ctx;
36
39
  const stores = {
37
40
  runStore,
38
- resumeAnchorStore: resumeAnchorStore ? resumeAnchorStore : undefined,
39
41
  approvalExemptionStore: approvalExemptionStore ? approvalExemptionStore : undefined,
40
42
  approvalNonceStore: approvalNonceStore ? approvalNonceStore : undefined,
41
43
  checkpointStore,
42
44
  checkpointCtxSealing,
43
- sessionPolicyStore: sessionPolicyStore ? sessionPolicyStore : undefined,
44
45
  ruleConsent,
45
- fileHistoryStore: fileHistoryStore ? fileHistoryStore : undefined,
46
46
  toolResultStore,
47
47
  taskAttachmentStore: taskAttachmentStore ? taskAttachmentStore : undefined,
48
48
  backgroundAgentStore: backgroundAgentStore ? backgroundAgentStore : undefined,
@@ -85,7 +85,7 @@ export async function runStage10(ctx) {
85
85
  sessionAudit,
86
86
  routeJudgeBrain: brain,
87
87
  purgeSession: purgeSession ? purgeSession : undefined,
88
- bindSessionInheritEnv: config.remoteExec.provider === "host" ? setSessionInheritEnv : undefined,
88
+ sessionBindings,
89
89
  dropSessionScopedOf,
90
90
  subagentTaskOutput: (handle, access) => backgroundAgentOutput(defaultTaskRegistry, handle, access, backgroundAgentStore),
91
91
  taskHandleOutput: (handle, access) => taskHandleOutput(defaultTaskRegistry, handle, access, backgroundAgentStore),
@@ -211,14 +211,14 @@ export async function runStage10(ctx) {
211
211
  config, logger, metrics, localRoot, scenarios, loadedSkills, principalCaps, centerRuntimeCapsResolver,
212
212
  peerDesk,
213
213
  getKeyResolver: () => webAdmin.getKeyResolver(),
214
- taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner,
214
+ taskAttachmentStore, perSessionCwd, fenceSessionOwner,
215
215
  hookLlm, hookAgent, belowTaskChainPatterns, fleetBus, hookWakeBus, ownerAware, taskLimitCaps, taskTimeoutSec,
216
216
  historyAnchors: resumeAnchorStore && runStore ? { anchors: resumeAnchorStore, runs: runStore } : undefined,
217
217
  selectEnvTool, sendUserFileToolSpec, memoryEngine, memorySyncRunner, durableEnabled, approvalExemptionStore,
218
218
  checkpointStore, imageIndex, perTaskImage,
219
219
  sessionEnvSelection,
220
220
  lockedKeys: governanceSeams.lockedKeys,
221
- liveQuestionFace: question,
221
+ questionSeat: question !== undefined,
222
222
  approverSeat: createRunnerDepsOnAsk(toolApproval),
223
223
  });
224
224
  const runnerFor = createHandsRunnerSelector({ full: runner, handsless: handslessRunner });
@@ -284,11 +284,12 @@ export async function runStage10(ctx) {
284
284
  version: serviceVersion(),
285
285
  signal: () => mintEngineSignal({ ...deployment, config }),
286
286
  modelRefusals: () => deployment.modelRefusalsState?.(),
287
- ...(servingLease ? { onCenterCapabilities: (caps) => servingLease.noteCenterCapabilities(caps) } : {}),
287
+ ...(servingLease ? { onHeartbeat: (hearing) => servingLease.noteHeartbeat(hearing) } : {}),
288
288
  ...(fleetUsage ? { usage: fleetUsage } : {}),
289
289
  logger: { info: (m, d) => logger.info(m, d ?? {}), warn: (m, d) => logger.warn(m, d ?? {}) },
290
290
  });
291
291
  webAdmin.onSelfReportChange(() => void fleetClient?.announceNow());
292
+ servingLease?.onViewChange(() => void fleetClient?.announceNow());
292
293
  if (fleetClient) {
293
294
  const advertised = config.fleetAdvertiseAddress;
294
295
  logger.info("fleet_client_started", { worker: config.webAdmin?.worker, usageReport: fleetUsage !== undefined, announce: advertised !== undefined, ...(advertised !== undefined ? { address: buildDisplaySafeUrl(advertised) } : {}) });
@@ -299,12 +300,13 @@ export async function runStage10(ctx) {
299
300
  const bound = server.address();
300
301
  if (bound === null || typeof bound === "string")
301
302
  throw new Error(`http server listening without a TCP address (server.address() = ${JSON.stringify(bound)})`);
302
- logger.info("listening", {
303
+ logger.info("listening", exactListeningLine({
303
304
  port: bound.port,
304
305
  bindHost: bindHost ?? "0.0.0.0/::(all interfaces)",
305
306
  ...(bindHost === "127.0.0.1" && !config.bindHost
306
307
  ? { bindHostNote: "auto-narrowed to loopback: write face is unauthenticated (ALLOW_UNAUTHED_WRITES with no service token). Set BIND_HOST explicitly to override." }
307
308
  : {}),
309
+ boundAddress: bound.address,
308
310
  model: config.model.id,
309
311
  brain: brainSummary(config),
310
312
  breakerState: config.resilience.circuitBreaker ? (breakerState ? `shared(${backend.kind})` : "in-process") : "off",
@@ -327,7 +329,7 @@ export async function runStage10(ctx) {
327
329
  ? `db(${backend.kind})`
328
330
  : "file"
329
331
  : "off",
330
- });
332
+ }));
331
333
  if (workflowNotifyGate) {
332
334
  void workflowNotifyGate
333
335
  .recover(workflowRecoverOpts)
@@ -144,7 +144,7 @@ export interface WebAdminRuntime {
144
144
  /** [ref] ②:caps `centerWiring.effectivePull` / `effectiveRevision` 的取值口 —— `lastPull`(新状态,只此一枚:boot 实拉 / 迟到 boot 到货 /
145
145
  * refresh 拍收尾写)+ 与 `configApplyState()` **同一只** ledger 视图的已应用修订号。形与词表见 `web-admin-client/pull-state.ts`。 */
146
146
  centerPullState(): CenterPullView;
147
- /** DESIGN-278 §5 S2([ref]):center **当前在管**的 ServiceConfig 键集 —— `GET /v1/config/catalog` 判
147
+ /** [ref] §5 S2([ref]):center **当前在管**的 ServiceConfig 键集 —— `GET /v1/config/catalog` 判
148
148
  * `effectiveLane` 的 center 半场。投影自最近一次成功应用的候选(`latestEffective`,LKG/refresh 同一
149
149
  * 份推进点;判据单源 = apply-effective.ts `centerManagedConfigKeys`)。`undefined` = 没有配置管道。
150
150
  * ⚠️ 部分应用窗(codex R2-F2 登记):某组整拒时 live config 已吃进其它组而 latestEffective 不推进,
@@ -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;
@@ -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
@@ -21,11 +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 { ServiceBlobExchange, ServiceFileHistoryStore, StoreBackend } from "./plugins/store-backend.js";
25
25
  import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
26
26
  import { type WorkspaceSyncCapability } from "./workspace-space.js";
27
27
  import type { WorkspaceCacheCapability } from "./workspace-cache.js";
28
- import { type HeadRead } from "./session-incarnation.js";
29
28
  import type { HistoryAnchorReaders } from "./history-anchor.js";
30
29
  import type { EngineHandoverDoor } from "./boot/engine-lease.js";
31
30
  /** why 闭集:词 → 给运维看的一句义(诊断 / 测试读它;wire 上的拒句由各门自写)。 */
@@ -43,7 +42,7 @@ export declare const CAPABILITY_FACT_WHY: {
43
42
  readonly session_fork_face_absent: "the session store has no fork face";
44
43
  readonly session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)";
45
44
  readonly session_purge_absent: "no session purge coordinator is wired";
46
- readonly session_policy_store_absent: "no session policy store is wired";
45
+ 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";
47
46
  readonly store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)";
48
47
  readonly file_history_store_absent: "no file-history store is wired";
49
48
  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)";
@@ -120,29 +119,40 @@ type Store<K extends keyof Deps> = NonNullable<Deps[K]>;
120
119
  type WithMethods<T, K extends keyof T> = T & {
121
120
  [P in K]-?: NonNullable<T[P]>;
122
121
  };
122
+ /**
123
+ * 见证里的 run 店 / 会话店 / 会话视图读**随调用方交来的 deps**(`D`):路由层交的是封住的视图(`route-ctx.ts` 的 `RouteDeps`:带属主的读口在型上调不了)⇒ 见证照样封着
124
+ * (方法在不在照判,见证交给属主存取器的口照读);装配层交完整的店 ⇒ 见证完整。事实不另开一扇读口(视图只在 `owner-access.ts` 的 `sealRouteDeps` 铸一次)。
125
+ */
126
+ type Held<D, K extends keyof D> = NonNullable<D[K]>;
127
+ /** 判过在场的方法(`K`)在见证上必有;封住的读口在场照样封着(`never`)。 */
128
+ type Present<T, K extends PropertyKey> = T & {
129
+ [P in K]-?: NonNullable<P extends keyof T ? T[P] : never>;
130
+ };
123
131
  /** 持久 run 账面在场 —— `/v1/runs/*` 族、trace / 用量统计、assistant 的 preempt / resume / plan-review、
124
132
  * 会话 detach、设备换绑都站在这一只事实上。 */
125
- export declare function durableRuns(d: Pick<Deps, "runStore">): Fact<"run_store_absent", {
126
- runStore: Store<"runStore">;
133
+ export declare function durableRuns<D extends Pick<Deps, "runStore">>(d: D): Fact<"run_store_absent", {
134
+ runStore: Held<D, "runStore">;
127
135
  }>;
128
- export declare function subagentSteer(d: Pick<Deps, "runStore" | "subagentSteerRegistry">): Fact<"run_store_absent" | "subagent_registry_absent", {
129
- runStore: Store<"runStore">;
136
+ export declare function subagentSteer<D extends Pick<Deps, "runStore" | "subagentSteerRegistry">>(d: D): Fact<"run_store_absent" | "subagent_registry_absent", {
137
+ runStore: Held<D, "runStore">;
130
138
  registry: Store<"subagentSteerRegistry">;
131
139
  }>;
132
- export declare function subagentOutput(d: Pick<Deps, "runStore" | "subagentTaskOutput">): Fact<"run_store_absent" | "subagent_output_face_absent", {
133
- runStore: Store<"runStore">;
140
+ export declare function subagentOutput<D extends Pick<Deps, "runStore" | "subagentTaskOutput">>(d: D): Fact<"run_store_absent" | "subagent_output_face_absent", {
141
+ runStore: Held<D, "runStore">;
134
142
  output: Store<"subagentTaskOutput">;
135
143
  }>;
136
- export declare function taskHandles(d: Pick<Deps, "runStore" | "taskHandleOutput" | "taskHandleStop">): Fact<"run_store_absent" | "task_handle_faces_absent", {
137
- runStore: Store<"runStore">;
144
+ export declare function taskHandles<D extends Pick<Deps, "runStore" | "taskHandleOutput" | "taskHandleStop">>(d: D): Fact<"run_store_absent" | "task_handle_faces_absent", {
145
+ runStore: Held<D, "runStore">;
138
146
  output: Store<"taskHandleOutput">;
139
147
  stop: Store<"taskHandleStop">;
140
148
  }>;
141
149
  /** 会话店按 id 读一行的唯一读口在场(core `headOf`:属主 / 住客 / 叶子一次读;「有没有」与 `session-incarnation.ts` 的 `headReadOf` 同判)。 */
142
- type HeadReadingSessionStore = WithMethods<OwnerAwareSessionStore, "headOf">;
150
+ type SessionDeps = Pick<Deps, "sessionStorage">;
151
+ type SessionWith<D extends SessionDeps, K extends PropertyKey> = Present<Held<D, "sessionStorage">, K>;
152
+ type HeadReadingSessionStore<D extends SessionDeps> = SessionWith<D, "headOf">;
143
153
  /** 会话属主面在场(入站 owner 门的地基;缺它,带会话的门一律 fail-closed)。属主 = `headOf(id)?.owner`。 */
144
- export declare function sessionOwnership(d: Pick<Deps, "sessionStorage">): Fact<"session_head_face_absent", {
145
- sessionStorage: HeadReadingSessionStore;
154
+ export declare function sessionOwnership<D extends SessionDeps>(d: D): Fact<"session_head_face_absent", {
155
+ sessionStorage: HeadReadingSessionStore<D>;
146
156
  }>;
147
157
  /**
148
158
  * 执行放置读面在场:会话店带执行席(`executionPlacement`:一次行读 = 住客 + 执行放置格;SQL 两孪生与 local 恒带,引擎缺省的内存会话店没有)。
@@ -151,90 +161,96 @@ export declare function sessionOwnership(d: Pick<Deps, "sessionStorage">): Fact<
151
161
  export declare function executionPlacementRead(d: Pick<Deps, "sessionStorage">): Fact<"execution_placement_seat_absent", {
152
162
  seat: NonNullable<OwnerAwareSessionStore["executionPlacement"]>;
153
163
  }>;
154
- export declare function mcpReconnect(d: Pick<Deps, "runStore" | "sessionStorage">): Fact<"run_store_absent" | "session_head_face_absent", {
155
- runStore: Store<"runStore">;
156
- sessionStorage: HeadReadingSessionStore;
164
+ export declare function mcpReconnect<D extends Pick<Deps, "runStore" | "sessionStorage">>(d: D): Fact<"run_store_absent" | "session_head_face_absent", {
165
+ runStore: Held<D, "runStore">;
166
+ sessionStorage: HeadReadingSessionStore<D>;
157
167
  }>;
158
168
  /**
159
169
  * 在飞 run 的切档口(`POST /v1/runs/:id/permission-mode`)= 持久 run 账面 ∧ checkpoint 店(ctx 面)。后一格是承重的:切档要读这条 run 的
160
170
  * **存储体**(本任务 settings 的 kill-switch 由受理判官折,与提交口同一份事实),也要把准入的词写回存储体(run 模式词的唯一来源,续跑腿读它);
161
171
  * 没有 ctx 面的部署两件都做不了 ⇒ 不提供这一口(能力位 `permissionModeWrite` 同读本事实)。
162
172
  */
163
- export declare function permissionModeWrite(d: Pick<Deps, "runStore" | "checkpointStore">): Fact<"run_store_absent" | "checkpoint_store_absent", {
164
- runStore: Store<"runStore">;
173
+ export declare function permissionModeWrite<D extends Pick<Deps, "runStore" | "checkpointStore">>(d: D): Fact<"run_store_absent" | "checkpoint_store_absent", {
174
+ runStore: Held<D, "runStore">;
165
175
  checkpointStore: Store<"checkpointStore">;
166
176
  }>;
167
- export declare function sessionAuditView(d: Pick<Deps, "sessionAudit">): Fact<"session_audit_absent", {
168
- sessionAudit: Store<"sessionAudit">;
177
+ export declare function sessionAuditView<D extends Pick<Deps, "sessionAudit">>(d: D): Fact<"session_audit_absent", {
178
+ sessionAudit: Held<D, "sessionAudit">;
169
179
  }>;
170
180
  /** 会话 SSE(watch 注册表 ∧ 头读:属主门与叶子都是 `headOf` 的投影)。 */
171
- export declare function sessionEventStream(d: Pick<Deps, "sessionWatch" | "sessionStorage">): Fact<"session_watch_absent" | "session_head_face_absent", {
181
+ export declare function sessionEventStream<D extends Pick<Deps, "sessionWatch" | "sessionStorage">>(d: D): Fact<"session_watch_absent" | "session_head_face_absent", {
172
182
  watch: Store<"sessionWatch">;
173
- sessionStorage: HeadReadingSessionStore;
183
+ sessionStorage: HeadReadingSessionStore<D>;
174
184
  }>;
175
185
  type SessionLister = NonNullable<OwnerAwareSessionStore["listSessions"]>;
176
186
  /** 会话枚举面:会话店的 `listSessions` —— 唯一的会话 lister(run 店不列会话:只有 run 行、没有会话行的面答不了「有哪些会话」)。见证 = 已绑好宿主的那一只。 */
177
187
  export declare function sessionList(d: Pick<Deps, "sessionStorage">): Fact<"session_lister_absent", {
178
188
  lister: SessionLister;
179
189
  }>;
180
- export declare function sessionFork(d: Pick<Deps, "sessionStorage">): Fact<"session_fork_face_absent" | "session_head_face_absent", {
181
- sessionStorage: WithMethods<OwnerAwareSessionStore, "headOf" | "fork">;
190
+ /**
191
+ * 会话种类在场(律 `session-kind.ts`):会话店交「带种类的出生回执」(`registerWithReceipt` 的第三参;授权口登记新行的那一笔)∧ 按 id 的种类读 `sessionKindOf`(既有会话上的比对)
192
+ * ∧ 列表面 `listSessions`(视图谓词在店里)∧ 老化候选面 `listIdleOfKind` ∧ 删除协调器(老化删走它)。读者三只、同读这一只:能力位 `capabilities.sessionKinds`、
193
+ * 受理门的 `request.precondition_unmet`、授权口的种类判。三只持久店恒在;内存店不在。
194
+ */
195
+ export declare function sessionKinds(d: Pick<Deps, "sessionStorage" | "purgeSession">): Fact<"session_kind_faces_absent">;
196
+ export declare function sessionFork<D extends SessionDeps>(d: D): Fact<"session_fork_face_absent" | "session_head_face_absent", {
197
+ sessionStorage: SessionWith<D, "headOf" | "fork">;
182
198
  }>;
183
199
  /** 会话行可写位(`PATCH /v1/sessions/:id`):会话店的头读(属主 + 化身一次读 —— 门判属主,那一读就是写原语的行期望)∧ 行格写原语(锁内判、提交后另读应答行)。
184
200
  * 三只 durable 店(SQL 双生 / local)都带;内存 dev 店没有行写口 ⇒ 501。
185
201
  * 本面**没有**独立能力位(契约附录 B.2c 登记):老 worker 对这一动词答 405,本事实为假的部署答 501;条件写也没有 —— 列表行上有 `rowTag` 即支持。 */
186
- export declare function sessionPatch(d: Pick<Deps, "sessionStorage">): Fact<"session_row_faces_absent", {
187
- sessionStorage: WithMethods<OwnerAwareSessionStore, "headOf" | "writeSessionRowCells">;
202
+ export declare function sessionPatch<D extends SessionDeps>(d: D): Fact<"session_row_faces_absent", {
203
+ sessionStorage: SessionWith<D, "headOf" | "writeSessionRowCells">;
188
204
  }>;
189
- /** 删除门读的会话店视图:按 id 读 = 删除门那一只头读,行格的 placement 问询 = 店自己的那一只。门照旧由属主存取器读头(`admitSessionById`),读的就是这一只。 */
190
- type DeletionGateStore = Pick<OwnerAwareSessionStore, "placementOf"> & {
191
- readonly headOf: HeadRead;
192
- };
193
205
  /**
194
- * 会话删除面(purge 协调器 ∧ 删除门的头读)。见证 = 协调器 + 删除门的店视图 {@link DeletionGateStore}:按 id 读是 `deletionHeadReadOf`(local 店删到一半的行也答得出属主,
195
- * 开始删它的那位重发收得完;别的店 = `headOf`)—— 与协调器围栏读同一只。
206
+ * 会话删除面(purge 协调器 ∧ 会话店的头读)。见证 = 协调器 + 判过头读在场的会话店;删除门读哪一只头(删到一半的行也答得出属主的那一只,与协调器围栏读同一只)
207
+ * 只由属主存取器的删除口判(`owner-access.ts` 的 `admitSessionForDeletion`)。
196
208
  */
197
- export declare function sessionDelete(d: Pick<Deps, "purgeSession" | "sessionStorage">): Fact<"session_purge_absent" | "session_head_face_absent", {
209
+ export declare function sessionDelete<D extends Pick<Deps, "purgeSession" | "sessionStorage">>(d: D): Fact<"session_purge_absent" | "session_head_face_absent", {
198
210
  purge: Store<"purgeSession">;
199
- gateStore: DeletionGateStore;
211
+ sessionStorage: HeadReadingSessionStore<D>;
200
212
  }>;
201
- export declare function sessionPolicy(d: Pick<Deps, "sessionPolicyStore" | "sessionStorage">): Fact<"session_policy_store_absent" | "session_head_face_absent", {
202
- policyStore: Store<"sessionPolicyStore">;
203
- sessionStorage: HeadReadingSessionStore;
213
+ /** 会话规则面(`GET` / `PUT /v1/sessions/:id/policy`):后端 ∧ 会话头读。见证交后端:`GET` 读 `backend.sessionPolicy()`(恒同一只 —— 引擎的规则席读同一只),
214
+ * `PUT` 写经同一只后端的落定席位 `landedAttendants()`(段首锁会话根行判门读的那一位住客,门后会话被删 / 同 id 重建 ⇒ 零写)写进的就是那一只。读与写同出一只后端,没有第二个店源。 */
215
+ export declare function sessionPolicy<D extends Pick<Deps, "sessionStorage" | "backend">>(d: D): Fact<"session_head_face_absent" | "store_backend_absent", {
216
+ sessionStorage: HeadReadingSessionStore<D>;
217
+ backend: StoreBackend;
204
218
  }>;
205
- type SyncSessionStore = WithMethods<OwnerAwareSessionStore, "exportEntries" | "exportEntriesStream" | "beginImportStaging" | "headOf" | "sessionSummaryOf" | "writeSessionRowCells">;
206
- type SessionSyncWhy = "store_backend_absent" | "file_history_store_absent" | "session_export_absent" | "session_import_staging_absent" | "session_row_faces_absent" | "policy_purge_absent";
207
- /** 会话对等同步的**对话半族**(manifest / entries / plan / import 两相):后端 ∧ 文件历史店 ∧ 导出两面 ∧ staged 导入面 ∧
219
+ type SyncSessionStore<D extends SessionDeps> = SessionWith<D, "exportEntries" | "exportEntriesStream" | "beginImportStaging" | "headOf" | "sessionSummaryOf" | "writeSessionRowCells">;
220
+ type SessionSyncWhy = "store_backend_absent" | "session_export_absent" | "session_import_staging_absent" | "session_row_faces_absent" | "policy_purge_absent";
221
+ /** 会话对等同步的**对话半族**(manifest / entries / plan / import 两相):后端(文件历史店 / 规则店 / 锚店都是它恒交的那一只,落定席位写的同一只)∧ 导出两面 ∧ staged 导入面 ∧
208
222
  * 会话行三口(门读头 `headOf` —— 属主 + 化身一次读,属主判门、化身给 identical 短路腿;manifest 带 `title` / `pinned`;导入经行格写原语以 `replay` 写者
209
223
  * 按导入落定的那一位住客重放它们)∧ policy 店能清(overwrite-dst 的 commit 要擦目的端旧 policy 行)。
210
224
  * 文件历史的 blob 搬运是另一只事实。 */
211
- export declare function sessionSync(d: Pick<Deps, "backend" | "sessionStorage" | "fileHistoryStore" | "sessionPolicyStore">): Fact<SessionSyncWhy, {
212
- backend: Store<"backend">;
213
- sessionStorage: SyncSessionStore;
225
+ export declare function sessionSync<D extends Pick<Deps, "backend" | "sessionStorage">>(d: D): Fact<SessionSyncWhy, {
226
+ backend: Held<D, "backend">;
227
+ sessionStorage: SyncSessionStore<D>;
214
228
  historyStore: ServiceFileHistoryStore;
215
229
  }>;
216
230
  /** 会话同步的**文件历史半族**:对话半族 ∧ 文件历史店带 blob 交换组(只有 SQL 两只店有)。「店能不能交换 blob」只在 `blobExchangeOf` 判一次(core 判官),
217
231
  * blob 取值口 `blobGetterOf` 读的是同一只 —— 本事实为真 ⟺ 取值口通到 `blobExchange.get`;判过的组随事实交出,路由的 GET / PUT / 在场预检只读它。 */
218
- export declare function sessionSyncFileHistory(d: Pick<Deps, "backend" | "sessionStorage" | "fileHistoryStore" | "sessionPolicyStore">): Fact<SessionSyncWhy | "blob_exchange_absent", {
232
+ export declare function sessionSyncFileHistory(d: Pick<Deps, "backend" | "sessionStorage">): Fact<SessionSyncWhy | "blob_exchange_absent", {
219
233
  historyStore: ServiceFileHistoryStore;
220
234
  blobExchange: ServiceBlobExchange;
221
235
  }>;
222
236
  type RewindFilesWhy = "file_history_store_absent" | "session_head_face_absent" | "resume_anchor_store_absent" | "execution_lane_handless" | "workspace_rebuilt_per_task" | "session_store_shared";
223
237
  /**
224
238
  * run 外的「只恢复代码」口(`POST /v1/sessions/:id/rewind-files`,[ref])这台部署**解不解得出** —— 能力位 `sessionRewindFiles` 与该口的 501 读这一只。
225
- * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(引擎 `Runner.rewindFiles` 读的同一只;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、不摘店,
226
- * 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
227
- * `history-anchor.ts`;两只同出存储后端,所以是同一格)∧ 执行车道有手
239
+ * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(后端恒交的那一只 —— 引擎 `Runner.rewindFiles` 读的同一只;没有后端 ⇒ 没有它;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、
240
+ * 不摘店,所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
241
+ * `history-anchor.ts`;锚店是后端恒交的那一只,run 店同出存储后端,所以是同一格)∧ 执行车道有手
228
242
  * (无手车道上引擎恒拒 `rewind.files_env_unsupported`:没有工作区可回退 —— 位说有而口恒拒不许发生)∧ 即时回退的工作区活过一次执行(部署形表行 `rewindableWorkspace`;
229
243
  * 否则恢复的结果到不了下一次执行)∧ 会话店由本进程独占(local 后端:数据根被一个活进程锁住 ⇒ 引擎的进程内会话锁就是全局互斥;
230
244
  * SQL 后端被多副本共用,而 run 外回退还没有一只跨副本的持久认领 —— 「先查认领再交引擎」只是检查不是互斥,所以在共享店上位为假、口 501,不留「检查即放行」)。
231
245
  * 动词本身是引擎 `Runner` 的必有成员(型上必在),不是一格。
232
246
  * 见证 = 判过在场的设施(历史店 · 手柄翻译的两只读店 · 会话店);路由在拒臂之后只读见证。
233
247
  */
234
- export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
248
+ export declare function sessionRewindFiles<D extends Pick<Deps, "runStore" | "sessionStorage" | "config" | "backend">>(d: D): Fact<RewindFilesWhy, {
235
249
  historyStore: ServiceFileHistoryStore;
236
- anchors: HistoryAnchorReaders;
237
- sessionStorage: HeadReadingSessionStore;
250
+ anchors: HistoryAnchorReaders & {
251
+ readonly runs: Held<D, "runStore">;
252
+ };
253
+ sessionStorage: HeadReadingSessionStore<D>;
238
254
  }>;
239
255
  /**
240
256
  * 同一口的 `dryRun` **带不带改动统计** —— 能力位 `sessionRewindFilesPreview`。= 立即回退可用 ∧ 店实现了 core 契约的可选座 `diffStats`
@@ -242,7 +258,7 @@ export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "r
242
258
  * `previewFileDelta` 不在 core 包根导出面上,本仓不另写一份 —— 等 core 导出它,SQL 店补这一座、本位随之转真,路由零改)。本位为假**不是**口不收 `dryRun`:口照收,答 `preview: null`
243
259
  * (「这台给不出统计」≠「什么都不会变」);所以本事实没有 501 拒点,只有能力位读它。
244
260
  */
245
- export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
261
+ export declare function sessionRewindFilesPreview(d: Pick<Deps, "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
246
262
  /** 持久审批底座(checkpoint 店)在场 —— `/v1/approvals/*` 与 `/v1/assistant/*` 整条车道、会话 wake 都站在它上面。 */
247
263
  export declare function checkpointPark(d: Pick<Deps, "checkpointStore">): Fact<"checkpoint_store_absent", {
248
264
  checkpointStore: Store<"checkpointStore">;
@@ -263,6 +279,7 @@ type ActiveStreamApproval = Extract<ReturnType<typeof resolveStreamApprovalGate>
263
279
  /** 流内审批协议在场 —— 判据的属主仍是 `resolveStreamApprovalGate`(三条执行腿的装配也读它);本事实把它的拒因译进 why 闭集。 */
264
280
  export declare function streamApproval(d: Pick<Deps, "toolApproval" | "config" | "backend" | "checkpointStore">): Fact<StreamApprovalWhy, {
265
281
  askStore: ActiveStreamApproval["askStore"];
282
+ coordinator: Store<"toolApproval">;
266
283
  }>;
267
284
  /**
268
285
  * 读根授权(「Yes, and add directory」)这台部署**受理不受理** —— `GET /v1/capabilities` 的 `approvalReadRootGrant` 位,与
@@ -291,11 +308,11 @@ export declare function deviceLane(d: Pick<Deps, "deviceHub">): Fact<"device_hub
291
308
  hub: Store<"deviceHub">;
292
309
  }>;
293
310
  /** 设备管理三动词(列 / 读 / 换绑):hub ∧ 设备店 ∧ 入网 ∧ 持久 run 账面(换绑的「无在飞 run」门要它)。 */
294
- export declare function deviceManagement(d: Pick<Deps, "deviceHub" | "deviceStore" | "deviceEnrollment" | "runStore">): Fact<"device_hub_absent" | "device_store_absent" | "device_enrollment_absent" | "run_store_absent", {
311
+ export declare function deviceManagement<D extends Pick<Deps, "deviceHub" | "deviceStore" | "deviceEnrollment" | "runStore">>(d: D): Fact<"device_hub_absent" | "device_store_absent" | "device_enrollment_absent" | "run_store_absent", {
295
312
  hub: Store<"deviceHub">;
296
313
  store: Store<"deviceStore">;
297
314
  enrollment: Store<"deviceEnrollment">;
298
- runStore: Store<"runStore">;
315
+ runStore: Held<D, "runStore">;
299
316
  }>;
300
317
  export declare function fleetStream(d: Pick<Deps, "fleetBus">): Fact<"fleet_bus_absent", {
301
318
  fleetBus: Store<"fleetBus">;
@@ -344,10 +361,10 @@ export declare function memorySyncServe(d: Pick<Deps, "memorySync" | "config">):
344
361
  * 会话记忆同步触发口(`POST /v1/sessions/:id/memory/sync`):本机同步腿在场 ∧ 持久 run 账面(读集 = 会话最近一条已结腿的记忆观测;收割栅栏读会话的 run 认领)
345
362
  * ∧ 会话头读(属主门与 `sourceRevision` = 同一次头读的叶子)。
346
363
  */
347
- export declare function sessionMemorySync(d: Pick<Deps, "memorySyncLeg" | "runStore" | "sessionStorage">): Fact<"memory_sync_leg_absent" | "run_store_absent" | "session_head_face_absent", {
364
+ export declare function sessionMemorySync<D extends Pick<Deps, "memorySyncLeg" | "runStore" | "sessionStorage">>(d: D): Fact<"memory_sync_leg_absent" | "run_store_absent" | "session_head_face_absent", {
348
365
  leg: Store<"memorySyncLeg">;
349
- runStore: Store<"runStore">;
350
- sessionStorage: HeadReadingSessionStore;
366
+ runStore: Held<D, "runStore">;
367
+ sessionStorage: HeadReadingSessionStore<D>;
351
368
  }>;
352
369
  /** 跨主体投递门在座(`POST /v1/principal-inbox/messages` 的可用性门与能力位 `principalInboxDelivery` 同读这一只)。门的装配本身是
353
370
  * 一道合取(收件箱消费方声明 ∧ 耐久 mailbox ∧ org 成员目录 ∧ 配额店,缺一拒启 —— `boot/stage-06-runners.ts`),
@@ -368,20 +385,21 @@ export declare function engineHandover(d: Pick<Deps, "drainState">): Fact<"engin
368
385
  export declare function operatorLane(d: {
369
386
  readonly config: Pick<ServiceConfig, "operatorPrincipals" | "operatorSingleUser">;
370
387
  }): Fact<"operator_principals_empty">;
371
- type AdoptionCapableBackend = Store<"backend"> & {
388
+ /** 带收编日志的后端(见证随调用方的 deps:路由层的后端视图上店工厂照样封着)。 */
389
+ type AdoptionCapableBackend<D extends Pick<Deps, "backend">> = Held<D, "backend"> & {
372
390
  adoptionLog(): ReturnType<NonNullable<Store<"backend">["adoptionLog"]>>;
373
391
  };
374
- export declare function adoption(d: Pick<Deps, "config" | "backend">): Fact<"operator_principals_empty" | "adoption_store_absent", {
375
- backend: AdoptionCapableBackend;
392
+ export declare function adoption<D extends Pick<Deps, "config" | "backend">>(d: D): Fact<"operator_principals_empty" | "adoption_store_absent", {
393
+ backend: AdoptionCapableBackend<D>;
376
394
  }>;
377
- type AdoptionImportSessionStore = WithMethods<OwnerAwareSessionStore, "beginImportStaging">;
395
+ type AdoptionImportSessionStore<D extends SessionDeps> = SessionWith<D, "beginImportStaging">;
378
396
  /**
379
397
  * 收编批量导入(`POST /v1/adoption/:id/sessions`)与能力位 `adoptionImport` 的部署半:收编日志 ∧ 会话店的暂存导入面(派生 id 那一格占没占由提交的属主判答,不另要头读面)。
380
398
  * **不判运维名册**:这扇门不是 operator 面 —— 调用者是那条收编行的源主体本人(名单空了,已收编的行照样在)。
381
399
  */
382
- export declare function adoptionSessionImport(d: Pick<Deps, "backend" | "sessionStorage">): Fact<"adoption_store_absent" | "session_import_staging_absent", {
383
- backend: AdoptionCapableBackend;
384
- sessionStorage: AdoptionImportSessionStore;
400
+ export declare function adoptionSessionImport<D extends Pick<Deps, "backend" | "sessionStorage">>(d: D): Fact<"adoption_store_absent" | "session_import_staging_absent", {
401
+ backend: AdoptionCapableBackend<D>;
402
+ sessionStorage: AdoptionImportSessionStore<D>;
385
403
  }>;
386
404
  export declare function memoryBundle(d: Pick<Deps, "config" | "memoryBundleExport" | "memoryBundleImport">): Fact<"operator_principals_empty" | "memory_bundle_faces_absent", {
387
405
  exportScopes: Store<"memoryBundleExport">;
@@ -417,9 +435,9 @@ export declare function ruleLaneForCaller(d: Pick<Deps, "ruleConsent">, principa
417
435
  export declare function mcpInjection(d: Pick<Deps, "config">): Fact<"caller_mcp_injection_refused">;
418
436
  /** server-as-peer:旋钮开 ∧ 持久 run 账面在场。两只 JSON-RPC 方法(`message/send` / `tasks/get`)都要 run 店 ——
419
437
  * 没有它,这个 peer 什么都做不了,对外就不该存在(卡与 RPC 一起 404)。 */
420
- export declare function a2aServe(d: Pick<Deps, "config" | "runStore">): Fact<"a2a_serve_off" | "run_store_absent", {
438
+ export declare function a2aServe<D extends Pick<Deps, "config" | "runStore">>(d: D): Fact<"a2a_serve_off" | "run_store_absent", {
421
439
  serve: NonNullable<ServiceConfig["a2aServe"]>;
422
- runStore: Store<"runStore">;
440
+ runStore: Held<D, "runStore">;
423
441
  }>;
424
442
  /** 引擎能不能自编排(core 单源 `workflowsCapability`,boot 算好经 `workflowsCapable` 递来;缺席回落行店代理)。 */
425
443
  export declare function selfOrchestrationEngine(d: Pick<Deps, "workflowsCapable" | "workflowRunStore">): Fact<"workflow_engine_absent">;