@makaio/framework 1.0.0-dev-1781022866275 → 1.0.0-dev-1781023871421

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 (456) hide show
  1. package/dist/.makaio-build.json +5 -0
  2. package/dist/account-identity-DT5NOtFi.mjs +1 -0
  3. package/dist/adapter-C1eI-fGV.mjs +1 -0
  4. package/dist/adapters/acp-client/index.d.mts +6208 -0
  5. package/dist/adapters/acp-client/index.mjs +3 -0
  6. package/dist/adapters/config/index.d.mts +429 -0
  7. package/dist/adapters/config/index.mjs +1 -0
  8. package/dist/adapters/index.d.mts +4202 -0
  9. package/dist/adapters/index.mjs +18 -0
  10. package/dist/adapters/node.d.mts +263 -0
  11. package/dist/adapters/node.mjs +4 -0
  12. package/dist/adapters/stream-session/index.d.mts +1414 -0
  13. package/dist/adapters/stream-session/index.mjs +1 -0
  14. package/dist/adapters/stream-session/testing/index.d.mts +29 -0
  15. package/dist/adapters/stream-session/testing/index.mjs +1 -0
  16. package/dist/artifact-B3npq1cy.mjs +1 -0
  17. package/dist/base-orchestrator-wyumsn3b.d.mts +772 -0
  18. package/dist/bus/index.d.mts +3994 -0
  19. package/dist/bus/index.mjs +1 -0
  20. package/dist/bus-Caz3Jpbc.mjs +1 -0
  21. package/dist/bus-Hb-LGzgb.mjs +2 -0
  22. package/dist/capability-service-CJbmhfv9.mjs +1 -0
  23. package/dist/chunk-DTipWd-i.mjs +1 -0
  24. package/dist/chunk-cpUYaJdV.mjs +1 -0
  25. package/dist/cleanEnvForAdapter-KkYzQa1f.mjs +1 -0
  26. package/dist/client-bx74gm4R.mjs +1 -0
  27. package/dist/clients/index.d.mts +2639 -0
  28. package/dist/clients/index.mjs +2 -0
  29. package/dist/clients-namespace-GmSJpBUV.d.mts +332 -0
  30. package/dist/config-namespace-CPY9YsR8.d.mts +638 -0
  31. package/dist/config-namespace-ncYg2ct_.mjs +1 -0
  32. package/dist/contracts/adapter/index.d.mts +3 -0
  33. package/dist/contracts/adapter/index.mjs +1 -0
  34. package/dist/contracts/adapter/schemas/session-lineage.d.mts +2 -0
  35. package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -0
  36. package/dist/contracts/artifact/index.d.mts +2 -0
  37. package/dist/contracts/artifact/index.mjs +1 -0
  38. package/dist/contracts/client/index.d.mts +3 -0
  39. package/dist/contracts/client/index.mjs +1 -0
  40. package/dist/contracts/common/index.d.mts +2 -0
  41. package/dist/contracts/common/index.mjs +1 -0
  42. package/dist/contracts/config/index.d.mts +455 -0
  43. package/dist/contracts/config/index.mjs +1 -0
  44. package/dist/contracts/extension/index.d.mts +4 -0
  45. package/dist/contracts/extension/index.mjs +1 -0
  46. package/dist/contracts/facet/index.d.mts +2 -0
  47. package/dist/contracts/facet/index.mjs +1 -0
  48. package/dist/contracts/harness/index.d.mts +2 -0
  49. package/dist/contracts/harness/index.mjs +1 -0
  50. package/dist/contracts/host/index.d.mts +2 -0
  51. package/dist/contracts/host/index.mjs +1 -0
  52. package/dist/contracts/index.d.mts +23046 -0
  53. package/dist/contracts/index.mjs +1 -0
  54. package/dist/contracts/materialization/index.d.mts +4 -0
  55. package/dist/contracts/materialization/index.mjs +1 -0
  56. package/dist/contracts/model-registry/index.d.mts +2 -0
  57. package/dist/contracts/model-registry/index.mjs +1 -0
  58. package/dist/contracts/native-session-supervisor/index.d.mts +2 -0
  59. package/dist/contracts/native-session-supervisor/index.mjs +1 -0
  60. package/dist/contracts/platform/index.d.mts +2 -0
  61. package/dist/contracts/platform/index.mjs +1 -0
  62. package/dist/contracts/provider/index.d.mts +3 -0
  63. package/dist/contracts/provider/index.mjs +1 -0
  64. package/dist/contracts/session/index.d.mts +3 -0
  65. package/dist/contracts/session/index.mjs +1 -0
  66. package/dist/contracts/shared/index.d.mts +2 -0
  67. package/dist/contracts/shared/index.mjs +1 -0
  68. package/dist/contracts/skill/index.d.mts +2 -0
  69. package/dist/contracts/skill/index.mjs +1 -0
  70. package/dist/contracts/telemetry/index.d.mts +2 -0
  71. package/dist/contracts/telemetry/index.mjs +1 -0
  72. package/dist/contracts/timeout/index.d.mts +2 -0
  73. package/dist/contracts/timeout/index.mjs +1 -0
  74. package/dist/contracts/toast/index.d.mts +198 -0
  75. package/dist/contracts/toast/index.mjs +1 -0
  76. package/dist/contracts/variant/index.d.mts +2 -0
  77. package/dist/contracts/variant/index.mjs +1 -0
  78. package/dist/core/index.d.mts +1263 -0
  79. package/dist/core/index.mjs +1 -0
  80. package/dist/credential-ref-YWQQENEo.mjs +1 -0
  81. package/dist/cursor-storage-CtVJ3JzB.mjs +1 -0
  82. package/dist/definition-BLCdXGzh.d.mts +383 -0
  83. package/dist/definition-CrgHIpTK.d.mts +60 -0
  84. package/dist/definition-DZMXOnjX.mjs +1 -0
  85. package/dist/definition-pkJ6szUl.d.mts +158 -0
  86. package/dist/drizzle-Eq8W1EbD.mjs +1 -0
  87. package/dist/event-Ca2yUf5i.mjs +1 -0
  88. package/dist/execution-target-CRPTfZlc.mjs +1 -0
  89. package/dist/extension-C-4BHMRI.mjs +1 -0
  90. package/dist/extension-CpIUgBKI.mjs +1 -0
  91. package/dist/extension-namespace-cMh_mMiL.mjs +1 -0
  92. package/dist/facet-BuwhrThl.mjs +1 -0
  93. package/dist/filesystem-service-B8rhBRgB.mjs +1 -0
  94. package/dist/filesystem-service-p_iJVHd4.d.mts +66 -0
  95. package/dist/git/index.d.mts +210 -0
  96. package/dist/git/index.mjs +18 -0
  97. package/dist/globby-rtWVaFHv.mjs +41 -0
  98. package/dist/handlers-CkTsQLra.mjs +41 -0
  99. package/dist/harness-BRCMcvQN.mjs +1 -0
  100. package/dist/hooks/index.d.mts +423 -0
  101. package/dist/hooks/index.mjs +1 -0
  102. package/dist/host-Br9VuOyr.mjs +1 -0
  103. package/dist/identity-Cz2IeEtm.mjs +1 -0
  104. package/dist/index-472sOmsW.d.mts +218 -0
  105. package/dist/index-8SZkg7s6.d.mts +353 -0
  106. package/dist/index-B3PK4FIn.d.mts +5116 -0
  107. package/dist/index-B80L4YqA.d.mts +180 -0
  108. package/dist/index-BFg9BUpx.d.mts +355 -0
  109. package/dist/index-BGfWS6GE.d.mts +483 -0
  110. package/dist/index-BVgfS-AJ.d.mts +109 -0
  111. package/dist/index-B_zQC98V.d.mts +995 -0
  112. package/dist/index-Bh_Ne7LF.d.mts +1008 -0
  113. package/dist/index-Bvb2mMH6.d.mts +1730 -0
  114. package/dist/index-CCGVh9BF2.d.mts +749 -0
  115. package/dist/index-CGmcS0Ma.d.mts +412 -0
  116. package/dist/index-CHQ1SqT0.d.mts +117 -0
  117. package/dist/index-CLpjm52M.d.mts +183 -0
  118. package/dist/index-Caig6TeF.d.mts +6746 -0
  119. package/dist/index-CelJCBjk.d.mts +2992 -0
  120. package/dist/index-ChunCFu4.d.mts +11 -0
  121. package/dist/index-Cm0dUkWL.d.mts +4651 -0
  122. package/dist/index-CokQYGVP.d.mts +184 -0
  123. package/dist/index-Cs0kZXIz2.d.mts +37 -0
  124. package/dist/index-D5d5HeWI2.d.mts +259 -0
  125. package/dist/index-D90OmGmV.d.mts +389 -0
  126. package/dist/index-D9MwJ2Q8.d.mts +67 -0
  127. package/dist/index-DANINzMu.d.mts +40 -0
  128. package/dist/index-DBw-89vC2.d.mts +3640 -0
  129. package/dist/index-DGBu6bHi2.d.mts +438 -0
  130. package/dist/index-DKC62dY5.d.mts +146 -0
  131. package/dist/index-DKia0MX1.d.mts +43 -0
  132. package/dist/index-DMKnON5s.d.mts +28 -0
  133. package/dist/index-DUaw0Dw8.d.mts +14747 -0
  134. package/dist/index-De3kPhlN.d.mts +72 -0
  135. package/dist/index-L4GjJDKb.d.mts +822 -0
  136. package/dist/index-U-A8eyGT.d.mts +1490 -0
  137. package/dist/index-eemAKwsB.d.mts +362 -0
  138. package/dist/index-mNec7V-9.d.mts +1075 -0
  139. package/dist/index-soFznFCy2.d.mts +89 -0
  140. package/dist/index-vtXJuwrz.d.mts +40 -0
  141. package/dist/index-x_lVDp_J.d.mts +134 -0
  142. package/dist/json-value-CmhSGMLv.mjs +1 -0
  143. package/dist/kernel/cli/index.d.mts +143 -0
  144. package/dist/kernel/cli/index.mjs +1 -0
  145. package/dist/kernel/cli/schemas.d.mts +64 -0
  146. package/dist/kernel/cli/schemas.mjs +1 -0
  147. package/dist/kernel/extension/index.d.mts +2 -0
  148. package/dist/kernel/extension/index.mjs +1 -0
  149. package/dist/kernel/index.d.mts +296 -0
  150. package/dist/kernel/index.mjs +1 -0
  151. package/dist/kernel/namespace/index.d.mts +2 -0
  152. package/dist/kernel/namespace/index.mjs +1 -0
  153. package/dist/kernel/observability/index.d.mts +2 -0
  154. package/dist/kernel/observability/index.mjs +1 -0
  155. package/dist/kernel/providers/index.d.mts +2 -0
  156. package/dist/kernel/providers/index.mjs +1 -0
  157. package/dist/kernel/window/index.d.mts +2 -0
  158. package/dist/kernel/window/index.mjs +1 -0
  159. package/dist/materialization-CuUBu4XI.mjs +1 -0
  160. package/dist/model-registry-CfXytvzx.mjs +1 -0
  161. package/dist/model-registry-Scn_MC2d.mjs +1 -0
  162. package/dist/namespace-5QQqbF-B.d.mts +3133 -0
  163. package/dist/namespace-BM7Djng9.d.mts +189 -0
  164. package/dist/namespace-BoD94mrN.mjs +1 -0
  165. package/dist/namespace-BwzZJqTV.mjs +1 -0
  166. package/dist/namespace-CFLAmQfh.mjs +1 -0
  167. package/dist/namespace-CTm3nEvh.d.mts +51 -0
  168. package/dist/namespace-CaaNnKcR.d.mts +921 -0
  169. package/dist/namespace-CaoZ3S78.d.mts +43 -0
  170. package/dist/namespace-CxhsoFUP.d.mts +607 -0
  171. package/dist/namespace-DD8Oiqo7.d.mts +580 -0
  172. package/dist/namespace-DLovh2Ws.d.mts +1313 -0
  173. package/dist/namespace-DgqkaOVu.d.mts +768 -0
  174. package/dist/namespace-DkRgbZYn.mjs +1 -0
  175. package/dist/namespace-Dr8K0MCp.d.mts +2047 -0
  176. package/dist/namespace-DuXK5AYN.mjs +1 -0
  177. package/dist/namespace-EQniz-Aw.d.mts +142 -0
  178. package/dist/namespace-IV1QK__V.d.mts +159 -0
  179. package/dist/namespace-LViZ-EQk.mjs +1 -0
  180. package/dist/namespace-TyiTsLFv.d.mts +3020 -0
  181. package/dist/namespace-Yna5-Pws.mjs +1 -0
  182. package/dist/namespace-xcmbQlxh.mjs +1 -0
  183. package/dist/native-session-supervisor-B1TnaPUF.mjs +1 -0
  184. package/dist/node/bus-server/index.d.mts +178 -0
  185. package/dist/node/bus-server/index.mjs +1 -0
  186. package/dist/node/bus-server/server-lifecycle.d.mts +2 -0
  187. package/dist/node/bus-server/server-lifecycle.mjs +1 -0
  188. package/dist/node/machine-identity/index.d.mts +85 -0
  189. package/dist/node/machine-identity/index.mjs +3 -0
  190. package/dist/node/transports/index.d.mts +1945 -0
  191. package/dist/node/transports/index.mjs +2 -0
  192. package/dist/orchestrator-shared-CIDiFJMD.mjs +1 -0
  193. package/dist/orchestrator-shared-Dfa7FMyw.d.mts +249 -0
  194. package/dist/package-DKVlsMP3.mjs +1 -0
  195. package/dist/platform-DZ7z-wXD.mjs +1 -0
  196. package/dist/profile-6ynCD5k3.mjs +1 -0
  197. package/dist/provider-context-CK6B4X_8.mjs +1 -0
  198. package/dist/providers/index.d.mts +135 -0
  199. package/dist/providers/index.mjs +1 -0
  200. package/dist/providers-namespace-DSEpli4A.d.mts +583 -0
  201. package/dist/providers-u8i15co9.mjs +1 -0
  202. package/dist/schema-CoyE6mPt.mjs +1 -0
  203. package/dist/schema-M5YTvSAG.d.mts +949 -0
  204. package/dist/schema-e0wU_lcV.mjs +1 -0
  205. package/dist/schema-introspection-Dn1jWQs1.mjs +1 -0
  206. package/dist/schemas-Bd0OjRQf.d.mts +46 -0
  207. package/dist/schemas-C46QfKzv.d.mts +459 -0
  208. package/dist/schemas-CDBSjg7o.d.mts +237 -0
  209. package/dist/schemas-CR1Rripy.mjs +1 -0
  210. package/dist/schemas-CVvwIfG4.mjs +1 -0
  211. package/dist/schemas-CaLhkkLn.mjs +1 -0
  212. package/dist/schemas-ClOOT1W6.d.mts +174 -0
  213. package/dist/schemas-DATniTHb.d.mts +182 -0
  214. package/dist/schemas-DE-GNmSD.mjs +1 -0
  215. package/dist/schemas-DVF1A4DF.d.mts +160 -0
  216. package/dist/schemas-DaRSfYLf.d.mts +73 -0
  217. package/dist/schemas-DiYVzG6e.d.mts +315 -0
  218. package/dist/schemas-hSrzflwZ.mjs +1 -0
  219. package/dist/schemas-j7ivZ2HI.d.mts +944 -0
  220. package/dist/schemas-jFe1AuI-.mjs +1 -0
  221. package/dist/schemas-wg_6PAdV.d.mts +153 -0
  222. package/dist/scoped-bus-04pwo1uM.mjs +1 -0
  223. package/dist/server-lifecycle-FXTPW39-.mjs +1 -0
  224. package/dist/server-lifecycle-YoSGFGnU.d.mts +160 -0
  225. package/dist/service-base/index.d.mts +98 -0
  226. package/dist/service-base/index.mjs +1 -0
  227. package/dist/services/adapter-runtime/index.d.mts +4 -0
  228. package/dist/services/adapter-runtime/index.mjs +1 -0
  229. package/dist/services/adapter-runtime/namespace.d.mts +2 -0
  230. package/dist/services/adapter-runtime/namespace.mjs +1 -0
  231. package/dist/services/adapter-runtime/schemas.d.mts +2 -0
  232. package/dist/services/adapter-runtime/schemas.mjs +1 -0
  233. package/dist/services/adapter-subsystem/index.d.mts +3 -0
  234. package/dist/services/adapter-subsystem/index.mjs +1 -0
  235. package/dist/services/adapter-subsystem/namespace.d.mts +2 -0
  236. package/dist/services/adapter-subsystem/namespace.mjs +1 -0
  237. package/dist/services/agent-runtime/index.d.mts +3 -0
  238. package/dist/services/agent-runtime/index.mjs +1 -0
  239. package/dist/services/agent-runtime/namespace.d.mts +2 -0
  240. package/dist/services/agent-runtime/namespace.mjs +1 -0
  241. package/dist/services/agent-runtime/schemas.d.mts +2 -0
  242. package/dist/services/agent-runtime/schemas.mjs +1 -0
  243. package/dist/services/capability/index.d.mts +2 -0
  244. package/dist/services/capability/index.mjs +1 -0
  245. package/dist/services/cli-detection/namespace.d.mts +56 -0
  246. package/dist/services/cli-detection/namespace.mjs +1 -0
  247. package/dist/services/codebase/index.d.mts +3 -0
  248. package/dist/services/codebase/index.mjs +1 -0
  249. package/dist/services/codebase/namespace.d.mts +2 -0
  250. package/dist/services/codebase/namespace.mjs +1 -0
  251. package/dist/services/codebase/schemas.d.mts +2 -0
  252. package/dist/services/codebase/schemas.mjs +1 -0
  253. package/dist/services/compression/index.d.mts +3 -0
  254. package/dist/services/compression/index.mjs +1 -0
  255. package/dist/services/compression/namespace.d.mts +2 -0
  256. package/dist/services/compression/namespace.mjs +1 -0
  257. package/dist/services/compression/schemas.d.mts +2 -0
  258. package/dist/services/compression/schemas.mjs +1 -0
  259. package/dist/services/context-rules/index.d.mts +412 -0
  260. package/dist/services/context-rules/index.mjs +1 -0
  261. package/dist/services/credential-change/index.d.mts +17 -0
  262. package/dist/services/credential-change/index.mjs +1 -0
  263. package/dist/services/definition/index.d.mts +2 -0
  264. package/dist/services/definition/index.mjs +1 -0
  265. package/dist/services/definition/namespace.d.mts +71 -0
  266. package/dist/services/definition/namespace.mjs +1 -0
  267. package/dist/services/definition/schemas.d.mts +38 -0
  268. package/dist/services/definition/schemas.mjs +1 -0
  269. package/dist/services/dialog/namespace.d.mts +105 -0
  270. package/dist/services/dialog/namespace.mjs +1 -0
  271. package/dist/services/dialog/schemas.d.mts +109 -0
  272. package/dist/services/dialog/schemas.mjs +1 -0
  273. package/dist/services/execution-target/index.d.mts +4 -0
  274. package/dist/services/execution-target/index.mjs +1 -0
  275. package/dist/services/execution-target/namespace.d.mts +2 -0
  276. package/dist/services/execution-target/namespace.mjs +1 -0
  277. package/dist/services/execution-target/schemas.d.mts +2 -0
  278. package/dist/services/execution-target/schemas.mjs +1 -0
  279. package/dist/services/filesystem/index.d.mts +3 -0
  280. package/dist/services/filesystem/index.mjs +1 -0
  281. package/dist/services/filesystem/namespace.d.mts +432 -0
  282. package/dist/services/filesystem/namespace.mjs +1 -0
  283. package/dist/services/filesystem/schemas.d.mts +240 -0
  284. package/dist/services/filesystem/schemas.mjs +1 -0
  285. package/dist/services/git/namespace.d.mts +1163 -0
  286. package/dist/services/git/namespace.mjs +1 -0
  287. package/dist/services/git/schemas.d.mts +932 -0
  288. package/dist/services/git/schemas.mjs +1 -0
  289. package/dist/services/harness/index.d.mts +861 -0
  290. package/dist/services/harness/index.mjs +1 -0
  291. package/dist/services/harness/storage/schema.d.mts +424 -0
  292. package/dist/services/harness/storage/schema.mjs +1 -0
  293. package/dist/services/index.d.mts +6185 -0
  294. package/dist/services/index.mjs +1 -0
  295. package/dist/services/local-notification/index.d.mts +25 -0
  296. package/dist/services/local-notification/index.mjs +1 -0
  297. package/dist/services/local-notification/namespace.d.mts +73 -0
  298. package/dist/services/local-notification/namespace.mjs +1 -0
  299. package/dist/services/local-notification/schemas.d.mts +88 -0
  300. package/dist/services/local-notification/schemas.mjs +1 -0
  301. package/dist/services/log-import/browser.d.mts +3 -0
  302. package/dist/services/log-import/browser.mjs +1 -0
  303. package/dist/services/log-import/index.d.mts +274 -0
  304. package/dist/services/log-import/index.mjs +2 -0
  305. package/dist/services/log-import/log-import.d.mts +3 -0
  306. package/dist/services/log-import/log-import.mjs +1 -0
  307. package/dist/services/log-import/namespace.d.mts +327 -0
  308. package/dist/services/log-import/namespace.mjs +1 -0
  309. package/dist/services/log-import/schemas.d.mts +217 -0
  310. package/dist/services/log-import/schemas.mjs +1 -0
  311. package/dist/services/model-registry/index.d.mts +2 -0
  312. package/dist/services/model-registry/index.mjs +1 -0
  313. package/dist/services/preferences/index.d.mts +3 -0
  314. package/dist/services/preferences/index.mjs +1 -0
  315. package/dist/services/preferences/schemas.d.mts +2 -0
  316. package/dist/services/preferences/schemas.mjs +1 -0
  317. package/dist/services/preferences/storage-namespace.d.mts +3 -0
  318. package/dist/services/preferences/storage-namespace.mjs +1 -0
  319. package/dist/services/provider-context/index.d.mts +2 -0
  320. package/dist/services/provider-context/index.mjs +1 -0
  321. package/dist/services/provider-runtime/index.d.mts +136 -0
  322. package/dist/services/provider-runtime/index.mjs +1 -0
  323. package/dist/services/session/handlers/index.d.mts +2 -0
  324. package/dist/services/session/handlers/index.mjs +1 -0
  325. package/dist/services/session/index.d.mts +10 -0
  326. package/dist/services/session/index.mjs +1 -0
  327. package/dist/services/session/messages/namespace.d.mts +2 -0
  328. package/dist/services/session/messages/namespace.mjs +1 -0
  329. package/dist/services/session/orchestrator-testing/index.d.mts +2 -0
  330. package/dist/services/session/orchestrator-testing/index.mjs +1 -0
  331. package/dist/services/session/session-events/namespace.d.mts +2 -0
  332. package/dist/services/session/session-events/namespace.mjs +1 -0
  333. package/dist/services/session/storage/namespace.d.mts +2 -0
  334. package/dist/services/session/storage/namespace.mjs +1 -0
  335. package/dist/services/session/storage/schema.d.mts +2 -0
  336. package/dist/services/session/storage/schema.mjs +1 -0
  337. package/dist/services/session/testing/index.d.mts +35 -0
  338. package/dist/services/session/testing/index.mjs +65 -0
  339. package/dist/services/session/testing/orchestrator-shared.d.mts +2 -0
  340. package/dist/services/session/testing/orchestrator-shared.mjs +1 -0
  341. package/dist/services/session/turns/namespace.d.mts +2 -0
  342. package/dist/services/session/turns/namespace.mjs +1 -0
  343. package/dist/services/session-editor/index.d.mts +119 -0
  344. package/dist/services/session-editor/index.mjs +1 -0
  345. package/dist/services/settings/index.d.mts +47 -0
  346. package/dist/services/settings/index.mjs +1 -0
  347. package/dist/services/settings/namespace.d.mts +663 -0
  348. package/dist/services/settings/namespace.mjs +1 -0
  349. package/dist/services/settings/storage/clients-namespace.d.mts +2 -0
  350. package/dist/services/settings/storage/clients-namespace.mjs +1 -0
  351. package/dist/services/settings/storage/extension-configs/namespace.d.mts +184 -0
  352. package/dist/services/settings/storage/extension-configs/namespace.mjs +1 -0
  353. package/dist/services/settings/storage/index.d.mts +4 -0
  354. package/dist/services/settings/storage/index.mjs +1 -0
  355. package/dist/services/settings/storage/providers-namespace.d.mts +2 -0
  356. package/dist/services/settings/storage/providers-namespace.mjs +1 -0
  357. package/dist/services/subagent/index.d.mts +2 -0
  358. package/dist/services/subagent/index.mjs +1 -0
  359. package/dist/services/subagent-template/index.d.mts +3 -0
  360. package/dist/services/subagent-template/index.mjs +1 -0
  361. package/dist/services/subagent-template/namespace.d.mts +2 -0
  362. package/dist/services/subagent-template/namespace.mjs +1 -0
  363. package/dist/services/subagent-template/schemas.d.mts +2 -0
  364. package/dist/services/subagent-template/schemas.mjs +1 -0
  365. package/dist/services/tool-approval/index.d.mts +2 -0
  366. package/dist/services/tool-approval/index.mjs +1 -0
  367. package/dist/services/tools/index.d.mts +2 -0
  368. package/dist/services/tools/index.mjs +1 -0
  369. package/dist/services/tray-menu/index.d.mts +4 -0
  370. package/dist/services/tray-menu/index.mjs +1 -0
  371. package/dist/services/tray-menu/namespace.d.mts +2 -0
  372. package/dist/services/tray-menu/namespace.mjs +1 -0
  373. package/dist/services/tray-menu/schemas.d.mts +2 -0
  374. package/dist/services/tray-menu/schemas.mjs +1 -0
  375. package/dist/services/turn/index.d.mts +2 -0
  376. package/dist/services/turn/index.mjs +1 -0
  377. package/dist/services/turn/namespace.d.mts +2 -0
  378. package/dist/services/turn/namespace.mjs +1 -0
  379. package/dist/services/turn/schemas.d.mts +335 -0
  380. package/dist/services/turn/schemas.mjs +1 -0
  381. package/dist/session-BoldSdNZ2.mjs +134 -0
  382. package/dist/session-DuVOYctZ.mjs +1 -0
  383. package/dist/session-lineage-CRsc9g1x.d.mts +65 -0
  384. package/dist/shared-DpOEfD8F.mjs +1 -0
  385. package/dist/shared-schemas-CPShiLNp.mjs +1 -0
  386. package/dist/skill-CQO4mDqK.mjs +1 -0
  387. package/dist/storage/drizzle/client.d.mts +78 -0
  388. package/dist/storage/drizzle/client.mjs +1 -0
  389. package/dist/storage/drizzle/index.d.mts +137 -0
  390. package/dist/storage/drizzle/index.mjs +1 -0
  391. package/dist/storage/handlers/drizzle/index.d.mts +2 -0
  392. package/dist/storage/handlers/drizzle/index.mjs +1 -0
  393. package/dist/storage/handlers/index.d.mts +33 -0
  394. package/dist/storage/handlers/index.mjs +1 -0
  395. package/dist/storage/index.d.mts +192 -0
  396. package/dist/storage/index.mjs +1 -0
  397. package/dist/storage-namespace-BXkoh5Sy.d.mts +221 -0
  398. package/dist/storage-namespace-DWsYLAXa.mjs +1 -0
  399. package/dist/storage-namespace-definition-Bkx5rSto.d.mts +17 -0
  400. package/dist/storage-namespace-definition-CqSdsuCC.mjs +1 -0
  401. package/dist/style.css +3782 -0
  402. package/dist/telemetry-CvdLBWuk.mjs +1 -0
  403. package/dist/testing/drizzle-harness.d.mts +130 -0
  404. package/dist/testing/drizzle-harness.mjs +1 -0
  405. package/dist/testing/index.d.mts +106 -0
  406. package/dist/testing/index.mjs +1 -0
  407. package/dist/timeout-XsYIOKrc.mjs +1 -0
  408. package/dist/tool-approval-service-BvZWhYZp.mjs +1 -0
  409. package/dist/tools/index.d.mts +835 -0
  410. package/dist/tools/index.mjs +1 -0
  411. package/dist/tools/testing/index.d.mts +53 -0
  412. package/dist/tools/testing/index.mjs +1 -0
  413. package/dist/tools-D-luYcDw.mjs +1431 -0
  414. package/dist/tray-menu-service-DuXq5k22.mjs +1 -0
  415. package/dist/types-BCMUtBj1.d.mts +1106 -0
  416. package/dist/types-C2Ob9zz_.d.mts +128 -0
  417. package/dist/types-CCdqjeuH.d.mts +262 -0
  418. package/dist/types-DZHvOc_Q.d.mts +305 -0
  419. package/dist/types-Dy3YTcTF.d.mts +6777 -0
  420. package/dist/types-MfJZ67e9.d.mts +315 -0
  421. package/dist/types-dyP-bXXE.d.mts +31 -0
  422. package/dist/ui-components/index.d.mts +2342 -0
  423. package/dist/ui-components/index.mjs +8 -0
  424. package/dist/ui-config-9bDRwFZr.mjs +1 -0
  425. package/dist/ui-hooks/index.d.mts +1915 -0
  426. package/dist/ui-hooks/index.mjs +1 -0
  427. package/dist/ui-kernel/index.d.mts +2793 -0
  428. package/dist/ui-kernel/index.mjs +1 -0
  429. package/dist/ui-kernel/pages/namespace.d.mts +88 -0
  430. package/dist/ui-kernel/pages/namespace.mjs +1 -0
  431. package/dist/ui-kernel/pages/schemas.d.mts +2 -0
  432. package/dist/ui-kernel/pages/schemas.mjs +1 -0
  433. package/dist/ui-views/index.d.mts +487 -0
  434. package/dist/ui-views/index.mjs +30 -0
  435. package/dist/utils/health-probe.d.mts +26 -0
  436. package/dist/utils/health-probe.mjs +1 -0
  437. package/dist/utils/index.d.mts +262 -0
  438. package/dist/utils/index.mjs +2 -0
  439. package/dist/utils/keychain.d.mts +31 -0
  440. package/dist/utils/keychain.mjs +1 -0
  441. package/dist/utils/project-manifest.d.mts +130 -0
  442. package/dist/utils/project-manifest.mjs +1 -0
  443. package/dist/utils/resolve-package-root.d.mts +12 -0
  444. package/dist/utils/resolve-package-root.mjs +1 -0
  445. package/dist/utils/scope-paths.d.mts +33 -0
  446. package/dist/utils/scope-paths.mjs +1 -0
  447. package/dist/utils/workspace-packages.d.mts +59 -0
  448. package/dist/utils/workspace-packages.mjs +1 -0
  449. package/dist/utils/workspace-root.d.mts +24 -0
  450. package/dist/utils/workspace-root.mjs +2 -0
  451. package/dist/variant-CT6XBP6T.mjs +1 -0
  452. package/dist/version-BeT3ASEe.mjs +1 -0
  453. package/dist/visibility-Cb62p9bv.mjs +1 -0
  454. package/dist/window-registry-CBcrGTv4.d.mts +130 -0
  455. package/dist/window-registry-DW-dKRjQ.mjs +1 -0
  456. package/package.json +1 -1
