@makaio/framework 1.0.0-dev-1785409369816 → 1.0.0-dev-1787670071418

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 (549) hide show
  1. package/README.md +2 -0
  2. package/dist/.makaio-build.json +4 -3
  3. package/dist/{account-identity-DFx8pwKL.mjs → account-identity-B3vLwm9O.mjs} +1 -1
  4. package/dist/adapter-Dz1fX5Wa.mjs +1 -0
  5. package/dist/adapter-subsystem/index.d.mts +194 -20
  6. package/dist/adapter-subsystem/index.mjs +1 -1
  7. package/dist/adapters/acp-client/index.d.mts +105 -7
  8. package/dist/adapters/acp-client/index.mjs +2 -2
  9. package/dist/adapters/claude/index.d.mts +5 -5
  10. package/dist/adapters/config/index.d.mts +1 -1
  11. package/dist/adapters/config/index.mjs +1 -1
  12. package/dist/adapters/index.d.mts +405 -824
  13. package/dist/adapters/index.mjs +6 -6
  14. package/dist/adapters/node.d.mts +1 -1
  15. package/dist/adapters/node.mjs +1 -1
  16. package/dist/adapters/stream-session/index.d.mts +28 -7
  17. package/dist/adapters/stream-session/index.mjs +1 -1
  18. package/dist/{ajv-DD3SIL2i.mjs → ajv-krzJXh1X.mjs} +2 -2
  19. package/dist/artifact-Btbuib48.mjs +1 -0
  20. package/dist/attach-error-Cb3GbeKe.mjs +1 -0
  21. package/dist/{auth-DGEdiHF6.mjs → auth-C6tVtaOX.mjs} +1 -1
  22. package/dist/authority-state-bootstrap-CLYus369.mjs +1 -0
  23. package/dist/automation-trigger-ByjNlClm.mjs +1 -0
  24. package/dist/await-trigger-Bkg2BQfg.mjs +1 -0
  25. package/dist/bus/index.d.mts +41 -9
  26. package/dist/bus/index.mjs +1 -1
  27. package/dist/bus-D6NoBhIV.mjs +2 -0
  28. package/dist/bus-UgFdHybD.mjs +1 -0
  29. package/dist/caller-owned-adapter-stub-C1M7FKrv.mjs +1 -0
  30. package/dist/{canonical-model-BAytQ4NV.mjs → canonical-model-DXOvCaVg.mjs} +1 -1
  31. package/dist/capabilities-BUwuA7XX.mjs +1 -0
  32. package/dist/capability-j3NekkIu.mjs +1 -0
  33. package/dist/{client-DbS847wW.mjs → client-BkznbdsO.mjs} +1 -1
  34. package/dist/clients/index.d.mts +2 -2
  35. package/dist/clients/index.mjs +1 -1
  36. package/dist/clients/managed-install.d.mts +1 -1
  37. package/dist/clients/managed-install.mjs +1 -1
  38. package/dist/code-execution/worker-entry.d.mts +21 -0
  39. package/dist/code-execution/worker-entry.mjs +1 -0
  40. package/dist/code-execution-Ckmn8OZu.mjs +1 -0
  41. package/dist/code-execution-CweDSWco.mjs +1 -0
  42. package/dist/code-execution-DqkQjKa1.mjs +1 -0
  43. package/dist/{compression-74fFeBha.mjs → compression-CtgeVLpP.mjs} +1 -1
  44. package/dist/{config-namespace-TVX-hG4I.mjs → config-namespace-CjWvw8ij.mjs} +1 -1
  45. package/dist/{context-resolution-DdyhpH4L.d.mts → context-resolution-841T7jBI.d.mts} +11 -11
  46. package/dist/contracts/adapter/index.d.mts +3 -3
  47. package/dist/contracts/adapter/index.mjs +1 -1
  48. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  49. package/dist/contracts/artifact/index.d.mts +3 -3
  50. package/dist/contracts/artifact/index.mjs +1 -1
  51. package/dist/contracts/auth/index.d.mts +2 -2
  52. package/dist/contracts/auth/index.mjs +1 -1
  53. package/dist/contracts/automation-trigger/index.d.mts +4 -0
  54. package/dist/contracts/automation-trigger/index.mjs +1 -0
  55. package/dist/contracts/canonical-model/index.d.mts +1 -1
  56. package/dist/contracts/canonical-model/index.mjs +1 -1
  57. package/dist/contracts/capabilities/index.d.mts +1 -1
  58. package/dist/contracts/capabilities/index.mjs +1 -1
  59. package/dist/contracts/client/index.d.mts +2 -2
  60. package/dist/contracts/client/index.mjs +1 -1
  61. package/dist/contracts/code-execution/index.d.mts +2 -0
  62. package/dist/contracts/code-execution/index.mjs +1 -0
  63. package/dist/contracts/common/index.d.mts +1 -1
  64. package/dist/contracts/config/index.d.mts +1 -1
  65. package/dist/contracts/config/index.mjs +1 -1
  66. package/dist/contracts/extension/index.d.mts +6 -5
  67. package/dist/contracts/extension/index.mjs +1 -1
  68. package/dist/contracts/facet/index.d.mts +1 -1
  69. package/dist/contracts/facet/index.mjs +1 -1
  70. package/dist/contracts/harness/index.d.mts +1 -1
  71. package/dist/contracts/harness/index.mjs +1 -1
  72. package/dist/contracts/host/index.d.mts +1 -1
  73. package/dist/contracts/host/index.mjs +1 -1
  74. package/dist/contracts/index.d.mts +171 -100
  75. package/dist/contracts/index.mjs +1 -1
  76. package/dist/contracts/materialization/index.d.mts +3 -3
  77. package/dist/contracts/materialization/index.mjs +1 -1
  78. package/dist/contracts/model-registry/index.d.mts +1 -1
  79. package/dist/contracts/model-registry/index.mjs +1 -1
  80. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  81. package/dist/contracts/native-session-supervisor/index.mjs +1 -1
  82. package/dist/contracts/platform/index.d.mts +1 -1
  83. package/dist/contracts/platform/index.mjs +1 -1
  84. package/dist/contracts/provider/index.d.mts +2 -2
  85. package/dist/contracts/provider/index.mjs +1 -1
  86. package/dist/contracts/reaction/index.d.mts +2 -0
  87. package/dist/contracts/reaction/index.mjs +1 -0
  88. package/dist/contracts/session/index.d.mts +3 -3
  89. package/dist/contracts/session/index.mjs +1 -1
  90. package/dist/contracts/shared/index.d.mts +3 -3
  91. package/dist/contracts/shared/index.mjs +1 -1
  92. package/dist/contracts/skill/index.d.mts +1 -1
  93. package/dist/contracts/skill/index.mjs +1 -1
  94. package/dist/contracts/telemetry/index.d.mts +1 -1
  95. package/dist/contracts/telemetry/index.mjs +1 -1
  96. package/dist/contracts/timeout/index.d.mts +1 -1
  97. package/dist/contracts/timeout/index.mjs +1 -1
  98. package/dist/contracts/toast/index.mjs +1 -1
  99. package/dist/contracts/variant/index.d.mts +1 -1
  100. package/dist/contracts/variant/index.mjs +1 -1
  101. package/dist/contracts/worker-node/index.d.mts +1 -1
  102. package/dist/contracts/worker-node/index.mjs +1 -1
  103. package/dist/contracts/workflow/index.d.mts +3 -3
  104. package/dist/contracts/workflow/index.mjs +1 -1
  105. package/dist/contribution-CUHLVLsT.d.mts +35 -0
  106. package/dist/core/index.d.mts +84 -2
  107. package/dist/core/index.mjs +1 -1
  108. package/dist/{definition-CJfiv8xm.mjs → definition-BH4QLGLI.mjs} +1 -1
  109. package/dist/definition-DyGImhyi.d.mts +375 -0
  110. package/dist/{detached-extension-handle-Ddfquy5_.mjs → detached-extension-handle-D0aI0pJA.mjs} +1 -1
  111. package/dist/drizzle/0031_adapter_session_currency.sql +66 -0
  112. package/dist/drizzle/0032_native_session_ownership.sql +77 -0
  113. package/dist/drizzle/0033_m_msf3hu2s.sql +1 -0
  114. package/dist/drizzle/0034_m_msha1388.sql +41 -0
  115. package/dist/drizzle/0035_m_mshgj6x7.sql +40 -0
  116. package/dist/drizzle/0036_m_msivwbgm.sql +1 -0
  117. package/dist/drizzle/0037_runtime_instance_incarnation_counter.sql +6 -0
  118. package/dist/drizzle/meta/_journal.json +49 -0
  119. package/dist/event-B8ELuk6k.mjs +1 -0
  120. package/dist/{execution-attempt-repository-DWXKY41_.d.mts → execution-attempt-repository-BJ2W6wwx.d.mts} +1 -1
  121. package/dist/{execution-target-Cf645pDj.mjs → execution-target-H0RWV7Py.mjs} +1 -1
  122. package/dist/extension-Bfkr2DBs.mjs +1 -0
  123. package/dist/extension-Cz39YNXy.mjs +1 -0
  124. package/dist/extension-context-QmFuHdq5.d.mts +295 -0
  125. package/dist/{extension-discovery-CQRdbVQ6.d.mts → extension-discovery-Dhu3WplO.d.mts} +11 -1
  126. package/dist/{extension-namespace-Yu41YepM.mjs → extension-namespace-QoTTwKPt.mjs} +1 -1
  127. package/dist/extension-package-provenance-aYrZuS4W.mjs +1 -0
  128. package/dist/{filesystem-service-DlP2HfDg.mjs → filesystem-service-CiUw0YN5.mjs} +1 -1
  129. package/dist/framework-packages-BHgul8Kl.mjs +1 -0
  130. package/dist/git/index.mjs +2 -2
  131. package/dist/{globby-1yCVCk8s.mjs → globby-QBDqstzq.mjs} +1 -1
  132. package/dist/handlers-BsHAFtye.mjs +57 -0
  133. package/dist/{harness-DpwsFsE7.mjs → harness-YQ2ewID9.mjs} +1 -1
  134. package/dist/{hook-responses-Dh1PWXqJ.d.mts → hook-responses-9Ywsqzzq.d.mts} +2 -293
  135. package/dist/identity-OjRlG6dZ.mjs +1 -0
  136. package/dist/{index-CMgLxw14.d.mts → index-8NdPPzUh2.d.mts} +2 -2
  137. package/dist/{index-Ds5_rDEJ.d.mts → index-8y4hT9WL.d.mts} +1 -12
  138. package/dist/{index-BVlXneHH.d.mts → index-B-3I98nw.d.mts} +14 -10
  139. package/dist/index-B0VO0rAl.d.mts +302 -0
  140. package/dist/{index-gUhidukN.d.mts → index-B0yMCJW8.d.mts} +324 -2
  141. package/dist/index-BM56936c.d.mts +165 -0
  142. package/dist/{index-CLvQsL6s2.d.mts → index-BNzUyVwV.d.mts} +2105 -320
  143. package/dist/{index-BaZeoZoS.d.mts → index-BTEJfzjE.d.mts} +1 -1
  144. package/dist/{index-B0Kf_OWi.d.mts → index-BfV8U4XX.d.mts} +1 -1
  145. package/dist/{index-DCZ8BX9S.d.mts → index-BkbnC65b.d.mts} +487 -85
  146. package/dist/{index-GHASUiem.d.mts → index-BmevAPME2.d.mts} +1 -1
  147. package/dist/index-Bqk0pJBQ2.d.mts +138 -0
  148. package/dist/{index-B9UW_vPM.d.mts → index-C146Eq_J.d.mts} +2465 -273
  149. package/dist/{index-BAXkicoQ.d.mts → index-CIEycZrt.d.mts} +1 -1
  150. package/dist/{index-DkiTJM5p.d.mts → index-CMekqu_D.d.mts} +44 -10
  151. package/dist/{index-SsBHjUqA.d.mts → index-CPRQ4dWX.d.mts} +0 -23
  152. package/dist/{index-EjsSBQXy2.d.mts → index-CPi0UpRh.d.mts} +1 -1
  153. package/dist/{index-DSBT83c0.d.mts → index-CYjgoYeX.d.mts} +24 -3
  154. package/dist/{index-DnG-QFpG.d.mts → index-CmwAJ8-5.d.mts} +18 -1
  155. package/dist/index-Cny5RvjO.d.mts +800 -0
  156. package/dist/{index-BNMnIe-j.d.mts → index-D-4jv_66.d.mts} +434 -863
  157. package/dist/{index-brqfk9JQ.d.mts → index-D8D-yibS2.d.mts} +4 -4
  158. package/dist/index-DHnSLGP4.d.mts +268 -0
  159. package/dist/{index-D5Nb7IEP.d.mts → index-DI2lS7VT.d.mts} +79 -41
  160. package/dist/{index-D_ODXsBv.d.mts → index-DJ2KgJDJ2.d.mts} +51 -95
  161. package/dist/{index-cqLS1eFV.d.mts → index-DNI6UF9h.d.mts} +133 -134
  162. package/dist/index-DQ8o3JGi.d.mts +132 -0
  163. package/dist/index-DWBkiiXH.d.mts +18 -0
  164. package/dist/{index-DlsHL9Jg.d.mts → index-DXtQRehh.d.mts} +12 -12
  165. package/dist/{index-4VfqCjl2.d.mts → index-D_4K3Tf_.d.mts} +79 -194
  166. package/dist/index-Dg11JxKZ.d.mts +496 -0
  167. package/dist/json-value-BBZ6uGwc.mjs +1 -0
  168. package/dist/json-value-DPqb-SJ8.d.mts +177 -0
  169. package/dist/kernel/cli/index.d.mts +2 -2
  170. package/dist/kernel/cli/index.mjs +1 -1
  171. package/dist/kernel/cli/register.d.mts +1 -1
  172. package/dist/kernel/cli/register.mjs +1 -1
  173. package/dist/kernel/cli/schemas.mjs +1 -1
  174. package/dist/kernel/extension/index.d.mts +1 -1
  175. package/dist/kernel/extension/index.mjs +1 -1
  176. package/dist/kernel/index.d.mts +9 -9
  177. package/dist/kernel/index.mjs +1 -1
  178. package/dist/kernel/namespace/index.d.mts +2 -2
  179. package/dist/kernel/namespace/index.mjs +1 -1
  180. package/dist/kernel/observability/index.d.mts +1 -1
  181. package/dist/kernel/observability/index.mjs +1 -1
  182. package/dist/kernel/providers/index.d.mts +1 -1
  183. package/dist/kernel/providers/index.mjs +1 -1
  184. package/dist/kernel/window/index.d.mts +1 -1
  185. package/dist/kernel/window/index.mjs +1 -1
  186. package/dist/{lib-DErgth_E.mjs → lib-BpGvHZye.mjs} +2 -2
  187. package/dist/{lib-C7-s68uf.mjs → lib-Cm-uEoC1.mjs} +1 -1
  188. package/dist/{load-extensions-BxsDB87B.d.mts → load-extensions-BQoXaHhR.d.mts} +17 -13
  189. package/dist/load-extensions-DG5LvPyM.mjs +1 -0
  190. package/dist/{materialization-Jd198K3y.mjs → materialization-lVd9_-jr.mjs} +1 -1
  191. package/dist/mcp-http-server/index.mjs +1 -1
  192. package/dist/model-DrzPt3ou.mjs +1 -0
  193. package/dist/{namespace-BqxtpNAn.mjs → namespace-BL7lHlmg.mjs} +1 -1
  194. package/dist/{namespace-CjjFvrIA2.d.mts → namespace-BNp7n_gu.d.mts} +25 -25
  195. package/dist/{namespace-g_mbIZq_.d.mts → namespace-BRuHzhPo.d.mts} +564 -28
  196. package/dist/{namespace-DV-Hr9sZ.d.mts → namespace-C06lJSuj.d.mts} +17 -7
  197. package/dist/{namespace-TseEI3Pu.d.mts → namespace-DOezqDti.d.mts} +18 -10
  198. package/dist/{namespace-CErHuXtb.d.mts → namespace-DknCutQZ.d.mts} +50 -0
  199. package/dist/{namespace-B8uKAzWJ.mjs → namespace-Du0accdE.mjs} +1 -1
  200. package/dist/{namespace-CWUDFGOy.mjs → namespace-NXm_zvL1.mjs} +1 -1
  201. package/dist/{namespace-CupOzbRv.d.mts → namespace-l-HG1rLF.d.mts} +24 -20
  202. package/dist/namespace-sCPb79-7.mjs +1 -0
  203. package/dist/{native-session-supervisor-DRx0MX-d.mjs → native-session-supervisor-LKio8XZn.mjs} +1 -1
  204. package/dist/node/bus-server/index.d.mts +1 -1
  205. package/dist/node/bus-server/index.mjs +1 -1
  206. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  207. package/dist/node/bus-server/server-lifecycle.mjs +1 -1
  208. package/dist/npm-package-name-DuTYVICk.mjs +1 -0
  209. package/dist/orchestrator-shared-BGlN-m-V.mjs +1 -0
  210. package/dist/{orchestrator-shared-BHCv-l2O.d.mts → orchestrator-shared-CNHSImNY.d.mts} +10 -10
  211. package/dist/ownership-memory-handler-BpGdR_uG.mjs +1 -0
  212. package/dist/ownership-recovery-guard-DyW5vGBr.mjs +1 -0
  213. package/dist/package-B01gmu75.mjs +7 -0
  214. package/dist/{package-DWMxGfzK.d.mts → package-BNFTUFLB.d.mts} +234 -84
  215. package/dist/package-DttKA9wN.mjs +1 -0
  216. package/dist/package-EGTn-Ng1.mjs +1 -0
  217. package/dist/package-JtjbO-Oi.mjs +1 -0
  218. package/dist/package.json +1 -1
  219. package/dist/{profile-BTAI31Nt.mjs → profile-N5qGUpF0.mjs} +1 -1
  220. package/dist/{provider-context-PZIQWcqQ.mjs → provider-context-CG42JlP9.mjs} +1 -1
  221. package/dist/{provider-context-Dq53Cgzz.mjs → provider-context-zTDSH2x9.mjs} +1 -1
  222. package/dist/reaction-D3TNwPK8.mjs +1 -0
  223. package/dist/{registry-wfF2uTty.mjs → registry-Dk12tAfv.mjs} +2 -2
  224. package/dist/{resolved-DZgqql2Z.mjs → resolved-sq8RXNDf.mjs} +1 -1
  225. package/dist/rules/index.d.mts +1 -1
  226. package/dist/rules/index.mjs +1 -1
  227. package/dist/rules/schemas.d.mts +1 -1
  228. package/dist/rules/schemas.mjs +1 -1
  229. package/dist/runtime-bun/index.mjs +1 -1
  230. package/dist/runtime-node/code-execution/index.d.mts +3 -0
  231. package/dist/runtime-node/code-execution/index.mjs +1 -0
  232. package/dist/runtime-node/extension-discovery.d.mts +2 -2
  233. package/dist/runtime-node/extension-discovery.mjs +1 -1
  234. package/dist/runtime-node/extension-validation.d.mts +1 -1
  235. package/dist/runtime-node/extension-validation.mjs +1 -1
  236. package/dist/runtime-node/index.d.mts +7 -5
  237. package/dist/runtime-node/index.mjs +24 -24
  238. package/dist/runtime-node/makaio-config.d.mts +1 -1
  239. package/dist/runtime-node/makaio-config.mjs +1 -1
  240. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  241. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  242. package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
  243. package/dist/{schema-DKUb4rkr.d.mts → schema-B3Pf7JP7.d.mts} +778 -21
  244. package/dist/{schema-Dd-e89MO.mjs → schema-Dq-7si8u.mjs} +1 -1
  245. package/dist/{schemas-B1NWNASS.d.mts → schemas-BXc9qOpl.d.mts} +2 -0
  246. package/dist/schemas-BfO5jkrL.mjs +1 -0
  247. package/dist/{schemas-CR8hSqTy.d.mts → schemas-C1mxTfd7.d.mts} +60 -4
  248. package/dist/schemas-C3kyQWGf.mjs +1 -0
  249. package/dist/{schemas-DnYiAvfz.d.mts → schemas-D7ScxLrf.d.mts} +24 -20
  250. package/dist/{schemas-BsVYZviy.d.mts → schemas-OWvBn7AH.d.mts} +4 -4
  251. package/dist/{schemas-DaHQzpgm.mjs → schemas-QWDnauKX.mjs} +1 -1
  252. package/dist/schemas-TK29KWx-.mjs +1 -0
  253. package/dist/schemas-_2Syo_01.mjs +1 -0
  254. package/dist/scoped-bus-DoPmCJeM.mjs +1 -0
  255. package/dist/{selection-BNwTKEVT.mjs → selection-DL3ric7K.mjs} +1 -1
  256. package/dist/services/adapter-runtime/index.d.mts +4 -4
  257. package/dist/services/adapter-runtime/index.mjs +1 -1
  258. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  259. package/dist/services/adapter-runtime/schemas.d.mts +2 -2
  260. package/dist/services/adapter-runtime/schemas.mjs +1 -1
  261. package/dist/services/adapter-subsystem/index.d.mts +4 -4
  262. package/dist/services/adapter-subsystem/index.mjs +1 -1
  263. package/dist/services/adapter-subsystem/namespace.d.mts +2 -2
  264. package/dist/services/adapter-subsystem/namespace.mjs +1 -1
  265. package/dist/services/agent-runtime/index.d.mts +2 -2
  266. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  267. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  268. package/dist/services/automation-trigger/index.d.mts +943 -0
  269. package/dist/services/automation-trigger/index.mjs +1 -0
  270. package/dist/services/capability/index.d.mts +3 -2
  271. package/dist/services/capability/index.mjs +1 -1
  272. package/dist/services/code-execution/index.d.mts +2 -0
  273. package/dist/services/code-execution/index.mjs +1 -0
  274. package/dist/services/codebase/index.d.mts +2 -2
  275. package/dist/services/codebase/namespace.d.mts +1 -1
  276. package/dist/services/codebase/schemas.d.mts +1 -1
  277. package/dist/services/compression/index.d.mts +2 -2
  278. package/dist/services/compression/namespace.d.mts +1 -1
  279. package/dist/services/compression/schemas.d.mts +1 -1
  280. package/dist/services/context-rules/index.d.mts +1 -1
  281. package/dist/services/context-rules/index.mjs +1 -1
  282. package/dist/services/execution-target/index.d.mts +3 -3
  283. package/dist/services/execution-target/index.mjs +1 -1
  284. package/dist/services/execution-target/namespace.d.mts +1 -1
  285. package/dist/services/execution-target/namespace.mjs +1 -1
  286. package/dist/services/execution-target/schemas.d.mts +1 -1
  287. package/dist/services/execution-target/schemas.mjs +1 -1
  288. package/dist/services/filesystem/index.d.mts +1 -1
  289. package/dist/services/filesystem/index.mjs +1 -1
  290. package/dist/services/filesystem/namespace.d.mts +6 -6
  291. package/dist/services/filesystem/schemas.d.mts +3 -3
  292. package/dist/services/git/namespace.d.mts +18 -0
  293. package/dist/services/git/namespace.mjs +1 -1
  294. package/dist/services/git/schemas.d.mts +10 -1
  295. package/dist/services/git/schemas.mjs +1 -1
  296. package/dist/services/harness/index.mjs +1 -1
  297. package/dist/services/index.d.mts +567 -101
  298. package/dist/services/index.mjs +1 -1
  299. package/dist/services/log-import/browser.d.mts +2 -2
  300. package/dist/services/log-import/index.d.mts +3 -3
  301. package/dist/services/log-import/log-import.d.mts +1 -1
  302. package/dist/services/log-import/log-import.mjs +1 -1
  303. package/dist/services/log-import/namespace.mjs +1 -1
  304. package/dist/services/log-import/schemas.mjs +1 -1
  305. package/dist/services/materialization/index.d.mts +1 -1
  306. package/dist/services/materialization/index.mjs +1 -1
  307. package/dist/services/model-registry/index.d.mts +1 -1
  308. package/dist/services/model-registry/index.mjs +1 -1
  309. package/dist/services/preferences/index.d.mts +2 -2
  310. package/dist/services/preferences/schemas.d.mts +1 -1
  311. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  312. package/dist/services/provider-context/index.d.mts +1 -1
  313. package/dist/services/provider-context/index.mjs +1 -1
  314. package/dist/services/provider-runtime/index.mjs +1 -1
  315. package/dist/services/session/handlers/index.d.mts +2 -2
  316. package/dist/services/session/handlers/index.mjs +1 -1
  317. package/dist/services/session/index.d.mts +10 -10
  318. package/dist/services/session/index.mjs +1 -1
  319. package/dist/services/session/messages/namespace.d.mts +1 -1
  320. package/dist/services/session/messages/namespace.mjs +1 -1
  321. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  322. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  323. package/dist/services/session/session-events/namespace.d.mts +1 -1
  324. package/dist/services/session/session-events/namespace.mjs +1 -1
  325. package/dist/services/session/storage/namespace.d.mts +1 -1
  326. package/dist/services/session/storage/schema.d.mts +2 -2
  327. package/dist/services/session/storage/schema.mjs +1 -1
  328. package/dist/services/session/testing/index.d.mts +33 -4
  329. package/dist/services/session/testing/index.mjs +68 -12
  330. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  331. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  332. package/dist/services/session/turns/namespace.d.mts +1 -1
  333. package/dist/services/session/turns/namespace.mjs +1 -1
  334. package/dist/services/session-editor/index.d.mts +1 -1
  335. package/dist/services/session-editor/index.mjs +1 -1
  336. package/dist/services/settings/index.d.mts +3 -3
  337. package/dist/services/settings/index.mjs +1 -1
  338. package/dist/services/settings/namespace.mjs +1 -1
  339. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  340. package/dist/services/settings/storage/clients-namespace.mjs +1 -1
  341. package/dist/services/settings/storage/index.d.mts +3 -3
  342. package/dist/services/settings/storage/index.mjs +1 -1
  343. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  344. package/dist/services/settings/storage/providers-namespace.mjs +1 -1
  345. package/dist/services/subagent/index.d.mts +1 -1
  346. package/dist/services/subagent/index.mjs +1 -1
  347. package/dist/services/subagent-template/index.d.mts +2 -2
  348. package/dist/services/subagent-template/namespace.d.mts +1 -1
  349. package/dist/services/subagent-template/schemas.d.mts +1 -1
  350. package/dist/services/tool-approval/index.d.mts +1 -1
  351. package/dist/services/tool-approval/index.mjs +1 -1
  352. package/dist/services/tools/index.d.mts +1 -1
  353. package/dist/services/tools/index.mjs +1 -1
  354. package/dist/services/tray-menu/index.d.mts +3 -3
  355. package/dist/services/tray-menu/index.mjs +1 -1
  356. package/dist/services/tray-menu/namespace.d.mts +1 -1
  357. package/dist/services/tray-menu/schemas.d.mts +1 -1
  358. package/dist/services/turn/index.d.mts +1 -1
  359. package/dist/services/turn/namespace.d.mts +1 -1
  360. package/dist/services/workflow-transitions/index.d.mts +1 -1
  361. package/dist/services/workflow-transitions/index.mjs +1 -1
  362. package/dist/session-BOpTI79g.mjs +1 -0
  363. package/dist/session-CXOPk3yg.mjs +95 -0
  364. package/dist/shared-B9AWRm9A.mjs +1 -0
  365. package/dist/{skill-BR6rkfLe.mjs → skill-DGNtc_ww.mjs} +1 -1
  366. package/dist/{src-DD0v-nIj.mjs → src-BmSQ3rlz.mjs} +1 -1
  367. package/dist/storage/drizzle/client.d.mts +1 -1
  368. package/dist/storage/drizzle/client.mjs +1 -1
  369. package/dist/storage/drizzle/index.d.mts +81 -2
  370. package/dist/storage/drizzle/index.mjs +1 -1
  371. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  372. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  373. package/dist/storage/handlers/index.d.mts +1 -1
  374. package/dist/storage/handlers/index.mjs +1 -1
  375. package/dist/tool-approval-service-BFDOFUGC.mjs +1 -0
  376. package/dist/{tools-PdG9fO1M.mjs → tools-DWKWX3eV.mjs} +1 -1
  377. package/dist/{transition-Du3MQzJV.d.mts → transition-D3zUBTPc.d.mts} +11 -38
  378. package/dist/{types-D7_kevBK.d.mts → types-BlB23n4f.d.mts} +1 -1
  379. package/dist/{types-DMLDHFR9.d.mts → types-CtDGkyLx2.d.mts} +1 -1
  380. package/dist/types-Cwza95hS.mjs +1 -0
  381. package/dist/{types-Dzrwa1GY.d.mts → types-DcxBYlPA.d.mts} +5834 -1436
  382. package/dist/types-DnK6Wa_Y.d.mts +260 -0
  383. package/dist/types-OKJCOjme.d.mts +2937 -0
  384. package/dist/ui-hooks/index.d.mts +29 -2
  385. package/dist/ui-hooks/index.mjs +1 -1
  386. package/dist/ui-kernel/index.d.mts +2 -2
  387. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  388. package/dist/ui-views/index.d.mts +1 -1
  389. package/dist/utils/index.d.mts +98 -1
  390. package/dist/utils/index.mjs +2 -2
  391. package/dist/utils/project-manifest.mjs +1 -1
  392. package/dist/{version-CoCeMxDT.mjs → version-BYeVh1pI.mjs} +1 -1
  393. package/dist/{view-builder-DeFd-k7C.d.mts → view-builder-B0j9p5C0.d.mts} +4 -4
  394. package/dist/{visibility-qhGWmpSJ.mjs → visibility-DtDLRBdr.mjs} +1 -1
  395. package/dist/worker-node-CjuQb9hl.mjs +1 -0
  396. package/dist/{worker-node-DZTuT1DS.mjs → worker-node-Dtf9ilsR.mjs} +1 -1
  397. package/dist/workflow-C4mck_NW.mjs +1 -0
  398. package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
  399. package/dist/workflow-engine/index.d.mts +237 -518
  400. package/dist/workflow-engine/index.mjs +1 -1
  401. package/dist/workflow-engine/package.d.mts +1 -1
  402. package/dist/workflow-engine/package.mjs +1 -1
  403. package/dist/workflow-engine/provider-operation.d.mts +1 -1
  404. package/dist/workflow-engine/testing/index.d.mts +2 -2
  405. package/dist/workflow-engine/testing/index.mjs +1 -1
  406. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  407. package/dist/workflow-engine/testing/sqlite.mjs +27 -27
  408. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  409. package/dist/workflow-engine/workflow-trigger-binding-consumer.d.mts +46 -0
  410. package/dist/workflow-engine/workflow-trigger-binding-consumer.mjs +1 -0
  411. package/dist/{workflow-transitions-DSc45ixc.mjs → workflow-transitions-c_VQbyV0.mjs} +1 -1
  412. package/dist/workflow-worker-aNbdgqml.mjs +1 -0
  413. package/dist/zod-json-schema-Dixc-B1T.mjs +1 -0
  414. package/package.json +46 -1
  415. package/dist/adapter-D5c5LrPN.mjs +0 -1
  416. package/dist/artifact-DGiXqb11.mjs +0 -1
  417. package/dist/attach-error-C3tngg6J.mjs +0 -1
  418. package/dist/authority-state-bootstrap-GPL_tqaT.mjs +0 -1
  419. package/dist/await-trigger-I3lrepb8.mjs +0 -1
  420. package/dist/bus-B6SAjgOC.mjs +0 -2
  421. package/dist/bus-C2l3K74u.mjs +0 -1
  422. package/dist/capabilities-BQEp34ir.mjs +0 -1
  423. package/dist/capability-service-BqiLlRGA.mjs +0 -1
  424. package/dist/event-CmVjR6Ib.mjs +0 -1
  425. package/dist/extension-DCA4pYrY.mjs +0 -1
  426. package/dist/extension-hjOPs10e.mjs +0 -1
  427. package/dist/framework-packages-C3RWfJDk.mjs +0 -1
  428. package/dist/handlers-CfnLyLfE.mjs +0 -57
  429. package/dist/identity-D6guMtmi.mjs +0 -1
  430. package/dist/index-CRvpVIqA.d.mts +0 -89
  431. package/dist/json-value-Brslhqbm.d.mts +0 -57
  432. package/dist/json-value-DmU8ibo_.mjs +0 -1
  433. package/dist/load-extensions-D0DfjYLC.mjs +0 -1
  434. package/dist/model-BGgVmRnN.mjs +0 -1
  435. package/dist/namespace-DJfUADSV.mjs +0 -1
  436. package/dist/orchestrator-shared-BxmHCPvx.mjs +0 -1
  437. package/dist/package-CNUPPcU1.mjs +0 -7
  438. package/dist/package-Dft_RItb.mjs +0 -1
  439. package/dist/schemas-CRB2O5zo.mjs +0 -1
  440. package/dist/schemas-Cm09dXL4.mjs +0 -1
  441. package/dist/schemas-tDf_WiC8.mjs +0 -1
  442. package/dist/scoped-bus-C9BdNwfM.mjs +0 -1
  443. package/dist/session-BOGCd18q.mjs +0 -1
  444. package/dist/session-BTFiDoGz.mjs +0 -76
  445. package/dist/shared-BQ0CHIVy.mjs +0 -1
  446. package/dist/tool-approval-service-kBA0fRzm.mjs +0 -1
  447. package/dist/types-CJ_QZ1yW.d.mts +0 -1487
  448. package/dist/worker-node-Bl9_vqYi.mjs +0 -1
  449. package/dist/workflow-BfDbgtIQ.mjs +0 -1
  450. package/dist/workflow-worker-BN9XPxQO.mjs +0 -1
  451. package/dist/{adapter-auth-runtime-DO-FVTXg.mjs → adapter-auth-runtime-DHHppU4f.mjs} +0 -0
  452. package/dist/{adapter-binding-DQchUtrK.d.mts → adapter-binding-CATvmGuz.d.mts} +0 -0
  453. package/dist/{attempt-record-codec-CqO1_XnE.mjs → attempt-record-codec-BYfYkj4M.mjs} +0 -0
  454. package/dist/{base-orchestrator-BilsQNW1.d.mts → base-orchestrator-B4YW6z_Q.d.mts} +0 -0
  455. package/dist/{index-DN4NOCqN2.d.mts → capability-service-BW1-teFU.d.mts} +0 -0
  456. package/dist/{client-B--e2qcU.d.mts → client-BG0WX5Vz.d.mts} +0 -0
  457. package/dist/{client-binary-version-verifier-taewmKTY.mjs → client-binary-version-verifier-0lCKZOTg.mjs} +0 -0
  458. package/dist/{client-binary-version-verifier-CgjM_vGF.d.mts → client-binary-version-verifier-lcv83Hq3.d.mts} +0 -0
  459. package/dist/{clients-namespace-DfxjG2ZP.d.mts → clients-namespace-DLAjOTTb.d.mts} +0 -0
  460. package/dist/{config-namespace-BCqvufbD.d.mts → config-namespace-CH7sJZ4f.d.mts} +0 -0
  461. package/dist/{create-static-mount-bbQhTt6W.mjs → create-static-mount-DxuixuLZ.mjs} +0 -0
  462. package/dist/{cross-spawn-B57KZuns.mjs → cross-spawn-CZygZJMH.mjs} +0 -0
  463. package/dist/{cursor-storage-DIFK_9hg.mjs → cursor-storage-bsc9lZKk.mjs} +0 -0
  464. package/dist/{definition-gnKgXU91.d.mts → definition-BrgzUuFk.d.mts} +0 -0
  465. package/dist/{definitions-xrrY0wgz.mjs → definitions-CRpdnHYM.mjs} +0 -0
  466. package/dist/{descriptor-to-package-DvF08krT.mjs → descriptor-to-package-CcjdoWP4.mjs} +0 -0
  467. package/dist/{drizzle-z_0SiGY8.mjs → drizzle-Bzc-OGVI.mjs} +0 -0
  468. package/dist/{esm-CltRnX8_.mjs → esm-i-S5TW72.mjs} +0 -0
  469. package/dist/{facet-BCI00njh.mjs → facet-BnMh7Jyc.mjs} +0 -0
  470. package/dist/{filesystem-service-CQ9yVkSz.d.mts → filesystem-service-ZJ43SbBi.d.mts} +0 -0
  471. package/dist/{handler-Cbv9FqDO.mjs → handler-DF1fVDpf.mjs} +0 -0
  472. package/dist/{host-Caq6ZfSJ.mjs → host-B-_ntOMH.mjs} +0 -0
  473. package/dist/{index-ye0oklfU.d.mts → index-B2Y1Wvbh.d.mts} +0 -0
  474. package/dist/{index-Cv-o5Krs.d.mts → index-B4svZC6L.d.mts} +0 -0
  475. package/dist/{index-DZunhZec.d.mts → index-B5dP8rj6.d.mts} +0 -0
  476. package/dist/{index-jTaAHsul.d.mts → index-BC-6qNeo.d.mts} +0 -0
  477. package/dist/{index-ByKi34v5.d.mts → index-BFWvT0NG.d.mts} +0 -0
  478. package/dist/{index-vA--0lOM.d.mts → index-BMRB9yhF.d.mts} +0 -0
  479. package/dist/{index-BskPjMet.d.mts → index-BuMsrli0.d.mts} +0 -0
  480. package/dist/{index-DR40QWlw.d.mts → index-C4V8Pmi4.d.mts} +0 -0
  481. package/dist/{index-BIdsFcQs2.d.mts → index-CL0Jo1b92.d.mts} +0 -0
  482. package/dist/{index-CjdRdsd0.d.mts → index-CVpaGijY.d.mts} +0 -0
  483. package/dist/{index-vcSj12YQ.d.mts → index-CmbkCxj-.d.mts} +0 -0
  484. package/dist/{index-sS6KUlrx.d.mts → index-CqdMbYmR.d.mts} +0 -0
  485. package/dist/{index-CnMu8BQl.d.mts → index-D037TVsm.d.mts} +0 -0
  486. package/dist/{index-CGZQVTid.d.mts → index-DgspOUa72.d.mts} +0 -0
  487. package/dist/{index-dtsLKOID.d.mts → index-Ek4y8M9J2.d.mts} +0 -0
  488. package/dist/{index-DjgLchuQ.d.mts → index-VzLAV0Yt.d.mts} +0 -0
  489. package/dist/{index-DXN_L5D6.d.mts → index-jxPncqWZ2.d.mts} +0 -0
  490. package/dist/{index-BVRQEpAg.d.mts → index-kzIjbrS02.d.mts} +6 -6
  491. /package/dist/{index-Dm1nUxCF.d.mts → index-l01zsChf.d.mts} +0 -0
  492. /package/dist/{index-CWHfOz6d.d.mts → index-pvX-BIpr2.d.mts} +0 -0
  493. /package/dist/{jsonl-transport-bQl3JwIu.mjs → jsonl-transport-Cyyh5Wje.mjs} +0 -0
  494. /package/dist/{lib-DOBXZmYX.mjs → lib-BqV8hYtk.mjs} +0 -0
  495. /package/dist/{model-registry-xyBKSye-.mjs → model-registry-C9rFu3kV.mjs} +0 -0
  496. /package/dist/{model-registry-CmgcPDH3.mjs → model-registry-Cixxx2jv.mjs} +0 -0
  497. /package/dist/{modes-BheyN7SS.mjs → modes-DwsJ3yVl.mjs} +0 -0
  498. /package/dist/{namespace-BOkKoq34.d.mts → namespace-B0ftHlK3.d.mts} +0 -0
  499. /package/dist/{namespace-YytVKIgI.d.mts → namespace-BGRHcrmp.d.mts} +0 -0
  500. /package/dist/{namespace-jDhZjw-i.d.mts → namespace-BUYDmd0r.d.mts} +0 -0
  501. /package/dist/{namespace-YxU1xf-K.mjs → namespace-BW3Bfu9h.mjs} +0 -0
  502. /package/dist/{namespace-DWCEo-9M.d.mts → namespace-BdAK0lD8.d.mts} +0 -0
  503. /package/dist/{namespace-Cv1RFP7n.d.mts → namespace-CPG6u60N.d.mts} +0 -0
  504. /package/dist/{namespace-GPA7zots.d.mts → namespace-CVFaZv8x.d.mts} +0 -0
  505. /package/dist/{namespace-Blp4c8GK.d.mts → namespace-DBO1OzYB.d.mts} +0 -0
  506. /package/dist/{namespace-C-9si-fV.mjs → namespace-DiwqpB-c.mjs} +0 -0
  507. /package/dist/{namespace-tGRAod3o.d.mts → namespace-DqZweTbX.d.mts} +0 -0
  508. /package/dist/{namespace-HO2J9sO8.mjs → namespace-jVTsuZHX.mjs} +0 -0
  509. /package/dist/{namespace-CWGKCNZm.mjs → namespace-tjoxekmf.mjs} +0 -0
  510. /package/dist/{out-CvjtANXN.mjs → out-8bOYN6EF.mjs} +0 -0
  511. /package/dist/{packages-DtEEP0Vt.mjs → packages-Bp124-gx.mjs} +0 -0
  512. /package/dist/{packages-BZ6pzFIq.d.mts → packages-CxPMEg8D.d.mts} +0 -0
  513. /package/dist/{platform-Bv8llU9c.mjs → platform-CxyYPrkf.mjs} +0 -0
  514. /package/dist/{provider-operation-Cxoe2SUr.d.mts → provider-operation-DbdyFwNm.d.mts} +0 -0
  515. /package/dist/{providers-Co5UszRH.mjs → providers-C-eekMxD.mjs} +0 -0
  516. /package/dist/{providers-namespace-DjFkmvBR.d.mts → providers-namespace-CfZKp-C0.d.mts} +0 -0
  517. /package/dist/{quick-lru-CrOpWwrf.mjs → quick-lru-CCEnf7y6.mjs} +0 -0
  518. /package/dist/{schema-Db-y-09L.mjs → schema-C0opCPww.mjs} +0 -0
  519. /package/dist/{schema-introspection-DgWQCpwx.mjs → schema-introspection-6-r_KEJQ.mjs} +0 -0
  520. /package/dist/{schemas-N6x2z7Lf.d.mts → schemas-B50oWBuj.d.mts} +0 -0
  521. /package/dist/{schemas-BO7uOum6.d.mts → schemas-B6Q-qdmn.d.mts} +0 -0
  522. /package/dist/{schemas-BGExwp3j.mjs → schemas-B8hKbBwI.mjs} +0 -0
  523. /package/dist/{schemas-miYxK_Z1.d.mts → schemas-BGvkTiCx.d.mts} +0 -0
  524. /package/dist/{schemas-CqRm0i9a.mjs → schemas-BivbWRkG.mjs} +0 -0
  525. /package/dist/{schemas-CwbYk_kZ.d.mts → schemas-ChmQldVH.d.mts} +0 -0
  526. /package/dist/{schemas-DrVg4aQQ.d.mts → schemas-Dd13TMgU.d.mts} +0 -0
  527. /package/dist/{schemas-BtZqovRH.d.mts → schemas-Pe892GgN.d.mts} +0 -0
  528. /package/dist/{schemas-CQyRBqD6.d.mts → schemas-bfZNpl0B.d.mts} +0 -0
  529. /package/dist/{schemas-Bfxskx_2.mjs → schemas-scyC2tFF.mjs} +0 -0
  530. /package/dist/{semver-DlM8znk4.mjs → semver-BI7kTNsY.mjs} +0 -0
  531. /package/dist/{server-lifecycle-kmQ5PUDv.mjs → server-lifecycle-B_OZnoe-.mjs} +0 -0
  532. /package/dist/{server-lifecycle-Dsq56aqC.d.mts → server-lifecycle-L8zja8t8.d.mts} +0 -0
  533. /package/dist/{session-lineage-B_JW5LpF.d.mts → session-lineage-bUkd3fqx.d.mts} +0 -0
  534. /package/dist/{shared-schemas-DXwyMCwZ.mjs → shared-schemas-CQ6blrEW.mjs} +0 -0
  535. /package/dist/{src-CCu8TwL6.mjs → src-BacfeiI4.mjs} +0 -0
  536. /package/dist/{storage-namespace-BSrv0vXR.mjs → storage-namespace-BZce8kkW.mjs} +0 -0
  537. /package/dist/{storage-namespace-dfywhXR3.d.mts → storage-namespace-YmE8XCCL.d.mts} +0 -0
  538. /package/dist/{storage-namespace-definition-BvlX0QV_.d.mts → storage-namespace-definition-BsnYAPot.d.mts} +0 -0
  539. /package/dist/{storage-namespace-definition-CkMKt7-I.mjs → storage-namespace-definition-Cca-zwXU.mjs} +0 -0
  540. /package/dist/{supports-color-DUugCQsK.mjs → supports-color-SV_FgSN2.mjs} +0 -0
  541. /package/dist/{telemetry-Pr3oP2rk.mjs → telemetry-BqoC87F-.mjs} +0 -0
  542. /package/dist/{timeout-DWDhddRJ.mjs → timeout-DVlN2Zhy.mjs} +0 -0
  543. /package/dist/{tray-menu-service-BBLa-Rcv.mjs → tray-menu-service-eVVxgPLc.mjs} +0 -0
  544. /package/dist/{types-BrcjaNPZ.d.mts → types-DdpSEmTO.d.mts} +0 -0
  545. /package/dist/{types-b54n1o57.d.mts → types-tyv0B605.d.mts} +0 -0
  546. /package/dist/{ui-config-CyCdlns_.mjs → ui-config-B35GloSX.mjs} +0 -0
  547. /package/dist/{variant-krjlTdJt.mjs → variant-Dwnge3J_.mjs} +0 -0
  548. /package/dist/{window-registry-I-imZHV_.mjs → window-registry-CKiMJjId.mjs} +0 -0
  549. /package/dist/{window-registry-BDnZLPVx.d.mts → window-registry-Pcf35cac.d.mts} +0 -0
