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