@sema-agent/server 7.145.0 → 7.147.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 (526) hide show
  1. package/MIGRATION.md +876 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +374 -99
  5. package/deploy/facts/CHANGES.json +25 -0
  6. package/deploy/facts/README.md +57 -0
  7. package/deploy/facts/lanes.json +61 -0
  8. package/deploy/facts/lanes.schema.json +57 -0
  9. package/deploy/facts/sandbox-rbac.json +113 -0
  10. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  11. package/deploy/facts/sealed-key.json +9 -0
  12. package/deploy/facts/sealed-key.schema.json +52 -0
  13. package/deploy/sema-up/README.md +2 -2
  14. package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
  15. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  16. package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
  17. package/deploy/sema-up/chart/templates/server.yaml +9 -4
  18. package/deploy/sema-up/chart/values.yaml +8 -1
  19. package/deploy/sema-up/cluster-up.sh +2 -1
  20. package/deploy/sema-up/lib/flagshape.sh +4 -0
  21. package/deploy/sema-up/lib/lanes.json +2 -5
  22. package/deploy/sema-up/sema-up.sh +12 -9
  23. package/deploy/sema-up/stack/compose.yaml +5 -4
  24. package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
  25. package/dist/adoption/import-limits.d.ts +6 -0
  26. package/dist/adoption/import-limits.js +7 -0
  27. package/dist/adoption/import.d.ts +62 -0
  28. package/dist/adoption/import.js +107 -0
  29. package/dist/adoption/wire.d.ts +52 -0
  30. package/dist/adoption/wire.js +9 -0
  31. package/dist/approval-ask-machine.d.ts +2 -2
  32. package/dist/approval-card.d.ts +7 -16
  33. package/dist/approval-card.js +0 -4
  34. package/dist/approval-gate-currency.d.ts +1 -1
  35. package/dist/approval-gate-currency.js +1 -1
  36. package/dist/approval-reconciler.d.ts +1 -1
  37. package/dist/approval.d.ts +3 -3
  38. package/dist/audit.js +2 -2
  39. package/dist/bench/s1/live-deps.js +3 -1
  40. package/dist/boot/crash-last.js +2 -1
  41. package/dist/boot/deployment-mods.d.ts +11 -1
  42. package/dist/boot/deployment-mods.js +15 -2
  43. package/dist/boot/device-lane.js +7 -5
  44. package/dist/boot/engine-lease.d.ts +195 -22
  45. package/dist/boot/engine-lease.js +146 -20
  46. package/dist/boot/execution-env.d.ts +5 -0
  47. package/dist/boot/execution-env.js +57 -33
  48. package/dist/boot/execution-lane.d.ts +37 -9
  49. package/dist/boot/execution-lane.js +74 -20
  50. package/dist/boot/exit-boundary.d.ts +50 -0
  51. package/dist/boot/exit-boundary.js +32 -0
  52. package/dist/boot/exit-last.d.ts +20 -4
  53. package/dist/boot/exit-last.js +23 -5
  54. package/dist/boot/governance-seams.d.ts +2 -2
  55. package/dist/boot/governance-seams.js +1 -0
  56. package/dist/boot/leader.js +1 -1
  57. package/dist/boot/memory-boundary.d.ts +11 -11
  58. package/dist/boot/memory-boundary.js +3 -3
  59. package/dist/boot/memory-consolidation.d.ts +42 -41
  60. package/dist/boot/memory-consolidation.js +26 -28
  61. package/dist/boot/org-memory.js +3 -2
  62. package/dist/boot/parked-revive-gate.d.ts +1 -1
  63. package/dist/boot/parked-revive-gate.js +1 -1
  64. package/dist/boot/reapers.d.ts +12 -4
  65. package/dist/boot/reapers.js +40 -16
  66. package/dist/boot/resolve-spec.d.ts +2 -0
  67. package/dist/boot/resolve-spec.js +126 -123
  68. package/dist/boot/retention-lane.d.ts +4 -42
  69. package/dist/boot/runner-deps.js +1 -1
  70. package/dist/boot/session-faces.d.ts +1 -0
  71. package/dist/boot/session-faces.js +11 -3
  72. package/dist/boot/shutdown.js +27 -9
  73. package/dist/boot/stage-01-config.d.ts +1 -1
  74. package/dist/boot/stage-01-config.js +7 -3
  75. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
  76. package/dist/boot/stage-02-web-admin-pull.js +10 -8
  77. package/dist/boot/stage-03-store-backend.d.ts +2 -1
  78. package/dist/boot/stage-03-store-backend.js +2 -2
  79. package/dist/boot/stage-04-stores.d.ts +2 -1
  80. package/dist/boot/stage-05-execution-env.d.ts +4 -1
  81. package/dist/boot/stage-05-execution-env.js +6 -6
  82. package/dist/boot/stage-06-runners.d.ts +5 -2
  83. package/dist/boot/stage-06-runners.js +12 -13
  84. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  85. package/dist/boot/stage-07-capability-layer.js +7 -7
  86. package/dist/boot/stage-08-reapers.d.ts +5 -2
  87. package/dist/boot/stage-08-reapers.js +3 -3
  88. package/dist/boot/stage-09-leader.d.ts +6 -2
  89. package/dist/boot/stage-10-http-server.d.ts +6 -2
  90. package/dist/boot/stage-10-http-server.js +5 -3
  91. package/dist/boot/stores.d.ts +10 -0
  92. package/dist/boot/stores.js +53 -26
  93. package/dist/boot/web-admin.js +3 -3
  94. package/dist/boot/workflow-orchestration.d.ts +1 -1
  95. package/dist/boot/workflow-orchestration.js +2 -1
  96. package/dist/capabilities/center-plugins.d.ts +2 -0
  97. package/dist/capabilities/center-plugins.js +6 -2
  98. package/dist/capabilities/composite-members.d.ts +4 -1
  99. package/dist/capabilities/composite-members.js +4 -1
  100. package/dist/capabilities/execution-lane.d.ts +7 -7
  101. package/dist/capabilities/execution-lane.js +2 -2
  102. package/dist/capabilities/hands-lane.d.ts +1 -1
  103. package/dist/capabilities/scenarios.d.ts +34 -20
  104. package/dist/capabilities/scenarios.js +13 -9
  105. package/dist/capabilities/settings-contract.d.ts +29 -0
  106. package/dist/capabilities/settings-contract.js +14 -0
  107. package/dist/capabilities/skills.d.ts +5 -5
  108. package/dist/capability-facts.d.ts +56 -1
  109. package/dist/capability-facts.js +59 -8
  110. package/dist/center-credential-renewer.js +3 -2
  111. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  112. package/dist/config-catalog.js +19 -9
  113. package/dist/config-invariants.d.ts +18 -3
  114. package/dist/config-invariants.js +36 -19
  115. package/dist/config-lkg.d.ts +1 -1
  116. package/dist/config-lkg.js +5 -6
  117. package/dist/config-provider.d.ts +2 -2
  118. package/dist/config-provider.js +2 -0
  119. package/dist/config-types.d.ts +228 -185
  120. package/dist/config.d.ts +74 -6
  121. package/dist/config.js +146 -64
  122. package/dist/degenerate-instrument.js +1 -1
  123. package/dist/deleted-session-ids.d.ts +19 -0
  124. package/dist/deleted-session-ids.js +26 -0
  125. package/dist/deploy-facts.d.ts +155 -0
  126. package/dist/deploy-facts.js +95 -0
  127. package/dist/deployment-shape.d.ts +21 -12
  128. package/dist/deployment-shape.js +24 -6
  129. package/dist/device-ws-hub.d.ts +48 -3
  130. package/dist/device-ws-hub.js +48 -2
  131. package/dist/env-facts.d.ts +7 -5
  132. package/dist/env-facts.js +10 -6
  133. package/dist/error-code-family.d.ts +35 -0
  134. package/dist/error-code-family.js +26 -0
  135. package/dist/execution-config-root.d.ts +5 -5
  136. package/dist/execution-config-root.js +5 -5
  137. package/dist/execution-env-purpose.d.ts +14 -0
  138. package/dist/execution-env-purpose.js +29 -0
  139. package/dist/execution-lane-caps.d.ts +49 -86
  140. package/dist/execution-lane-caps.js +52 -62
  141. package/dist/execution-placement.d.ts +18 -2
  142. package/dist/execution-placement.js +19 -0
  143. package/dist/file-history-disclosure.d.ts +2 -2
  144. package/dist/fleet/drain-entry.d.ts +46 -3
  145. package/dist/fleet/drain-entry.js +6 -0
  146. package/dist/fleet/fleet-bus.d.ts +2 -1
  147. package/dist/fleet/serving-lease.js +3 -4
  148. package/dist/history-anchor.d.ts +22 -0
  149. package/dist/history-anchor.js +14 -0
  150. package/dist/hooks/branch-transcript.d.ts +1 -1
  151. package/dist/hooks/branch-transcript.js +1 -0
  152. package/dist/hooks/classic-stations.d.ts +25 -8
  153. package/dist/hooks/classic-stations.js +29 -3
  154. package/dist/hooks/command-spawn.d.ts +1 -4
  155. package/dist/hooks/command-spawn.js +0 -11
  156. package/dist/hooks/hook-runner.d.ts +85 -24
  157. package/dist/hooks/hook-runner.js +326 -109
  158. package/dist/hooks/hook-source.d.ts +14 -2
  159. package/dist/hooks/hook-source.js +8 -0
  160. package/dist/http/active-run-conflict.d.ts +1 -1
  161. package/dist/http/active-run-conflict.js +1 -1
  162. package/dist/http/admission.js +11 -1
  163. package/dist/http/approval-sweeps.d.ts +2 -5
  164. package/dist/http/approval-sweeps.js +3 -2
  165. package/dist/http/checkpoint-ctx.d.ts +76 -71
  166. package/dist/http/checkpoint-ctx.js +40 -40
  167. package/dist/http/claim-latency.d.ts +10 -0
  168. package/dist/http/claim-latency.js +12 -0
  169. package/dist/http/dispatch.js +19 -3
  170. package/dist/http/durable-run-leg.d.ts +5 -0
  171. package/dist/http/durable-run-leg.js +3 -1
  172. package/dist/http/execution-context.d.ts +7 -1
  173. package/dist/http/execution-context.js +13 -0
  174. package/dist/http/health-self-report.d.ts +6 -2
  175. package/dist/http/health-self-report.js +3 -2
  176. package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
  177. package/dist/http/memory-compliance-failure-reply.js +5 -15
  178. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  179. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  180. package/dist/http/memory-store-refusal-reply.d.ts +3 -3
  181. package/dist/http/memory-store-refusal-reply.js +3 -0
  182. package/dist/http/owner-access.d.ts +11 -0
  183. package/dist/http/owner-access.js +7 -4
  184. package/dist/http/principal-gate.d.ts +28 -16
  185. package/dist/http/principal-gate.js +10 -19
  186. package/dist/http/request-guards.d.ts +2 -2
  187. package/dist/http/request-guards.js +5 -5
  188. package/dist/http/resume-legs.d.ts +29 -10
  189. package/dist/http/resume-legs.js +94 -56
  190. package/dist/http/rewind-files-reply.d.ts +34 -0
  191. package/dist/http/rewind-files-reply.js +36 -0
  192. package/dist/http/route-ctx.d.ts +43 -26
  193. package/dist/http/route-table.js +4 -0
  194. package/dist/http/routes/adoption.d.ts +11 -0
  195. package/dist/http/routes/adoption.js +80 -6
  196. package/dist/http/routes/agents-roster.js +1 -0
  197. package/dist/http/routes/approvals-assistant.js +7 -26
  198. package/dist/http/routes/background.js +1 -0
  199. package/dist/http/routes/capabilities.js +12 -3
  200. package/dist/http/routes/devices.js +1 -1
  201. package/dist/http/routes/diagnostics.d.ts +9 -14
  202. package/dist/http/routes/diagnostics.js +10 -20
  203. package/dist/http/routes/engine.d.ts +31 -0
  204. package/dist/http/routes/engine.js +81 -0
  205. package/dist/http/routes/memory-bundle.js +3 -0
  206. package/dist/http/routes/memory-consolidation.js +3 -5
  207. package/dist/http/routes/memory-origin.d.ts +2 -2
  208. package/dist/http/routes/memory-origin.js +2 -4
  209. package/dist/http/routes/memory-policy.js +5 -1
  210. package/dist/http/routes/notify-wake.js +2 -1
  211. package/dist/http/routes/observability.js +3 -6
  212. package/dist/http/routes/projects.d.ts +70 -0
  213. package/dist/http/routes/projects.js +86 -0
  214. package/dist/http/routes/rules.js +30 -2
  215. package/dist/http/routes/runs.js +15 -11
  216. package/dist/http/routes/session-sync.js +39 -35
  217. package/dist/http/routes/sessions-list.d.ts +1 -1
  218. package/dist/http/routes/sessions.d.ts +7 -1
  219. package/dist/http/routes/sessions.js +108 -2
  220. package/dist/http/routes/tasks.js +32 -8
  221. package/dist/http/routes/trace-usage.js +1 -1
  222. package/dist/http/run-concurrency-cap.d.ts +86 -0
  223. package/dist/http/run-concurrency-cap.js +54 -0
  224. package/dist/http/server.d.ts +31 -14
  225. package/dist/http/server.js +29 -3
  226. package/dist/http/stored-body-replay.d.ts +12 -7
  227. package/dist/http/stored-body-replay.js +28 -5
  228. package/dist/http/wire-types.d.ts +27 -13
  229. package/dist/index.d.ts +2 -2
  230. package/dist/index.js +1 -1
  231. package/dist/instruction-source-notice.d.ts +1 -1
  232. package/dist/json-body-limit.d.ts +8 -0
  233. package/dist/json-body-limit.js +2 -0
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/local-data-root.d.ts +2 -2
  236. package/dist/memory-embedder-reembed.d.ts +38 -0
  237. package/dist/memory-embedder-reembed.js +20 -0
  238. package/dist/memory-incident-sink.d.ts +0 -28
  239. package/dist/memory-incident-sink.js +5 -0
  240. package/dist/memory-operator-faces.d.ts +9 -4
  241. package/dist/memory-scope-stores.d.ts +9 -7
  242. package/dist/memory-scope-stores.js +3 -14
  243. package/dist/memory-scope.d.ts +38 -2
  244. package/dist/memory-scope.js +33 -2
  245. package/dist/memory-store-refusal.d.ts +17 -4
  246. package/dist/memory-store-refusal.js +1 -1
  247. package/dist/memory-sync-client.d.ts +2 -0
  248. package/dist/memory-sync-client.js +13 -11
  249. package/dist/memory-sync.js +1 -1
  250. package/dist/model-compat.d.ts +35 -21
  251. package/dist/model-compat.js +49 -21
  252. package/dist/model-entry-refusal.d.ts +11 -1
  253. package/dist/model-entry-refusal.js +7 -0
  254. package/dist/namespaced-rule-name.d.ts +18 -1
  255. package/dist/namespaced-rule-name.js +12 -0
  256. package/dist/net-address.d.ts +53 -0
  257. package/dist/net-address.js +111 -0
  258. package/dist/observability/fail-open.d.ts +29 -17
  259. package/dist/observability/fail-open.js +29 -17
  260. package/dist/observability/metrics.d.ts +2 -0
  261. package/dist/observability/metrics.js +2 -0
  262. package/dist/observability/secret-env-scrub.d.ts +30 -4
  263. package/dist/observability/secret-env-scrub.js +15 -3
  264. package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
  265. package/dist/orchestration/workflow-agent-session-index.js +1 -6
  266. package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
  267. package/dist/orchestration/workflow-completion-inbox.js +63 -45
  268. package/dist/orchestration/workflow-notify-journal.js +2 -3
  269. package/dist/org-delivery-gate.js +1 -1
  270. package/dist/org-memory-admission.d.ts +5 -2
  271. package/dist/org-memory-admission.js +25 -10
  272. package/dist/parked-decide.d.ts +33 -26
  273. package/dist/parked-decide.js +36 -44
  274. package/dist/peer-directory.d.ts +6 -12
  275. package/dist/peer-directory.js +5 -1
  276. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  277. package/dist/plugins/approval-ask-store-file.js +37 -4
  278. package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
  279. package/dist/plugins/approval-ask-store-memory.js +11 -2
  280. package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
  281. package/dist/plugins/approval-ask-store-sql.js +3 -1
  282. package/dist/plugins/blob-backend.d.ts +38 -195
  283. package/dist/plugins/blob-backend.js +33 -229
  284. package/dist/plugins/caching-session-store.d.ts +12 -5
  285. package/dist/plugins/caching-session-store.js +3 -0
  286. package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
  287. package/dist/plugins/checkpoint-index-columns.js +3 -2
  288. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  289. package/dist/plugins/checkpoint-store-face.js +152 -0
  290. package/dist/plugins/device-store-sql.d.ts +2 -2
  291. package/dist/plugins/device-store-sql.js +5 -10
  292. package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
  293. package/dist/plugins/execution-lane-rename-m40.js +10 -0
  294. package/dist/plugins/execution-placement-sql.d.ts +63 -88
  295. package/dist/plugins/execution-placement-sql.js +94 -54
  296. package/dist/plugins/file-run-store.d.ts +26 -18
  297. package/dist/plugins/file-run-store.js +64 -75
  298. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  299. package/dist/plugins/fork-routing-session-store.js +2 -2
  300. package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
  301. package/dist/plugins/imported-layer-root-retirement.js +4 -8
  302. package/dist/plugins/inbox-payload-column.d.ts +14 -0
  303. package/dist/plugins/inbox-payload-column.js +13 -0
  304. package/dist/plugins/local-checkpoint-store.d.ts +7 -2
  305. package/dist/plugins/local-checkpoint-store.js +13 -8
  306. package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
  307. package/dist/plugins/local-data-dir-modes-m39.js +182 -0
  308. package/dist/plugins/local-engine-high-water.d.ts +11 -0
  309. package/dist/plugins/local-engine-high-water.js +59 -0
  310. package/dist/plugins/local-session-store.d.ts +119 -30
  311. package/dist/plugins/local-session-store.js +156 -53
  312. package/dist/plugins/local-task-attachment-store.d.ts +2 -0
  313. package/dist/plugins/local-task-attachment-store.js +10 -11
  314. package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
  315. package/dist/plugins/memory-embedder-fingerprint.js +52 -12
  316. package/dist/plugins/memory-embedder.d.ts +1 -1
  317. package/dist/plugins/memory-embedder.js +2 -2
  318. package/dist/plugins/memory-engine-pg.d.ts +30 -6
  319. package/dist/plugins/memory-engine-pg.js +96 -214
  320. package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
  321. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  322. package/dist/plugins/memory-engine-tidb.d.ts +38 -9
  323. package/dist/plugins/memory-engine-tidb.js +99 -230
  324. package/dist/plugins/memory-key-guards.d.ts +1 -1
  325. package/dist/plugins/memory-origin-law.d.ts +3 -3
  326. package/dist/plugins/one-time-migrations.d.ts +169 -83
  327. package/dist/plugins/one-time-migrations.js +295 -235
  328. package/dist/plugins/owner-only-file-mode.d.ts +29 -0
  329. package/dist/plugins/owner-only-file-mode.js +141 -0
  330. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  331. package/dist/plugins/permission-rule-store-file.js +20 -1
  332. package/dist/plugins/pg-pool.d.ts +2 -1
  333. package/dist/plugins/pg-pool.js +12 -5
  334. package/dist/plugins/release-version.d.ts +20 -0
  335. package/dist/plugins/release-version.js +28 -0
  336. package/dist/plugins/remote-env-adb.d.ts +20 -4
  337. package/dist/plugins/remote-env-adb.js +39 -11
  338. package/dist/plugins/remote-env-e2b.d.ts +12 -3
  339. package/dist/plugins/remote-env-e2b.js +6 -4
  340. package/dist/plugins/remote-env-host.d.ts +9 -1
  341. package/dist/plugins/remote-env-host.js +6 -5
  342. package/dist/plugins/remote-env-k8s.d.ts +5 -2
  343. package/dist/plugins/remote-env-k8s.js +15 -4
  344. package/dist/plugins/remote-env-local-docker.d.ts +4 -1
  345. package/dist/plugins/remote-env-local-docker.js +3 -3
  346. package/dist/plugins/remote-env-ssh.d.ts +8 -2
  347. package/dist/plugins/remote-env-ssh.js +26 -24
  348. package/dist/plugins/remote-shell.d.ts +59 -30
  349. package/dist/plugins/remote-shell.js +175 -62
  350. package/dist/plugins/retention-declaration.d.ts +37 -0
  351. package/dist/plugins/retention-declaration.js +9 -0
  352. package/dist/plugins/retention-deployment.d.ts +126 -0
  353. package/dist/plugins/retention-deployment.js +88 -0
  354. package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
  355. package/dist/plugins/retention-lane-store-sql.js +103 -1
  356. package/dist/plugins/retention-sql.d.ts +29 -0
  357. package/dist/plugins/retention-sql.js +8 -0
  358. package/dist/plugins/run-store-sql.js +2 -2
  359. package/dist/plugins/schema-consistency.d.ts +0 -6
  360. package/dist/plugins/schema-consistency.js +1 -2
  361. package/dist/plugins/schema-ensure-legs.d.ts +1 -1
  362. package/dist/plugins/schema-ensure-legs.js +13 -3
  363. package/dist/plugins/session-ext-table.d.ts +74 -0
  364. package/dist/plugins/session-ext-table.js +121 -0
  365. package/dist/plugins/session-fork.d.ts +31 -9
  366. package/dist/plugins/session-fork.js +3 -2
  367. package/dist/plugins/session-placement.d.ts +4 -2
  368. package/dist/plugins/session-row-sql.d.ts +8 -7
  369. package/dist/plugins/session-row-sql.js +15 -7
  370. package/dist/plugins/session-store-sql.d.ts +131 -0
  371. package/dist/plugins/session-store-sql.js +298 -0
  372. package/dist/plugins/session-workspace-cell.d.ts +2 -2
  373. package/dist/plugins/session-workspace-cell.js +2 -2
  374. package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
  375. package/dist/plugins/shared-memory-store-sql.js +13 -13
  376. package/dist/plugins/snapshot-bucket-presence.js +1 -1
  377. package/dist/plugins/sql-driver.d.ts +23 -7
  378. package/dist/plugins/sql-driver.js +41 -8
  379. package/dist/plugins/sql-errors.d.ts +5 -2
  380. package/dist/plugins/sql-errors.js +4 -0
  381. package/dist/plugins/sql-json-column.d.ts +5 -1
  382. package/dist/plugins/store-backend.d.ts +46 -16
  383. package/dist/plugins/store-backend.js +192 -69
  384. package/dist/plugins/store-contracts.d.ts +10 -13
  385. package/dist/plugins/store-contracts.js +1 -9
  386. package/dist/plugins/store-sweep.d.ts +63 -0
  387. package/dist/plugins/store-sweep.js +48 -0
  388. package/dist/plugins/task-attachment-store.d.ts +6 -8
  389. package/dist/plugins/task-attachment-store.js +15 -10
  390. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  391. package/dist/plugins/text-column-capacity.d.ts +21 -0
  392. package/dist/plugins/text-column-capacity.js +5 -0
  393. package/dist/plugins/tidb-pool.d.ts +3 -2
  394. package/dist/plugins/tidb-pool.js +20 -32
  395. package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
  396. package/dist/prompt-screen.d.ts +6 -9
  397. package/dist/prompt-screen.js +2 -5
  398. package/dist/read-face-posture.d.ts +6 -6
  399. package/dist/read-face-posture.js +2 -2
  400. package/dist/request-value-closure.d.ts +5 -5
  401. package/dist/request-value-closure.js +1 -1
  402. package/dist/rules-consent.d.ts +48 -27
  403. package/dist/rules-consent.js +147 -23
  404. package/dist/run-cancel-context.d.ts +4 -1
  405. package/dist/run-cancel-context.js +2 -1
  406. package/dist/run-local.js +17 -13
  407. package/dist/runs.d.ts +48 -30
  408. package/dist/runs.js +27 -17
  409. package/dist/runtime-caps-resolver.d.ts +15 -8
  410. package/dist/runtime-caps-resolver.js +14 -10
  411. package/dist/sandbox-egress-policy.js +6 -11
  412. package/dist/sandbox-rbac-rules.d.ts +88 -0
  413. package/dist/sandbox-rbac-rules.js +80 -0
  414. package/dist/sealed-key-layout.d.ts +16 -0
  415. package/dist/sealed-key-layout.js +3 -0
  416. package/dist/sealed-key.js +8 -6
  417. package/dist/security.d.ts +43 -9
  418. package/dist/security.js +9 -2
  419. package/dist/sema-config-dir.js +2 -2
  420. package/dist/server-secret-env.d.ts +2 -0
  421. package/dist/service-version.d.ts +2 -1
  422. package/dist/service-version.js +2 -2
  423. package/dist/session-error-wire.d.ts +1 -1
  424. package/dist/session-incarnation.d.ts +8 -5
  425. package/dist/session-notify-door.d.ts +5 -3
  426. package/dist/session-resident-background.d.ts +110 -0
  427. package/dist/session-resident-background.js +88 -0
  428. package/dist/session-row.d.ts +1 -1
  429. package/dist/session-sync-kernel.d.ts +53 -14
  430. package/dist/session-sync-kernel.js +70 -1
  431. package/dist/session-sync.d.ts +5 -3
  432. package/dist/session-workspace.d.ts +12 -2
  433. package/dist/session-workspace.js +6 -0
  434. package/dist/sighup-idle.d.ts +9 -7
  435. package/dist/sighup-idle.js +4 -5
  436. package/dist/spec-fields.d.ts +16 -0
  437. package/dist/spec-fields.js +7 -0
  438. package/dist/store-posture.d.ts +2 -1
  439. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  440. package/dist/stored-request-env-credentials-m38.js +8 -0
  441. package/dist/stored-request-hooks-m20.d.ts +3 -2
  442. package/dist/stored-request-hooks-m20.js +19 -14
  443. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  444. package/dist/stores-sql/blob-index-sql.d.ts +148 -0
  445. package/dist/stores-sql/blob-index-sql.js +154 -0
  446. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
  447. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
  448. package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
  449. package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
  450. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  451. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  452. package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
  453. package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
  454. package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
  455. package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
  456. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  457. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  458. package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
  459. package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
  460. package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
  461. package/dist/stores-sql/session-write-hooks.d.ts +59 -0
  462. package/dist/stores-sql/session-write-hooks.js +2 -0
  463. package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
  464. package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
  465. package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
  466. package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
  467. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
  468. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  469. package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
  470. package/dist/stores-sql/windowed-session-storage.js +61 -0
  471. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  472. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  473. package/dist/task-a2a.d.ts +7 -1
  474. package/dist/task-a2a.js +15 -14
  475. package/dist/task-cwd.d.ts +11 -3
  476. package/dist/task-cwd.js +17 -1
  477. package/dist/task-mcp.d.ts +10 -2
  478. package/dist/task-mcp.js +13 -16
  479. package/dist/task-settings.d.ts +68 -8
  480. package/dist/task-settings.js +63 -6
  481. package/dist/tool-approval.d.ts +23 -10
  482. package/dist/tool-approval.js +10 -6
  483. package/dist/trace/core-keyset-guard.d.ts +17 -10
  484. package/dist/trace/engine-notice-wire.d.ts +1 -1
  485. package/dist/trace/engine-notice-wire.js +4 -0
  486. package/dist/trace/exit-seat.d.ts +29 -1
  487. package/dist/trace/exit-seat.js +4 -0
  488. package/dist/trace/project.d.ts +33 -16
  489. package/dist/trace/project.js +21 -9
  490. package/dist/trace/redact.d.ts +13 -2
  491. package/dist/trace/redact.js +347 -78
  492. package/dist/trace/self-minted-wire.d.ts +587 -16
  493. package/dist/trace/self-minted-wire.js +215 -9
  494. package/dist/trace/sema-provenance.d.ts +45 -41
  495. package/dist/trace/sema-provenance.js +81 -10
  496. package/dist/trace/task-notification-facets.d.ts +70 -2
  497. package/dist/trace/task-notification-facets.js +71 -1
  498. package/dist/trace/wire-projection-faces.d.ts +39 -3
  499. package/dist/trace/wire-projection-faces.js +27 -2
  500. package/dist/unread-request-members.d.ts +66 -0
  501. package/dist/unread-request-members.js +41 -0
  502. package/dist/usage-analytics.d.ts +4 -0
  503. package/dist/user-input-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/apply-effective.js +22 -26
  505. package/dist/web-admin-client/candidate-gate.d.ts +35 -3
  506. package/dist/web-admin-client/candidate-gate.js +53 -5
  507. package/dist/web-admin-client/center-request.d.ts +4 -1
  508. package/dist/web-admin-client/center-request.js +2 -1
  509. package/dist/web-admin-client/effective-keys.js +0 -1
  510. package/dist/web-admin-client/facade.d.ts +1 -1
  511. package/dist/web-admin-client/http-client.d.ts +1 -0
  512. package/dist/web-admin-client/http-client.js +17 -9
  513. package/dist/web-admin-client/restart-signal.js +5 -2
  514. package/dist/web-admin-client/skills-mcp.d.ts +20 -6
  515. package/dist/web-admin-client/skills-mcp.js +26 -21
  516. package/dist/web-admin-client/types.d.ts +34 -49
  517. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
  518. package/package.json +22 -13
  519. package/scripts/drain-check-local.mjs +8 -55
  520. package/scripts/drain-check.mysql.sql +3 -40
  521. package/scripts/drain-check.pg.sql +3 -40
  522. package/skills/update-config.md +1 -1
  523. package/wire-changes/server@7.146.0.json +3221 -0
  524. package/wire-changes/server@7.147.0.json +813 -0
  525. package/dist/approval-batch-census.d.ts +0 -27
  526. package/dist/approval-batch-census.js +0 -27