@@ -1,21 +1,47 @@
1
- import { r as ExecutionTarget } from "./schemas-N6x2z7Lf.mjs";
2
- import { l as Turn$1 } from "./index-gUhidukN.mjs";
3
- import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-D7_kevBK.mjs";
1
+ import { g as OwnedAdapterInstance, h as MachineScopedAdapterInstance, w as Turn$1 } from "./index-B0yMCJW8.mjs";
2
+ import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-BlB23n4f.mjs";
4
3
  import { z } from "zod";
5
4
  import * as _$_makaio_core0 from "@makaio/framework/core";
6
5
  import { ExtractSubjectPayload, SubjectDefinition } from "@makaio/framework/core";
7
6
  import { IMakaioBus } from "@makaio/framework/bus";
8
7
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
9
- import { AIReasoningLevel, AdapterRuntimeOptions, BranchKind, ContextWindowState, ForkOptions, ForkTransforms, ICapabilityProvider, IMakaioSession, JsonValue, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, NativeLocalityVerdict, ReasoningLevelMap, SessionContext, SessionEventType, SessionExtensionContext, SessionLineage, SessionLineageKind, SessionMessage, SessionMessageBlock, SessionMessageOrigin, SessionSubjects, TurnIngestionMarker, TurnInitiator, TurnUsage } from "@makaio/framework/contracts";
8
+ import { AIReasoningLevel, AdapterRuntimeOptions, AdapterSelection, AdapterSessionClaimRecord, AgentRole, BranchKind, ContextWindowState, ForkOptions, ForkTransforms, ICapabilityProvider, IMakaioSession, JsonValue, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, NativeLocalityVerdict, OwnershipTopology, ResolvedProviderContext, RuntimeInstanceRecord, SessionContext, SessionEventType, SessionExtensionContext, SessionLineage, SessionLineageKind, SessionMessage, SessionMessageBlock, SessionMessageOrigin, SessionOwnershipReclaimReason, SessionOwnershipRecoveryGuard, SessionOwnershipReserveStartServiceResult, SessionSubjects, StartAgentRequest, StartAgentResponse, TurnIngestionMarker, TurnInitiator, TurnUsage } from "@makaio/framework/contracts";
10
9
  import { BaseService } from "@makaio/framework/service-base";
11
10
  import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
12
11
  import * as _$drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
13
12
  import * as _$_makaio_storage_drizzle0 from "@makaio/framework/storage/drizzle";
14
- import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
13
+ import { MakaioDatabase, TransactionLock } from "@makaio/framework/storage/drizzle";
15
14
  import * as _$drizzle_orm0 from "drizzle-orm";
15
+ import { SQL } from "drizzle-orm";
16
16
  import * as _$_makaio_storage_core0 from "@makaio/framework/storage";
17
17
 
18
18
  //#region services/core/src/session/session-service.d.ts
19
+ /**
20
+ * Host-supplied composition of the session service.
21
+ *
22
+ * Everything here belongs to the ownership authority, which is the one part of
23
+ * this service that cannot work from the bus alone: it has to know which
24
+ * machine it owns claims under, and how many runtimes may own claims there.
25
+ */
26
+ interface MakaioSessionServiceOptions {
27
+ /**
28
+ * Machine identity the ownership authority owns claims under.
29
+ *
30
+ * Injected by the composition root — the ownership key is (machine, adapter
31
+ * instance, provider session), and an authority that resolved its own machine
32
+ * identity through the bus would make every ownership decision depend on
33
+ * adapter-runtime boot order. Omitted, every identity-dependent ownership
34
+ * operation answers `machine-identity-unavailable` and writes nothing, which
35
+ * is the correct behavior for a host that has no machine identity to offer.
36
+ */
37
+ machineId?: string;
38
+ /**
39
+ * How many runtime processes may own claims on this machine. Defaults to
40
+ * `'shared-machine'`; a host claims `'machine-exclusive'` only when it can
41
+ * prove no peer process hosts adapters on the same machine.
42
+ */
43
+ topology?: OwnershipTopology;
44
+ }
19
45
  /**
20
46
  * Framework-core session service for managing makaio sessions.
21
47
  *
@@ -24,6 +50,12 @@ import * as _$_makaio_storage_core0 from "@makaio/framework/storage";
24
50
  * `session.turn.await`, `session.restartAgents`, `session.agent.added`, and
25
51
  * `session.agent.removed`.
26
52
  *
53
+ * It is also the **session-ownership authority**: the `session.ownership.*`
54
+ * operations, each of which is one durable ownership act, and the movement
55
+ * observer that settles every announced provider-session movement through them.
56
+ * That authority needs a machine identity, which the composition root injects
57
+ * (see {@link MakaioSessionServiceOptions}).
58
+ *
27
59
  * Host-specific handlers (search, update, resume, archive, purge, analytics,
28
60
  * context window, branching) are registered by the host session service which
29
61
  * depends on this service.
@@ -61,11 +93,26 @@ import * as _$_makaio_storage_core0 from "@makaio/framework/storage";
61
93
  * ```
62
94
  */