@@ -0,0 +1,3640 @@
1
+ import { r as ExecutionTarget } from "./schemas-C46QfKzv.mjs";
2
+ import { d as Turn$1 } from "./index-DGBu6bHi2.mjs";
3
+ import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-C2Ob9zz_.mjs";
4
+ import { a as agents, o as sessions } from "./schema-M5YTvSAG.mjs";
5
+ import { z } from "zod";
6
+ import * as _$_makaio_core0 from "@makaio/framework/core";
7
+ import { ExtractSubjectPayload, SubjectDefinition } from "@makaio/framework/core";
8
+ import { IMakaioBus } from "@makaio/framework/bus";
9
+ import { AIReasoningLevel, AdapterRuntimeOptions, BranchKind, ContextWindowState, ExtensionContext, ForkOptions, ForkTransforms, IMakaioSession, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, ReasoningLevelMap, SessionContext, SessionExtensionContext, SessionLineage, SessionLineageKind, SessionMessage, SessionMessageBlock, TurnInitiator } from "@makaio/framework/contracts";
10
+ import { BaseService } from "@makaio/framework/service-base";
11
+ import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
12
+ import * as _$_makaio_storage_core0 from "@makaio/framework/storage";
13
+ import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
14
+
15
+ //#region services/core/src/session/session-service.d.ts
16
+ /**
17
+ * Framework-core session service for managing makaio sessions.
18
+ *
19
+ * Registers the minimal, load-bearing session handlers that the framework SDK
20
+ * requires: `session.create`, `session.get`, `session.list`, `session.close`,
21
+ * `session.agent.added`, and `session.agent.removed`.
22
+ *
23
+ * Host-specific handlers (search, update, resume, archive, purge, analytics,
24
+ * context window, branching) are registered by the host session service which
25
+ * depends on this service.
26
+ *
27
+ * Storage is fully decoupled via bus — this service calls
28
+ * `SessionStorageSubjects.*` subjects. Register appropriate storage handlers
29
+ * (memory or drizzle) before creating this service.
30
+ *
31
+ * `SessionLogger` is intentionally NOT a dependency here: it persists session
32
+ * lifecycle events consumed only by recovery context assembly, fork, merge,
33
+ * compress, and purge — all host features. Host services declare
34
+ * `SessionLogger` in their own dependency chain.
35
+ * @example
36
+ * ```typescript
37
+ * import { MakaioBus } from '@makaio/framework/bus';
38
+ * import {
39
+ * MakaioSessionService,
40
+ * registerMemorySessionStorage,
41
+ * } from '@makaio/framework/services/session';
42
+ *
43
+ * // Register storage handlers first
44
+ * registerMemorySessionStorage(MakaioBus);
45
+ *
46
+ * // Create and initialise the service
47
+ * const sessionService = new MakaioSessionService(MakaioBus);
48
+ * await sessionService.init();
49
+ *
50
+ * // Now clients can interact via bus
51
+ * const { sessionId } = await MakaioBus.request(SessionSubjects.create, {});
52
+ * const { session } = await MakaioBus.request(SessionSubjects.get, { sessionId });
53
+ *
54
+ * // Cleanup when done
55
+ * sessionService.destroy();
56
+ * ```
57
+ */
58
+ declare class MakaioSessionService extends BaseService {
59
+ /**
60
+ * Creates a new MakaioSessionService instance.
61
+ * @param bus - The event bus for inter-service communication
62
+ */
63
+ constructor(bus?: IMakaioBus);
64
+ /**
65
+ * Initialize the service.
66
+ *
67
+ * Registers the six framework-core session bus handlers, then performs
68
+ * startup reconciliation to close any turns that were left `active` by a
69
+ * prior process crash. Each orphaned turn is closed with status `'error'`
70
+ * and a `'process-restart'` error message, and a `turn.completed` event is
71
+ * emitted so the UI can update accordingly.
72
+ *
73
+ * The reconciliation uses `requestOptional` so it is silently skipped when
74
+ * no `storage:turn.listActive` handler is registered (e.g., in unit tests
75
+ * that do not register turn storage).
76
+ */
77
+ protected onInit(): Promise<void>;
78
+ /**
79
+ * Close any turns left `active` from a prior process crash.
80
+ *
81
+ * Queries all active turns via `storage:turn.listActive`. For each orphaned
82
+ * turn, attempts to atomically mark it as `error` only if it is still `active`,
83
+ * then emits `session.turn.completed` only when that transition succeeds.
84
+ * This prevents clobbering turns completed concurrently by other components.
85
+ *
86
+ * Uses `requestOptional` so that environments without a turn storage handler
87
+ * (e.g., isolated unit tests) are unaffected.
88
+ */
89
+ private reconcileOrphanedTurns;
90
+ }
91
+ //#endregion
92
+ //#region services/core/src/session/session-service-handlers-core.d.ts
93
+ /**
94
+ * Dependencies required to register the framework-core session service handlers.
95
+ *
96
+ * Intentionally minimal — no `contextTracker` or host-layer concerns.
97
+ * Host-specific handlers (search, resume, context window, etc.) are registered
98
+ * separately via the host session service.
99
+ */
100
+ interface CoreSessionServiceHandlerDeps {
101
+ /** The event bus used for handler registration and storage dispatch. */
102
+ bus: IMakaioBus;
103
+ }
104
+ /**
105
+ * Registers the framework-core session service handlers:
106
+ * `session.create`, `session.get`, `session.list`, `session.close`,
107
+ * `session.update`, `session.archive`, `session.purge`,
108
+ * `session.agent.added`, and `session.agent.removed`.
109
+ *
110
+ * These handlers cover the minimal, load-bearing session contract for the
111
+ * framework SDK. Host-specific handlers (search, resume, analytics, context
112
+ * window) are registered by the host session service at a higher priority.
113
+ *
114
+ * Persistence degrades gracefully when no storage handlers are registered:
115
+ * `session.get` / `session.list` / `session.close` all delegate to
116
+ * `SessionStorageSubjects.*` which may be unhandled in ephemeral mode.
117
+ * @param deps - Bus dependency
118
+ * @returns Array of cleanup callbacks, one per registered handler
119
+ */
120
+ declare function registerCoreSessionServiceHandlers(deps: CoreSessionServiceHandlerDeps): Array<() => void>;
121
+ //#endregion
122
+ //#region services/core/src/session/session-orchestrator.d.ts
123
+ /**
124
+ * Minimum public contract for a session orchestrator service.
125
+ *
126
+ * Both the framework orchestrator and host-provided orchestrators can satisfy
127
+ * this interface. The service token is keyed on this
128
+ * interface so the conditional injection pattern (same service name, different
129
+ * implementation per runtime) compiles without structural conflicts.
130
+ */
131
+ interface ISessionOrchestrator {
132
+ /** Stop the orchestrator and clean up all subscriptions. */
133
+ destroy(): void;
134
+ }
135
+ /**
136
+ * Slim framework session orchestrator.
137
+ *
138
+ * Composes with `SessionTurnManager` (turn lifecycle, usage accumulation,
139
+ * completion), `AdapterRegistry` (adapterName to adapterId mapping), and the
140
+ * adapter-subsystem reverse lookup for canonical `adapterId` to `adapterName`
141
+ * validation when callers select a direct adapter instance.
142
+ *
143
+ * Registers the core `session.sendMessage` handler only:
144
+ * 1. Get or create session (via `getOrCreateSession`)
145
+ * 2. Start agent if session has no agents — resolves the canonical
146
+ * `adapterName` from direct selections, uses `adapterId` directly when
147
+ * provided, otherwise resolves it via `AdapterRegistry`, then calls bare
148
+ * `AdapterSubjects.startAgent`
149
+ * 3. Resolve target agents (via `resolveTargetAgents`)
150
+ * 4. Verify agent liveness and build recovery context for dead agents
151
+ * (requestOptional `AdapterSubjects.getAgent` + `buildRecoveryContext`)
152
+ * 5. Get or create turn (via `SessionTurnManager`)
153
+ * 6. Generate message ID and store user message + routing records
154
+ * (requestOptional, fire-and-forget)
155
+ * 7. Emit `session.turn.started` + `session.user_message.sent`
156
+ * 8. Route to agents (via `routeToAgentsCore`, single shared context)
157
+ * 9. Return result with `messageId`, `turnId`, `sessionId`
158
+ *
159
+ * Host-specific features (personas, MCP, execution targets, container spawn,
160
+ * connector swap, CWD/model enforcement, fork context, TurnContextEnricher) are
161
+ * handled by a host-provided orchestrator.
162
+ * @example
163
+ * ```typescript
164
+ * const orchestrator = new SessionOrchestrator(MakaioBus, 'machine-id');
165
+ *
166
+ * const { messageId, turnId, sessionId } = await MakaioBus.request(
167
+ * SessionSubjects.sendMessage,
168
+ * { sessionId: crypto.randomUUID(), adapterName: 'openai-node', message: 'Hello!' },
169
+ * );
170
+ * ```
171
+ */
172
+ declare class SessionOrchestrator implements ISessionOrchestrator {
173
+ private readonly bus;
174
+ private readonly turnManager;
175
+ private readonly adapterRegistry;
176
+ /** Cleanup functions for bus subscriptions. */
177
+ private readonly cleanups;
178
+ /**
179
+ * @param bus - Event bus used for handler registration and message routing
180
+ * @param _machineId - Machine identifier (reserved for future routing use)
181
+ */
182
+ constructor(bus: IMakaioBus | undefined, _machineId: string);
183
+ /**
184
+ * Register the `session.sendMessage` RPC handler.
185
+ *
186
+ * Core flow:
187
+ * 1. Get or create session
188
+ * 2. Start agent if session has no agents (canonicalize direct selections,
189
+ * resolve adapterId, bare startAgent)
190
+ * 3. Resolve target agents
191
+ * 4. Verify agent liveness and build recovery context for dead agents
192
+ * 5. Get or create turn (via SessionTurnManager)
193
+ * 6. Generate message ID and store user message + routing records (fire-and-forget)
194
+ * 7. Emit turn.started + user_message.sent
195
+ * 8. Route to agents (routeToAgentsCore, single shared context)
196
+ * 9. Return result with messageId, turnId, sessionId
197
+ */
198
+ private registerSendMessageHandler;
199
+ /**
200
+ * Complete a turn by delegating to `SessionTurnManager`.
201
+ *
202
+ * Called by `routeToAgentsCore` error handling and by the turn manager's
203
+ * own `agent.complete` listener (registered via `registerCompletionHandlers`).
204
+ * @param turn - The turn to complete
205
+ * @param result - Turn result (success status and error messages)
206
+ */
207
+ private completeTurn;
208
+ /**
209
+ * Stop the orchestrator and clean up all subscriptions and composition utilities.
210
+ */
211
+ destroy(): void;
212
+ /**
213
+ * Resolve the adapter name for a direct adapter selection.
214
+ *
215
+ * Adapter startup and persisted identity require a stable adapter name.
216
+ * When the caller provides `adapterId`, the framework validates any explicit
217
+ * name against the adapter-subsystem reverse lookup and otherwise backfills the
218
+ * canonical adapter name from that subsystem-owned mapping.
219
+ * @param selection - Direct adapter selection
220
+ * @param sessionId - Session ID used in error messages
221
+ * @returns Resolved adapter name
222
+ */
223
+ private resolveAdapterName;
224
+ /**
225
+ * Resolve the public agent selection into the direct adapter shape required
226
+ * by the framework orchestrator's startup path.
227
+ * @param selection - Public session agent selection from the request.
228
+ * @param sessionId - Session ID used for context and diagnostics.
229
+ * @param message - User message used as canonical-model prompt context.
230
+ * @param sessionContext - Optional session context passed through the request.
231
+ * @returns Direct adapter selection for `adapter.startAgent`.
232
+ */
233
+ private resolveInitialAdapterSelection;
234
+ /**
235
+ * Resolve a framework-owned canonical-model selection to a direct adapter selection.
236
+ * @param selection - Canonical model selection from the session request.
237
+ * @param sessionId - Session ID used for context and diagnostics.
238
+ * @param message - User message used as canonical-model prompt context.
239
+ * @param sessionContext - Optional session context passed through the request.
240
+ * @returns Direct adapter selection with resolved adapter, provider config, and model.
241
+ */
242
+ private resolveCanonicalModelSelection;
243
+ }
244
+ //#endregion
245
+ //#region services/core/src/session/adapter-registry.d.ts
246
+ /**
247
+ * Resolves adapterName → adapterId mappings for the framework session
248
+ * orchestrator.
249
+ *
250
+ * The runtime `resolveId` request is the authoritative seam. The
251
+ * `adapter.initialized` listener maintains a local cache for observers and for
252
+ * tests that intentionally exercise the event path.
253
+ *
254
+ * Lifecycle: construct to start listening, call `destroy()` when done.
255
+ */
256
+ declare class AdapterRegistry {
257
+ private readonly bus;
258
+ private readonly registry;
259
+ private cleanup?;
260
+ /**
261
+ * Create an AdapterRegistry and start listening for adapter.initialized events.
262
+ *
263
+ * If the same `adapterName` is seen in a subsequent `adapter.initialized` event,
264
+ * the new `adapterId` silently overwrites the previous mapping. This is intentional:
265
+ * adapters that restart emit a fresh initialized event and the registry should
266
+ * reflect the latest instance.
267
+ * @param bus - The event bus to listen on
268
+ */
269
+ constructor(bus: IMakaioBus);
270
+ /**
271
+ * Resolve an adapterId from the event cache.
272
+ * @param adapterName - Adapter type name (e.g., `'openai-node'`, `'claude-agent-sdk'`)
273
+ * @returns The cached adapterId registered for this adapterName.
274
+ * @throws Error when no adapter with this name is present in the event cache
275
+ */
276
+ resolve(adapterName: string): string;
277
+ /**
278
+ * Resolve an adapterId from an adapterName through the runtime identity
279
+ * resolver.
280
+ *
281
+ * The `adapter.initialized` listener is a non-authoritative cache only. It
282
+ * keeps legacy event-driven tests and observers useful, but session routing
283
+ * must prefer the replayable request seam so a session created after adapter
284
+ * initialization does not miss a one-time event.
285
+ * @param adapterName - Adapter type name (e.g., `'openai-node'`)
286
+ * @returns Adapter runtime identifier for bus routing.
287
+ */
288
+ resolveAvailable(adapterName: string): Promise<string>;
289
+ /** Stop listening to `adapter.initialized` events and clear the registry. */
290
+ destroy(): void;
291
+ }
292
+ //#endregion
293
+ //#region services/core/src/session/turn-context-enricher.d.ts
294
+ /**
295
+ * Enriches messageHistory with turn-so-far messages for immediate delivery.
296
+ *
297
+ * Uses MessageStorageSubjects to load messages already persisted in the current turn.
298
+ * For immediate messages within an active turn, this provides context from:
299
+ * - The initiating user message
300
+ * - Any assistant responses from agents that have already completed
301
+ */
302
+ declare class TurnContextEnricher {
303
+ private readonly bus;
304
+ constructor(bus: IMakaioBus);
305
+ /**
306
+ * Load turn-so-far messages and convert to Message[].
307
+ * @param turnId - Turn ID to load context for
308
+ * @returns Messages representing turn-so-far context
309
+ */
310
+ getTurnSoFarContext(turnId: string): Promise<Message[]>;
311
+ /**
312
+ * Enrich messageHistory for immediate delivery mode.
313
+ * @param originalHistory - Curated history from sessionContext
314
+ * @param turnId - Turn ID for current turn
315
+ * @param deliveryMode - Message delivery mode
316
+ * @returns Enriched messageHistory (original + turn-so-far for immediate)
317
+ */
318
+ enrichForDeliveryMode(originalHistory: Message[] | undefined, turnId: string, deliveryMode: 'enqueue' | 'immediate' | 'replace' | undefined): Promise<Message[] | undefined>;
319
+ /**
320
+ * Convert SessionMessage[] to shared Message[] format.
321
+ *
322
+ * Since SessionMessageBlock and MessageBlock are unified, blocks pass through directly.
323
+ * @param sessionMessages - Messages from storage
324
+ * @returns Array of Message objects
325
+ */
326
+ private convertSessionMessagesToMessages;
327
+ }
328
+ //#endregion
329
+ //#region services/core/src/session/utils/message-utils.d.ts
330
+ /**
331
+ * Extract plain text content from a MessageInput for FTS indexing.
332
+ * @param message - The message input (string or structured)
333
+ * @returns Plain text content
334
+ */
335
+ declare function extractTextContent(message: MessageInput): string;
336
+ /**
337
+ * Normalize MessageInput to SessionMessageBlock[] for storage.
338
+ * Preserves structured blocks instead of flattening to a single text block.
339
+ * @param message - The message input (string or structured)
340
+ * @returns Array of SessionMessageBlock for storage
341
+ */
342
+ declare function normalizeToBlocks(message: MessageInput): SessionMessageBlock[];
343
+ //#endregion
344
+ //#region services/core/src/session/utils/session-utils.d.ts
345
+ /**
346
+ * Get existing session or create a new one.
347
+ * @param bus - Makaio bus instance
348
+ * @param providedSessionId - Session ID to look up
349
+ * @param _sessionContext - Optional session context (scope fields removed in W1-A)
350
+ * @param originWindowId - Window ID that initiated the session creation
351
+ * @returns Session ID and session object
352
+ */
353
+ declare function getOrCreateSession(bus: IMakaioBus, providedSessionId: string, _sessionContext?: SessionContext, originWindowId?: string): Promise<{
354
+ sessionId: string;
355
+ session: IMakaioSession;
356
+ }>;
357
+ /**
358
+ * Resolve which agents to target based on the request.
359
+ * @param session - The session containing agents
360
+ * @param targetSpec - Target: undefined (lead agent), 'all', or specific agent IDs
361
+ * @returns Resolved target agents
362
+ */
363
+ declare function resolveTargetAgents(session: IMakaioSession, targetSpec: string[] | 'all' | undefined): MakaioSessionAgent[];
364
+ /**
365
+ * Find which turn an agent belongs to.
366
+ * @param activeTurns - Active turns map
367
+ * @param agentId - The agent ID to look up
368
+ * @returns The turn containing this agent, or undefined
369
+ */
370
+ declare function findTurnByAgent(activeTurns: Map<string, Turn$1>, agentId: string): Turn$1 | undefined;
371
+ //#endregion
372
+ //#region services/core/src/session/utils/resolution.d.ts
373
+ /**
374
+ * Resolve adapterName → adapterId for bus routing.
375
+ * Queries the adapters table for a local enabled instance.
376
+ * @param bus - Bus instance
377
+ * @param adapterName - Adapter type name
378
+ * @param machineId - Optional machine ID for deterministic local resolution
379
+ * @returns Canonical adapter ID for bus routing
380
+ * @throws if no enabled instance found for this adapterName
381
+ */
382
+ declare function resolveAdapterId(bus: IMakaioBus, adapterName: string, machineId?: string): Promise<string>;
383
+ /**
384
+ * Resolve supported reasoning levels for a model from provider definitions.
385
+ *
386
+ * Looks up the provider config by ID, finds the provider definition it belongs to,
387
+ * then finds the model's `supportedReasoningLevels` in the provider's `availableModels`
388
+ * catalog.
389
+ * @param bus - Bus instance for RPC calls
390
+ * @param providerConfigId - Canonical provider config ID (ProviderConfigRecord.id)
391
+ * @param model - Model identifier to look up in the provider's catalog
392
+ * @returns Object with `supportedReasoningLevels` when found, or `undefined` when not resolvable
393
+ */
394
+ declare function resolveModelCapabilities(bus: IMakaioBus, providerConfigId: string | undefined, model: string | undefined): Promise<{
395
+ supportedReasoningLevels?: ReasoningLevelMap;
396
+ } | undefined>;
397
+ /**
398
+ * Resolves the effective execution target for a session.
399
+ * Priority: explicit executionTargetId → system default (local).
400
+ * @param bus - Makaio bus instance
401
+ * @param params - Resolution parameters from session context
402
+ * @returns Resolved execution target
403
+ */
404
+ declare function resolveExecutionTarget(bus: IMakaioBus, params: {
405
+ executionTargetId?: string;
406
+ }): Promise<ExecutionTarget>;
407
+ //#endregion
408
+ //#region services/core/src/session/utils/recovery-context.d.ts
409
+ /**
410
+ * Build sessionContext with messageHistory for a recovered agent.
411
+ * Uses getFullConversation() to assemble history from stored messages.
412
+ *
413
+ * This function is framework-safe: it has no host-layer dependencies
414
+ * (no PersonaSubjects, ProfileSubjects, VirtualModelSubjects, etc.).
415
+ * @param bus - Bus instance
416
+ * @param session - Session to build context for
417
+ * @returns SessionContext with messageHistory and isFirstTurn signal
418
+ */
419
+ declare function buildRecoveryContext(bus: IMakaioBus, session: IMakaioSession): Promise<SessionContext>;
420
+ //#endregion
421
+ //#region services/core/src/session/utils/agent-recovery.d.ts
422
+ /**
423
+ * Configuration for recovering dead agents during liveness verification.
424
+ */
425
+ interface RecoveryConfig {
426
+ /** Working directory for agent execution */
427
+ cwd?: string;
428
+ /** Model identifier (e.g., 'claude-sonnet-4-20250514', 'gpt-4o') */
429
+ model?: string;
430
+ }
431
+ /**
432
+ * Ensure agent cwd matches desired cwd, swapping connector if needed.
433
+ * Must be called while agent is idle (before message routing).
434
+ * @param bus - Bus instance
435
+ * @param agent - Agent to validate/swap
436
+ * @param desiredCwd - Target working directory
437
+ * @param options - Optional request flags (e.g., skip interactive warnings)
438
+ * @returns Swap result with previous cwd when a swap occurred
439
+ */
440
+ declare function ensureAgentCwd(bus: IMakaioBus, agent: MakaioSessionAgent, desiredCwd: string, options?: {
441
+ skipWarning?: boolean;
442
+ }): Promise<{
443
+ swapped: false;
444
+ } | {
445
+ swapped: true;
446
+ previousCwd: string;
447
+ }>;
448
+ /**
449
+ * Ensure an agent uses the desired model and/or reasoning effort, performing an
450
+ * in-place change or connector swap as needed.
451
+ *
452
+ * Mirrors the `ensureAgentCwd()` pattern. At least one of `desiredModel`,
453
+ * `options.reasoningEffort`, or `options.providerConfigId` must be defined for a
454
+ * change to occur.
455
+ * @param bus - The bus instance for RPC
456
+ * @param agent - The agent to change (mutated in-place on success)
457
+ * @param desiredModel - The model identifier to switch to, or undefined to keep current model
458
+ * @param options - Optional configuration: `providerConfigId` triggers a swap when it differs from the
459
+ * current one; `reasoningEffort` is applied after the model change; `skipWarning` suppresses the
460
+ * model-change confirmation dialog
461
+ * @returns Discriminated union: no change, or changed with swap info
462
+ */
463
+ declare function ensureAgentModel(bus: IMakaioBus, agent: MakaioSessionAgent, desiredModel: string | undefined, options?: {
464
+ providerConfigId?: string;
465
+ reasoningEffort?: AIReasoningLevel;
466
+ skipWarning?: boolean;
467
+ }): Promise<{
468
+ changed: false;
469
+ } | {
470
+ changed: true;
471
+ swapped: boolean;
472
+ }>;
473
+ /**
474
+ * Verify liveness of agents and recover any that are dead.
475
+ * Queries each agent via getAgent; if unresponsive, triggers connector swap via recoverAgent.
476
+ * @param bus - Bus instance
477
+ * @param agents - Agents to verify
478
+ * @param recoveryConfig - Configuration for recovering dead agents
479
+ * @returns Verified/recovered agents and set of recovered agent IDs
480
+ */
481
+ declare function verifyAndRecoverAgents(bus: IMakaioBus, agents: MakaioSessionAgent[], recoveryConfig: RecoveryConfig): Promise<{
482
+ verifiedAgents: MakaioSessionAgent[];
483
+ recoveredAgentIds: Set<string>;
484
+ }>;
485
+ /**
486
+ * Build recovery context and apply optional additional transforms.
487
+ * @param bus - Bus instance
488
+ * @param session - Session to build context for
489
+ * @param options - Optional transform pipeline to run before conversion
490
+ * @returns SessionContext with transformed messageHistory and fresh-mode signal
491
+ */
492
+ declare function buildRecoveryContextWithPipeline(bus: IMakaioBus, session: IMakaioSession, options?: {
493
+ pipeline?: PipelineStep[];
494
+ }): Promise<SessionContext>;
495
+ /**
496
+ * Recover a dead agent by triggering connector swap via the adapter.
497
+ * The agent keeps its identity — no session mutation needed.
498
+ *
499
+ * Context delivery happens via the normal sendMessage path that follows
500
+ * recovery (same handler invocation). No staging needed.
501
+ * @param bus - Bus instance
502
+ * @param deadAgent - The dead agent to recover
503
+ * @param recoveryConfig - Configuration for the recovered connector
504
+ * @returns Same agent reference — identity preserved
505
+ */
506
+ declare function recoverAgent(bus: IMakaioBus, deadAgent: MakaioSessionAgent, recoveryConfig: RecoveryConfig): Promise<MakaioSessionAgent>;
507
+ //#endregion
508
+ //#region services/core/src/session/utils/turn-initiator.d.ts
509
+ /**
510
+ * Builds turn initiator metadata from `sendMessage` source fields.
511
+ *
512
+ * Returns `{ source: 'extension', sourceId: extensionId }` for extension-initiated turns,
513
+ * `{ source }` for other explicit sources, or `{ source: 'user' }` as the default.
514
+ * @param source - Optional turn origin discriminator
515
+ * @param extensionId - Required when `source === 'extension'`
516
+ * @returns Normalised turn initiator
517
+ * @throws Error when `source` is `'extension'` and `extensionId` is absent or blank
518
+ */
519
+ declare function buildTurnInitiator(source: 'extension' | 'user' | 'system' | undefined, extensionId: string | undefined): TurnInitiator;
520
+ //#endregion
521
+ //#region services/core/src/session/context-window/types.d.ts
522
+ /**
523
+ * Context window tracking types for per-session aggregation.
524
+ *
525
+ * The tracker monitors AgentSubjects.contextWindow.updated events
526
+ * and maintains per-session state using "worst agent" aggregation.
527
+ */
528
+ /**
529
+ * Per-session context window state, aggregated across agents.
530
+ *
531
+ * Uses "worst agent" strategy: reports the state of whichever
532
+ * agent has the highest usage percentage.
533
+ */
534
+ interface SessionContextWindowState {
535
+ /** Current token count (worst across agents) */
536
+ currentTokens: number;
537
+ /** Max tokens for the model with lowest headroom */
538
+ maxTokens: number;
539
+ /** Percentage used (0-100) */
540
+ percentage: number;
541
+ /** Warning level based on percentage */
542
+ level: 'ok' | 'warn' | 'critical';
543
+ /** Agent ID with the highest usage */
544
+ worstAgentId?: string;
545
+ /** Timestamp of last update */
546
+ lastUpdatedAt: number;
547
+ }
548
+ /**
549
+ * Per-agent context state (internal tracking).
550
+ *
551
+ * Stored by the tracker to enable per-session aggregation
552
+ * when multiple agents are attached to the same session.
553
+ */
554
+ interface AgentContextState {
555
+ agentId: string;
556
+ sessionId: string;
557
+ currentTokens: number;
558
+ maxTokens: number;
559
+ percentage: number;
560
+ level: 'ok' | 'warn' | 'critical';
561
+ cachedTokens?: number;
562
+ updatedAt: number;
563
+ }
564
+ /**
565
+ * Tracker configuration options.
566
+ */
567
+ interface ContextWindowTrackerConfig {
568
+ /** How long to keep stale agent entries (ms). Default: 1 hour */
569
+ staleThresholdMs?: number;
570
+ }
571
+ //#endregion
572
+ //#region services/core/src/session/context-window/context-window-tracker.d.ts
573
+ /**
574
+ * Tracks context window state per session, aggregating across agents.
575
+ *
576
+ * Subscribes to AgentSubjects.contextWindow.updated and maintains
577
+ * per-session state using "worst agent" aggregation strategy.
578
+ * @example
579
+ * ```typescript
580
+ * const tracker = new ContextWindowTracker(MakaioBus);
581
+ * tracker.start();
582
+ *
583
+ * // Later, query session state
584
+ * const state = tracker.getSessionState('session-123');
585
+ * if (state?.level === 'critical') {
586
+ * // Suggest compression
587
+ * }
588
+ *
589
+ * // Cleanup on shutdown
590
+ * tracker.stop();
591
+ * ```
592
+ */
593
+ declare class ContextWindowTracker {
594
+ private readonly bus;
595
+ private readonly agentStates;
596
+ private readonly sessionStates;
597
+ private unsubscribe?;
598
+ private readonly staleThresholdMs;
599
+ constructor(bus: IMakaioBus, config?: ContextWindowTrackerConfig);
600
+ /**
601
+ * Start tracking context window updates.
602
+ * Idempotent - calling multiple times is safe.
603
+ */
604
+ start(): void;
605
+ /**
606
+ * Stop tracking and clear all state.
607
+ */
608
+ stop(): void;
609
+ /**
610
+ * Get aggregated context state for a session.
611
+ *
612
+ * State persists until explicitly cleared via clearSession().
613
+ * Clear is called by MakaioSessionService on:
614
+ * - session.close (session closed)
615
+ * - session.compressed (context compression)
616
+ *
617
+ * Even if we haven't heard from agents recently, the context window
618
+ * is still full - the state remains valid.
619
+ * @param sessionId - The session to get state for
620
+ * @returns The aggregated context window state, or undefined if no data
621
+ */
622
+ getSessionState(sessionId: string): SessionContextWindowState | undefined;
623
+ /**
624
+ * Clear state for a specific session (e.g., on session close).
625
+ * Removes both the session state and all agent states for that session.
626
+ * @param sessionId - The session to clear
627
+ */
628
+ clearSession(sessionId: string): void;
629
+ /**
630
+ * Recompute session state from all agents in that session.
631
+ * Uses "worst agent" strategy - highest percentage wins.
632
+ *
633
+ * Stale agent entries are pruned for memory management, but session
634
+ * state is preserved - context window is still full even if agent
635
+ * hasn't reported recently.
636
+ * @param sessionId - The session to recompute
637
+ */
638
+ private recomputeSessionState;
639
+ }
640
+ //#endregion
641
+ //#region services/core/src/session/handlers/lifecycle-handlers.d.ts
642
+ /**
643
+ * Dependencies for session lifecycle handlers.
644
+ */
645
+ interface SessionLifecycleDeps {
646
+ bus: IMakaioBus;
647
+ contextTracker: ContextWindowTracker;
648
+ }
649
+ /**
650
+ * Register handler for session.getStatusCounts.
651
+ * @param deps - Handler dependencies
652
+ * @returns Cleanup function
653
+ */
654
+ declare function registerGetStatusCountsHandler(deps: SessionLifecycleDeps): () => void;
655
+ /**
656
+ * Register handler for session.resume.
657
+ * @param deps - Handler dependencies
658
+ * @returns Cleanup function
659
+ */
660
+ declare function registerResumeHandler(deps: SessionLifecycleDeps): () => void;
661
+ //#endregion
662
+ //#region services/core/src/session/session-editor/action-registry.d.ts
663
+ /**
664
+ * Registry for pipeline actions.
665
+ * Actions are registered at startup and looked up during pipeline execution.
666
+ */
667
+ declare class ActionRegistry {
668
+ private actions;
669
+ /**
670
+ * Register a pipeline action.
671
+ * @param action - Action definition
672
+ */
673
+ register(action: SessionEditorAction): void;
674
+ /**
675
+ * Get an action by ID.
676
+ * @param id - Action identifier
677
+ * @returns Action or undefined if not found
678
+ */
679
+ get(id: string): SessionEditorAction | undefined;
680
+ /**
681
+ * Get all registered actions.
682
+ * @returns Array of all actions
683
+ */
684
+ getAll(): SessionEditorAction[];
685
+ /**
686
+ * Get actions by category.
687
+ * @param category - Category to filter by
688
+ * @returns Actions in that category
689
+ */
690
+ getByCategory(category: ActionCategory): SessionEditorAction[];
691
+ /**
692
+ * Clear all registered actions.
693
+ * @internal For testing only - clears state between tests.
694
+ */
695
+ reset(): void;
696
+ }
697
+ /** Global action registry instance */
698
+ declare const actionRegistry: ActionRegistry;
699
+ //#endregion
700
+ //#region services/core/src/session/session-editor/actions/index.d.ts
701
+ /**
702
+ * Register all built-in actions.
703
+ * Call this at service startup. Safe to call multiple times.
704
+ *
705
+ * Base actions (no bus required) are registered once on first call.
706
+ * Bus-dependent actions (e.g. llm-extract) are registered on the first
707
+ * call that supplies a `bus` instance, independently of whether base
708
+ * registration has already occurred.
709
+ * @param bus - Optional bus instance. When provided, bus-dependent actions
710
+ * (e.g. llm-extract) are also registered. Existing callers that pass no
711
+ * args continue to work without change.
712
+ */
713
+ declare function registerBuiltInActions(bus?: IMakaioBus): void;
714
+ /**
715
+ * Reset registration state.
716
+ * @internal For testing only.
717
+ */
718
+ declare function resetBuiltInActionsRegistration(): void;
719
+ //#endregion
720
+ //#region services/core/src/session/session-editor/handlers.d.ts
721
+ /**
722
+ * Register handler for session-editor.listActions.
723
+ *
724
+ * Maps all registered actions to UI-safe summaries by stripping the execute
725
+ * method and keeping only id, label, description, and category.
726
+ * @param bus - Bus instance to register on
727
+ * @returns Cleanup function to unsubscribe the handler
728
+ */
729
+ declare function registerListActionsHandler(bus: IMakaioBus): () => void;
730
+ //#endregion
731
+ //#region services/core/src/session/selection-utils.d.ts
732
+ /**
733
+ * Normalize a selection string field by trimming whitespace and coercing
734
+ * blank strings to `undefined`.
735
+ *
736
+ * Used wherever adapter/agent selection strings are read from wire payloads to
737
+ * ensure callers cannot accidentally pass whitespace-only values as meaningful
738
+ * adapter names or IDs.
739
+ * @param value - Candidate string value from a selection payload field
740
+ * @returns Trimmed non-empty string, or `undefined` when the input is absent
741
+ * or contains only whitespace
742
+ */
743
+ declare function normalizeSelectionString(value: string | undefined): string | undefined;
744
+ /**
745
+ * Resolve the canonical `adapterName` for a given deterministic `adapterId`,
746
+ * rejecting when the caller-supplied name does not match the subsystem lookup.
747
+ *
748
+ * The adapter runtime owns reverse lookup for deterministic IDs, including
749
+ * remote-machine IDs that still identify a known adapter type.
750
+ * @param bus - Bus instance used to query the adapter runtime reverse lookup
751
+ * @param adapterId - Adapter instance identifier to look up
752
+ * @param explicitAdapterName - Caller-supplied name to validate against storage;
753
+ * `undefined` skips the mismatch check
754
+ * @param errorPrefix - Prefix prepended to thrown error messages (include trailing space)
755
+ * @returns Canonical adapter name resolved by the adapter runtime
756
+ */
757
+ declare function resolveAdapterNameById(bus: IMakaioBus, adapterId: string, explicitAdapterName: string | undefined, errorPrefix: string): Promise<string>;
758
+ //#endregion
759
+ //#region services/core/src/session/constants.d.ts
760
+ /** Default transform pipeline for connector-swap history injection. */
761
+ declare const CONNECTOR_SWAP_DEFAULT_PIPELINE: PipelineStep[];
762
+ //#endregion
763
+ //#region services/core/src/session/fallback-runtime-options.d.ts
764
+ /**
765
+ * Runtime options preserved across a VirtualModel fallback hop.
766
+ *
767
+ * These fields are extracted from the original `agent.attach` or `adapter.startAgent`
768
+ * payload and re-applied to the fallback attach so the replacement agent
769
+ * inherits the same execution environment (cwd, tool restrictions, system prompt).
770
+ *
771
+ * `allowedDirectories` is intentionally excluded — directory restrictions are
772
+ * resolved at attach time and must not be blindly forwarded across adapter hops.
773
+ */
774
+ type FallbackRuntimeOptions = Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt' | 'allowedTools' | 'disallowedTools'>;
775
+ /**
776
+ * Picks fallback-relevant runtime options from an object that carries
777
+ * `AdapterRuntimeOptions`-compatible fields.
778
+ *
779
+ * Covers both `adapter.startAgent` payloads (which merge `AdapterRuntimeOptionsSchema`
780
+ * at the top level) and caller-extracted `agent` sub-objects from
781
+ * `session.agent.attach` payloads (which carry the same fields on `AgentSelectionBase`).
782
+ *
783
+ * Only defined fields are included — omitted keys are not forwarded to avoid
784
+ * overwriting adapter or schema defaults with `undefined`.
785
+ * @param payload - Object carrying the runtime option fields
786
+ * @returns Sparse runtime options object used for fallback attach
787
+ */
788
+ declare function pickFallbackRuntimeOptions(payload: Partial<Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt' | 'allowedTools' | 'disallowedTools'>>): FallbackRuntimeOptions;
789
+ //#endregion
790
+ //#region services/core/src/session/context/assemble-fork-context.d.ts
791
+ /**
792
+ * Assemble fork context for a session's first turn.
793
+ *
794
+ * For fork sessions on their first turn, this:
795
+ * 1. Detects if this is a fork session (has parentSessionId)
796
+ * 2. Checks if this is the first turn (via isNewTurn flag + storage query)
797
+ * 3. Calls getFullConversation() to get projected context with transforms
798
+ * 4. Converts SessionMessage[] to Message[] format
799
+ * 5. Returns enriched SessionContext with messageHistory
800
+ *
801
+ * If not a fork first turn, returns the original sessionContext unchanged.
802
+ * @param bus - Bus instance for RPC calls
803
+ * @param session - Session to check for fork context
804
+ * @param sessionId - Session ID
805
+ * @param originalContext - Original sessionContext from payload
806
+ * @param isNewTurn - Whether this is a new turn (avoids race with just-created turn record)
807
+ * @returns Enriched or original SessionContext
808
+ */
809
+ declare function assembleForkContext(bus: IMakaioBus, session: IMakaioSession, sessionId: string, originalContext?: SessionContext, isNewTurn?: boolean): Promise<SessionContext | undefined>;
810
+ //#endregion
811
+ //#region services/core/src/session/session-bridge.d.ts
812
+ declare class SessionBridge {
813
+ private readonly bus;
814
+ private readonly agentToSession;
815
+ /** Extended mapping: agentId -\> \{ sessionId, turnId, adapterSessionId \} */
816
+ private readonly agentContext;
817
+ /** Block accumulator: agentId -\> blocks (one agent = one response per turn) */
818
+ private readonly agentBlocks;
819
+ private readonly cleanups;
820
+ constructor(bus?: IMakaioBus);
821
+ private registerHandlers;
822
+ /**
823
+ * Build and maintain agentId→sessionId mapping.
824
+ */
825
+ private registerMappingHandlers;
826
+ /**
827
+ * Track turn assignments for agents.
828
+ */
829
+ private registerTurnTrackingHandlers;
830
+ /**
831
+ * Accumulate blocks from agent events for storage on complete.
832
+ */
833
+ private registerBlockAccumulationHandlers;
834
+ /**
835
+ * Store accumulated blocks as an assistant message.
836
+ * @param agentId - ID of the agent that produced the message
837
+ * @param adapterSessionId - Optional adapter session ID
838
+ * @param error - Optional error message if agent failed
839
+ * @param messageOverride - Optional validated terminal message to store instead of accumulated provider blocks
840
+ */
841
+ private storeAssistantMessage;
842
+ /**
843
+ * Stop the bridge and clean up subscriptions.
844
+ */
845
+ destroy(): void;
846
+ }
847
+ //#endregion
848
+ //#region services/core/src/session/extension-context.d.ts
849
+ /**
850
+ * Implementation of SessionExtensionContext.
851
+ * Routes all actions through bus subjects.
852
+ */
853
+ declare class SessionExtensionContextImpl implements SessionExtensionContext {
854
+ private readonly bus;
855
+ private readonly _sessionId;
856
+ private readonly _extensionId;
857
+ private readonly _turnId?;
858
+ private readonly _parentSessionId?;
859
+ private readonly contextTracker?;
860
+ private readonly contextContributions;
861
+ constructor(bus: IMakaioBus, _sessionId: string, _extensionId: string, _turnId?: string | undefined, _parentSessionId?: string | undefined, contextTracker?: ContextWindowTracker | undefined);
862
+ get sessionId(): string;
863
+ get turnId(): string | undefined;
864
+ get parentSessionId(): string | undefined;
865
+ get extensionId(): string;
866
+ sendToAgent(agentId: string, message: Message): Promise<void>;
867
+ contributeContext(key: string, value: unknown): void;
868
+ /**
869
+ * Get all contributions (called by orchestrator at turn boundary).
870
+ * @returns Record of all context contributions
871
+ */
872
+ getContributions(): Record<string, unknown>;
873
+ fork(options: ForkOptions): Promise<string>;
874
+ merge(childSessionId: string, summary?: string): Promise<void>;
875
+ abandon(childSessionId: string): Promise<void>;
876
+ requestCompression(reason: string): Promise<void>;
877
+ getContextWindowState(): Promise<ContextWindowState>;
878
+ getChildSessions(): Promise<string[]>;
879
+ }
880
+ /**
881
+ * Factory function for creating SessionExtensionContext instances.
882
+ * @param bus - The bus instance for communication
883
+ * @param sessionId - The session identifier
884
+ * @param extensionId - The extension identifier for audit trail
885
+ * @param turnId - Optional current turn identifier
886
+ * @param parentSessionId - Optional parent session identifier (for forked sessions)
887
+ * @param contextTracker - Optional ContextWindowTracker for real-time context state
888
+ * @returns A new SessionExtensionContextImpl instance
889
+ */
890
+ declare function createSessionExtensionContext(bus: IMakaioBus, sessionId: string, extensionId: string, turnId?: string, parentSessionId?: string, contextTracker?: ContextWindowTracker): SessionExtensionContextImpl;
891
+ //#endregion
892
+ //#region services/core/src/session/storage/agent-namespace.d.ts
893
+ /**
894
+ * Agent storage namespace.
895
+ *
896
+ * Provides bus subjects for agent CRUD operations and
897
+ * Drizzle schemas for SQL-based persistence.
898
+ * @example
899
+ * ```typescript
900
+ * import { AgentStorageSubjects } from '@makaio/framework/services/session';
901
+ *
902
+ * const { agent } = await bus.request(AgentStorageSubjects.get, { agentId: '123' });
903
+ * ```
904
+ */
905
+ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDefinition<"agent", {
906
+ /**
907
+ * Get an agent by ID.
908
+ *
909
+ * Subject: `storage:agent.get`
910
+ * Type: Request (RPC)
911
+ */
912
+ get: {
913
+ request: z.ZodObject<{
914
+ agentId: z.ZodString;
915
+ }, z.core.$strip>;
916
+ response: z.ZodObject<{
917
+ agent: z.ZodNullable<z.ZodObject<{
918
+ agentId: z.ZodString;
919
+ adapterId: z.ZodString;
920
+ adapterName: z.ZodString;
921
+ sessionId: z.ZodString;
922
+ adapterSessionId: z.ZodOptional<z.ZodString>;
923
+ model: z.ZodOptional<z.ZodString>;
924
+ cwd: z.ZodOptional<z.ZodString>;
925
+ providerConfigId: z.ZodOptional<z.ZodString>;
926
+ personaId: z.ZodOptional<z.ZodString>;
927
+ profileId: z.ZodOptional<z.ZodString>;
928
+ harnessId: z.ZodOptional<z.ZodString>;
929
+ clientId: z.ZodOptional<z.ZodString>;
930
+ compressionMode: z.ZodOptional<z.ZodEnum<{
931
+ auto: "auto";
932
+ manual: "manual";
933
+ off: "off";
934
+ }>>;
935
+ role: z.ZodEnum<{
936
+ lead: "lead";
937
+ member: "member";
938
+ }>;
939
+ status: z.ZodEnum<{
940
+ active: "active";
941
+ idle: "idle";
942
+ dead: "dead";
943
+ disposed: "disposed";
944
+ }>;
945
+ createdAt: z.ZodNumber;
946
+ lastActivityAt: z.ZodNumber;
947
+ }, z.core.$strip>>;
948
+ }, z.core.$strip>;
949
+ };
950
+ /**
951
+ * Store or update an agent.
952
+ *
953
+ * Subject: `storage:agent.set`
954
+ * Type: Request (RPC)
955
+ */
956
+ set: {
957
+ request: z.ZodObject<{
958
+ agentId: z.ZodString;
959
+ agent: z.ZodObject<{
960
+ agentId: z.ZodString;
961
+ adapterId: z.ZodString;
962
+ adapterName: z.ZodString;
963
+ sessionId: z.ZodString;
964
+ adapterSessionId: z.ZodOptional<z.ZodString>;
965
+ model: z.ZodOptional<z.ZodString>;
966
+ cwd: z.ZodOptional<z.ZodString>;
967
+ providerConfigId: z.ZodOptional<z.ZodString>;
968
+ personaId: z.ZodOptional<z.ZodString>;
969
+ profileId: z.ZodOptional<z.ZodString>;
970
+ harnessId: z.ZodOptional<z.ZodString>;
971
+ clientId: z.ZodOptional<z.ZodString>;
972
+ compressionMode: z.ZodOptional<z.ZodEnum<{
973
+ auto: "auto";
974
+ manual: "manual";
975
+ off: "off";
976
+ }>>;
977
+ role: z.ZodEnum<{
978
+ lead: "lead";
979
+ member: "member";
980
+ }>;
981
+ status: z.ZodEnum<{
982
+ active: "active";
983
+ idle: "idle";
984
+ dead: "dead";
985
+ disposed: "disposed";
986
+ }>;
987
+ createdAt: z.ZodNumber;
988
+ lastActivityAt: z.ZodNumber;
989
+ }, z.core.$strip>;
990
+ }, z.core.$strip>;
991
+ response: z.ZodObject<{
992
+ success: z.ZodBoolean;
993
+ }, z.core.$strip>;
994
+ };
995
+ /**
996
+ * Delete an agent by ID.
997
+ *
998
+ * Subject: `storage:agent.delete`
999
+ * Type: Request (RPC)
1000
+ */
1001
+ delete: {
1002
+ request: z.ZodObject<{
1003
+ agentId: z.ZodString;
1004
+ }, z.core.$strip>;
1005
+ response: z.ZodObject<{
1006
+ success: z.ZodBoolean;
1007
+ }, z.core.$strip>;
1008
+ };
1009
+ /**
1010
+ * List agents by adapter name with optional status filter.
1011
+ *
1012
+ * Subject: `storage:agent.listByAdapter`
1013
+ * Type: Request (RPC)
1014
+ */
1015
+ listByAdapter: {
1016
+ request: z.ZodObject<{
1017
+ adapterName: z.ZodString;
1018
+ status: z.ZodOptional<z.ZodEnum<{
1019
+ all: "all";
1020
+ active: "active";
1021
+ idle: "idle";
1022
+ dead: "dead";
1023
+ disposed: "disposed";
1024
+ }>>;
1025
+ }, z.core.$strip>;
1026
+ response: z.ZodObject<{
1027
+ agents: z.ZodArray<z.ZodObject<{
1028
+ agentId: z.ZodString;
1029
+ adapterId: z.ZodString;
1030
+ adapterName: z.ZodString;
1031
+ sessionId: z.ZodString;
1032
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1033
+ model: z.ZodOptional<z.ZodString>;
1034
+ cwd: z.ZodOptional<z.ZodString>;
1035
+ providerConfigId: z.ZodOptional<z.ZodString>;
1036
+ personaId: z.ZodOptional<z.ZodString>;
1037
+ profileId: z.ZodOptional<z.ZodString>;
1038
+ harnessId: z.ZodOptional<z.ZodString>;
1039
+ clientId: z.ZodOptional<z.ZodString>;
1040
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1041
+ auto: "auto";
1042
+ manual: "manual";
1043
+ off: "off";
1044
+ }>>;
1045
+ role: z.ZodEnum<{
1046
+ lead: "lead";
1047
+ member: "member";
1048
+ }>;
1049
+ status: z.ZodEnum<{
1050
+ active: "active";
1051
+ idle: "idle";
1052
+ dead: "dead";
1053
+ disposed: "disposed";
1054
+ }>;
1055
+ createdAt: z.ZodNumber;
1056
+ lastActivityAt: z.ZodNumber;
1057
+ }, z.core.$strip>>;
1058
+ }, z.core.$strip>;
1059
+ };
1060
+ /**
1061
+ * List agents by session ID.
1062
+ *
1063
+ * Subject: `storage:agent.listBySession`
1064
+ * Type: Request (RPC)
1065
+ */
1066
+ listBySession: {
1067
+ request: z.ZodObject<{
1068
+ sessionId: z.ZodString;
1069
+ }, z.core.$strip>;
1070
+ response: z.ZodObject<{
1071
+ agents: z.ZodArray<z.ZodObject<{
1072
+ agentId: z.ZodString;
1073
+ adapterId: z.ZodString;
1074
+ adapterName: z.ZodString;
1075
+ sessionId: z.ZodString;
1076
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1077
+ model: z.ZodOptional<z.ZodString>;
1078
+ cwd: z.ZodOptional<z.ZodString>;
1079
+ providerConfigId: z.ZodOptional<z.ZodString>;
1080
+ personaId: z.ZodOptional<z.ZodString>;
1081
+ profileId: z.ZodOptional<z.ZodString>;
1082
+ harnessId: z.ZodOptional<z.ZodString>;
1083
+ clientId: z.ZodOptional<z.ZodString>;
1084
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1085
+ auto: "auto";
1086
+ manual: "manual";
1087
+ off: "off";
1088
+ }>>;
1089
+ role: z.ZodEnum<{
1090
+ lead: "lead";
1091
+ member: "member";
1092
+ }>;
1093
+ status: z.ZodEnum<{
1094
+ active: "active";
1095
+ idle: "idle";
1096
+ dead: "dead";
1097
+ disposed: "disposed";
1098
+ }>;
1099
+ createdAt: z.ZodNumber;
1100
+ lastActivityAt: z.ZodNumber;
1101
+ }, z.core.$strip>>;
1102
+ }, z.core.$strip>;
1103
+ };
1104
+ /**
1105
+ * Update agent status.
1106
+ *
1107
+ * Subject: `storage:agent.updateStatus`
1108
+ * Type: Request (RPC)
1109
+ */
1110
+ updateStatus: {
1111
+ request: z.ZodObject<{
1112
+ agentId: z.ZodString;
1113
+ status: z.ZodEnum<{
1114
+ active: "active";
1115
+ idle: "idle";
1116
+ dead: "dead";
1117
+ disposed: "disposed";
1118
+ }>;
1119
+ }, z.core.$strip>;
1120
+ response: z.ZodObject<{
1121
+ success: z.ZodBoolean;
1122
+ }, z.core.$strip>;
1123
+ };
1124
+ /**
1125
+ * Update agent last activity timestamp.
1126
+ *
1127
+ * Subject: `storage:agent.updateActivity`
1128
+ * Type: Request (RPC)
1129
+ */
1130
+ updateActivity: {
1131
+ request: z.ZodObject<{
1132
+ agentId: z.ZodString;
1133
+ lastActivityAt: z.ZodNumber;
1134
+ }, z.core.$strip>;
1135
+ response: z.ZodObject<{
1136
+ success: z.ZodBoolean;
1137
+ }, z.core.$strip>;
1138
+ };
1139
+ /**
1140
+ * Update runtime-mutable agent fields without full record overwrite.
1141
+ *
1142
+ * Subject: `storage:agent.updateRuntime`
1143
+ * Type: Request (RPC)
1144
+ */
1145
+ updateRuntime: {
1146
+ request: z.ZodObject<{
1147
+ agentId: z.ZodString;
1148
+ cwd: z.ZodOptional<z.ZodString>;
1149
+ model: z.ZodOptional<z.ZodString>;
1150
+ providerConfigId: z.ZodOptional<z.ZodString>;
1151
+ }, z.core.$strip>;
1152
+ response: z.ZodObject<{
1153
+ success: z.ZodBoolean;
1154
+ }, z.core.$strip>;
1155
+ };
1156
+ }, {
1157
+ drizzle: {
1158
+ agents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
1159
+ name: "agents";
1160
+ schema: undefined;
1161
+ columns: {
1162
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1163
+ name: "agent_id";
1164
+ tableName: "agents";
1165
+ dataType: "string";
1166
+ columnType: "SQLiteText";
1167
+ data: string;
1168
+ driverParam: string;
1169
+ notNull: true;
1170
+ hasDefault: false;
1171
+ isPrimaryKey: true;
1172
+ isAutoincrement: false;
1173
+ hasRuntimeDefault: false;
1174
+ enumValues: [string, ...string[]];
1175
+ baseColumn: never;
1176
+ identity: undefined;
1177
+ generated: undefined;
1178
+ }, {}, {
1179
+ length: number | undefined;
1180
+ }>;
1181
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1182
+ name: "adapter_id";
1183
+ tableName: "agents";
1184
+ dataType: "string";
1185
+ columnType: "SQLiteText";
1186
+ data: string;
1187
+ driverParam: string;
1188
+ notNull: true;
1189
+ hasDefault: false;
1190
+ isPrimaryKey: false;
1191
+ isAutoincrement: false;
1192
+ hasRuntimeDefault: false;
1193
+ enumValues: [string, ...string[]];
1194
+ baseColumn: never;
1195
+ identity: undefined;
1196
+ generated: undefined;
1197
+ }, {}, {
1198
+ length: number | undefined;
1199
+ }>;
1200
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1201
+ name: "adapter_name";
1202
+ tableName: "agents";
1203
+ dataType: "string";
1204
+ columnType: "SQLiteText";
1205
+ data: string;
1206
+ driverParam: string;
1207
+ notNull: true;
1208
+ hasDefault: false;
1209
+ isPrimaryKey: false;
1210
+ isAutoincrement: false;
1211
+ hasRuntimeDefault: false;
1212
+ enumValues: [string, ...string[]];
1213
+ baseColumn: never;
1214
+ identity: undefined;
1215
+ generated: undefined;
1216
+ }, {}, {
1217
+ length: number | undefined;
1218
+ }>;
1219
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1220
+ name: "session_id";
1221
+ tableName: "agents";
1222
+ dataType: "string";
1223
+ columnType: "SQLiteText";
1224
+ data: string;
1225
+ driverParam: string;
1226
+ notNull: true;
1227
+ hasDefault: false;
1228
+ isPrimaryKey: false;
1229
+ isAutoincrement: false;
1230
+ hasRuntimeDefault: false;
1231
+ enumValues: [string, ...string[]];
1232
+ baseColumn: never;
1233
+ identity: undefined;
1234
+ generated: undefined;
1235
+ }, {}, {
1236
+ length: number | undefined;
1237
+ }>;
1238
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1239
+ name: "adapter_session_id";
1240
+ tableName: "agents";
1241
+ dataType: "string";
1242
+ columnType: "SQLiteText";
1243
+ data: string;
1244
+ driverParam: string;
1245
+ notNull: false;
1246
+ hasDefault: false;
1247
+ isPrimaryKey: false;
1248
+ isAutoincrement: false;
1249
+ hasRuntimeDefault: false;
1250
+ enumValues: [string, ...string[]];
1251
+ baseColumn: never;
1252
+ identity: undefined;
1253
+ generated: undefined;
1254
+ }, {}, {
1255
+ length: number | undefined;
1256
+ }>;
1257
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1258
+ name: "model";
1259
+ tableName: "agents";
1260
+ dataType: "string";
1261
+ columnType: "SQLiteText";
1262
+ data: string;
1263
+ driverParam: string;
1264
+ notNull: false;
1265
+ hasDefault: false;
1266
+ isPrimaryKey: false;
1267
+ isAutoincrement: false;
1268
+ hasRuntimeDefault: false;
1269
+ enumValues: [string, ...string[]];
1270
+ baseColumn: never;
1271
+ identity: undefined;
1272
+ generated: undefined;
1273
+ }, {}, {
1274
+ length: number | undefined;
1275
+ }>;
1276
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1277
+ name: "cwd";
1278
+ tableName: "agents";
1279
+ dataType: "string";
1280
+ columnType: "SQLiteText";
1281
+ data: string;
1282
+ driverParam: string;
1283
+ notNull: false;
1284
+ hasDefault: false;
1285
+ isPrimaryKey: false;
1286
+ isAutoincrement: false;
1287
+ hasRuntimeDefault: false;
1288
+ enumValues: [string, ...string[]];
1289
+ baseColumn: never;
1290
+ identity: undefined;
1291
+ generated: undefined;
1292
+ }, {}, {
1293
+ length: number | undefined;
1294
+ }>;
1295
+ providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1296
+ name: "provider_config_id";
1297
+ tableName: "agents";
1298
+ dataType: "string";
1299
+ columnType: "SQLiteText";
1300
+ data: string;
1301
+ driverParam: string;
1302
+ notNull: false;
1303
+ hasDefault: false;
1304
+ isPrimaryKey: false;
1305
+ isAutoincrement: false;
1306
+ hasRuntimeDefault: false;
1307
+ enumValues: [string, ...string[]];
1308
+ baseColumn: never;
1309
+ identity: undefined;
1310
+ generated: undefined;
1311
+ }, {}, {
1312
+ length: number | undefined;
1313
+ }>;
1314
+ personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1315
+ name: "persona_id";
1316
+ tableName: "agents";
1317
+ dataType: "string";
1318
+ columnType: "SQLiteText";
1319
+ data: string;
1320
+ driverParam: string;
1321
+ notNull: false;
1322
+ hasDefault: false;
1323
+ isPrimaryKey: false;
1324
+ isAutoincrement: false;
1325
+ hasRuntimeDefault: false;
1326
+ enumValues: [string, ...string[]];
1327
+ baseColumn: never;
1328
+ identity: undefined;
1329
+ generated: undefined;
1330
+ }, {}, {
1331
+ length: number | undefined;
1332
+ }>;
1333
+ profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1334
+ name: "profile_id";
1335
+ tableName: "agents";
1336
+ dataType: "string";
1337
+ columnType: "SQLiteText";
1338
+ data: string;
1339
+ driverParam: string;
1340
+ notNull: false;
1341
+ hasDefault: false;
1342
+ isPrimaryKey: false;
1343
+ isAutoincrement: false;
1344
+ hasRuntimeDefault: false;
1345
+ enumValues: [string, ...string[]];
1346
+ baseColumn: never;
1347
+ identity: undefined;
1348
+ generated: undefined;
1349
+ }, {}, {
1350
+ length: number | undefined;
1351
+ }>;
1352
+ harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1353
+ name: "harness_id";
1354
+ tableName: "agents";
1355
+ dataType: "string";
1356
+ columnType: "SQLiteText";
1357
+ data: string;
1358
+ driverParam: string;
1359
+ notNull: false;
1360
+ hasDefault: false;
1361
+ isPrimaryKey: false;
1362
+ isAutoincrement: false;
1363
+ hasRuntimeDefault: false;
1364
+ enumValues: [string, ...string[]];
1365
+ baseColumn: never;
1366
+ identity: undefined;
1367
+ generated: undefined;
1368
+ }, {}, {
1369
+ length: number | undefined;
1370
+ }>;
1371
+ clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1372
+ name: "client_id";
1373
+ tableName: "agents";
1374
+ dataType: "string";
1375
+ columnType: "SQLiteText";
1376
+ data: string;
1377
+ driverParam: string;
1378
+ notNull: false;
1379
+ hasDefault: false;
1380
+ isPrimaryKey: false;
1381
+ isAutoincrement: false;
1382
+ hasRuntimeDefault: false;
1383
+ enumValues: [string, ...string[]];
1384
+ baseColumn: never;
1385
+ identity: undefined;
1386
+ generated: undefined;
1387
+ }, {}, {
1388
+ length: number | undefined;
1389
+ }>;
1390
+ compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1391
+ name: "compression_mode";
1392
+ tableName: "agents";
1393
+ dataType: "string";
1394
+ columnType: "SQLiteText";
1395
+ data: string;
1396
+ driverParam: string;
1397
+ notNull: false;
1398
+ hasDefault: false;
1399
+ isPrimaryKey: false;
1400
+ isAutoincrement: false;
1401
+ hasRuntimeDefault: false;
1402
+ enumValues: [string, ...string[]];
1403
+ baseColumn: never;
1404
+ identity: undefined;
1405
+ generated: undefined;
1406
+ }, {}, {
1407
+ length: number | undefined;
1408
+ }>;
1409
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1410
+ name: "role";
1411
+ tableName: "agents";
1412
+ dataType: "string";
1413
+ columnType: "SQLiteText";
1414
+ data: "lead" | "member";
1415
+ driverParam: string;
1416
+ notNull: true;
1417
+ hasDefault: false;
1418
+ isPrimaryKey: false;
1419
+ isAutoincrement: false;
1420
+ hasRuntimeDefault: false;
1421
+ enumValues: ["lead", "member"];
1422
+ baseColumn: never;
1423
+ identity: undefined;
1424
+ generated: undefined;
1425
+ }, {}, {
1426
+ length: number | undefined;
1427
+ }>;
1428
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1429
+ name: "status";
1430
+ tableName: "agents";
1431
+ dataType: "string";
1432
+ columnType: "SQLiteText";
1433
+ data: "active" | "idle" | "dead" | "disposed";
1434
+ driverParam: string;
1435
+ notNull: true;
1436
+ hasDefault: false;
1437
+ isPrimaryKey: false;
1438
+ isAutoincrement: false;
1439
+ hasRuntimeDefault: false;
1440
+ enumValues: ["idle", "active", "dead", "disposed"];
1441
+ baseColumn: never;
1442
+ identity: undefined;
1443
+ generated: undefined;
1444
+ }, {}, {
1445
+ length: number | undefined;
1446
+ }>;
1447
+ createdAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1448
+ name: "created_at";
1449
+ tableName: "agents";
1450
+ dataType: "number";
1451
+ columnType: "SQLiteInteger";
1452
+ data: number;
1453
+ driverParam: number;
1454
+ notNull: true;
1455
+ hasDefault: false;
1456
+ isPrimaryKey: false;
1457
+ isAutoincrement: false;
1458
+ hasRuntimeDefault: false;
1459
+ enumValues: undefined;
1460
+ baseColumn: never;
1461
+ identity: undefined;
1462
+ generated: undefined;
1463
+ }, {}, {}>;
1464
+ lastActivityAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1465
+ name: "last_activity_at";
1466
+ tableName: "agents";
1467
+ dataType: "number";
1468
+ columnType: "SQLiteInteger";
1469
+ data: number;
1470
+ driverParam: number;
1471
+ notNull: true;
1472
+ hasDefault: false;
1473
+ isPrimaryKey: false;
1474
+ isAutoincrement: false;
1475
+ hasRuntimeDefault: false;
1476
+ enumValues: undefined;
1477
+ baseColumn: never;
1478
+ identity: undefined;
1479
+ generated: undefined;
1480
+ }, {}, {}>;
1481
+ };
1482
+ dialect: "sqlite";
1483
+ }>;
1484
+ };
1485
+ }>;
1486
+ /**
1487
+ * Typed subjects for agent storage operations.
1488
+ */
1489
+ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"storage:agent", {
1490
+ /**
1491
+ * Get an agent by ID.
1492
+ *
1493
+ * Subject: `storage:agent.get`
1494
+ * Type: Request (RPC)
1495
+ */
1496
+ get: {
1497
+ request: z.ZodObject<{
1498
+ agentId: z.ZodString;
1499
+ }, z.core.$strip>;
1500
+ response: z.ZodObject<{
1501
+ agent: z.ZodNullable<z.ZodObject<{
1502
+ agentId: z.ZodString;
1503
+ adapterId: z.ZodString;
1504
+ adapterName: z.ZodString;
1505
+ sessionId: z.ZodString;
1506
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1507
+ model: z.ZodOptional<z.ZodString>;
1508
+ cwd: z.ZodOptional<z.ZodString>;
1509
+ providerConfigId: z.ZodOptional<z.ZodString>;
1510
+ personaId: z.ZodOptional<z.ZodString>;
1511
+ profileId: z.ZodOptional<z.ZodString>;
1512
+ harnessId: z.ZodOptional<z.ZodString>;
1513
+ clientId: z.ZodOptional<z.ZodString>;
1514
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1515
+ auto: "auto";
1516
+ manual: "manual";
1517
+ off: "off";
1518
+ }>>;
1519
+ role: z.ZodEnum<{
1520
+ lead: "lead";
1521
+ member: "member";
1522
+ }>;
1523
+ status: z.ZodEnum<{
1524
+ active: "active";
1525
+ idle: "idle";
1526
+ dead: "dead";
1527
+ disposed: "disposed";
1528
+ }>;
1529
+ createdAt: z.ZodNumber;
1530
+ lastActivityAt: z.ZodNumber;
1531
+ }, z.core.$strip>>;
1532
+ }, z.core.$strip>;
1533
+ };
1534
+ /**
1535
+ * Store or update an agent.
1536
+ *
1537
+ * Subject: `storage:agent.set`
1538
+ * Type: Request (RPC)
1539
+ */
1540
+ set: {
1541
+ request: z.ZodObject<{
1542
+ agentId: z.ZodString;
1543
+ agent: z.ZodObject<{
1544
+ agentId: z.ZodString;
1545
+ adapterId: z.ZodString;
1546
+ adapterName: z.ZodString;
1547
+ sessionId: z.ZodString;
1548
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1549
+ model: z.ZodOptional<z.ZodString>;
1550
+ cwd: z.ZodOptional<z.ZodString>;
1551
+ providerConfigId: z.ZodOptional<z.ZodString>;
1552
+ personaId: z.ZodOptional<z.ZodString>;
1553
+ profileId: z.ZodOptional<z.ZodString>;
1554
+ harnessId: z.ZodOptional<z.ZodString>;
1555
+ clientId: z.ZodOptional<z.ZodString>;
1556
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1557
+ auto: "auto";
1558
+ manual: "manual";
1559
+ off: "off";
1560
+ }>>;
1561
+ role: z.ZodEnum<{
1562
+ lead: "lead";
1563
+ member: "member";
1564
+ }>;
1565
+ status: z.ZodEnum<{
1566
+ active: "active";
1567
+ idle: "idle";
1568
+ dead: "dead";
1569
+ disposed: "disposed";
1570
+ }>;
1571
+ createdAt: z.ZodNumber;
1572
+ lastActivityAt: z.ZodNumber;
1573
+ }, z.core.$strip>;
1574
+ }, z.core.$strip>;
1575
+ response: z.ZodObject<{
1576
+ success: z.ZodBoolean;
1577
+ }, z.core.$strip>;
1578
+ };
1579
+ /**
1580
+ * Delete an agent by ID.
1581
+ *
1582
+ * Subject: `storage:agent.delete`
1583
+ * Type: Request (RPC)
1584
+ */
1585
+ delete: {
1586
+ request: z.ZodObject<{
1587
+ agentId: z.ZodString;
1588
+ }, z.core.$strip>;
1589
+ response: z.ZodObject<{
1590
+ success: z.ZodBoolean;
1591
+ }, z.core.$strip>;
1592
+ };
1593
+ /**
1594
+ * List agents by adapter name with optional status filter.
1595
+ *
1596
+ * Subject: `storage:agent.listByAdapter`
1597
+ * Type: Request (RPC)
1598
+ */
1599
+ listByAdapter: {
1600
+ request: z.ZodObject<{
1601
+ adapterName: z.ZodString;
1602
+ status: z.ZodOptional<z.ZodEnum<{
1603
+ all: "all";
1604
+ active: "active";
1605
+ idle: "idle";
1606
+ dead: "dead";
1607
+ disposed: "disposed";
1608
+ }>>;
1609
+ }, z.core.$strip>;
1610
+ response: z.ZodObject<{
1611
+ agents: z.ZodArray<z.ZodObject<{
1612
+ agentId: z.ZodString;
1613
+ adapterId: z.ZodString;
1614
+ adapterName: z.ZodString;
1615
+ sessionId: z.ZodString;
1616
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1617
+ model: z.ZodOptional<z.ZodString>;
1618
+ cwd: z.ZodOptional<z.ZodString>;
1619
+ providerConfigId: z.ZodOptional<z.ZodString>;
1620
+ personaId: z.ZodOptional<z.ZodString>;
1621
+ profileId: z.ZodOptional<z.ZodString>;
1622
+ harnessId: z.ZodOptional<z.ZodString>;
1623
+ clientId: z.ZodOptional<z.ZodString>;
1624
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1625
+ auto: "auto";
1626
+ manual: "manual";
1627
+ off: "off";
1628
+ }>>;
1629
+ role: z.ZodEnum<{
1630
+ lead: "lead";
1631
+ member: "member";
1632
+ }>;
1633
+ status: z.ZodEnum<{
1634
+ active: "active";
1635
+ idle: "idle";
1636
+ dead: "dead";
1637
+ disposed: "disposed";
1638
+ }>;
1639
+ createdAt: z.ZodNumber;
1640
+ lastActivityAt: z.ZodNumber;
1641
+ }, z.core.$strip>>;
1642
+ }, z.core.$strip>;
1643
+ };
1644
+ /**
1645
+ * List agents by session ID.
1646
+ *
1647
+ * Subject: `storage:agent.listBySession`
1648
+ * Type: Request (RPC)
1649
+ */
1650
+ listBySession: {
1651
+ request: z.ZodObject<{
1652
+ sessionId: z.ZodString;
1653
+ }, z.core.$strip>;
1654
+ response: z.ZodObject<{
1655
+ agents: z.ZodArray<z.ZodObject<{
1656
+ agentId: z.ZodString;
1657
+ adapterId: z.ZodString;
1658
+ adapterName: z.ZodString;
1659
+ sessionId: z.ZodString;
1660
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1661
+ model: z.ZodOptional<z.ZodString>;
1662
+ cwd: z.ZodOptional<z.ZodString>;
1663
+ providerConfigId: z.ZodOptional<z.ZodString>;
1664
+ personaId: z.ZodOptional<z.ZodString>;
1665
+ profileId: z.ZodOptional<z.ZodString>;
1666
+ harnessId: z.ZodOptional<z.ZodString>;
1667
+ clientId: z.ZodOptional<z.ZodString>;
1668
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1669
+ auto: "auto";
1670
+ manual: "manual";
1671
+ off: "off";
1672
+ }>>;
1673
+ role: z.ZodEnum<{
1674
+ lead: "lead";
1675
+ member: "member";
1676
+ }>;
1677
+ status: z.ZodEnum<{
1678
+ active: "active";
1679
+ idle: "idle";
1680
+ dead: "dead";
1681
+ disposed: "disposed";
1682
+ }>;
1683
+ createdAt: z.ZodNumber;
1684
+ lastActivityAt: z.ZodNumber;
1685
+ }, z.core.$strip>>;
1686
+ }, z.core.$strip>;
1687
+ };
1688
+ /**
1689
+ * Update agent status.
1690
+ *
1691
+ * Subject: `storage:agent.updateStatus`
1692
+ * Type: Request (RPC)
1693
+ */
1694
+ updateStatus: {
1695
+ request: z.ZodObject<{
1696
+ agentId: z.ZodString;
1697
+ status: z.ZodEnum<{
1698
+ active: "active";
1699
+ idle: "idle";
1700
+ dead: "dead";
1701
+ disposed: "disposed";
1702
+ }>;
1703
+ }, z.core.$strip>;
1704
+ response: z.ZodObject<{
1705
+ success: z.ZodBoolean;
1706
+ }, z.core.$strip>;
1707
+ };
1708
+ /**
1709
+ * Update agent last activity timestamp.
1710
+ *
1711
+ * Subject: `storage:agent.updateActivity`
1712
+ * Type: Request (RPC)
1713
+ */
1714
+ updateActivity: {
1715
+ request: z.ZodObject<{
1716
+ agentId: z.ZodString;
1717
+ lastActivityAt: z.ZodNumber;
1718
+ }, z.core.$strip>;
1719
+ response: z.ZodObject<{
1720
+ success: z.ZodBoolean;
1721
+ }, z.core.$strip>;
1722
+ };
1723
+ /**
1724
+ * Update runtime-mutable agent fields without full record overwrite.
1725
+ *
1726
+ * Subject: `storage:agent.updateRuntime`
1727
+ * Type: Request (RPC)
1728
+ */
1729
+ updateRuntime: {
1730
+ request: z.ZodObject<{
1731
+ agentId: z.ZodString;
1732
+ cwd: z.ZodOptional<z.ZodString>;
1733
+ model: z.ZodOptional<z.ZodString>;
1734
+ providerConfigId: z.ZodOptional<z.ZodString>;
1735
+ }, z.core.$strip>;
1736
+ response: z.ZodObject<{
1737
+ success: z.ZodBoolean;
1738
+ }, z.core.$strip>;
1739
+ };
1740
+ }>, "storage:agent">;
1741
+ //#endregion
1742
+ //#region services/core/src/session/storage/memory-handler.d.ts
1743
+ /**
1744
+ * Register in-memory session storage handlers.
1745
+ *
1746
+ * Suitable for development, testing, and single-instance deployments.
1747
+ * Data is lost when the process exits.
1748
+ * @param bus - The bus instance to register handlers on
1749
+ * @returns Cleanup function to unsubscribe all handlers
1750
+ * @example
1751
+ * ```typescript
1752
+ * import { registerMemorySessionStorage } from '@makaio/framework/services/session';
1753
+ *
1754
+ * const cleanup = registerMemorySessionStorage(bus);
1755
+ *
1756
+ * // Later, when shutting down:
1757
+ * cleanup();
1758
+ * ```
1759
+ */
1760
+ declare function registerMemorySessionStorage(bus: IMakaioBus): () => void;
1761
+ //#endregion
1762
+ //#region services/core/src/session/storage/drizzle-handler.d.ts
1763
+ /**
1764
+ * Register Drizzle-based session storage handlers.
1765
+ *
1766
+ * Persists sessions to SQLite/libSQL via Drizzle ORM.
1767
+ * Provides durable storage suitable for production deployments.
1768
+ *
1769
+ * CONCURRENCY INVARIANT: All handlers must use single-statement operations only.
1770
+ * Storage handlers share a single DB connection. Fire-and-forget bus events
1771
+ * (e.g., agent.added) race with sequential RPC handlers (e.g., turn.create).
1772
+ * db.transaction() holds write locks across await boundaries, causing SQLITE_BUSY
1773
+ * deadlocks on the same connection. Single statements serialize automatically
1774
+ * via SQLite's busy_timeout + WAL mode.
1775
+ * @param bus - The bus instance to register handlers on
1776
+ * @param db - The Drizzle database instance (any libSQL database)
1777
+ * @param _ctx - Extension context (unused; reserved for future use)
1778
+ * @returns Cleanup function to unsubscribe all handlers
1779
+ * @example
1780
+ * ```typescript
1781
+ * import { registerDrizzleSessionStorage } from '@makaio/framework/services/session';
1782
+ * import { drizzle } from 'drizzle-orm/libsql';
1783
+ * import { createClient } from '@libsql/client';
1784
+ *
1785
+ * const client = createClient({ url: 'file:./makaio.db' });
1786
+ * const db = drizzle(client);
1787
+ * const cleanup = registerDrizzleSessionStorage(bus, db, ctx);
1788
+ *
1789
+ * // Later, when shutting down:
1790
+ * cleanup();
1791
+ * ```
1792
+ */
1793
+ declare function registerDrizzleSessionStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
1794
+ //#endregion
1795
+ //#region services/core/src/session/storage/agent-memory-handler.d.ts
1796
+ /**
1797
+ * Register in-memory agent storage handlers.
1798
+ *
1799
+ * Suitable for development and testing. Data is lost when the process exits.
1800
+ * @param bus - The bus instance to register handlers on
1801
+ * @returns Cleanup function to unsubscribe all handlers
1802
+ */
1803
+ declare function registerMemoryAgentStorage(bus: IMakaioBus): () => void;
1804
+ //#endregion
1805
+ //#region services/core/src/session/storage/agent-drizzle-handler.d.ts
1806
+ /**
1807
+ * Register Drizzle-based agent storage handlers.
1808
+ *
1809
+ * Persists agents to SQLite/libSQL via Drizzle ORM.
1810
+ * Provides durable storage suitable for production deployments.
1811
+ * @param bus - The bus instance to register handlers on
1812
+ * @param db - The MakaioDatabase instance
1813
+ * @param _ctx - Extension context (unused; reserved for future use)
1814
+ * @returns Cleanup function to unsubscribe all handlers
1815
+ * @example
1816
+ * ```typescript
1817
+ * import { registerDrizzleAgentStorage } from '@makaio/framework/services/session';
1818
+ * import { drizzle } from 'drizzle-orm/libsql';
1819
+ * import { createClient } from '@libsql/client';
1820
+ *
1821
+ * const client = createClient({ url: 'file:./makaio.db' });
1822
+ * const db = drizzle(client);
1823
+ * const cleanup = registerDrizzleAgentStorage(bus, db, ctx);
1824
+ *
1825
+ * // Later, when shutting down:
1826
+ * cleanup();
1827
+ * ```
1828
+ */
1829
+ declare function registerDrizzleAgentStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
1830
+ //#endregion
1831
+ //#region services/core/src/session/storage/fts-search-handler.d.ts
1832
+ /**
1833
+ * Registers FTS-backed `storage:session.search` handler.
1834
+ * @param bus - Bus instance used for handler registration
1835
+ * @param db - Drizzle database instance
1836
+ * @returns Cleanup function that unregisters the search handler
1837
+ */
1838
+ declare function registerFtsSearchHandler(bus: IMakaioBus, db: MakaioDatabase): () => void;
1839
+ //#endregion
1840
+ //#region services/core/src/session/storage/fts-search-utils.d.ts
1841
+ /**
1842
+ * Row shape returned by FTS session search queries.
1843
+ *
1844
+ * Contains only framework-owned columns. Scope fields (`project_id`,
1845
+ * `worktree_id`, `workstream_id`) are intentionally absent — they are
1846
+ * managed by the host-owned junction table after the sealed-sessions
1847
+ * refactor.
1848
+ */
1849
+ interface SearchSessionRow {
1850
+ session_id: string;
1851
+ created_at: number;
1852
+ last_activity_at: number;
1853
+ status: IMakaioSession['status'];
1854
+ title: string | null;
1855
+ lead_agent_id: string | null;
1856
+ parent_session_id: string | null;
1857
+ root_session_id: string | null;
1858
+ fork_point_message_id: string | null;
1859
+ branch_kind: IMakaioSession['branchKind'] | null;
1860
+ adapter_name: string | null;
1861
+ adapter_session_id: string | null;
1862
+ adapter_id: string | null;
1863
+ is_orchestrated: number | null;
1864
+ is_imported: number | null;
1865
+ summary: string | null;
1866
+ summary_updated_at: number | null;
1867
+ fork_transforms: string | null;
1868
+ target_working_directory: string | null;
1869
+ }
1870
+ /**
1871
+ * Filter parameters accepted by FTS search queries.
1872
+ *
1873
+ * Scope filters (`projectId`, `worktreeId`) are intentionally absent —
1874
+ * scope-aware filtering is the responsibility of host priority-100
1875
+ * handlers that JOIN with the `session_scopes` junction table.
1876
+ */
1877
+ interface SearchFilters {
1878
+ status: IMakaioSession['status'] | 'all';
1879
+ isImported?: boolean;
1880
+ }
1881
+ /**
1882
+ * Loads agent rows and groups them by session ID.
1883
+ * @param db - Drizzle database instance
1884
+ * @param sessionIds - Matched session IDs
1885
+ * @returns Agent rows keyed by session ID
1886
+ */
1887
+ declare function fetchAgentsBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, Array<typeof agents.$inferSelect>>>;
1888
+ /**
1889
+ * Resolves first-user-message previews for matched sessions.
1890
+ * @param db - Drizzle database instance
1891
+ * @param sessionIds - Matched session IDs
1892
+ * @returns First user message text keyed by session ID
1893
+ */
1894
+ declare function fetchPreviewBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, string | null>>;
1895
+ /**
1896
+ * Counts messages per matched session.
1897
+ * @param db - Drizzle database instance
1898
+ * @param sessionIds - Matched session IDs
1899
+ * @returns Message counts keyed by session ID
1900
+ */
1901
+ declare function fetchMessageCountsBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, number>>;
1902
+ /**
1903
+ * Parses serialized fork transform JSON.
1904
+ * @param raw - Raw JSON column value
1905
+ * @returns Parsed fork transforms, or undefined on invalid JSON
1906
+ */
1907
+ declare function parseForkTransforms(raw: string | null): ForkTransforms | undefined;
1908
+ /**
1909
+ * Maps a raw search row to session API format with preview metadata.
1910
+ *
1911
+ * Scope fields are intentionally absent from the returned `IMakaioSession`.
1912
+ * Host handlers composing a scoped search must augment the result with
1913
+ * scope data read from the junction table after calling this utility.
1914
+ * @param row - Raw session row from SQL search query
1915
+ * @param sessionAgents - Agents attached to the session
1916
+ * @param previewBySession - First-user-message map
1917
+ * @param countBySession - Message count map
1918
+ * @returns Session payload with preview block
1919
+ */
1920
+ declare function mapRowToSession(row: SearchSessionRow, sessionAgents: Array<typeof agents.$inferSelect>, previewBySession: Map<string, string | null>, countBySession: Map<string, number>): IMakaioSession & {
1921
+ preview: {
1922
+ messageCount: number;
1923
+ firstUserMessage: string | null;
1924
+ };
1925
+ };
1926
+ //#endregion
1927
+ //#region services/core/src/session/storage/drizzle-utils.d.ts
1928
+ type SessionRow = typeof sessions.$inferSelect;
1929
+ type AgentRow = typeof agents.$inferSelect;
1930
+ /**
1931
+ * Preview maps for session list response hydration.
1932
+ */
1933
+ interface SessionPreviewMaps {
1934
+ previewBySession?: Map<string, string | null>;
1935
+ countBySession?: Map<string, number>;
1936
+ }
1937
+ /**
1938
+ * Map a Drizzle session row to the `IMakaioSession` API type.
1939
+ *
1940
+ * Scope fields (`projectId`, `worktreeId`, `workstreamId`) are intentionally
1941
+ * absent from the returned object. They are managed by the host-owned
1942
+ * junction table after the sealed-sessions refactor. Host handlers
1943
+ * composing a scoped query must augment the result with scope data read
1944
+ * from the junction table.
1945
+ * @param sessionRow - The session table row
1946
+ * @param agentRows - The associated agent rows
1947
+ * @returns The mapped session object
1948
+ */
1949
+ declare function mapToSession(sessionRow: SessionRow, agentRows: AgentRow[]): IMakaioSession;
1950
+ /**
1951
+ * Groups agent rows by session ID for list response hydration.
1952
+ * @param agentRows - Agent table rows
1953
+ * @returns Map keyed by session ID
1954
+ */
1955
+ declare function mapAgentsBySession(agentRows: AgentRow[]): Map<string, AgentRow[]>;
1956
+ /**
1957
+ * Fetches optional preview maps for session list responses.
1958
+ * @param db - Drizzle database client
1959
+ * @param sessionIds - Session IDs in current result page
1960
+ * @param includePreview - Whether preview fields are requested
1961
+ * @returns Preview maps for first user message and message count
1962
+ */
1963
+ declare function fetchSessionPreviewMaps(db: MakaioDatabase, sessionIds: string[], includePreview: boolean): Promise<SessionPreviewMaps>;
1964
+ //#endregion
1965
+ //#region services/core/src/session/session-events/schema.d.ts
1966
+ /**
1967
+ * Session events table schema.
1968
+ *
1969
+ * Stores immutable, append-only session events for unified history reconstruction.
1970
+ * Events are persisted by SessionLogger via storage service.
1971
+ *
1972
+ * **Event Types:**
1973
+ * - Message references (type='message' with messageId FK to messages table)
1974
+ * - Agent lifecycle (agent.added)
1975
+ * - Turn lifecycle (turn.started, turn.completed)
1976
+ * - User message events (user_message.sent/acknowledged/completed)
1977
+ *
1978
+ * Design rationale:
1979
+ * - First-class columns for queryable fields (IDs, timestamp, type)
1980
+ * - `contentText` extracted for FTS5/embeddings (future)
1981
+ * - `payload` stores full JSON for exact API reconstruction
1982
+ *
1983
+ * SEAM: The `sessionId` FK enables cascade delete when sessions are purged.
1984
+ * Future embeddings table can reference `eventId` for vector search.
1985
+ */
1986
+ declare const sessionEvents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
1987
+ name: "session_events";
1988
+ schema: undefined;
1989
+ columns: {
1990
+ id: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1991
+ name: "id";
1992
+ tableName: "session_events";
1993
+ dataType: "number";
1994
+ columnType: "SQLiteInteger";
1995
+ data: number;
1996
+ driverParam: number;
1997
+ notNull: true;
1998
+ hasDefault: true;
1999
+ isPrimaryKey: true;
2000
+ isAutoincrement: false;
2001
+ hasRuntimeDefault: false;
2002
+ enumValues: undefined;
2003
+ baseColumn: never;
2004
+ identity: undefined;
2005
+ generated: undefined;
2006
+ }, {}, {}>;
2007
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2008
+ name: "session_id";
2009
+ tableName: "session_events";
2010
+ dataType: "string";
2011
+ columnType: "SQLiteText";
2012
+ data: string;
2013
+ driverParam: string;
2014
+ notNull: true;
2015
+ hasDefault: false;
2016
+ isPrimaryKey: false;
2017
+ isAutoincrement: false;
2018
+ hasRuntimeDefault: false;
2019
+ enumValues: [string, ...string[]];
2020
+ baseColumn: never;
2021
+ identity: undefined;
2022
+ generated: undefined;
2023
+ }, {}, {
2024
+ length: number | undefined;
2025
+ }>;
2026
+ eventId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2027
+ name: "event_id";
2028
+ tableName: "session_events";
2029
+ dataType: "string";
2030
+ columnType: "SQLiteText";
2031
+ data: string;
2032
+ driverParam: string;
2033
+ notNull: true;
2034
+ hasDefault: false;
2035
+ isPrimaryKey: false;
2036
+ isAutoincrement: false;
2037
+ hasRuntimeDefault: false;
2038
+ enumValues: [string, ...string[]];
2039
+ baseColumn: never;
2040
+ identity: undefined;
2041
+ generated: undefined;
2042
+ }, {}, {
2043
+ length: number | undefined;
2044
+ }>;
2045
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2046
+ name: "timestamp";
2047
+ tableName: "session_events";
2048
+ dataType: "number";
2049
+ columnType: "SQLiteInteger";
2050
+ data: number;
2051
+ driverParam: number;
2052
+ notNull: true;
2053
+ hasDefault: false;
2054
+ isPrimaryKey: false;
2055
+ isAutoincrement: false;
2056
+ hasRuntimeDefault: false;
2057
+ enumValues: undefined;
2058
+ baseColumn: never;
2059
+ identity: undefined;
2060
+ generated: undefined;
2061
+ }, {}, {}>;
2062
+ type: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2063
+ name: "type";
2064
+ tableName: "session_events";
2065
+ dataType: "string";
2066
+ columnType: "SQLiteText";
2067
+ data: string;
2068
+ driverParam: string;
2069
+ notNull: true;
2070
+ hasDefault: false;
2071
+ isPrimaryKey: false;
2072
+ isAutoincrement: false;
2073
+ hasRuntimeDefault: false;
2074
+ enumValues: [string, ...string[]];
2075
+ baseColumn: never;
2076
+ identity: undefined;
2077
+ generated: undefined;
2078
+ }, {}, {
2079
+ length: number | undefined;
2080
+ }>;
2081
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2082
+ name: "agent_id";
2083
+ tableName: "session_events";
2084
+ dataType: "string";
2085
+ columnType: "SQLiteText";
2086
+ data: string;
2087
+ driverParam: string;
2088
+ notNull: false;
2089
+ hasDefault: false;
2090
+ isPrimaryKey: false;
2091
+ isAutoincrement: false;
2092
+ hasRuntimeDefault: false;
2093
+ enumValues: [string, ...string[]];
2094
+ baseColumn: never;
2095
+ identity: undefined;
2096
+ generated: undefined;
2097
+ }, {}, {
2098
+ length: number | undefined;
2099
+ }>;
2100
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2101
+ name: "adapter_id";
2102
+ tableName: "session_events";
2103
+ dataType: "string";
2104
+ columnType: "SQLiteText";
2105
+ data: string;
2106
+ driverParam: string;
2107
+ notNull: false;
2108
+ hasDefault: false;
2109
+ isPrimaryKey: false;
2110
+ isAutoincrement: false;
2111
+ hasRuntimeDefault: false;
2112
+ enumValues: [string, ...string[]];
2113
+ baseColumn: never;
2114
+ identity: undefined;
2115
+ generated: undefined;
2116
+ }, {}, {
2117
+ length: number | undefined;
2118
+ }>;
2119
+ originatingMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2120
+ name: "originating_message_id";
2121
+ tableName: "session_events";
2122
+ dataType: "string";
2123
+ columnType: "SQLiteText";
2124
+ data: string;
2125
+ driverParam: string;
2126
+ notNull: false;
2127
+ hasDefault: false;
2128
+ isPrimaryKey: false;
2129
+ isAutoincrement: false;
2130
+ hasRuntimeDefault: false;
2131
+ enumValues: [string, ...string[]];
2132
+ baseColumn: never;
2133
+ identity: undefined;
2134
+ generated: undefined;
2135
+ }, {}, {
2136
+ length: number | undefined;
2137
+ }>;
2138
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2139
+ name: "message_id";
2140
+ tableName: "session_events";
2141
+ dataType: "string";
2142
+ columnType: "SQLiteText";
2143
+ data: string;
2144
+ driverParam: string;
2145
+ notNull: false;
2146
+ hasDefault: false;
2147
+ isPrimaryKey: false;
2148
+ isAutoincrement: false;
2149
+ hasRuntimeDefault: false;
2150
+ enumValues: [string, ...string[]];
2151
+ baseColumn: never;
2152
+ identity: undefined;
2153
+ generated: undefined;
2154
+ }, {}, {
2155
+ length: number | undefined;
2156
+ }>;
2157
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2158
+ name: "turn_id";
2159
+ tableName: "session_events";
2160
+ dataType: "string";
2161
+ columnType: "SQLiteText";
2162
+ data: string;
2163
+ driverParam: string;
2164
+ notNull: false;
2165
+ hasDefault: false;
2166
+ isPrimaryKey: false;
2167
+ isAutoincrement: false;
2168
+ hasRuntimeDefault: false;
2169
+ enumValues: [string, ...string[]];
2170
+ baseColumn: never;
2171
+ identity: undefined;
2172
+ generated: undefined;
2173
+ }, {}, {
2174
+ length: number | undefined;
2175
+ }>;
2176
+ contentText: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2177
+ name: "content_text";
2178
+ tableName: "session_events";
2179
+ dataType: "string";
2180
+ columnType: "SQLiteText";
2181
+ data: string;
2182
+ driverParam: string;
2183
+ notNull: false;
2184
+ hasDefault: false;
2185
+ isPrimaryKey: false;
2186
+ isAutoincrement: false;
2187
+ hasRuntimeDefault: false;
2188
+ enumValues: [string, ...string[]];
2189
+ baseColumn: never;
2190
+ identity: undefined;
2191
+ generated: undefined;
2192
+ }, {}, {
2193
+ length: number | undefined;
2194
+ }>;
2195
+ payload: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2196
+ name: "payload";
2197
+ tableName: "session_events";
2198
+ dataType: "string";
2199
+ columnType: "SQLiteText";
2200
+ data: string;
2201
+ driverParam: string;
2202
+ notNull: true;
2203
+ hasDefault: false;
2204
+ isPrimaryKey: false;
2205
+ isAutoincrement: false;
2206
+ hasRuntimeDefault: false;
2207
+ enumValues: [string, ...string[]];
2208
+ baseColumn: never;
2209
+ identity: undefined;
2210
+ generated: undefined;
2211
+ }, {}, {
2212
+ length: number | undefined;
2213
+ }>;
2214
+ };
2215
+ dialect: "sqlite";
2216
+ }>;
2217
+ /**
2218
+ * Type for inserting a new session event.
2219
+ */
2220
+ type InsertSessionEvent = typeof sessionEvents.$inferInsert;
2221
+ /**
2222
+ * Type for a selected session event row.
2223
+ */
2224
+ type SelectSessionEvent = typeof sessionEvents.$inferSelect;
2225
+ //#endregion
2226
+ //#region services/core/src/session/session-events/memory-handler.d.ts
2227
+ /**
2228
+ * Register in-memory session event storage handlers.
2229
+ *
2230
+ * Suitable for development, testing, and single-instance deployments.
2231
+ * Data is lost when the process exits.
2232
+ *
2233
+ * Events are stored per-session in insertion order. Cursor-based pagination
2234
+ * uses a stable, monotonically-increasing sequence ID (`seqIdByEventId`)
2235
+ * assigned at append time — semantically equivalent to the Drizzle handler's
2236
+ * auto-increment `id` column. Cursors survive concurrent appends and remain
2237
+ * meaningful after deletes: an `after` cursor simply skips all events whose
2238
+ * seqId is ≤ the cursor value, regardless of whether the referenced event
2239
+ * still exists.
2240
+ * @param bus - The bus instance to register handlers on
2241
+ * @returns Cleanup function to unsubscribe all handlers
2242
+ * @example
2243
+ * ```typescript
2244
+ * import { registerMemorySessionEventStorage } from '@makaio/framework/services/session';
2245
+ *
2246
+ * const cleanup = registerMemorySessionEventStorage(bus);
2247
+ *
2248
+ * // Later, when shutting down:
2249
+ * cleanup();
2250
+ * ```
2251
+ */
2252
+ declare function registerMemorySessionEventStorage(bus: IMakaioBus): () => void;
2253
+ //#endregion
2254
+ //#region services/core/src/session/session-events/drizzle-handler.d.ts
2255
+ /**
2256
+ * Register Drizzle-based session event storage handlers.
2257
+ *
2258
+ * Persists events to SQLite/libSQL via Drizzle ORM with cursor-based
2259
+ * pagination and content extraction for future FTS/embedding support.
2260
+ * @param bus - The bus instance to register handlers on
2261
+ * @param db - The Drizzle database instance (any libSQL database)
2262
+ * @param _ctx - Extension context (unused; reserved for future use)
2263
+ * @returns Cleanup function to unsubscribe all handlers
2264
+ * @example
2265
+ * ```typescript
2266
+ * import { registerDrizzleSessionEventStorage } from '@makaio/framework/services/session';
2267
+ * import { drizzle } from 'drizzle-orm/libsql';
2268
+ * import { createClient } from '@libsql/client';
2269
+ *
2270
+ * const client = createClient({ url: 'file:./makaio.db' });
2271
+ * const db = drizzle(client);
2272
+ * const cleanup = registerDrizzleSessionEventStorage(bus, db, ctx);
2273
+ *
2274
+ * // Later, when shutting down:
2275
+ * cleanup();
2276
+ * ```
2277
+ */
2278
+ declare function registerDrizzleSessionEventStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2279
+ //#endregion
2280
+ //#region services/core/src/session/session-logger.d.ts
2281
+ /**
2282
+ * Transform function for event payloads before storage emission.
2283
+ * Use for redaction, PII filtering, or payload normalization.
2284
+ *
2285
+ * **Scope:** Only affects events emitted to `storage:sessionEvent.append`.
2286
+ * Individual subjects (`session.agent.*`, `session.user_message.*`) still receive
2287
+ * raw payloads. For full bus-level PII protection, redaction must happen at emit sites
2288
+ * (e.g., in SessionOrchestrator before emitting user_message.sent).
2289
+ * @param event - The event to transform
2290
+ * @returns Transformed event, or null to skip storage emission
2291
+ */
2292
+ type EventTransform = (event: MakaioSessionEvent) => MakaioSessionEvent | null;
2293
+ /**
2294
+ * Options for SessionLogger.
2295
+ */
2296
+ interface SessionLoggerOptions {
2297
+ /**
2298
+ * Transform function applied before storage emission.
2299
+ * Return null to skip storage entirely.
2300
+ * Note: Does not affect individual session.* subjects (see EventTransform docs).
2301
+ * Default: identity (no transformation)
2302
+ */
2303
+ transform?: EventTransform;
2304
+ }
2305
+ /**
2306
+ * Bridges session lifecycle events to storage layer for persistence.
2307
+ *
2308
+ * **Architecture (Normalized Message Model):**
2309
+ * - Messages: Stored in `messages` table via MessageStorageSubjects (by SessionOrchestrator/SessionBridge)
2310
+ * - SessionLogger: Stores LIFECYCLE events only — agent.added, turn.started, turn.completed
2311
+ *
2312
+ * **NO longer subscribes to user_message.* events** — user messages are now
2313
+ * first-class entities in the `messages` table, not embedded in event payloads.
2314
+ *
2315
+ * The correlation link is `session.agent.added` which maps:
2316
+ * `sessionId ↔ agentId ↔ adapterSessionId`
2317
+ *
2318
+ * Subscribes to:
2319
+ * - session.agent.added — correlation link for multi-agent reconstruction
2320
+ * - session.turn.started, session.turn.completed — turn lifecycle
2321
+ * - session.branch.created — branch creation audit trail
2322
+ *
2323
+ * Does NOT subscribe to session.branch.merged or session.squash — those
2324
+ * handlers (merge-handler, compress-handler) own their persistence directly
2325
+ * using a stable eventId so retries are idempotent.
2326
+ *
2327
+ * Emits transformed events to `storage:sessionEvent.append` for persistence.
2328
+ * @example
2329
+ * ```typescript
2330
+ * // Basic usage - lifecycle events are emitted to storage:sessionEvent.append
2331
+ * const sessionLogger = new SessionLogger(MakaioBus);
2332
+ *
2333
+ * // With redaction transform (mainly for turn error messages)
2334
+ * const sessionLogger = new SessionLogger(MakaioBus, {
2335
+ * transform: (event) => {
2336
+ * // Redact sensitive info if needed
2337
+ * return event;
2338
+ * },
2339
+ * });
2340
+ * ```
2341
+ */
2342
+ declare class SessionLogger {
2343
+ private readonly bus;
2344
+ private readonly options;
2345
+ private readonly cleanups;
2346
+ private readonly transform;
2347
+ constructor(bus?: IMakaioBus, options?: SessionLoggerOptions);
2348
+ /**
2349
+ * Emit a session event to storage layer.
2350
+ *
2351
+ * Creates event envelope, applies transform, and emits to storage subject.
2352
+ * If transform returns null, event is skipped.
2353
+ * @param eventType - Event type for classification
2354
+ * @param sessionId - Session identifier
2355
+ * @param payload - Event payload to persist
2356
+ */
2357
+ private emitStorageEvent;
2358
+ /**
2359
+ * Register a handler for a session event subject.
2360
+ * @param subject - Subject definition to subscribe to
2361
+ * @param eventType - Event type for persistence
2362
+ */
2363
+ private registerHandler;
2364
+ /**
2365
+ * Register all session lifecycle event handlers.
2366
+ *
2367
+ * **Normalized Message Model:**
2368
+ * - User messages are stored in `messages` table by SessionOrchestrator
2369
+ * - Assistant messages are stored by SessionBridge on agent.complete
2370
+ * - SessionLogger only stores LIFECYCLE events for audit/correlation
2371
+ */
2372
+ private registerHandlers;
2373
+ /**
2374
+ * Stop the logger and clean up subscriptions.
2375
+ */
2376
+ destroy(): void;
2377
+ }
2378
+ //#endregion
2379
+ //#region services/core/src/session/import-cursors/schema.d.ts
2380
+ /**
2381
+ * Import cursors table schema.
2382
+ *
2383
+ * Tracks byte offsets for incremental log file import.
2384
+ * Enables resuming import from the last processed position after restarts.
2385
+ */
2386
+ declare const importCursors: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2387
+ name: "import_cursors";
2388
+ schema: undefined;
2389
+ columns: {
2390
+ filePath: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2391
+ name: "file_path";
2392
+ tableName: "import_cursors";
2393
+ dataType: "string";
2394
+ columnType: "SQLiteText";
2395
+ data: string;
2396
+ driverParam: string;
2397
+ notNull: true;
2398
+ hasDefault: false;
2399
+ isPrimaryKey: true;
2400
+ isAutoincrement: false;
2401
+ hasRuntimeDefault: false;
2402
+ enumValues: [string, ...string[]];
2403
+ baseColumn: never;
2404
+ identity: undefined;
2405
+ generated: undefined;
2406
+ }, {}, {
2407
+ length: number | undefined;
2408
+ }>;
2409
+ bytesRead: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2410
+ name: "bytes_read";
2411
+ tableName: "import_cursors";
2412
+ dataType: "number";
2413
+ columnType: "SQLiteInteger";
2414
+ data: number;
2415
+ driverParam: number;
2416
+ notNull: true;
2417
+ hasDefault: false;
2418
+ isPrimaryKey: false;
2419
+ isAutoincrement: false;
2420
+ hasRuntimeDefault: false;
2421
+ enumValues: undefined;
2422
+ baseColumn: never;
2423
+ identity: undefined;
2424
+ generated: undefined;
2425
+ }, {}, {}>;
2426
+ lastModified: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2427
+ name: "last_modified";
2428
+ tableName: "import_cursors";
2429
+ dataType: "string";
2430
+ columnType: "SQLiteText";
2431
+ data: string;
2432
+ driverParam: string;
2433
+ notNull: true;
2434
+ hasDefault: false;
2435
+ isPrimaryKey: false;
2436
+ isAutoincrement: false;
2437
+ hasRuntimeDefault: false;
2438
+ enumValues: [string, ...string[]];
2439
+ baseColumn: never;
2440
+ identity: undefined;
2441
+ generated: undefined;
2442
+ }, {}, {
2443
+ length: number | undefined;
2444
+ }>;
2445
+ updatedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2446
+ name: "updated_at";
2447
+ tableName: "import_cursors";
2448
+ dataType: "number";
2449
+ columnType: "SQLiteInteger";
2450
+ data: number;
2451
+ driverParam: number;
2452
+ notNull: true;
2453
+ hasDefault: false;
2454
+ isPrimaryKey: false;
2455
+ isAutoincrement: false;
2456
+ hasRuntimeDefault: false;
2457
+ enumValues: undefined;
2458
+ baseColumn: never;
2459
+ identity: undefined;
2460
+ generated: undefined;
2461
+ }, {}, {}>;
2462
+ };
2463
+ dialect: "sqlite";
2464
+ }>;
2465
+ //#endregion
2466
+ //#region services/core/src/session/import-cursors/drizzle-handler.d.ts
2467
+ /**
2468
+ * Register Drizzle-backed import cursor storage handlers.
2469
+ *
2470
+ * Provides persistent cursor storage for efficient log import resume.
2471
+ * On restart, import continues from the last processed byte offset.
2472
+ * @param bus - The bus instance to register handlers on
2473
+ * @param db - Drizzle database instance
2474
+ * @param _ctx - Extension context (unused; reserved for future use)
2475
+ * @returns Cleanup function to unsubscribe all handlers
2476
+ * @example
2477
+ * ```typescript
2478
+ * import { registerDrizzleImportCursorStorage } from '@makaio/framework/services/session';
2479
+ *
2480
+ * const cleanup = registerDrizzleImportCursorStorage(bus, db, ctx);
2481
+ *
2482
+ * // Later, when shutting down:
2483
+ * cleanup();
2484
+ * ```
2485
+ */
2486
+ declare function registerDrizzleImportCursorStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2487
+ //#endregion
2488
+ //#region services/core/src/session/turns/drizzle-handler.d.ts
2489
+ /**
2490
+ * Register Drizzle-based turn storage handlers.
2491
+ *
2492
+ * Manages turn lifecycle in SQLite/libSQL via Drizzle ORM.
2493
+ *
2494
+ * CONCURRENCY INVARIANT: All handlers must use single-statement operations only.
2495
+ * Storage handlers share a single DB connection. Fire-and-forget bus events
2496
+ * (e.g., agent.added) race with sequential RPC handlers (e.g., turn.create).
2497
+ * db.transaction() holds write locks across await boundaries, causing SQLITE_BUSY
2498
+ * deadlocks on the same connection. Single statements serialize automatically
2499
+ * via SQLite's busy_timeout + WAL mode.
2500
+ * @param bus - The bus instance to register handlers on
2501
+ * @param db - The Drizzle database instance
2502
+ * @param _ctx - Extension context (unused; reserved for future use)
2503
+ * @returns Cleanup function to unsubscribe all handlers
2504
+ */
2505
+ declare function registerDrizzleTurnStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2506
+ //#endregion
2507
+ //#region services/core/src/session/turns/memory-handler.d.ts
2508
+ /**
2509
+ * Register in-memory turn storage handlers.
2510
+ *
2511
+ * Suitable for development and tests. Data is lost on process exit.
2512
+ * @param bus - The bus instance to register handlers on
2513
+ * @returns Cleanup function to unsubscribe all handlers
2514
+ */
2515
+ declare function registerMemoryTurnStorage(bus: IMakaioBus): () => void;
2516
+ //#endregion
2517
+ //#region services/core/src/session/turns/schema.d.ts
2518
+ /**
2519
+ * Turns table schema.
2520
+ *
2521
+ * A turn represents a user message and all agent responses to it.
2522
+ * Extracted from events to provide explicit turn boundaries.
2523
+ *
2524
+ * Design rationale:
2525
+ * - First-class entity for turn lifecycle tracking
2526
+ * - Links to session via FK for cascade delete
2527
+ * - Status tracks completion state for UI progress indication
2528
+ */
2529
+ declare const turns: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2530
+ name: "turns";
2531
+ schema: undefined;
2532
+ columns: {
2533
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2534
+ name: "turn_id";
2535
+ tableName: "turns";
2536
+ dataType: "string";
2537
+ columnType: "SQLiteText";
2538
+ data: string;
2539
+ driverParam: string;
2540
+ notNull: true;
2541
+ hasDefault: false;
2542
+ isPrimaryKey: true;
2543
+ isAutoincrement: false;
2544
+ hasRuntimeDefault: false;
2545
+ enumValues: [string, ...string[]];
2546
+ baseColumn: never;
2547
+ identity: undefined;
2548
+ generated: undefined;
2549
+ }, {}, {
2550
+ length: number | undefined;
2551
+ }>;
2552
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2553
+ name: "session_id";
2554
+ tableName: "turns";
2555
+ dataType: "string";
2556
+ columnType: "SQLiteText";
2557
+ data: string;
2558
+ driverParam: string;
2559
+ notNull: true;
2560
+ hasDefault: false;
2561
+ isPrimaryKey: false;
2562
+ isAutoincrement: false;
2563
+ hasRuntimeDefault: false;
2564
+ enumValues: [string, ...string[]];
2565
+ baseColumn: never;
2566
+ identity: undefined;
2567
+ generated: undefined;
2568
+ }, {}, {
2569
+ length: number | undefined;
2570
+ }>;
2571
+ turnNumber: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2572
+ name: "turn_number";
2573
+ tableName: "turns";
2574
+ dataType: "number";
2575
+ columnType: "SQLiteInteger";
2576
+ data: number;
2577
+ driverParam: number;
2578
+ notNull: true;
2579
+ hasDefault: false;
2580
+ isPrimaryKey: false;
2581
+ isAutoincrement: false;
2582
+ hasRuntimeDefault: false;
2583
+ enumValues: undefined;
2584
+ baseColumn: never;
2585
+ identity: undefined;
2586
+ generated: undefined;
2587
+ }, {}, {}>;
2588
+ startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2589
+ name: "started_at";
2590
+ tableName: "turns";
2591
+ dataType: "number";
2592
+ columnType: "SQLiteInteger";
2593
+ data: number;
2594
+ driverParam: number;
2595
+ notNull: true;
2596
+ hasDefault: false;
2597
+ isPrimaryKey: false;
2598
+ isAutoincrement: false;
2599
+ hasRuntimeDefault: false;
2600
+ enumValues: undefined;
2601
+ baseColumn: never;
2602
+ identity: undefined;
2603
+ generated: undefined;
2604
+ }, {}, {}>;
2605
+ completedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2606
+ name: "completed_at";
2607
+ tableName: "turns";
2608
+ dataType: "number";
2609
+ columnType: "SQLiteInteger";
2610
+ data: number;
2611
+ driverParam: number;
2612
+ notNull: false;
2613
+ hasDefault: false;
2614
+ isPrimaryKey: false;
2615
+ isAutoincrement: false;
2616
+ hasRuntimeDefault: false;
2617
+ enumValues: undefined;
2618
+ baseColumn: never;
2619
+ identity: undefined;
2620
+ generated: undefined;
2621
+ }, {}, {}>;
2622
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2623
+ name: "status";
2624
+ tableName: "turns";
2625
+ dataType: "string";
2626
+ columnType: "SQLiteText";
2627
+ data: "error" | "active" | "completed";
2628
+ driverParam: string;
2629
+ notNull: true;
2630
+ hasDefault: false;
2631
+ isPrimaryKey: false;
2632
+ isAutoincrement: false;
2633
+ hasRuntimeDefault: false;
2634
+ enumValues: ["active", "completed", "error"];
2635
+ baseColumn: never;
2636
+ identity: undefined;
2637
+ generated: undefined;
2638
+ }, {}, {
2639
+ length: number | undefined;
2640
+ }>;
2641
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2642
+ name: "error";
2643
+ tableName: "turns";
2644
+ dataType: "string";
2645
+ columnType: "SQLiteText";
2646
+ data: string;
2647
+ driverParam: string;
2648
+ notNull: false;
2649
+ hasDefault: false;
2650
+ isPrimaryKey: false;
2651
+ isAutoincrement: false;
2652
+ hasRuntimeDefault: false;
2653
+ enumValues: [string, ...string[]];
2654
+ baseColumn: never;
2655
+ identity: undefined;
2656
+ generated: undefined;
2657
+ }, {}, {
2658
+ length: number | undefined;
2659
+ }>;
2660
+ usage: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2661
+ name: "usage";
2662
+ tableName: "turns";
2663
+ dataType: "string";
2664
+ columnType: "SQLiteText";
2665
+ data: string;
2666
+ driverParam: string;
2667
+ notNull: false;
2668
+ hasDefault: false;
2669
+ isPrimaryKey: false;
2670
+ isAutoincrement: false;
2671
+ hasRuntimeDefault: false;
2672
+ enumValues: [string, ...string[]];
2673
+ baseColumn: never;
2674
+ identity: undefined;
2675
+ generated: undefined;
2676
+ }, {}, {
2677
+ length: number | undefined;
2678
+ }>;
2679
+ };
2680
+ dialect: "sqlite";
2681
+ }>;
2682
+ /**
2683
+ * Type for inserting a new turn.
2684
+ */
2685
+ type InsertTurn = typeof turns.$inferInsert;
2686
+ /**
2687
+ * Type for a selected turn row.
2688
+ */
2689
+ type SelectTurn = typeof turns.$inferSelect;
2690
+ //#endregion
2691
+ //#region services/core/src/session/messages/drizzle-handler.d.ts
2692
+ /**
2693
+ * Register Drizzle-based message storage handlers.
2694
+ *
2695
+ * Manages message persistence in SQLite/libSQL via Drizzle ORM.
2696
+ * @param bus - The bus instance to register handlers on
2697
+ * @param db - The Drizzle database instance
2698
+ * @param _ctx - Extension context (unused; reserved for future use)
2699
+ * @returns Cleanup function to unsubscribe all handlers
2700
+ */
2701
+ declare function registerDrizzleMessageStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2702
+ //#endregion
2703
+ //#region services/core/src/session/messages/memory-handler.d.ts
2704
+ /**
2705
+ * Register in-memory message storage handlers.
2706
+ *
2707
+ * Intended for dev/test runtime usage. Durable storage is provided by the
2708
+ * Drizzle handlers in ./drizzle-handler.ts.
2709
+ * @param bus - The bus instance to register handlers on
2710
+ * @returns Cleanup function to unregister handlers
2711
+ */
2712
+ declare function registerMemoryMessageStorage(bus: IMakaioBus): () => void;
2713
+ //#endregion
2714
+ //#region services/core/src/session/messages/schema.d.ts
2715
+ /**
2716
+ * Messages table schema.
2717
+ *
2718
+ * The single source of truth for conversation content as consumed by Makaio
2719
+ * (UI history, search, transforms, routing).
2720
+ *
2721
+ * Design principles:
2722
+ * - Messages are first-class entities, not embedded in events
2723
+ * - Single source of truth for conversation content
2724
+ * - Blocks stored as JSON for flexible structure
2725
+ * - contentText extracted for FTS5 search
2726
+ * - session_events tracks lifecycle (turns, branches) but not content
2727
+ */
2728
+ declare const messages: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2729
+ name: "messages";
2730
+ schema: undefined;
2731
+ columns: {
2732
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2733
+ name: "message_id";
2734
+ tableName: "messages";
2735
+ dataType: "string";
2736
+ columnType: "SQLiteText";
2737
+ data: string;
2738
+ driverParam: string;
2739
+ notNull: true;
2740
+ hasDefault: false;
2741
+ isPrimaryKey: true;
2742
+ isAutoincrement: false;
2743
+ hasRuntimeDefault: false;
2744
+ enumValues: [string, ...string[]];
2745
+ baseColumn: never;
2746
+ identity: undefined;
2747
+ generated: undefined;
2748
+ }, {}, {
2749
+ length: number | undefined;
2750
+ }>;
2751
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2752
+ name: "turn_id";
2753
+ tableName: "messages";
2754
+ dataType: "string";
2755
+ columnType: "SQLiteText";
2756
+ data: string;
2757
+ driverParam: string;
2758
+ notNull: false;
2759
+ hasDefault: false;
2760
+ isPrimaryKey: false;
2761
+ isAutoincrement: false;
2762
+ hasRuntimeDefault: false;
2763
+ enumValues: [string, ...string[]];
2764
+ baseColumn: never;
2765
+ identity: undefined;
2766
+ generated: undefined;
2767
+ }, {}, {
2768
+ length: number | undefined;
2769
+ }>;
2770
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2771
+ name: "session_id";
2772
+ tableName: "messages";
2773
+ dataType: "string";
2774
+ columnType: "SQLiteText";
2775
+ data: string;
2776
+ driverParam: string;
2777
+ notNull: true;
2778
+ hasDefault: false;
2779
+ isPrimaryKey: false;
2780
+ isAutoincrement: false;
2781
+ hasRuntimeDefault: false;
2782
+ enumValues: [string, ...string[]];
2783
+ baseColumn: never;
2784
+ identity: undefined;
2785
+ generated: undefined;
2786
+ }, {}, {
2787
+ length: number | undefined;
2788
+ }>;
2789
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2790
+ name: "role";
2791
+ tableName: "messages";
2792
+ dataType: "string";
2793
+ columnType: "SQLiteText";
2794
+ data: "user" | "assistant";
2795
+ driverParam: string;
2796
+ notNull: true;
2797
+ hasDefault: false;
2798
+ isPrimaryKey: false;
2799
+ isAutoincrement: false;
2800
+ hasRuntimeDefault: false;
2801
+ enumValues: ["user", "assistant"];
2802
+ baseColumn: never;
2803
+ identity: undefined;
2804
+ generated: undefined;
2805
+ }, {}, {
2806
+ length: number | undefined;
2807
+ }>;
2808
+ contentText: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2809
+ name: "content_text";
2810
+ tableName: "messages";
2811
+ dataType: "string";
2812
+ columnType: "SQLiteText";
2813
+ data: string;
2814
+ driverParam: string;
2815
+ notNull: true;
2816
+ hasDefault: false;
2817
+ isPrimaryKey: false;
2818
+ isAutoincrement: false;
2819
+ hasRuntimeDefault: false;
2820
+ enumValues: [string, ...string[]];
2821
+ baseColumn: never;
2822
+ identity: undefined;
2823
+ generated: undefined;
2824
+ }, {}, {
2825
+ length: number | undefined;
2826
+ }>;
2827
+ blocks: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2828
+ name: "blocks";
2829
+ tableName: "messages";
2830
+ dataType: "string";
2831
+ columnType: "SQLiteText";
2832
+ data: string;
2833
+ driverParam: string;
2834
+ notNull: true;
2835
+ hasDefault: true;
2836
+ isPrimaryKey: false;
2837
+ isAutoincrement: false;
2838
+ hasRuntimeDefault: false;
2839
+ enumValues: [string, ...string[]];
2840
+ baseColumn: never;
2841
+ identity: undefined;
2842
+ generated: undefined;
2843
+ }, {}, {
2844
+ length: number | undefined;
2845
+ }>;
2846
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2847
+ name: "agent_id";
2848
+ tableName: "messages";
2849
+ dataType: "string";
2850
+ columnType: "SQLiteText";
2851
+ data: string;
2852
+ driverParam: string;
2853
+ notNull: false;
2854
+ hasDefault: false;
2855
+ isPrimaryKey: false;
2856
+ isAutoincrement: false;
2857
+ hasRuntimeDefault: false;
2858
+ enumValues: [string, ...string[]];
2859
+ baseColumn: never;
2860
+ identity: undefined;
2861
+ generated: undefined;
2862
+ }, {}, {
2863
+ length: number | undefined;
2864
+ }>;
2865
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2866
+ name: "adapter_session_id";
2867
+ tableName: "messages";
2868
+ dataType: "string";
2869
+ columnType: "SQLiteText";
2870
+ data: string;
2871
+ driverParam: string;
2872
+ notNull: false;
2873
+ hasDefault: false;
2874
+ isPrimaryKey: false;
2875
+ isAutoincrement: false;
2876
+ hasRuntimeDefault: false;
2877
+ enumValues: [string, ...string[]];
2878
+ baseColumn: never;
2879
+ identity: undefined;
2880
+ generated: undefined;
2881
+ }, {}, {
2882
+ length: number | undefined;
2883
+ }>;
2884
+ adapterMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2885
+ name: "adapter_message_id";
2886
+ tableName: "messages";
2887
+ dataType: "string";
2888
+ columnType: "SQLiteText";
2889
+ data: string;
2890
+ driverParam: string;
2891
+ notNull: false;
2892
+ hasDefault: false;
2893
+ isPrimaryKey: false;
2894
+ isAutoincrement: false;
2895
+ hasRuntimeDefault: false;
2896
+ enumValues: [string, ...string[]];
2897
+ baseColumn: never;
2898
+ identity: undefined;
2899
+ generated: undefined;
2900
+ }, {}, {
2901
+ length: number | undefined;
2902
+ }>;
2903
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2904
+ name: "timestamp";
2905
+ tableName: "messages";
2906
+ dataType: "number";
2907
+ columnType: "SQLiteInteger";
2908
+ data: number;
2909
+ driverParam: number;
2910
+ notNull: true;
2911
+ hasDefault: false;
2912
+ isPrimaryKey: false;
2913
+ isAutoincrement: false;
2914
+ hasRuntimeDefault: false;
2915
+ enumValues: undefined;
2916
+ baseColumn: never;
2917
+ identity: undefined;
2918
+ generated: undefined;
2919
+ }, {}, {}>;
2920
+ editOf: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2921
+ name: "edit_of";
2922
+ tableName: "messages";
2923
+ dataType: "string";
2924
+ columnType: "SQLiteText";
2925
+ data: string;
2926
+ driverParam: string;
2927
+ notNull: false;
2928
+ hasDefault: false;
2929
+ isPrimaryKey: false;
2930
+ isAutoincrement: false;
2931
+ hasRuntimeDefault: false;
2932
+ enumValues: [string, ...string[]];
2933
+ baseColumn: never;
2934
+ identity: undefined;
2935
+ generated: undefined;
2936
+ }, {}, {
2937
+ length: number | undefined;
2938
+ }>;
2939
+ origin: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2940
+ name: "origin";
2941
+ tableName: "messages";
2942
+ dataType: "string";
2943
+ columnType: "SQLiteText";
2944
+ data: "text" | "voice" | "compact";
2945
+ driverParam: string;
2946
+ notNull: false;
2947
+ hasDefault: false;
2948
+ isPrimaryKey: false;
2949
+ isAutoincrement: false;
2950
+ hasRuntimeDefault: false;
2951
+ enumValues: ["voice", "text", "compact"];
2952
+ baseColumn: never;
2953
+ identity: undefined;
2954
+ generated: undefined;
2955
+ }, {}, {
2956
+ length: number | undefined;
2957
+ }>;
2958
+ };
2959
+ dialect: "sqlite";
2960
+ }>;
2961
+ /**
2962
+ * Type for inserting a new message.
2963
+ */
2964
+ type InsertMessage = typeof messages.$inferInsert;
2965
+ /**
2966
+ * Type for a selected message row.
2967
+ */
2968
+ type SelectMessage = typeof messages.$inferSelect;
2969
+ //#endregion
2970
+ //#region services/core/src/session/message-routing/namespace.d.ts
2971
+ /**
2972
+ * Message routing storage namespace.
2973
+ *
2974
+ * Tracks delivery status of messages to agents in multi-agent sessions.
2975
+ * Enables querying completion status for turn coordination.
2976
+ */
2977
+ declare const MessageRoutingNamespace: _$_makaio_storage_core0.StorageNamespaceDefinition<"messageRouting", {
2978
+ /**
2979
+ * Record routing status for a message to an agent.
2980
+ *
2981
+ * Subject: `storage:messageRouting.record`
2982
+ * Type: Request (RPC)
2983
+ */
2984
+ record: {
2985
+ request: z.ZodObject<{
2986
+ messageId: z.ZodString;
2987
+ agentId: z.ZodString;
2988
+ status: z.ZodEnum<{
2989
+ completed: "completed";
2990
+ sent: "sent";
2991
+ acknowledged: "acknowledged";
2992
+ }>;
2993
+ timestamp: z.ZodNumber;
2994
+ error: z.ZodOptional<z.ZodString>;
2995
+ }, z.core.$strip>;
2996
+ response: z.ZodObject<{
2997
+ success: z.ZodBoolean;
2998
+ }, z.core.$strip>;
2999
+ };
3000
+ /**
3001
+ * Get routing status for a message.
3002
+ *
3003
+ * Subject: `storage:messageRouting.getByMessage`
3004
+ * Type: Request (RPC)
3005
+ */
3006
+ getByMessage: {
3007
+ request: z.ZodObject<{
3008
+ messageId: z.ZodString;
3009
+ }, z.core.$strip>;
3010
+ response: z.ZodObject<{
3011
+ routing: z.ZodArray<z.ZodObject<{
3012
+ messageId: z.ZodString;
3013
+ agentId: z.ZodString;
3014
+ status: z.ZodEnum<{
3015
+ completed: "completed";
3016
+ sent: "sent";
3017
+ acknowledged: "acknowledged";
3018
+ }>;
3019
+ timestamp: z.ZodNumber;
3020
+ error: z.ZodOptional<z.ZodString>;
3021
+ }, z.core.$strip>>;
3022
+ }, z.core.$strip>;
3023
+ };
3024
+ /**
3025
+ * Get all completed routings for a message.
3026
+ * Used to check if all target agents have responded.
3027
+ *
3028
+ * Subject: `storage:messageRouting.getCompleted`
3029
+ * Type: Request (RPC)
3030
+ */
3031
+ getCompleted: {
3032
+ request: z.ZodObject<{
3033
+ messageId: z.ZodString;
3034
+ }, z.core.$strip>;
3035
+ response: z.ZodObject<{
3036
+ agentIds: z.ZodArray<z.ZodString>;
3037
+ }, z.core.$strip>;
3038
+ };
3039
+ /**
3040
+ * Check if all target agents have completed for a message.
3041
+ *
3042
+ * Subject: `storage:messageRouting.isComplete`
3043
+ * Type: Request (RPC)
3044
+ */
3045
+ isComplete: {
3046
+ request: z.ZodObject<{
3047
+ messageId: z.ZodString;
3048
+ targetAgentIds: z.ZodArray<z.ZodString>;
3049
+ }, z.core.$strip>;
3050
+ response: z.ZodObject<{
3051
+ complete: z.ZodBoolean;
3052
+ pending: z.ZodArray<z.ZodString>;
3053
+ }, z.core.$strip>;
3054
+ };
3055
+ }, {
3056
+ drizzle: {
3057
+ messageRouting: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3058
+ name: "message_routing";
3059
+ schema: undefined;
3060
+ columns: {
3061
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3062
+ name: "message_id";
3063
+ tableName: "message_routing";
3064
+ dataType: "string";
3065
+ columnType: "SQLiteText";
3066
+ data: string;
3067
+ driverParam: string;
3068
+ notNull: true;
3069
+ hasDefault: false;
3070
+ isPrimaryKey: false;
3071
+ isAutoincrement: false;
3072
+ hasRuntimeDefault: false;
3073
+ enumValues: [string, ...string[]];
3074
+ baseColumn: never;
3075
+ identity: undefined;
3076
+ generated: undefined;
3077
+ }, {}, {
3078
+ length: number | undefined;
3079
+ }>;
3080
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3081
+ name: "agent_id";
3082
+ tableName: "message_routing";
3083
+ dataType: "string";
3084
+ columnType: "SQLiteText";
3085
+ data: string;
3086
+ driverParam: string;
3087
+ notNull: true;
3088
+ hasDefault: false;
3089
+ isPrimaryKey: false;
3090
+ isAutoincrement: false;
3091
+ hasRuntimeDefault: false;
3092
+ enumValues: [string, ...string[]];
3093
+ baseColumn: never;
3094
+ identity: undefined;
3095
+ generated: undefined;
3096
+ }, {}, {
3097
+ length: number | undefined;
3098
+ }>;
3099
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3100
+ name: "status";
3101
+ tableName: "message_routing";
3102
+ dataType: "string";
3103
+ columnType: "SQLiteText";
3104
+ data: "completed" | "sent" | "acknowledged";
3105
+ driverParam: string;
3106
+ notNull: true;
3107
+ hasDefault: false;
3108
+ isPrimaryKey: false;
3109
+ isAutoincrement: false;
3110
+ hasRuntimeDefault: false;
3111
+ enumValues: ["sent", "acknowledged", "completed"];
3112
+ baseColumn: never;
3113
+ identity: undefined;
3114
+ generated: undefined;
3115
+ }, {}, {
3116
+ length: number | undefined;
3117
+ }>;
3118
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3119
+ name: "timestamp";
3120
+ tableName: "message_routing";
3121
+ dataType: "number";
3122
+ columnType: "SQLiteInteger";
3123
+ data: number;
3124
+ driverParam: number;
3125
+ notNull: true;
3126
+ hasDefault: false;
3127
+ isPrimaryKey: false;
3128
+ isAutoincrement: false;
3129
+ hasRuntimeDefault: false;
3130
+ enumValues: undefined;
3131
+ baseColumn: never;
3132
+ identity: undefined;
3133
+ generated: undefined;
3134
+ }, {}, {}>;
3135
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3136
+ name: "error";
3137
+ tableName: "message_routing";
3138
+ dataType: "string";
3139
+ columnType: "SQLiteText";
3140
+ data: string;
3141
+ driverParam: string;
3142
+ notNull: false;
3143
+ hasDefault: false;
3144
+ isPrimaryKey: false;
3145
+ isAutoincrement: false;
3146
+ hasRuntimeDefault: false;
3147
+ enumValues: [string, ...string[]];
3148
+ baseColumn: never;
3149
+ identity: undefined;
3150
+ generated: undefined;
3151
+ }, {}, {
3152
+ length: number | undefined;
3153
+ }>;
3154
+ };
3155
+ dialect: "sqlite";
3156
+ }>;
3157
+ };
3158
+ }>;
3159
+ /**
3160
+ * Typed subjects for message routing storage operations.
3161
+ */
3162
+ declare const MessageRoutingSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"storage:messageRouting", {
3163
+ /**
3164
+ * Record routing status for a message to an agent.
3165
+ *
3166
+ * Subject: `storage:messageRouting.record`
3167
+ * Type: Request (RPC)
3168
+ */
3169
+ record: {
3170
+ request: z.ZodObject<{
3171
+ messageId: z.ZodString;
3172
+ agentId: z.ZodString;
3173
+ status: z.ZodEnum<{
3174
+ completed: "completed";
3175
+ sent: "sent";
3176
+ acknowledged: "acknowledged";
3177
+ }>;
3178
+ timestamp: z.ZodNumber;
3179
+ error: z.ZodOptional<z.ZodString>;
3180
+ }, z.core.$strip>;
3181
+ response: z.ZodObject<{
3182
+ success: z.ZodBoolean;
3183
+ }, z.core.$strip>;
3184
+ };
3185
+ /**
3186
+ * Get routing status for a message.
3187
+ *
3188
+ * Subject: `storage:messageRouting.getByMessage`
3189
+ * Type: Request (RPC)
3190
+ */
3191
+ getByMessage: {
3192
+ request: z.ZodObject<{
3193
+ messageId: z.ZodString;
3194
+ }, z.core.$strip>;
3195
+ response: z.ZodObject<{
3196
+ routing: z.ZodArray<z.ZodObject<{
3197
+ messageId: z.ZodString;
3198
+ agentId: z.ZodString;
3199
+ status: z.ZodEnum<{
3200
+ completed: "completed";
3201
+ sent: "sent";
3202
+ acknowledged: "acknowledged";
3203
+ }>;
3204
+ timestamp: z.ZodNumber;
3205
+ error: z.ZodOptional<z.ZodString>;
3206
+ }, z.core.$strip>>;
3207
+ }, z.core.$strip>;
3208
+ };
3209
+ /**
3210
+ * Get all completed routings for a message.
3211
+ * Used to check if all target agents have responded.
3212
+ *
3213
+ * Subject: `storage:messageRouting.getCompleted`
3214
+ * Type: Request (RPC)
3215
+ */
3216
+ getCompleted: {
3217
+ request: z.ZodObject<{
3218
+ messageId: z.ZodString;
3219
+ }, z.core.$strip>;
3220
+ response: z.ZodObject<{
3221
+ agentIds: z.ZodArray<z.ZodString>;
3222
+ }, z.core.$strip>;
3223
+ };
3224
+ /**
3225
+ * Check if all target agents have completed for a message.
3226
+ *
3227
+ * Subject: `storage:messageRouting.isComplete`
3228
+ * Type: Request (RPC)
3229
+ */
3230
+ isComplete: {
3231
+ request: z.ZodObject<{
3232
+ messageId: z.ZodString;
3233
+ targetAgentIds: z.ZodArray<z.ZodString>;
3234
+ }, z.core.$strip>;
3235
+ response: z.ZodObject<{
3236
+ complete: z.ZodBoolean;
3237
+ pending: z.ZodArray<z.ZodString>;
3238
+ }, z.core.$strip>;
3239
+ };
3240
+ }>, "storage:messageRouting">;
3241
+ //#endregion
3242
+ //#region services/core/src/session/message-routing/drizzle-handler.d.ts
3243
+ /**
3244
+ * Register Drizzle-based message routing storage handlers.
3245
+ *
3246
+ * Manages message delivery tracking in SQLite/libSQL via Drizzle ORM.
3247
+ * @param bus - The bus instance to register handlers on
3248
+ * @param db - The Drizzle database instance
3249
+ * @param _ctx - Extension context (unused; reserved for future use)
3250
+ * @returns Cleanup function to unsubscribe all handlers
3251
+ */
3252
+ declare function registerDrizzleMessageRoutingStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
3253
+ //#endregion
3254
+ //#region services/core/src/session/message-routing/schema.d.ts
3255
+ /**
3256
+ * Message routing table schema.
3257
+ *
3258
+ * Tracks delivery status of messages to agents in multi-agent sessions.
3259
+ * Each row represents a message-agent pair with status progression.
3260
+ *
3261
+ * Status progression: sent -\> acknowledged -\> completed
3262
+ *
3263
+ * Design rationale:
3264
+ * - Composite primary key allows multiple status entries per message-agent pair
3265
+ * - Enables tracking of delivery lifecycle for each target agent
3266
+ * - Supports querying "which agents have completed for this message?"
3267
+ */
3268
+ declare const messageRouting: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3269
+ name: "message_routing";
3270
+ schema: undefined;
3271
+ columns: {
3272
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3273
+ name: "message_id";
3274
+ tableName: "message_routing";
3275
+ dataType: "string";
3276
+ columnType: "SQLiteText";
3277
+ data: string;
3278
+ driverParam: string;
3279
+ notNull: true;
3280
+ hasDefault: false;
3281
+ isPrimaryKey: false;
3282
+ isAutoincrement: false;
3283
+ hasRuntimeDefault: false;
3284
+ enumValues: [string, ...string[]];
3285
+ baseColumn: never;
3286
+ identity: undefined;
3287
+ generated: undefined;
3288
+ }, {}, {
3289
+ length: number | undefined;
3290
+ }>;
3291
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3292
+ name: "agent_id";
3293
+ tableName: "message_routing";
3294
+ dataType: "string";
3295
+ columnType: "SQLiteText";
3296
+ data: string;
3297
+ driverParam: string;
3298
+ notNull: true;
3299
+ hasDefault: false;
3300
+ isPrimaryKey: false;
3301
+ isAutoincrement: false;
3302
+ hasRuntimeDefault: false;
3303
+ enumValues: [string, ...string[]];
3304
+ baseColumn: never;
3305
+ identity: undefined;
3306
+ generated: undefined;
3307
+ }, {}, {
3308
+ length: number | undefined;
3309
+ }>;
3310
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3311
+ name: "status";
3312
+ tableName: "message_routing";
3313
+ dataType: "string";
3314
+ columnType: "SQLiteText";
3315
+ data: "completed" | "sent" | "acknowledged";
3316
+ driverParam: string;
3317
+ notNull: true;
3318
+ hasDefault: false;
3319
+ isPrimaryKey: false;
3320
+ isAutoincrement: false;
3321
+ hasRuntimeDefault: false;
3322
+ enumValues: ["sent", "acknowledged", "completed"];
3323
+ baseColumn: never;
3324
+ identity: undefined;
3325
+ generated: undefined;
3326
+ }, {}, {
3327
+ length: number | undefined;
3328
+ }>;
3329
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3330
+ name: "timestamp";
3331
+ tableName: "message_routing";
3332
+ dataType: "number";
3333
+ columnType: "SQLiteInteger";
3334
+ data: number;
3335
+ driverParam: number;
3336
+ notNull: true;
3337
+ hasDefault: false;
3338
+ isPrimaryKey: false;
3339
+ isAutoincrement: false;
3340
+ hasRuntimeDefault: false;
3341
+ enumValues: undefined;
3342
+ baseColumn: never;
3343
+ identity: undefined;
3344
+ generated: undefined;
3345
+ }, {}, {}>;
3346
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3347
+ name: "error";
3348
+ tableName: "message_routing";
3349
+ dataType: "string";
3350
+ columnType: "SQLiteText";
3351
+ data: string;
3352
+ driverParam: string;
3353
+ notNull: false;
3354
+ hasDefault: false;
3355
+ isPrimaryKey: false;
3356
+ isAutoincrement: false;
3357
+ hasRuntimeDefault: false;
3358
+ enumValues: [string, ...string[]];
3359
+ baseColumn: never;
3360
+ identity: undefined;
3361
+ generated: undefined;
3362
+ }, {}, {
3363
+ length: number | undefined;
3364
+ }>;
3365
+ };
3366
+ dialect: "sqlite";
3367
+ }>;
3368
+ /**
3369
+ * Type for inserting a new routing entry.
3370
+ */
3371
+ type InsertMessageRouting = typeof messageRouting.$inferInsert;
3372
+ /**
3373
+ * Type for a selected routing entry row.
3374
+ */
3375
+ type SelectMessageRouting = typeof messageRouting.$inferSelect;
3376
+ //#endregion
3377
+ //#region services/core/src/session/entities/makaio-session.d.ts
3378
+ /**
3379
+ * Configuration for creating a MakaioSession.
3380
+ */
3381
+ interface MakaioSessionConfig {
3382
+ /** Session ID (generated if not provided) */
3383
+ sessionId?: string;
3384
+ /** Bus for event emission */
3385
+ bus: IMakaioBus;
3386
+ /** Parent session ID (for forks) */
3387
+ parentSessionId?: string;
3388
+ }
3389
+ /**
3390
+ * Options for starting a turn.
3391
+ */
3392
+ interface StartTurnOptions {
3393
+ /** Agents participating in this turn */
3394
+ agentIds: string[];
3395
+ /** Initial message ID (required - turn.started schema mandates it) */
3396
+ messageId: string;
3397
+ /** Monotonic per-session ordinal (1-based), assigned by turn storage. */
3398
+ turnNumber: number;
3399
+ /** Optional pre-generated turn ID */
3400
+ turnId?: string;
3401
+ }
3402
+ /**
3403
+ * MakaioSession is the aggregate root for session state.
3404
+ *
3405
+ * It owns Turn[] children and emits lifecycle events from within,
3406
+ * mirroring the AIAgent pattern. Events are emitted when state changes,
3407
+ * not by external orchestration code.
3408
+ *
3409
+ * SEAM: This entity is designed to support future buildContext() method
3410
+ * for projecting raw history to effective history (transforms, token budgets).
3411
+ */
3412
+ declare class MakaioSession {
3413
+ readonly sessionId: string;
3414
+ readonly parentSessionId?: string;
3415
+ status: 'active' | 'closed' | 'archived';
3416
+ /** Turn children - owned by this aggregate */
3417
+ private readonly _turns;
3418
+ /** Track which turns have been completed */
3419
+ private readonly _completedTurnIds;
3420
+ /** Bus for event emission */
3421
+ protected readonly bus: IMakaioBus;
3422
+ constructor(config: MakaioSessionConfig);
3423
+ /**
3424
+ * Get turns owned by this session (read-only view).
3425
+ * @returns Immutable array of turns
3426
+ */
3427
+ get turns(): readonly Turn$1[];
3428
+ /**
3429
+ * Start a new turn in this session.
3430
+ *
3431
+ * Creates a Turn child entity and emits turn.started event.
3432
+ * This is the key pattern: state change + event emission happen together
3433
+ * inside the aggregate, not in external orchestration code.
3434
+ * @param options - Turn configuration
3435
+ * @returns The created Turn
3436
+ * @throws Error if session is not active (for example closed or archived)
3437
+ */
3438
+ startTurn(options: StartTurnOptions): Promise<Turn$1>;
3439
+ /**
3440
+ * Get the currently active (incomplete) turn.
3441
+ * @returns The active turn, or undefined if no turn is active
3442
+ */
3443
+ getActiveTurn(): Turn$1 | undefined;
3444
+ /**
3445
+ * Complete a turn and emit turn.completed event.
3446
+ * @param turn - The turn to complete
3447
+ */
3448
+ completeTurn(turn: Turn$1): Promise<void>;
3449
+ /**
3450
+ * Emit an event with sessionId auto-enriched.
3451
+ *
3452
+ * Mirrors AIAgent.emitGlobal pattern - entity emits its own events
3453
+ * with context automatically included.
3454
+ * @param subject - The subject to emit to
3455
+ * @param payload - The payload (without sessionId - it's added automatically)
3456
+ */
3457
+ protected emit<S extends SubjectDefinition>(subject: S, payload: Omit<ExtractSubjectPayload<S>, 'sessionId'>): Promise<void>;
3458
+ }
3459
+ //#endregion
3460
+ //#region services/core/src/session/import/parent-resolver.d.ts
3461
+ /**
3462
+ * Register handler to resolve parent relationships when sessions are imported.
3463
+ *
3464
+ * When `session.import.completed` is emitted:
3465
+ * 1. Query sessions for children whose `parentExternalSessionId` matches
3466
+ * the just-imported session's `adapterSessionId` and whose `parentSessionId`
3467
+ * is still null (unresolved).
3468
+ * 2. For each unresolved child, update its `parentSessionId` and `rootSessionId`.
3469
+ * 3. Cascade `rootSessionId` down the tree to any already-resolved grandchildren.
3470
+ * @param bus - The bus instance to register handlers on
3471
+ * @param db - The Drizzle database instance for direct queries
3472
+ * @returns Cleanup function to unsubscribe the handler
3473
+ * @example
3474
+ * ```typescript
3475
+ * import { registerParentResolver } from '@makaio/framework/services/session';
3476
+ *
3477
+ * const cleanup = registerParentResolver(bus, db);
3478
+ *
3479
+ * // Later, when shutting down:
3480
+ * cleanup();
3481
+ * ```
3482
+ */
3483
+ declare function registerParentResolver(bus: IMakaioBus, db: MakaioDatabase): () => void;
3484
+ //#endregion
3485
+ //#region services/core/src/session/import/compress-lineage-resolver.d.ts
3486
+ /**
3487
+ * Re-parents post-compaction subagents from the parent session to the compress child.
3488
+ *
3489
+ * Handles two scenarios triggered by `session.import.completed`:
3490
+ *
3491
+ * **Path A — compress child imported first (batch import)**:
3492
+ * When a compress child import completes, subagents spawned after compaction are
3493
+ * already parented to the parent Makaio session (by the parent-resolver).
3494
+ * This path scans the compress child's messages and re-parents matching subagents.
3495
+ *
3496
+ * **Path B — subagent imported after compress child (incremental / separate files)**:
3497
+ * When a subagent import completes and its parent has compress children, the compress
3498
+ * children and their messages already exist. This path scans those compress
3499
+ * children for the subagent's spawning tool_call and re-parents when found.
3500
+ *
3501
+ * Must be registered BEFORE registerSpawningToolCallResolver so it runs
3502
+ * first on `session.import.completed` (bus handlers fire in registration order).
3503
+ * @param bus - The bus instance to register handlers on
3504
+ * @returns Cleanup function to unsubscribe the handler
3505
+ * @example
3506
+ * ```typescript
3507
+ * import { registerCompressLineageResolver } from '@makaio/framework/services/session';
3508
+ *
3509
+ * const cleanup = registerCompressLineageResolver(bus);
3510
+ *
3511
+ * // Later, when shutting down:
3512
+ * cleanup();
3513
+ * ```
3514
+ */
3515
+ declare function registerCompressLineageResolver(bus: IMakaioBus): () => void;
3516
+ //#endregion
3517
+ //#region services/core/src/session/import/spawning-tool-call-resolver.d.ts
3518
+ /**
3519
+ * Register handler to backfill `spawningToolCallId` for imported subagent sessions.
3520
+ *
3521
+ * When `session.import.completed` is emitted:
3522
+ * 1. Fetch children of the newly imported parent session.
3523
+ * 2. Filter to subagent children with no `spawningToolCallId`.
3524
+ * 3. Fetch parent session messages and scan for Agent/spawn_subagent tool_call blocks.
3525
+ * 4. Match each unmatched child to a tool_call by tool_output content reference
3526
+ * (session ID in output string). Unmatched children are left as null.
3527
+ * 5. Update matched children via `SessionStorageSubjects.update`.
3528
+ * @param bus - The bus instance to register handlers on
3529
+ * @returns Cleanup function to unsubscribe the handler
3530
+ * @example
3531
+ * ```typescript
3532
+ * import { registerSpawningToolCallResolver } from '@makaio/framework/services/session';
3533
+ *
3534
+ * const cleanup = registerSpawningToolCallResolver(bus);
3535
+ *
3536
+ * // Later, when shutting down:
3537
+ * cleanup();
3538
+ * ```
3539
+ */
3540
+ declare function registerSpawningToolCallResolver(bus: IMakaioBus): () => void;
3541
+ //#endregion
3542
+ //#region services/core/src/session/import/session-discovered-handler.d.ts
3543
+ /**
3544
+ * Register a bus handler for `adapter.session.discovered` events.
3545
+ *
3546
+ * When a session is discovered from a log watcher:
3547
+ * 1. Validates the payload with `SessionDiscoveredSchema` (fail-fast on schema violations).
3548
+ * 2. Calls `storage:session.importUpsert` to create or enrich the session record atomically.
3549
+ * - On first discovery: inserts a stub session with `importStatus='discovered'` and
3550
+ * eagerly resolves `parentSessionId` / `rootSessionId` when the parent is already imported.
3551
+ * - On re-discovery: COALESCE-merges enrichment fields (title, cwd, logFilePath)
3552
+ * so subsequent scans can supply previously-unknown values without overwriting existing data.
3553
+ * @param bus - The bus instance to register the handler on
3554
+ * @returns Cleanup function to unsubscribe the handler
3555
+ * @example
3556
+ * ```typescript
3557
+ * import { registerSessionDiscoveredHandler } from '@makaio/framework/services/session';
3558
+ *
3559
+ * const cleanup = registerSessionDiscoveredHandler(bus);
3560
+ *
3561
+ * // Later, when shutting down:
3562
+ * cleanup();
3563
+ * ```
3564
+ */
3565
+ declare function registerSessionDiscoveredHandler(bus: IMakaioBus): () => void;
3566
+ //#endregion
3567
+ //#region services/core/src/session/import/lineage-utils.d.ts
3568
+ /**
3569
+ * Maps adapter-level session lineage kind to Makaio session branch kind.
3570
+ * Root sessions have no branch kind (undefined).
3571
+ * @param kind - The adapter session's lineage kind
3572
+ * @returns The corresponding BranchKind, or undefined for root sessions
3573
+ */
3574
+ declare function kindToBranchKind(kind: SessionLineageKind): BranchKind | undefined;
3575
+ /**
3576
+ * Convert lineage metadata to a canonical `SessionLineage` discriminated union.
3577
+ * @param metadata - Object with kind, parentAdapterSessionId, and forkPointMessageId
3578
+ * @returns Canonical lineage object matching session contracts
3579
+ */
3580
+ declare function toSessionLineage(metadata: {
3581
+ kind: SessionLineageKind;
3582
+ parentAdapterSessionId: string | null;
3583
+ forkPointMessageId: string | null;
3584
+ }): SessionLineage;
3585
+ //#endregion
3586
+ //#region services/core/src/session/context/types.d.ts
3587
+ /**
3588
+ * Options for building session context.
3589
+ */
3590
+ interface BuildContextOptions {
3591
+ /** Session ID to build context for */
3592
+ sessionId: string;
3593
+ /** Maximum messages to return (for token budgeting, default: no limit) */
3594
+ limit?: number;
3595
+ }
3596
+ /**
3597
+ * Result of context assembly.
3598
+ */
3599
+ interface ContextAssemblyResult {
3600
+ /** Assembled messages in chronological order */
3601
+ messages: SessionMessage[];
3602
+ /** Whether a squash boundary was encountered */
3603
+ hasSquashBoundary: boolean;
3604
+ /** Sessions traversed (for debugging) */
3605
+ sessionChain: string[];
3606
+ /** Whether results were truncated due to limit or pagination */
3607
+ truncated: boolean;
3608
+ /** Whether parent chain is incomplete (missing session in ancestry) */
3609
+ incomplete: boolean;
3610
+ }
3611
+ //#endregion
3612
+ //#region services/core/src/session/context/build-context.d.ts
3613
+ /**
3614
+ * Build context for a single session by walking session_events.
3615
+ *
3616
+ * Respects squash boundaries: if a squash event is encountered,
3617
+ * messages before it are replaced with the summary.
3618
+ * Paginates through all events until no more cursors or message limit is reached.
3619
+ * @param bus - Bus instance for RPC calls
3620
+ * @param options - Build context options
3621
+ * @returns Assembled context result
3622
+ */
3623
+ declare function buildSessionContext(bus: IMakaioBus, options: BuildContextOptions): Promise<ContextAssemblyResult>;
3624
+ //#endregion
3625
+ //#region services/core/src/session/context/get-full-conversation.d.ts
3626
+ /**
3627
+ * Get full conversation for a session, traversing parent chain.
3628
+ *
3629
+ * For forked sessions, this walks up the parent chain and assembles
3630
+ * messages from each ancestor, respecting forkPointMessageId boundaries.
3631
+ *
3632
+ * IMPORTANT: forkPointMessageId must be a Makaio message ID (not adapter ID).
3633
+ * Normalization happens at adapter session link time.
3634
+ * @param bus - Bus instance for RPC calls
3635
+ * @param sessionId - Session to get conversation for
3636
+ * @returns Full conversation with lineage
3637
+ */
3638
+ declare function getFullConversation(bus: IMakaioBus, sessionId: string): Promise<ContextAssemblyResult>;
3639
+ //#endregion
3640
+ export { registerMemoryAgentStorage as $, registerDrizzleImportCursorStorage as A, buildRecoveryContext as At, SessionPreviewMaps as B, AdapterRegistry as Bt, registerMemoryMessageStorage as C, buildTurnInitiator as Ct, turns as D, ensureAgentModel as Dt, SelectTurn as E, ensureAgentCwd as Et, registerDrizzleSessionEventStorage as F, getOrCreateSession as Ft, SearchSessionRow as G, mapAgentsBySession as H, SessionOrchestrator as Ht, registerMemorySessionEventStorage as I, resolveTargetAgents as It, fetchPreviewBySession as J, fetchAgentsBySession as K, InsertSessionEvent as L, extractTextContent as Lt, EventTransform as M, resolveExecutionTarget as Mt, SessionLogger as N, resolveModelCapabilities as Nt, registerMemoryTurnStorage as O, recoverAgent as Ot, SessionLoggerOptions as P, findTurnByAgent as Pt, registerDrizzleAgentStorage as Q, SelectSessionEvent as R, normalizeToBlocks as Rt, messages as S, SessionContextWindowState as St, InsertTurn as T, buildRecoveryContextWithPipeline as Tt, mapToSession as U, registerCoreSessionServiceHandlers as Ut, fetchSessionPreviewMaps as V, ISessionOrchestrator as Vt, SearchFilters as W, MakaioSessionService as Wt, parseForkTransforms as X, mapRowToSession as Y, registerFtsSearchHandler as Z, registerDrizzleMessageRoutingStorage as _, registerGetStatusCountsHandler as _t, kindToBranchKind as a, createSessionExtensionContext as at, InsertMessage as b, AgentContextState as bt, registerSpawningToolCallResolver as c, FallbackRuntimeOptions as ct, MakaioSession as d, normalizeSelectionString as dt, registerDrizzleSessionStorage as et, MakaioSessionConfig as f, resolveAdapterNameById as ft, messageRouting as g, actionRegistry as gt, SelectMessageRouting as h, resetBuiltInActionsRegistration as ht, ContextAssemblyResult as i, SessionExtensionContextImpl as it, importCursors as j, resolveAdapterId as jt, registerDrizzleTurnStorage as k, verifyAndRecoverAgents as kt, registerCompressLineageResolver as l, pickFallbackRuntimeOptions as lt, InsertMessageRouting as m, registerBuiltInActions as mt, buildSessionContext as n, AgentStorageNamespace as nt, toSessionLineage as o, SessionBridge as ot, StartTurnOptions as p, registerListActionsHandler as pt, fetchMessageCountsBySession as q, BuildContextOptions as r, AgentStorageSubjects as rt, registerSessionDiscoveredHandler as s, assembleForkContext as st, getFullConversation as t, registerMemorySessionStorage as tt, registerParentResolver as u, CONNECTOR_SWAP_DEFAULT_PIPELINE as ut, MessageRoutingNamespace as v, registerResumeHandler as vt, registerDrizzleMessageStorage as w, RecoveryConfig as wt, SelectMessage as x, ContextWindowTrackerConfig as xt, MessageRoutingSubjects as y, ContextWindowTracker as yt, sessionEvents as z, TurnContextEnricher as zt };