@@ -29,47 +29,16 @@
29
29
  * (车1 已实现)。lane **不补记**它们 —— 补记 = 「删了但审计没落地」的窗口重新打开。receipt 在本文件里
30
30
  * 只做两件事:二次确认(日志/指标)与「本轮到底动了多少」的读数。
31
31
  */
32
- import type { RetentionPolicy, RetentionReceipt } from "@sema-agent/core";
32
+ import type { RetentionPolicy } from "@sema-agent/core";
33
33
  import type { RetentionMode } from "../config-types.js";
34
- import type { EndedSpace, SpaceReclaimer } from "../workspace-space.js";
34
+ import type { SpaceReclaimer } from "../workspace-space.js";
35
+ import type { RetentionExecutor } from "../plugins/retention-deployment.js";
35
36
  /** 同 domain 连续失败多少次算「卡住了」(fail-loud 的阈值)。`5` 与 reaper 家族的
36
37
  * `REAPER_FAILURE_WARN_THRESHOLD` 同值同理由:一次抖动(一次重连、一次超时)正是容错要吸收的,
37
38
  * 只有**连败**才越过「可诊断」这条线。 */
38
39
  export declare const RETENTION_SWEEP_STUCK_THRESHOLD = 5;
39
40
  /** 租约 TTL = 本倍数 × sweep 间隔(设计稿 §3)。`2` = 允许一轮跑满一个完整间隔还有余量,再多就该让位。 */