63
95
  declare class MakaioSessionService extends BaseService {
96
+ private readonly options;
97
+ private ownership;
98
+ /**
99
+ * Return the currently active ownership-authority incarnation.
100
+ *
101
+ * Read at adapter construction time rather than cached by the adapter
102
+ * subsystem, so reinitializing this service gives every subsequently created
103
+ * adapter the newly minted incarnation.
104
+ * @returns Active runtime-incarnation identity.
105
+ * @throws When the service has not initialized its authority.
106
+ */
107
+ requireOwnershipInstanceId(): string;
64
108
  /**
65
109
  * Creates a new MakaioSessionService instance.
66
110
  * @param bus - The event bus for inter-service communication
111
+ * @param options - Composition of the ownership authority; omitted entirely,
112
+ * the service still serves every non-ownership subject and declines the
113
+ * identity-dependent ownership ones.
67
114
  */
68
- constructor(bus?: IMakaioBus);
115
+ constructor(bus?: IMakaioBus, options?: MakaioSessionServiceOptions);
69
116
  /**
70
117
  * Initialize the service.
71
118
  *
@@ -80,6 +127,34 @@ declare class MakaioSessionService extends BaseService {
80
127
  * that do not register turn storage).
81
128
  */
82
129
  protected onInit(): Promise<void>;
130
+ /**
131
+ * Retire this process only after the adapter subsystem's earlier teardown has
132
+ * published its aggregate evidence.
133
+ *
134
+ * Reverse dependency ordering destroys the adapter subsystem first. The
135
+ * authority then closes admission, drains operations already admitted, and
136
+ * stamps retirement only when that published aggregate proves teardown was
137
+ * observed.
138
+ */
139
+ protected onDestroy(): Promise<void>;
140
+ /**
141
+ * Arm the ownership reconcile behind the post-coordinator barrier.
142
+ *
143
+ * Deliberately **not** run from `onInit`. This service starts inside the
144
+ * extension coordinator, and adapter instances register after it — so a
145
+ * reconcile here would probe adapters that do not exist yet and report every
146
+ * live claim's instance as gone. `kernel.phase.coordinatorReady` is broadcast
147
+ * once the coordinator has started everything, which is the first instant at
148
+ * which the probe means what it says.
149
+ *
150
+ * A host that never broadcasts the phase never reconciles: there is no timer
151
+ * and no fallback, because a reconcile at an unknown point in boot is exactly
152
+ * the thing this barrier exists to prevent. Failures are logged and swallowed
153
+ * for the same reason orphaned-turn reconciliation is — diagnostics must
154
+ * never keep a session service from starting.
155
+ * @returns Cleanup that unsubscribes the barrier if it never fires.
156
+ */
157
+ private scheduleOwnershipReconcile;
83
158
  /**
84
159
  * Close any turns left `active` from a prior process crash.
85
160
  *
@@ -94,6 +169,285 @@ declare class MakaioSessionService extends BaseService {
94
169
  private reconcileOrphanedTurns;
95
170
  }
96
171
  //#endregion
172
+ //#region services/core/src/session/ownership/context.d.ts
173
+ /**
174
+ * What the ownership authority was composed with.
175
+ *
176
+ * The machine identity is **injected, not resolved through the bus**. Resolving
177
+ * it per call would make every ownership decision depend on whether the adapter
178
+ * runtime happened to have registered its identity handler yet — a boot-order
179
+ * dependency the authority cannot observe and callers cannot reason about.
180
+ * Composed with `undefined`, the authority declines every identity-dependent
181
+ * operation instead of deciding under a guess.
182
+ */
183
+ interface OwnershipAuthorityContext {
184
+ /** Bus the authority reads and writes storage through. */
185
+ readonly bus: IMakaioBus;
186
+ /** Machine identity the authority owns claims under, or `undefined` when it has none. */
187
+ readonly machineId: string | undefined;
188
+ /** Runtime-incarnation identity stamped onto every generation this authority allocates. */
189
+ readonly instanceId: string;
190
+ /** {@inheritDoc OwnershipTopologySchema} */
191
+ readonly topology: OwnershipTopology;
192
+ }
193
+ //#endregion
194
+ //#region services/core/src/session/ownership/authority.d.ts
195
+ /**
196
+ * What the session-ownership authority is composed with.
197
+ *
198
+ * The same shape the operations receive, deliberately: what a caller composes
199
+ * the authority with *is* what every operation decides under, so there is no
200
+ * second declaration for the two to drift apart in.
201
+ */
202
+ interface SessionOwnershipAuthorityDeps extends Omit<OwnershipAuthorityContext, 'instanceId'> {
203
+ /** Runtime-incarnation identity, or a freshly minted identity in isolated compositions. */
204
+ readonly instanceId?: string;
205
+ }
206
+ /** Private lifecycle control for the locally composed ownership authority. */
207
+ interface OwnershipAuthorityHandle {
208
+ /** Identity stamped onto generations allocated by this authority. */
209
+ readonly instanceId: string;
210
+ /** Close admission, drain admitted operations, and retire on observed teardown. */
211
+ close(): Promise<void>;
212
+ }
213
+ /** Authority handlers and the private lifecycle control that owns them. */
214
+ interface RegisteredSessionOwnershipAuthority {
215
+ /** Idempotent handler cleanups for the containing service. */
216
+ readonly cleanups: readonly (() => void)[];
217
+ /** Private shutdown capability; deliberately not exposed as a bus subject. */
218
+ readonly ownership: OwnershipAuthorityHandle;
219
+ }
220
+ /**
221
+ * Register the session-ownership authority.
222
+ *
223
+ * These five subjects are the service surface of the ownership aggregate, and
224
+ * each one is exactly one durable ownership act. That is the point: composed by
225
+ * a caller out of storage RPCs, a reservation or a movement is three
226
+ * transactions with windows in which a crash strands an ownership key or
227
+ * publishes a currency no generation owns.
228
+ * @param deps - Bus, machine identity, topology and optional test identity.
229
+ * @returns Registered cleanups and the private retirement handle.
230
+ */
231
+ declare function registerSessionOwnershipAuthority(deps: SessionOwnershipAuthorityDeps): RegisteredSessionOwnershipAuthority;
232
+ //#endregion
233
+ //#region services/core/src/session/ownership/movement-observer.d.ts
234
+ /**
235
+ * Registers the provider-session movement observer.
236
+ *
237
+ * `agent.adapterSession.moved` is an **observation**, not a write. The seam
238
+ * reports where an agent's provider conversation went; what that implies for
239
+ * durable currency — which generation may record it, whether it supersedes
240
+ * anything, whether the session snapshot follows — is the ownership authority's
241
+ * to decide, inside one transaction. This handler's whole job is to turn the
242
+ * announcement into a settle request and to order the settles of one agent.
243
+ *
244
+ * **No lead guard.** A member's movement is now recorded on its own agent row,
245
+ * and the mirror onto the session row is gated inside the settle by the stored
246
+ * designation. The old handler had to drop a member's movement because the only
247
+ * row it could write was the session's; it also had to drop every movement
248
+ * announced during a start, because the designation did not exist yet. Both
249
+ * windows close here: the agent row always exists, and the reservation
250
+ * designates before the first dispatch.
251
+ *
252
+ * **No change guard.** Storage answers `idempotent` for a target that is
253
+ * already settled, which is a decision made against the stored row rather than
254
+ * against a snapshot this handler read a moment earlier.
255
+ *
256
+ * **The announcement is acknowledged, not absorbed.** `bus.emit` resolves when
257
+ * its handlers do, and the producer's seam contract reads that resolution as
258
+ * "the currency write already happened" — it is what lets a producer order the
259
+ * dispatch that abandons the old provider session behind the write, and what
260
+ * lets it hold an undelivered movement for re-announcement. So this handler
261
+ * waits for its queued settlement and answers honestly: it resolves only when
262
+ * the authority actually recorded the movement, and rejects with a
263
+ * {@link MovementNotSettledError} otherwise. Resolving on a refusal would let
264
+ * the producer retire a movement no row carries.
265
+ *
266
+ * Rejecting is the seam's negative acknowledgment, not an escaping failure: the
267
+ * one modeled error is what the producer catches and turns into `false`, and no
268
+ * other error leaves this handler unclassified.
269
+ * @param bus - Message bus used by the session service.
270
+ * @returns Cleanup function.
271
+ */
272
+ declare function registerAdapterSessionMovementObserver(bus: IMakaioBus): () => void;
273
+ //#endregion
274
+ //#region services/core/src/session/ownership/in-flight-starts.d.ts
275
+ /**
276
+ * What an attempt tells a joiner about the agent it was driving.
277
+ *
278
+ * One bit, because one bit is what every attempt can state honestly and what
279
+ * every joiner actually needs. The three attempts this seam carries — a fresh
280
+ * lead start, an attach, a reserved rehydrate — end in outcomes of three
281
+ * different shapes, and none of them is meaningful to a joiner that ran none of
282
+ * that work under none of those inputs. "Is there a connector for this agent
283
+ * now" is meaningful to all of them.
284
+ */
285
+ type StartAttemptOutcome = /** A connector for this agent is live, as far as this attempt got. */'connected'
286
+ /**
287
+ * The attempt ended without building one, and said so rather than throwing.
288
+ *
289
+ * The modeled non-successes: a recovery that deferred or was refused, a start
290
+ * that lost its designation race. They are *resolutions*, so a joiner watching
291
+ * only for a rejection cannot see them.
292
+ */
293
+ | 'no-connector';
294
+ /**
295
+ * One agent's start attempt, as a joinable handle.
296
+ *
297
+ * `settled` resolves — or rejects — when the attempt is completely over,
298
+ * including every failure-cleanup step, and it carries **the attempt's own
299
+ * verdict**. That is what a joiner reads.
300
+ *
301
+ * It did not always: joiners used to await the promise for its timing alone and
302
+ * then re-read the agent row. The row cannot answer the question. Where an
303
+ * attempt *writes* it the row is authoritative about the row — a fresh start's
304
+ * pre-dispatch failure deletes it, so mapping the rejection onto "dead" would
305
+ * contradict the deleted-row rule for one event — but the row was never a proxy
306
+ * for "a connector exists", and every place that treated it as one was one
307
+ * interleaving away from being wrong. A recovery that rolls its claim back to
308
+ * the `idle` it found leaves a row that reads *usable* behind an attempt that
309
+ * built nothing; an `idle` row whose connector died is exactly what the liveness
310
+ * probe exists to catch.
311
+ *
312
+ * So the division is: the attempt's verdict says whether a connector exists, and
313
+ * the row says what state the agent identity is in. A joiner needs both, and
314
+ * infers neither from the other. Where there is no entry to join — another
315
+ * process, or one that died — there is no verdict to read, and the status
316
+ * compare-and-swap arbitrates instead.
317
+ */
318
+ interface InFlightStart {
319
+ /** Settles when the attempt is over, carrying what it left behind. */
320
+ readonly settled: Promise<StartAttemptOutcome>;
321
+ }
322
+ /**
323
+ * One call's view of {@link runExclusiveStart}.
324
+ *
325
+ * The flag is what makes the seam usable by a caller that has durable work of
326
+ * its own to do around the dispatch. A joiner ran none of that work — the
327
+ * attempt it joined did, under *its* inputs — so a joiner that went on to
328
+ * persist its own adapter identity, or to settle the provider session *it*
329
+ * planned to resume, would overwrite the identity the running attempt actually
330
+ * established.
331
+ *
332
+ * What a joiner consumes instead is the attempt's own verdict — see
333
+ * {@link InFlightStart.settled} — together with the durable agent row, which
334
+ * says what state the identity is in but never whether a connector exists.
335
+ */
336
+ interface ExclusiveStart extends InFlightStart {
337
+ /**
338
+ * `true` when this call joined an attempt that was already running, and
339
+ * therefore ran no callback of its own.
340
+ */
341
+ readonly joined: boolean;
342
+ }
343
+ /**
344
+ * Register a start attempt for an agent and run it, so a concurrent consumer
345
+ * joins the attempt instead of racing it.
346
+ *
347
+ * The entry is published **before** `attempt` runs, and therefore before the
348
+ * attempt's first durable write. That ordering is the whole point: there is no
349
+ * instant at which a `starting` agent row is visible without its entry, so a
350
+ * joiner never has to guess whether an attempt is in progress here.
351
+ *
352
+ * Re-entering for an agent that already has an entry returns the existing one
353
+ * and does **not** run `attempt` — two lifecycle attempts for one agent
354
+ * identity are exactly what this seam exists to prevent. The returned handle
355
+ * says which of the two happened, because a caller whose `attempt` carries
356
+ * durable work must not repeat that work against inputs the running attempt
357
+ * never used (see {@link ExclusiveStart.joined}).
358
+ * @param agentId - Agent identity the attempt belongs to; the seam's key.
359
+ * @param attempt - The complete attempt, answering whether it left a connector
360
+ * behind, including its reservation, its
361
+ * persistence, its settlement and its failure cleanup. Nothing that can leave
362
+ * durable state behind may run outside it: a joiner runs none of it, and what
363
+ * sits outside would then run twice, once against the wrong inputs.
364
+ * @returns This call's handle — the attempt it registered, or the one it joined.
365
+ */
366
+ declare function runExclusiveStart(agentId: string, attempt: () => Promise<StartAttemptOutcome>): ExclusiveStart;
367
+ /**
368
+ * Look up an in-flight start without creating one.
369
+ *
370
+ * A consumer that finds an entry joins it. Finding none means the attempt
371
+ * belongs to a process that is gone, or to a live peer — neither of which this
372
+ * registry can see, so the caller arbitrates through the agent row's status
373
+ * compare-and-swap instead.
374
+ * @param agentId - Agent identity to look up.
375
+ * @returns The entry, or `undefined` when this process is not driving a start.
376
+ */
377
+ declare function peekInFlightStart(agentId: string): InFlightStart | undefined;
378
+ //#endregion
379
+ //#region services/core/src/session/ownership/settle-queue.d.ts
380
+ /**
381
+ * Serialize one agent's movement settlements, in receipt order.
382
+ *
383
+ * `bus.emit` runs handlers concurrently across independent producer chains —
384
+ * payload enrichment, connector-swap completion and turn-dispatch rotation all
385
+ * announce without a shared lock — so two movements for one agent otherwise
386
+ * interleave between the authority's revision read and its transaction, and
387
+ * both burn their single `currency-changed` retry against each other. Chaining
388
+ * per agent makes settle order equal receipt order, which is the strongest
389
+ * ordering an observation seam can offer: it does not claim producer order,
390
+ * only that what this process received first is settled first.
391
+ *
392
+ * The chain is keyed per agent rather than globally because two agents' currency
393
+ * rows share nothing — a global queue would serialize independent work and turn
394
+ * one slow settle into everyone's latency.
395
+ * @param agentId - Agent whose settles are being ordered.
396
+ * @param settle - The settle to run once every settle received earlier for this
397
+ * agent has finished.
398
+ * @returns A promise for this settle's own completion. It rejects if `settle`
399
+ * rejects; the chain itself absorbs the failure so queued successors still run.
400
+ */
401
+ declare function enqueueAgentSettle(agentId: string, settle: () => Promise<void>): Promise<void>;
402
+ //#endregion
403
+ //#region services/core/src/session/ownership/claim-token.d.ts
404
+ /**
405
+ * Mint the identity of one claim generation.
406
+ *
407
+ * The single way a generation identity comes into existence, whether the
408
+ * authority mints it or a caller mints one to name its own settlement with.
409
+ * Re-using a token whose generation is *retired* is a caller bug storage cannot
410
+ * defend against: retired generations are not remembered, so a released token
411
+ * is storable again and how it interacts with later generations is undefined.
412
+ * Re-offering an *unused* token — what the settle retry does — is not that: a
413
+ * rolled-back attempt left no row behind for it to collide with.
414
+ * @returns An opaque, single-use claim token.
415
+ */
416
+ declare function mintClaimToken(): string;
417
+ //#endregion
418
+ //#region services/core/src/session/ownership/owner-liveness.d.ts
419
+ /**
420
+ * Judge whether a claim's owner is gone — **for diagnostics only**.
421
+ *
422
+ * Reconcile is this function's sole caller, and the verdict it produces
423
+ * authorizes nothing: a takeover is a predicate evaluated inside the taking
424
+ * transaction, over the incumbent's own agent row, and it never consults a
425
+ * probe or a filed verdict. Keeping the assessment out of the authorization
426
+ * path is what makes the authorization impossible to base on evidence that is
427
+ * stale, replayed, or contradicted by a concurrent writer.
428
+ *
429
+ * Reasons are tested in order of how provable they are, and the first that
430
+ * holds is reported:
431
+ *
432
+ * - `agent-gone` — the agent row is absent. Rare, because both claim foreign
433
+ * keys cascade and normally remove the claim with its parent; kept because a
434
+ * diagnostic must report what it observes, and a probe can straddle a delete.
435
+ * - `agent-disposed` — the agent was removed. A disposed agent can never
436
+ * legitimately hold a key.
437
+ * - `owner-instance-retired` — storage proves the exact process that took this
438
+ * generation retired itself.
439
+ * - `adapter-instance-gone` — no adapter answers for the claim's instance.
440
+ * Admitted **only** under `machine-exclusive`: where peers may host adapters
441
+ * on the same machine, an unanswered probe means "not this runtime's", never
442
+ * "nobody's".
443
+ * @param bus - Bus used for the agent read and the adapter probe.
444
+ * @param topology - How many runtime processes may own claims on this machine;
445
+ * the one input that decides whether the adapter probe is evidence at all.
446
+ * @param claim - The claim whose owner is being assessed.
447
+ * @returns The first reason that holds, or `null` when the owner looks alive.
448
+ */
449
+ declare function assessClaimOwner(bus: IMakaioBus, topology: OwnershipTopology, claim: AdapterSessionClaimRecord): Promise<SessionOwnershipReclaimReason | null>;
450
+ //#endregion
97
451
  //#region services/core/src/session/session-service-handlers-core.d.ts
98
452
  /**
99
453
  * Dependencies required to register the framework-core session service handlers.
@@ -105,13 +459,37 @@ declare class MakaioSessionService extends BaseService {
105
459
  interface CoreSessionServiceHandlerDeps {
106
460
  /** The event bus used for handler registration and storage dispatch. */
107
461
  bus: IMakaioBus;
462
+ /**
463
+ * Machine identity the ownership authority owns claims under.
464
+ *
465
+ * Injected by the composition root, never resolved through the bus: an
466
+ * ownership decision must not depend on whether the adapter runtime's
467
+ * identity handler happened to register first. Absent, every
468
+ * identity-dependent ownership operation declines instead of guessing.
469
+ */
470
+ machineId?: string;
471
+ /**
472
+ * How many runtime processes may own claims on this machine. Defaults to
473
+ * `'shared-machine'` — the reading no host can be wrong about.
474
+ */
475
+ topology?: OwnershipTopology;
476
+ /** Runtime-incarnation identity stamped onto ownership generations. */
477
+ instanceId?: string;
478
+ }
479
+ /** Core handler cleanups plus the private ownership lifecycle handle. */
480
+ interface RegisteredCoreSessionServiceHandlers {
481
+ /** Cleanup callbacks for the containing service. */
482
+ readonly cleanups: readonly (() => void)[];
483
+ /** Private authority shutdown capability. */
484
+ readonly ownership: OwnershipAuthorityHandle;
108
485
  }
109
486
  /**
110
487
  * Registers the framework-core session service handlers:
111
488
  * `session.create`, `session.get`, `session.list`, `session.turn.await`,
112
489
  * `session.close`, `session.restartAgents`, `session.update`,
113
490
  * `session.archive`, `session.purge`,
114
- * `session.agent.added`, and `session.agent.removed`.
491
+ * `session.agent.added`, `session.agent.removed`, and the five
492
+ * `session.ownership.*` operations of the ownership authority.
115
493
  *
116
494
  * These handlers cover the minimal, load-bearing session contract for the
117
495
  * framework SDK. Host-specific handlers (search, resume, analytics, context
@@ -120,10 +498,10 @@ interface CoreSessionServiceHandlerDeps {
120
498
  * Persistence degrades gracefully when no storage handlers are registered:
121
499
  * `session.get` / `session.list` / `session.close` all delegate to
122
500
  * `SessionStorageSubjects.*` which may be unhandled in ephemeral mode.
123
- * @param deps - Bus dependency
124
- * @returns Array of cleanup callbacks, one per registered handler
501
+ * @param deps - Bus, plus the identity the ownership authority is composed with
502
+ * @returns Cleanup callbacks plus the private ownership lifecycle handle.
125
503
  */
126
- declare function registerCoreSessionServiceHandlers(deps: CoreSessionServiceHandlerDeps): Array<() => void>;
504
+ declare function registerCoreSessionServiceHandlers(deps: CoreSessionServiceHandlerDeps): RegisteredCoreSessionServiceHandlers;
127
505
  //#endregion
128
506
  //#region services/core/src/session/session-orchestrator.d.ts
129
507
  /**
@@ -138,46 +516,7 @@ interface ISessionOrchestrator {
138
516
  /** Stop the orchestrator and clean up all subscriptions. */
139
517
  destroy(): void;
140
518
  }
141
- /**
142
- * Slim framework session orchestrator.
143
- *
144
- * Composes with `SessionTurnManager` (turn lifecycle, usage accumulation,
145
- * completion), `AdapterRegistry` (adapterName to adapterId mapping), and the
146
- * adapter-subsystem reverse lookup for canonical `adapterId` to `adapterName`
147
- * validation when callers select a direct adapter instance.
148
- *
149
- * Registers the core session orchestration handlers:
150
- * 1. Get or create session (via `getOrCreateSession`)
151
- * 2. Start agent if session has no agents — resolves the canonical
152
- * `adapterName` from direct selections, uses `adapterId` directly when
153
- * provided, otherwise resolves it via `AdapterRegistry`, resolves
154
- * provider credentials when selected, then calls `AdapterSubjects.startAgent`
155
- * 3. Resolve target agents (via `resolveTargetAgents`)
156
- * 4. Verify agent liveness and build recovery context for dead agents
157
- * (requestOptional `AdapterSubjects.getAgent` + `buildRecoveryContext`)
158
- * 5. Get or create turn (via `SessionTurnManager`)
159
- * 6. Generate message ID and store user message (awaited, persist-before-route)
160
- * + routing records (fire-and-forget)
161
- * 7. Emit `session.turn.started` + `session.user_message.sent`
162
- * 8. Route to agents (via `routeToAgentsCore`, single shared context)
163
- * 9. Return result with `messageId`, `turnId`, `sessionId`
164
- *
165
- * Explicit `session.agent.attach` handlers share the same turn manager so
166
- * attach-time initial messages participate in the same completion lifecycle.
167
- *
168
- * Host-specific features (personas, MCP, execution targets, container spawn,
169
- * connector swap, CWD/model enforcement, fork context, TurnContextEnricher) are
170
- * handled by a host-provided orchestrator.
171
- * @example
172
- * ```typescript
173
- * const orchestrator = new SessionOrchestrator(MakaioBus, 'machine-id');
174
- *
175
- * const { messageId, turnId, sessionId } = await MakaioBus.request(
176
- * SessionSubjects.sendMessage,
177
- * { sessionId: crypto.randomUUID(), adapterName: 'openai-node', message: 'Hello!' },
178
- * );
179
- * ```
180
- */
519
+ /** Coordinates session sends, recovery and turn completion. */
181
520
  declare class SessionOrchestrator implements ISessionOrchestrator {
182
521
  private readonly bus;
183
522
  private readonly turnManager;
@@ -192,22 +531,28 @@ declare class SessionOrchestrator implements ISessionOrchestrator {
192
531
  * instance resolution).
193
532
  */
194
533
  constructor(bus: IMakaioBus | undefined, machineId: string);
534
+ /** Register the `session.sendMessage` RPC handler. */
535
+ private registerSendMessageHandler;
195
536
  /**
196
- * Register the `session.sendMessage` RPC handler.
537
+ * Start the session's lead agent, reserved and in the order §7.1 prescribes.
197
538
  *
198
- * Core flow:
199
- * 1. Get or create session
200
- * 2. Start agent if session has no agents (canonicalize direct selections,
201
- * resolve adapterId, resolve provider credentials, startAgent)
202
- * 3. Resolve target agents
203
- * 4. Verify agent liveness and build recovery context for dead agents
204
- * 5. Get or create turn (via SessionTurnManager)
205
- * 6. Generate message ID and store user message (awaited) + routing records (fire-and-forget)
206
- * 7. Emit turn.started + user_message.sent
207
- * 8. Route to agents (routeToAgentsCore, single shared context)
208
- * 9. Return result with messageId, turnId, sessionId
539
+ * Only the adapter selection is resolved here; the reordered start itself —
540
+ * mint the identity, register the attempt, persist the row, reserve, dispatch,
541
+ * settle, transition — lives in `startLeadAgent` so this class keeps only the
542
+ * selection knowledge that is genuinely orchestrator-owned.
543
+ *
544
+ * A lost designation race is not an error: the session now has the winner's
545
+ * agent, and this send continues against it. Only a session that *still* has
546
+ * no agents after the re-read has nothing to send to.
547
+ * @param session - Session being sent to; its agents and lead are updated in place.
548
+ * @param sessionId - Resolved session identity.
549
+ * @param agentSelection - Public agent selection from the request.
550
+ * @param message - User message, used as canonical-model prompt context.
551
+ * @param sessionContext - Session context passed through to the adapter.
552
+ * @param leadTransition - Whether this start creates or replaces the durable lead.
553
+ * @returns What the adopted agents need, empty unless a race was lost.
209
554
  */
210
- private registerSendMessageHandler;
555
+ private startLeadAgent;
211
556
  /**
212
557
  * Complete a turn by delegating to `SessionTurnManager`.
213
558
  *
@@ -221,37 +566,6 @@ declare class SessionOrchestrator implements ISessionOrchestrator {
221
566
  * Stop the orchestrator and clean up all subscriptions and composition utilities.
222
567
  */
223
568
  destroy(): void;
224
- /**
225
- * Resolve the adapter name for a direct adapter selection.
226
- *
227
- * Adapter startup and persisted identity require a stable adapter name.
228
- * When the caller provides `adapterId`, the framework validates any explicit
229
- * name against the adapter-subsystem reverse lookup and otherwise backfills the
230
- * canonical adapter name from that subsystem-owned mapping.
231
- * @param selection - Direct adapter selection
232
- * @param sessionId - Session ID used in error messages
233
- * @returns Resolved adapter name
234
- */
235
- private resolveAdapterName;
236
- /**
237
- * Resolve the public agent selection into the direct adapter shape required
238
- * by the framework orchestrator's startup path.
239
- * @param selection - Public session agent selection from the request.
240
- * @param sessionId - Session ID used for context and diagnostics.
241
- * @param message - User message used as canonical-model prompt context.
242
- * @param sessionContext - Optional session context passed through the request.
243
- * @returns Direct adapter selection for `adapter.startAgent`.
244
- */
245
- private resolveInitialAdapterSelection;
246
- /**
247
- * Resolve a framework-owned canonical-model selection to a direct adapter selection.
248
- * @param selection - Canonical model selection from the session request.
249
- * @param sessionId - Session ID used for context and diagnostics.
250
- * @param message - User message used as canonical-model prompt context.
251
- * @param sessionContext - Optional session context passed through the request.
252
- * @returns Direct adapter selection with resolved adapter, provider config, and model.
253
- */
254
- private resolveCanonicalModelSelection;
255
569
  }
256
570
  //#endregion
257
571
  //#region services/core/src/session/adapter-registry.d.ts
@@ -276,6 +590,11 @@ declare class AdapterRegistry {
276
590
  * the new `adapterId` silently overwrites the previous mapping. This is intentional:
277
591
  * adapters that restart emit a fresh initialized event and the registry should
278
592
  * reflect the latest instance.
593
+ *
594
+ * Every initialization announcement carries the machine that hosts the exact
595
+ * adapter ID, so event fallback may serve only that same scope. The unscoped
596
+ * entry remains for legacy observers that intentionally make no ownership
597
+ * assertion.
279
598
  * @param bus - The event bus to listen on
280
599
  */
281
600
  constructor(bus: IMakaioBus);
@@ -294,10 +613,18 @@ declare class AdapterRegistry {
294
613
  * keeps legacy event-driven tests and observers useful, but session routing
295
614
  * must prefer the replayable request seam so a session created after adapter
296
615
  * initialization does not miss a one-time event.
616
+ * **Naming the machine is what makes the answer usable as an ownership key.**
617
+ * An instance ID is derived from `(machineId, adapterName)`, so a caller that
618
+ * will reserve or settle under a particular machine has to resolve for that
619
+ * same machine — otherwise the instance it dispatches to and the namespace it
620
+ * claims in come from two different identities and the key protects nothing.
621
+ * Omitted, the resolver derives the runtime's own, which is what a caller with
622
+ * no machine of its own to act for wants.
297
623
  * @param adapterName - Adapter type name (e.g., `'openai-node'`)
624
+ * @param machineId - Machine to resolve the instance for; omit for the runtime's own.
298
625
  * @returns Adapter runtime identifier for bus routing.
299
626
  */
300
- resolveAvailable(adapterName: string): Promise<string>;
627
+ resolveAvailable(adapterName: string, machineId?: string): Promise<string>;
301
628
  /** Stop listening to `adapter.initialized` events and clear the registry. */
302
629
  destroy(): void;
303
630
  }
@@ -382,41 +709,148 @@ declare function resolveTargetAgents(session: IMakaioSession, targetSpec: string
382
709
  */
383
710
  declare function findTurnByAgent(activeTurns: Map<string, Turn$1>, agentId: string): Turn$1 | undefined;
384
711
  //#endregion
385
- //#region services/core/src/session/utils/resolution.d.ts
712
+ //#region services/core/src/session/utils/start-reservation.d.ts
713
+ /** Adapter identity sufficient to route every reservation to one authority. */
714
+ type ReservationAdapterInstance = OwnedAdapterInstance & {
715
+ readonly ownerInstanceId: string;
716
+ };
717
+ /** What every start reservation names, whatever role it takes. */
718
+ interface StartReservationIdentity {
719
+ /** Session the agent belongs to; verified against the agent row by the authority. */
720
+ readonly sessionId: string;
721
+ /** Agent the reservation is taken for. */
722
+ readonly agentId: string;
723
+ /** Adapter type name carried onto any claim for diagnostics. */
724
+ readonly adapterName: string;
725
+ /** Instance the dispatch addresses, and the machine its ownership acts are filed under. */
726
+ readonly instance: ReservationAdapterInstance;
727
+ /** Provider session to reserve, or `null` for a start with no key yet. */
728
+ readonly resumeProviderSessionId: string | null;
729
+ /** Caller-minted identity for the reservation generation. */
730
+ readonly claimToken: string;
731
+ }
386
732
  /**
387
- * Resolve adapterName → adapterId for bus routing.
388
- * Queries the adapters table for a local enabled instance.
389
- * @param bus - Bus instance
390
- * @param adapterName - Adapter type name
391
- * @param machineId - Optional machine ID for deterministic local resolution
392
- * @returns Canonical adapter ID for bus routing
393
- * @throws if no enabled instance found for this adapterName
733
+ * The designation half, as a union rather than an optional field.
734
+ *
735
+ * A lead reservation is a compare-and-swap and must name the exact value the
736
+ * caller read; `null` is a legitimate observation ("the session named no lead")
737
+ * and therefore cannot double as "not supplied". Modelling it as one optional
738
+ * field would make the authority's own refusal — *`expectedLeadAgentId` is
739
+ * required when role is `'lead'`* — reachable from these four callers, which is
740
+ * exactly what a union makes impossible to write.
394
741
  */
395
- declare function resolveAdapterId(bus: IMakaioBus, adapterName: string, machineId?: string): Promise<string>;
742
+ type StartReservationDesignation = {
743
+ /** This start designates the session's lead. */readonly role: Extract<AgentRole, 'lead'>; /** Lead the caller observed on the session row, or `null` when it named none. */
744
+ readonly expectedLeadAgentId: string | null;
745
+ } | {
746
+ /** This start leaves the designation untouched. */readonly role: Exclude<AgentRole, 'lead'>;
747
+ };
748
+ /** Everything a start reservation names beyond the instance it runs against. */
749
+ type StartReservationRequest = StartReservationIdentity & StartReservationDesignation & {
750
+ /** Atomic snapshot for a member recovery; absent for ordinary starts. */readonly recoveryGuard?: SessionOwnershipRecoveryGuard; /** Opaque fence for this guarded recovery attempt. */
751
+ readonly recoveryAttemptId?: string;
752
+ };
753
+ /**
754
+ * Take one start reservation.
755
+ *
756
+ * Issued as a **hard** request by every caller, and that is deliberate rather
757
+ * than incidental: a host that can dispatch a start and cannot reserve one is a
758
+ * broken composition, not a lightweight one, and a degrade here would make that
759
+ * misconfiguration indistinguishable from a supported topology. Each caller owns
760
+ * what a throw means for its own rollback, so no attempt is made to classify it
761
+ * here.
762
+ * @param bus - Bus the reservation is issued on.
763
+ * @param request - Identity, instance, role and resume target of the start being reserved for.
764
+ * @returns What the authority answered, verbatim.
765
+ */
766
+ declare function reserveStartFor(bus: IMakaioBus, request: StartReservationRequest): Promise<SessionOwnershipReserveStartServiceResult>;
767
+ //#endregion
768
+ //#region services/core/src/session/recovery-plan.d.ts
396
769
  /**
397
- * Resolve supported reasoning levels for a model from provider definitions.
770
+ * Continue the agent's existing provider conversation.
398
771
  *
399
- * Looks up the provider config by ID, finds the provider definition it belongs to,
400
- * then finds the model's `supportedReasoningLevels` in the provider's `availableModels`
401
- * catalog.
402
- * @param bus - Bus instance for RPC calls
403
- * @param providerConfigId - Canonical provider config ID (ProviderConfigRecord.id)
404
- * @param model - Model identifier to look up in the provider's catalog
405
- * @returns Object with `supportedReasoningLevels` when found, or `undefined` when not resolvable
772
+ * The provider still holds the conversation, so history must **not** be
773
+ * injected — the model would see every prior message twice.
774
+ */
775
+ interface NativeResumeRecoveryPlan {
776
+ readonly kind: 'native-resume';
777
+ /** Provider session the replacement connector resumes. */
778
+ readonly resumeAdapterSessionId: string;
779
+ }
780
+ /**
781
+ * Start a fresh provider session and inject the stored conversation.
782
+ *
783
+ * This is the "warm-fresh" case named in the session-locality design: the agent
784
+ * record survives, but its provider conversation does not — either because the
785
+ * provider session is unreachable (foreign machine, unsupported adapter,
786
+ * unconfirmed movement) or because the agent never had a confirmed one. The
787
+ * caller owns history injection; without it the model starts blank on a session
788
+ * that visibly has prior turns.
406
789
  */
407
- declare function resolveModelCapabilities(bus: IMakaioBus, providerConfigId: string | undefined, model: string | undefined): Promise<{
408
- supportedReasoningLevels?: ReasoningLevelMap;
409
- } | undefined>;
790
+ interface FreshWithHistoryRecoveryPlan {
791
+ readonly kind: 'fresh-with-history';
792
+ }
410
793
  /**
411
- * Resolves the effective execution target for a session.
412
- * Priority: explicit executionTargetId → system default (local).
413
- * @param bus - Makaio bus instance
414
- * @param params - Resolution parameters from session context
415
- * @returns Resolved execution target
794
+ * How one agent regains its conversation when its connector is gone.
795
+ *
796
+ * Produced by {@link planAgentRecovery} (or taken as
797
+ * {@link FRESH_WITH_HISTORY_RECOVERY_PLAN} where no provider session can exist)
798
+ * and read back through {@link recoveryPlanResumeTarget} and
799
+ * {@link recoveryPlanRequiresHistory}, so the rehydrate call and the history
800
+ * routing cannot drift apart.
801
+ */
802
+ type RecoveryPlan = NativeResumeRecoveryPlan | FreshWithHistoryRecoveryPlan;
803
+ /**
804
+ * The fresh-with-history plan.
805
+ *
806
+ * Shared frozen instance: the variant carries no per-agent data, and a single
807
+ * instance keeps call sites from implying that it does.
416
808
  */
417
- declare function resolveExecutionTarget(bus: IMakaioBus, params: {
418
- executionTargetId?: string;
419
- }): Promise<ExecutionTarget>;
809
+ declare const FRESH_WITH_HISTORY_RECOVERY_PLAN: FreshWithHistoryRecoveryPlan;
810
+ /**
811
+ * Derive the recovery plan for one agent from its locality verdict.
812
+ *
813
+ * Native resume requires both halves of the gate:
814
+ * - the verdict is `native` — this machine owns the provider session store, the
815
+ * adapter can resume, and the resume currency is intact; and
816
+ * - the agent's own settled currency names a provider session.
817
+ *
818
+ * A native verdict with no resolved currency stays fresh-with-history. The
819
+ * verdict is computed from session-level structural signals, so borrowing
820
+ * another agent's provider session to satisfy it would attach two agents to one
821
+ * provider conversation.
822
+ *
823
+ * **The target is settled currency, not an origin column.** Callers resolve it
824
+ * through `resolveAgentResumeIdentity`, which follows a movement the ownership
825
+ * seam settled onto the agent row; the immutable `adapterSessionId` records only
826
+ * where the conversation started. Passing the raw column here would evaluate the
827
+ * verdict against the currency and then resume the pre-movement session anyway.
828
+ * @param verdict - Native locality verdict evaluated for this agent
829
+ * @param agentAdapterSessionId - Resume currency resolved for this agent, or `undefined` when nothing is resumable
830
+ * @returns Native-resume plan when both halves of the gate hold, fresh-with-history otherwise
831
+ */
832
+ declare function planAgentRecovery(verdict: NativeLocalityVerdict, agentAdapterSessionId: string | undefined): RecoveryPlan;
833
+ /**
834
+ * Resume target the plan hands to `adapter.rehydrateAgent`.
835
+ * @param plan - Recovery plan decided for this agent
836
+ * @returns Provider session to resume, or `undefined` for a fresh replacement connector
837
+ */
838
+ declare function recoveryPlanResumeTarget(plan: RecoveryPlan): string | undefined;
839
+ /**
840
+ * Whether the caller must inject the stored conversation alongside the rehydrate.
841
+ *
842
+ * Exactly the inverse of {@link recoveryPlanResumeTarget} being defined — stated
843
+ * as its own predicate so the history side reads the decision instead of
844
+ * re-deriving it from the absence of a resume target.
845
+ *
846
+ * Declared as a type predicate rather than left to inference: a caller that
847
+ * returns early on history keeps a `native-resume` plan afterwards, and that
848
+ * narrowing is part of what this function promises. Inferring it would make the
849
+ * promise depend on the checker's version rather than on the signature.
850
+ * @param plan - Recovery plan decided for this agent
851
+ * @returns `true` when the replacement connector starts without provider-side history
852
+ */
853
+ declare function recoveryPlanRequiresHistory(plan: RecoveryPlan): plan is FreshWithHistoryRecoveryPlan;
420
854
  //#endregion
421
855
  //#region services/core/src/session/utils/recovery-context.d.ts
422
856
  /**
@@ -430,6 +864,19 @@ declare function resolveExecutionTarget(bus: IMakaioBus, params: {
430
864
  * @returns SessionContext with messageHistory and isFirstTurn signal
431
865
  */
432
866
  declare function buildRecoveryContext(bus: IMakaioBus, session: IMakaioSession): Promise<SessionContext>;
867
+ /**
868
+ * Build the session context a recovery plan calls for.
869
+ *
870
+ * This is the history half of the recovery contract: it consumes the same
871
+ * {@link RecoveryPlan} the rehydrate call consumes, so a natively resumed agent
872
+ * can never also be handed the conversation the provider already holds, and a
873
+ * fresh-with-history agent can never start blank.
874
+ * @param bus - Bus instance
875
+ * @param session - Session whose conversation is projected
876
+ * @param plan - Recovery plan decided for the agents being recovered
877
+ * @returns Full-history context for a fresh-with-history plan, `undefined` for native resume
878
+ */
879
+ declare function buildPlannedRecoveryContext(bus: IMakaioBus, session: IMakaioSession, plan: RecoveryPlan): Promise<SessionContext | undefined>;
433
880
  //#endregion
434
881
  //#region services/core/src/session/utils/agent-recovery.d.ts
435
882
  /**
@@ -441,14 +888,34 @@ interface RecoveryConfig {
441
888
  /** Model identifier (e.g., 'claude-sonnet-4-20250514', 'gpt-4o') */
442
889
  model?: string;
443
890
  /**
444
- * Provider-native session ID to resume.
891
+ * Whether the replacement connector resumes the provider conversation or
892
+ * starts fresh and receives the stored conversation as injected history.
893
+ *
894
+ * Required, and required to be the same value the caller feeds to its history
895
+ * assembly (via `buildPlannedRecoveryContext`): the two halves of a
896
+ * recovery are only correct together. Deciding native resume here while
897
+ * building history there replays the conversation into a provider session that
898
+ * already holds it; deciding fresh here without building history there starts
899
+ * the model blank on a session with prior turns.
900
+ *
901
+ * Locality evaluation belongs to the caller — see `planAgentRecovery`.
902
+ */
903
+ plan: RecoveryPlan;
904
+ /**
905
+ * Machine identity every ownership act of this recovery names.
445
906
  *
446
- * When set, the adapter creates the connector in native-resume mode so the
447
- * provider session continues from where it left off. The caller is responsible
448
- * for evaluating locality (machine identity, adapter capability, CWD match)
449
- * before setting this field.
907
+ * A recovery reserves and settles under a machine, and addresses an adapter
908
+ * instance that is derived from one — so both have to come from the *same*
909
+ * identity or the key they build is one no other actor computes. Supplying it
910
+ * is therefore not an optimisation: without it the instance is resolved for
911
+ * this runtime's own machine (or falls back to the agent's persisted one)
912
+ * while the authority files the acts under its default, which is the mixed key
913
+ * the aggregate exists to prevent.
914
+ *
915
+ * Omitted when the caller cannot target a real machine. Such a recovery is
916
+ * deferred before it can dispatch a connector.
450
917
  */
451
- resumeAdapterSessionId?: string;
918
+ machineId?: string;
452
919
  }
453
920
  /**
454
921
  * Ensure agent cwd matches desired cwd, swapping connector if needed.
@@ -492,18 +959,48 @@ declare function ensureAgentModel(bus: IMakaioBus, agent: MakaioSessionAgent, de
492
959
  changed: true;
493
960
  swapped: boolean;
494
961
  }>;
962
+ /**
963
+ * What a liveness-and-recovery pass leaves its caller with.
964
+ *
965
+ * Three sets rather than two, because a recovery can now end in a third state:
966
+ * the agent's provider session is held by a generation this runtime does not
967
+ * own, so no connector was built and none may be. The helper **names** that set
968
+ * and decides nothing with it — it has no session, no orchestrator and no way
969
+ * to start anything, and what a product does without those agents differs per
970
+ * product.
971
+ */
972
+ interface VerifiedAgents {
973
+ /** Agents this runtime may drive. */
974
+ readonly usable: MakaioSessionAgent[];
975
+ /** Agents recovered during this call. */
976
+ readonly recoveredAgentIds: Set<string>;
977
+ /**
978
+ * Agents this runtime may **not** drive: their provider session is held by a
979
+ * generation it does not own (I23a). Never empty-able by retrying — the
980
+ * caller must decide what its product does without them.
981
+ */
982
+ readonly deferredAgentIds: Set<string>;
983
+ }
495
984
  /**
496
985
  * Verify liveness of agents and recover any that are dead.
497
- * Queries each agent via getAgent; if unresponsive, triggers connector swap via recoverAgent.
986
+ * Queries each agent via getAgent; if unresponsive, triggers a reserved
987
+ * rehydrate via recoverAgent.
988
+ *
989
+ * The caller's `recoveryConfig.plan` applies to every agent recovered in this
990
+ * batch and must be the same plan the caller feeds to its history assembly.
991
+ *
992
+ * The **adapter instance is resolved per agent**, inside the exclusive recovery
993
+ * attempt, and not once for the batch: a batch may span adapters, and a
994
+ * persisted `adapterId` goes stale across a runtime restart or failover.
995
+ * Resolving per agent is what keeps each rehydrate addressed to the live
996
+ * instance that actually owns that agent's adapter, and keeps a single
997
+ * unresolvable adapter from deciding the batch.
498
998
  * @param bus - Bus instance
499
999
  * @param agents - Agents to verify
500
- * @param recoveryConfig - Configuration for recovering dead agents
501
- * @returns Verified/recovered agents and set of recovered agent IDs
1000
+ * @param recoveryConfig - Configuration for recovering dead agents, including the shared recovery plan
1001
+ * @returns Usable agents, the ones recovered here, and the ones this runtime may not drive
502
1002
  */
503
- declare function verifyAndRecoverAgents(bus: IMakaioBus, agents: MakaioSessionAgent[], recoveryConfig: RecoveryConfig): Promise<{
504
- verifiedAgents: MakaioSessionAgent[];
505
- recoveredAgentIds: Set<string>;
506
- }>;
1003
+ declare function verifyAndRecoverAgents(bus: IMakaioBus, agents: MakaioSessionAgent[], recoveryConfig: RecoveryConfig): Promise<VerifiedAgents>;
507
1004
  /**
508
1005
  * Build recovery context and apply optional additional transforms.
509
1006
  * @param bus - Bus instance
@@ -514,18 +1011,45 @@ declare function verifyAndRecoverAgents(bus: IMakaioBus, agents: MakaioSessionAg
514
1011
  declare function buildRecoveryContextWithPipeline(bus: IMakaioBus, session: IMakaioSession, options?: {
515
1012
  pipeline?: PipelineStep[];
516
1013
  }): Promise<SessionContext>;
1014
+ /** How one agent's recovery ended, for a caller that has a fallback for neither. */
1015
+ type AgentRecoveryOutcome = /** A connector is live again; the agent carries the instance it now lives on. */{
1016
+ readonly kind: 'recovered';
1017
+ readonly agent: MakaioSessionAgent;
1018
+ }
1019
+ /**
1020
+ * This runtime may not drive the agent: its provider session is held by a
1021
+ * generation it does not own. Nothing was dispatched and nothing may be.
1022
+ */
1023
+ | {
1024
+ readonly kind: 'deferred';
1025
+ readonly reason: 'occupied' | 'machine-identity-unavailable';
1026
+ };
517
1027
  /**
518
- * Recover a dead agent by triggering connector swap via the adapter.
1028
+ * Recover a dead agent under the ownership authority.
519
1029
  * The agent keeps its identity — no session mutation needed.
520
1030
  *
521
1031
  * Context delivery happens via the normal sendMessage path that follows
522
1032
  * recovery (same handler invocation). No staging needed.
1033
+ *
1034
+ * Every invocation that wins the exclusive seam reads the canonical recovery
1035
+ * snapshot and resolves its live adapter instance itself. A join can leave a
1036
+ * different status, binding, or holder generation behind, so carrying any of
1037
+ * those planning facts into a self-reentry would make its guarded reservation
1038
+ * describe the attempt it joined rather than the row it is about to claim.
1039
+ *
1040
+ * The reserved rehydrate runs inside the in-flight-start seam, so a concurrent
1041
+ * consumer that finds this agent mid-recovery joins the attempt instead of
1042
+ * starting a second lifecycle for the same identity — and consumes that join
1043
+ * through the shared seam, which classifies the row the attempt left behind
1044
+ * rather than reading its own success into the absence of a rejection.
523
1045
  * @param bus - Bus instance
524
- * @param deadAgent - The dead agent to recover
1046
+ * @param deadAgent - The dead agent to recover; its `adapterId` is re-stamped to the instance the
1047
+ * attempt actually used
525
1048
  * @param recoveryConfig - Configuration for the recovered connector
526
- * @returns Same agent reference — identity preserved
1049
+ * @returns The recovered agent, or the statement that this runtime may not drive it
1050
+ * @throws Whatever {@link failedRehydrateError} raises when the recovery failed rather than deferred
527
1051
  */
528
- declare function recoverAgent(bus: IMakaioBus, deadAgent: MakaioSessionAgent, recoveryConfig: RecoveryConfig): Promise<MakaioSessionAgent>;
1052
+ declare function recoverAgent(bus: IMakaioBus, deadAgent: MakaioSessionAgent, recoveryConfig: RecoveryConfig): Promise<AgentRecoveryOutcome>;
529
1053
  //#endregion
530
1054
  //#region services/core/src/session/utils/turn-initiator.d.ts
531
1055
  /**
@@ -540,6 +1064,119 @@ declare function recoverAgent(bus: IMakaioBus, deadAgent: MakaioSessionAgent, re
540
1064
  */
541
1065
  declare function buildTurnInitiator(source: 'extension' | 'user' | 'system' | undefined, extensionId: string | undefined): TurnInitiator;
542
1066
  //#endregion
1067
+ //#region services/core/src/session/handlers/lead-start-request.d.ts
1068
+ /** Fully-owned payload supplied to a host-specific lead-start dispatcher. */
1069
+ type LeadStartDispatchRequest = StartAgentRequest & {
1070
+ /** Framework-minted identity of this exact attempt. */readonly agentId: string; /** Runtime incarnation selected by the ownership reservation. */
1071
+ readonly ownerInstanceId: string;
1072
+ };
1073
+ /**
1074
+ * Host-specific transport policy for one already-reserved lead start.
1075
+ *
1076
+ * The callback may choose how the request reaches the selected adapter, but it
1077
+ * does not own identity, persistence, reservation, settlement, or cleanup.
1078
+ */
1079
+ type LeadStartDispatch = (request: LeadStartDispatchRequest) => Promise<StartAgentResponse>;
1080
+ /** Whether this start creates the first lead or replaces an existing one. */
1081
+ type LeadTransition = {
1082
+ readonly kind: 'fresh';
1083
+ } | {
1084
+ readonly kind: 'replace';
1085
+ };
1086
+ /** Everything a lead transition needs beyond the payload it dispatches. */
1087
+ interface LeadStartRequest {
1088
+ /** Session the agent is started into. */
1089
+ readonly sessionId: string;
1090
+ /** Machine-scoped adapter runtime selected for dispatch and ownership. */
1091
+ readonly instance: MachineScopedAdapterInstance;
1092
+ /** Adapter type name, carried onto the agent row and any claim. */
1093
+ readonly adapterName: string;
1094
+ /** Provider config to stamp on the agent's runtime row once the start lands. */
1095
+ readonly providerConfigId?: string;
1096
+ /** Persona identity persisted before the adapter can create a connector. */
1097
+ readonly personaId?: string;
1098
+ /** Profile identity persisted before the adapter can create a connector. */
1099
+ readonly profileId?: string;
1100
+ /** Explicit lifecycle transition; never inferred from designation identity. */
1101
+ readonly leadTransition: LeadTransition;
1102
+ /** Lead designation the caller observed before entering the reservation. */
1103
+ readonly expectedLeadAgentId: string | null;
1104
+ /** Adapter payload, complete except for the attempt identity minted by this service. */
1105
+ readonly startRequest: StartAgentRequest;
1106
+ /** Optional host transport policy; the bus request remains the default. */
1107
+ readonly dispatch?: LeadStartDispatch;
1108
+ }
1109
+ /** How a lead transition ended, for the caller that has a send to continue. */
1110
+ type LeadStartResult = {
1111
+ /** The agent is live, owns its provider session and is `idle` in storage. */outcome: 'started'; /** The agent row as it now stands, for the caller's in-memory session. */
1112
+ agent: MakaioSessionAgent;
1113
+ } | {
1114
+ /** Another start won the designation race and this attempt left nothing behind. */outcome: 'lead-conflict'; /** Lead the session actually names, or `null` when it has none. */
1115
+ currentLeadAgentId: string | null;
1116
+ };
1117
+ //#endregion
1118
+ //#region services/core/src/session/handlers/lead-start.d.ts
1119
+ /**
1120
+ * Start or replace a session lead under the ownership reservation.
1121
+ *
1122
+ * The whole attempt runs inside the in-flight-start seam, registered *before*
1123
+ * the agent row is written. There is therefore no instant at which a `starting`
1124
+ * row is visible without an entry a concurrent consumer can join, which is what
1125
+ * lets that consumer wait for this attempt instead of opening a second
1126
+ * lifecycle for the same identity.
1127
+ * @param bus - Bus every step is issued on.
1128
+ * @param request - The start to run.
1129
+ * @returns The started agent, or the designation race this start lost.
1130
+ */
1131
+ declare function startLeadAgent(bus: IMakaioBus, request: LeadStartRequest): Promise<LeadStartResult>;
1132
+ //#endregion
1133
+ //#region services/core/src/session/session-orchestrator-selection.d.ts
1134
+ /** What resolving a fresh start's instance needs beyond the selection itself. */
1135
+ interface SelectionInstanceContext {
1136
+ /** Adapter type name already resolved for the selection. */
1137
+ readonly adapterName: string;
1138
+ /** Session identity, for the refusal message. */
1139
+ readonly sessionId: string;
1140
+ /** This runtime's machine identity, used when it resolves the instance itself. */
1141
+ readonly machineId: string;
1142
+ /** Registry that resolves an adapter name to a live instance for a named machine. */
1143
+ readonly registry: Pick<AdapterRegistry, 'resolveAvailable'>;
1144
+ }
1145
+ /**
1146
+ * Resolve the instance a fresh lead start dispatches to, together with the
1147
+ * machine every one of its ownership acts names.
1148
+ *
1149
+ * **A fresh start always has a machine, and that is what closes the last hole
1150
+ * in the degrade matrix.** Its *reservation* is keyless and therefore cannot
1151
+ * see the machine's absence — but its *settlement* is keyed, on the provider
1152
+ * session the connector confirms, so an unnamed machine surfaced there as an
1153
+ * outcome no caller on this path had a policy for. Naming the machine here
1154
+ * removes the case by construction rather than by a new branch.
1155
+ *
1156
+ * Two shapes, and the asymmetry is deliberate:
1157
+ *
1158
+ * - **No instance named:** resolve one for this runtime's own machine, and
1159
+ * hand that same machine to the start. The instance ID is derived from
1160
+ * `(machineId, adapterName)`, so passing one identity to the resolution and
1161
+ * the other to the start is the mixed key; passing the same value to both is
1162
+ * what makes them provably agree.
1163
+ * - **An instance named:** its machine comes from the caller, because the
1164
+ * derivation is one-way and this runtime must not invent one.
1165
+ *
1166
+ * **A selection that named one half without the other is refused before either
1167
+ * branch runs**, by the rule {@link describeHalfNamedInstanceRefusal} states for
1168
+ * every path that reads the pair. Refusing first is what makes the two branches
1169
+ * above total: each one holds a pair it can honour, so neither has to decide what
1170
+ * to do with half of one.
1171
+ * @param bus - Bus the resolution is issued on.
1172
+ * @param selection - Direct adapter selection this start runs from.
1173
+ * @param context - Adapter name, session identity, this runtime's machine and its instance registry.
1174
+ * @returns The instance and the machine, as one key.
1175
+ * @throws A {@link SessionStartError} when an identity is incomplete or its
1176
+ * complete explicit triple has no matching live announcement.
1177
+ */
1178
+ declare function resolveSelectionOwnedInstance(bus: IMakaioBus, selection: AdapterSelection, context: SelectionInstanceContext): Promise<MachineScopedAdapterInstance>;
1179
+ //#endregion
543
1180
  //#region services/core/src/session/context-window/types.d.ts
544
1181
  /**
545
1182
  * Context window tracking types for per-session aggregation.
@@ -763,6 +1400,60 @@ declare function registerListActionsHandler(bus: IMakaioBus): () => void;
763
1400
  * or contains only whitespace
764
1401
  */
765
1402
  declare function normalizeSelectionString(value: string | undefined): string | undefined;
1403
+ /** What a caller may know about the instance a selection named, once normalized. */
1404
+ interface NamedSelectionInstance {
1405
+ /** Instance the selection named, or `undefined` when it named none. */
1406
+ readonly adapterId: string | undefined;
1407
+ /** Machine the selection named, or `undefined` when it named none. */
1408
+ readonly machineId: string | undefined;
1409
+ }
1410
+ /** Session identity and the prefix a caller's own messages carry. */
1411
+ interface SelectionRefusalContext {
1412
+ /** Session the selection was submitted for, for the refusal message. */
1413
+ readonly sessionId: string;
1414
+ /** Prefix of the caller's own error messages; include the trailing space. */
1415
+ readonly errorPrefix: string;
1416
+ }
1417
+ /**
1418
+ * Explain why a selection naming one half of the instance/machine pair must be
1419
+ * refused rather than served.
1420
+ *
1421
+ * **One rule, every path that reads the pair.** An instance ID is a one-way hash
1422
+ * of `(machineId, adapterName)`, so the two halves are only ever honest together:
1423
+ *
1424
+ * - **A machine and no instance** cannot be served, because resolving an instance
1425
+ * without one named derives it for the runtime doing the resolving. Honouring
1426
+ * the name is not what that derivation does, and ignoring it starts the agent
1427
+ * here while the caller believes it chose a host.
1428
+ * - **An instance and no machine** cannot be completed, because the derivation
1429
+ * cannot be inverted. Filling the gap with the resolving runtime's own machine
1430
+ * files every ownership act under a key no other actor computes — it collides
1431
+ * with nothing, so it protects nothing, while the runtime that really owns the
1432
+ * instance claims the same provider session beside it.
1433
+ *
1434
+ * **Stated once, thrown by each caller in its own error form**, because the paths
1435
+ * that read the pair do not share one: a start refuses with a typed start error, an
1436
+ * attach with its own handler error. Returning the reason rather than throwing it
1437
+ * is what lets the rule be one rule without making the paths converge on an error
1438
+ * type none of them owns.
1439
+ *
1440
+ * **Needed as well as the selection schema**, whose two refinements forbid both
1441
+ * shapes: payload validation returns early in production builds and in-process
1442
+ * callers reach these paths with an unparsed selection, so the schema is a guard
1443
+ * against *writing* such a caller while this is what an existing one meets.
1444
+ *
1445
+ * **No path is exempt, including the one that looked like it had a softer answer.**
1446
+ * An attach used to serve a named instance with no machine as a locality degrade,
1447
+ * on the grounds that a fresh-with-history conversation is still worth offering.
1448
+ * The degraded attach still starts, and its settlement still files the confirmed
1449
+ * provider session under the resolving runtime's machine while the dispatch
1450
+ * addressed the named instance — so the softer answer was the mis-key, taken one
1451
+ * step later.
1452
+ * @param named - Normalized instance and machine the selection named
1453
+ * @param context - Session identity and the prefix of the caller's own messages
1454
+ * @returns The refusal, or `undefined` when the selection named both halves or neither
1455
+ */
1456
+ declare function describeHalfNamedInstanceRefusal(named: NamedSelectionInstance, context: SelectionRefusalContext): string | undefined;
766
1457
  /**
767
1458
  * Resolve the canonical `adapterName` for a given deterministic `adapterId`,
768
1459
  * rejecting when the caller-supplied name does not match the subsystem lookup.
@@ -977,7 +1668,20 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
977
1668
  adapterId: z.ZodString;
978
1669
  adapterName: z.ZodString;
979
1670
  sessionId: z.ZodString;
1671
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
1672
+ machineId: z.ZodString;
1673
+ instanceId: z.ZodString;
1674
+ }, z.core.$strip>>;
1675
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
980
1676
  adapterSessionId: z.ZodOptional<z.ZodString>;
1677
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
1678
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
1679
+ confirmed: "confirmed";
1680
+ moved: "moved";
1681
+ inherited: "inherited";
1682
+ }>>;
1683
+ revision: z.ZodOptional<z.ZodNumber>;
1684
+ currencyFence: z.ZodOptional<z.ZodNumber>;
981
1685
  model: z.ZodOptional<z.ZodString>;
982
1686
  cwd: z.ZodOptional<z.ZodString>;
983
1687
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -998,6 +1702,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
998
1702
  status: z.ZodEnum<{
999
1703
  idle: "idle";
1000
1704
  active: "active";
1705
+ starting: "starting";
1001
1706
  dead: "dead";
1002
1707
  disposed: "disposed";
1003
1708
  }>;
@@ -1009,6 +1714,14 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1009
1714
  /**
1010
1715
  * Store or update an agent.
1011
1716
  *
1717
+ * A whole-record write of a caller-held snapshot, so on an *existing* row it
1718
+ * may not carry every column: the ownership columns and the origin provider
1719
+ * session stay with the stored row, and a stored `disposed` status wins over
1720
+ * the snapshot's. Disposal is the agent's removal and is terminal (see
1721
+ * `updateStatus`); a snapshot read before it must not revive the row. On a
1722
+ * fresh row there is nothing to protect and the caller's record is stored
1723
+ * verbatim.
1724
+ *
1012
1725
  * Subject: `storage:agent.set`
1013
1726
  * Type: Request (RPC)
1014
1727
  */
@@ -1020,7 +1733,20 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1020
1733
  adapterId: z.ZodString;
1021
1734
  adapterName: z.ZodString;
1022
1735
  sessionId: z.ZodString;
1736
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
1737
+ machineId: z.ZodString;
1738
+ instanceId: z.ZodString;
1739
+ }, z.core.$strip>>;
1740
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1023
1741
  adapterSessionId: z.ZodOptional<z.ZodString>;