40
41
  export declare const RETENTION_LEASE_TTL_FACTOR = 2;
41
- /**
42
- * lane 消费的**执行器**面 —— core `ManagedRetentionCapability` 的三方法 + 车1 的非契约窄读口
43
- * `previewRetention`(audit-only 档的读数源;core 契约无 count 面)+ 声明位。
44
- *
45
- * 🔴 三方法的入参是 core 契约形的**超集**(多一个 `audit`):车1 的店在运行期对缺席的审计上下文
46
- * fail-closed 抛错,所以这里把它写进类型 —— 让「忘了传」变成编译错,而不是一次运行期的破坏性调用被拒。
47
- */
48
- export interface RetentionExecutor {
49
- readonly retention?: "managed" | "none";
50
- listRetentionDomains(): Promise<readonly string[]>;
51
- previewRetention(input: {
52
- domain: string;
53
- cutoffMs: number;
54
- }): Promise<{
55
- checkpoints: number;
56
- sessions: number;
57
- toolResults: number;
58
- }>;
59
- expireCheckpoints(input: RetentionDestructiveInput): Promise<RetentionReceipt>;
60
- deleteExpiredSessions(input: RetentionDestructiveInput): Promise<RetentionSessionsReceipt>;
61
- deleteOrphanToolResults(input: RetentionDestructiveInput): Promise<RetentionReceipt>;
62
- }
63
- /** 破坏性调用的入参(判定时点的三格随行 —— 理由逐字见车1 `RetentionAuditContext` 的头注)。 */
64
- export interface RetentionDestructiveInput {
65
- domain: string;
66
- cutoffMs: number;
67
- audit: {
68
- mode: RetentionMode;
69
- policyDays: number;
70
- fencingToken: number | null;
71
- };
72
- }
73
42
  /** 非破坏性审计行的写口(lane 侧属主的那五个词)。 */