1742
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
1743
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
1744
+ confirmed: "confirmed";
1745
+ moved: "moved";
1746
+ inherited: "inherited";
1747
+ }>>;
1748
+ revision: z.ZodOptional<z.ZodNumber>;
1749
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1024
1750
  model: z.ZodOptional<z.ZodString>;
1025
1751
  cwd: z.ZodOptional<z.ZodString>;
1026
1752
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1041,6 +1767,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1041
1767
  status: z.ZodEnum<{
1042
1768
  idle: "idle";
1043
1769
  active: "active";
1770
+ starting: "starting";
1044
1771
  dead: "dead";
1045
1772
  disposed: "disposed";
1046
1773
  }>;
@@ -1079,6 +1806,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1079
1806
  all: "all";
1080
1807
  idle: "idle";
1081
1808
  active: "active";
1809
+ starting: "starting";
1082
1810
  dead: "dead";
1083
1811
  disposed: "disposed";
1084
1812
  }>>;
@@ -1089,7 +1817,20 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1089
1817
  adapterId: z.ZodString;
1090
1818
  adapterName: z.ZodString;
1091
1819
  sessionId: z.ZodString;
1820
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
1821
+ machineId: z.ZodString;
1822
+ instanceId: z.ZodString;
1823
+ }, z.core.$strip>>;
1824
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1092
1825
  adapterSessionId: z.ZodOptional<z.ZodString>;
1826
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
1827
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
1828
+ confirmed: "confirmed";
1829
+ moved: "moved";
1830
+ inherited: "inherited";
1831
+ }>>;
1832
+ revision: z.ZodOptional<z.ZodNumber>;
1833
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1093
1834
  model: z.ZodOptional<z.ZodString>;
1094
1835
  cwd: z.ZodOptional<z.ZodString>;
1095
1836
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1110,6 +1851,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1110
1851
  status: z.ZodEnum<{
1111
1852
  idle: "idle";
1112
1853
  active: "active";
1854
+ starting: "starting";
1113
1855
  dead: "dead";
1114
1856
  disposed: "disposed";
1115
1857
  }>;
@@ -1134,7 +1876,20 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1134
1876
  adapterId: z.ZodString;
1135
1877
  adapterName: z.ZodString;
1136
1878
  sessionId: z.ZodString;
1879
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
1880
+ machineId: z.ZodString;
1881
+ instanceId: z.ZodString;
1882
+ }, z.core.$strip>>;
1883
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1137
1884
  adapterSessionId: z.ZodOptional<z.ZodString>;
1885
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
1886
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
1887
+ confirmed: "confirmed";
1888
+ moved: "moved";
1889
+ inherited: "inherited";
1890
+ }>>;
1891
+ revision: z.ZodOptional<z.ZodNumber>;
1892
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1138
1893
  model: z.ZodOptional<z.ZodString>;
1139
1894
  cwd: z.ZodOptional<z.ZodString>;
1140
1895
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1155,6 +1910,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1155
1910
  status: z.ZodEnum<{
1156
1911
  idle: "idle";
1157
1912
  active: "active";
1913
+ starting: "starting";
1158
1914
  dead: "dead";
1159
1915
  disposed: "disposed";
1160
1916
  }>;
@@ -1164,7 +1920,15 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1164
1920
  }, z.core.$strip>;
1165
1921
  };
1166
1922
  /**
1167
- * Update agent status.
1923
+ * Update agent status, optionally as a compare-and-swap.
1924
+ *
1925
+ * **`disposed` is terminal.** A row that already carries it never transitions
1926
+ * again, whatever `status` or `expectedStatus` the call names. Disposal is
1927
+ * the agent's removal, and ownership authority is a predicate over the agent
1928
+ * row: a status revived to `idle` would let a removed agent reserve and
1929
+ * settle again. Enforcing it here — rather than asking every lifecycle writer
1930
+ * to check first — is what makes the guarantee hold against a removal that
1931
+ * lands mid-start or mid-rehydrate.
1168
1932
  *
1169
1933
  * Subject: `storage:agent.updateStatus`
1170
1934
  * Type: Request (RPC)
@@ -1175,12 +1939,21 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1175
1939
  status: z.ZodEnum<{
1176
1940
  idle: "idle";
1177
1941
  active: "active";
1942
+ starting: "starting";
1178
1943
  dead: "dead";
1179
1944
  disposed: "disposed";
1180
1945
  }>;
1946
+ expectedStatus: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1947
+ idle: "idle";
1948
+ active: "active";
1949
+ starting: "starting";
1950
+ dead: "dead";
1951
+ disposed: "disposed";
1952
+ }>>>;
1181
1953
  }, z.core.$strip>;
1182
1954
  response: z.ZodObject<{
1183
1955
  success: z.ZodBoolean;
1956
+ transitioned: z.ZodBoolean;
1184
1957
  }, z.core.$strip>;
1185
1958
  };
1186
1959
  /**
@@ -1201,6 +1974,11 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1201
1974
  /**
1202
1975
  * Update runtime-mutable agent fields without full record overwrite.
1203
1976
  *
1977
+ * The agent's ownership columns (currency pair, revision, fence) are
1978
+ * deliberately not expressible here: they may only be written under a claim
1979
+ * generation, through the `storage:sessionOwnership` seam. `adapterSessionId`
1980
+ * below is the immutable *origin* identity, not the currency.
1981
+ *
1204
1982
  * Subject: `storage:agent.updateRuntime`
1205
1983
  * Type: Request (RPC)
1206
1984
  */
@@ -1208,6 +1986,10 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1208
1986
  request: z.ZodObject<{
1209
1987
  agentId: z.ZodString;
1210
1988
  adapterId: z.ZodOptional<z.ZodString>;
1989
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
1990
+ machineId: z.ZodString;
1991
+ instanceId: z.ZodString;
1992
+ }, z.core.$strip>>;
1211
1993
  adapterSessionId: z.ZodOptional<z.ZodString>;
1212
1994
  cwd: z.ZodOptional<z.ZodString>;
1213
1995
  model: z.ZodOptional<z.ZodString>;
@@ -1300,8 +2082,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1300
2082
  }, {}, {
1301
2083
  length: number | undefined;
1302
2084
  }>;
1303
- adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1304
- name: "adapter_session_id";
2085
+ ownerMachineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2086
+ name: "owner_machine_id";
1305
2087
  tableName: "agents";
1306
2088
  dataType: "string";
1307
2089
  columnType: "SQLiteText";
@@ -1319,8 +2101,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1319
2101
  }, {}, {
1320
2102
  length: number | undefined;
1321
2103
  }>;
1322
- model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1323
- name: "model";
2104
+ ownerInstanceId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2105
+ name: "owner_instance_id";
1324
2106
  tableName: "agents";
1325
2107
  dataType: "string";
1326
2108
  columnType: "SQLiteText";
@@ -1338,8 +2120,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1338
2120
  }, {}, {
1339
2121
  length: number | undefined;
1340
2122
  }>;
1341
- cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1342
- name: "cwd";
2123
+ recoveryAttemptId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2124
+ name: "recovery_attempt_id";
1343
2125
  tableName: "agents";
1344
2126
  dataType: "string";
1345
2127
  columnType: "SQLiteText";
@@ -1357,27 +2139,27 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1357
2139
  }, {}, {
1358
2140
  length: number | undefined;
1359
2141
  }>;
1360
- allowedDirectories: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1361
- name: string;
2142
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2143
+ name: "adapter_session_id";
1362
2144
  tableName: "agents";
1363
- dataType: "json";
1364
- columnType: "SQLiteTextJson";
1365
- data: string[];
2145
+ dataType: "string";
2146
+ columnType: "SQLiteText";
2147
+ data: string;
1366
2148
  driverParam: string;
1367
2149
  notNull: false;
1368
2150
  hasDefault: false;
1369
2151
  isPrimaryKey: false;
1370
2152
  isAutoincrement: false;
1371
2153
  hasRuntimeDefault: false;
1372
- enumValues: undefined;
2154
+ enumValues: [string, ...string[]];
1373
2155
  baseColumn: never;
1374
2156
  identity: undefined;
1375
2157
  generated: undefined;
1376
2158
  }, {}, {
1377
- $type: string[];
2159
+ length: number | undefined;
1378
2160
  }>;
1379
- providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1380
- name: "provider_config_id";
2161
+ currentAdapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2162
+ name: "current_adapter_session_id";
1381
2163
  tableName: "agents";
1382
2164
  dataType: "string";
1383
2165
  columnType: "SQLiteText";
@@ -1395,27 +2177,61 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1395
2177
  }, {}, {
1396
2178
  length: number | undefined;
1397
2179
  }>;
1398
- personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1399
- name: "persona_id";
2180
+ currentAdapterSessionIdState: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2181
+ name: "current_adapter_session_id_state";
1400
2182
  tableName: "agents";
1401
2183
  dataType: "string";
1402
2184
  columnType: "SQLiteText";
1403
- data: string;
2185
+ data: "confirmed" | "moved" | "inherited";
1404
2186
  driverParam: string;
1405
- notNull: false;
1406
- hasDefault: false;
2187
+ notNull: true;
2188
+ hasDefault: true;
1407
2189
  isPrimaryKey: false;
1408
2190
  isAutoincrement: false;
1409
2191
  hasRuntimeDefault: false;
1410
- enumValues: [string, ...string[]];
2192
+ enumValues: ["inherited", "moved", "confirmed"];
1411
2193
  baseColumn: never;
1412
2194
  identity: undefined;
1413
2195
  generated: undefined;
1414
2196
  }, {}, {
1415
2197
  length: number | undefined;
1416
2198
  }>;
1417
- profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1418
- name: "profile_id";
2199
+ revision: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2200
+ name: string;
2201
+ tableName: "agents";
2202
+ dataType: "number";
2203
+ columnType: "SQLiteInteger";
2204
+ data: number;
2205
+ driverParam: number;
2206
+ notNull: true;
2207
+ hasDefault: true;
2208
+ isPrimaryKey: false;
2209
+ isAutoincrement: false;
2210
+ hasRuntimeDefault: false;
2211
+ enumValues: undefined;
2212
+ baseColumn: never;
2213
+ identity: undefined;
2214
+ generated: undefined;
2215
+ }, {}, {}>;
2216
+ currencyFence: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2217
+ name: string;
2218
+ tableName: "agents";
2219
+ dataType: "number";
2220
+ columnType: "SQLiteInteger";
2221
+ data: number;
2222
+ driverParam: number;
2223
+ notNull: true;
2224
+ hasDefault: true;
2225
+ isPrimaryKey: false;
2226
+ isAutoincrement: false;
2227
+ hasRuntimeDefault: false;
2228
+ enumValues: undefined;
2229
+ baseColumn: never;
2230
+ identity: undefined;
2231
+ generated: undefined;
2232
+ }, {}, {}>;
2233
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2234
+ name: "model";
1419
2235
  tableName: "agents";
1420
2236
  dataType: "string";
1421
2237
  columnType: "SQLiteText";
@@ -1433,8 +2249,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1433
2249
  }, {}, {
1434
2250
  length: number | undefined;
1435
2251
  }>;
1436
- harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1437
- name: "harness_id";
2252
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2253
+ name: "cwd";
1438
2254
  tableName: "agents";
1439
2255
  dataType: "string";
1440
2256
  columnType: "SQLiteText";
@@ -1452,27 +2268,27 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1452
2268
  }, {}, {
1453
2269
  length: number | undefined;
1454
2270
  }>;
1455
- clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1456
- name: "client_id";
2271
+ allowedDirectories: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2272
+ name: string;
1457
2273
  tableName: "agents";
1458
- dataType: "string";
1459
- columnType: "SQLiteText";
1460
- data: string;
2274
+ dataType: "json";
2275
+ columnType: "SQLiteTextJson";
2276
+ data: string[];
1461
2277
  driverParam: string;
1462
2278
  notNull: false;
1463
2279
  hasDefault: false;
1464
2280
  isPrimaryKey: false;
1465
2281
  isAutoincrement: false;
1466
2282
  hasRuntimeDefault: false;
1467
- enumValues: [string, ...string[]];
2283
+ enumValues: undefined;
1468
2284
  baseColumn: never;
1469
2285
  identity: undefined;
1470
2286
  generated: undefined;
1471
2287
  }, {}, {
1472
- length: number | undefined;
2288
+ $type: string[];
1473
2289
  }>;
1474
- compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1475
- name: "compression_mode";
2290
+ providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2291
+ name: "provider_config_id";
1476
2292
  tableName: "agents";
1477
2293
  dataType: "string";
1478
2294
  columnType: "SQLiteText";
@@ -1490,9 +2306,104 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1490
2306
  }, {}, {
1491
2307
  length: number | undefined;
1492
2308
  }>;
1493
- role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1494
- name: "role";
1495
- tableName: "agents";
2309
+ personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2310
+ name: "persona_id";
2311
+ tableName: "agents";
2312
+ dataType: "string";
2313
+ columnType: "SQLiteText";
2314
+ data: string;
2315
+ driverParam: string;
2316
+ notNull: false;
2317
+ hasDefault: false;
2318
+ isPrimaryKey: false;
2319
+ isAutoincrement: false;
2320
+ hasRuntimeDefault: false;
2321
+ enumValues: [string, ...string[]];
2322
+ baseColumn: never;
2323
+ identity: undefined;
2324
+ generated: undefined;
2325
+ }, {}, {
2326
+ length: number | undefined;
2327
+ }>;
2328
+ profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2329
+ name: "profile_id";
2330
+ tableName: "agents";
2331
+ dataType: "string";
2332
+ columnType: "SQLiteText";
2333
+ data: string;
2334
+ driverParam: string;
2335
+ notNull: false;
2336
+ hasDefault: false;
2337
+ isPrimaryKey: false;
2338
+ isAutoincrement: false;
2339
+ hasRuntimeDefault: false;
2340
+ enumValues: [string, ...string[]];
2341
+ baseColumn: never;
2342
+ identity: undefined;
2343
+ generated: undefined;
2344
+ }, {}, {
2345
+ length: number | undefined;
2346
+ }>;
2347
+ harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2348
+ name: "harness_id";
2349
+ tableName: "agents";
2350
+ dataType: "string";
2351
+ columnType: "SQLiteText";
2352
+ data: string;
2353
+ driverParam: string;
2354
+ notNull: false;
2355
+ hasDefault: false;
2356
+ isPrimaryKey: false;
2357
+ isAutoincrement: false;
2358
+ hasRuntimeDefault: false;
2359
+ enumValues: [string, ...string[]];
2360
+ baseColumn: never;
2361
+ identity: undefined;
2362
+ generated: undefined;
2363
+ }, {}, {
2364
+ length: number | undefined;
2365
+ }>;
2366
+ clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2367
+ name: "client_id";
2368
+ tableName: "agents";
2369
+ dataType: "string";
2370
+ columnType: "SQLiteText";
2371
+ data: string;
2372
+ driverParam: string;
2373
+ notNull: false;
2374
+ hasDefault: false;
2375
+ isPrimaryKey: false;
2376
+ isAutoincrement: false;
2377
+ hasRuntimeDefault: false;
2378
+ enumValues: [string, ...string[]];
2379
+ baseColumn: never;
2380
+ identity: undefined;
2381
+ generated: undefined;
2382
+ }, {}, {
2383
+ length: number | undefined;
2384
+ }>;
2385
+ compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2386
+ name: "compression_mode";
2387
+ tableName: "agents";
2388
+ dataType: "string";
2389
+ columnType: "SQLiteText";
2390
+ data: string;
2391
+ driverParam: string;
2392
+ notNull: false;
2393
+ hasDefault: false;
2394
+ isPrimaryKey: false;
2395
+ isAutoincrement: false;
2396
+ hasRuntimeDefault: false;
2397
+ enumValues: [string, ...string[]];
2398
+ baseColumn: never;
2399
+ identity: undefined;
2400
+ generated: undefined;
2401
+ }, {}, {
2402
+ length: number | undefined;
2403
+ }>;
2404
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2405
+ name: "role";
2406
+ tableName: "agents";
1496
2407
  dataType: "string";
1497
2408
  columnType: "SQLiteText";
1498
2409
  data: "lead" | "member";
@@ -1514,14 +2425,14 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1514
2425
  tableName: "agents";
1515
2426
  dataType: "string";
1516
2427
  columnType: "SQLiteText";
1517
- data: "idle" | "active" | "dead" | "disposed";
2428
+ data: "idle" | "active" | "starting" | "dead" | "disposed";
1518
2429
  driverParam: string;
1519
2430
  notNull: true;
1520
2431
  hasDefault: false;
1521
2432
  isPrimaryKey: false;
1522
2433
  isAutoincrement: false;
1523
2434
  hasRuntimeDefault: false;
1524
- enumValues: ["idle", "active", "dead", "disposed"];
2435
+ enumValues: ["starting", "idle", "active", "dead", "disposed"];
1525
2436
  baseColumn: never;
1526
2437
  identity: undefined;
1527
2438
  generated: undefined;
@@ -1587,7 +2498,20 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1587
2498
  adapterId: z.ZodString;
1588
2499
  adapterName: z.ZodString;
1589
2500
  sessionId: z.ZodString;
2501
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
2502
+ machineId: z.ZodString;
2503
+ instanceId: z.ZodString;
2504
+ }, z.core.$strip>>;
2505
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1590
2506
  adapterSessionId: z.ZodOptional<z.ZodString>;
2507
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
2508
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
2509
+ confirmed: "confirmed";
2510
+ moved: "moved";
2511
+ inherited: "inherited";
2512
+ }>>;
2513
+ revision: z.ZodOptional<z.ZodNumber>;
2514
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1591
2515
  model: z.ZodOptional<z.ZodString>;
1592
2516
  cwd: z.ZodOptional<z.ZodString>;
1593
2517
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1608,6 +2532,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1608
2532
  status: z.ZodEnum<{
1609
2533
  idle: "idle";
1610
2534
  active: "active";
2535
+ starting: "starting";
1611
2536
  dead: "dead";
1612
2537
  disposed: "disposed";
1613
2538
  }>;
@@ -1619,6 +2544,14 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1619
2544
  /**
1620
2545
  * Store or update an agent.
1621
2546
  *
2547
+ * A whole-record write of a caller-held snapshot, so on an *existing* row it
2548
+ * may not carry every column: the ownership columns and the origin provider
2549
+ * session stay with the stored row, and a stored `disposed` status wins over
2550
+ * the snapshot's. Disposal is the agent's removal and is terminal (see
2551
+ * `updateStatus`); a snapshot read before it must not revive the row. On a
2552
+ * fresh row there is nothing to protect and the caller's record is stored
2553
+ * verbatim.
2554
+ *
1622
2555
  * Subject: `storage:agent.set`
1623
2556
  * Type: Request (RPC)
1624
2557
  */
@@ -1630,7 +2563,20 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1630
2563
  adapterId: z.ZodString;
1631
2564
  adapterName: z.ZodString;
1632
2565
  sessionId: z.ZodString;
2566
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
2567
+ machineId: z.ZodString;
2568
+ instanceId: z.ZodString;
2569
+ }, z.core.$strip>>;
2570
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1633
2571
  adapterSessionId: z.ZodOptional<z.ZodString>;
2572
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
2573
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
2574
+ confirmed: "confirmed";
2575
+ moved: "moved";
2576
+ inherited: "inherited";
2577
+ }>>;
2578
+ revision: z.ZodOptional<z.ZodNumber>;
2579
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1634
2580
  model: z.ZodOptional<z.ZodString>;
1635
2581
  cwd: z.ZodOptional<z.ZodString>;
1636
2582
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1651,6 +2597,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1651
2597
  status: z.ZodEnum<{
1652
2598
  idle: "idle";
1653
2599
  active: "active";
2600
+ starting: "starting";
1654
2601
  dead: "dead";
1655
2602
  disposed: "disposed";
1656
2603
  }>;
@@ -1689,6 +2636,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1689
2636
  all: "all";
1690
2637
  idle: "idle";
1691
2638
  active: "active";
2639
+ starting: "starting";
1692
2640
  dead: "dead";
1693
2641
  disposed: "disposed";
1694
2642
  }>>;
@@ -1699,7 +2647,20 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1699
2647
  adapterId: z.ZodString;
1700
2648
  adapterName: z.ZodString;
1701
2649
  sessionId: z.ZodString;
2650
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
2651
+ machineId: z.ZodString;
2652
+ instanceId: z.ZodString;
2653
+ }, z.core.$strip>>;
2654
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1702
2655
  adapterSessionId: z.ZodOptional<z.ZodString>;
2656
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
2657
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
2658
+ confirmed: "confirmed";
2659
+ moved: "moved";
2660
+ inherited: "inherited";
2661
+ }>>;
2662
+ revision: z.ZodOptional<z.ZodNumber>;
2663
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1703
2664
  model: z.ZodOptional<z.ZodString>;
1704
2665
  cwd: z.ZodOptional<z.ZodString>;
1705
2666
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1720,6 +2681,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1720
2681
  status: z.ZodEnum<{
1721
2682
  idle: "idle";
1722
2683
  active: "active";
2684
+ starting: "starting";
1723
2685
  dead: "dead";
1724
2686
  disposed: "disposed";
1725
2687
  }>;
@@ -1744,7 +2706,20 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1744
2706
  adapterId: z.ZodString;
1745
2707
  adapterName: z.ZodString;
1746
2708
  sessionId: z.ZodString;
2709
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
2710
+ machineId: z.ZodString;
2711
+ instanceId: z.ZodString;
2712
+ }, z.core.$strip>>;
2713
+ recoveryAttemptId: z.ZodOptional<z.ZodString>;
1747
2714
  adapterSessionId: z.ZodOptional<z.ZodString>;
2715
+ currentAdapterSessionId: z.ZodOptional<z.ZodString>;
2716
+ currentAdapterSessionIdState: z.ZodOptional<z.ZodEnum<{
2717
+ confirmed: "confirmed";
2718
+ moved: "moved";
2719
+ inherited: "inherited";
2720
+ }>>;
2721
+ revision: z.ZodOptional<z.ZodNumber>;
2722
+ currencyFence: z.ZodOptional<z.ZodNumber>;
1748
2723
  model: z.ZodOptional<z.ZodString>;
1749
2724
  cwd: z.ZodOptional<z.ZodString>;
1750
2725
  allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1765,6 +2740,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1765
2740
  status: z.ZodEnum<{
1766
2741
  idle: "idle";
1767
2742
  active: "active";
2743
+ starting: "starting";
1768
2744
  dead: "dead";
1769
2745
  disposed: "disposed";
1770
2746
  }>;
@@ -1774,7 +2750,15 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1774
2750
  }, z.core.$strip>;
1775
2751
  };
1776
2752
  /**
1777
- * Update agent status.
2753
+ * Update agent status, optionally as a compare-and-swap.
2754
+ *
2755
+ * **`disposed` is terminal.** A row that already carries it never transitions
2756
+ * again, whatever `status` or `expectedStatus` the call names. Disposal is
2757
+ * the agent's removal, and ownership authority is a predicate over the agent
2758
+ * row: a status revived to `idle` would let a removed agent reserve and
2759
+ * settle again. Enforcing it here — rather than asking every lifecycle writer
2760
+ * to check first — is what makes the guarantee hold against a removal that
2761
+ * lands mid-start or mid-rehydrate.
1778
2762
  *
1779
2763
  * Subject: `storage:agent.updateStatus`
1780
2764
  * Type: Request (RPC)
@@ -1785,12 +2769,21 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1785
2769
  status: z.ZodEnum<{
1786
2770
  idle: "idle";
1787
2771
  active: "active";
2772
+ starting: "starting";
1788
2773
  dead: "dead";
1789
2774
  disposed: "disposed";
1790
2775
  }>;
2776
+ expectedStatus: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2777
+ idle: "idle";
2778
+ active: "active";
2779
+ starting: "starting";
2780
+ dead: "dead";
2781
+ disposed: "disposed";
2782
+ }>>>;
1791
2783
  }, z.core.$strip>;
1792
2784
  response: z.ZodObject<{
1793
2785
  success: z.ZodBoolean;
2786
+ transitioned: z.ZodBoolean;
1794
2787
  }, z.core.$strip>;
1795
2788
  };
1796
2789
  /**
@@ -1811,6 +2804,11 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1811
2804
  /**
1812
2805
  * Update runtime-mutable agent fields without full record overwrite.
1813
2806
  *
2807
+ * The agent's ownership columns (currency pair, revision, fence) are
2808
+ * deliberately not expressible here: they may only be written under a claim
2809
+ * generation, through the `storage:sessionOwnership` seam. `adapterSessionId`
2810
+ * below is the immutable *origin* identity, not the currency.
2811
+ *
1814
2812
  * Subject: `storage:agent.updateRuntime`
1815
2813
  * Type: Request (RPC)
1816
2814
  */
@@ -1818,6 +2816,10 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1818
2816
  request: z.ZodObject<{
1819
2817
  agentId: z.ZodString;
1820
2818
  adapterId: z.ZodOptional<z.ZodString>;
2819
+ runtimeOwner: z.ZodOptional<z.ZodObject<{
2820
+ machineId: z.ZodString;
2821
+ instanceId: z.ZodString;
2822
+ }, z.core.$strip>>;
1821
2823
  adapterSessionId: z.ZodOptional<z.ZodString>;
1822
2824
  cwd: z.ZodOptional<z.ZodString>;
1823
2825
  model: z.ZodOptional<z.ZodString>;
@@ -1830,13 +2832,50 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1830
2832
  };
1831
2833
  }>, "storage:agent">;
1832
2834
  //#endregion
2835
+ //#region services/core/src/session/storage/memory-store.d.ts
2836
+ /**
2837
+ * In-memory backing state shared by the session, agent and ownership memory handlers.
2838
+ *
2839
+ * Extracting the maps from their individual handler closures is what allows the
2840
+ * ownership handler to read and mutate agent and session rows written by the other
2841
+ * two handlers — a property that cannot be achieved with three disconnected private
2842
+ * `Map` instances. Pass one `SessionStorageMemoryState` to all three `register*`
2843
+ * functions to make them share the same rows.
2844
+ */
2845
+ interface SessionStorageMemoryState {
2846
+ /** Session rows keyed by `sessionId`. */
2847
+ readonly sessions: Map<string, IMakaioSession>;
2848
+ /** Agent rows keyed by `agentId`. */
2849
+ readonly agents: Map<string, MakaioSessionAgent>;
2850
+ /** Claim rows keyed by `claimId`. */
2851
+ readonly claims: Map<string, AdapterSessionClaimRecord>;
2852
+ /** Runtime-instance rows keyed by the process/machine pair. */
2853
+ readonly runtimeInstances: Map<string, RuntimeInstanceRecord>;
2854
+ }
2855
+ /**
2856
+ * Allocate a fresh, empty in-memory state instance.
2857
+ *
2858
+ * Each call returns an independent set of maps. Pass the same instance to all
2859
+ * three memory handler registrations when they must share the same rows; pass
2860
+ * separate instances to isolate them (the default when no state is supplied).
2861
+ * @returns A new `SessionStorageMemoryState` with empty maps
2862
+ */
2863
+ declare function createSessionStorageMemoryState(): SessionStorageMemoryState;
2864
+ //#endregion
1833
2865
  //#region services/core/src/session/storage/memory-handler.d.ts
1834
2866
  /**
1835
2867
  * Register in-memory session storage handlers.
1836
2868
  *
1837
2869
  * Suitable for development, testing, and single-instance deployments.
1838
2870
  * Data is lost when the process exits.
2871
+ *
2872
+ * Pass a shared `SessionStorageMemoryState` to make this handler operate on the
2873
+ * same rows as `registerMemoryAgentStorage` and
2874
+ * `registerMemorySessionOwnershipStorage`. Omit it (or pass `undefined`) to get
2875
+ * an isolated, private store — the default, which preserves backward
2876
+ * compatibility for callers that do not need cross-handler state sharing.
1839
2877
  * @param bus - The bus instance to register handlers on
2878
+ * @param state - Shared in-memory state; defaults to a new isolated instance
1840
2879
  * @returns Cleanup function to unsubscribe all handlers
1841
2880
  * @example
1842
2881
  * ```typescript
@@ -1848,7 +2887,7 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1848
2887
  * cleanup();
1849
2888
  * ```
1850
2889
  */
1851
- declare function registerMemorySessionStorage(bus: IMakaioBus): () => void;
2890
+ declare function registerMemorySessionStorage(bus: IMakaioBus, state?: SessionStorageMemoryState): () => void;
1852
2891
  //#endregion
1853
2892
  //#region services/core/src/session/storage/drizzle-handler.d.ts
1854
2893
  /**
@@ -1887,10 +2926,17 @@ declare function registerDrizzleSessionStorage(bus: IMakaioBus, db: MakaioDataba
1887
2926
  * Register in-memory agent storage handlers.
1888
2927
  *
1889
2928
  * Suitable for development and testing. Data is lost when the process exits.
2929
+ *
2930
+ * Pass a shared `SessionStorageMemoryState` to make this handler operate on the
2931
+ * same rows as `registerMemorySessionStorage` and
2932
+ * `registerMemorySessionOwnershipStorage`. Omit it (or pass `undefined`) to get
2933
+ * an isolated, private store — the default, which preserves backward
2934
+ * compatibility for callers that do not need cross-handler state sharing.
1890
2935
  * @param bus - The bus instance to register handlers on
2936
+ * @param state - Shared in-memory state; defaults to a new isolated instance
1891
2937
  * @returns Cleanup function to unsubscribe all handlers
1892
2938
  */
1893
- declare function registerMemoryAgentStorage(bus: IMakaioBus): () => void;
2939
+ declare function registerMemoryAgentStorage(bus: IMakaioBus, state?: SessionStorageMemoryState): () => void;
1894
2940
  //#endregion
1895
2941
  //#region services/core/src/session/storage/schema.variants.d.ts
1896
2942
  /** Dialect variants for the session storage tables. */
@@ -1957,7 +3003,7 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
1957
3003
  tableName: "sessions";
1958
3004
  dataType: "string";
1959
3005
  columnType: "SQLiteText";
1960
- data: "discovered" | "closed" | "active" | "archived";
3006
+ data: "closed" | "discovered" | "active" | "archived";
1961
3007
  driverParam: string;
1962
3008
  notNull: true;
1963
3009
  hasDefault: false;
@@ -2123,6 +3169,44 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2123
3169
  }, {}, {
2124
3170
  length: number | undefined;
2125
3171
  }>;
3172
+ currentAdapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3173
+ name: "current_adapter_session_id";
3174
+ tableName: "sessions";
3175
+ dataType: "string";
3176
+ columnType: "SQLiteText";
3177
+ data: string;
3178
+ driverParam: string;
3179
+ notNull: false;
3180
+ hasDefault: false;
3181
+ isPrimaryKey: false;
3182
+ isAutoincrement: false;
3183
+ hasRuntimeDefault: false;
3184
+ enumValues: [string, ...string[]];
3185
+ baseColumn: never;
3186
+ identity: undefined;
3187
+ generated: undefined;
3188
+ }, {}, {
3189
+ length: number | undefined;
3190
+ }>;
3191
+ currentAdapterSessionIdState: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3192
+ name: "current_adapter_session_id_state";
3193
+ tableName: "sessions";
3194
+ dataType: "string";
3195
+ columnType: "SQLiteText";
3196
+ data: "confirmed" | "moved" | "inherited";
3197
+ driverParam: string;
3198
+ notNull: true;
3199
+ hasDefault: true;
3200
+ isPrimaryKey: false;
3201
+ isAutoincrement: false;
3202
+ hasRuntimeDefault: false;
3203
+ enumValues: ["inherited", "moved", "confirmed"];
3204
+ baseColumn: never;
3205
+ identity: undefined;
3206
+ generated: undefined;
3207
+ }, {}, {
3208
+ length: number | undefined;
3209
+ }>;
2126
3210
  adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2127
3211
  name: "adapter_id";
2128
3212
  tableName: "sessions";
@@ -2502,7 +3586,500 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2502
3586
  columnType: "SQLiteBoolean";
2503
3587
  data: boolean;
2504
3588
  driverParam: number;
2505
- notNull: false;
3589
+ notNull: false;
3590
+ hasDefault: false;
3591
+ isPrimaryKey: false;
3592
+ isAutoincrement: false;
3593
+ hasRuntimeDefault: false;
3594
+ enumValues: undefined;
3595
+ baseColumn: never;
3596
+ identity: undefined;
3597
+ generated: undefined;
3598
+ }, {}, {}>;
3599
+ machineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3600
+ name: "machine_id";
3601
+ tableName: "sessions";
3602
+ dataType: "string";
3603
+ columnType: "SQLiteText";
3604
+ data: string;
3605
+ driverParam: string;
3606
+ notNull: false;
3607
+ hasDefault: false;
3608
+ isPrimaryKey: false;
3609
+ isAutoincrement: false;
3610
+ hasRuntimeDefault: false;
3611
+ enumValues: [string, ...string[]];
3612
+ baseColumn: never;
3613
+ identity: undefined;
3614
+ generated: undefined;
3615
+ }, {}, {
3616
+ length: number | undefined;
3617
+ }>;
3618
+ };
3619
+ dialect: "sqlite";
3620
+ }>;
3621
+ agents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3622
+ name: "agents";
3623
+ schema: undefined;
3624
+ columns: {
3625
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3626
+ name: "agent_id";
3627
+ tableName: "agents";
3628
+ dataType: "string";
3629
+ columnType: "SQLiteText";
3630
+ data: string;
3631
+ driverParam: string;
3632
+ notNull: true;
3633
+ hasDefault: false;
3634
+ isPrimaryKey: true;
3635
+ isAutoincrement: false;
3636
+ hasRuntimeDefault: false;
3637
+ enumValues: [string, ...string[]];
3638
+ baseColumn: never;
3639
+ identity: undefined;
3640
+ generated: undefined;
3641
+ }, {}, {
3642
+ length: number | undefined;
3643
+ }>;
3644
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3645
+ name: "adapter_id";
3646
+ tableName: "agents";
3647
+ dataType: "string";
3648
+ columnType: "SQLiteText";
3649
+ data: string;
3650
+ driverParam: string;
3651
+ notNull: true;
3652
+ hasDefault: false;
3653
+ isPrimaryKey: false;
3654
+ isAutoincrement: false;
3655
+ hasRuntimeDefault: false;
3656
+ enumValues: [string, ...string[]];
3657
+ baseColumn: never;
3658
+ identity: undefined;
3659
+ generated: undefined;
3660
+ }, {}, {
3661
+ length: number | undefined;
3662
+ }>;
3663
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3664
+ name: "adapter_name";
3665
+ tableName: "agents";
3666
+ dataType: "string";
3667
+ columnType: "SQLiteText";
3668
+ data: string;
3669
+ driverParam: string;
3670
+ notNull: true;
3671
+ hasDefault: false;
3672
+ isPrimaryKey: false;
3673
+ isAutoincrement: false;
3674
+ hasRuntimeDefault: false;
3675
+ enumValues: [string, ...string[]];
3676
+ baseColumn: never;
3677
+ identity: undefined;
3678
+ generated: undefined;
3679
+ }, {}, {
3680
+ length: number | undefined;
3681
+ }>;
3682
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3683
+ name: "session_id";
3684
+ tableName: "agents";
3685
+ dataType: "string";
3686
+ columnType: "SQLiteText";
3687
+ data: string;
3688
+ driverParam: string;
3689
+ notNull: true;
3690
+ hasDefault: false;
3691
+ isPrimaryKey: false;
3692
+ isAutoincrement: false;
3693
+ hasRuntimeDefault: false;
3694
+ enumValues: [string, ...string[]];
3695
+ baseColumn: never;
3696
+ identity: undefined;
3697
+ generated: undefined;
3698
+ }, {}, {
3699
+ length: number | undefined;
3700
+ }>;
3701
+ ownerMachineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3702
+ name: "owner_machine_id";
3703
+ tableName: "agents";
3704
+ dataType: "string";
3705
+ columnType: "SQLiteText";
3706
+ data: string;
3707
+ driverParam: string;
3708
+ notNull: false;
3709
+ hasDefault: false;
3710
+ isPrimaryKey: false;
3711
+ isAutoincrement: false;
3712
+ hasRuntimeDefault: false;
3713
+ enumValues: [string, ...string[]];
3714
+ baseColumn: never;
3715
+ identity: undefined;
3716
+ generated: undefined;
3717
+ }, {}, {
3718
+ length: number | undefined;
3719
+ }>;
3720
+ ownerInstanceId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3721
+ name: "owner_instance_id";
3722
+ tableName: "agents";
3723
+ dataType: "string";
3724
+ columnType: "SQLiteText";
3725
+ data: string;
3726
+ driverParam: string;
3727
+ notNull: false;
3728
+ hasDefault: false;
3729
+ isPrimaryKey: false;
3730
+ isAutoincrement: false;
3731
+ hasRuntimeDefault: false;
3732
+ enumValues: [string, ...string[]];
3733
+ baseColumn: never;
3734
+ identity: undefined;
3735
+ generated: undefined;
3736
+ }, {}, {
3737
+ length: number | undefined;
3738
+ }>;
3739
+ recoveryAttemptId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3740
+ name: "recovery_attempt_id";
3741
+ tableName: "agents";
3742
+ dataType: "string";
3743
+ columnType: "SQLiteText";
3744
+ data: string;
3745
+ driverParam: string;
3746
+ notNull: false;
3747
+ hasDefault: false;
3748
+ isPrimaryKey: false;
3749
+ isAutoincrement: false;
3750
+ hasRuntimeDefault: false;
3751
+ enumValues: [string, ...string[]];
3752
+ baseColumn: never;
3753
+ identity: undefined;
3754
+ generated: undefined;
3755
+ }, {}, {
3756
+ length: number | undefined;
3757
+ }>;
3758
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3759
+ name: "adapter_session_id";
3760
+ tableName: "agents";
3761
+ dataType: "string";
3762
+ columnType: "SQLiteText";
3763
+ data: string;
3764
+ driverParam: string;
3765
+ notNull: false;
3766
+ hasDefault: false;
3767
+ isPrimaryKey: false;
3768
+ isAutoincrement: false;
3769
+ hasRuntimeDefault: false;
3770
+ enumValues: [string, ...string[]];
3771
+ baseColumn: never;
3772
+ identity: undefined;
3773
+ generated: undefined;
3774
+ }, {}, {
3775
+ length: number | undefined;
3776
+ }>;
3777
+ currentAdapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3778
+ name: "current_adapter_session_id";
3779
+ tableName: "agents";
3780
+ dataType: "string";
3781
+ columnType: "SQLiteText";
3782
+ data: string;
3783
+ driverParam: string;
3784
+ notNull: false;
3785
+ hasDefault: false;
3786
+ isPrimaryKey: false;
3787
+ isAutoincrement: false;
3788
+ hasRuntimeDefault: false;
3789
+ enumValues: [string, ...string[]];
3790
+ baseColumn: never;
3791
+ identity: undefined;
3792
+ generated: undefined;
3793
+ }, {}, {
3794
+ length: number | undefined;
3795
+ }>;
3796
+ currentAdapterSessionIdState: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3797
+ name: "current_adapter_session_id_state";
3798
+ tableName: "agents";
3799
+ dataType: "string";
3800
+ columnType: "SQLiteText";
3801
+ data: "confirmed" | "moved" | "inherited";
3802
+ driverParam: string;
3803
+ notNull: true;
3804
+ hasDefault: true;
3805
+ isPrimaryKey: false;
3806
+ isAutoincrement: false;
3807
+ hasRuntimeDefault: false;
3808
+ enumValues: ["inherited", "moved", "confirmed"];
3809
+ baseColumn: never;
3810
+ identity: undefined;
3811
+ generated: undefined;
3812
+ }, {}, {
3813
+ length: number | undefined;
3814
+ }>;
3815
+ revision: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3816
+ name: string;
3817
+ tableName: "agents";
3818
+ dataType: "number";
3819
+ columnType: "SQLiteInteger";
3820
+ data: number;
3821
+ driverParam: number;
3822
+ notNull: true;
3823
+ hasDefault: true;
3824
+ isPrimaryKey: false;
3825
+ isAutoincrement: false;
3826
+ hasRuntimeDefault: false;
3827
+ enumValues: undefined;
3828
+ baseColumn: never;
3829
+ identity: undefined;
3830
+ generated: undefined;
3831
+ }, {}, {}>;
3832
+ currencyFence: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3833
+ name: string;
3834
+ tableName: "agents";
3835
+ dataType: "number";
3836
+ columnType: "SQLiteInteger";
3837
+ data: number;
3838
+ driverParam: number;
3839
+ notNull: true;
3840
+ hasDefault: true;
3841
+ isPrimaryKey: false;
3842
+ isAutoincrement: false;
3843
+ hasRuntimeDefault: false;
3844
+ enumValues: undefined;
3845
+ baseColumn: never;
3846
+ identity: undefined;
3847
+ generated: undefined;
3848
+ }, {}, {}>;
3849
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3850
+ name: "model";
3851
+ tableName: "agents";
3852
+ dataType: "string";
3853
+ columnType: "SQLiteText";
3854
+ data: string;
3855
+ driverParam: string;
3856
+ notNull: false;
3857
+ hasDefault: false;
3858
+ isPrimaryKey: false;
3859
+ isAutoincrement: false;
3860
+ hasRuntimeDefault: false;
3861
+ enumValues: [string, ...string[]];
3862
+ baseColumn: never;
3863
+ identity: undefined;
3864
+ generated: undefined;
3865
+ }, {}, {
3866
+ length: number | undefined;
3867
+ }>;
3868
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3869
+ name: "cwd";
3870
+ tableName: "agents";
3871
+ dataType: "string";
3872
+ columnType: "SQLiteText";
3873
+ data: string;
3874
+ driverParam: string;
3875
+ notNull: false;
3876
+ hasDefault: false;
3877
+ isPrimaryKey: false;
3878
+ isAutoincrement: false;
3879
+ hasRuntimeDefault: false;
3880
+ enumValues: [string, ...string[]];
3881
+ baseColumn: never;
3882
+ identity: undefined;
3883
+ generated: undefined;
3884
+ }, {}, {
3885
+ length: number | undefined;
3886
+ }>;
3887
+ allowedDirectories: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3888
+ name: string;
3889
+ tableName: "agents";
3890
+ dataType: "json";
3891
+ columnType: "SQLiteTextJson";
3892
+ data: string[];
3893
+ driverParam: string;
3894
+ notNull: false;
3895
+ hasDefault: false;
3896
+ isPrimaryKey: false;
3897
+ isAutoincrement: false;
3898
+ hasRuntimeDefault: false;
3899
+ enumValues: undefined;
3900
+ baseColumn: never;
3901
+ identity: undefined;
3902
+ generated: undefined;
3903
+ }, {}, {
3904
+ $type: string[];
3905
+ }>;
3906
+ providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3907
+ name: "provider_config_id";
3908
+ tableName: "agents";
3909
+ dataType: "string";
3910
+ columnType: "SQLiteText";
3911
+ data: string;
3912
+ driverParam: string;
3913
+ notNull: false;
3914
+ hasDefault: false;
3915
+ isPrimaryKey: false;
3916
+ isAutoincrement: false;
3917
+ hasRuntimeDefault: false;
3918
+ enumValues: [string, ...string[]];
3919
+ baseColumn: never;
3920
+ identity: undefined;
3921
+ generated: undefined;
3922
+ }, {}, {
3923
+ length: number | undefined;
3924
+ }>;
3925
+ personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3926
+ name: "persona_id";
3927
+ tableName: "agents";
3928
+ dataType: "string";
3929
+ columnType: "SQLiteText";
3930
+ data: string;
3931
+ driverParam: string;
3932
+ notNull: false;
3933
+ hasDefault: false;
3934
+ isPrimaryKey: false;
3935
+ isAutoincrement: false;
3936
+ hasRuntimeDefault: false;
3937
+ enumValues: [string, ...string[]];
3938
+ baseColumn: never;
3939
+ identity: undefined;
3940
+ generated: undefined;
3941
+ }, {}, {
3942
+ length: number | undefined;
3943
+ }>;
3944
+ profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3945
+ name: "profile_id";
3946
+ tableName: "agents";
3947
+ dataType: "string";
3948
+ columnType: "SQLiteText";
3949
+ data: string;
3950
+ driverParam: string;
3951
+ notNull: false;
3952
+ hasDefault: false;
3953
+ isPrimaryKey: false;
3954
+ isAutoincrement: false;
3955
+ hasRuntimeDefault: false;
3956
+ enumValues: [string, ...string[]];
3957
+ baseColumn: never;
3958
+ identity: undefined;
3959
+ generated: undefined;
3960
+ }, {}, {
3961
+ length: number | undefined;
3962
+ }>;
3963
+ harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3964
+ name: "harness_id";
3965
+ tableName: "agents";
3966
+ dataType: "string";
3967
+ columnType: "SQLiteText";
3968
+ data: string;
3969
+ driverParam: string;
3970
+ notNull: false;
3971
+ hasDefault: false;
3972
+ isPrimaryKey: false;
3973
+ isAutoincrement: false;
3974
+ hasRuntimeDefault: false;
3975
+ enumValues: [string, ...string[]];
3976
+ baseColumn: never;
3977
+ identity: undefined;
3978
+ generated: undefined;
3979
+ }, {}, {
3980
+ length: number | undefined;
3981
+ }>;
3982
+ clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3983
+ name: "client_id";
3984
+ tableName: "agents";
3985
+ dataType: "string";
3986
+ columnType: "SQLiteText";
3987
+ data: string;
3988
+ driverParam: string;
3989
+ notNull: false;
3990
+ hasDefault: false;
3991
+ isPrimaryKey: false;
3992
+ isAutoincrement: false;
3993
+ hasRuntimeDefault: false;
3994
+ enumValues: [string, ...string[]];
3995
+ baseColumn: never;
3996
+ identity: undefined;
3997
+ generated: undefined;
3998
+ }, {}, {
3999
+ length: number | undefined;
4000
+ }>;
4001
+ compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4002
+ name: "compression_mode";
4003
+ tableName: "agents";
4004
+ dataType: "string";
4005
+ columnType: "SQLiteText";
4006
+ data: string;
4007
+ driverParam: string;
4008
+ notNull: false;
4009
+ hasDefault: false;
4010
+ isPrimaryKey: false;
4011
+ isAutoincrement: false;
4012
+ hasRuntimeDefault: false;
4013
+ enumValues: [string, ...string[]];
4014
+ baseColumn: never;
4015
+ identity: undefined;
4016
+ generated: undefined;
4017
+ }, {}, {
4018
+ length: number | undefined;
4019
+ }>;
4020
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4021
+ name: "role";
4022
+ tableName: "agents";
4023
+ dataType: "string";
4024
+ columnType: "SQLiteText";
4025
+ data: "lead" | "member";
4026
+ driverParam: string;
4027
+ notNull: true;
4028
+ hasDefault: false;
4029
+ isPrimaryKey: false;
4030
+ isAutoincrement: false;
4031
+ hasRuntimeDefault: false;
4032
+ enumValues: ["lead", "member"];
4033
+ baseColumn: never;
4034
+ identity: undefined;
4035
+ generated: undefined;
4036
+ }, {}, {
4037
+ length: number | undefined;
4038
+ }>;
4039
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4040
+ name: "status";
4041
+ tableName: "agents";
4042
+ dataType: "string";
4043
+ columnType: "SQLiteText";
4044
+ data: "idle" | "active" | "starting" | "dead" | "disposed";
4045
+ driverParam: string;
4046
+ notNull: true;
4047
+ hasDefault: false;
4048
+ isPrimaryKey: false;
4049
+ isAutoincrement: false;
4050
+ hasRuntimeDefault: false;
4051
+ enumValues: ["starting", "idle", "active", "dead", "disposed"];
4052
+ baseColumn: never;
4053
+ identity: undefined;
4054
+ generated: undefined;
4055
+ }, {}, {
4056
+ length: number | undefined;
4057
+ }>;
4058
+ createdAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4059
+ name: string;
4060
+ tableName: "agents";
4061
+ dataType: "number";
4062
+ columnType: "SQLiteInteger";
4063
+ data: number;
4064
+ driverParam: number;
4065
+ notNull: true;
4066
+ hasDefault: false;
4067
+ isPrimaryKey: false;
4068
+ isAutoincrement: false;
4069
+ hasRuntimeDefault: false;
4070
+ enumValues: undefined;
4071
+ baseColumn: never;
4072
+ identity: undefined;
4073
+ generated: undefined;
4074
+ }, {}, {}>;
4075
+ lastActivityAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4076
+ name: string;
4077
+ tableName: "agents";
4078
+ dataType: "number";
4079
+ columnType: "SQLiteInteger";
4080
+ data: number;
4081
+ driverParam: number;
4082
+ notNull: true;
2506
4083
  hasDefault: false;