74
43
  export interface RetentionAuditSink {
75
44
  append(row: {
@@ -132,13 +101,6 @@ export interface RetentionSweepCtx {
132
101
  * (缓存卷、`space/` 快照、该会话停驻车道的快照一并回收)。它从不抛(失败 = 一行 + fail-open 计数);缺席 = 本部署没有可回收的东西。 */
133
102
  spaceReclaimer?: SpaceReclaimer;
134
103
  }
135
- /**
136
- * 会话树 sweep 的回执 = core 契约的 `RetentionReceipt` + 本仓一位:`endedSpaces` = 本次删掉的会话树里**结束了的空间**(会话 id + 住客空间键 = 会话化身;
137
- * 读不出住客的空化身不算),present-iff 非空。lane 把它交给空间的回收座(与会话删除协调器同一只),缓存卷与快照随空间的终结回收。
138
- */
139
- export type RetentionSessionsReceipt = RetentionReceipt & {
140
- readonly endedSpaces?: readonly EndedSpace[];
141
- };
142
104
  /** 一轮的读数(给日志与判据用;lane 自己不做任何决策依赖它)。 */
143
105
  export interface RetentionSweepOutcome {
144
106
  /** 本轮真正处理完的 domain 数(丢租中止时 = 中止之前那些)。 */
@@ -168,7 +130,7 @@ export interface RetentionSweepOutcome {
168
130
  * 为什么本道必须存在:引擎的门不拦
169
131
  * · 没锁时,执行器在场 × 一只 `"none"` 的店 —— 部署于是**广告了一个不执行的留存面**:能力位说
170
132
  * `{mode,maxAgeDays}`、审计表也在长,而那只店的行谁都没在删。
171
- * 本仓的 SQL 后端按同一个事实(扫车道开不开,`plugins/retention-store-sql.ts` 的 `retentionSweepRuns`)给它铸的三只店声明词,所以 lane 开着时
133
+ * 本仓的 SQL 后端按同一个事实(扫车道开不开,`plugins/retention-declaration.ts` 的 `retentionSweepRuns`)给它铸的三只店声明词,所以 lane 开着时
172
134
  * 这三只店在这一格上恒是 `managed`;这一格防的是声明与 lane 脱钩的店(别的后端、替身)。
173
135
  * 这些都在**启动期**拒(安全控件不得半开),不是让运维从一台"启动成功、什么也没删"的机器上猜。
174
136
  *
@@ -144,7 +144,7 @@ export function createSharedRunnerDeps(ctx) {
144
144
  }
145
145
  export function createRunnerDeps(ctx) {
146
146
  const { config, logger, metrics, localRoot, outcomeSink, elicitation, question, toolApproval, sessionStore, memoryEngine, sessionCaptureRecords, memorySyncRunner, runtimeCapsResolver, fileHistoryStore, permissionRuleStore, fleetBus, workflowRunStore, workflowJournalStore, workflowAgentRegistry, workflowNotifyGate, deliverWorkflowCompletion, } = ctx;
147
- const peerSessionLister = sessionStore.listSessions?.bind(sessionStore);
147
+ const peerSessionLister = sessionStore.listSessionRows?.bind(sessionStore);
148
148
  const memoryEngineIncident = createMemoryEngineIncidentSink({ logger, metrics });
149
149
  const sharedRunnerDeps = createSharedRunnerDeps(ctx);
150
150
  const workflowModelAllowlist = workflowModelAllowlistFor(config);
@@ -66,6 +66,7 @@ export interface SessionFacesCtx {
66
66
  export declare function createSessionFaces(ctx: SessionFacesCtx): {
67
67
  ownerAware: OwnerAwareSessionStore;
68
68
  sessionAudit: ((sessionId: string, opts?: SessionAuditReadOpts) => Promise<{
69
+ projectId?: string | undefined;
69
70
  agent?: import("../session-agent.js").SessionAgent | undefined;
70
71
  owner: string | null;
71
72
  sessionId: string;
@@ -1,5 +1,6 @@
1
1
  import { buildRewindHandles, buildSessionAudit, buildSessionAuditLocal, buildSessionAuditPg } from "../audit.js";
2
2
  import { readSessionAgent } from "../session-agent.js";
3
+ import { readSessionProjectId, sessionWorkspaceStoreOf } from "../session-workspace.js";
3
4
  import { makeDegenerateInstrument } from "../degenerate-instrument.js";
4
5
  import { PlanCacheProbe } from "../plan-cache-probe.js";
5
6
  import { purgeScratchpadDir } from "../env-facts.js";
@@ -12,6 +13,7 @@ import { probeSessionChildren, retireSessionChildren, sessionChildrenScope, Sess
12
13
  import { SessionActiveRunError } from "../execution-placement.js";
13
14
  import { headReadOf, redactIncarnations } from "../session-incarnation.js";
14
15
  import { recordFailOpen } from "../observability/fail-open.js";
16
+ import { retireSessionId } from "../deleted-session-ids.js";
15
17
  import { seatText } from "../trace/exit-seat.js";
16
18
  export function createSessionFaces(ctx) {
17
19
  const { config, logger, metrics, localRoot, backend, sessionStore, runStore, checkpointStore, toolResultStore, resumeAnchorStore, approvalExemptionStore, sessionPolicyStore, taskAttachmentStore, fileHistoryErasure, workflowCompletionInbox, taskListLane, dropSessionScoped, mailboxStore, mailboxRecipientLifecycle, backgroundAgentStore, userInputLedgerStore, spaceReclaimer, } = ctx;
@@ -20,6 +22,7 @@ export function createSessionFaces(ctx) {
20
22
  const auditLocalRows = localSessionRowsOf(backend);
21
23
  const ownerAware = sessionStore;
22
24
  const headOf = headReadOf(sessionStore);
25
+ const workspaceStore = sessionWorkspaceStoreOf(sessionStore);
23
26
  const sessionAudit = mysqlPool || auditPgPool || auditLocalRows
24
27
  ? async (sessionId, opts) => {
25
28
  const handles = opts !== undefined && resumeAnchorStore !== undefined ? buildRewindHandles(await resumeAnchorStore.listBySession(sessionId), opts.reader) : undefined;
@@ -30,9 +33,13 @@ export function createSessionFaces(ctx) {
30
33
  : await buildSessionAuditLocal(auditLocalRows, sessionId, handles);
31
34
  if (!audit)
32
35
  return undefined;
33
- const [head, agent] = await Promise.all([headOf?.(sessionId), opts !== undefined ? readSessionAgent(ownerAware, sessionId) : undefined]);
36
+ const [head, agent, projectId] = await Promise.all([
37
+ headOf?.(sessionId),
38
+ opts !== undefined ? readSessionAgent(ownerAware, sessionId) : undefined,
39
+ opts !== undefined ? readSessionProjectId(workspaceStore, sessionId) : undefined,
40
+ ]);
34
41
  const owner = head?.owner;
35
- return { ...audit, owner: owner ?? null, ...(agent !== undefined ? { agent } : {}) };
42
+ return { ...audit, owner: owner ?? null, ...(agent !== undefined ? { agent } : {}), ...(projectId !== undefined ? { projectId } : {}) };
36
43
  }
37
44
  : undefined;
38
45
  const sessionWatchRegistry = headOf
@@ -102,7 +109,7 @@ export function createSessionFaces(ctx) {
102
109
  await fileHistoryErasure.reap(sessionId, []);
103
110
  logger.warn("session_file_history_baselines_retained", {
104
111
  sessionId,
105
- note: "the local file-history store has no whole-scope purge verb; boundaries were reaped but v1 baselines (original file bytes) remain under the data root until the upstream purge seam lands — recorded as an open deletion-rights gap, not silent",
112
+ note: "this file-history store has no whole-scope erase verb (deleteBySession); boundaries were reaped but v1 baselines (original file bytes) remain in the store until it implements that verb — an open deletion-rights gap, not silent",
106
113
  });
107
114
  }
108
115
  }
@@ -123,6 +130,7 @@ export function createSessionFaces(ctx) {
123
130
  }
124
131
  if (peerBox !== undefined)
125
132
  await peerBox.store.drop(peerBox.scope, peerBox.handle);
133
+ retireSessionId(sessionId, owner, config);
126
134
  let historyDeleted;
127
135
  try {
128
136
  historyDeleted = await ownerAware.deleteSession(sessionId, owner);
@@ -5,8 +5,8 @@ import { createParentWatch } from "../parent-watch.js";
5
5
  import { setTimeout as delay } from "node:timers/promises";
6
6
  import { HOST_BG_KILL_GRACE_MS } from "../plugins/remote-env-host.js";
7
7
  import { installProcessExitBoundary } from "./exit-boundary.js";
8
- import { createEngineLeaseTracker } from "./engine-lease.js";
9
- import { writeExitLast, readExitLast, clearExitLast } from "./exit-last.js";
8
+ import { backgroundShellsUnreachable, createEngineLeaseTracker, laneWork } from "./engine-lease.js";
9
+ import { writeExitLast, readExitLast, clearExitLast, EXIT_LAST_FORMAT } from "./exit-last.js";
10
10
  import { isScriptRealmRejection, describeRejectionReason } from "../orchestration/hardened-vm-runner.js";
11
11
  import { DRAIN_CAUSE_COUNTS_AS_FIRST_STOP_SIGNAL, HARD_STOP_ACTION_ID, drainDeadlineBeyondBound } from "../fleet/drain-entry.js";
12
12
  import { seatText } from "../trace/exit-seat.js";
@@ -24,10 +24,20 @@ export function installShutdownHandlers(ctx) {
24
24
  const prior = readCrashLast(dataRoot);
25
25
  if (prior)
26
26
  logger.warn("crash_last_found", { at: prior.at, version: prior.version, pid: prior.pid, uptimeMs: prior.uptimeMs, ...(prior.inflight !== undefined ? { inflight: prior.inflight } : {}), err: prior.err });
27
- const lastExit = readExitLast(dataRoot);
27
+ const lastExitReading = readExitLast(dataRoot);
28
+ if (lastExitReading?.kind === "formatMismatch") {
29
+ logger.warn("exit_last_stale_format", {
30
+ fileFormat: lastExitReading.fileFormat,
31
+ buildFormat: EXIT_LAST_FORMAT,
32
+ note: "exit-last.json on this data root was written in a different format by another engine version — it is not projected " +
33
+ "(no exit_last_found for it) and is removed now; only the previous exit's self-exit record is lost, nothing else is affected.",
34
+ });
35
+ clearExitLast(dataRoot);
36
+ }
37
+ const lastExit = lastExitReading?.kind === "found" ? lastExitReading.info : undefined;
28
38
  if (lastExit) {
29
39
  logger.info("exit_last_found", {
30
- at: lastExit.at, version: lastExit.version, pid: lastExit.pid, orphan: lastExit.orphan, reason: lastExit.reason,
40
+ at: lastExit.at, version: lastExit.version, pid: lastExit.pid, lane: lastExit.lane, reason: lastExit.reason,
31
41
  idleForMs: lastExit.idleForMs, attached: lastExit.attached, inflight: lastExit.inflight, lingerMs: lastExit.lingerMs,
32
42
  ...(lastExit.orphanedForMs !== undefined ? { orphanedForMs: lastExit.orphanedForMs } : {}),
33
43
  crashedDuringExit: prior !== undefined && prior.pid === lastExit.pid,
@@ -76,6 +86,7 @@ export function installShutdownHandlers(ctx) {
76
86
  let parentWatch;
77
87
  let engineLease;
78
88
  let leaseFactsReader;
89
+ let handoverDoor;
79
90
  const hardShutdown = () => {
80
91
  if (closing)
81
92
  return;
@@ -191,14 +202,14 @@ export function installShutdownHandlers(ctx) {
191
202
  drainState.endSubscriptions?.();
192
203
  toolApproval?.beginDrain();
193
204
  void fleetClient?.announceNow();
194
- const inflight = drainState.inflight?.() ?? 0;
205
+ const inflight = drainState.blockingInflight?.() ?? 0;
195
206
  logger.info("draining_started", { actionId: entry.actionId, inflight, deadlineAt: entry.deadlineAt, windowMs });
196
207
  if (inflight === 0) {
197
208
  hardShutdown();
198
209
  return { ...current, state: "draining" };
199
210
  }
200
211
  const tick = setInterval(() => {
201
- const n = drainState.inflight?.() ?? 0;
212
+ const n = drainState.blockingInflight?.() ?? 0;
202
213
  const now = performance.now();
203
214
  if (n === 0 || now >= deadlineMono) {
204
215
  clearInterval(tick);
@@ -254,9 +265,9 @@ export function installShutdownHandlers(ctx) {
254
265
  const onSigint = () => onStopSignal("SIGINT");
255
266
  process.on("SIGTERM", onSigterm);
256
267
  process.on("SIGINT", onSigint);
268
+ const handoverLane = !config.requirePrincipal ? { lingerMs: config.engineHandoverLingerMs, backgroundShells: exitBoundary.shellsExitWouldKill } : undefined;
257
269
  const onSighup = createSighupIdleHandler({
258
- inflight: () => drainState.inflight?.() ?? 0,
259
- attached: () => drainState.attachedStreams?.() ?? 0,
270
+ work: () => laneWork(engineLease?.lane(), { attached: drainState.attachedStreams?.() ?? 0, inflight: drainState.blockingInflight?.() ?? 0, backgroundShells: handoverLane?.backgroundShells ?? backgroundShellsUnreachable }, "sighup"),
260
271
  lastActivityAt: () => drainState.lastActivityAt?.() ?? 0,
261
272
  isStopped: () => closing || draining,
262
273
  escalate: () => drainOnCause("signal:SIGHUP"),
@@ -283,7 +294,7 @@ export function installShutdownHandlers(ctx) {
283
294
  if (config.parentPid !== undefined || config.engineAutoExit) {
284
295
  engineLease = createEngineLeaseTracker({
285
296
  attachedStreams: () => drainState.attachedStreams?.() ?? 0,
286
- inflight: () => drainState.inflight?.() ?? 0,
297
+ inflight: () => drainState.blockingInflight?.() ?? 0,
287
298
  lastActivityAt: () => drainState.lastActivityAt?.() ?? 0,
288
299
  lastAttachEndedAt: () => drainState.lastAttachEndedAt?.() ?? 0,
289
300
  isStopped: () => closing || draining,
@@ -296,10 +307,15 @@ export function installShutdownHandlers(ctx) {
296
307
  ...(config.parentPid !== undefined
297
308
  ? { orphan: { lingerMs: config.engineOrphanLingerMs, read: () => orphanState } }
298
309
  : {}),
310
+ firstAttach: { windowMs: config.engineFirstAttachMs, firstTouchAt: () => drainState.firstActivityAt?.() ?? null },
311
+ ...(handoverLane !== undefined ? { handover: handoverLane } : {}),
299
312
  log: (event, fields) => logger.info(event, fields),
300
313
  });
301
314
  leaseFactsReader = () => engineLease?.facts;
302
315
  drainState.engineLease = leaseFactsReader;
316
+ handoverDoor = engineLease.handover;
317
+ if (handoverDoor !== undefined)
318
+ drainState.engineHandover = handoverDoor;
303
319
  }
304
320
  let disposed = false;
305
321
  return {
@@ -324,6 +340,8 @@ export function installShutdownHandlers(ctx) {
324
340
  drainState.enter = undefined;
325
341
  if (leaseFactsReader !== undefined && drainState.engineLease === leaseFactsReader)
326
342
  drainState.engineLease = undefined;
343
+ if (handoverDoor !== undefined && drainState.engineHandover === handoverDoor)
344
+ drainState.engineHandover = undefined;
327
345
  },
328
346
  };
329
347
  }
@@ -1,5 +1,5 @@
1
1
  export declare function runStage01(): {
2
- config: import("../config-types.js").ServiceConfig;
2
+ config: import("../config-types.js").LoadedConfig;
3
3
  localRoot: string;
4
4
  logger: import("../observability/logger.js").Logger;
5
5
  metrics: import("../observability/metrics.js").Metrics;
@@ -1,7 +1,7 @@
1
1
  import { homedir } from "node:os";
2
2
  import { loadConfig, logConfigDiagnostics, splitLocalRoots } from "../config.js";
3
3
  import { configLocalRoot } from "../config-provider.js";
4
- import { crossInvariant } from "../config-invariants.js";
4
+ import { operatorDeclarationRefusal, runStaleHeartbeatRefusal } from "../config-invariants.js";
5
5
  import { drainNumEnvWarnings } from "../plugins/remote-shell.js";
6
6
  import { setWebSearchBadPayloadObserver } from "../plugins/web-search.js";
7
7
  import { createLogger } from "../observability/logger.js";
@@ -20,10 +20,14 @@ export function runStage01() {
20
20
  declareServerWithheldEnv();
21
21
  const config = loadConfig();
22
22
  bindOwnCredentialsConfig(config);
23
- const runStaleFailure = crossInvariant("run-stale-heartbeat").check({ live: config, next: config });
23
+ const runStaleFailure = runStaleHeartbeatRefusal(config);
24
24
  if (runStaleFailure !== undefined) {
25
25
  throw new Error(runStaleFailure);
26
26
  }
27
+ const operatorDeclarationFailure = operatorDeclarationRefusal(config);
28
+ if (operatorDeclarationFailure !== undefined) {
29
+ throw new Error(operatorDeclarationFailure);
30
+ }
27
31
  const logger = createLogger(config.logLevel);
28
32
  const metrics = createMetrics();
29
33
  installFailOpenRecorder({ logger, metrics, redactDetail: redactSecrets });
@@ -61,7 +65,7 @@ export function runStage01() {
61
65
  if (rootsSplit) {
62
66
  logger.warn("local_roots_split", {
63
67
  ...rootsSplit,
64
- note: "LOCAL_DATA_ROOT moved the local backend's DATA root, but config.d / remote-exec.json are still read from the config root (LOCAL_DATA_ROOT is not consulted there). If you meant to move both, set CONFIG_LOCAL_DIR to the same directory.",
68
+ note: "The local backend's DATA root and the config root differ, and CONFIG_LOCAL_DIR is not set: config.d / remote-exec.json are read from the derived config root (AGENT_DATA_DIR or ~/.ai-agent; LOCAL_DATA_ROOT is not consulted there), while data lives under the data root (LOCAL_DATA_ROOT, else CONFIG_LOCAL_DIR, AGENT_DATA_DIR, ~/.ai-agent). If you meant to move both, set CONFIG_LOCAL_DIR to the same directory; if the split is intended, set CONFIG_LOCAL_DIR to the config directory explicitly — any explicit CONFIG_LOCAL_DIR silences this line.",
65
69
  });
66
70
  }
67
71
  installOutboundDispatcher(logger);
@@ -1,8 +1,8 @@
1
1
  import type { runStage01 } from "./stage-01-config.js";
2
2
  export declare function runStage02(ctx: Awaited<ReturnType<typeof runStage01>>): Promise<{
3
+ config: import("../config-types.js").ServiceConfig;
3
4
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
4
5
  webAdmin: import("./web-admin.js").WebAdminRuntime;
5
- config: import("../config-types.js").ServiceConfig;
6
6
  localRoot: string;
7
7
  logger: import("../index.js").Logger;
8
8
  metrics: import("../index.js").Metrics;
@@ -1,7 +1,8 @@
1
1
  import { createUnpricedCeilingVerdict } from "./unpriced-ceiling-verdict.js";
2
2
  import { createWebAdminRuntime } from "./web-admin.js";
3
- import { composeExecutionLane, FILE_SOURCED_LANES } from "./execution-lane.js";
3
+ import { composeExecutionLane, HTTP_SERVICE_LANE_ENTRY } from "./execution-lane.js";
4
4
  import { configSourceKind } from "../config-provider.js";
5
+ import { buildCandidateRejectionNotes } from "../web-admin-client/candidate-gate.js";
5
6
  import { logConfigDirMigration, migrateLocalConfigDirectory } from "../config-d-migration.js";
6
7
  import { logEnvModelsMigration, runEnvModelsMigration } from "../config-root-migration.js";
7
8
  import { assertLocalConfigDirTrusted } from "../config-dir-trust.js";
@@ -10,18 +11,19 @@ import { isRosterGateArmed } from "../config.js";
10
11
  import { judgeServedModelRoute } from "../model-route-endpoint.js";
11
12
  import { servedModelTableLeg } from "../model-select.js";
12
13
  export async function runStage02(ctx) {
13
- const { config, localRoot, logger, metrics } = ctx;
14
- const configSource = configSourceKind(config);
14
+ const { config: loaded, localRoot, logger, metrics } = ctx;
15
+ const configSource = configSourceKind(loaded);
15
16
  if (configSource === "local") {
16
- await assertLocalConfigDirTrusted({ root: localRoot, declaredOwnerUid: config.configLocalOwnerUid });
17
- const envModelsMigration = { root: localRoot, env: process.env, envTableIsPlaceholder: isRosterGateArmed(config.webAdmin) };
17
+ await assertLocalConfigDirTrusted({ root: localRoot, declaredOwnerUid: loaded.configLocalOwnerUid });
18
+ const envModelsMigration = { root: localRoot, env: process.env, envTableIsPlaceholder: isRosterGateArmed(loaded.webAdmin) };
18
19
  logEnvModelsMigration(logger, envModelsMigration, await runEnvModelsMigration(envModelsMigration));
19
20
  logConfigDirMigration(logger, await migrateLocalConfigDirectory(localRoot));
20
21
  }
21
- await composeExecutionLane(config, { configSource, localRoot, logger, drivesFromFile: FILE_SOURCED_LANES });
22
+ const config = await composeExecutionLane(loaded, { configSource, localRoot, logger, entry: HTTP_SERVICE_LANE_ENTRY });
22
23
  const webAdmin = await createWebAdminRuntime({ config, logger, metrics, localRoot });
23
24
  const servedLeg = servedModelTableLeg(config);
24
- const noDefaultModel = defaultModelRefusal(config, servedLeg);
25
+ const rejection = webAdmin.candidateRejectionState();
26
+ const noDefaultModel = defaultModelRefusal({ models: config.models, modelRefusals: config.modelRefusals, candidateRejectionNotes: rejection === undefined ? undefined : buildCandidateRejectionNotes(rejection) }, servedLeg);
25
27
  if (noDefaultModel !== undefined) {
26
28
  throw new Error(noDefaultModel);
27
29
  }
@@ -35,6 +37,6 @@ export async function runStage02(ctx) {
35
37
  }
36
38
  const ceilingVerdict = createUnpricedCeilingVerdict({ config, logger });
37
39
  ceilingVerdict.judge();
38
- return { ...ctx, ceilingVerdict, webAdmin };
40
+ return { ...ctx, config, ceilingVerdict, webAdmin };
39
41
  }
40
42
  //# sourceMappingURL=stage-02-web-admin-pull.js.map
@@ -20,12 +20,13 @@ export declare function runStage03(ctx: Awaited<ReturnType<typeof runStage02>>):
20
20
  sessionStore: import("@sema-agent/core").SessionStore<import("@sema-agent/core").SessionStoreSummary, import("@sema-agent/core").SessionListQuery>;
21
21
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
22
22
  storePosture: import("../store-posture.js").StorePosture;
23
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
23
24
  taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
24
25
  taskListLane: import("./task-list-lane.js").TaskListLane;
25
26
  usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
27
+ config: import("../config-types.js").ServiceConfig;
26
28
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
27
29
  webAdmin: import("./web-admin.js").WebAdminRuntime;
28
- config: import("../config-types.js").ServiceConfig;
29
30
  localRoot: string;
30
31
  logger: import("../index.js").Logger;
31
32
  metrics: import("../index.js").Metrics;
@@ -2,8 +2,8 @@ import { uuidv7 } from "@sema-agent/core";
2
2
  import { openStores } from "./stores.js";
3
3
  export async function runStage03(ctx) {
4
4
  const { config, localRoot, logger, metrics } = ctx;
5
- const { backend, storePosture, memoryEngine, engineDataRoot, memorySyncCursors, rosterStore, backgroundAgentStore, sessionCaptureRecords, taskAttachmentStore, mailboxStore, mailboxRecipientLifecycle, memoryExportStores, memorySyncRunner, sessionStore, breakerState, usageWindowStore, memoryPosture, taskListLane, sqlEngine, } = await openStores({ config, logger, metrics, localRoot });
5
+ const { backend, storePosture, memoryEngine, engineDataRoot, memorySyncCursors, rosterStore, backgroundAgentStore, sessionCaptureRecords, taskAttachmentStore, mailboxStore, mailboxRecipientLifecycle, memoryExportStores, memorySyncRunner, sessionStore, breakerState, usageWindowStore, memoryPosture, taskListLane, sqlEngine, storeSweep, } = await openStores({ config, logger, metrics, localRoot });
6
6
  const instanceId = uuidv7();
7
- return { ...ctx, backend, backgroundAgentStore, breakerState, engineDataRoot, instanceId, mailboxRecipientLifecycle, mailboxStore, memoryEngine, memoryExportStores, memoryPosture, memorySyncCursors, memorySyncRunner, rosterStore, sessionCaptureRecords, sessionStore, sqlEngine, storePosture, taskAttachmentStore, taskListLane, usageWindowStore };
7
+ return { ...ctx, backend, backgroundAgentStore, breakerState, engineDataRoot, instanceId, mailboxRecipientLifecycle, mailboxStore, memoryEngine, memoryExportStores, memoryPosture, memorySyncCursors, memorySyncRunner, rosterStore, sessionCaptureRecords, sessionStore, sqlEngine, storePosture, storeSweep, taskAttachmentStore, taskListLane, usageWindowStore };
8
8
  }
9
9
  //# sourceMappingURL=stage-03-store-backend.js.map
@@ -50,12 +50,13 @@ export declare function runStage04(ctx: Awaited<ReturnType<typeof runStage03>>):
50
50
  sessionStore: import("@sema-agent/core").SessionStore<import("@sema-agent/core").SessionStoreSummary, import("@sema-agent/core").SessionListQuery>;
51
51
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
52
52
  storePosture: import("../store-posture.js").StorePosture;
53
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
53
54
  taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
54
55
  taskListLane: import("./task-list-lane.js").TaskListLane;
55
56
  usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
57
+ config: import("../config-types.js").ServiceConfig;
56
58
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
57
59
  webAdmin: import("./web-admin.js").WebAdminRuntime;
58
- config: import("../config-types.js").ServiceConfig;
59
60
  localRoot: string;
60
61
  logger: import("../index.js").Logger;
61
62
  metrics: import("../index.js").Metrics;
@@ -2,11 +2,13 @@ import type { runStage04 } from "./stage-04-stores.js";
2
2
  export declare function runStage05(ctx: Awaited<ReturnType<typeof runStage04>>): Promise<{
3
3
  deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
4
4
  deploymentModsLoaded: readonly import("./deployment-mods.js").LoadedModPackage[];
5
+ belowTaskChainPatterns: readonly string[];
5
6
  deviceLane: import("./device-lane.js").DeviceLane | undefined;
6
7
  peerDesk: import("../peer-seat.js").PeerDesk;
7
8
  dropSessionScoped: (sid: string) => void;
8
9
  executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
9
10
  fenceSessionOwner: (sid: string, owner: string | null) => void;
11
+ sessionResidentBackground: () => import("../session-resident-background.js").SessionResidentCounts;
10
12
  lspManager: import("@sema-agent/core").NodeLspManager | import("../lsp/manager.js").E2bLspManager | undefined;
11
13
  spaceReclaimer: import("../workspace-space.js").SpaceReclaimer | undefined;
12
14
  sandboxPodReaper: import("../plugins/k8s-pod-reaper.js").SandboxPodReaper | undefined;
@@ -69,12 +71,13 @@ export declare function runStage05(ctx: Awaited<ReturnType<typeof runStage04>>):
69
71
  sessionStore: import("@sema-agent/core").SessionStore<import("@sema-agent/core").SessionStoreSummary, import("@sema-agent/core").SessionListQuery>;
70
72
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
71
73
  storePosture: import("../store-posture.js").StorePosture;
74
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
72
75
  taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
73
76
  taskListLane: import("./task-list-lane.js").TaskListLane;
74
77
  usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
78
+ config: import("../config-types.js").ServiceConfig;
75
79
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
76
80
  webAdmin: import("./web-admin.js").WebAdminRuntime;
77
- config: import("../config-types.js").ServiceConfig;
78
81
  localRoot: string;
79
82
  logger: import("../index.js").Logger;
80
83
  metrics: import("../index.js").Metrics;
@@ -10,12 +10,12 @@ import { SANDBOX_GIT_PLANE_OFF_TEXT } from "../sandbox-git-plane.js";
10
10
  import { createPeerDesk } from "../peer-seat.js";
11
11
  export async function runStage05(ctx) {
12
12
  const { backend, config, instanceId, logger, metrics, sessionStore, taskAttachmentStore } = ctx;
13
- const deviceLane = config.remoteExec?.provider === "device" ? createDeviceLane({ config, logger, metrics, backend, seat: sessionStore.executionPlacement, replicaId: instanceId }) : undefined;
13
+ const deviceLane = config.remoteExec.provider === "device" ? createDeviceLane({ config, logger, metrics, backend, seat: sessionStore.executionPlacement, replicaId: instanceId }) : undefined;
14
14
  const headOf = headReadOf(sessionStore);
15
15
  const spaceCommits = backend !== undefined ? () => runStore : undefined;
16
- const { perTaskImage, sessionEnvSelection, perSessionCwd, setSessionCwd, setSessionShellEnv, setSessionInheritEnv, fenceSessionOwner, dropSessionScoped, executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxSecretSeatGate, sandboxPodReaper, sandboxGitPlane: sandboxGitPlaneSeat, } = createExecutionEnv({ config, logger, metrics, taskAttachmentStore, ...(deviceLane ? { deviceLane } : {}), ...(spaceCommits !== undefined ? { spaceCommits } : {}), ...(headOf !== undefined ? { headOf } : {}), ...(backend !== undefined ? { runRows: () => runStore } : {}) });
17
- assertDeviceLaneWired(config.remoteExec?.provider === "device", deviceLane, executionEnvFactory !== undefined);
18
- if (deviceLane !== undefined && config.remoteExec?.provider === "device")
16
+ const { perTaskImage, sessionEnvSelection, perSessionCwd, setSessionCwd, setSessionShellEnv, setSessionInheritEnv, fenceSessionOwner, dropSessionScoped, sessionResidentBackground, executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxSecretSeatGate, sandboxPodReaper, sandboxGitPlane: sandboxGitPlaneSeat, } = createExecutionEnv({ config, logger, metrics, taskAttachmentStore, ...(deviceLane ? { deviceLane } : {}), ...(spaceCommits !== undefined ? { spaceCommits } : {}), ...(headOf !== undefined ? { headOf } : {}), ...(backend !== undefined ? { runRows: () => runStore } : {}) });
17
+ assertDeviceLaneWired(config.remoteExec.provider === "device", deviceLane, executionEnvFactory !== undefined);
18
+ if (deviceLane !== undefined && config.remoteExec.provider === "device")
19
19
  await noteDeviceRelayBindings(config.remoteExec.relay, deviceLane.store, logger);
20
20
  assertWorkspaceSpaceReadable(facts.workspaceSpace(config), { headOf, spaceCommits }, facts.workspaceCache(config), sessionStoreLabelOf(config.sessionBackend, backend?.kind));
21
21
  if (sandboxSecretSeatGate !== undefined)
@@ -30,10 +30,10 @@ export async function runStage05(ctx) {
30
30
  }
31
31
  if (config.toolTrace)
32
32
  logger.info("tool_trace_enabled", {});
33
- const { registrations: deploymentMods, loaded: deploymentModsLoaded } = await assembleDeploymentMods({ metrics, ...(config.toolTrace ? { traceLogger: logger } : {}), brandIdentity: isBrandedDeployment(config), declaration: config.modsDeclaration, logger });
33
+ const { registrations: deploymentMods, loaded: deploymentModsLoaded, belowTaskChainPatterns } = await assembleDeploymentMods({ metrics, ...(config.toolTrace ? { traceLogger: logger } : {}), brandIdentity: isBrandedDeployment(config), declaration: config.modsDeclaration, logger });
34
34
  const peerDesk = createPeerDesk({ log: logger });
35
35
  metrics.dynamicGauge("peer_registry_entries", "Peer desk entries (declared peer credentials registered for in-flight legs and the roster)", () => peerDesk.size().entries);
36
36
  metrics.dynamicGauge("peer_registry_holders", "Peer desk holders of entries (host leases and engine holds), summed across entries", () => peerDesk.size().holders);
37
- return { ...ctx, deploymentMods, deploymentModsLoaded, deviceLane, peerDesk, dropSessionScoped, executionEnvFactory, fenceSessionOwner, lspManager, spaceReclaimer, sandboxPodReaper, sandboxGitPlane, perSessionCwd, perTaskImage, sendUserFileTaskEnvs, sessionEnvSelection, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, worktreeReap };
37
+ return { ...ctx, deploymentMods, deploymentModsLoaded, belowTaskChainPatterns, deviceLane, peerDesk, dropSessionScoped, executionEnvFactory, fenceSessionOwner, sessionResidentBackground, lspManager, spaceReclaimer, sandboxPodReaper, sandboxGitPlane, perSessionCwd, perTaskImage, sendUserFileTaskEnvs, sessionEnvSelection, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, worktreeReap };
38
38
  }
39
39
  //# sourceMappingURL=stage-05-execution-env.js.map
@@ -30,7 +30,7 @@ export declare function runStage06(ctx: Awaited<ReturnType<typeof runStage05>>):
30
30
  outcomeSink: import("../plugins/file-outcome-sink.js").OutcomeSink | undefined;
31
31
  principalCaps: import("../runtime-caps-resolver.js").PrincipalEntitlementsClient | undefined;
32
32
  question: import("../question.js").QuestionCoordinator | undefined;
33
- retentionExecutor: import("../plugins/retention-store-sql.js").SqlRetentionStore | undefined;
33
+ retentionExecutor: import("../plugins/retention-deployment.js").RetentionExecutor | undefined;
34
34
  retentionLaneStore: import("../plugins/retention-lane-store-sql.js").RetentionLaneStore | undefined;
35
35
  runner: Runner;
36
36
  runnerDeps: import("@sema-agent/core").RunnerDeps;
@@ -63,11 +63,13 @@ export declare function runStage06(ctx: Awaited<ReturnType<typeof runStage05>>):
63
63
  orgDeliveryGate: import("@sema-agent/core").OrgDeliveryGate | undefined;
64
64
  deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
65
65
  deploymentModsLoaded: readonly import("./deployment-mods.js").LoadedModPackage[];
66
+ belowTaskChainPatterns: readonly string[];
66
67
  deviceLane: import("./device-lane.js").DeviceLane | undefined;
67
68
  peerDesk: import("../peer-seat.js").PeerDesk;
68
69
  dropSessionScoped: (sid: string) => void;
69
70
  executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
70
71
  fenceSessionOwner: (sid: string, owner: string | null) => void;
72
+ sessionResidentBackground: () => import("../session-resident-background.js").SessionResidentCounts;
71
73
  lspManager: import("@sema-agent/core").NodeLspManager | import("../lsp/manager.js").E2bLspManager | undefined;
72
74
  spaceReclaimer: import("../workspace-space.js").SpaceReclaimer | undefined;
73
75
  sandboxPodReaper: import("../plugins/k8s-pod-reaper.js").SandboxPodReaper | undefined;
@@ -130,12 +132,13 @@ export declare function runStage06(ctx: Awaited<ReturnType<typeof runStage05>>):
130
132
  sessionStore: import("@sema-agent/core").SessionStore<import("@sema-agent/core").SessionStoreSummary, import("@sema-agent/core").SessionListQuery>;
131
133
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
132
134
  storePosture: import("../store-posture.js").StorePosture;
135
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
133
136
  taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
134
137
  taskListLane: import("./task-list-lane.js").TaskListLane;
135
138
  usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
139
+ config: import("../config-types.js").ServiceConfig;
136
140
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
137
141
  webAdmin: import("./web-admin.js").WebAdminRuntime;
138
- config: import("../config-types.js").ServiceConfig;
139
142
  localRoot: string;
140
143
  logger: import("../index.js").Logger;
141
144
  metrics: import("../index.js").Metrics;
@@ -6,7 +6,6 @@ import { ForkRoutingSessionStore } from "../plugins/fork-routing-session-store.j
6
6
  import { withoutHands } from "../capabilities/hands-lane.js";
7
7
  import { isBrandedDeployment } from "../capabilities/brand-identity.js";
8
8
  import { hasServiceAuth } from "../http/server.js";
9
- import { operatorRosterPresent } from "../http/principal-gate.js";
10
9
  import { workflowModelAllowlistFor } from "../task-workflow.js";
11
10
  import { createHookLlm, buildHookFailureText } from "../hooks/hook-llm.js";
12
11
  import { assertRetentionLaneWirable } from "./retention-lane.js";
@@ -28,7 +27,7 @@ import { createSharedMemoryScopeAuthorizer } from "../shared-memory-scope-author
28
27
  import { mountOrgDeliveryGate } from "./org-delivery.js";
29
28
  import { parkedAskRedeem, runStore } from "./late-binds.js";
30
29
  import { withInternalRunEnvs } from "../internal-run-env.js";
31
- import { retentionSweepRuns } from "../plugins/retention-store-sql.js";
30
+ import { retentionSweepRuns } from "../plugins/retention-declaration.js";
32
31
  import { createOperatorFaceIncidentSink } from "../memory-incident-sink.js";
33
32
  export async function runStage06(ctx) {
34
33
  const { backend, backgroundAgentStore, brain, engineDataRoot, peerDesk, config, webAdmin, consolidationValve, deploymentMods, executionEnvFactory, fileHistoryStore, localRoot, logger, lspManager, mailboxRecipientLifecycle, mailboxStore, memoryEngine, memorySyncRunner, metrics, perSessionCwd, permissionRuleProvider, pricing, rosterStore, ruleConsent, sendUserFileTaskEnvs, sessionCaptureRecords, sessionPolicyStore, sessionStore, taskAttachmentStore, taskListLane, toolResultStore, tracer, usageWindowStore } = ctx;
@@ -79,6 +78,16 @@ export async function runStage06(ctx) {
79
78
  ],
80
79
  locked: (config.lockedConfigKeys ?? []).includes("retentionPolicy"),
81
80
  });
81
+ const governanceSeams = createGovernanceSeams({
82
+ config,
83
+ logger,
84
+ retentionStores: [
85
+ { name: "sessionStore", store: sessionStore },
86
+ { name: "checkpointStore", store: checkpointStore },
87
+ { name: "toolResultStore", store: runnerOffloadStore },
88
+ ],
89
+ retentionExecutor: retentionSweepRuns(config.retentionSweep) ? (retentionExecutor ?? null) : null,
90
+ });
82
91
  const consolidationSeat = consolidationValve.enabled && memoryEngine
83
92
  ? resolveConsolidationDriverSeat({
84
93
  brain,
@@ -97,11 +106,11 @@ export async function runStage06(ctx) {
97
106
  onStopDetail: (audit) => logger.warn("memory_consolidation_stop_detail", audit),
98
107
  writeJudge: createOperatorValveWriteJudge({ ruleStoreProvider: permissionRuleProvider, config }),
99
108
  onNotice: createEngineNoticeForwarder(logger, defaultEngineNoticeRouter, metrics),
109
+ postureOf: governanceSeams.compliancePostureResolver,
100
110
  })
101
111
  : undefined;
102
112
  for (const w of buildConsolidationValveAudit({
103
113
  valve: consolidationValve,
104
- operatorRosterPresent: operatorRosterPresent(config),
105
114
  hasServiceAuth: hasServiceAuth(config),
106
115
  allowUnauthedWrites: config.allowUnauthedWrites ?? false,
107
116
  }).warnings) {
@@ -117,16 +126,6 @@ export async function runStage06(ctx) {
117
126
  autoRunOnRecommendation: config.memoryConsolidationDriver.autoRunOnRecommendation ?? "engine-default(on)",
118
127
  });
119
128
  }
120
- const governanceSeams = createGovernanceSeams({
121
- config,
122
- logger,
123
- retentionStores: [
124
- { name: "sessionStore", store: sessionStore },
125
- { name: "checkpointStore", store: checkpointStore },
126
- { name: "toolResultStore", store: runnerOffloadStore },
127
- ],
128
- retentionExecutor: retentionSweepRuns(config.retentionSweep) ? (retentionExecutor ?? null) : null,
129
- });
130
129
  const mcpRevocations = webAdmin.takeMcpRevocations();
131
130
  const workflowModelAllowlistSnapshot = workflowModelAllowlistFor(config) ?? [];
132
131
  const runnerDeps = createRunnerDeps({
@@ -47,7 +47,7 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
47
47
  outcomeSink: import("../plugins/file-outcome-sink.js").OutcomeSink | undefined;
48
48
  principalCaps: import("../runtime-caps-resolver.js").PrincipalEntitlementsClient | undefined;
49
49
  question: import("../question.js").QuestionCoordinator | undefined;
50
- retentionExecutor: import("../plugins/retention-store-sql.js").SqlRetentionStore | undefined;
50
+ retentionExecutor: import("../plugins/retention-deployment.js").RetentionExecutor | undefined;
51
51
  retentionLaneStore: import("../plugins/retention-lane-store-sql.js").RetentionLaneStore | undefined;
52
52
  runner: import("@sema-agent/core").Runner;
53
53
  runnerDeps: import("@sema-agent/core").RunnerDeps;
@@ -80,11 +80,13 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
80
80
  orgDeliveryGate: import("@sema-agent/core").OrgDeliveryGate | undefined;
81
81
  deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
82
82
  deploymentModsLoaded: readonly import("./deployment-mods.js").LoadedModPackage[];
83
+ belowTaskChainPatterns: readonly string[];
83
84
  deviceLane: import("./device-lane.js").DeviceLane | undefined;
84
85
  peerDesk: import("../peer-seat.js").PeerDesk;
85
86
  dropSessionScoped: (sid: string) => void;
86
87
  executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
87
88
  fenceSessionOwner: (sid: string, owner: string | null) => void;
89
+ sessionResidentBackground: () => import("../session-resident-background.js").SessionResidentCounts;
88
90
  lspManager: import("@sema-agent/core").NodeLspManager | import("../lsp/manager.js").E2bLspManager | undefined;
89
91
  spaceReclaimer: import("../workspace-space.js").SpaceReclaimer | undefined;
90
92
  sandboxPodReaper: import("../plugins/k8s-pod-reaper.js").SandboxPodReaper | undefined;
@@ -147,12 +149,13 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
147
149
  sessionStore: import("@sema-agent/core").SessionStore<import("@sema-agent/core").SessionStoreSummary, import("@sema-agent/core").SessionListQuery>;
148
150
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
149
151
  storePosture: import("../store-posture.js").StorePosture;
152
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
150
153
  taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
151
154
  taskListLane: import("./task-list-lane.js").TaskListLane;
152
155
  usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
156
+ config: import("../config-types.js").ServiceConfig;
153
157
  ceilingVerdict: import("./unpriced-ceiling-verdict.js").UnpricedCeilingVerdict;
154
158
  webAdmin: import("./web-admin.js").WebAdminRuntime;
155
- config: import("../config-types.js").ServiceConfig;
156
159
  localRoot: string;
157
160
  logger: import("../index.js").Logger;
158
161
  metrics: import("../index.js").Metrics;