2507
4084
  isPrimaryKey: false;
2508
4085
  isAutoincrement: false;
@@ -2512,16 +4089,23 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2512
4089
  identity: undefined;
2513
4090
  generated: undefined;
2514
4091
  }, {}, {}>;
4092
+ };
4093
+ dialect: "sqlite";
4094
+ }>;
4095
+ runtimeInstanceIncarnationCounters: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4096
+ name: "runtime_instance_incarnation_counters";
4097
+ schema: undefined;
4098
+ columns: {
2515
4099
  machineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2516
4100
  name: "machine_id";
2517
- tableName: "sessions";
4101
+ tableName: "runtime_instance_incarnation_counters";
2518
4102
  dataType: "string";
2519
4103
  columnType: "SQLiteText";
2520
4104
  data: string;
2521
4105
  driverParam: string;
2522
- notNull: false;
4106
+ notNull: true;
2523
4107
  hasDefault: false;
2524
- isPrimaryKey: false;
4108
+ isPrimaryKey: true;
2525
4109
  isAutoincrement: false;
2526
4110
  hasRuntimeDefault: false;
2527
4111
  enumValues: [string, ...string[]];
@@ -2531,23 +4115,40 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2531
4115
  }, {}, {
2532
4116
  length: number | undefined;
2533
4117
  }>;
4118
+ lastAllocatedIncarnation: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4119
+ name: string;
4120
+ tableName: "runtime_instance_incarnation_counters";
4121
+ dataType: "number";
4122
+ columnType: "SQLiteInteger";
4123
+ data: number;
4124
+ driverParam: number;
4125
+ notNull: true;
4126
+ hasDefault: false;
4127
+ isPrimaryKey: false;
4128
+ isAutoincrement: false;
4129
+ hasRuntimeDefault: false;
4130
+ enumValues: undefined;
4131
+ baseColumn: never;
4132
+ identity: undefined;
4133
+ generated: undefined;
4134
+ }, {}, {}>;
2534
4135
  };
2535
4136
  dialect: "sqlite";
2536
4137
  }>;
2537
- agents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2538
- name: "agents";
4138
+ runtimeInstances: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4139
+ name: "runtime_instances";
2539
4140
  schema: undefined;
2540
4141
  columns: {
2541
- agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2542
- name: "agent_id";
2543
- tableName: "agents";
4142
+ instanceId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4143
+ name: "instance_id";
4144
+ tableName: "runtime_instances";
2544
4145
  dataType: "string";
2545
4146
  columnType: "SQLiteText";
2546
4147
  data: string;
2547
4148
  driverParam: string;
2548
4149
  notNull: true;
2549
4150
  hasDefault: false;
2550
- isPrimaryKey: true;
4151
+ isPrimaryKey: false;
2551
4152
  isAutoincrement: false;
2552
4153
  hasRuntimeDefault: false;
2553
4154
  enumValues: [string, ...string[]];
@@ -2557,9 +4158,9 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2557
4158
  }, {}, {
2558
4159
  length: number | undefined;
2559
4160
  }>;
2560
- adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2561
- name: "adapter_id";
2562
- tableName: "agents";
4161
+ machineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4162
+ name: "machine_id";
4163
+ tableName: "runtime_instances";
2563
4164
  dataType: "string";
2564
4165
  columnType: "SQLiteText";
2565
4166
  data: string;
@@ -2576,73 +4177,74 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2576
4177
  }, {}, {
2577
4178
  length: number | undefined;
2578
4179
  }>;
2579
- adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2580
- name: "adapter_name";
2581
- tableName: "agents";
2582
- dataType: "string";
2583
- columnType: "SQLiteText";
2584
- data: string;
2585
- driverParam: string;
4180
+ incarnation: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4181
+ name: string;
4182
+ tableName: "runtime_instances";
4183
+ dataType: "number";
4184
+ columnType: "SQLiteInteger";
4185
+ data: number;
4186
+ driverParam: number;
2586
4187
  notNull: true;
2587
4188
  hasDefault: false;
2588
4189
  isPrimaryKey: false;
2589
4190
  isAutoincrement: false;
2590
4191
  hasRuntimeDefault: false;
2591
- enumValues: [string, ...string[]];
4192
+ enumValues: undefined;
2592
4193
  baseColumn: never;
2593
4194
  identity: undefined;
2594
4195
  generated: undefined;
2595
- }, {}, {
2596
- length: number | undefined;
2597
- }>;
2598
- sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2599
- name: "session_id";
2600
- tableName: "agents";
2601
- dataType: "string";
2602
- columnType: "SQLiteText";
2603
- data: string;
2604
- driverParam: string;
4196
+ }, {}, {}>;
4197
+ startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4198
+ name: string;
4199
+ tableName: "runtime_instances";
4200
+ dataType: "number";
4201
+ columnType: "SQLiteInteger";
4202
+ data: number;
4203
+ driverParam: number;
2605
4204
  notNull: true;
2606
4205
  hasDefault: false;
2607
4206
  isPrimaryKey: false;
2608
4207
  isAutoincrement: false;
2609
4208
  hasRuntimeDefault: false;
2610
- enumValues: [string, ...string[]];
4209
+ enumValues: undefined;
2611
4210
  baseColumn: never;
2612
4211
  identity: undefined;
2613
4212
  generated: undefined;
2614
- }, {}, {
2615
- length: number | undefined;
2616
- }>;
2617
- adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2618
- name: "adapter_session_id";
2619
- tableName: "agents";
2620
- dataType: "string";
2621
- columnType: "SQLiteText";
2622
- data: string;
2623
- driverParam: string;
4213
+ }, {}, {}>;
4214
+ retiredAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4215
+ name: string;
4216
+ tableName: "runtime_instances";
4217
+ dataType: "number";
4218
+ columnType: "SQLiteInteger";
4219
+ data: number;
4220
+ driverParam: number;
2624
4221
  notNull: false;
2625
4222
  hasDefault: false;
2626
4223
  isPrimaryKey: false;
2627
4224
  isAutoincrement: false;
2628
4225
  hasRuntimeDefault: false;
2629
- enumValues: [string, ...string[]];
4226
+ enumValues: undefined;
2630
4227
  baseColumn: never;
2631
4228
  identity: undefined;
2632
4229
  generated: undefined;
2633
- }, {}, {
2634
- length: number | undefined;
2635
- }>;
2636
- model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2637
- name: "model";
2638
- tableName: "agents";
4230
+ }, {}, {}>;
4231
+ };
4232
+ dialect: "sqlite";
4233
+ }>;
4234
+ adapterSessionClaims: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4235
+ name: "adapter_session_claims";
4236
+ schema: undefined;
4237
+ columns: {
4238
+ claimId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4239
+ name: "claim_id";
4240
+ tableName: "adapter_session_claims";
2639
4241
  dataType: "string";
2640
4242
  columnType: "SQLiteText";
2641
4243
  data: string;
2642
4244
  driverParam: string;
2643
- notNull: false;
4245
+ notNull: true;
2644
4246
  hasDefault: false;
2645
- isPrimaryKey: false;
4247
+ isPrimaryKey: true;
2646
4248
  isAutoincrement: false;
2647
4249
  hasRuntimeDefault: false;
2648
4250
  enumValues: [string, ...string[]];
@@ -2652,14 +4254,14 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2652
4254
  }, {}, {
2653
4255
  length: number | undefined;
2654
4256
  }>;
2655
- cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2656
- name: "cwd";
2657
- tableName: "agents";
4257
+ machineId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4258
+ name: "machine_id";
4259
+ tableName: "adapter_session_claims";
2658
4260
  dataType: "string";
2659
4261
  columnType: "SQLiteText";
2660
4262
  data: string;
2661
4263
  driverParam: string;
2662
- notNull: false;
4264
+ notNull: true;
2663
4265
  hasDefault: false;
2664
4266
  isPrimaryKey: false;
2665
4267
  isAutoincrement: false;
@@ -2671,33 +4273,33 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2671
4273
  }, {}, {
2672
4274
  length: number | undefined;
2673
4275
  }>;
2674
- allowedDirectories: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2675
- name: string;
2676
- tableName: "agents";
2677
- dataType: "json";
2678
- columnType: "SQLiteTextJson";
2679
- data: string[];
4276
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4277
+ name: "adapter_id";
4278
+ tableName: "adapter_session_claims";
4279
+ dataType: "string";
4280
+ columnType: "SQLiteText";
4281
+ data: string;
2680
4282
  driverParam: string;
2681
- notNull: false;
4283
+ notNull: true;
2682
4284
  hasDefault: false;
2683
4285
  isPrimaryKey: false;
2684
4286
  isAutoincrement: false;
2685
4287
  hasRuntimeDefault: false;
2686
- enumValues: undefined;
4288
+ enumValues: [string, ...string[]];
2687
4289
  baseColumn: never;
2688
4290
  identity: undefined;
2689
4291
  generated: undefined;
2690
4292
  }, {}, {
2691
- $type: string[];
4293
+ length: number | undefined;
2692
4294
  }>;
2693
- providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2694
- name: "provider_config_id";
2695
- tableName: "agents";
4295
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4296
+ name: "adapter_name";
4297
+ tableName: "adapter_session_claims";
2696
4298
  dataType: "string";
2697
4299
  columnType: "SQLiteText";
2698
4300
  data: string;
2699
4301
  driverParam: string;
2700
- notNull: false;
4302
+ notNull: true;
2701
4303
  hasDefault: false;
2702
4304
  isPrimaryKey: false;
2703
4305
  isAutoincrement: false;
@@ -2709,14 +4311,14 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2709
4311
  }, {}, {
2710
4312
  length: number | undefined;
2711
4313
  }>;
2712
- personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2713
- name: "persona_id";
2714
- tableName: "agents";
4314
+ providerSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4315
+ name: "provider_session_id";
4316
+ tableName: "adapter_session_claims";
2715
4317
  dataType: "string";
2716
4318
  columnType: "SQLiteText";
2717
4319
  data: string;
2718
4320
  driverParam: string;
2719
- notNull: false;
4321
+ notNull: true;
2720
4322
  hasDefault: false;
2721
4323
  isPrimaryKey: false;
2722
4324
  isAutoincrement: false;
@@ -2728,14 +4330,14 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2728
4330
  }, {}, {
2729
4331
  length: number | undefined;
2730
4332
  }>;
2731
- profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2732
- name: "profile_id";
2733
- tableName: "agents";
4333
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4334
+ name: "session_id";
4335
+ tableName: "adapter_session_claims";
2734
4336
  dataType: "string";
2735
4337
  columnType: "SQLiteText";
2736
4338
  data: string;
2737
4339
  driverParam: string;
2738
- notNull: false;
4340
+ notNull: true;
2739
4341
  hasDefault: false;
2740
4342
  isPrimaryKey: false;
2741
4343
  isAutoincrement: false;
@@ -2747,14 +4349,14 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2747
4349
  }, {}, {
2748
4350
  length: number | undefined;
2749
4351
  }>;
2750
- harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2751
- name: "harness_id";
2752
- tableName: "agents";
4352
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4353
+ name: "agent_id";
4354
+ tableName: "adapter_session_claims";
2753
4355
  dataType: "string";
2754
4356
  columnType: "SQLiteText";
2755
4357
  data: string;
2756
4358
  driverParam: string;
2757
- notNull: false;
4359
+ notNull: true;
2758
4360
  hasDefault: false;
2759
4361
  isPrimaryKey: false;
2760
4362
  isAutoincrement: false;
@@ -2766,9 +4368,9 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2766
4368
  }, {}, {
2767
4369
  length: number | undefined;
2768
4370
  }>;
2769
- clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2770
- name: "client_id";
2771
- tableName: "agents";
4371
+ ownerInstanceId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4372
+ name: "owner_instance_id";
4373
+ tableName: "adapter_session_claims";
2772
4374
  dataType: "string";
2773
4375
  columnType: "SQLiteText";
2774
4376
  data: string;
@@ -2785,14 +4387,14 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2785
4387
  }, {}, {
2786
4388
  length: number | undefined;
2787
4389
  }>;
2788
- compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2789
- name: "compression_mode";
2790
- tableName: "agents";
4390
+ claimToken: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4391
+ name: "claim_token";
4392
+ tableName: "adapter_session_claims";
2791
4393
  dataType: "string";
2792
4394
  columnType: "SQLiteText";
2793
4395
  data: string;
2794
4396
  driverParam: string;
2795
- notNull: false;
4397
+ notNull: true;
2796
4398
  hasDefault: false;
2797
4399
  isPrimaryKey: false;
2798
4400
  isAutoincrement: false;
@@ -2804,47 +4406,45 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2804
4406
  }, {}, {
2805
4407
  length: number | undefined;
2806
4408
  }>;
2807
- role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2808
- name: "role";
2809
- tableName: "agents";
2810
- dataType: "string";
2811
- columnType: "SQLiteText";
2812
- data: "lead" | "member";
2813
- driverParam: string;
4409
+ fence: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4410
+ name: string;
4411
+ tableName: "adapter_session_claims";
4412
+ dataType: "number";
4413
+ columnType: "SQLiteInteger";
4414
+ data: number;
4415
+ driverParam: number;
2814
4416
  notNull: true;
2815
4417
  hasDefault: false;
2816
4418
  isPrimaryKey: false;
2817
4419
  isAutoincrement: false;
2818
4420
  hasRuntimeDefault: false;
2819
- enumValues: ["lead", "member"];
4421
+ enumValues: undefined;
2820
4422
  baseColumn: never;
2821
4423
  identity: undefined;
2822
4424
  generated: undefined;
2823
- }, {}, {
2824
- length: number | undefined;
2825
- }>;
4425
+ }, {}, {}>;
2826
4426
  status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2827
4427
  name: "status";
2828
- tableName: "agents";
4428
+ tableName: "adapter_session_claims";
2829
4429
  dataType: "string";
2830
4430
  columnType: "SQLiteText";
2831
- data: "idle" | "active" | "dead" | "disposed";
4431
+ data: "abandoned" | "held" | "releasing";
2832
4432
  driverParam: string;
2833
4433
  notNull: true;
2834
- hasDefault: false;
4434
+ hasDefault: true;
2835
4435
  isPrimaryKey: false;
2836
4436
  isAutoincrement: false;
2837
4437
  hasRuntimeDefault: false;
2838
- enumValues: ["idle", "active", "dead", "disposed"];
4438
+ enumValues: ["held", "releasing", "abandoned"];
2839
4439
  baseColumn: never;
2840
4440
  identity: undefined;
2841
4441
  generated: undefined;
2842
4442
  }, {}, {
2843
4443
  length: number | undefined;
2844
4444
  }>;
2845
- createdAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4445
+ claimedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2846
4446
  name: string;
2847
- tableName: "agents";
4447
+ tableName: "adapter_session_claims";
2848
4448
  dataType: "number";
2849
4449
  columnType: "SQLiteInteger";
2850
4450
  data: number;
@@ -2859,9 +4459,9 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2859
4459
  identity: undefined;
2860
4460
  generated: undefined;
2861
4461
  }, {}, {}>;
2862
- lastActivityAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4462
+ updatedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2863
4463
  name: string;
2864
- tableName: "agents";
4464
+ tableName: "adapter_session_claims";
2865
4465
  dataType: "number";
2866
4466
  columnType: "SQLiteInteger";
2867
4467
  data: number;
@@ -2906,6 +4506,64 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2906
4506
  */
2907
4507
  declare function registerDrizzleAgentStorage(bus: IMakaioBus, db: MakaioDatabase): () => void;
2908
4508
  //#endregion
4509
+ //#region services/core/src/session/storage/ownership-memory-handler.d.ts
4510
+ /**
4511
+ * Register in-memory session ownership storage handlers.
4512
+ *
4513
+ * Pass a shared `SessionStorageMemoryState` to make these handlers operate on
4514
+ * the same session and agent rows as `registerMemorySessionStorage` and
4515
+ * `registerMemoryAgentStorage`. Omit it (or pass `undefined`) to get an isolated
4516
+ * private store — useful only for unit tests that exercise ownership without
4517
+ * needing real sessions or agents.
4518
+ * @param bus - The bus instance to register handlers on
4519
+ * @param state - Shared in-memory state; defaults to a new isolated instance
4520
+ * @returns Cleanup function to unsubscribe all handlers
4521
+ */
4522
+ declare function registerMemorySessionOwnershipStorage(bus: IMakaioBus, state?: SessionStorageMemoryState): () => void;
4523
+ //#endregion
4524
+ //#region services/core/src/session/storage/ownership-drizzle-handler.d.ts
4525
+ /**
4526
+ * Register Drizzle-based session ownership storage handlers.
4527
+ *
4528
+ * These are the only writers of the agent currency columns, of the claim table
4529
+ * and of the session row's lead designation. Whole-record surfaces such as
4530
+ * `storage:agent.set` deliberately cannot express those columns, so a writer
4531
+ * holding a pre-movement snapshot cannot resurrect an abandoned provider
4532
+ * session.
4533
+ * @param bus - The bus instance to register handlers on.
4534
+ * @param db - The MakaioDatabase instance.
4535
+ * @returns Cleanup function to unsubscribe all handlers.
4536
+ * @example
4537
+ * ```typescript
4538
+ * const cleanup = registerDrizzleSessionOwnershipStorage(bus, db);
4539
+ * // Later, when shutting down:
4540
+ * cleanup();
4541
+ * ```
4542
+ */
4543
+ declare function registerDrizzleSessionOwnershipStorage(bus: IMakaioBus, db: MakaioDatabase): () => void;
4544
+ //#endregion
4545
+ //#region services/core/src/session/storage/ownership-drizzle-claim-keys.d.ts
4546
+ /** Versioned namespace for ownership-key lock identities. */
4547
+ declare const SESSION_OWNERSHIP_CLAIM_LOCK_NAMESPACE = "makaio:session-ownership:claim:v1";
4548
+ /** Claim-key fields that identify one provider-session ownership row. */
4549
+ interface OwnershipClaimKey {
4550
+ /** Runtime machine owning the provider session store. */
4551
+ readonly machineId: string;
4552
+ /** Adapter runtime owning the provider session. */
4553
+ readonly adapterId: string;
4554
+ /** Provider-native session identifier. */
4555
+ readonly providerSessionId: string;
4556
+ }
4557
+ /**
4558
+ * Build the stable transaction lock for one ownership key.
4559
+ *
4560
+ * JSON arrays preserve field boundaries while keeping the identity independent
4561
+ * of the storage row that currently represents this key.
4562
+ * @param key - Provider-session ownership key.
4563
+ * @returns Stable transaction lock used before claim-row mutation.
4564
+ */
4565
+ declare function ownershipClaimTransactionLock(key: OwnershipClaimKey): TransactionLock;
4566
+ //#endregion
2909
4567
  //#region services/core/src/session/storage/fts-search-handler.d.ts
2910
4568
  /**
2911
4569
  * Registers FTS-backed `storage:session.search` handler.
@@ -3683,20 +5341,12 @@ interface IngestCompletedTurnResult {
3683
5341
  */
3684
5342
  declare function ingestCompletedTurn(bus: IMakaioBus, params: IngestCompletedTurnParams): Promise<IngestCompletedTurnResult>;
3685
5343
  //#endregion
3686
- //#region services/core/src/session/observed-session-ingestion.d.ts
5344
+ //#region services/core/src/session/log-import-trigger-subjects.d.ts
3687
5345
  /**
3688
- * Minimal local mirror of the log-import bus subjects this component calls.
5346
+ * The three log-import subjects observed-session ingestion triggers.
3689
5347
  *
3690
- * The log-import service package depends on this package, so importing its
3691
- * subject definitions here would create a package cycle. Bus subjects are
3692
- * matched by fully-qualified name and payloads are validated against the
3693
- * schemas registered by the owning service at boot — these mirrored
3694
- * definitions are type carriers for the fields this component reads and
3695
- * writes, not a second source of truth. Canonical schemas live with the
3696
- * log-import service.
3697
- *
3698
- * Exported for tests that stub the log-import seam; not part of the public
3699
- * session API surface.
5348
+ * Exported for tests that stub the log-import seam and for the owning
5349
+ * service's conformance pin; not part of the public session API surface.
3700
5350
  * @internal
3701
5351
  */
3702
5352
  declare const LogImportTriggerSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"log-import", {
@@ -3746,6 +5396,8 @@ declare const LogImportTriggerSubjects: _$_makaio_core0.BusSubjects<_$_makaio_co
3746
5396
  }, z.core.$strip>;
3747
5397
  };
3748
5398
  }>, "log-import">;
5399
+ //#endregion
5400
+ //#region services/core/src/session/observed-session-ingestion.d.ts
3749
5401
  /**
3750
5402
  * Check whether a stored session represents a metadata-only observed session.
3751
5403
  *
@@ -3779,10 +5431,15 @@ declare function isTrackingStub(session: Pick<IMakaioSession, 'isImported' | 'im
3779
5431
  * Bridges observed client sessions into the canonical session model.
3780
5432
  *
3781
5433
  * Responsibilities:
3782
- * - Register observed sessions on `client.session.started` through the
3783
- * unified registration seam (`storage:session.importUpsert`), keyed on the
3784
- * importer's adapter name so hook-first registration and later transcript
3785
- * imports converge on the same `(source, adapterSessionId)` identity.
5434
+ * - Register newly started observed sessions on `client.session.started`
5435
+ * through the unified registration seam (`storage:session.importUpsert`),
5436
+ * keyed on the importer's adapter name so hook-first registration and later
5437
+ * transcript imports converge on the same `(source, adapterSessionId)`
5438
+ * identity.
5439
+ * - Rebind continued sessions (`startMode` `resume` / `compact`) through
5440
+ * `storage:session.rebindObserved`: a continuation refreshes runtime and
5441
+ * locality facts only and never registers, so it cannot rewrite the origin,
5442
+ * lineage, import status, creation time or content an import owns.
3786
5443
  * - Trigger targeted transcript imports on `client.session.turn.completed`
3787
5444
  * (`log-import.importFile` when the transcript path is known, discovery
3788
5445
  * fallback via `log-import.importSession` otherwise).
@@ -3901,18 +5558,85 @@ declare class ObservedSessionIngestionService {
3901
5558
  */
3902
5559
  private debugUnresolved;
3903
5560
  /**
3904
- * Register an observed session through the unified registration seam.
5561
+ * Route an observed session start to registration or rebind.
5562
+ *
5563
+ * A `SessionStart` signal carries two different facts depending on its start
5564
+ * mode, and conflating them is what let a continuation rewrite import data:
5565
+ * - `resume` / `compact` continue an external session that already exists.
5566
+ * Its origin, lineage, import status, creation time and content belong to
5567
+ * whoever first imported it; only the runtime observing it may have moved.
5568
+ * These modes therefore *rebind* (see {@link rebindObservedSession}).
5569
+ * - `fresh`, `clear`, `fork` and an absent start mode announce a session
5570
+ * this process is seeing begin, so they register through the unified
5571
+ * registration seam (see {@link registerObservedSession}).
3905
5572
  *
3906
5573
  * Skipped for managed sessions and when no importer is resolvable — a
3907
5574
  * session that can never receive imported content must not create a
3908
- * dangling stub. The registration `source` is the importer's adapter name,
3909
- * NOT the raw client id: the `(source, adapterSessionId)` upsert key must
3910
- * match what the import path writes, otherwise hook-first registration
3911
- * would fork the session identity and every import would create a
3912
- * duplicate session.
5575
+ * dangling stub.
3913
5576
  * @param payload - `client.session.started` payload
3914
5577
  */
3915
5578
  private handleSessionStarted;
5579
+ /**
5580
+ * Rebind an already known observed session to the runtime continuing it.
5581
+ *
5582
+ * Refreshes runtime/locality facts only (working directory, transcript path,
5583
+ * owning machine). A continuation carries no evidence about origin, lineage,
5584
+ * import status or creation time, so it must not be able to write them —
5585
+ * that is precisely what routing resume/compact through the import upsert
5586
+ * used to do.
5587
+ *
5588
+ * A `'not-found'` outcome is resolved by the ingestion policy, because the
5589
+ * skip is only correct while a transcript import is still coming:
5590
+ * - `tracking`: skip. Fabricating a row here would stamp import provenance
5591
+ * and a creation time taken from the resume moment, and the
5592
+ * timestamp-correction clause of the import upsert only fires while
5593
+ * `createdAt` still equals `discoveredAt` — so the invented creation time
5594
+ * would survive the real transcript import forever. Skipping keeps the
5595
+ * session's first row the one the import path creates from the transcript,
5596
+ * with the real creation time and content; the turn-completed trigger
5597
+ * reaches that path on the very next turn without any extra state here.
5598
+ * - `discovered`: register. Metadata-only policy makes the turn-completed
5599
+ * trigger decline content import for this session forever, so no import
5600
+ * will ever create the row and skipping would drop the session entirely.
5601
+ * The registration seam stamps discovered status plus metadata, and its
5602
+ * creation time taken from the observation is the best available — nothing
5603
+ * downstream will correct it.
5604
+ * A successful rebind is also **evidence the conversation is still in use**,
5605
+ * which a `closed` row contradicts — so it is reported to the ownership
5606
+ * authority, which decides what the observation implies for the row (and
5607
+ * which row: a compaction's lineage root, never a synthesized child).
5608
+ * Reporting is this side's whole duty, and it never changes the rebind's own
5609
+ * result.
5610
+ * @param payload - `client.session.started` payload
5611
+ * @param adapterSessionId - External session id of the continued session
5612
+ * @param source - Importer adapter name (import identity of the session)
5613
+ * @param startMode - How the provider continued the conversation
5614
+ * @returns True when a stored session was rebound
5615
+ */
5616
+ private rebindObservedSession;
5617
+ /**
5618
+ * Build the ingestion-policy input for an observed session-start payload.
5619
+ * @param payload - `client.session.started` payload
5620
+ * @param adapterSessionId - External session id of the observed session
5621
+ * @param adapterName - Importer adapter name that would own content import
5622
+ * @returns Policy input describing the observation
5623
+ */
5624
+ private policyInput;
5625
+ /**
5626
+ * Register an observed session through the unified registration seam.
5627
+ *
5628
+ * The registration `source` is the importer's adapter name, NOT the raw
5629
+ * client id: the `(source, adapterSessionId)` upsert key must match what the
5630
+ * import path writes, otherwise hook-first registration would fork the
5631
+ * session identity and every import would create a duplicate session.
5632
+ * @param payload - `client.session.started` payload
5633
+ * @param adapterSessionId - External session id of the started session
5634
+ * @param source - Importer adapter name (import identity of the session)
5635
+ * @param decidedImportStatus - Already evaluated ingestion-policy verdict,
5636
+ * passed by callers that had to consult the policy before routing here
5637
+ * @returns True when the registration reached storage
5638
+ */
5639
+ private registerObservedSession;
3916
5640
  /**
3917
5641
  * Trigger a targeted transcript import for a completed observed turn.
3918
5642
  *
@@ -4826,7 +6550,7 @@ declare const messages: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4826
6550
  tableName: "messages";
4827
6551
  dataType: "string";
4828
6552
  columnType: "SQLiteText";
4829
- data: "text" | "voice" | "compact";
6553
+ data: "text" | "compact" | "voice";
4830
6554
  driverParam: string;
4831
6555
  notNull: false;
4832
6556
  hasDefault: false;
@@ -4872,8 +6596,8 @@ declare const MessageRoutingNamespace: _$_makaio_storage_core0.StorageNamespaceD
4872
6596
  agentId: z.ZodString;
4873
6597
  status: z.ZodEnum<{
4874
6598
  completed: "completed";
4875
- sent: "sent";
4876
6599
  acknowledged: "acknowledged";
6600
+ sent: "sent";
4877
6601
  }>;
4878
6602
  timestamp: z.ZodNumber;
4879
6603
  error: z.ZodOptional<z.ZodString>;
@@ -4898,8 +6622,8 @@ declare const MessageRoutingNamespace: _$_makaio_storage_core0.StorageNamespaceD
4898
6622
  agentId: z.ZodString;
4899
6623
  status: z.ZodEnum<{
4900
6624
  completed: "completed";
4901
- sent: "sent";
4902
6625
  acknowledged: "acknowledged";
6626
+ sent: "sent";
4903
6627
  }>;
4904
6628
  timestamp: z.ZodNumber;
4905
6629
  error: z.ZodOptional<z.ZodString>;
@@ -4986,7 +6710,7 @@ declare const MessageRoutingNamespace: _$_makaio_storage_core0.StorageNamespaceD
4986
6710
  tableName: "message_routing";
4987
6711
  dataType: "string";
4988
6712
  columnType: "SQLiteText";
4989
- data: "completed" | "sent" | "acknowledged";
6713
+ data: "completed" | "acknowledged" | "sent";
4990
6714
  driverParam: string;
4991
6715
  notNull: true;
4992
6716
  hasDefault: false;
@@ -5057,8 +6781,8 @@ declare const MessageRoutingSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core
5057
6781
  agentId: z.ZodString;
5058
6782
  status: z.ZodEnum<{
5059
6783
  completed: "completed";
5060
- sent: "sent";
5061
6784
  acknowledged: "acknowledged";
6785
+ sent: "sent";
5062
6786
  }>;
5063
6787
  timestamp: z.ZodNumber;
5064
6788
  error: z.ZodOptional<z.ZodString>;
@@ -5083,8 +6807,8 @@ declare const MessageRoutingSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core
5083
6807
  agentId: z.ZodString;
5084
6808
  status: z.ZodEnum<{
5085
6809
  completed: "completed";
5086
- sent: "sent";
5087
6810
  acknowledged: "acknowledged";
6811
+ sent: "sent";
5088
6812
  }>;
5089
6813
  timestamp: z.ZodNumber;
5090
6814
  error: z.ZodOptional<z.ZodString>;
@@ -5228,7 +6952,7 @@ declare const messageRouting: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<
5228
6952
  tableName: "message_routing";
5229
6953
  dataType: "string";
5230
6954
  columnType: "SQLiteText";
5231
- data: "completed" | "sent" | "acknowledged";
6955
+ data: "completed" | "acknowledged" | "sent";
5232
6956
  driverParam: string;
5233
6957
  notNull: true;
5234
6958
  hasDefault: false;
@@ -5553,6 +7277,54 @@ declare function buildSessionContext(bus: IMakaioBus, options: BuildContextOptio
5553
7277
  */
5554
7278
  declare function getFullConversation(bus: IMakaioBus, sessionId: string): Promise<ContextAssemblyResult>;
5555
7279
  //#endregion
7280
+ //#region services/core/src/session/session-resume-identity.d.ts
7281
+ /**
7282
+ * The provider session a resume operation may legitimately target right now.
7283
+ *
7284
+ * Produced by {@link resolveSessionResumeIdentity} so that every role in a
7285
+ * resume path — locality evaluation, live-writer detection, and the resume
7286
+ * target handed to the adapter — reads the same value. Reading
7287
+ * `session.adapterSessionId` directly in those roles is what let them diverge:
7288
+ * that column is immutable origin provenance, not resume currency.
7289
+ */
7290
+ interface SessionResumeIdentity {
7291
+ /**
7292
+ * Provider session ID that is valid resume currency, or `undefined` when the
7293
+ * session has none.
7294
+ */
7295
+ readonly adapterSessionId: string | undefined;
7296
+ /**
7297
+ * Whether the provider session moved without provider confirmation.
7298
+ *
7299
+ * When `true`, native resume is impossible regardless of every other
7300
+ * structural signal — there is no provider session that still holds the
7301
+ * conversation. Callers degrade to fresh-with-history.
7302
+ */
7303
+ readonly movedUnconfirmed: boolean;
7304
+ }
7305
+ /**
7306
+ * Resolve the tri-state resume currency of a session row.
7307
+ *
7308
+ * | `currentAdapterSessionIdState` | resume currency |
7309
+ * |-------------------------------|-----------------------------------------|
7310
+ * | `'inherited'` (or absent) | `session.adapterSessionId` (origin) |
7311
+ * | `'confirmed'` | `session.currentAdapterSessionId` |
7312
+ * | `'moved'` | none — degrade to fresh-with-history |
7313
+ *
7314
+ * **Compress children are never a resume source.** Provider-side compaction is
7315
+ * in place — same provider session ID, same transcript — so the row that
7316
+ * carries the provider identity is the lineage root, and the compress children
7317
+ * the transcript importer synthesizes carry no currency at all. Passing one here
7318
+ * therefore resolves to "nothing resumable", which is the correct answer for
7319
+ * that row: the conversation lives on its root. A caller holding a compress
7320
+ * child resolves the root first; this function deliberately does not, because it
7321
+ * takes a row and not a bus, and a lineage walk hidden behind a pure projection
7322
+ * would be a storage read no caller asked for.
7323
+ * @param session - Session record loaded from storage
7324
+ * @returns Resolved resume identity for this session
7325
+ */
7326
+ declare function resolveSessionResumeIdentity(session: IMakaioSession): SessionResumeIdentity;
7327
+ //#endregion
5556
7328
  //#region services/core/src/session/native-locality.d.ts
5557
7329
  /**
5558
7330
  * Describes whether the session resume/fork intent is a native continuation
@@ -5608,6 +7380,19 @@ interface NativeLocalityInput {
5608
7380
  * Required when `session.forkPointMessageId` is set and `intent === 'fork'`.
5609
7381
  */
5610
7382
  readonly midHistoryForkSupported?: boolean;
7383
+ /**
7384
+ * Resume currency the caller resolved for this session.
7385
+ *
7386
+ * `session.adapterSessionId` is immutable origin provenance, so callers that
7387
+ * track currency must resolve it with {@link resolveSessionResumeIdentity} and
7388
+ * pass the result here. When present it is authoritative — including when it
7389
+ * resolves to no usable provider session, which must never silently fall back
7390
+ * to the origin column.
7391
+ *
7392
+ * Omit it to read the origin column directly. That is correct only for callers
7393
+ * whose sessions cannot have moved their provider identity.
7394
+ */
7395
+ readonly resumeIdentity?: SessionResumeIdentity;
5611
7396
  }
5612
7397
  /**
5613
7398
  * Evaluates whether a session can use native resume or fork, or must fall back
@@ -5627,4 +7412,4 @@ interface NativeLocalityInput {
5627
7412
  */
5628
7413
  declare function evaluateNativeLocality(input: NativeLocalityInput): NativeLocalityVerdict;
5629
7414
  //#endregion
5630
- export { ingestCompletedTurn as $, RecoveryConfig as $t, SelectTurn as A, registerMemorySessionStorage as At, OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID as B, normalizeSelectionString as Bt, MessageRoutingSubjects as C, fetchPreviewBySession as Ct, registerMemoryMessageStorage as D, registerDrizzleAgentStorage as Dt, messages as E, registerFtsSearchHandler as Et, EmbeddingIndexManager as F, SessionBridge as Ft, unregisterObservedSessionIngestionPolicyProvider as G, actionRegistry as Gt, ObservedSessionIngestionPolicyImportStatus as H, registerListActionsHandler as Ht, registerDrizzleImportCursorStorage as I, assembleForkContext as It, isPolicyDiscoveredObservedSession as J, ContextWindowTracker as Jt, LogImportTriggerSubjects as K, registerGetStatusCountsHandler as Kt, importCursors as L, FallbackRuntimeOptions as Lt, turnsDual as M, AgentStorageSubjects as Mt, registerMemoryTurnStorage as N, SessionExtensionContextImpl as Nt, registerDrizzleMessageStorage as O, registerMemoryAgentStorage as Ot, registerDrizzleTurnStorage as P, createSessionExtensionContext as Pt, IngestTurnMessage as Q, buildTurnInitiator as Qt, importCursorsDual as R, pickFallbackRuntimeOptions as Rt, MessageRoutingNamespace as S, fetchMessageCountsBySession as St, SelectMessage as T, parseForkTransforms as Tt, ObservedSessionIngestionPolicyInput as U, registerBuiltInActions as Ut, ObservedSessionIngestionPolicyDecision as V, resolveAdapterNameById as Vt, registerObservedSessionIngestionPolicyProvider as W, resetBuiltInActionsRegistration as Wt, IngestCompletedTurnParams as X, ContextWindowTrackerConfig as Xt, isTrackingStub as Y, AgentContextState as Yt, IngestCompletedTurnResult as Z, SessionContextWindowState as Zt, InsertMessageRouting as _, SessionOrchestrator as _n, mapAgentsBySession as _t, buildSessionContext as a, buildRecoveryContext as an, emitSessionTurnStarted as at, messageRoutingDual as b, SearchSessionRow as bt, kindToBranchKind as c, resolveModelCapabilities as cn, registerDrizzleSessionEventStorage as ct, registerSpawningToolCallResolver as d, resolveTargetAgents as dn, SelectSessionEvent as dt, buildRecoveryContextWithPipeline as en, EventTransform as et, registerCompressLineageResolver as f, extractTextContent as fn, sessionEvents as ft, StartTurnOptions as g, ISessionOrchestrator as gn, fetchSessionPreviewMaps as gt, MakaioSessionConfig as h, AdapterRegistry as hn, SessionPreviewMaps as ht, getFullConversation as i, verifyAndRecoverAgents as in, appendSessionLifecycleEvent as it, turns as j, AgentStorageNamespace as jt, InsertTurn as k, registerDrizzleSessionStorage as kt, toSessionLineage as l, findTurnByAgent as ln, registerMemorySessionEventStorage as lt, MakaioSession as m, TurnContextEnricher as mn, getSessionAncestorChain as mt, NativeLocalityIntent as n, ensureAgentModel as nn, SessionTurnStartedPayload as nt, BuildContextOptions as o, resolveAdapterId as on, emitSessionUserMessageSent as ot, registerParentResolver as p, normalizeToBlocks as pn, sessionEventsDual as pt, ObservedSessionIngestionService as q, registerResumeHandler as qt, evaluateNativeLocality as r, recoverAgent as rn, SessionUserMessageSentPayload as rt, ContextAssemblyResult as s, resolveExecutionTarget as sn, registerSessionLifecycleEventWriters as st, NativeLocalityInput as t, ensureAgentCwd as tn, SessionLifecycleEventArgs as tt, registerSessionDiscoveredHandler as u, getOrCreateSession as un, InsertSessionEvent as ut, SelectMessageRouting as v, registerCoreSessionServiceHandlers as vn, mapToSession as vt, InsertMessage as w, mapRowToSession as wt, registerDrizzleMessageRoutingStorage as x, fetchAgentsBySession as xt, messageRouting as y, MakaioSessionService as yn, SearchFilters as yt, IObservedSessionIngestionPolicyProvider as z, CONNECTOR_SWAP_DEFAULT_PIPELINE as zt };
7415
+ export { IngestCompletedTurnResult as $, runExclusiveStart as $n, resolveAdapterNameById as $t, registerDrizzleMessageStorage as A, FreshWithHistoryRecoveryPlan as An, SESSION_OWNERSHIP_CLAIM_LOCK_NAMESPACE as At, importCursorsDual as B, resolveTargetAgents as Bn, AgentStorageNamespace as Bt, registerDrizzleMessageRoutingStorage as C, ensureAgentCwd as Cn, fetchAgentsBySession as Ct, SelectMessage as D, buildPlannedRecoveryContext as Dn, parseForkTransforms as Dt, InsertMessage as E, verifyAndRecoverAgents as En, mapRowToSession as Et, registerMemoryTurnStorage as F, recoveryPlanResumeTarget as Fn, registerMemoryAgentStorage as Ft, ObservedSessionIngestionPolicyInput as G, ISessionOrchestrator as Gn, assembleForkContext as Gt, OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID as H, normalizeToBlocks as Hn, SessionExtensionContextImpl as Ht, registerDrizzleTurnStorage as I, StartReservationRequest as In, registerDrizzleSessionStorage as It, ObservedSessionIngestionService as J, assessClaimOwner as Jn, CONNECTOR_SWAP_DEFAULT_PIPELINE as Jt, registerObservedSessionIngestionPolicyProvider as K, SessionOrchestrator as Kn, FallbackRuntimeOptions as Kt, EmbeddingIndexManager as L, reserveStartFor as Ln, registerMemorySessionStorage as Lt, SelectTurn as M, RecoveryPlan as Mn, registerDrizzleSessionOwnershipStorage as Mt, turns as N, planAgentRecovery as Nn, registerMemorySessionOwnershipStorage as Nt, messages as O, buildRecoveryContext as On, registerFtsSearchHandler as Ot, turnsDual as P, recoveryPlanRequiresHistory as Pn, registerDrizzleAgentStorage as Pt, IngestCompletedTurnParams as Q, peekInFlightStart as Qn, normalizeSelectionString as Qt, registerDrizzleImportCursorStorage as R, findTurnByAgent as Rn, SessionStorageMemoryState as Rt, messageRoutingDual as S, buildRecoveryContextWithPipeline as Sn, SearchSessionRow as St, MessageRoutingSubjects as T, recoverAgent as Tn, fetchPreviewBySession as Tt, ObservedSessionIngestionPolicyDecision as U, TurnContextEnricher as Un, createSessionExtensionContext as Ut, IObservedSessionIngestionPolicyProvider as V, extractTextContent as Vn, AgentStorageSubjects as Vt, ObservedSessionIngestionPolicyImportStatus as W, AdapterRegistry as Wn, SessionBridge as Wt, isTrackingStub as X, enqueueAgentSettle as Xn, SelectionRefusalContext as Xt, isPolicyDiscoveredObservedSession as Y, mintClaimToken as Yn, NamedSelectionInstance as Yt, LogImportTriggerSubjects as Z, InFlightStart as Zn, describeHalfNamedInstanceRefusal as Zt, MakaioSessionConfig as _, LeadTransition as _n, SessionPreviewMaps as _t, resolveSessionResumeIdentity as a, registerResumeHandler as an, SessionUserMessageSentPayload as at, SelectMessageRouting as b, RecoveryConfig as bn, mapToSession as bt, BuildContextOptions as c, ContextWindowTrackerConfig as cn, emitSessionUserMessageSent as ct, toSessionLineage as d, resolveSelectionOwnedInstance as dn, registerMemorySessionEventStorage as dt, registerListActionsHandler as en, registerAdapterSessionMovementObserver as er, IngestTurnMessage as et, registerSessionDiscoveredHandler as f, startLeadAgent as fn, InsertSessionEvent as ft, MakaioSession as g, LeadStartResult as gn, getSessionAncestorChain as gt, registerParentResolver as h, LeadStartRequest as hn, sessionEventsDual as ht, SessionResumeIdentity as i, registerGetStatusCountsHandler as in, MakaioSessionServiceOptions as ir, SessionTurnStartedPayload as it, InsertTurn as j, NativeResumeRecoveryPlan as jn, ownershipClaimTransactionLock as jt, registerMemoryMessageStorage as k, FRESH_WITH_HISTORY_RECOVERY_PLAN as kn, OwnershipClaimKey as kt, ContextAssemblyResult as l, SessionContextWindowState as ln, registerSessionLifecycleEventWriters as lt, registerCompressLineageResolver as m, LeadStartDispatchRequest as mn, sessionEvents as mt, NativeLocalityIntent as n, resetBuiltInActionsRegistration as nn, registerSessionOwnershipAuthority as nr, EventTransform as nt, getFullConversation as o, ContextWindowTracker as on, appendSessionLifecycleEvent as ot, registerSpawningToolCallResolver as p, LeadStartDispatch as pn, SelectSessionEvent as pt, unregisterObservedSessionIngestionPolicyProvider as q, registerCoreSessionServiceHandlers as qn, pickFallbackRuntimeOptions as qt, evaluateNativeLocality as r, actionRegistry as rn, MakaioSessionService as rr, SessionLifecycleEventArgs as rt, buildSessionContext as s, AgentContextState as sn, emitSessionTurnStarted as st, NativeLocalityInput as t, registerBuiltInActions as tn, SessionOwnershipAuthorityDeps as tr, ingestCompletedTurn as tt, kindToBranchKind as u, SelectionInstanceContext as un, registerDrizzleSessionEventStorage as ut, StartTurnOptions as v, buildTurnInitiator as vn, fetchSessionPreviewMaps as vt, MessageRoutingNamespace as w, ensureAgentModel as wn, fetchMessageCountsBySession as wt, messageRouting as x, VerifiedAgents as xn, SearchFilters as xt, InsertMessageRouting as y, AgentRecoveryOutcome as yn, mapAgentsBySession as yt, importCursors as z, getOrCreateSession as zn, createSessionStorageMemoryState as zt };