@makaio/framework 1.0.0-dev-1779046984397

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 (410) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -0
  3. package/dist/account-identity-Ce1Bwrqi.mjs +1 -0
  4. package/dist/adapter-CbyjCE2d.mjs +1 -0
  5. package/dist/adapters/acp-client/index.d.mts +209 -0
  6. package/dist/adapters/acp-client/index.mjs +1 -0
  7. package/dist/adapters/config/index.d.mts +429 -0
  8. package/dist/adapters/config/index.mjs +1 -0
  9. package/dist/adapters/index.d.mts +4175 -0
  10. package/dist/adapters/index.mjs +11 -0
  11. package/dist/adapters/node.d.mts +263 -0
  12. package/dist/adapters/node.mjs +4 -0
  13. package/dist/adapters/stream-session/index.d.mts +1384 -0
  14. package/dist/adapters/stream-session/index.mjs +1 -0
  15. package/dist/adapters/stream-session/testing/index.d.mts +29 -0
  16. package/dist/adapters/stream-session/testing/index.mjs +1 -0
  17. package/dist/base-orchestrator-9z8TuA5a.d.mts +772 -0
  18. package/dist/bus/index.d.mts +3331 -0
  19. package/dist/bus/index.mjs +1 -0
  20. package/dist/bus-B1seC4M_.mjs +2 -0
  21. package/dist/capability-service-tnpR_TaB.mjs +1 -0
  22. package/dist/chunk-Dc06z0qk.mjs +1 -0
  23. package/dist/chunk-cpUYaJdV.mjs +1 -0
  24. package/dist/cleanEnvForAdapter-DvcIGXTG.mjs +1 -0
  25. package/dist/client-Dh4x4GQN.mjs +1 -0
  26. package/dist/clients/index.d.mts +2786 -0
  27. package/dist/clients/index.mjs +1 -0
  28. package/dist/clients-namespace-B0xAPZ6J.d.mts +332 -0
  29. package/dist/config-namespace-DLSs83zr.d.mts +638 -0
  30. package/dist/config-namespace-MJT8P0Ud.mjs +1 -0
  31. package/dist/contracts/adapter/index.d.mts +3 -0
  32. package/dist/contracts/adapter/index.mjs +1 -0
  33. package/dist/contracts/adapter/schemas/session-lineage.d.mts +2 -0
  34. package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -0
  35. package/dist/contracts/client/index.d.mts +3 -0
  36. package/dist/contracts/client/index.mjs +1 -0
  37. package/dist/contracts/common/index.d.mts +2 -0
  38. package/dist/contracts/common/index.mjs +1 -0
  39. package/dist/contracts/config/index.d.mts +455 -0
  40. package/dist/contracts/config/index.mjs +1 -0
  41. package/dist/contracts/extension/index.d.mts +3 -0
  42. package/dist/contracts/extension/index.mjs +1 -0
  43. package/dist/contracts/harness/index.d.mts +2 -0
  44. package/dist/contracts/harness/index.mjs +1 -0
  45. package/dist/contracts/host/index.d.mts +2 -0
  46. package/dist/contracts/host/index.mjs +1 -0
  47. package/dist/contracts/index.d.mts +12665 -0
  48. package/dist/contracts/index.mjs +1 -0
  49. package/dist/contracts/model-registry/index.d.mts +2 -0
  50. package/dist/contracts/model-registry/index.mjs +1 -0
  51. package/dist/contracts/native-session-supervisor/index.d.mts +2 -0
  52. package/dist/contracts/native-session-supervisor/index.mjs +1 -0
  53. package/dist/contracts/platform/index.d.mts +2 -0
  54. package/dist/contracts/platform/index.mjs +1 -0
  55. package/dist/contracts/provider/index.d.mts +3 -0
  56. package/dist/contracts/provider/index.mjs +1 -0
  57. package/dist/contracts/session/index.d.mts +3 -0
  58. package/dist/contracts/session/index.mjs +1 -0
  59. package/dist/contracts/shared/index.d.mts +2 -0
  60. package/dist/contracts/shared/index.mjs +1 -0
  61. package/dist/contracts/skill/index.d.mts +2 -0
  62. package/dist/contracts/skill/index.mjs +1 -0
  63. package/dist/contracts/toast/index.d.mts +198 -0
  64. package/dist/contracts/toast/index.mjs +1 -0
  65. package/dist/contracts/variant/index.d.mts +2 -0
  66. package/dist/contracts/variant/index.mjs +1 -0
  67. package/dist/core/index.d.mts +1001 -0
  68. package/dist/core/index.mjs +1 -0
  69. package/dist/credential-ref-DLCsoKVZ.mjs +1 -0
  70. package/dist/cursor-storage-DOQdvo9j.mjs +1 -0
  71. package/dist/definition-DkYy1PZz.mjs +1 -0
  72. package/dist/definition-DtUNiGom.d.mts +158 -0
  73. package/dist/definition-DxvZ9e22.d.mts +376 -0
  74. package/dist/drizzle-CWVVw7Er.mjs +1 -0
  75. package/dist/execution-target-BW_uiBVe.mjs +1 -0
  76. package/dist/extension-COqwS-2Q.mjs +1 -0
  77. package/dist/extension-Cbrl4YGX.mjs +1 -0
  78. package/dist/extension-namespace-zaGKi6Qj.mjs +1 -0
  79. package/dist/handlers-iGKUJ380.mjs +41 -0
  80. package/dist/harness-CEq1Zkf9.mjs +1 -0
  81. package/dist/hooks/index.d.mts +423 -0
  82. package/dist/hooks/index.mjs +1 -0
  83. package/dist/host-CXAUGGN0.mjs +1 -0
  84. package/dist/identity-B_A0mE63.mjs +1 -0
  85. package/dist/index-6lyShOoU.d.mts +225 -0
  86. package/dist/index-7sXlairn2.d.mts +43 -0
  87. package/dist/index-BAKM2GMH2.d.mts +535 -0
  88. package/dist/index-BB419vv-.d.mts +3897 -0
  89. package/dist/index-BJOfdtbw.d.mts +729 -0
  90. package/dist/index-BXP9GK5q.d.mts +1075 -0
  91. package/dist/index-BdPwu6c0.d.mts +1730 -0
  92. package/dist/index-BePI0ckL.d.mts +40 -0
  93. package/dist/index-Bigx81Kr.d.mts +37 -0
  94. package/dist/index-BnNqbx2I.d.mts +134 -0
  95. package/dist/index-Bv15sNLn.d.mts +389 -0
  96. package/dist/index-C-myW_aK.d.mts +412 -0
  97. package/dist/index-C9F3Fc1A.d.mts +2938 -0
  98. package/dist/index-CNxS4Tlu.d.mts +1 -0
  99. package/dist/index-CVA0m1g9.d.mts +995 -0
  100. package/dist/index-C_kS2aqV2.d.mts +438 -0
  101. package/dist/index-Ch3ph52M2.d.mts +40 -0
  102. package/dist/index-CnZOKNjU.d.mts +89 -0
  103. package/dist/index-D1T-PPqF.d.mts +67 -0
  104. package/dist/index-D7T8XCku.d.mts +341 -0
  105. package/dist/index-DBQtpFLE.d.mts +4843 -0
  106. package/dist/index-DEw90pa2.d.mts +183 -0
  107. package/dist/index-DQRsGXb5.d.mts +109 -0
  108. package/dist/index-Dd5s4MSm.d.mts +72 -0
  109. package/dist/index-DubqLGH8.d.mts +1002 -0
  110. package/dist/index-ESSDWIB7.d.mts +11 -0
  111. package/dist/index-N5K1NOYs.d.mts +184 -0
  112. package/dist/index-PdUSmPT2.d.mts +180 -0
  113. package/dist/index-SzSiyG61.d.mts +117 -0
  114. package/dist/index-T0471kWA.d.mts +6760 -0
  115. package/dist/index-WKjrpcA_.d.mts +218 -0
  116. package/dist/index-hapw9_En.d.mts +13592 -0
  117. package/dist/index-iID2R9G1.d.mts +1490 -0
  118. package/dist/kernel/cli/index.d.mts +141 -0
  119. package/dist/kernel/cli/index.mjs +1 -0
  120. package/dist/kernel/cli/schemas.d.mts +63 -0
  121. package/dist/kernel/cli/schemas.mjs +1 -0
  122. package/dist/kernel/extension/index.d.mts +2 -0
  123. package/dist/kernel/extension/index.mjs +1 -0
  124. package/dist/kernel/index.d.mts +296 -0
  125. package/dist/kernel/index.mjs +1 -0
  126. package/dist/kernel/namespace/index.d.mts +2 -0
  127. package/dist/kernel/namespace/index.mjs +1 -0
  128. package/dist/kernel/observability/index.d.mts +2 -0
  129. package/dist/kernel/observability/index.mjs +1 -0
  130. package/dist/kernel/providers/index.d.mts +2 -0
  131. package/dist/kernel/providers/index.mjs +1 -0
  132. package/dist/kernel/window/index.d.mts +2 -0
  133. package/dist/kernel/window/index.mjs +1 -0
  134. package/dist/model-registry-BNzpR6TU.mjs +1 -0
  135. package/dist/model-registry-CIscwC52.mjs +1 -0
  136. package/dist/namespace-0yuzAKlr.mjs +1 -0
  137. package/dist/namespace-8cNguvIp.mjs +1 -0
  138. package/dist/namespace-BK2erxpV.d.mts +921 -0
  139. package/dist/namespace-Bmc7AW4J2.mjs +1 -0
  140. package/dist/namespace-C2ufjgaQ.d.mts +767 -0
  141. package/dist/namespace-C54Oj025.d.mts +159 -0
  142. package/dist/namespace-CCDEOwmW.d.mts +1313 -0
  143. package/dist/namespace-CfEWMXBx.mjs +1 -0
  144. package/dist/namespace-CkLUtc0g.d.mts +580 -0
  145. package/dist/namespace-D5Wrt7YU.mjs +1 -0
  146. package/dist/namespace-DZcuLwEA.d.mts +51 -0
  147. package/dist/namespace-Db-p67Rg.mjs +1 -0
  148. package/dist/namespace-FWx6HxaW.d.mts +611 -0
  149. package/dist/namespace-GLGGcWPH.d.mts +43 -0
  150. package/dist/namespace-N0dfwSg6.mjs +1 -0
  151. package/dist/namespace-O5SNY-LV.d.mts +2226 -0
  152. package/dist/namespace-ZbthBQVt.d.mts +142 -0
  153. package/dist/namespace-bq4Prtzn.d.mts +2046 -0
  154. package/dist/namespace-pNcSglBS.mjs +1 -0
  155. package/dist/namespace-ptv-pw_g.d.mts +3019 -0
  156. package/dist/namespace-xkvVw3hf2.d.mts +189 -0
  157. package/dist/native-session-supervisor-L-UIaEfd.mjs +1 -0
  158. package/dist/node/bus-server/index.d.mts +178 -0
  159. package/dist/node/bus-server/index.mjs +1 -0
  160. package/dist/node/bus-server/server-lifecycle.d.mts +2 -0
  161. package/dist/node/bus-server/server-lifecycle.mjs +1 -0
  162. package/dist/node/machine-identity/index.d.mts +85 -0
  163. package/dist/node/machine-identity/index.mjs +3 -0
  164. package/dist/node/transports/index.d.mts +1752 -0
  165. package/dist/node/transports/index.mjs +2 -0
  166. package/dist/orchestrator-shared-DrjtTXYh.d.mts +249 -0
  167. package/dist/orchestrator-shared-Wv1GI2mW.mjs +1 -0
  168. package/dist/platform-BbSLVg5b.mjs +1 -0
  169. package/dist/profile-4StaDQW0.mjs +1 -0
  170. package/dist/provider-context-CNRQ4d5m.mjs +1 -0
  171. package/dist/providers/index.d.mts +135 -0
  172. package/dist/providers/index.mjs +1 -0
  173. package/dist/providers-Cr4Za8a1.mjs +1 -0
  174. package/dist/providers-namespace-CDwxY_DV.d.mts +583 -0
  175. package/dist/schema-BwzXEtT2.d.mts +837 -0
  176. package/dist/schema-CAw_BqaG.mjs +1 -0
  177. package/dist/schema-introspection-D61TT_7b.mjs +1 -0
  178. package/dist/schema-uSGW-6oM.mjs +1 -0
  179. package/dist/schemas-BXstpWVp.mjs +1 -0
  180. package/dist/schemas-BdMU-gew.d.mts +160 -0
  181. package/dist/schemas-C40ZAJ33.mjs +1 -0
  182. package/dist/schemas-C5xtVqdb.d.mts +46 -0
  183. package/dist/schemas-CGZy_rU6.d.mts +13 -0
  184. package/dist/schemas-CLxtoKFy.mjs +1 -0
  185. package/dist/schemas-Co_sVhzz.mjs +1 -0
  186. package/dist/schemas-D9108Iv1.d.mts +182 -0
  187. package/dist/schemas-DENVYyds.d.mts +463 -0
  188. package/dist/schemas-DbWs_hj8.d.mts +174 -0
  189. package/dist/schemas-Di0XnnMX.d.mts +73 -0
  190. package/dist/schemas-KMA1efQg.d.mts +944 -0
  191. package/dist/schemas-qmn5SWPU.d.mts +312 -0
  192. package/dist/schemas-sshQEF3l.d.mts +237 -0
  193. package/dist/server-lifecycle-Cf_SZ27k.d.mts +160 -0
  194. package/dist/server-lifecycle-DbFwlrTW.mjs +1 -0
  195. package/dist/service-base/index.d.mts +98 -0
  196. package/dist/service-base/index.mjs +1 -0
  197. package/dist/services/adapter-runtime/index.d.mts +4 -0
  198. package/dist/services/adapter-runtime/index.mjs +1 -0
  199. package/dist/services/adapter-runtime/namespace.d.mts +2 -0
  200. package/dist/services/adapter-runtime/namespace.mjs +1 -0
  201. package/dist/services/adapter-runtime/schemas.d.mts +2 -0
  202. package/dist/services/adapter-runtime/schemas.mjs +1 -0
  203. package/dist/services/adapter-subsystem/index.d.mts +3 -0
  204. package/dist/services/adapter-subsystem/index.mjs +1 -0
  205. package/dist/services/adapter-subsystem/namespace.d.mts +2 -0
  206. package/dist/services/adapter-subsystem/namespace.mjs +1 -0
  207. package/dist/services/agent-runtime/index.d.mts +3 -0
  208. package/dist/services/agent-runtime/index.mjs +1 -0
  209. package/dist/services/agent-runtime/namespace.d.mts +2 -0
  210. package/dist/services/agent-runtime/namespace.mjs +1 -0
  211. package/dist/services/agent-runtime/schemas.d.mts +2 -0
  212. package/dist/services/agent-runtime/schemas.mjs +1 -0
  213. package/dist/services/capability/index.d.mts +2 -0
  214. package/dist/services/capability/index.mjs +1 -0
  215. package/dist/services/cli-detection/namespace.d.mts +56 -0
  216. package/dist/services/cli-detection/namespace.mjs +1 -0
  217. package/dist/services/codebase/index.d.mts +3 -0
  218. package/dist/services/codebase/index.mjs +1 -0
  219. package/dist/services/codebase/namespace.d.mts +2 -0
  220. package/dist/services/codebase/namespace.mjs +1 -0
  221. package/dist/services/codebase/schemas.d.mts +2 -0
  222. package/dist/services/codebase/schemas.mjs +1 -0
  223. package/dist/services/compression/index.d.mts +3 -0
  224. package/dist/services/compression/index.mjs +1 -0
  225. package/dist/services/compression/namespace.d.mts +2 -0
  226. package/dist/services/compression/namespace.mjs +1 -0
  227. package/dist/services/compression/schemas.d.mts +2 -0
  228. package/dist/services/compression/schemas.mjs +1 -0
  229. package/dist/services/context-rules/index.d.mts +412 -0
  230. package/dist/services/context-rules/index.mjs +1 -0
  231. package/dist/services/credential-change/index.d.mts +17 -0
  232. package/dist/services/credential-change/index.mjs +1 -0
  233. package/dist/services/definition/index.d.mts +2 -0
  234. package/dist/services/definition/index.mjs +1 -0
  235. package/dist/services/definition/namespace.d.mts +71 -0
  236. package/dist/services/definition/namespace.mjs +1 -0
  237. package/dist/services/definition/schemas.d.mts +38 -0
  238. package/dist/services/definition/schemas.mjs +1 -0
  239. package/dist/services/dialog/namespace.d.mts +105 -0
  240. package/dist/services/dialog/namespace.mjs +1 -0
  241. package/dist/services/dialog/schemas.d.mts +109 -0
  242. package/dist/services/dialog/schemas.mjs +1 -0
  243. package/dist/services/execution-target/index.d.mts +4 -0
  244. package/dist/services/execution-target/index.mjs +1 -0
  245. package/dist/services/execution-target/namespace.d.mts +2 -0
  246. package/dist/services/execution-target/namespace.mjs +1 -0
  247. package/dist/services/execution-target/schemas.d.mts +2 -0
  248. package/dist/services/execution-target/schemas.mjs +1 -0
  249. package/dist/services/filesystem/namespace.d.mts +432 -0
  250. package/dist/services/filesystem/namespace.mjs +1 -0
  251. package/dist/services/filesystem/schemas.d.mts +240 -0
  252. package/dist/services/filesystem/schemas.mjs +1 -0
  253. package/dist/services/harness/index.d.mts +861 -0
  254. package/dist/services/harness/index.mjs +1 -0
  255. package/dist/services/harness/storage/schema.d.mts +424 -0
  256. package/dist/services/harness/storage/schema.mjs +1 -0
  257. package/dist/services/index.d.mts +5703 -0
  258. package/dist/services/index.mjs +1 -0
  259. package/dist/services/local-notification/index.d.mts +25 -0
  260. package/dist/services/local-notification/index.mjs +1 -0
  261. package/dist/services/local-notification/namespace.d.mts +73 -0
  262. package/dist/services/local-notification/namespace.mjs +1 -0
  263. package/dist/services/local-notification/schemas.d.mts +88 -0
  264. package/dist/services/local-notification/schemas.mjs +1 -0
  265. package/dist/services/log-import/browser.d.mts +3 -0
  266. package/dist/services/log-import/browser.mjs +1 -0
  267. package/dist/services/log-import/index.d.mts +275 -0
  268. package/dist/services/log-import/index.mjs +2 -0
  269. package/dist/services/log-import/log-import.d.mts +3 -0
  270. package/dist/services/log-import/log-import.mjs +1 -0
  271. package/dist/services/log-import/namespace.d.mts +327 -0
  272. package/dist/services/log-import/namespace.mjs +1 -0
  273. package/dist/services/log-import/schemas.d.mts +217 -0
  274. package/dist/services/log-import/schemas.mjs +1 -0
  275. package/dist/services/model-registry/index.d.mts +2 -0
  276. package/dist/services/model-registry/index.mjs +1 -0
  277. package/dist/services/preferences/index.d.mts +3 -0
  278. package/dist/services/preferences/index.mjs +1 -0
  279. package/dist/services/preferences/schemas.d.mts +2 -0
  280. package/dist/services/preferences/schemas.mjs +1 -0
  281. package/dist/services/preferences/storage-namespace.d.mts +3 -0
  282. package/dist/services/preferences/storage-namespace.mjs +1 -0
  283. package/dist/services/provider-context/index.d.mts +2 -0
  284. package/dist/services/provider-context/index.mjs +1 -0
  285. package/dist/services/provider-runtime/index.d.mts +136 -0
  286. package/dist/services/provider-runtime/index.mjs +1 -0
  287. package/dist/services/session/handlers/index.d.mts +2 -0
  288. package/dist/services/session/handlers/index.mjs +1 -0
  289. package/dist/services/session/index.d.mts +10 -0
  290. package/dist/services/session/index.mjs +1 -0
  291. package/dist/services/session/messages/namespace.d.mts +2 -0
  292. package/dist/services/session/messages/namespace.mjs +1 -0
  293. package/dist/services/session/orchestrator-testing/index.d.mts +2 -0
  294. package/dist/services/session/orchestrator-testing/index.mjs +1 -0
  295. package/dist/services/session/session-events/namespace.d.mts +2 -0
  296. package/dist/services/session/session-events/namespace.mjs +1 -0
  297. package/dist/services/session/storage/namespace.d.mts +2 -0
  298. package/dist/services/session/storage/namespace.mjs +1 -0
  299. package/dist/services/session/storage/schema.d.mts +2 -0
  300. package/dist/services/session/storage/schema.mjs +1 -0
  301. package/dist/services/session/testing/index.d.mts +35 -0
  302. package/dist/services/session/testing/index.mjs +52 -0
  303. package/dist/services/session/testing/orchestrator-shared.d.mts +2 -0
  304. package/dist/services/session/testing/orchestrator-shared.mjs +1 -0
  305. package/dist/services/session/turns/namespace.d.mts +2 -0
  306. package/dist/services/session/turns/namespace.mjs +1 -0
  307. package/dist/services/session-editor/index.d.mts +119 -0
  308. package/dist/services/session-editor/index.mjs +1 -0
  309. package/dist/services/settings/index.d.mts +47 -0
  310. package/dist/services/settings/index.mjs +1 -0
  311. package/dist/services/settings/namespace.d.mts +662 -0
  312. package/dist/services/settings/namespace.mjs +1 -0
  313. package/dist/services/settings/storage/clients-namespace.d.mts +2 -0
  314. package/dist/services/settings/storage/clients-namespace.mjs +1 -0
  315. package/dist/services/settings/storage/extension-configs/namespace.d.mts +184 -0
  316. package/dist/services/settings/storage/extension-configs/namespace.mjs +1 -0
  317. package/dist/services/settings/storage/index.d.mts +4 -0
  318. package/dist/services/settings/storage/index.mjs +1 -0
  319. package/dist/services/settings/storage/providers-namespace.d.mts +2 -0
  320. package/dist/services/settings/storage/providers-namespace.mjs +1 -0
  321. package/dist/services/tool-approval/index.d.mts +2 -0
  322. package/dist/services/tool-approval/index.mjs +1 -0
  323. package/dist/services/tools/index.d.mts +2 -0
  324. package/dist/services/tools/index.mjs +1 -0
  325. package/dist/services/tray-menu/index.d.mts +4 -0
  326. package/dist/services/tray-menu/index.mjs +1 -0
  327. package/dist/services/tray-menu/namespace.d.mts +2 -0
  328. package/dist/services/tray-menu/namespace.mjs +1 -0
  329. package/dist/services/tray-menu/schemas.d.mts +2 -0
  330. package/dist/services/tray-menu/schemas.mjs +1 -0
  331. package/dist/services/turn/index.d.mts +2 -0
  332. package/dist/services/turn/index.mjs +1 -0
  333. package/dist/services/turn/namespace.d.mts +2 -0
  334. package/dist/services/turn/namespace.mjs +1 -0
  335. package/dist/services/turn/schemas.d.mts +335 -0
  336. package/dist/services/turn/schemas.mjs +1 -0
  337. package/dist/services/worker/index.d.mts +3 -0
  338. package/dist/services/worker/index.mjs +1 -0
  339. package/dist/services/worker/namespace.d.mts +2 -0
  340. package/dist/services/worker/namespace.mjs +1 -0
  341. package/dist/services/worker/schemas.d.mts +2 -0
  342. package/dist/services/worker/schemas.mjs +1 -0
  343. package/dist/session-Do6lDZM4.mjs +123 -0
  344. package/dist/session-lineage-Eev4uo4I.d.mts +65 -0
  345. package/dist/session-piI1R5rP.mjs +1 -0
  346. package/dist/shared-DxHLl9UP.mjs +1 -0
  347. package/dist/shared-schemas-BgQv_tnu.mjs +1 -0
  348. package/dist/skill-CB5h-ZFQ.mjs +1 -0
  349. package/dist/storage/drizzle/client.d.mts +78 -0
  350. package/dist/storage/drizzle/client.mjs +1 -0
  351. package/dist/storage/drizzle/index.d.mts +98 -0
  352. package/dist/storage/drizzle/index.mjs +1 -0
  353. package/dist/storage/handlers/drizzle/index.d.mts +2 -0
  354. package/dist/storage/handlers/drizzle/index.mjs +1 -0
  355. package/dist/storage/handlers/index.d.mts +33 -0
  356. package/dist/storage/handlers/index.mjs +1 -0
  357. package/dist/storage/index.d.mts +192 -0
  358. package/dist/storage/index.mjs +1 -0
  359. package/dist/storage-namespace-ADwyijoe.mjs +1 -0
  360. package/dist/storage-namespace-DAm8iWEj.d.mts +221 -0
  361. package/dist/storage-namespace-definition-CHu2k14q.mjs +1 -0
  362. package/dist/storage-namespace-definition-CJgqyXH1.d.mts +17 -0
  363. package/dist/style.css +3782 -0
  364. package/dist/testing/drizzle-harness.d.mts +130 -0
  365. package/dist/testing/drizzle-harness.mjs +1 -0
  366. package/dist/testing/index.d.mts +106 -0
  367. package/dist/testing/index.mjs +1 -0
  368. package/dist/tool-approval-service-BcBSUZCO.mjs +1 -0
  369. package/dist/tools/index.d.mts +825 -0
  370. package/dist/tools/index.mjs +1 -0
  371. package/dist/tools/testing/index.d.mts +53 -0
  372. package/dist/tools/testing/index.mjs +1 -0
  373. package/dist/tools-CDSgj0ee.mjs +1 -0
  374. package/dist/tray-menu-service-CTXC1Elg.mjs +1 -0
  375. package/dist/types-6WxLfoM3.d.mts +31 -0
  376. package/dist/types-BjToUrHp.d.mts +6619 -0
  377. package/dist/types-CD1LJwPc.d.mts +1009 -0
  378. package/dist/types-Cvrj2ogm.d.mts +305 -0
  379. package/dist/types-DYF5LxZY.d.mts +233 -0
  380. package/dist/types-t295YC6T.d.mts +262 -0
  381. package/dist/types-vNpkAe4Y.d.mts +128 -0
  382. package/dist/ui-components/index.d.mts +2342 -0
  383. package/dist/ui-components/index.mjs +8 -0
  384. package/dist/ui-config-CXmbsqZV.mjs +1 -0
  385. package/dist/ui-hooks/index.d.mts +1805 -0
  386. package/dist/ui-hooks/index.mjs +1 -0
  387. package/dist/ui-kernel/index.d.mts +2793 -0
  388. package/dist/ui-kernel/index.mjs +1 -0
  389. package/dist/ui-kernel/pages/namespace.d.mts +88 -0
  390. package/dist/ui-kernel/pages/namespace.mjs +1 -0
  391. package/dist/ui-kernel/pages/schemas.d.mts +2 -0
  392. package/dist/ui-kernel/pages/schemas.mjs +1 -0
  393. package/dist/ui-views/index.d.mts +487 -0
  394. package/dist/ui-views/index.mjs +30 -0
  395. package/dist/utils/health-probe.d.mts +26 -0
  396. package/dist/utils/health-probe.mjs +1 -0
  397. package/dist/utils/index.d.mts +227 -0
  398. package/dist/utils/index.mjs +2 -0
  399. package/dist/utils/keychain.d.mts +31 -0
  400. package/dist/utils/keychain.mjs +1 -0
  401. package/dist/utils/resolve-package-root.d.mts +12 -0
  402. package/dist/utils/resolve-package-root.mjs +1 -0
  403. package/dist/utils/workspace-root.d.mts +27 -0
  404. package/dist/utils/workspace-root.mjs +2 -0
  405. package/dist/variant-D5kSrL3m.mjs +1 -0
  406. package/dist/version-CjS20oXi.mjs +1 -0
  407. package/dist/visibility-CZu8ooOA.mjs +1 -0
  408. package/dist/window-registry-CUftmDr3.mjs +1 -0
  409. package/dist/window-registry-C_IJmY8_.d.mts +130 -0
  410. package/package.json +346 -0
@@ -0,0 +1,4843 @@
1
+ import { r as ExecutionTarget } from "./schemas-DENVYyds.mjs";
2
+ import { d as Turn$1 } from "./index-C_kS2aqV2.mjs";
3
+ import { a as PipelineStep, o as SessionEditorAction, t as ActionCategory } from "./types-vNpkAe4Y.mjs";
4
+ import { a as agents, o as sessions } from "./schema-BwzXEtT2.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, AdapterSessionStatusSchema, BranchKind, ContextWindowState, ExtensionContext, ForkOptions, ForkTransforms, IMakaioSession, MakaioSessionAgent, MakaioSessionEvent, Message, MessageBlock, MessageInput, ReasoningLevelMap, SessionContext, SessionExtensionContext, 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 packages/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 packages/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 packages/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 packages/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 packages/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 packages/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 packages/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 packages/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 → workstream default → 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
+ workstreamId?: string;
407
+ projectId?: string;
408
+ }): Promise<ExecutionTarget>;
409
+ //#endregion
410
+ //#region packages/services/core/src/session/utils/recovery-context.d.ts
411
+ /**
412
+ * Build sessionContext with messageHistory for a recovered agent.
413
+ * Uses getFullConversation() to assemble history from stored messages.
414
+ *
415
+ * This function is framework-safe: it has no host-layer dependencies
416
+ * (no PersonaSubjects, ProfileSubjects, VirtualModelSubjects, etc.).
417
+ * @param bus - Bus instance
418
+ * @param session - Session to build context for
419
+ * @returns SessionContext with messageHistory and isFirstTurn signal
420
+ */
421
+ declare function buildRecoveryContext(bus: IMakaioBus, session: IMakaioSession): Promise<SessionContext>;
422
+ //#endregion
423
+ //#region packages/services/core/src/session/utils/agent-recovery.d.ts
424
+ /**
425
+ * Configuration for recovering dead agents during liveness verification.
426
+ */
427
+ interface RecoveryConfig {
428
+ /** Working directory for agent execution */
429
+ cwd?: string;
430
+ /** Model identifier (e.g., 'claude-sonnet-4-20250514', 'gpt-4o') */
431
+ model?: string;
432
+ }
433
+ /**
434
+ * Ensure agent cwd matches desired cwd, swapping connector if needed.
435
+ * Must be called while agent is idle (before message routing).
436
+ * @param bus - Bus instance
437
+ * @param agent - Agent to validate/swap
438
+ * @param desiredCwd - Target working directory
439
+ * @param options - Optional request flags (e.g., skip interactive warnings)
440
+ * @returns Swap result with previous cwd when a swap occurred
441
+ */
442
+ declare function ensureAgentCwd(bus: IMakaioBus, agent: MakaioSessionAgent, desiredCwd: string, options?: {
443
+ skipWarning?: boolean;
444
+ }): Promise<{
445
+ swapped: false;
446
+ } | {
447
+ swapped: true;
448
+ previousCwd: string;
449
+ }>;
450
+ /**
451
+ * Ensure an agent uses the desired model and/or reasoning effort, performing an
452
+ * in-place change or connector swap as needed.
453
+ *
454
+ * Mirrors the `ensureAgentCwd()` pattern. At least one of `desiredModel`,
455
+ * `options.reasoningEffort`, or `options.providerConfigId` must be defined for a
456
+ * change to occur.
457
+ * @param bus - The bus instance for RPC
458
+ * @param agent - The agent to change (mutated in-place on success)
459
+ * @param desiredModel - The model identifier to switch to, or undefined to keep current model
460
+ * @param options - Optional configuration: `providerConfigId` triggers a swap when it differs from the
461
+ * current one; `reasoningEffort` is applied after the model change; `skipWarning` suppresses the
462
+ * model-change confirmation dialog
463
+ * @returns Discriminated union: no change, or changed with swap info
464
+ */
465
+ declare function ensureAgentModel(bus: IMakaioBus, agent: MakaioSessionAgent, desiredModel: string | undefined, options?: {
466
+ providerConfigId?: string;
467
+ reasoningEffort?: AIReasoningLevel;
468
+ skipWarning?: boolean;
469
+ }): Promise<{
470
+ changed: false;
471
+ } | {
472
+ changed: true;
473
+ swapped: boolean;
474
+ }>;
475
+ /**
476
+ * Verify liveness of agents and recover any that are dead.
477
+ * Queries each agent via getAgent; if unresponsive, triggers connector swap via recoverAgent.
478
+ * @param bus - Bus instance
479
+ * @param agents - Agents to verify
480
+ * @param recoveryConfig - Configuration for recovering dead agents
481
+ * @returns Verified/recovered agents and set of recovered agent IDs
482
+ */
483
+ declare function verifyAndRecoverAgents(bus: IMakaioBus, agents: MakaioSessionAgent[], recoveryConfig: RecoveryConfig): Promise<{
484
+ verifiedAgents: MakaioSessionAgent[];
485
+ recoveredAgentIds: Set<string>;
486
+ }>;
487
+ /**
488
+ * Build recovery context and apply optional additional transforms.
489
+ * @param bus - Bus instance
490
+ * @param session - Session to build context for
491
+ * @param options - Optional transform pipeline to run before conversion
492
+ * @returns SessionContext with transformed messageHistory and fresh-mode signal
493
+ */
494
+ declare function buildRecoveryContextWithPipeline(bus: IMakaioBus, session: IMakaioSession, options?: {
495
+ pipeline?: PipelineStep[];
496
+ }): Promise<SessionContext>;
497
+ /**
498
+ * Recover a dead agent by triggering connector swap via the adapter.
499
+ * The agent keeps its identity — no session mutation needed.
500
+ *
501
+ * Context delivery happens via the normal sendMessage path that follows
502
+ * recovery (same handler invocation). No staging needed.
503
+ * @param bus - Bus instance
504
+ * @param deadAgent - The dead agent to recover
505
+ * @param recoveryConfig - Configuration for the recovered connector
506
+ * @returns Same agent reference — identity preserved
507
+ */
508
+ declare function recoverAgent(bus: IMakaioBus, deadAgent: MakaioSessionAgent, recoveryConfig: RecoveryConfig): Promise<MakaioSessionAgent>;
509
+ //#endregion
510
+ //#region packages/services/core/src/session/utils/turn-initiator.d.ts
511
+ /**
512
+ * Builds turn initiator metadata from `sendMessage` source fields.
513
+ *
514
+ * Returns `{ source: 'extension', sourceId: extensionId }` for extension-initiated turns,
515
+ * `{ source }` for other explicit sources, or `{ source: 'user' }` as the default.
516
+ * @param source - Optional turn origin discriminator
517
+ * @param extensionId - Required when `source === 'extension'`
518
+ * @returns Normalised turn initiator
519
+ * @throws Error when `source` is `'extension'` and `extensionId` is absent or blank
520
+ */
521
+ declare function buildTurnInitiator(source: 'extension' | 'user' | 'system' | undefined, extensionId: string | undefined): TurnInitiator;
522
+ //#endregion
523
+ //#region packages/services/core/src/session/context-window/types.d.ts
524
+ /**
525
+ * Context window tracking types for per-session aggregation.
526
+ *
527
+ * The tracker monitors AgentSubjects.contextWindow.updated events
528
+ * and maintains per-session state using "worst agent" aggregation.
529
+ */
530
+ /**
531
+ * Per-session context window state, aggregated across agents.
532
+ *
533
+ * Uses "worst agent" strategy: reports the state of whichever
534
+ * agent has the highest usage percentage.
535
+ */
536
+ interface SessionContextWindowState {
537
+ /** Current token count (worst across agents) */
538
+ currentTokens: number;
539
+ /** Max tokens for the model with lowest headroom */
540
+ maxTokens: number;
541
+ /** Percentage used (0-100) */
542
+ percentage: number;
543
+ /** Warning level based on percentage */
544
+ level: 'ok' | 'warn' | 'critical';
545
+ /** Agent ID with the highest usage */
546
+ worstAgentId?: string;
547
+ /** Timestamp of last update */
548
+ lastUpdatedAt: number;
549
+ }
550
+ /**
551
+ * Per-agent context state (internal tracking).
552
+ *
553
+ * Stored by the tracker to enable per-session aggregation
554
+ * when multiple agents are attached to the same session.
555
+ */
556
+ interface AgentContextState {
557
+ agentId: string;
558
+ sessionId: string;
559
+ currentTokens: number;
560
+ maxTokens: number;
561
+ percentage: number;
562
+ level: 'ok' | 'warn' | 'critical';
563
+ cachedTokens?: number;
564
+ updatedAt: number;
565
+ }
566
+ /**
567
+ * Tracker configuration options.
568
+ */
569
+ interface ContextWindowTrackerConfig {
570
+ /** How long to keep stale agent entries (ms). Default: 1 hour */
571
+ staleThresholdMs?: number;
572
+ }
573
+ //#endregion
574
+ //#region packages/services/core/src/session/context-window/context-window-tracker.d.ts
575
+ /**
576
+ * Tracks context window state per session, aggregating across agents.
577
+ *
578
+ * Subscribes to AgentSubjects.contextWindow.updated and maintains
579
+ * per-session state using "worst agent" aggregation strategy.
580
+ * @example
581
+ * ```typescript
582
+ * const tracker = new ContextWindowTracker(MakaioBus);
583
+ * tracker.start();
584
+ *
585
+ * // Later, query session state
586
+ * const state = tracker.getSessionState('session-123');
587
+ * if (state?.level === 'critical') {
588
+ * // Suggest compression
589
+ * }
590
+ *
591
+ * // Cleanup on shutdown
592
+ * tracker.stop();
593
+ * ```
594
+ */
595
+ declare class ContextWindowTracker {
596
+ private readonly bus;
597
+ private readonly agentStates;
598
+ private readonly sessionStates;
599
+ private unsubscribe?;
600
+ private readonly staleThresholdMs;
601
+ constructor(bus: IMakaioBus, config?: ContextWindowTrackerConfig);
602
+ /**
603
+ * Start tracking context window updates.
604
+ * Idempotent - calling multiple times is safe.
605
+ */
606
+ start(): void;
607
+ /**
608
+ * Stop tracking and clear all state.
609
+ */
610
+ stop(): void;
611
+ /**
612
+ * Get aggregated context state for a session.
613
+ *
614
+ * State persists until explicitly cleared via clearSession().
615
+ * Clear is called by MakaioSessionService on:
616
+ * - session.close (session closed)
617
+ * - session.compressed (context compression)
618
+ *
619
+ * Even if we haven't heard from agents recently, the context window
620
+ * is still full - the state remains valid.
621
+ * @param sessionId - The session to get state for
622
+ * @returns The aggregated context window state, or undefined if no data
623
+ */
624
+ getSessionState(sessionId: string): SessionContextWindowState | undefined;
625
+ /**
626
+ * Clear state for a specific session (e.g., on session close).
627
+ * Removes both the session state and all agent states for that session.
628
+ * @param sessionId - The session to clear
629
+ */
630
+ clearSession(sessionId: string): void;
631
+ /**
632
+ * Recompute session state from all agents in that session.
633
+ * Uses "worst agent" strategy - highest percentage wins.
634
+ *
635
+ * Stale agent entries are pruned for memory management, but session
636
+ * state is preserved - context window is still full even if agent
637
+ * hasn't reported recently.
638
+ * @param sessionId - The session to recompute
639
+ */
640
+ private recomputeSessionState;
641
+ }
642
+ //#endregion
643
+ //#region packages/services/core/src/session/handlers/lifecycle-handlers.d.ts
644
+ /**
645
+ * Dependencies for session lifecycle handlers.
646
+ */
647
+ interface SessionLifecycleDeps {
648
+ bus: IMakaioBus;
649
+ contextTracker: ContextWindowTracker;
650
+ }
651
+ /**
652
+ * Register handler for session.getStatusCounts.
653
+ * @param deps - Handler dependencies
654
+ * @returns Cleanup function
655
+ */
656
+ declare function registerGetStatusCountsHandler(deps: SessionLifecycleDeps): () => void;
657
+ /**
658
+ * Register handler for session.resume.
659
+ * @param deps - Handler dependencies
660
+ * @returns Cleanup function
661
+ */
662
+ declare function registerResumeHandler(deps: SessionLifecycleDeps): () => void;
663
+ //#endregion
664
+ //#region packages/services/core/src/session/session-editor/action-registry.d.ts
665
+ /**
666
+ * Registry for pipeline actions.
667
+ * Actions are registered at startup and looked up during pipeline execution.
668
+ */
669
+ declare class ActionRegistry {
670
+ private actions;
671
+ /**
672
+ * Register a pipeline action.
673
+ * @param action - Action definition
674
+ */
675
+ register(action: SessionEditorAction): void;
676
+ /**
677
+ * Get an action by ID.
678
+ * @param id - Action identifier
679
+ * @returns Action or undefined if not found
680
+ */
681
+ get(id: string): SessionEditorAction | undefined;
682
+ /**
683
+ * Get all registered actions.
684
+ * @returns Array of all actions
685
+ */
686
+ getAll(): SessionEditorAction[];
687
+ /**
688
+ * Get actions by category.
689
+ * @param category - Category to filter by
690
+ * @returns Actions in that category
691
+ */
692
+ getByCategory(category: ActionCategory): SessionEditorAction[];
693
+ /**
694
+ * Clear all registered actions.
695
+ * @internal For testing only - clears state between tests.
696
+ */
697
+ reset(): void;
698
+ }
699
+ /** Global action registry instance */
700
+ declare const actionRegistry: ActionRegistry;
701
+ //#endregion
702
+ //#region packages/services/core/src/session/session-editor/actions/index.d.ts
703
+ /**
704
+ * Register all built-in actions.
705
+ * Call this at service startup. Safe to call multiple times.
706
+ *
707
+ * Base actions (no bus required) are registered once on first call.
708
+ * Bus-dependent actions (e.g. llm-extract) are registered on the first
709
+ * call that supplies a `bus` instance, independently of whether base
710
+ * registration has already occurred.
711
+ * @param bus - Optional bus instance. When provided, bus-dependent actions
712
+ * (e.g. llm-extract) are also registered. Existing callers that pass no
713
+ * args continue to work without change.
714
+ */
715
+ declare function registerBuiltInActions(bus?: IMakaioBus): void;
716
+ /**
717
+ * Reset registration state.
718
+ * @internal For testing only.
719
+ */
720
+ declare function resetBuiltInActionsRegistration(): void;
721
+ //#endregion
722
+ //#region packages/services/core/src/session/session-editor/handlers.d.ts
723
+ /**
724
+ * Register handler for session-editor.listActions.
725
+ *
726
+ * Maps all registered actions to UI-safe summaries by stripping the execute
727
+ * method and keeping only id, label, description, and category.
728
+ * @param bus - Bus instance to register on
729
+ * @returns Cleanup function to unsubscribe the handler
730
+ */
731
+ declare function registerListActionsHandler(bus: IMakaioBus): () => void;
732
+ //#endregion
733
+ //#region packages/services/core/src/session/selection-utils.d.ts
734
+ /**
735
+ * Normalize a selection string field by trimming whitespace and coercing
736
+ * blank strings to `undefined`.
737
+ *
738
+ * Used wherever adapter/agent selection strings are read from wire payloads to
739
+ * ensure callers cannot accidentally pass whitespace-only values as meaningful
740
+ * adapter names or IDs.
741
+ * @param value - Candidate string value from a selection payload field
742
+ * @returns Trimmed non-empty string, or `undefined` when the input is absent
743
+ * or contains only whitespace
744
+ */
745
+ declare function normalizeSelectionString(value: string | undefined): string | undefined;
746
+ /**
747
+ * Resolve the canonical `adapterName` for a given deterministic `adapterId`,
748
+ * rejecting when the caller-supplied name does not match the subsystem lookup.
749
+ *
750
+ * The adapter runtime owns reverse lookup for deterministic IDs, including
751
+ * remote-machine IDs that still identify a known adapter type.
752
+ * @param bus - Bus instance used to query the adapter runtime reverse lookup
753
+ * @param adapterId - Adapter instance identifier to look up
754
+ * @param explicitAdapterName - Caller-supplied name to validate against storage;
755
+ * `undefined` skips the mismatch check
756
+ * @param errorPrefix - Prefix prepended to thrown error messages (include trailing space)
757
+ * @returns Canonical adapter name resolved by the adapter runtime
758
+ */
759
+ declare function resolveAdapterNameById(bus: IMakaioBus, adapterId: string, explicitAdapterName: string | undefined, errorPrefix: string): Promise<string>;
760
+ //#endregion
761
+ //#region packages/services/core/src/session/constants.d.ts
762
+ /** Default transform pipeline for connector-swap history injection. */
763
+ declare const CONNECTOR_SWAP_DEFAULT_PIPELINE: PipelineStep[];
764
+ //#endregion
765
+ //#region packages/services/core/src/session/fallback-runtime-options.d.ts
766
+ /**
767
+ * Runtime options preserved across a VirtualModel fallback hop.
768
+ *
769
+ * These fields are extracted from the original `agent.attach` or `adapter.startAgent`
770
+ * payload and re-applied to the fallback attach so the replacement agent
771
+ * inherits the same execution environment (cwd, tool restrictions, system prompt).
772
+ *
773
+ * `allowedDirectories` is intentionally excluded — directory restrictions are
774
+ * resolved at attach time and must not be blindly forwarded across adapter hops.
775
+ */
776
+ type FallbackRuntimeOptions = Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt' | 'allowedTools' | 'disallowedTools'>;
777
+ /**
778
+ * Picks fallback-relevant runtime options from an object that carries
779
+ * `AdapterRuntimeOptions`-compatible fields.
780
+ *
781
+ * Covers both `adapter.startAgent` payloads (which merge `AdapterRuntimeOptionsSchema`
782
+ * at the top level) and caller-extracted `agent` sub-objects from
783
+ * `session.agent.attach` payloads (which carry the same fields on `AgentSelectionBase`).
784
+ *
785
+ * Only defined fields are included — omitted keys are not forwarded to avoid
786
+ * overwriting adapter or schema defaults with `undefined`.
787
+ * @param payload - Object carrying the runtime option fields
788
+ * @returns Sparse runtime options object used for fallback attach
789
+ */
790
+ declare function pickFallbackRuntimeOptions(payload: Partial<Pick<AdapterRuntimeOptions, 'cwd' | 'systemPrompt' | 'allowedTools' | 'disallowedTools'>>): FallbackRuntimeOptions;
791
+ //#endregion
792
+ //#region packages/services/core/src/session/context/assemble-fork-context.d.ts
793
+ /**
794
+ * Assemble fork context for a session's first turn.
795
+ *
796
+ * For fork sessions on their first turn, this:
797
+ * 1. Detects if this is a fork session (has parentSessionId)
798
+ * 2. Checks if this is the first turn (via isNewTurn flag + storage query)
799
+ * 3. Calls getFullConversation() to get projected context with transforms
800
+ * 4. Converts SessionMessage[] to Message[] format
801
+ * 5. Returns enriched SessionContext with messageHistory
802
+ *
803
+ * If not a fork first turn, returns the original sessionContext unchanged.
804
+ * @param bus - Bus instance for RPC calls
805
+ * @param session - Session to check for fork context
806
+ * @param sessionId - Session ID
807
+ * @param originalContext - Original sessionContext from payload
808
+ * @param isNewTurn - Whether this is a new turn (avoids race with just-created turn record)
809
+ * @returns Enriched or original SessionContext
810
+ */
811
+ declare function assembleForkContext(bus: IMakaioBus, session: IMakaioSession, sessionId: string, originalContext?: SessionContext, isNewTurn?: boolean): Promise<SessionContext | undefined>;
812
+ //#endregion
813
+ //#region packages/services/core/src/session/attachment-artifacts.d.ts
814
+ /**
815
+ * Minimal descriptor for a session-scoped attachment artifact.
816
+ *
817
+ * Defined here so the framework core remains independent of any host plugin.
818
+ * The host (host layer) owns the full storage schema; this type covers only
819
+ * the fields that `createAttachmentArtifacts` needs to populate.
820
+ */
821
+ /** Metadata linking an attachment artifact back to its originating message. */
822
+ interface AttachmentArtifactMetadata extends Record<string, unknown> {
823
+ /** Message that contained the attachment. */
824
+ messageId: string;
825
+ /** Position of the attachment block within the message's blocks array. */
826
+ blockIndex: number;
827
+ /** Original file name of the attachment. */
828
+ fileName?: string;
829
+ }
830
+ interface AttachmentArtifactInput {
831
+ /** Unique artifact identifier. */
832
+ id: string;
833
+ /** Always 'session' for attachment artifacts created from message blocks. */
834
+ scope: 'session';
835
+ /** Session the artifact belongs to. */
836
+ sessionId: string;
837
+ /** Always 'user-upload' for attachment artifacts. */
838
+ type: 'user-upload';
839
+ /** MIME type of the attached file. */
840
+ mimeType: string;
841
+ /** Absolute file path on disk, when available. */
842
+ filePath?: string;
843
+ /** Base64-encoded content, when the source was base64 data. */
844
+ content?: string;
845
+ /** Structured metadata linking the artifact back to its origin. */
846
+ metadata: AttachmentArtifactMetadata;
847
+ }
848
+ /**
849
+ * Result of a single artifact store attempt.
850
+ *
851
+ * Mirrors the optional-result discriminated-union shape returned by
852
+ * `IMakaioBus.requestOptional` so the host can signal whether the artifacts
853
+ * plugin was available without coupling the framework to the bus API.
854
+ */
855
+ type StoreArtifactResult = {
856
+ handled: true;
857
+ data: {
858
+ id: string;
859
+ };
860
+ } | {
861
+ handled: false;
862
+ };
863
+ /**
864
+ * Host-provided callback that persists one attachment artifact.
865
+ *
866
+ * Injected by the host layer so that `createAttachmentArtifacts` stays
867
+ * free of host plugin imports. Returning `{ handled: false }` signals
868
+ * that the artifacts plugin is not loaded; the caller logs a warning but
869
+ * never fails the parent request.
870
+ * @param artifact - The artifact descriptor to store.
871
+ * @returns A promise resolving to a {@link StoreArtifactResult}.
872
+ */
873
+ type StoreArtifactFn = (artifact: AttachmentArtifactInput) => Promise<StoreArtifactResult>;
874
+ /**
875
+ * Creates session-scoped artifacts for attachment blocks in a user message.
876
+ *
877
+ * Called after message storage. Delegates persistence to `storeArtifact` so
878
+ * this function remains free of host plugin dependencies — the host
879
+ * (host layer) owns the storage subject and wires the bus call.
880
+ *
881
+ * Breaking change: previously accepted `IMakaioBus` and relied on the
882
+ * artifacts storage subject from `@makaio/contracts`. The callback signature
883
+ * decouples the framework from that bus + subject wiring.
884
+ *
885
+ * Each attachment block becomes a `user-upload` artifact in the session scope,
886
+ * with metadata linking it back to the originating message.
887
+ * @param storeArtifact - Host-provided callback to persist one artifact
888
+ * @param sessionId - Session containing the message
889
+ * @param messageId - Message containing the attachments
890
+ * @param blocks - Normalized message blocks (already stored)
891
+ */
892
+ declare function createAttachmentArtifacts(storeArtifact: StoreArtifactFn, sessionId: string, messageId: string, blocks: SessionMessageBlock[]): Promise<void>;
893
+ //#endregion
894
+ //#region packages/services/core/src/session/session-bridge.d.ts
895
+ declare class SessionBridge {
896
+ private readonly bus;
897
+ private readonly agentToSession;
898
+ /** Extended mapping: agentId -\> \{ sessionId, turnId, adapterSessionId \} */
899
+ private readonly agentContext;
900
+ /** Block accumulator: agentId -\> blocks (one agent = one response per turn) */
901
+ private readonly agentBlocks;
902
+ private readonly cleanups;
903
+ constructor(bus?: IMakaioBus);
904
+ private registerHandlers;
905
+ /**
906
+ * Build and maintain agentId→sessionId mapping.
907
+ */
908
+ private registerMappingHandlers;
909
+ /**
910
+ * Track turn assignments for agents.
911
+ */
912
+ private registerTurnTrackingHandlers;
913
+ /**
914
+ * Accumulate blocks from agent events for storage on complete.
915
+ */
916
+ private registerBlockAccumulationHandlers;
917
+ /**
918
+ * Store accumulated blocks as an assistant message.
919
+ * @param agentId - ID of the agent that produced the message
920
+ * @param adapterSessionId - Optional adapter session ID
921
+ * @param error - Optional error message if agent failed
922
+ */
923
+ private storeAssistantMessage;
924
+ /**
925
+ * Stop the bridge and clean up subscriptions.
926
+ */
927
+ destroy(): void;
928
+ }
929
+ //#endregion
930
+ //#region packages/services/core/src/session/extension-context.d.ts
931
+ /**
932
+ * Implementation of SessionExtensionContext.
933
+ * Routes all actions through bus subjects.
934
+ */
935
+ declare class SessionExtensionContextImpl implements SessionExtensionContext {
936
+ private readonly bus;
937
+ private readonly _sessionId;
938
+ private readonly _extensionId;
939
+ private readonly _turnId?;
940
+ private readonly _parentSessionId?;
941
+ private readonly contextTracker?;
942
+ private readonly contextContributions;
943
+ constructor(bus: IMakaioBus, _sessionId: string, _extensionId: string, _turnId?: string | undefined, _parentSessionId?: string | undefined, contextTracker?: ContextWindowTracker | undefined);
944
+ get sessionId(): string;
945
+ get turnId(): string | undefined;
946
+ get parentSessionId(): string | undefined;
947
+ get extensionId(): string;
948
+ sendToAgent(agentId: string, message: Message): Promise<void>;
949
+ contributeContext(key: string, value: unknown): void;
950
+ /**
951
+ * Get all contributions (called by orchestrator at turn boundary).
952
+ * @returns Record of all context contributions
953
+ */
954
+ getContributions(): Record<string, unknown>;
955
+ fork(options: ForkOptions): Promise<string>;
956
+ merge(childSessionId: string, summary?: string): Promise<void>;
957
+ abandon(childSessionId: string): Promise<void>;
958
+ requestCompression(reason: string): Promise<void>;
959
+ getContextWindowState(): Promise<ContextWindowState>;
960
+ getChildSessions(): Promise<string[]>;
961
+ }
962
+ /**
963
+ * Factory function for creating SessionExtensionContext instances.
964
+ * @param bus - The bus instance for communication
965
+ * @param sessionId - The session identifier
966
+ * @param extensionId - The extension identifier for audit trail
967
+ * @param turnId - Optional current turn identifier
968
+ * @param parentSessionId - Optional parent session identifier (for forked sessions)
969
+ * @param contextTracker - Optional ContextWindowTracker for real-time context state
970
+ * @returns A new SessionExtensionContextImpl instance
971
+ */
972
+ declare function createSessionExtensionContext(bus: IMakaioBus, sessionId: string, extensionId: string, turnId?: string, parentSessionId?: string, contextTracker?: ContextWindowTracker): SessionExtensionContextImpl;
973
+ //#endregion
974
+ //#region packages/services/core/src/session/storage/agent-namespace.d.ts
975
+ /**
976
+ * Agent storage namespace.
977
+ *
978
+ * Provides bus subjects for agent CRUD operations and
979
+ * Drizzle schemas for SQL-based persistence.
980
+ * @example
981
+ * ```typescript
982
+ * import { AgentStorageSubjects } from '@makaio/framework/services/session';
983
+ *
984
+ * const { agent } = await bus.request(AgentStorageSubjects.get, { agentId: '123' });
985
+ * ```
986
+ */
987
+ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDefinition<"agent", {
988
+ /**
989
+ * Get an agent by ID.
990
+ *
991
+ * Subject: `storage:agent.get`
992
+ * Type: Request (RPC)
993
+ */
994
+ get: {
995
+ request: z.ZodObject<{
996
+ agentId: z.ZodString;
997
+ }, z.core.$strip>;
998
+ response: z.ZodObject<{
999
+ agent: z.ZodNullable<z.ZodObject<{
1000
+ agentId: z.ZodString;
1001
+ adapterId: z.ZodString;
1002
+ adapterName: z.ZodString;
1003
+ sessionId: z.ZodString;
1004
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1005
+ model: z.ZodOptional<z.ZodString>;
1006
+ cwd: z.ZodOptional<z.ZodString>;
1007
+ providerConfigId: z.ZodOptional<z.ZodString>;
1008
+ personaId: z.ZodOptional<z.ZodString>;
1009
+ profileId: z.ZodOptional<z.ZodString>;
1010
+ harnessId: z.ZodOptional<z.ZodString>;
1011
+ clientId: z.ZodOptional<z.ZodString>;
1012
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1013
+ auto: "auto";
1014
+ manual: "manual";
1015
+ off: "off";
1016
+ }>>;
1017
+ role: z.ZodEnum<{
1018
+ lead: "lead";
1019
+ member: "member";
1020
+ }>;
1021
+ status: z.ZodEnum<{
1022
+ active: "active";
1023
+ idle: "idle";
1024
+ dead: "dead";
1025
+ disposed: "disposed";
1026
+ }>;
1027
+ createdAt: z.ZodNumber;
1028
+ lastActivityAt: z.ZodNumber;
1029
+ }, z.core.$strip>>;
1030
+ }, z.core.$strip>;
1031
+ };
1032
+ /**
1033
+ * Store or update an agent.
1034
+ *
1035
+ * Subject: `storage:agent.set`
1036
+ * Type: Request (RPC)
1037
+ */
1038
+ set: {
1039
+ request: z.ZodObject<{
1040
+ agentId: z.ZodString;
1041
+ agent: z.ZodObject<{
1042
+ agentId: z.ZodString;
1043
+ adapterId: z.ZodString;
1044
+ adapterName: z.ZodString;
1045
+ sessionId: z.ZodString;
1046
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1047
+ model: z.ZodOptional<z.ZodString>;
1048
+ cwd: z.ZodOptional<z.ZodString>;
1049
+ providerConfigId: z.ZodOptional<z.ZodString>;
1050
+ personaId: z.ZodOptional<z.ZodString>;
1051
+ profileId: z.ZodOptional<z.ZodString>;
1052
+ harnessId: z.ZodOptional<z.ZodString>;
1053
+ clientId: z.ZodOptional<z.ZodString>;
1054
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1055
+ auto: "auto";
1056
+ manual: "manual";
1057
+ off: "off";
1058
+ }>>;
1059
+ role: z.ZodEnum<{
1060
+ lead: "lead";
1061
+ member: "member";
1062
+ }>;
1063
+ status: z.ZodEnum<{
1064
+ active: "active";
1065
+ idle: "idle";
1066
+ dead: "dead";
1067
+ disposed: "disposed";
1068
+ }>;
1069
+ createdAt: z.ZodNumber;
1070
+ lastActivityAt: z.ZodNumber;
1071
+ }, z.core.$strip>;
1072
+ }, z.core.$strip>;
1073
+ response: z.ZodObject<{
1074
+ success: z.ZodBoolean;
1075
+ }, z.core.$strip>;
1076
+ };
1077
+ /**
1078
+ * Delete an agent by ID.
1079
+ *
1080
+ * Subject: `storage:agent.delete`
1081
+ * Type: Request (RPC)
1082
+ */
1083
+ delete: {
1084
+ request: z.ZodObject<{
1085
+ agentId: z.ZodString;
1086
+ }, z.core.$strip>;
1087
+ response: z.ZodObject<{
1088
+ success: z.ZodBoolean;
1089
+ }, z.core.$strip>;
1090
+ };
1091
+ /**
1092
+ * List agents by adapter name with optional status filter.
1093
+ *
1094
+ * Subject: `storage:agent.listByAdapter`
1095
+ * Type: Request (RPC)
1096
+ */
1097
+ listByAdapter: {
1098
+ request: z.ZodObject<{
1099
+ adapterName: z.ZodString;
1100
+ status: z.ZodOptional<z.ZodEnum<{
1101
+ all: "all";
1102
+ active: "active";
1103
+ idle: "idle";
1104
+ dead: "dead";
1105
+ disposed: "disposed";
1106
+ }>>;
1107
+ }, z.core.$strip>;
1108
+ response: z.ZodObject<{
1109
+ agents: z.ZodArray<z.ZodObject<{
1110
+ agentId: z.ZodString;
1111
+ adapterId: z.ZodString;
1112
+ adapterName: z.ZodString;
1113
+ sessionId: z.ZodString;
1114
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1115
+ model: z.ZodOptional<z.ZodString>;
1116
+ cwd: z.ZodOptional<z.ZodString>;
1117
+ providerConfigId: z.ZodOptional<z.ZodString>;
1118
+ personaId: z.ZodOptional<z.ZodString>;
1119
+ profileId: z.ZodOptional<z.ZodString>;
1120
+ harnessId: z.ZodOptional<z.ZodString>;
1121
+ clientId: z.ZodOptional<z.ZodString>;
1122
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1123
+ auto: "auto";
1124
+ manual: "manual";
1125
+ off: "off";
1126
+ }>>;
1127
+ role: z.ZodEnum<{
1128
+ lead: "lead";
1129
+ member: "member";
1130
+ }>;
1131
+ status: z.ZodEnum<{
1132
+ active: "active";
1133
+ idle: "idle";
1134
+ dead: "dead";
1135
+ disposed: "disposed";
1136
+ }>;
1137
+ createdAt: z.ZodNumber;
1138
+ lastActivityAt: z.ZodNumber;
1139
+ }, z.core.$strip>>;
1140
+ }, z.core.$strip>;
1141
+ };
1142
+ /**
1143
+ * List agents by session ID.
1144
+ *
1145
+ * Subject: `storage:agent.listBySession`
1146
+ * Type: Request (RPC)
1147
+ */
1148
+ listBySession: {
1149
+ request: z.ZodObject<{
1150
+ sessionId: z.ZodString;
1151
+ }, z.core.$strip>;
1152
+ response: z.ZodObject<{
1153
+ agents: z.ZodArray<z.ZodObject<{
1154
+ agentId: z.ZodString;
1155
+ adapterId: z.ZodString;
1156
+ adapterName: z.ZodString;
1157
+ sessionId: z.ZodString;
1158
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1159
+ model: z.ZodOptional<z.ZodString>;
1160
+ cwd: z.ZodOptional<z.ZodString>;
1161
+ providerConfigId: z.ZodOptional<z.ZodString>;
1162
+ personaId: z.ZodOptional<z.ZodString>;
1163
+ profileId: z.ZodOptional<z.ZodString>;
1164
+ harnessId: z.ZodOptional<z.ZodString>;
1165
+ clientId: z.ZodOptional<z.ZodString>;
1166
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1167
+ auto: "auto";
1168
+ manual: "manual";
1169
+ off: "off";
1170
+ }>>;
1171
+ role: z.ZodEnum<{
1172
+ lead: "lead";
1173
+ member: "member";
1174
+ }>;
1175
+ status: z.ZodEnum<{
1176
+ active: "active";
1177
+ idle: "idle";
1178
+ dead: "dead";
1179
+ disposed: "disposed";
1180
+ }>;
1181
+ createdAt: z.ZodNumber;
1182
+ lastActivityAt: z.ZodNumber;
1183
+ }, z.core.$strip>>;
1184
+ }, z.core.$strip>;
1185
+ };
1186
+ /**
1187
+ * Update agent status.
1188
+ *
1189
+ * Subject: `storage:agent.updateStatus`
1190
+ * Type: Request (RPC)
1191
+ */
1192
+ updateStatus: {
1193
+ request: z.ZodObject<{
1194
+ agentId: z.ZodString;
1195
+ status: z.ZodEnum<{
1196
+ active: "active";
1197
+ idle: "idle";
1198
+ dead: "dead";
1199
+ disposed: "disposed";
1200
+ }>;
1201
+ }, z.core.$strip>;
1202
+ response: z.ZodObject<{
1203
+ success: z.ZodBoolean;
1204
+ }, z.core.$strip>;
1205
+ };
1206
+ /**
1207
+ * Update agent last activity timestamp.
1208
+ *
1209
+ * Subject: `storage:agent.updateActivity`
1210
+ * Type: Request (RPC)
1211
+ */
1212
+ updateActivity: {
1213
+ request: z.ZodObject<{
1214
+ agentId: z.ZodString;
1215
+ lastActivityAt: z.ZodNumber;
1216
+ }, z.core.$strip>;
1217
+ response: z.ZodObject<{
1218
+ success: z.ZodBoolean;
1219
+ }, z.core.$strip>;
1220
+ };
1221
+ /**
1222
+ * Update runtime-mutable agent fields without full record overwrite.
1223
+ *
1224
+ * Subject: `storage:agent.updateRuntime`
1225
+ * Type: Request (RPC)
1226
+ */
1227
+ updateRuntime: {
1228
+ request: z.ZodObject<{
1229
+ agentId: z.ZodString;
1230
+ cwd: z.ZodOptional<z.ZodString>;
1231
+ model: z.ZodOptional<z.ZodString>;
1232
+ providerConfigId: z.ZodOptional<z.ZodString>;
1233
+ }, z.core.$strip>;
1234
+ response: z.ZodObject<{
1235
+ success: z.ZodBoolean;
1236
+ }, z.core.$strip>;
1237
+ };
1238
+ }, {
1239
+ drizzle: {
1240
+ agents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
1241
+ name: "agents";
1242
+ schema: undefined;
1243
+ columns: {
1244
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1245
+ name: "agent_id";
1246
+ tableName: "agents";
1247
+ dataType: "string";
1248
+ columnType: "SQLiteText";
1249
+ data: string;
1250
+ driverParam: string;
1251
+ notNull: true;
1252
+ hasDefault: false;
1253
+ isPrimaryKey: true;
1254
+ isAutoincrement: false;
1255
+ hasRuntimeDefault: false;
1256
+ enumValues: [string, ...string[]];
1257
+ baseColumn: never;
1258
+ identity: undefined;
1259
+ generated: undefined;
1260
+ }, {}, {
1261
+ length: number | undefined;
1262
+ }>;
1263
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1264
+ name: "adapter_id";
1265
+ tableName: "agents";
1266
+ dataType: "string";
1267
+ columnType: "SQLiteText";
1268
+ data: string;
1269
+ driverParam: string;
1270
+ notNull: true;
1271
+ hasDefault: false;
1272
+ isPrimaryKey: false;
1273
+ isAutoincrement: false;
1274
+ hasRuntimeDefault: false;
1275
+ enumValues: [string, ...string[]];
1276
+ baseColumn: never;
1277
+ identity: undefined;
1278
+ generated: undefined;
1279
+ }, {}, {
1280
+ length: number | undefined;
1281
+ }>;
1282
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1283
+ name: "adapter_name";
1284
+ tableName: "agents";
1285
+ dataType: "string";
1286
+ columnType: "SQLiteText";
1287
+ data: string;
1288
+ driverParam: string;
1289
+ notNull: true;
1290
+ hasDefault: false;
1291
+ isPrimaryKey: false;
1292
+ isAutoincrement: false;
1293
+ hasRuntimeDefault: false;
1294
+ enumValues: [string, ...string[]];
1295
+ baseColumn: never;
1296
+ identity: undefined;
1297
+ generated: undefined;
1298
+ }, {}, {
1299
+ length: number | undefined;
1300
+ }>;
1301
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1302
+ name: "session_id";
1303
+ tableName: "agents";
1304
+ dataType: "string";
1305
+ columnType: "SQLiteText";
1306
+ data: string;
1307
+ driverParam: string;
1308
+ notNull: true;
1309
+ hasDefault: false;
1310
+ isPrimaryKey: false;
1311
+ isAutoincrement: false;
1312
+ hasRuntimeDefault: false;
1313
+ enumValues: [string, ...string[]];
1314
+ baseColumn: never;
1315
+ identity: undefined;
1316
+ generated: undefined;
1317
+ }, {}, {
1318
+ length: number | undefined;
1319
+ }>;
1320
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1321
+ name: "adapter_session_id";
1322
+ tableName: "agents";
1323
+ dataType: "string";
1324
+ columnType: "SQLiteText";
1325
+ data: string;
1326
+ driverParam: string;
1327
+ notNull: false;
1328
+ hasDefault: false;
1329
+ isPrimaryKey: false;
1330
+ isAutoincrement: false;
1331
+ hasRuntimeDefault: false;
1332
+ enumValues: [string, ...string[]];
1333
+ baseColumn: never;
1334
+ identity: undefined;
1335
+ generated: undefined;
1336
+ }, {}, {
1337
+ length: number | undefined;
1338
+ }>;
1339
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1340
+ name: "model";
1341
+ tableName: "agents";
1342
+ dataType: "string";
1343
+ columnType: "SQLiteText";
1344
+ data: string;
1345
+ driverParam: string;
1346
+ notNull: false;
1347
+ hasDefault: false;
1348
+ isPrimaryKey: false;
1349
+ isAutoincrement: false;
1350
+ hasRuntimeDefault: false;
1351
+ enumValues: [string, ...string[]];
1352
+ baseColumn: never;
1353
+ identity: undefined;
1354
+ generated: undefined;
1355
+ }, {}, {
1356
+ length: number | undefined;
1357
+ }>;
1358
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1359
+ name: "cwd";
1360
+ tableName: "agents";
1361
+ dataType: "string";
1362
+ columnType: "SQLiteText";
1363
+ data: string;
1364
+ driverParam: string;
1365
+ notNull: false;
1366
+ hasDefault: false;
1367
+ isPrimaryKey: false;
1368
+ isAutoincrement: false;
1369
+ hasRuntimeDefault: false;
1370
+ enumValues: [string, ...string[]];
1371
+ baseColumn: never;
1372
+ identity: undefined;
1373
+ generated: undefined;
1374
+ }, {}, {
1375
+ length: number | undefined;
1376
+ }>;
1377
+ providerConfigId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1378
+ name: "provider_config_id";
1379
+ tableName: "agents";
1380
+ dataType: "string";
1381
+ columnType: "SQLiteText";
1382
+ data: string;
1383
+ driverParam: string;
1384
+ notNull: false;
1385
+ hasDefault: false;
1386
+ isPrimaryKey: false;
1387
+ isAutoincrement: false;
1388
+ hasRuntimeDefault: false;
1389
+ enumValues: [string, ...string[]];
1390
+ baseColumn: never;
1391
+ identity: undefined;
1392
+ generated: undefined;
1393
+ }, {}, {
1394
+ length: number | undefined;
1395
+ }>;
1396
+ personaId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1397
+ name: "persona_id";
1398
+ tableName: "agents";
1399
+ dataType: "string";
1400
+ columnType: "SQLiteText";
1401
+ data: string;
1402
+ driverParam: string;
1403
+ notNull: false;
1404
+ hasDefault: false;
1405
+ isPrimaryKey: false;
1406
+ isAutoincrement: false;
1407
+ hasRuntimeDefault: false;
1408
+ enumValues: [string, ...string[]];
1409
+ baseColumn: never;
1410
+ identity: undefined;
1411
+ generated: undefined;
1412
+ }, {}, {
1413
+ length: number | undefined;
1414
+ }>;
1415
+ profileId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1416
+ name: "profile_id";
1417
+ tableName: "agents";
1418
+ dataType: "string";
1419
+ columnType: "SQLiteText";
1420
+ data: string;
1421
+ driverParam: string;
1422
+ notNull: false;
1423
+ hasDefault: false;
1424
+ isPrimaryKey: false;
1425
+ isAutoincrement: false;
1426
+ hasRuntimeDefault: false;
1427
+ enumValues: [string, ...string[]];
1428
+ baseColumn: never;
1429
+ identity: undefined;
1430
+ generated: undefined;
1431
+ }, {}, {
1432
+ length: number | undefined;
1433
+ }>;
1434
+ harnessId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1435
+ name: "harness_id";
1436
+ tableName: "agents";
1437
+ dataType: "string";
1438
+ columnType: "SQLiteText";
1439
+ data: string;
1440
+ driverParam: string;
1441
+ notNull: false;
1442
+ hasDefault: false;
1443
+ isPrimaryKey: false;
1444
+ isAutoincrement: false;
1445
+ hasRuntimeDefault: false;
1446
+ enumValues: [string, ...string[]];
1447
+ baseColumn: never;
1448
+ identity: undefined;
1449
+ generated: undefined;
1450
+ }, {}, {
1451
+ length: number | undefined;
1452
+ }>;
1453
+ clientId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1454
+ name: "client_id";
1455
+ tableName: "agents";
1456
+ dataType: "string";
1457
+ columnType: "SQLiteText";
1458
+ data: string;
1459
+ driverParam: string;
1460
+ notNull: false;
1461
+ hasDefault: false;
1462
+ isPrimaryKey: false;
1463
+ isAutoincrement: false;
1464
+ hasRuntimeDefault: false;
1465
+ enumValues: [string, ...string[]];
1466
+ baseColumn: never;
1467
+ identity: undefined;
1468
+ generated: undefined;
1469
+ }, {}, {
1470
+ length: number | undefined;
1471
+ }>;
1472
+ compressionMode: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1473
+ name: "compression_mode";
1474
+ tableName: "agents";
1475
+ dataType: "string";
1476
+ columnType: "SQLiteText";
1477
+ data: string;
1478
+ driverParam: string;
1479
+ notNull: false;
1480
+ hasDefault: false;
1481
+ isPrimaryKey: false;
1482
+ isAutoincrement: false;
1483
+ hasRuntimeDefault: false;
1484
+ enumValues: [string, ...string[]];
1485
+ baseColumn: never;
1486
+ identity: undefined;
1487
+ generated: undefined;
1488
+ }, {}, {
1489
+ length: number | undefined;
1490
+ }>;
1491
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1492
+ name: "role";
1493
+ tableName: "agents";
1494
+ dataType: "string";
1495
+ columnType: "SQLiteText";
1496
+ data: "lead" | "member";
1497
+ driverParam: string;
1498
+ notNull: true;
1499
+ hasDefault: false;
1500
+ isPrimaryKey: false;
1501
+ isAutoincrement: false;
1502
+ hasRuntimeDefault: false;
1503
+ enumValues: ["lead", "member"];
1504
+ baseColumn: never;
1505
+ identity: undefined;
1506
+ generated: undefined;
1507
+ }, {}, {
1508
+ length: number | undefined;
1509
+ }>;
1510
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1511
+ name: "status";
1512
+ tableName: "agents";
1513
+ dataType: "string";
1514
+ columnType: "SQLiteText";
1515
+ data: "active" | "idle" | "dead" | "disposed";
1516
+ driverParam: string;
1517
+ notNull: true;
1518
+ hasDefault: false;
1519
+ isPrimaryKey: false;
1520
+ isAutoincrement: false;
1521
+ hasRuntimeDefault: false;
1522
+ enumValues: ["idle", "active", "dead", "disposed"];
1523
+ baseColumn: never;
1524
+ identity: undefined;
1525
+ generated: undefined;
1526
+ }, {}, {
1527
+ length: number | undefined;
1528
+ }>;
1529
+ createdAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1530
+ name: "created_at";
1531
+ tableName: "agents";
1532
+ dataType: "number";
1533
+ columnType: "SQLiteInteger";
1534
+ data: number;
1535
+ driverParam: number;
1536
+ notNull: true;
1537
+ hasDefault: false;
1538
+ isPrimaryKey: false;
1539
+ isAutoincrement: false;
1540
+ hasRuntimeDefault: false;
1541
+ enumValues: undefined;
1542
+ baseColumn: never;
1543
+ identity: undefined;
1544
+ generated: undefined;
1545
+ }, {}, {}>;
1546
+ lastActivityAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
1547
+ name: "last_activity_at";
1548
+ tableName: "agents";
1549
+ dataType: "number";
1550
+ columnType: "SQLiteInteger";
1551
+ data: number;
1552
+ driverParam: number;
1553
+ notNull: true;
1554
+ hasDefault: false;
1555
+ isPrimaryKey: false;
1556
+ isAutoincrement: false;
1557
+ hasRuntimeDefault: false;
1558
+ enumValues: undefined;
1559
+ baseColumn: never;
1560
+ identity: undefined;
1561
+ generated: undefined;
1562
+ }, {}, {}>;
1563
+ };
1564
+ dialect: "sqlite";
1565
+ }>;
1566
+ };
1567
+ }>;
1568
+ /**
1569
+ * Typed subjects for agent storage operations.
1570
+ */
1571
+ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"storage:agent", {
1572
+ /**
1573
+ * Get an agent by ID.
1574
+ *
1575
+ * Subject: `storage:agent.get`
1576
+ * Type: Request (RPC)
1577
+ */
1578
+ get: {
1579
+ request: z.ZodObject<{
1580
+ agentId: z.ZodString;
1581
+ }, z.core.$strip>;
1582
+ response: z.ZodObject<{
1583
+ agent: z.ZodNullable<z.ZodObject<{
1584
+ agentId: z.ZodString;
1585
+ adapterId: z.ZodString;
1586
+ adapterName: z.ZodString;
1587
+ sessionId: z.ZodString;
1588
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1589
+ model: z.ZodOptional<z.ZodString>;
1590
+ cwd: z.ZodOptional<z.ZodString>;
1591
+ providerConfigId: z.ZodOptional<z.ZodString>;
1592
+ personaId: z.ZodOptional<z.ZodString>;
1593
+ profileId: z.ZodOptional<z.ZodString>;
1594
+ harnessId: z.ZodOptional<z.ZodString>;
1595
+ clientId: z.ZodOptional<z.ZodString>;
1596
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1597
+ auto: "auto";
1598
+ manual: "manual";
1599
+ off: "off";
1600
+ }>>;
1601
+ role: z.ZodEnum<{
1602
+ lead: "lead";
1603
+ member: "member";
1604
+ }>;
1605
+ status: z.ZodEnum<{
1606
+ active: "active";
1607
+ idle: "idle";
1608
+ dead: "dead";
1609
+ disposed: "disposed";
1610
+ }>;
1611
+ createdAt: z.ZodNumber;
1612
+ lastActivityAt: z.ZodNumber;
1613
+ }, z.core.$strip>>;
1614
+ }, z.core.$strip>;
1615
+ };
1616
+ /**
1617
+ * Store or update an agent.
1618
+ *
1619
+ * Subject: `storage:agent.set`
1620
+ * Type: Request (RPC)
1621
+ */
1622
+ set: {
1623
+ request: z.ZodObject<{
1624
+ agentId: z.ZodString;
1625
+ agent: z.ZodObject<{
1626
+ agentId: z.ZodString;
1627
+ adapterId: z.ZodString;
1628
+ adapterName: z.ZodString;
1629
+ sessionId: z.ZodString;
1630
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1631
+ model: z.ZodOptional<z.ZodString>;
1632
+ cwd: z.ZodOptional<z.ZodString>;
1633
+ providerConfigId: z.ZodOptional<z.ZodString>;
1634
+ personaId: z.ZodOptional<z.ZodString>;
1635
+ profileId: z.ZodOptional<z.ZodString>;
1636
+ harnessId: z.ZodOptional<z.ZodString>;
1637
+ clientId: z.ZodOptional<z.ZodString>;
1638
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1639
+ auto: "auto";
1640
+ manual: "manual";
1641
+ off: "off";
1642
+ }>>;
1643
+ role: z.ZodEnum<{
1644
+ lead: "lead";
1645
+ member: "member";
1646
+ }>;
1647
+ status: z.ZodEnum<{
1648
+ active: "active";
1649
+ idle: "idle";
1650
+ dead: "dead";
1651
+ disposed: "disposed";
1652
+ }>;
1653
+ createdAt: z.ZodNumber;
1654
+ lastActivityAt: z.ZodNumber;
1655
+ }, z.core.$strip>;
1656
+ }, z.core.$strip>;
1657
+ response: z.ZodObject<{
1658
+ success: z.ZodBoolean;
1659
+ }, z.core.$strip>;
1660
+ };
1661
+ /**
1662
+ * Delete an agent by ID.
1663
+ *
1664
+ * Subject: `storage:agent.delete`
1665
+ * Type: Request (RPC)
1666
+ */
1667
+ delete: {
1668
+ request: z.ZodObject<{
1669
+ agentId: z.ZodString;
1670
+ }, z.core.$strip>;
1671
+ response: z.ZodObject<{
1672
+ success: z.ZodBoolean;
1673
+ }, z.core.$strip>;
1674
+ };
1675
+ /**
1676
+ * List agents by adapter name with optional status filter.
1677
+ *
1678
+ * Subject: `storage:agent.listByAdapter`
1679
+ * Type: Request (RPC)
1680
+ */
1681
+ listByAdapter: {
1682
+ request: z.ZodObject<{
1683
+ adapterName: z.ZodString;
1684
+ status: z.ZodOptional<z.ZodEnum<{
1685
+ all: "all";
1686
+ active: "active";
1687
+ idle: "idle";
1688
+ dead: "dead";
1689
+ disposed: "disposed";
1690
+ }>>;
1691
+ }, z.core.$strip>;
1692
+ response: z.ZodObject<{
1693
+ agents: z.ZodArray<z.ZodObject<{
1694
+ agentId: z.ZodString;
1695
+ adapterId: z.ZodString;
1696
+ adapterName: z.ZodString;
1697
+ sessionId: z.ZodString;
1698
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1699
+ model: z.ZodOptional<z.ZodString>;
1700
+ cwd: z.ZodOptional<z.ZodString>;
1701
+ providerConfigId: z.ZodOptional<z.ZodString>;
1702
+ personaId: z.ZodOptional<z.ZodString>;
1703
+ profileId: z.ZodOptional<z.ZodString>;
1704
+ harnessId: z.ZodOptional<z.ZodString>;
1705
+ clientId: z.ZodOptional<z.ZodString>;
1706
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1707
+ auto: "auto";
1708
+ manual: "manual";
1709
+ off: "off";
1710
+ }>>;
1711
+ role: z.ZodEnum<{
1712
+ lead: "lead";
1713
+ member: "member";
1714
+ }>;
1715
+ status: z.ZodEnum<{
1716
+ active: "active";
1717
+ idle: "idle";
1718
+ dead: "dead";
1719
+ disposed: "disposed";
1720
+ }>;
1721
+ createdAt: z.ZodNumber;
1722
+ lastActivityAt: z.ZodNumber;
1723
+ }, z.core.$strip>>;
1724
+ }, z.core.$strip>;
1725
+ };
1726
+ /**
1727
+ * List agents by session ID.
1728
+ *
1729
+ * Subject: `storage:agent.listBySession`
1730
+ * Type: Request (RPC)
1731
+ */
1732
+ listBySession: {
1733
+ request: z.ZodObject<{
1734
+ sessionId: z.ZodString;
1735
+ }, z.core.$strip>;
1736
+ response: z.ZodObject<{
1737
+ agents: z.ZodArray<z.ZodObject<{
1738
+ agentId: z.ZodString;
1739
+ adapterId: z.ZodString;
1740
+ adapterName: z.ZodString;
1741
+ sessionId: z.ZodString;
1742
+ adapterSessionId: z.ZodOptional<z.ZodString>;
1743
+ model: z.ZodOptional<z.ZodString>;
1744
+ cwd: z.ZodOptional<z.ZodString>;
1745
+ providerConfigId: z.ZodOptional<z.ZodString>;
1746
+ personaId: z.ZodOptional<z.ZodString>;
1747
+ profileId: z.ZodOptional<z.ZodString>;
1748
+ harnessId: z.ZodOptional<z.ZodString>;
1749
+ clientId: z.ZodOptional<z.ZodString>;
1750
+ compressionMode: z.ZodOptional<z.ZodEnum<{
1751
+ auto: "auto";
1752
+ manual: "manual";
1753
+ off: "off";
1754
+ }>>;
1755
+ role: z.ZodEnum<{
1756
+ lead: "lead";
1757
+ member: "member";
1758
+ }>;
1759
+ status: z.ZodEnum<{
1760
+ active: "active";
1761
+ idle: "idle";
1762
+ dead: "dead";
1763
+ disposed: "disposed";
1764
+ }>;
1765
+ createdAt: z.ZodNumber;
1766
+ lastActivityAt: z.ZodNumber;
1767
+ }, z.core.$strip>>;
1768
+ }, z.core.$strip>;
1769
+ };
1770
+ /**
1771
+ * Update agent status.
1772
+ *
1773
+ * Subject: `storage:agent.updateStatus`
1774
+ * Type: Request (RPC)
1775
+ */
1776
+ updateStatus: {
1777
+ request: z.ZodObject<{
1778
+ agentId: z.ZodString;
1779
+ status: z.ZodEnum<{
1780
+ active: "active";
1781
+ idle: "idle";
1782
+ dead: "dead";
1783
+ disposed: "disposed";
1784
+ }>;
1785
+ }, z.core.$strip>;
1786
+ response: z.ZodObject<{
1787
+ success: z.ZodBoolean;
1788
+ }, z.core.$strip>;
1789
+ };
1790
+ /**
1791
+ * Update agent last activity timestamp.
1792
+ *
1793
+ * Subject: `storage:agent.updateActivity`
1794
+ * Type: Request (RPC)
1795
+ */
1796
+ updateActivity: {
1797
+ request: z.ZodObject<{
1798
+ agentId: z.ZodString;
1799
+ lastActivityAt: z.ZodNumber;
1800
+ }, z.core.$strip>;
1801
+ response: z.ZodObject<{
1802
+ success: z.ZodBoolean;
1803
+ }, z.core.$strip>;
1804
+ };
1805
+ /**
1806
+ * Update runtime-mutable agent fields without full record overwrite.
1807
+ *
1808
+ * Subject: `storage:agent.updateRuntime`
1809
+ * Type: Request (RPC)
1810
+ */
1811
+ updateRuntime: {
1812
+ request: z.ZodObject<{
1813
+ agentId: z.ZodString;
1814
+ cwd: z.ZodOptional<z.ZodString>;
1815
+ model: z.ZodOptional<z.ZodString>;
1816
+ providerConfigId: z.ZodOptional<z.ZodString>;
1817
+ }, z.core.$strip>;
1818
+ response: z.ZodObject<{
1819
+ success: z.ZodBoolean;
1820
+ }, z.core.$strip>;
1821
+ };
1822
+ }>, "storage:agent">;
1823
+ //#endregion
1824
+ //#region packages/services/core/src/session/storage/memory-handler.d.ts
1825
+ /**
1826
+ * Register in-memory session storage handlers.
1827
+ *
1828
+ * Suitable for development, testing, and single-instance deployments.
1829
+ * Data is lost when the process exits.
1830
+ * @param bus - The bus instance to register handlers on
1831
+ * @returns Cleanup function to unsubscribe all handlers
1832
+ * @example
1833
+ * ```typescript
1834
+ * import { registerMemorySessionStorage } from '@makaio/framework/services/session';
1835
+ *
1836
+ * const cleanup = registerMemorySessionStorage(bus);
1837
+ *
1838
+ * // Later, when shutting down:
1839
+ * cleanup();
1840
+ * ```
1841
+ */
1842
+ declare function registerMemorySessionStorage(bus: IMakaioBus): () => void;
1843
+ //#endregion
1844
+ //#region packages/services/core/src/session/storage/drizzle-handler.d.ts
1845
+ /**
1846
+ * Register Drizzle-based session storage handlers.
1847
+ *
1848
+ * Persists sessions to SQLite/libSQL via Drizzle ORM.
1849
+ * Provides durable storage suitable for production deployments.
1850
+ *
1851
+ * CONCURRENCY INVARIANT: All handlers must use single-statement operations only.
1852
+ * Storage handlers share a single DB connection. Fire-and-forget bus events
1853
+ * (e.g., agent.added) race with sequential RPC handlers (e.g., turn.create).
1854
+ * db.transaction() holds write locks across await boundaries, causing SQLITE_BUSY
1855
+ * deadlocks on the same connection. Single statements serialize automatically
1856
+ * via SQLite's busy_timeout + WAL mode.
1857
+ * @param bus - The bus instance to register handlers on
1858
+ * @param db - The Drizzle database instance (any libSQL database)
1859
+ * @param _ctx - Extension context (unused; reserved for future use)
1860
+ * @returns Cleanup function to unsubscribe all handlers
1861
+ * @example
1862
+ * ```typescript
1863
+ * import { registerDrizzleSessionStorage } from '@makaio/framework/services/session';
1864
+ * import { drizzle } from 'drizzle-orm/libsql';
1865
+ * import { createClient } from '@libsql/client';
1866
+ *
1867
+ * const client = createClient({ url: 'file:./makaio.db' });
1868
+ * const db = drizzle(client);
1869
+ * const cleanup = registerDrizzleSessionStorage(bus, db, ctx);
1870
+ *
1871
+ * // Later, when shutting down:
1872
+ * cleanup();
1873
+ * ```
1874
+ */
1875
+ declare function registerDrizzleSessionStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
1876
+ //#endregion
1877
+ //#region packages/services/core/src/session/storage/agent-memory-handler.d.ts
1878
+ /**
1879
+ * Register in-memory agent storage handlers.
1880
+ *
1881
+ * Suitable for development and testing. Data is lost when the process exits.
1882
+ * @param bus - The bus instance to register handlers on
1883
+ * @returns Cleanup function to unsubscribe all handlers
1884
+ */
1885
+ declare function registerMemoryAgentStorage(bus: IMakaioBus): () => void;
1886
+ //#endregion
1887
+ //#region packages/services/core/src/session/storage/agent-drizzle-handler.d.ts
1888
+ /**
1889
+ * Register Drizzle-based agent storage handlers.
1890
+ *
1891
+ * Persists agents to SQLite/libSQL via Drizzle ORM.
1892
+ * Provides durable storage suitable for production deployments.
1893
+ * @param bus - The bus instance to register handlers on
1894
+ * @param db - The MakaioDatabase instance
1895
+ * @param _ctx - Extension context (unused; reserved for future use)
1896
+ * @returns Cleanup function to unsubscribe all handlers
1897
+ * @example
1898
+ * ```typescript
1899
+ * import { registerDrizzleAgentStorage } from '@makaio/framework/services/session';
1900
+ * import { drizzle } from 'drizzle-orm/libsql';
1901
+ * import { createClient } from '@libsql/client';
1902
+ *
1903
+ * const client = createClient({ url: 'file:./makaio.db' });
1904
+ * const db = drizzle(client);
1905
+ * const cleanup = registerDrizzleAgentStorage(bus, db, ctx);
1906
+ *
1907
+ * // Later, when shutting down:
1908
+ * cleanup();
1909
+ * ```
1910
+ */
1911
+ declare function registerDrizzleAgentStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
1912
+ //#endregion
1913
+ //#region packages/services/core/src/session/storage/fts-search-handler.d.ts
1914
+ /**
1915
+ * Registers FTS-backed `storage:session.search` handler.
1916
+ * @param bus - Bus instance used for handler registration
1917
+ * @param db - Drizzle database instance
1918
+ * @returns Cleanup function that unregisters the search handler
1919
+ */
1920
+ declare function registerFtsSearchHandler(bus: IMakaioBus, db: MakaioDatabase): () => void;
1921
+ //#endregion
1922
+ //#region packages/services/core/src/session/storage/fts-search-utils.d.ts
1923
+ /**
1924
+ * Row shape returned by FTS session search queries.
1925
+ *
1926
+ * Contains only framework-owned columns. Scope fields (`project_id`,
1927
+ * `worktree_id`, `workstream_id`) are intentionally absent — they are
1928
+ * managed by the host-owned junction table after the sealed-sessions
1929
+ * refactor.
1930
+ */
1931
+ interface SearchSessionRow {
1932
+ session_id: string;
1933
+ created_at: number;
1934
+ last_activity_at: number;
1935
+ status: IMakaioSession['status'];
1936
+ title: string | null;
1937
+ lead_agent_id: string | null;
1938
+ parent_session_id: string | null;
1939
+ root_session_id: string | null;
1940
+ fork_point_message_id: string | null;
1941
+ branch_kind: IMakaioSession['branchKind'] | null;
1942
+ adapter_name: string | null;
1943
+ adapter_session_id: string | null;
1944
+ adapter_id: string | null;
1945
+ is_orchestrated: number | null;
1946
+ is_imported: number | null;
1947
+ summary: string | null;
1948
+ summary_updated_at: number | null;
1949
+ fork_transforms: string | null;
1950
+ target_working_directory: string | null;
1951
+ }
1952
+ /**
1953
+ * Filter parameters accepted by FTS search queries.
1954
+ *
1955
+ * Scope filters (`projectId`, `worktreeId`) are intentionally absent —
1956
+ * scope-aware filtering is the responsibility of host priority-100
1957
+ * handlers that JOIN with the `session_scopes` junction table.
1958
+ */
1959
+ interface SearchFilters {
1960
+ status: IMakaioSession['status'] | 'all';
1961
+ isImported?: boolean;
1962
+ }
1963
+ /**
1964
+ * Loads agent rows and groups them by session ID.
1965
+ * @param db - Drizzle database instance
1966
+ * @param sessionIds - Matched session IDs
1967
+ * @returns Agent rows keyed by session ID
1968
+ */
1969
+ declare function fetchAgentsBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, Array<typeof agents.$inferSelect>>>;
1970
+ /**
1971
+ * Resolves first-user-message previews for matched sessions.
1972
+ * @param db - Drizzle database instance
1973
+ * @param sessionIds - Matched session IDs
1974
+ * @returns First user message text keyed by session ID
1975
+ */
1976
+ declare function fetchPreviewBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, string | null>>;
1977
+ /**
1978
+ * Counts messages per matched session.
1979
+ * @param db - Drizzle database instance
1980
+ * @param sessionIds - Matched session IDs
1981
+ * @returns Message counts keyed by session ID
1982
+ */
1983
+ declare function fetchMessageCountsBySession(db: MakaioDatabase, sessionIds: string[]): Promise<Map<string, number>>;
1984
+ /**
1985
+ * Parses serialized fork transform JSON.
1986
+ * @param raw - Raw JSON column value
1987
+ * @returns Parsed fork transforms, or undefined on invalid JSON
1988
+ */
1989
+ declare function parseForkTransforms(raw: string | null): ForkTransforms | undefined;
1990
+ /**
1991
+ * Maps a raw search row to session API format with preview metadata.
1992
+ *
1993
+ * Scope fields are intentionally absent from the returned `IMakaioSession`.
1994
+ * Host handlers composing a scoped search must augment the result with
1995
+ * scope data read from the junction table after calling this utility.
1996
+ * @param row - Raw session row from SQL search query
1997
+ * @param sessionAgents - Agents attached to the session
1998
+ * @param previewBySession - First-user-message map
1999
+ * @param countBySession - Message count map
2000
+ * @returns Session payload with preview block
2001
+ */
2002
+ declare function mapRowToSession(row: SearchSessionRow, sessionAgents: Array<typeof agents.$inferSelect>, previewBySession: Map<string, string | null>, countBySession: Map<string, number>): IMakaioSession & {
2003
+ preview: {
2004
+ messageCount: number;
2005
+ firstUserMessage: string | null;
2006
+ };
2007
+ };
2008
+ //#endregion
2009
+ //#region packages/services/core/src/session/storage/drizzle-utils.d.ts
2010
+ type SessionRow = typeof sessions.$inferSelect;
2011
+ type AgentRow = typeof agents.$inferSelect;
2012
+ /**
2013
+ * Preview maps for session list response hydration.
2014
+ */
2015
+ interface SessionPreviewMaps {
2016
+ previewBySession?: Map<string, string | null>;
2017
+ countBySession?: Map<string, number>;
2018
+ }
2019
+ /**
2020
+ * Map a Drizzle session row to the `IMakaioSession` API type.
2021
+ *
2022
+ * Scope fields (`projectId`, `worktreeId`, `workstreamId`) are intentionally
2023
+ * absent from the returned object. They are managed by the host-owned
2024
+ * junction table after the sealed-sessions refactor. Host handlers
2025
+ * composing a scoped query must augment the result with scope data read
2026
+ * from the junction table.
2027
+ * @param sessionRow - The session table row
2028
+ * @param agentRows - The associated agent rows
2029
+ * @returns The mapped session object
2030
+ */
2031
+ declare function mapToSession(sessionRow: SessionRow, agentRows: AgentRow[]): IMakaioSession;
2032
+ /**
2033
+ * Groups agent rows by session ID for list response hydration.
2034
+ * @param agentRows - Agent table rows
2035
+ * @returns Map keyed by session ID
2036
+ */
2037
+ declare function mapAgentsBySession(agentRows: AgentRow[]): Map<string, AgentRow[]>;
2038
+ /**
2039
+ * Fetches optional preview maps for session list responses.
2040
+ * @param db - Drizzle database client
2041
+ * @param sessionIds - Session IDs in current result page
2042
+ * @param includePreview - Whether preview fields are requested
2043
+ * @returns Preview maps for first user message and message count
2044
+ */
2045
+ declare function fetchSessionPreviewMaps(db: MakaioDatabase, sessionIds: string[], includePreview: boolean): Promise<SessionPreviewMaps>;
2046
+ //#endregion
2047
+ //#region packages/services/core/src/session/session-events/schema.d.ts
2048
+ /**
2049
+ * Session events table schema.
2050
+ *
2051
+ * Stores immutable, append-only session events for unified history reconstruction.
2052
+ * Events are persisted by SessionLogger via storage service.
2053
+ *
2054
+ * **Event Types:**
2055
+ * - Message references (type='message' with messageId FK to messages table)
2056
+ * - Agent lifecycle (agent.added)
2057
+ * - Turn lifecycle (turn.started, turn.completed)
2058
+ * - User message events (user_message.sent/acknowledged/completed)
2059
+ *
2060
+ * Design rationale:
2061
+ * - First-class columns for queryable fields (IDs, timestamp, type)
2062
+ * - `contentText` extracted for FTS5/embeddings (future)
2063
+ * - `payload` stores full JSON for exact API reconstruction
2064
+ *
2065
+ * SEAM: The `sessionId` FK enables cascade delete when sessions are purged.
2066
+ * Future embeddings table can reference `eventId` for vector search.
2067
+ */
2068
+ declare const sessionEvents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2069
+ name: "session_events";
2070
+ schema: undefined;
2071
+ columns: {
2072
+ id: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2073
+ name: "id";
2074
+ tableName: "session_events";
2075
+ dataType: "number";
2076
+ columnType: "SQLiteInteger";
2077
+ data: number;
2078
+ driverParam: number;
2079
+ notNull: true;
2080
+ hasDefault: true;
2081
+ isPrimaryKey: true;
2082
+ isAutoincrement: false;
2083
+ hasRuntimeDefault: false;
2084
+ enumValues: undefined;
2085
+ baseColumn: never;
2086
+ identity: undefined;
2087
+ generated: undefined;
2088
+ }, {}, {}>;
2089
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2090
+ name: "session_id";
2091
+ tableName: "session_events";
2092
+ dataType: "string";
2093
+ columnType: "SQLiteText";
2094
+ data: string;
2095
+ driverParam: string;
2096
+ notNull: true;
2097
+ hasDefault: false;
2098
+ isPrimaryKey: false;
2099
+ isAutoincrement: false;
2100
+ hasRuntimeDefault: false;
2101
+ enumValues: [string, ...string[]];
2102
+ baseColumn: never;
2103
+ identity: undefined;
2104
+ generated: undefined;
2105
+ }, {}, {
2106
+ length: number | undefined;
2107
+ }>;
2108
+ eventId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2109
+ name: "event_id";
2110
+ tableName: "session_events";
2111
+ dataType: "string";
2112
+ columnType: "SQLiteText";
2113
+ data: string;
2114
+ driverParam: string;
2115
+ notNull: true;
2116
+ hasDefault: false;
2117
+ isPrimaryKey: false;
2118
+ isAutoincrement: false;
2119
+ hasRuntimeDefault: false;
2120
+ enumValues: [string, ...string[]];
2121
+ baseColumn: never;
2122
+ identity: undefined;
2123
+ generated: undefined;
2124
+ }, {}, {
2125
+ length: number | undefined;
2126
+ }>;
2127
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2128
+ name: "timestamp";
2129
+ tableName: "session_events";
2130
+ dataType: "number";
2131
+ columnType: "SQLiteInteger";
2132
+ data: number;
2133
+ driverParam: number;
2134
+ notNull: true;
2135
+ hasDefault: false;
2136
+ isPrimaryKey: false;
2137
+ isAutoincrement: false;
2138
+ hasRuntimeDefault: false;
2139
+ enumValues: undefined;
2140
+ baseColumn: never;
2141
+ identity: undefined;
2142
+ generated: undefined;
2143
+ }, {}, {}>;
2144
+ type: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2145
+ name: "type";
2146
+ tableName: "session_events";
2147
+ dataType: "string";
2148
+ columnType: "SQLiteText";
2149
+ data: string;
2150
+ driverParam: string;
2151
+ notNull: true;
2152
+ hasDefault: false;
2153
+ isPrimaryKey: false;
2154
+ isAutoincrement: false;
2155
+ hasRuntimeDefault: false;
2156
+ enumValues: [string, ...string[]];
2157
+ baseColumn: never;
2158
+ identity: undefined;
2159
+ generated: undefined;
2160
+ }, {}, {
2161
+ length: number | undefined;
2162
+ }>;
2163
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2164
+ name: "agent_id";
2165
+ tableName: "session_events";
2166
+ dataType: "string";
2167
+ columnType: "SQLiteText";
2168
+ data: string;
2169
+ driverParam: string;
2170
+ notNull: false;
2171
+ hasDefault: false;
2172
+ isPrimaryKey: false;
2173
+ isAutoincrement: false;
2174
+ hasRuntimeDefault: false;
2175
+ enumValues: [string, ...string[]];
2176
+ baseColumn: never;
2177
+ identity: undefined;
2178
+ generated: undefined;
2179
+ }, {}, {
2180
+ length: number | undefined;
2181
+ }>;
2182
+ adapterId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2183
+ name: "adapter_id";
2184
+ tableName: "session_events";
2185
+ dataType: "string";
2186
+ columnType: "SQLiteText";
2187
+ data: string;
2188
+ driverParam: string;
2189
+ notNull: false;
2190
+ hasDefault: false;
2191
+ isPrimaryKey: false;
2192
+ isAutoincrement: false;
2193
+ hasRuntimeDefault: false;
2194
+ enumValues: [string, ...string[]];
2195
+ baseColumn: never;
2196
+ identity: undefined;
2197
+ generated: undefined;
2198
+ }, {}, {
2199
+ length: number | undefined;
2200
+ }>;
2201
+ originatingMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2202
+ name: "originating_message_id";
2203
+ tableName: "session_events";
2204
+ dataType: "string";
2205
+ columnType: "SQLiteText";
2206
+ data: string;
2207
+ driverParam: string;
2208
+ notNull: false;
2209
+ hasDefault: false;
2210
+ isPrimaryKey: false;
2211
+ isAutoincrement: false;
2212
+ hasRuntimeDefault: false;
2213
+ enumValues: [string, ...string[]];
2214
+ baseColumn: never;
2215
+ identity: undefined;
2216
+ generated: undefined;
2217
+ }, {}, {
2218
+ length: number | undefined;
2219
+ }>;
2220
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2221
+ name: "message_id";
2222
+ tableName: "session_events";
2223
+ dataType: "string";
2224
+ columnType: "SQLiteText";
2225
+ data: string;
2226
+ driverParam: string;
2227
+ notNull: false;
2228
+ hasDefault: false;
2229
+ isPrimaryKey: false;
2230
+ isAutoincrement: false;
2231
+ hasRuntimeDefault: false;
2232
+ enumValues: [string, ...string[]];
2233
+ baseColumn: never;
2234
+ identity: undefined;
2235
+ generated: undefined;
2236
+ }, {}, {
2237
+ length: number | undefined;
2238
+ }>;
2239
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2240
+ name: "turn_id";
2241
+ tableName: "session_events";
2242
+ dataType: "string";
2243
+ columnType: "SQLiteText";
2244
+ data: string;
2245
+ driverParam: string;
2246
+ notNull: false;
2247
+ hasDefault: false;
2248
+ isPrimaryKey: false;
2249
+ isAutoincrement: false;
2250
+ hasRuntimeDefault: false;
2251
+ enumValues: [string, ...string[]];
2252
+ baseColumn: never;
2253
+ identity: undefined;
2254
+ generated: undefined;
2255
+ }, {}, {
2256
+ length: number | undefined;
2257
+ }>;
2258
+ contentText: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2259
+ name: "content_text";
2260
+ tableName: "session_events";
2261
+ dataType: "string";
2262
+ columnType: "SQLiteText";
2263
+ data: string;
2264
+ driverParam: string;
2265
+ notNull: false;
2266
+ hasDefault: false;
2267
+ isPrimaryKey: false;
2268
+ isAutoincrement: false;
2269
+ hasRuntimeDefault: false;
2270
+ enumValues: [string, ...string[]];
2271
+ baseColumn: never;
2272
+ identity: undefined;
2273
+ generated: undefined;
2274
+ }, {}, {
2275
+ length: number | undefined;
2276
+ }>;
2277
+ payload: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2278
+ name: "payload";
2279
+ tableName: "session_events";
2280
+ dataType: "string";
2281
+ columnType: "SQLiteText";
2282
+ data: string;
2283
+ driverParam: string;
2284
+ notNull: true;
2285
+ hasDefault: false;
2286
+ isPrimaryKey: false;
2287
+ isAutoincrement: false;
2288
+ hasRuntimeDefault: false;
2289
+ enumValues: [string, ...string[]];
2290
+ baseColumn: never;
2291
+ identity: undefined;
2292
+ generated: undefined;
2293
+ }, {}, {
2294
+ length: number | undefined;
2295
+ }>;
2296
+ };
2297
+ dialect: "sqlite";
2298
+ }>;
2299
+ /**
2300
+ * Type for inserting a new session event.
2301
+ */
2302
+ type InsertSessionEvent = typeof sessionEvents.$inferInsert;
2303
+ /**
2304
+ * Type for a selected session event row.
2305
+ */
2306
+ type SelectSessionEvent = typeof sessionEvents.$inferSelect;
2307
+ //#endregion
2308
+ //#region packages/services/core/src/session/session-events/memory-handler.d.ts
2309
+ /**
2310
+ * Register in-memory session event storage handlers.
2311
+ *
2312
+ * Suitable for development, testing, and single-instance deployments.
2313
+ * Data is lost when the process exits.
2314
+ *
2315
+ * Events are stored per-session in insertion order. Cursor-based pagination
2316
+ * uses a stable, monotonically-increasing sequence ID (`seqIdByEventId`)
2317
+ * assigned at append time — semantically equivalent to the Drizzle handler's
2318
+ * auto-increment `id` column. Cursors survive concurrent appends and remain
2319
+ * meaningful after deletes: an `after` cursor simply skips all events whose
2320
+ * seqId is ≤ the cursor value, regardless of whether the referenced event
2321
+ * still exists.
2322
+ * @param bus - The bus instance to register handlers on
2323
+ * @returns Cleanup function to unsubscribe all handlers
2324
+ * @example
2325
+ * ```typescript
2326
+ * import { registerMemorySessionEventStorage } from '@makaio/framework/services/session';
2327
+ *
2328
+ * const cleanup = registerMemorySessionEventStorage(bus);
2329
+ *
2330
+ * // Later, when shutting down:
2331
+ * cleanup();
2332
+ * ```
2333
+ */
2334
+ declare function registerMemorySessionEventStorage(bus: IMakaioBus): () => void;
2335
+ //#endregion
2336
+ //#region packages/services/core/src/session/session-events/drizzle-handler.d.ts
2337
+ /**
2338
+ * Register Drizzle-based session event storage handlers.
2339
+ *
2340
+ * Persists events to SQLite/libSQL via Drizzle ORM with cursor-based
2341
+ * pagination and content extraction for future FTS/embedding support.
2342
+ * @param bus - The bus instance to register handlers on
2343
+ * @param db - The Drizzle database instance (any libSQL database)
2344
+ * @param _ctx - Extension context (unused; reserved for future use)
2345
+ * @returns Cleanup function to unsubscribe all handlers
2346
+ * @example
2347
+ * ```typescript
2348
+ * import { registerDrizzleSessionEventStorage } from '@makaio/framework/services/session';
2349
+ * import { drizzle } from 'drizzle-orm/libsql';
2350
+ * import { createClient } from '@libsql/client';
2351
+ *
2352
+ * const client = createClient({ url: 'file:./makaio.db' });
2353
+ * const db = drizzle(client);
2354
+ * const cleanup = registerDrizzleSessionEventStorage(bus, db, ctx);
2355
+ *
2356
+ * // Later, when shutting down:
2357
+ * cleanup();
2358
+ * ```
2359
+ */
2360
+ declare function registerDrizzleSessionEventStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2361
+ //#endregion
2362
+ //#region packages/services/core/src/session/session-logger.d.ts
2363
+ /**
2364
+ * Transform function for event payloads before storage emission.
2365
+ * Use for redaction, PII filtering, or payload normalization.
2366
+ *
2367
+ * **Scope:** Only affects events emitted to `storage:sessionEvent.append`.
2368
+ * Individual subjects (`session.agent.*`, `session.user_message.*`) still receive
2369
+ * raw payloads. For full bus-level PII protection, redaction must happen at emit sites
2370
+ * (e.g., in SessionOrchestrator before emitting user_message.sent).
2371
+ * @param event - The event to transform
2372
+ * @returns Transformed event, or null to skip storage emission
2373
+ */
2374
+ type EventTransform = (event: MakaioSessionEvent) => MakaioSessionEvent | null;
2375
+ /**
2376
+ * Options for SessionLogger.
2377
+ */
2378
+ interface SessionLoggerOptions {
2379
+ /**
2380
+ * Transform function applied before storage emission.
2381
+ * Return null to skip storage entirely.
2382
+ * Note: Does not affect individual session.* subjects (see EventTransform docs).
2383
+ * Default: identity (no transformation)
2384
+ */
2385
+ transform?: EventTransform;
2386
+ }
2387
+ /**
2388
+ * Bridges session lifecycle events to storage layer for persistence.
2389
+ *
2390
+ * **Architecture (Normalized Message Model):**
2391
+ * - Messages: Stored in `messages` table via MessageStorageSubjects (by SessionOrchestrator/SessionBridge)
2392
+ * - SessionLogger: Stores LIFECYCLE events only — agent.added, turn.started, turn.completed
2393
+ *
2394
+ * **NO longer subscribes to user_message.* events** — user messages are now
2395
+ * first-class entities in the `messages` table, not embedded in event payloads.
2396
+ *
2397
+ * The correlation link is `session.agent.added` which maps:
2398
+ * `sessionId ↔ agentId ↔ adapterSessionId`
2399
+ *
2400
+ * Subscribes to:
2401
+ * - session.agent.added — correlation link for multi-agent reconstruction
2402
+ * - session.turn.started, session.turn.completed — turn lifecycle
2403
+ * - session.branch.created — branch creation audit trail
2404
+ *
2405
+ * Does NOT subscribe to session.branch.merged or session.squash — those
2406
+ * handlers (merge-handler, compress-handler) own their persistence directly
2407
+ * using a stable eventId so retries are idempotent.
2408
+ *
2409
+ * Emits transformed events to `storage:sessionEvent.append` for persistence.
2410
+ * @example
2411
+ * ```typescript
2412
+ * // Basic usage - lifecycle events are emitted to storage:sessionEvent.append
2413
+ * const sessionLogger = new SessionLogger(MakaioBus);
2414
+ *
2415
+ * // With redaction transform (mainly for turn error messages)
2416
+ * const sessionLogger = new SessionLogger(MakaioBus, {
2417
+ * transform: (event) => {
2418
+ * // Redact sensitive info if needed
2419
+ * return event;
2420
+ * },
2421
+ * });
2422
+ * ```
2423
+ */
2424
+ declare class SessionLogger {
2425
+ private readonly bus;
2426
+ private readonly options;
2427
+ private readonly cleanups;
2428
+ private readonly transform;
2429
+ constructor(bus?: IMakaioBus, options?: SessionLoggerOptions);
2430
+ /**
2431
+ * Emit a session event to storage layer.
2432
+ *
2433
+ * Creates event envelope, applies transform, and emits to storage subject.
2434
+ * If transform returns null, event is skipped.
2435
+ * @param eventType - Event type for classification
2436
+ * @param sessionId - Session identifier
2437
+ * @param payload - Event payload to persist
2438
+ */
2439
+ private emitStorageEvent;
2440
+ /**
2441
+ * Register a handler for a session event subject.
2442
+ * @param subject - Subject definition to subscribe to
2443
+ * @param eventType - Event type for persistence
2444
+ */
2445
+ private registerHandler;
2446
+ /**
2447
+ * Register all session lifecycle event handlers.
2448
+ *
2449
+ * **Normalized Message Model:**
2450
+ * - User messages are stored in `messages` table by SessionOrchestrator
2451
+ * - Assistant messages are stored by SessionBridge on agent.complete
2452
+ * - SessionLogger only stores LIFECYCLE events for audit/correlation
2453
+ */
2454
+ private registerHandlers;
2455
+ /**
2456
+ * Stop the logger and clean up subscriptions.
2457
+ */
2458
+ destroy(): void;
2459
+ }
2460
+ //#endregion
2461
+ //#region packages/services/core/src/session/import-cursors/schema.d.ts
2462
+ /**
2463
+ * Import cursors table schema.
2464
+ *
2465
+ * Tracks byte offsets for incremental log file import.
2466
+ * Enables resuming import from the last processed position after restarts.
2467
+ */
2468
+ declare const importCursors: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2469
+ name: "import_cursors";
2470
+ schema: undefined;
2471
+ columns: {
2472
+ filePath: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2473
+ name: "file_path";
2474
+ tableName: "import_cursors";
2475
+ dataType: "string";
2476
+ columnType: "SQLiteText";
2477
+ data: string;
2478
+ driverParam: string;
2479
+ notNull: true;
2480
+ hasDefault: false;
2481
+ isPrimaryKey: true;
2482
+ isAutoincrement: false;
2483
+ hasRuntimeDefault: false;
2484
+ enumValues: [string, ...string[]];
2485
+ baseColumn: never;
2486
+ identity: undefined;
2487
+ generated: undefined;
2488
+ }, {}, {
2489
+ length: number | undefined;
2490
+ }>;
2491
+ bytesRead: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2492
+ name: "bytes_read";
2493
+ tableName: "import_cursors";
2494
+ dataType: "number";
2495
+ columnType: "SQLiteInteger";
2496
+ data: number;
2497
+ driverParam: number;
2498
+ notNull: true;
2499
+ hasDefault: false;
2500
+ isPrimaryKey: false;
2501
+ isAutoincrement: false;
2502
+ hasRuntimeDefault: false;
2503
+ enumValues: undefined;
2504
+ baseColumn: never;
2505
+ identity: undefined;
2506
+ generated: undefined;
2507
+ }, {}, {}>;
2508
+ lastModified: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2509
+ name: "last_modified";
2510
+ tableName: "import_cursors";
2511
+ dataType: "string";
2512
+ columnType: "SQLiteText";
2513
+ data: string;
2514
+ driverParam: string;
2515
+ notNull: true;
2516
+ hasDefault: false;
2517
+ isPrimaryKey: false;
2518
+ isAutoincrement: false;
2519
+ hasRuntimeDefault: false;
2520
+ enumValues: [string, ...string[]];
2521
+ baseColumn: never;
2522
+ identity: undefined;
2523
+ generated: undefined;
2524
+ }, {}, {
2525
+ length: number | undefined;
2526
+ }>;
2527
+ updatedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2528
+ name: "updated_at";
2529
+ tableName: "import_cursors";
2530
+ dataType: "number";
2531
+ columnType: "SQLiteInteger";
2532
+ data: number;
2533
+ driverParam: number;
2534
+ notNull: true;
2535
+ hasDefault: false;
2536
+ isPrimaryKey: false;
2537
+ isAutoincrement: false;
2538
+ hasRuntimeDefault: false;
2539
+ enumValues: undefined;
2540
+ baseColumn: never;
2541
+ identity: undefined;
2542
+ generated: undefined;
2543
+ }, {}, {}>;
2544
+ };
2545
+ dialect: "sqlite";
2546
+ }>;
2547
+ //#endregion
2548
+ //#region packages/services/core/src/session/import-cursors/drizzle-handler.d.ts
2549
+ /**
2550
+ * Register Drizzle-backed import cursor storage handlers.
2551
+ *
2552
+ * Provides persistent cursor storage for efficient log import resume.
2553
+ * On restart, import continues from the last processed byte offset.
2554
+ * @param bus - The bus instance to register handlers on
2555
+ * @param db - Drizzle database instance
2556
+ * @param _ctx - Extension context (unused; reserved for future use)
2557
+ * @returns Cleanup function to unsubscribe all handlers
2558
+ * @example
2559
+ * ```typescript
2560
+ * import { registerDrizzleImportCursorStorage } from '@makaio/framework/services/session';
2561
+ *
2562
+ * const cleanup = registerDrizzleImportCursorStorage(bus, db, ctx);
2563
+ *
2564
+ * // Later, when shutting down:
2565
+ * cleanup();
2566
+ * ```
2567
+ */
2568
+ declare function registerDrizzleImportCursorStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2569
+ //#endregion
2570
+ //#region packages/services/core/src/session/turns/drizzle-handler.d.ts
2571
+ /**
2572
+ * Register Drizzle-based turn storage handlers.
2573
+ *
2574
+ * Manages turn lifecycle in SQLite/libSQL via Drizzle ORM.
2575
+ *
2576
+ * CONCURRENCY INVARIANT: All handlers must use single-statement operations only.
2577
+ * Storage handlers share a single DB connection. Fire-and-forget bus events
2578
+ * (e.g., agent.added) race with sequential RPC handlers (e.g., turn.create).
2579
+ * db.transaction() holds write locks across await boundaries, causing SQLITE_BUSY
2580
+ * deadlocks on the same connection. Single statements serialize automatically
2581
+ * via SQLite's busy_timeout + WAL mode.
2582
+ * @param bus - The bus instance to register handlers on
2583
+ * @param db - The Drizzle database instance
2584
+ * @param _ctx - Extension context (unused; reserved for future use)
2585
+ * @returns Cleanup function to unsubscribe all handlers
2586
+ */
2587
+ declare function registerDrizzleTurnStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2588
+ //#endregion
2589
+ //#region packages/services/core/src/session/turns/memory-handler.d.ts
2590
+ /**
2591
+ * Register in-memory turn storage handlers.
2592
+ *
2593
+ * Suitable for development and tests. Data is lost on process exit.
2594
+ * @param bus - The bus instance to register handlers on
2595
+ * @returns Cleanup function to unsubscribe all handlers
2596
+ */
2597
+ declare function registerMemoryTurnStorage(bus: IMakaioBus): () => void;
2598
+ //#endregion
2599
+ //#region packages/services/core/src/session/turns/schema.d.ts
2600
+ /**
2601
+ * Turns table schema.
2602
+ *
2603
+ * A turn represents a user message and all agent responses to it.
2604
+ * Extracted from events to provide explicit turn boundaries.
2605
+ *
2606
+ * Design rationale:
2607
+ * - First-class entity for turn lifecycle tracking
2608
+ * - Links to session via FK for cascade delete
2609
+ * - Status tracks completion state for UI progress indication
2610
+ */
2611
+ declare const turns: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2612
+ name: "turns";
2613
+ schema: undefined;
2614
+ columns: {
2615
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2616
+ name: "turn_id";
2617
+ tableName: "turns";
2618
+ dataType: "string";
2619
+ columnType: "SQLiteText";
2620
+ data: string;
2621
+ driverParam: string;
2622
+ notNull: true;
2623
+ hasDefault: false;
2624
+ isPrimaryKey: true;
2625
+ isAutoincrement: false;
2626
+ hasRuntimeDefault: false;
2627
+ enumValues: [string, ...string[]];
2628
+ baseColumn: never;
2629
+ identity: undefined;
2630
+ generated: undefined;
2631
+ }, {}, {
2632
+ length: number | undefined;
2633
+ }>;
2634
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2635
+ name: "session_id";
2636
+ tableName: "turns";
2637
+ dataType: "string";
2638
+ columnType: "SQLiteText";
2639
+ data: string;
2640
+ driverParam: string;
2641
+ notNull: true;
2642
+ hasDefault: false;
2643
+ isPrimaryKey: false;
2644
+ isAutoincrement: false;
2645
+ hasRuntimeDefault: false;
2646
+ enumValues: [string, ...string[]];
2647
+ baseColumn: never;
2648
+ identity: undefined;
2649
+ generated: undefined;
2650
+ }, {}, {
2651
+ length: number | undefined;
2652
+ }>;
2653
+ turnNumber: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2654
+ name: "turn_number";
2655
+ tableName: "turns";
2656
+ dataType: "number";
2657
+ columnType: "SQLiteInteger";
2658
+ data: number;
2659
+ driverParam: number;
2660
+ notNull: true;
2661
+ hasDefault: false;
2662
+ isPrimaryKey: false;
2663
+ isAutoincrement: false;
2664
+ hasRuntimeDefault: false;
2665
+ enumValues: undefined;
2666
+ baseColumn: never;
2667
+ identity: undefined;
2668
+ generated: undefined;
2669
+ }, {}, {}>;
2670
+ startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2671
+ name: "started_at";
2672
+ tableName: "turns";
2673
+ dataType: "number";
2674
+ columnType: "SQLiteInteger";
2675
+ data: number;
2676
+ driverParam: number;
2677
+ notNull: true;
2678
+ hasDefault: false;
2679
+ isPrimaryKey: false;
2680
+ isAutoincrement: false;
2681
+ hasRuntimeDefault: false;
2682
+ enumValues: undefined;
2683
+ baseColumn: never;
2684
+ identity: undefined;
2685
+ generated: undefined;
2686
+ }, {}, {}>;
2687
+ completedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2688
+ name: "completed_at";
2689
+ tableName: "turns";
2690
+ dataType: "number";
2691
+ columnType: "SQLiteInteger";
2692
+ data: number;
2693
+ driverParam: number;
2694
+ notNull: false;
2695
+ hasDefault: false;
2696
+ isPrimaryKey: false;
2697
+ isAutoincrement: false;
2698
+ hasRuntimeDefault: false;
2699
+ enumValues: undefined;
2700
+ baseColumn: never;
2701
+ identity: undefined;
2702
+ generated: undefined;
2703
+ }, {}, {}>;
2704
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2705
+ name: "status";
2706
+ tableName: "turns";
2707
+ dataType: "string";
2708
+ columnType: "SQLiteText";
2709
+ data: "error" | "completed" | "active";
2710
+ driverParam: string;
2711
+ notNull: true;
2712
+ hasDefault: false;
2713
+ isPrimaryKey: false;
2714
+ isAutoincrement: false;
2715
+ hasRuntimeDefault: false;
2716
+ enumValues: ["active", "completed", "error"];
2717
+ baseColumn: never;
2718
+ identity: undefined;
2719
+ generated: undefined;
2720
+ }, {}, {
2721
+ length: number | undefined;
2722
+ }>;
2723
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2724
+ name: "error";
2725
+ tableName: "turns";
2726
+ dataType: "string";
2727
+ columnType: "SQLiteText";
2728
+ data: string;
2729
+ driverParam: string;
2730
+ notNull: false;
2731
+ hasDefault: false;
2732
+ isPrimaryKey: false;
2733
+ isAutoincrement: false;
2734
+ hasRuntimeDefault: false;
2735
+ enumValues: [string, ...string[]];
2736
+ baseColumn: never;
2737
+ identity: undefined;
2738
+ generated: undefined;
2739
+ }, {}, {
2740
+ length: number | undefined;
2741
+ }>;
2742
+ usage: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2743
+ name: "usage";
2744
+ tableName: "turns";
2745
+ dataType: "string";
2746
+ columnType: "SQLiteText";
2747
+ data: string;
2748
+ driverParam: string;
2749
+ notNull: false;
2750
+ hasDefault: false;
2751
+ isPrimaryKey: false;
2752
+ isAutoincrement: false;
2753
+ hasRuntimeDefault: false;
2754
+ enumValues: [string, ...string[]];
2755
+ baseColumn: never;
2756
+ identity: undefined;
2757
+ generated: undefined;
2758
+ }, {}, {
2759
+ length: number | undefined;
2760
+ }>;
2761
+ };
2762
+ dialect: "sqlite";
2763
+ }>;
2764
+ /**
2765
+ * Type for inserting a new turn.
2766
+ */
2767
+ type InsertTurn = typeof turns.$inferInsert;
2768
+ /**
2769
+ * Type for a selected turn row.
2770
+ */
2771
+ type SelectTurn = typeof turns.$inferSelect;
2772
+ //#endregion
2773
+ //#region packages/services/core/src/session/messages/drizzle-handler.d.ts
2774
+ /**
2775
+ * Register Drizzle-based message storage handlers.
2776
+ *
2777
+ * Manages message persistence in SQLite/libSQL via Drizzle ORM.
2778
+ * @param bus - The bus instance to register handlers on
2779
+ * @param db - The Drizzle database instance
2780
+ * @param _ctx - Extension context (unused; reserved for future use)
2781
+ * @returns Cleanup function to unsubscribe all handlers
2782
+ */
2783
+ declare function registerDrizzleMessageStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
2784
+ //#endregion
2785
+ //#region packages/services/core/src/session/messages/memory-handler.d.ts
2786
+ /**
2787
+ * Register in-memory message storage handlers.
2788
+ *
2789
+ * Intended for dev/test runtime usage. Durable storage is provided by the
2790
+ * Drizzle handlers in ./drizzle-handler.ts.
2791
+ * @param bus - The bus instance to register handlers on
2792
+ * @returns Cleanup function to unregister handlers
2793
+ */
2794
+ declare function registerMemoryMessageStorage(bus: IMakaioBus): () => void;
2795
+ //#endregion
2796
+ //#region packages/services/core/src/session/messages/schema.d.ts
2797
+ /**
2798
+ * Messages table schema.
2799
+ *
2800
+ * The single source of truth for conversation content as consumed by Makaio
2801
+ * (UI history, search, transforms, routing).
2802
+ *
2803
+ * Design principles:
2804
+ * - Messages are first-class entities, not embedded in events
2805
+ * - Single source of truth for conversation content
2806
+ * - Blocks stored as JSON for flexible structure
2807
+ * - contentText extracted for FTS5 search
2808
+ * - session_events tracks lifecycle (turns, branches) but not content
2809
+ */
2810
+ declare const messages: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
2811
+ name: "messages";
2812
+ schema: undefined;
2813
+ columns: {
2814
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2815
+ name: "message_id";
2816
+ tableName: "messages";
2817
+ dataType: "string";
2818
+ columnType: "SQLiteText";
2819
+ data: string;
2820
+ driverParam: string;
2821
+ notNull: true;
2822
+ hasDefault: false;
2823
+ isPrimaryKey: true;
2824
+ isAutoincrement: false;
2825
+ hasRuntimeDefault: false;
2826
+ enumValues: [string, ...string[]];
2827
+ baseColumn: never;
2828
+ identity: undefined;
2829
+ generated: undefined;
2830
+ }, {}, {
2831
+ length: number | undefined;
2832
+ }>;
2833
+ turnId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2834
+ name: "turn_id";
2835
+ tableName: "messages";
2836
+ dataType: "string";
2837
+ columnType: "SQLiteText";
2838
+ data: string;
2839
+ driverParam: string;
2840
+ notNull: false;
2841
+ hasDefault: false;
2842
+ isPrimaryKey: false;
2843
+ isAutoincrement: false;
2844
+ hasRuntimeDefault: false;
2845
+ enumValues: [string, ...string[]];
2846
+ baseColumn: never;
2847
+ identity: undefined;
2848
+ generated: undefined;
2849
+ }, {}, {
2850
+ length: number | undefined;
2851
+ }>;
2852
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2853
+ name: "session_id";
2854
+ tableName: "messages";
2855
+ dataType: "string";
2856
+ columnType: "SQLiteText";
2857
+ data: string;
2858
+ driverParam: string;
2859
+ notNull: true;
2860
+ hasDefault: false;
2861
+ isPrimaryKey: false;
2862
+ isAutoincrement: false;
2863
+ hasRuntimeDefault: false;
2864
+ enumValues: [string, ...string[]];
2865
+ baseColumn: never;
2866
+ identity: undefined;
2867
+ generated: undefined;
2868
+ }, {}, {
2869
+ length: number | undefined;
2870
+ }>;
2871
+ role: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2872
+ name: "role";
2873
+ tableName: "messages";
2874
+ dataType: "string";
2875
+ columnType: "SQLiteText";
2876
+ data: "user" | "assistant";
2877
+ driverParam: string;
2878
+ notNull: true;
2879
+ hasDefault: false;
2880
+ isPrimaryKey: false;
2881
+ isAutoincrement: false;
2882
+ hasRuntimeDefault: false;
2883
+ enumValues: ["user", "assistant"];
2884
+ baseColumn: never;
2885
+ identity: undefined;
2886
+ generated: undefined;
2887
+ }, {}, {
2888
+ length: number | undefined;
2889
+ }>;
2890
+ contentText: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2891
+ name: "content_text";
2892
+ tableName: "messages";
2893
+ dataType: "string";
2894
+ columnType: "SQLiteText";
2895
+ data: string;
2896
+ driverParam: string;
2897
+ notNull: true;
2898
+ hasDefault: false;
2899
+ isPrimaryKey: false;
2900
+ isAutoincrement: false;
2901
+ hasRuntimeDefault: false;
2902
+ enumValues: [string, ...string[]];
2903
+ baseColumn: never;
2904
+ identity: undefined;
2905
+ generated: undefined;
2906
+ }, {}, {
2907
+ length: number | undefined;
2908
+ }>;
2909
+ blocks: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2910
+ name: "blocks";
2911
+ tableName: "messages";
2912
+ dataType: "string";
2913
+ columnType: "SQLiteText";
2914
+ data: string;
2915
+ driverParam: string;
2916
+ notNull: true;
2917
+ hasDefault: true;
2918
+ isPrimaryKey: false;
2919
+ isAutoincrement: false;
2920
+ hasRuntimeDefault: false;
2921
+ enumValues: [string, ...string[]];
2922
+ baseColumn: never;
2923
+ identity: undefined;
2924
+ generated: undefined;
2925
+ }, {}, {
2926
+ length: number | undefined;
2927
+ }>;
2928
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2929
+ name: "agent_id";
2930
+ tableName: "messages";
2931
+ dataType: "string";
2932
+ columnType: "SQLiteText";
2933
+ data: string;
2934
+ driverParam: string;
2935
+ notNull: false;
2936
+ hasDefault: false;
2937
+ isPrimaryKey: false;
2938
+ isAutoincrement: false;
2939
+ hasRuntimeDefault: false;
2940
+ enumValues: [string, ...string[]];
2941
+ baseColumn: never;
2942
+ identity: undefined;
2943
+ generated: undefined;
2944
+ }, {}, {
2945
+ length: number | undefined;
2946
+ }>;
2947
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2948
+ name: "adapter_session_id";
2949
+ tableName: "messages";
2950
+ dataType: "string";
2951
+ columnType: "SQLiteText";
2952
+ data: string;
2953
+ driverParam: string;
2954
+ notNull: false;
2955
+ hasDefault: false;
2956
+ isPrimaryKey: false;
2957
+ isAutoincrement: false;
2958
+ hasRuntimeDefault: false;
2959
+ enumValues: [string, ...string[]];
2960
+ baseColumn: never;
2961
+ identity: undefined;
2962
+ generated: undefined;
2963
+ }, {}, {
2964
+ length: number | undefined;
2965
+ }>;
2966
+ adapterMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2967
+ name: "adapter_message_id";
2968
+ tableName: "messages";
2969
+ dataType: "string";
2970
+ columnType: "SQLiteText";
2971
+ data: string;
2972
+ driverParam: string;
2973
+ notNull: false;
2974
+ hasDefault: false;
2975
+ isPrimaryKey: false;
2976
+ isAutoincrement: false;
2977
+ hasRuntimeDefault: false;
2978
+ enumValues: [string, ...string[]];
2979
+ baseColumn: never;
2980
+ identity: undefined;
2981
+ generated: undefined;
2982
+ }, {}, {
2983
+ length: number | undefined;
2984
+ }>;
2985
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2986
+ name: "timestamp";
2987
+ tableName: "messages";
2988
+ dataType: "number";
2989
+ columnType: "SQLiteInteger";
2990
+ data: number;
2991
+ driverParam: number;
2992
+ notNull: true;
2993
+ hasDefault: false;
2994
+ isPrimaryKey: false;
2995
+ isAutoincrement: false;
2996
+ hasRuntimeDefault: false;
2997
+ enumValues: undefined;
2998
+ baseColumn: never;
2999
+ identity: undefined;
3000
+ generated: undefined;
3001
+ }, {}, {}>;
3002
+ editOf: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3003
+ name: "edit_of";
3004
+ tableName: "messages";
3005
+ dataType: "string";
3006
+ columnType: "SQLiteText";
3007
+ data: string;
3008
+ driverParam: string;
3009
+ notNull: false;
3010
+ hasDefault: false;
3011
+ isPrimaryKey: false;
3012
+ isAutoincrement: false;
3013
+ hasRuntimeDefault: false;
3014
+ enumValues: [string, ...string[]];
3015
+ baseColumn: never;
3016
+ identity: undefined;
3017
+ generated: undefined;
3018
+ }, {}, {
3019
+ length: number | undefined;
3020
+ }>;
3021
+ origin: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3022
+ name: "origin";
3023
+ tableName: "messages";
3024
+ dataType: "string";
3025
+ columnType: "SQLiteText";
3026
+ data: "text" | "voice" | "compact";
3027
+ driverParam: string;
3028
+ notNull: false;
3029
+ hasDefault: false;
3030
+ isPrimaryKey: false;
3031
+ isAutoincrement: false;
3032
+ hasRuntimeDefault: false;
3033
+ enumValues: ["voice", "text", "compact"];
3034
+ baseColumn: never;
3035
+ identity: undefined;
3036
+ generated: undefined;
3037
+ }, {}, {
3038
+ length: number | undefined;
3039
+ }>;
3040
+ };
3041
+ dialect: "sqlite";
3042
+ }>;
3043
+ /**
3044
+ * Type for inserting a new message.
3045
+ */
3046
+ type InsertMessage = typeof messages.$inferInsert;
3047
+ /**
3048
+ * Type for a selected message row.
3049
+ */
3050
+ type SelectMessage = typeof messages.$inferSelect;
3051
+ //#endregion
3052
+ //#region packages/services/core/src/session/message-routing/namespace.d.ts
3053
+ /**
3054
+ * Message routing storage namespace.
3055
+ *
3056
+ * Tracks delivery status of messages to agents in multi-agent sessions.
3057
+ * Enables querying completion status for turn coordination.
3058
+ */
3059
+ declare const MessageRoutingNamespace: _$_makaio_storage_core0.StorageNamespaceDefinition<"messageRouting", {
3060
+ /**
3061
+ * Record routing status for a message to an agent.
3062
+ *
3063
+ * Subject: `storage:messageRouting.record`
3064
+ * Type: Request (RPC)
3065
+ */
3066
+ record: {
3067
+ request: z.ZodObject<{
3068
+ messageId: z.ZodString;
3069
+ agentId: z.ZodString;
3070
+ status: z.ZodEnum<{
3071
+ completed: "completed";
3072
+ sent: "sent";
3073
+ acknowledged: "acknowledged";
3074
+ }>;
3075
+ timestamp: z.ZodNumber;
3076
+ error: z.ZodOptional<z.ZodString>;
3077
+ }, z.core.$strip>;
3078
+ response: z.ZodObject<{
3079
+ success: z.ZodBoolean;
3080
+ }, z.core.$strip>;
3081
+ };
3082
+ /**
3083
+ * Get routing status for a message.
3084
+ *
3085
+ * Subject: `storage:messageRouting.getByMessage`
3086
+ * Type: Request (RPC)
3087
+ */
3088
+ getByMessage: {
3089
+ request: z.ZodObject<{
3090
+ messageId: z.ZodString;
3091
+ }, z.core.$strip>;
3092
+ response: z.ZodObject<{
3093
+ routing: z.ZodArray<z.ZodObject<{
3094
+ messageId: z.ZodString;
3095
+ agentId: z.ZodString;
3096
+ status: z.ZodEnum<{
3097
+ completed: "completed";
3098
+ sent: "sent";
3099
+ acknowledged: "acknowledged";
3100
+ }>;
3101
+ timestamp: z.ZodNumber;
3102
+ error: z.ZodOptional<z.ZodString>;
3103
+ }, z.core.$strip>>;
3104
+ }, z.core.$strip>;
3105
+ };
3106
+ /**
3107
+ * Get all completed routings for a message.
3108
+ * Used to check if all target agents have responded.
3109
+ *
3110
+ * Subject: `storage:messageRouting.getCompleted`
3111
+ * Type: Request (RPC)
3112
+ */
3113
+ getCompleted: {
3114
+ request: z.ZodObject<{
3115
+ messageId: z.ZodString;
3116
+ }, z.core.$strip>;
3117
+ response: z.ZodObject<{
3118
+ agentIds: z.ZodArray<z.ZodString>;
3119
+ }, z.core.$strip>;
3120
+ };
3121
+ /**
3122
+ * Check if all target agents have completed for a message.
3123
+ *
3124
+ * Subject: `storage:messageRouting.isComplete`
3125
+ * Type: Request (RPC)
3126
+ */
3127
+ isComplete: {
3128
+ request: z.ZodObject<{
3129
+ messageId: z.ZodString;
3130
+ targetAgentIds: z.ZodArray<z.ZodString>;
3131
+ }, z.core.$strip>;
3132
+ response: z.ZodObject<{
3133
+ complete: z.ZodBoolean;
3134
+ pending: z.ZodArray<z.ZodString>;
3135
+ }, z.core.$strip>;
3136
+ };
3137
+ }, {
3138
+ drizzle: {
3139
+ messageRouting: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3140
+ name: "message_routing";
3141
+ schema: undefined;
3142
+ columns: {
3143
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3144
+ name: "message_id";
3145
+ tableName: "message_routing";
3146
+ dataType: "string";
3147
+ columnType: "SQLiteText";
3148
+ data: string;
3149
+ driverParam: string;
3150
+ notNull: true;
3151
+ hasDefault: false;
3152
+ isPrimaryKey: false;
3153
+ isAutoincrement: false;
3154
+ hasRuntimeDefault: false;
3155
+ enumValues: [string, ...string[]];
3156
+ baseColumn: never;
3157
+ identity: undefined;
3158
+ generated: undefined;
3159
+ }, {}, {
3160
+ length: number | undefined;
3161
+ }>;
3162
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3163
+ name: "agent_id";
3164
+ tableName: "message_routing";
3165
+ dataType: "string";
3166
+ columnType: "SQLiteText";
3167
+ data: string;
3168
+ driverParam: string;
3169
+ notNull: true;
3170
+ hasDefault: false;
3171
+ isPrimaryKey: false;
3172
+ isAutoincrement: false;
3173
+ hasRuntimeDefault: false;
3174
+ enumValues: [string, ...string[]];
3175
+ baseColumn: never;
3176
+ identity: undefined;
3177
+ generated: undefined;
3178
+ }, {}, {
3179
+ length: number | undefined;
3180
+ }>;
3181
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3182
+ name: "status";
3183
+ tableName: "message_routing";
3184
+ dataType: "string";
3185
+ columnType: "SQLiteText";
3186
+ data: "completed" | "sent" | "acknowledged";
3187
+ driverParam: string;
3188
+ notNull: true;
3189
+ hasDefault: false;
3190
+ isPrimaryKey: false;
3191
+ isAutoincrement: false;
3192
+ hasRuntimeDefault: false;
3193
+ enumValues: ["sent", "acknowledged", "completed"];
3194
+ baseColumn: never;
3195
+ identity: undefined;
3196
+ generated: undefined;
3197
+ }, {}, {
3198
+ length: number | undefined;
3199
+ }>;
3200
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3201
+ name: "timestamp";
3202
+ tableName: "message_routing";
3203
+ dataType: "number";
3204
+ columnType: "SQLiteInteger";
3205
+ data: number;
3206
+ driverParam: number;
3207
+ notNull: true;
3208
+ hasDefault: false;
3209
+ isPrimaryKey: false;
3210
+ isAutoincrement: false;
3211
+ hasRuntimeDefault: false;
3212
+ enumValues: undefined;
3213
+ baseColumn: never;
3214
+ identity: undefined;
3215
+ generated: undefined;
3216
+ }, {}, {}>;
3217
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3218
+ name: "error";
3219
+ tableName: "message_routing";
3220
+ dataType: "string";
3221
+ columnType: "SQLiteText";
3222
+ data: string;
3223
+ driverParam: string;
3224
+ notNull: false;
3225
+ hasDefault: false;
3226
+ isPrimaryKey: false;
3227
+ isAutoincrement: false;
3228
+ hasRuntimeDefault: false;
3229
+ enumValues: [string, ...string[]];
3230
+ baseColumn: never;
3231
+ identity: undefined;
3232
+ generated: undefined;
3233
+ }, {}, {
3234
+ length: number | undefined;
3235
+ }>;
3236
+ };
3237
+ dialect: "sqlite";
3238
+ }>;
3239
+ };
3240
+ }>;
3241
+ /**
3242
+ * Typed subjects for message routing storage operations.
3243
+ */
3244
+ declare const MessageRoutingSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"storage:messageRouting", {
3245
+ /**
3246
+ * Record routing status for a message to an agent.
3247
+ *
3248
+ * Subject: `storage:messageRouting.record`
3249
+ * Type: Request (RPC)
3250
+ */
3251
+ record: {
3252
+ request: z.ZodObject<{
3253
+ messageId: z.ZodString;
3254
+ agentId: z.ZodString;
3255
+ status: z.ZodEnum<{
3256
+ completed: "completed";
3257
+ sent: "sent";
3258
+ acknowledged: "acknowledged";
3259
+ }>;
3260
+ timestamp: z.ZodNumber;
3261
+ error: z.ZodOptional<z.ZodString>;
3262
+ }, z.core.$strip>;
3263
+ response: z.ZodObject<{
3264
+ success: z.ZodBoolean;
3265
+ }, z.core.$strip>;
3266
+ };
3267
+ /**
3268
+ * Get routing status for a message.
3269
+ *
3270
+ * Subject: `storage:messageRouting.getByMessage`
3271
+ * Type: Request (RPC)
3272
+ */
3273
+ getByMessage: {
3274
+ request: z.ZodObject<{
3275
+ messageId: z.ZodString;
3276
+ }, z.core.$strip>;
3277
+ response: z.ZodObject<{
3278
+ routing: z.ZodArray<z.ZodObject<{
3279
+ messageId: z.ZodString;
3280
+ agentId: z.ZodString;
3281
+ status: z.ZodEnum<{
3282
+ completed: "completed";
3283
+ sent: "sent";
3284
+ acknowledged: "acknowledged";
3285
+ }>;
3286
+ timestamp: z.ZodNumber;
3287
+ error: z.ZodOptional<z.ZodString>;
3288
+ }, z.core.$strip>>;
3289
+ }, z.core.$strip>;
3290
+ };
3291
+ /**
3292
+ * Get all completed routings for a message.
3293
+ * Used to check if all target agents have responded.
3294
+ *
3295
+ * Subject: `storage:messageRouting.getCompleted`
3296
+ * Type: Request (RPC)
3297
+ */
3298
+ getCompleted: {
3299
+ request: z.ZodObject<{
3300
+ messageId: z.ZodString;
3301
+ }, z.core.$strip>;
3302
+ response: z.ZodObject<{
3303
+ agentIds: z.ZodArray<z.ZodString>;
3304
+ }, z.core.$strip>;
3305
+ };
3306
+ /**
3307
+ * Check if all target agents have completed for a message.
3308
+ *
3309
+ * Subject: `storage:messageRouting.isComplete`
3310
+ * Type: Request (RPC)
3311
+ */
3312
+ isComplete: {
3313
+ request: z.ZodObject<{
3314
+ messageId: z.ZodString;
3315
+ targetAgentIds: z.ZodArray<z.ZodString>;
3316
+ }, z.core.$strip>;
3317
+ response: z.ZodObject<{
3318
+ complete: z.ZodBoolean;
3319
+ pending: z.ZodArray<z.ZodString>;
3320
+ }, z.core.$strip>;
3321
+ };
3322
+ }>, "storage:messageRouting">;
3323
+ //#endregion
3324
+ //#region packages/services/core/src/session/message-routing/drizzle-handler.d.ts
3325
+ /**
3326
+ * Register Drizzle-based message routing storage handlers.
3327
+ *
3328
+ * Manages message delivery tracking in SQLite/libSQL via Drizzle ORM.
3329
+ * @param bus - The bus instance to register handlers on
3330
+ * @param db - The Drizzle database instance
3331
+ * @param _ctx - Extension context (unused; reserved for future use)
3332
+ * @returns Cleanup function to unsubscribe all handlers
3333
+ */
3334
+ declare function registerDrizzleMessageRoutingStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
3335
+ //#endregion
3336
+ //#region packages/services/core/src/session/message-routing/schema.d.ts
3337
+ /**
3338
+ * Message routing table schema.
3339
+ *
3340
+ * Tracks delivery status of messages to agents in multi-agent sessions.
3341
+ * Each row represents a message-agent pair with status progression.
3342
+ *
3343
+ * Status progression: sent -\> acknowledged -\> completed
3344
+ *
3345
+ * Design rationale:
3346
+ * - Composite primary key allows multiple status entries per message-agent pair
3347
+ * - Enables tracking of delivery lifecycle for each target agent
3348
+ * - Supports querying "which agents have completed for this message?"
3349
+ */
3350
+ declare const messageRouting: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3351
+ name: "message_routing";
3352
+ schema: undefined;
3353
+ columns: {
3354
+ messageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3355
+ name: "message_id";
3356
+ tableName: "message_routing";
3357
+ dataType: "string";
3358
+ columnType: "SQLiteText";
3359
+ data: string;
3360
+ driverParam: string;
3361
+ notNull: true;
3362
+ hasDefault: false;
3363
+ isPrimaryKey: false;
3364
+ isAutoincrement: false;
3365
+ hasRuntimeDefault: false;
3366
+ enumValues: [string, ...string[]];
3367
+ baseColumn: never;
3368
+ identity: undefined;
3369
+ generated: undefined;
3370
+ }, {}, {
3371
+ length: number | undefined;
3372
+ }>;
3373
+ agentId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3374
+ name: "agent_id";
3375
+ tableName: "message_routing";
3376
+ dataType: "string";
3377
+ columnType: "SQLiteText";
3378
+ data: string;
3379
+ driverParam: string;
3380
+ notNull: true;
3381
+ hasDefault: false;
3382
+ isPrimaryKey: false;
3383
+ isAutoincrement: false;
3384
+ hasRuntimeDefault: false;
3385
+ enumValues: [string, ...string[]];
3386
+ baseColumn: never;
3387
+ identity: undefined;
3388
+ generated: undefined;
3389
+ }, {}, {
3390
+ length: number | undefined;
3391
+ }>;
3392
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3393
+ name: "status";
3394
+ tableName: "message_routing";
3395
+ dataType: "string";
3396
+ columnType: "SQLiteText";
3397
+ data: "completed" | "sent" | "acknowledged";
3398
+ driverParam: string;
3399
+ notNull: true;
3400
+ hasDefault: false;
3401
+ isPrimaryKey: false;
3402
+ isAutoincrement: false;
3403
+ hasRuntimeDefault: false;
3404
+ enumValues: ["sent", "acknowledged", "completed"];
3405
+ baseColumn: never;
3406
+ identity: undefined;
3407
+ generated: undefined;
3408
+ }, {}, {
3409
+ length: number | undefined;
3410
+ }>;
3411
+ timestamp: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3412
+ name: "timestamp";
3413
+ tableName: "message_routing";
3414
+ dataType: "number";
3415
+ columnType: "SQLiteInteger";
3416
+ data: number;
3417
+ driverParam: number;
3418
+ notNull: true;
3419
+ hasDefault: false;
3420
+ isPrimaryKey: false;
3421
+ isAutoincrement: false;
3422
+ hasRuntimeDefault: false;
3423
+ enumValues: undefined;
3424
+ baseColumn: never;
3425
+ identity: undefined;
3426
+ generated: undefined;
3427
+ }, {}, {}>;
3428
+ error: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3429
+ name: "error";
3430
+ tableName: "message_routing";
3431
+ dataType: "string";
3432
+ columnType: "SQLiteText";
3433
+ data: string;
3434
+ driverParam: string;
3435
+ notNull: false;
3436
+ hasDefault: false;
3437
+ isPrimaryKey: false;
3438
+ isAutoincrement: false;
3439
+ hasRuntimeDefault: false;
3440
+ enumValues: [string, ...string[]];
3441
+ baseColumn: never;
3442
+ identity: undefined;
3443
+ generated: undefined;
3444
+ }, {}, {
3445
+ length: number | undefined;
3446
+ }>;
3447
+ };
3448
+ dialect: "sqlite";
3449
+ }>;
3450
+ /**
3451
+ * Type for inserting a new routing entry.
3452
+ */
3453
+ type InsertMessageRouting = typeof messageRouting.$inferInsert;
3454
+ /**
3455
+ * Type for a selected routing entry row.
3456
+ */
3457
+ type SelectMessageRouting = typeof messageRouting.$inferSelect;
3458
+ //#endregion
3459
+ //#region packages/services/core/src/session/entities/makaio-session.d.ts
3460
+ /**
3461
+ * Configuration for creating a MakaioSession.
3462
+ */
3463
+ interface MakaioSessionConfig {
3464
+ /** Session ID (generated if not provided) */
3465
+ sessionId?: string;
3466
+ /** Bus for event emission */
3467
+ bus: IMakaioBus;
3468
+ /** Parent session ID (for forks) */
3469
+ parentSessionId?: string;
3470
+ }
3471
+ /**
3472
+ * Options for starting a turn.
3473
+ */
3474
+ interface StartTurnOptions {
3475
+ /** Agents participating in this turn */
3476
+ agentIds: string[];
3477
+ /** Initial message ID (required - turn.started schema mandates it) */
3478
+ messageId: string;
3479
+ /** Monotonic per-session ordinal (1-based), assigned by turn storage. */
3480
+ turnNumber: number;
3481
+ /** Optional pre-generated turn ID */
3482
+ turnId?: string;
3483
+ }
3484
+ /**
3485
+ * MakaioSession is the aggregate root for session state.
3486
+ *
3487
+ * It owns Turn[] children and emits lifecycle events from within,
3488
+ * mirroring the AIAgent pattern. Events are emitted when state changes,
3489
+ * not by external orchestration code.
3490
+ *
3491
+ * SEAM: This entity is designed to support future buildContext() method
3492
+ * for projecting raw history to effective history (transforms, token budgets).
3493
+ */
3494
+ declare class MakaioSession {
3495
+ readonly sessionId: string;
3496
+ readonly parentSessionId?: string;
3497
+ status: 'active' | 'closed' | 'archived';
3498
+ /** Turn children - owned by this aggregate */
3499
+ private readonly _turns;
3500
+ /** Track which turns have been completed */
3501
+ private readonly _completedTurnIds;
3502
+ /** Bus for event emission */
3503
+ protected readonly bus: IMakaioBus;
3504
+ constructor(config: MakaioSessionConfig);
3505
+ /**
3506
+ * Get turns owned by this session (read-only view).
3507
+ * @returns Immutable array of turns
3508
+ */
3509
+ get turns(): readonly Turn$1[];
3510
+ /**
3511
+ * Start a new turn in this session.
3512
+ *
3513
+ * Creates a Turn child entity and emits turn.started event.
3514
+ * This is the key pattern: state change + event emission happen together
3515
+ * inside the aggregate, not in external orchestration code.
3516
+ * @param options - Turn configuration
3517
+ * @returns The created Turn
3518
+ * @throws Error if session is not active (for example closed or archived)
3519
+ */
3520
+ startTurn(options: StartTurnOptions): Promise<Turn$1>;
3521
+ /**
3522
+ * Get the currently active (incomplete) turn.
3523
+ * @returns The active turn, or undefined if no turn is active
3524
+ */
3525
+ getActiveTurn(): Turn$1 | undefined;
3526
+ /**
3527
+ * Complete a turn and emit turn.completed event.
3528
+ * @param turn - The turn to complete
3529
+ */
3530
+ completeTurn(turn: Turn$1): Promise<void>;
3531
+ /**
3532
+ * Emit an event with sessionId auto-enriched.
3533
+ *
3534
+ * Mirrors AIAgent.emitGlobal pattern - entity emits its own events
3535
+ * with context automatically included.
3536
+ * @param subject - The subject to emit to
3537
+ * @param payload - The payload (without sessionId - it's added automatically)
3538
+ */
3539
+ protected emit<S extends SubjectDefinition>(subject: S, payload: Omit<ExtractSubjectPayload<S>, 'sessionId'>): Promise<void>;
3540
+ }
3541
+ //#endregion
3542
+ //#region packages/services/core/src/session/adapter-sessions/schema.d.ts
3543
+ /**
3544
+ * Adapter sessions table schema.
3545
+ *
3546
+ * Tracks sessions discovered from external adapter logs (e.g., Claude Code).
3547
+ * Stores lineage information with soft parent references that resolve
3548
+ * when all sessions in a fork chain are imported.
3549
+ */
3550
+ declare const adapterSessions: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
3551
+ name: "adapter_sessions";
3552
+ schema: undefined;
3553
+ columns: {
3554
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3555
+ name: "adapter_session_id";
3556
+ tableName: "adapter_sessions";
3557
+ dataType: "string";
3558
+ columnType: "SQLiteText";
3559
+ data: string;
3560
+ driverParam: string;
3561
+ notNull: true;
3562
+ hasDefault: false;
3563
+ isPrimaryKey: true;
3564
+ isAutoincrement: false;
3565
+ hasRuntimeDefault: false;
3566
+ enumValues: [string, ...string[]];
3567
+ baseColumn: never;
3568
+ identity: undefined;
3569
+ generated: undefined;
3570
+ }, {}, {
3571
+ length: number | undefined;
3572
+ }>;
3573
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3574
+ name: "adapter_name";
3575
+ tableName: "adapter_sessions";
3576
+ dataType: "string";
3577
+ columnType: "SQLiteText";
3578
+ data: string;
3579
+ driverParam: string;
3580
+ notNull: true;
3581
+ hasDefault: false;
3582
+ isPrimaryKey: false;
3583
+ isAutoincrement: false;
3584
+ hasRuntimeDefault: false;
3585
+ enumValues: [string, ...string[]];
3586
+ baseColumn: never;
3587
+ identity: undefined;
3588
+ generated: undefined;
3589
+ }, {}, {
3590
+ length: number | undefined;
3591
+ }>;
3592
+ parentAdapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3593
+ name: "parent_adapter_session_id";
3594
+ tableName: "adapter_sessions";
3595
+ dataType: "string";
3596
+ columnType: "SQLiteText";
3597
+ data: string;
3598
+ driverParam: string;
3599
+ notNull: false;
3600
+ hasDefault: false;
3601
+ isPrimaryKey: false;
3602
+ isAutoincrement: false;
3603
+ hasRuntimeDefault: false;
3604
+ enumValues: [string, ...string[]];
3605
+ baseColumn: never;
3606
+ identity: undefined;
3607
+ generated: undefined;
3608
+ }, {}, {
3609
+ length: number | undefined;
3610
+ }>;
3611
+ forkPointMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3612
+ name: "fork_point_message_id";
3613
+ tableName: "adapter_sessions";
3614
+ dataType: "string";
3615
+ columnType: "SQLiteText";
3616
+ data: string;
3617
+ driverParam: string;
3618
+ notNull: false;
3619
+ hasDefault: false;
3620
+ isPrimaryKey: false;
3621
+ isAutoincrement: false;
3622
+ hasRuntimeDefault: false;
3623
+ enumValues: [string, ...string[]];
3624
+ baseColumn: never;
3625
+ identity: undefined;
3626
+ generated: undefined;
3627
+ }, {}, {
3628
+ length: number | undefined;
3629
+ }>;
3630
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3631
+ name: "session_id";
3632
+ tableName: "adapter_sessions";
3633
+ dataType: "string";
3634
+ columnType: "SQLiteText";
3635
+ data: string;
3636
+ driverParam: string;
3637
+ notNull: false;
3638
+ hasDefault: false;
3639
+ isPrimaryKey: false;
3640
+ isAutoincrement: false;
3641
+ hasRuntimeDefault: false;
3642
+ enumValues: [string, ...string[]];
3643
+ baseColumn: never;
3644
+ identity: undefined;
3645
+ generated: undefined;
3646
+ }, {}, {
3647
+ length: number | undefined;
3648
+ }>;
3649
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3650
+ name: "model";
3651
+ tableName: "adapter_sessions";
3652
+ dataType: "string";
3653
+ columnType: "SQLiteText";
3654
+ data: string;
3655
+ driverParam: string;
3656
+ notNull: false;
3657
+ hasDefault: false;
3658
+ isPrimaryKey: false;
3659
+ isAutoincrement: false;
3660
+ hasRuntimeDefault: false;
3661
+ enumValues: [string, ...string[]];
3662
+ baseColumn: never;
3663
+ identity: undefined;
3664
+ generated: undefined;
3665
+ }, {}, {
3666
+ length: number | undefined;
3667
+ }>;
3668
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3669
+ name: "cwd";
3670
+ tableName: "adapter_sessions";
3671
+ dataType: "string";
3672
+ columnType: "SQLiteText";
3673
+ data: string;
3674
+ driverParam: string;
3675
+ notNull: false;
3676
+ hasDefault: false;
3677
+ isPrimaryKey: false;
3678
+ isAutoincrement: false;
3679
+ hasRuntimeDefault: false;
3680
+ enumValues: [string, ...string[]];
3681
+ baseColumn: never;
3682
+ identity: undefined;
3683
+ generated: undefined;
3684
+ }, {}, {
3685
+ length: number | undefined;
3686
+ }>;
3687
+ logFilePath: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3688
+ name: "log_file_path";
3689
+ tableName: "adapter_sessions";
3690
+ dataType: "string";
3691
+ columnType: "SQLiteText";
3692
+ data: string;
3693
+ driverParam: string;
3694
+ notNull: false;
3695
+ hasDefault: false;
3696
+ isPrimaryKey: false;
3697
+ isAutoincrement: false;
3698
+ hasRuntimeDefault: false;
3699
+ enumValues: [string, ...string[]];
3700
+ baseColumn: never;
3701
+ identity: undefined;
3702
+ generated: undefined;
3703
+ }, {}, {
3704
+ length: number | undefined;
3705
+ }>;
3706
+ kind: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3707
+ name: "kind";
3708
+ tableName: "adapter_sessions";
3709
+ dataType: "string";
3710
+ columnType: "SQLiteText";
3711
+ data: "root" | "fork" | "subagent" | "compress";
3712
+ driverParam: string;
3713
+ notNull: true;
3714
+ hasDefault: true;
3715
+ isPrimaryKey: false;
3716
+ isAutoincrement: false;
3717
+ hasRuntimeDefault: false;
3718
+ enumValues: ["root", "fork", "subagent", "compress"];
3719
+ baseColumn: never;
3720
+ identity: undefined;
3721
+ generated: undefined;
3722
+ }, {}, {
3723
+ length: number | undefined;
3724
+ }>;
3725
+ discoveredAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3726
+ name: "discovered_at";
3727
+ tableName: "adapter_sessions";
3728
+ dataType: "number";
3729
+ columnType: "SQLiteInteger";
3730
+ data: number;
3731
+ driverParam: number;
3732
+ notNull: true;
3733
+ hasDefault: false;
3734
+ isPrimaryKey: false;
3735
+ isAutoincrement: false;
3736
+ hasRuntimeDefault: false;
3737
+ enumValues: undefined;
3738
+ baseColumn: never;
3739
+ identity: undefined;
3740
+ generated: undefined;
3741
+ }, {}, {}>;
3742
+ startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3743
+ name: "started_at";
3744
+ tableName: "adapter_sessions";
3745
+ dataType: "number";
3746
+ columnType: "SQLiteInteger";
3747
+ data: number;
3748
+ driverParam: number;
3749
+ notNull: true;
3750
+ hasDefault: false;
3751
+ isPrimaryKey: false;
3752
+ isAutoincrement: false;
3753
+ hasRuntimeDefault: false;
3754
+ enumValues: undefined;
3755
+ baseColumn: never;
3756
+ identity: undefined;
3757
+ generated: undefined;
3758
+ }, {}, {}>;
3759
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3760
+ name: "status";
3761
+ tableName: "adapter_sessions";
3762
+ dataType: "string";
3763
+ columnType: "SQLiteText";
3764
+ data: "imported" | "discovered" | "live" | "tracking";
3765
+ driverParam: string;
3766
+ notNull: true;
3767
+ hasDefault: true;
3768
+ isPrimaryKey: false;
3769
+ isAutoincrement: false;
3770
+ hasRuntimeDefault: false;
3771
+ enumValues: ["discovered", "imported", "live", "tracking"];
3772
+ baseColumn: never;
3773
+ identity: undefined;
3774
+ generated: undefined;
3775
+ }, {}, {
3776
+ length: number | undefined;
3777
+ }>;
3778
+ };
3779
+ dialect: "sqlite";
3780
+ }>;
3781
+ /**
3782
+ * Type for inserting a new adapter session.
3783
+ */
3784
+ type InsertAdapterSession = typeof adapterSessions.$inferInsert;
3785
+ /**
3786
+ * Type for a selected adapter session row.
3787
+ */
3788
+ type SelectAdapterSession = typeof adapterSessions.$inferSelect;
3789
+ //#endregion
3790
+ //#region packages/services/core/src/session/adapter-sessions/namespace.d.ts
3791
+ /**
3792
+ * Shared Zod schema for the adapter session response object.
3793
+ *
3794
+ * Used by `get`, `getByLogFilePath`, and `list` responses.
3795
+ */
3796
+ declare const AdapterSessionResponseSchema: z.ZodObject<{
3797
+ adapterSessionId: z.ZodString;
3798
+ adapterName: z.ZodString;
3799
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
3800
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
3801
+ sessionId: z.ZodNullable<z.ZodString>;
3802
+ model: z.ZodNullable<z.ZodString>;
3803
+ cwd: z.ZodNullable<z.ZodString>;
3804
+ logFilePath: z.ZodNullable<z.ZodString>;
3805
+ discoveredAt: z.ZodNumber;
3806
+ startedAt: z.ZodNumber;
3807
+ status: z.ZodEnum<{
3808
+ imported: "imported";
3809
+ discovered: "discovered";
3810
+ live: "live";
3811
+ tracking: "tracking";
3812
+ }>;
3813
+ kind: z.ZodEnum<{
3814
+ root: "root";
3815
+ fork: "fork";
3816
+ subagent: "subagent";
3817
+ compress: "compress";
3818
+ }>;
3819
+ }, z.core.$strip>;
3820
+ declare const CreateAndLinkMetadataSchema: z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
3821
+ parentAdapterSessionId: z.ZodNull;
3822
+ forkPointMessageId: z.ZodNull;
3823
+ kind: z.ZodNull;
3824
+ }, z.core.$strip>, z.ZodObject<{
3825
+ kind: z.ZodLiteral<"fork">;
3826
+ parentAdapterSessionId: z.ZodString;
3827
+ forkPointMessageId: z.ZodString;
3828
+ }, z.core.$strip>, z.ZodObject<{
3829
+ kind: z.ZodLiteral<"subagent">;
3830
+ parentAdapterSessionId: z.ZodString;
3831
+ forkPointMessageId: z.ZodNull;
3832
+ }, z.core.$strip>, z.ZodObject<{
3833
+ kind: z.ZodLiteral<"compress">;
3834
+ parentAdapterSessionId: z.ZodString;
3835
+ forkPointMessageId: z.ZodNull;
3836
+ }, z.core.$strip>]>, z.ZodObject<{
3837
+ model: z.ZodNullable<z.ZodString>;
3838
+ cwd: z.ZodNullable<z.ZodString>;
3839
+ title: z.ZodNullable<z.ZodString>;
3840
+ }, z.core.$strip>>;
3841
+ /**
3842
+ * Inferred type for an adapter session record.
3843
+ *
3844
+ * Represents the full adapter session record as returned by `get`, `list`,
3845
+ * and `getByLogFilePath` bus subjects.
3846
+ */
3847
+ type AdapterSessionRecord = z.infer<typeof AdapterSessionResponseSchema>;
3848
+ type AdapterSessionStatus = z.infer<typeof AdapterSessionStatusSchema>;
3849
+ type CreateAndLinkMetadata = z.infer<typeof CreateAndLinkMetadataSchema>;
3850
+ /**
3851
+ * Adapter session storage namespace.
3852
+ *
3853
+ * Provides bus subjects for managing adapter session records.
3854
+ * Adapter sessions track sessions discovered from external adapter logs
3855
+ * (e.g., Claude Code) and maintain lineage information for fork detection.
3856
+ */
3857
+ declare const AdapterSessionStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDefinition<"adapterSession", {
3858
+ /**
3859
+ * Upsert an adapter session record.
3860
+ *
3861
+ * If the record exists, updates mutable fields (parent, forkPoint, model, cwd).
3862
+ * If not, inserts with discoveredAt=Date.now() and status='discovered'.
3863
+ *
3864
+ * Subject: `storage:adapterSession.upsert`
3865
+ * Type: Request (RPC)
3866
+ */
3867
+ upsert: {
3868
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
3869
+ adapterSessionId: z.ZodString;
3870
+ adapterName: z.ZodString;
3871
+ model: z.ZodNullable<z.ZodString>;
3872
+ cwd: z.ZodNullable<z.ZodString>;
3873
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3874
+ startedAt: z.ZodOptional<z.ZodNumber>;
3875
+ kind: z.ZodLiteral<"root">;
3876
+ parentAdapterSessionId: z.ZodNull;
3877
+ forkPointMessageId: z.ZodNull;
3878
+ }, z.core.$strip>, z.ZodObject<{
3879
+ adapterSessionId: z.ZodString;
3880
+ adapterName: z.ZodString;
3881
+ model: z.ZodNullable<z.ZodString>;
3882
+ cwd: z.ZodNullable<z.ZodString>;
3883
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3884
+ startedAt: z.ZodOptional<z.ZodNumber>;
3885
+ kind: z.ZodLiteral<"fork">;
3886
+ parentAdapterSessionId: z.ZodString;
3887
+ forkPointMessageId: z.ZodString;
3888
+ }, z.core.$strip>, z.ZodObject<{
3889
+ adapterSessionId: z.ZodString;
3890
+ adapterName: z.ZodString;
3891
+ model: z.ZodNullable<z.ZodString>;
3892
+ cwd: z.ZodNullable<z.ZodString>;
3893
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3894
+ startedAt: z.ZodOptional<z.ZodNumber>;
3895
+ kind: z.ZodLiteral<"subagent">;
3896
+ parentAdapterSessionId: z.ZodString;
3897
+ forkPointMessageId: z.ZodNull;
3898
+ }, z.core.$strip>, z.ZodObject<{
3899
+ adapterSessionId: z.ZodString;
3900
+ adapterName: z.ZodString;
3901
+ model: z.ZodNullable<z.ZodString>;
3902
+ cwd: z.ZodNullable<z.ZodString>;
3903
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3904
+ startedAt: z.ZodOptional<z.ZodNumber>;
3905
+ kind: z.ZodLiteral<"compress">;
3906
+ parentAdapterSessionId: z.ZodString;
3907
+ forkPointMessageId: z.ZodNull;
3908
+ }, z.core.$strip>], "kind">;
3909
+ response: z.ZodObject<{
3910
+ adapterSessionId: z.ZodString;
3911
+ sessionId: z.ZodNullable<z.ZodString>;
3912
+ created: z.ZodBoolean;
3913
+ }, z.core.$strip>;
3914
+ };
3915
+ /**
3916
+ * Get an adapter session by ID.
3917
+ *
3918
+ * Subject: `storage:adapterSession.get`
3919
+ * Type: Request (RPC)
3920
+ */
3921
+ get: {
3922
+ request: z.ZodObject<{
3923
+ adapterSessionId: z.ZodString;
3924
+ }, z.core.$strip>;
3925
+ response: z.ZodObject<{
3926
+ session: z.ZodNullable<z.ZodObject<{
3927
+ adapterSessionId: z.ZodString;
3928
+ adapterName: z.ZodString;
3929
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
3930
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
3931
+ sessionId: z.ZodNullable<z.ZodString>;
3932
+ model: z.ZodNullable<z.ZodString>;
3933
+ cwd: z.ZodNullable<z.ZodString>;
3934
+ logFilePath: z.ZodNullable<z.ZodString>;
3935
+ discoveredAt: z.ZodNumber;
3936
+ startedAt: z.ZodNumber;
3937
+ status: z.ZodEnum<{
3938
+ imported: "imported";
3939
+ discovered: "discovered";
3940
+ live: "live";
3941
+ tracking: "tracking";
3942
+ }>;
3943
+ kind: z.ZodEnum<{
3944
+ root: "root";
3945
+ fork: "fork";
3946
+ subagent: "subagent";
3947
+ compress: "compress";
3948
+ }>;
3949
+ }, z.core.$strip>>;
3950
+ }, z.core.$strip>;
3951
+ };
3952
+ /**
3953
+ * Update adapter session status.
3954
+ *
3955
+ * Subject: `storage:adapterSession.updateStatus`
3956
+ * Type: Request (RPC)
3957
+ */
3958
+ updateStatus: {
3959
+ request: z.ZodObject<{
3960
+ adapterSessionId: z.ZodString;
3961
+ status: z.ZodEnum<{
3962
+ imported: "imported";
3963
+ discovered: "discovered";
3964
+ live: "live";
3965
+ tracking: "tracking";
3966
+ }>;
3967
+ }, z.core.$strip>;
3968
+ response: z.ZodObject<{
3969
+ success: z.ZodBoolean;
3970
+ }, z.core.$strip>;
3971
+ };
3972
+ /**
3973
+ * Link an adapter session to a Makaio session.
3974
+ *
3975
+ * Subject: `storage:adapterSession.linkSession`
3976
+ * Type: Request (RPC)
3977
+ */
3978
+ linkSession: {
3979
+ request: z.ZodObject<{
3980
+ adapterSessionId: z.ZodString;
3981
+ sessionId: z.ZodString;
3982
+ }, z.core.$strip>;
3983
+ response: z.ZodObject<{
3984
+ success: z.ZodBoolean;
3985
+ }, z.core.$strip>;
3986
+ };
3987
+ /**
3988
+ * Get an adapter session by its source log file path.
3989
+ *
3990
+ * Subject: `storage:adapterSession.getByLogFilePath`
3991
+ * Type: Request (RPC)
3992
+ */
3993
+ getByLogFilePath: {
3994
+ request: z.ZodObject<{
3995
+ logFilePath: z.ZodString;
3996
+ }, z.core.$strip>;
3997
+ response: z.ZodObject<{
3998
+ session: z.ZodNullable<z.ZodObject<{
3999
+ adapterSessionId: z.ZodString;
4000
+ adapterName: z.ZodString;
4001
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
4002
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
4003
+ sessionId: z.ZodNullable<z.ZodString>;
4004
+ model: z.ZodNullable<z.ZodString>;
4005
+ cwd: z.ZodNullable<z.ZodString>;
4006
+ logFilePath: z.ZodNullable<z.ZodString>;
4007
+ discoveredAt: z.ZodNumber;
4008
+ startedAt: z.ZodNumber;
4009
+ status: z.ZodEnum<{
4010
+ imported: "imported";
4011
+ discovered: "discovered";
4012
+ live: "live";
4013
+ tracking: "tracking";
4014
+ }>;
4015
+ kind: z.ZodEnum<{
4016
+ root: "root";
4017
+ fork: "fork";
4018
+ subagent: "subagent";
4019
+ compress: "compress";
4020
+ }>;
4021
+ }, z.core.$strip>>;
4022
+ }, z.core.$strip>;
4023
+ };
4024
+ /**
4025
+ * List all adapter sessions.
4026
+ *
4027
+ * Returns all adapter session records ordered by startedAt descending.
4028
+ * Used by the entity cache to populate the reactive `adapterSessions` collection.
4029
+ *
4030
+ * Subject: `storage:adapterSession.list`
4031
+ * Type: Request (RPC)
4032
+ */
4033
+ list: {
4034
+ request: z.ZodObject<{}, z.core.$strip>;
4035
+ response: z.ZodObject<{
4036
+ sessions: z.ZodArray<z.ZodObject<{
4037
+ adapterSessionId: z.ZodString;
4038
+ adapterName: z.ZodString;
4039
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
4040
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
4041
+ sessionId: z.ZodNullable<z.ZodString>;
4042
+ model: z.ZodNullable<z.ZodString>;
4043
+ cwd: z.ZodNullable<z.ZodString>;
4044
+ logFilePath: z.ZodNullable<z.ZodString>;
4045
+ discoveredAt: z.ZodNumber;
4046
+ startedAt: z.ZodNumber;
4047
+ status: z.ZodEnum<{
4048
+ imported: "imported";
4049
+ discovered: "discovered";
4050
+ live: "live";
4051
+ tracking: "tracking";
4052
+ }>;
4053
+ kind: z.ZodEnum<{
4054
+ root: "root";
4055
+ fork: "fork";
4056
+ subagent: "subagent";
4057
+ compress: "compress";
4058
+ }>;
4059
+ }, z.core.$strip>>;
4060
+ }, z.core.$strip>;
4061
+ };
4062
+ /**
4063
+ * Count adapter sessions grouped by status.
4064
+ *
4065
+ * Subject: `storage:adapterSession.countByAdapter`
4066
+ * Type: Request (RPC)
4067
+ */
4068
+ countByAdapter: {
4069
+ request: z.ZodObject<{
4070
+ adapterName: z.ZodString;
4071
+ }, z.core.$strip>;
4072
+ response: z.ZodObject<{
4073
+ total: z.ZodNumber;
4074
+ imported: z.ZodNumber;
4075
+ discovered: z.ZodNumber;
4076
+ }, z.core.$strip>;
4077
+ };
4078
+ /**
4079
+ * Create and link a Makaio session for an adapter session.
4080
+ *
4081
+ * Consolidates session creation, parent/scope resolution, linking,
4082
+ * and event emission into a single idempotent bus request.
4083
+ * The bus field is injected by the handler — callers must not pass it.
4084
+ *
4085
+ * Subject: `storage:adapterSession.createAndLink`
4086
+ * Type: Request (RPC)
4087
+ */
4088
+ createAndLink: {
4089
+ request: z.ZodObject<{
4090
+ adapterSessionId: z.ZodString;
4091
+ adapterName: z.ZodString;
4092
+ adapterId: z.ZodString;
4093
+ metadata: z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
4094
+ parentAdapterSessionId: z.ZodNull;
4095
+ forkPointMessageId: z.ZodNull;
4096
+ kind: z.ZodNull;
4097
+ }, z.core.$strip>, z.ZodObject<{
4098
+ kind: z.ZodLiteral<"fork">;
4099
+ parentAdapterSessionId: z.ZodString;
4100
+ forkPointMessageId: z.ZodString;
4101
+ }, z.core.$strip>, z.ZodObject<{
4102
+ kind: z.ZodLiteral<"subagent">;
4103
+ parentAdapterSessionId: z.ZodString;
4104
+ forkPointMessageId: z.ZodNull;
4105
+ }, z.core.$strip>, z.ZodObject<{
4106
+ kind: z.ZodLiteral<"compress">;
4107
+ parentAdapterSessionId: z.ZodString;
4108
+ forkPointMessageId: z.ZodNull;
4109
+ }, z.core.$strip>]>, z.ZodObject<{
4110
+ model: z.ZodNullable<z.ZodString>;
4111
+ cwd: z.ZodNullable<z.ZodString>;
4112
+ title: z.ZodNullable<z.ZodString>;
4113
+ }, z.core.$strip>>;
4114
+ existingSessionId: z.ZodOptional<z.ZodString>;
4115
+ }, z.core.$strip>;
4116
+ response: z.ZodObject<{
4117
+ sessionId: z.ZodString;
4118
+ created: z.ZodBoolean;
4119
+ }, z.core.$strip>;
4120
+ };
4121
+ }, {
4122
+ drizzle: {
4123
+ adapterSessions: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
4124
+ name: "adapter_sessions";
4125
+ schema: undefined;
4126
+ columns: {
4127
+ adapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4128
+ name: "adapter_session_id";
4129
+ tableName: "adapter_sessions";
4130
+ dataType: "string";
4131
+ columnType: "SQLiteText";
4132
+ data: string;
4133
+ driverParam: string;
4134
+ notNull: true;
4135
+ hasDefault: false;
4136
+ isPrimaryKey: true;
4137
+ isAutoincrement: false;
4138
+ hasRuntimeDefault: false;
4139
+ enumValues: [string, ...string[]];
4140
+ baseColumn: never;
4141
+ identity: undefined;
4142
+ generated: undefined;
4143
+ }, {}, {
4144
+ length: number | undefined;
4145
+ }>;
4146
+ adapterName: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4147
+ name: "adapter_name";
4148
+ tableName: "adapter_sessions";
4149
+ dataType: "string";
4150
+ columnType: "SQLiteText";
4151
+ data: string;
4152
+ driverParam: string;
4153
+ notNull: true;
4154
+ hasDefault: false;
4155
+ isPrimaryKey: false;
4156
+ isAutoincrement: false;
4157
+ hasRuntimeDefault: false;
4158
+ enumValues: [string, ...string[]];
4159
+ baseColumn: never;
4160
+ identity: undefined;
4161
+ generated: undefined;
4162
+ }, {}, {
4163
+ length: number | undefined;
4164
+ }>;
4165
+ parentAdapterSessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4166
+ name: "parent_adapter_session_id";
4167
+ tableName: "adapter_sessions";
4168
+ dataType: "string";
4169
+ columnType: "SQLiteText";
4170
+ data: string;
4171
+ driverParam: string;
4172
+ notNull: false;
4173
+ hasDefault: false;
4174
+ isPrimaryKey: false;
4175
+ isAutoincrement: false;
4176
+ hasRuntimeDefault: false;
4177
+ enumValues: [string, ...string[]];
4178
+ baseColumn: never;
4179
+ identity: undefined;
4180
+ generated: undefined;
4181
+ }, {}, {
4182
+ length: number | undefined;
4183
+ }>;
4184
+ forkPointMessageId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4185
+ name: "fork_point_message_id";
4186
+ tableName: "adapter_sessions";
4187
+ dataType: "string";
4188
+ columnType: "SQLiteText";
4189
+ data: string;
4190
+ driverParam: string;
4191
+ notNull: false;
4192
+ hasDefault: false;
4193
+ isPrimaryKey: false;
4194
+ isAutoincrement: false;
4195
+ hasRuntimeDefault: false;
4196
+ enumValues: [string, ...string[]];
4197
+ baseColumn: never;
4198
+ identity: undefined;
4199
+ generated: undefined;
4200
+ }, {}, {
4201
+ length: number | undefined;
4202
+ }>;
4203
+ sessionId: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4204
+ name: "session_id";
4205
+ tableName: "adapter_sessions";
4206
+ dataType: "string";
4207
+ columnType: "SQLiteText";
4208
+ data: string;
4209
+ driverParam: string;
4210
+ notNull: false;
4211
+ hasDefault: false;
4212
+ isPrimaryKey: false;
4213
+ isAutoincrement: false;
4214
+ hasRuntimeDefault: false;
4215
+ enumValues: [string, ...string[]];
4216
+ baseColumn: never;
4217
+ identity: undefined;
4218
+ generated: undefined;
4219
+ }, {}, {
4220
+ length: number | undefined;
4221
+ }>;
4222
+ model: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4223
+ name: "model";
4224
+ tableName: "adapter_sessions";
4225
+ dataType: "string";
4226
+ columnType: "SQLiteText";
4227
+ data: string;
4228
+ driverParam: string;
4229
+ notNull: false;
4230
+ hasDefault: false;
4231
+ isPrimaryKey: false;
4232
+ isAutoincrement: false;
4233
+ hasRuntimeDefault: false;
4234
+ enumValues: [string, ...string[]];
4235
+ baseColumn: never;
4236
+ identity: undefined;
4237
+ generated: undefined;
4238
+ }, {}, {
4239
+ length: number | undefined;
4240
+ }>;
4241
+ cwd: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4242
+ name: "cwd";
4243
+ tableName: "adapter_sessions";
4244
+ dataType: "string";
4245
+ columnType: "SQLiteText";
4246
+ data: string;
4247
+ driverParam: string;
4248
+ notNull: false;
4249
+ hasDefault: false;
4250
+ isPrimaryKey: false;
4251
+ isAutoincrement: false;
4252
+ hasRuntimeDefault: false;
4253
+ enumValues: [string, ...string[]];
4254
+ baseColumn: never;
4255
+ identity: undefined;
4256
+ generated: undefined;
4257
+ }, {}, {
4258
+ length: number | undefined;
4259
+ }>;
4260
+ logFilePath: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4261
+ name: "log_file_path";
4262
+ tableName: "adapter_sessions";
4263
+ dataType: "string";
4264
+ columnType: "SQLiteText";
4265
+ data: string;
4266
+ driverParam: string;
4267
+ notNull: false;
4268
+ hasDefault: false;
4269
+ isPrimaryKey: false;
4270
+ isAutoincrement: false;
4271
+ hasRuntimeDefault: false;
4272
+ enumValues: [string, ...string[]];
4273
+ baseColumn: never;
4274
+ identity: undefined;
4275
+ generated: undefined;
4276
+ }, {}, {
4277
+ length: number | undefined;
4278
+ }>;
4279
+ kind: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4280
+ name: "kind";
4281
+ tableName: "adapter_sessions";
4282
+ dataType: "string";
4283
+ columnType: "SQLiteText";
4284
+ data: "root" | "fork" | "subagent" | "compress";
4285
+ driverParam: string;
4286
+ notNull: true;
4287
+ hasDefault: true;
4288
+ isPrimaryKey: false;
4289
+ isAutoincrement: false;
4290
+ hasRuntimeDefault: false;
4291
+ enumValues: ["root", "fork", "subagent", "compress"];
4292
+ baseColumn: never;
4293
+ identity: undefined;
4294
+ generated: undefined;
4295
+ }, {}, {
4296
+ length: number | undefined;
4297
+ }>;
4298
+ discoveredAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4299
+ name: "discovered_at";
4300
+ tableName: "adapter_sessions";
4301
+ dataType: "number";
4302
+ columnType: "SQLiteInteger";
4303
+ data: number;
4304
+ driverParam: number;
4305
+ notNull: true;
4306
+ hasDefault: false;
4307
+ isPrimaryKey: false;
4308
+ isAutoincrement: false;
4309
+ hasRuntimeDefault: false;
4310
+ enumValues: undefined;
4311
+ baseColumn: never;
4312
+ identity: undefined;
4313
+ generated: undefined;
4314
+ }, {}, {}>;
4315
+ startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4316
+ name: "started_at";
4317
+ tableName: "adapter_sessions";
4318
+ dataType: "number";
4319
+ columnType: "SQLiteInteger";
4320
+ data: number;
4321
+ driverParam: number;
4322
+ notNull: true;
4323
+ hasDefault: false;
4324
+ isPrimaryKey: false;
4325
+ isAutoincrement: false;
4326
+ hasRuntimeDefault: false;
4327
+ enumValues: undefined;
4328
+ baseColumn: never;
4329
+ identity: undefined;
4330
+ generated: undefined;
4331
+ }, {}, {}>;
4332
+ status: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
4333
+ name: "status";
4334
+ tableName: "adapter_sessions";
4335
+ dataType: "string";
4336
+ columnType: "SQLiteText";
4337
+ data: "imported" | "discovered" | "live" | "tracking";
4338
+ driverParam: string;
4339
+ notNull: true;
4340
+ hasDefault: true;
4341
+ isPrimaryKey: false;
4342
+ isAutoincrement: false;
4343
+ hasRuntimeDefault: false;
4344
+ enumValues: ["discovered", "imported", "live", "tracking"];
4345
+ baseColumn: never;
4346
+ identity: undefined;
4347
+ generated: undefined;
4348
+ }, {}, {
4349
+ length: number | undefined;
4350
+ }>;
4351
+ };
4352
+ dialect: "sqlite";
4353
+ }>;
4354
+ };
4355
+ }>;
4356
+ /**
4357
+ * Typed subjects for adapter session storage operations.
4358
+ */
4359
+ declare const AdapterSessionStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSubjectDefinitions<"storage:adapterSession", {
4360
+ /**
4361
+ * Upsert an adapter session record.
4362
+ *
4363
+ * If the record exists, updates mutable fields (parent, forkPoint, model, cwd).
4364
+ * If not, inserts with discoveredAt=Date.now() and status='discovered'.
4365
+ *
4366
+ * Subject: `storage:adapterSession.upsert`
4367
+ * Type: Request (RPC)
4368
+ */
4369
+ upsert: {
4370
+ request: z.ZodDiscriminatedUnion<[z.ZodObject<{
4371
+ adapterSessionId: z.ZodString;
4372
+ adapterName: z.ZodString;
4373
+ model: z.ZodNullable<z.ZodString>;
4374
+ cwd: z.ZodNullable<z.ZodString>;
4375
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4376
+ startedAt: z.ZodOptional<z.ZodNumber>;
4377
+ kind: z.ZodLiteral<"root">;
4378
+ parentAdapterSessionId: z.ZodNull;
4379
+ forkPointMessageId: z.ZodNull;
4380
+ }, z.core.$strip>, z.ZodObject<{
4381
+ adapterSessionId: z.ZodString;
4382
+ adapterName: z.ZodString;
4383
+ model: z.ZodNullable<z.ZodString>;
4384
+ cwd: z.ZodNullable<z.ZodString>;
4385
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4386
+ startedAt: z.ZodOptional<z.ZodNumber>;
4387
+ kind: z.ZodLiteral<"fork">;
4388
+ parentAdapterSessionId: z.ZodString;
4389
+ forkPointMessageId: z.ZodString;
4390
+ }, z.core.$strip>, z.ZodObject<{
4391
+ adapterSessionId: z.ZodString;
4392
+ adapterName: z.ZodString;
4393
+ model: z.ZodNullable<z.ZodString>;
4394
+ cwd: z.ZodNullable<z.ZodString>;
4395
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4396
+ startedAt: z.ZodOptional<z.ZodNumber>;
4397
+ kind: z.ZodLiteral<"subagent">;
4398
+ parentAdapterSessionId: z.ZodString;
4399
+ forkPointMessageId: z.ZodNull;
4400
+ }, z.core.$strip>, z.ZodObject<{
4401
+ adapterSessionId: z.ZodString;
4402
+ adapterName: z.ZodString;
4403
+ model: z.ZodNullable<z.ZodString>;
4404
+ cwd: z.ZodNullable<z.ZodString>;
4405
+ logFilePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4406
+ startedAt: z.ZodOptional<z.ZodNumber>;
4407
+ kind: z.ZodLiteral<"compress">;
4408
+ parentAdapterSessionId: z.ZodString;
4409
+ forkPointMessageId: z.ZodNull;
4410
+ }, z.core.$strip>], "kind">;
4411
+ response: z.ZodObject<{
4412
+ adapterSessionId: z.ZodString;
4413
+ sessionId: z.ZodNullable<z.ZodString>;
4414
+ created: z.ZodBoolean;
4415
+ }, z.core.$strip>;
4416
+ };
4417
+ /**
4418
+ * Get an adapter session by ID.
4419
+ *
4420
+ * Subject: `storage:adapterSession.get`
4421
+ * Type: Request (RPC)
4422
+ */
4423
+ get: {
4424
+ request: z.ZodObject<{
4425
+ adapterSessionId: z.ZodString;
4426
+ }, z.core.$strip>;
4427
+ response: z.ZodObject<{
4428
+ session: z.ZodNullable<z.ZodObject<{
4429
+ adapterSessionId: z.ZodString;
4430
+ adapterName: z.ZodString;
4431
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
4432
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
4433
+ sessionId: z.ZodNullable<z.ZodString>;
4434
+ model: z.ZodNullable<z.ZodString>;
4435
+ cwd: z.ZodNullable<z.ZodString>;
4436
+ logFilePath: z.ZodNullable<z.ZodString>;
4437
+ discoveredAt: z.ZodNumber;
4438
+ startedAt: z.ZodNumber;
4439
+ status: z.ZodEnum<{
4440
+ imported: "imported";
4441
+ discovered: "discovered";
4442
+ live: "live";
4443
+ tracking: "tracking";
4444
+ }>;
4445
+ kind: z.ZodEnum<{
4446
+ root: "root";
4447
+ fork: "fork";
4448
+ subagent: "subagent";
4449
+ compress: "compress";
4450
+ }>;
4451
+ }, z.core.$strip>>;
4452
+ }, z.core.$strip>;
4453
+ };
4454
+ /**
4455
+ * Update adapter session status.
4456
+ *
4457
+ * Subject: `storage:adapterSession.updateStatus`
4458
+ * Type: Request (RPC)
4459
+ */
4460
+ updateStatus: {
4461
+ request: z.ZodObject<{
4462
+ adapterSessionId: z.ZodString;
4463
+ status: z.ZodEnum<{
4464
+ imported: "imported";
4465
+ discovered: "discovered";
4466
+ live: "live";
4467
+ tracking: "tracking";
4468
+ }>;
4469
+ }, z.core.$strip>;
4470
+ response: z.ZodObject<{
4471
+ success: z.ZodBoolean;
4472
+ }, z.core.$strip>;
4473
+ };
4474
+ /**
4475
+ * Link an adapter session to a Makaio session.
4476
+ *
4477
+ * Subject: `storage:adapterSession.linkSession`
4478
+ * Type: Request (RPC)
4479
+ */
4480
+ linkSession: {
4481
+ request: z.ZodObject<{
4482
+ adapterSessionId: z.ZodString;
4483
+ sessionId: z.ZodString;
4484
+ }, z.core.$strip>;
4485
+ response: z.ZodObject<{
4486
+ success: z.ZodBoolean;
4487
+ }, z.core.$strip>;
4488
+ };
4489
+ /**
4490
+ * Get an adapter session by its source log file path.
4491
+ *
4492
+ * Subject: `storage:adapterSession.getByLogFilePath`
4493
+ * Type: Request (RPC)
4494
+ */
4495
+ getByLogFilePath: {
4496
+ request: z.ZodObject<{
4497
+ logFilePath: z.ZodString;
4498
+ }, z.core.$strip>;
4499
+ response: z.ZodObject<{
4500
+ session: z.ZodNullable<z.ZodObject<{
4501
+ adapterSessionId: z.ZodString;
4502
+ adapterName: z.ZodString;
4503
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
4504
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
4505
+ sessionId: z.ZodNullable<z.ZodString>;
4506
+ model: z.ZodNullable<z.ZodString>;
4507
+ cwd: z.ZodNullable<z.ZodString>;
4508
+ logFilePath: z.ZodNullable<z.ZodString>;
4509
+ discoveredAt: z.ZodNumber;
4510
+ startedAt: z.ZodNumber;
4511
+ status: z.ZodEnum<{
4512
+ imported: "imported";
4513
+ discovered: "discovered";
4514
+ live: "live";
4515
+ tracking: "tracking";
4516
+ }>;
4517
+ kind: z.ZodEnum<{
4518
+ root: "root";
4519
+ fork: "fork";
4520
+ subagent: "subagent";
4521
+ compress: "compress";
4522
+ }>;
4523
+ }, z.core.$strip>>;
4524
+ }, z.core.$strip>;
4525
+ };
4526
+ /**
4527
+ * List all adapter sessions.
4528
+ *
4529
+ * Returns all adapter session records ordered by startedAt descending.
4530
+ * Used by the entity cache to populate the reactive `adapterSessions` collection.
4531
+ *
4532
+ * Subject: `storage:adapterSession.list`
4533
+ * Type: Request (RPC)
4534
+ */
4535
+ list: {
4536
+ request: z.ZodObject<{}, z.core.$strip>;
4537
+ response: z.ZodObject<{
4538
+ sessions: z.ZodArray<z.ZodObject<{
4539
+ adapterSessionId: z.ZodString;
4540
+ adapterName: z.ZodString;
4541
+ parentAdapterSessionId: z.ZodNullable<z.ZodString>;
4542
+ forkPointMessageId: z.ZodNullable<z.ZodString>;
4543
+ sessionId: z.ZodNullable<z.ZodString>;
4544
+ model: z.ZodNullable<z.ZodString>;
4545
+ cwd: z.ZodNullable<z.ZodString>;
4546
+ logFilePath: z.ZodNullable<z.ZodString>;
4547
+ discoveredAt: z.ZodNumber;
4548
+ startedAt: z.ZodNumber;
4549
+ status: z.ZodEnum<{
4550
+ imported: "imported";
4551
+ discovered: "discovered";
4552
+ live: "live";
4553
+ tracking: "tracking";
4554
+ }>;
4555
+ kind: z.ZodEnum<{
4556
+ root: "root";
4557
+ fork: "fork";
4558
+ subagent: "subagent";
4559
+ compress: "compress";
4560
+ }>;
4561
+ }, z.core.$strip>>;
4562
+ }, z.core.$strip>;
4563
+ };
4564
+ /**
4565
+ * Count adapter sessions grouped by status.
4566
+ *
4567
+ * Subject: `storage:adapterSession.countByAdapter`
4568
+ * Type: Request (RPC)
4569
+ */
4570
+ countByAdapter: {
4571
+ request: z.ZodObject<{
4572
+ adapterName: z.ZodString;
4573
+ }, z.core.$strip>;
4574
+ response: z.ZodObject<{
4575
+ total: z.ZodNumber;
4576
+ imported: z.ZodNumber;
4577
+ discovered: z.ZodNumber;
4578
+ }, z.core.$strip>;
4579
+ };
4580
+ /**
4581
+ * Create and link a Makaio session for an adapter session.
4582
+ *
4583
+ * Consolidates session creation, parent/scope resolution, linking,
4584
+ * and event emission into a single idempotent bus request.
4585
+ * The bus field is injected by the handler — callers must not pass it.
4586
+ *
4587
+ * Subject: `storage:adapterSession.createAndLink`
4588
+ * Type: Request (RPC)
4589
+ */
4590
+ createAndLink: {
4591
+ request: z.ZodObject<{
4592
+ adapterSessionId: z.ZodString;
4593
+ adapterName: z.ZodString;
4594
+ adapterId: z.ZodString;
4595
+ metadata: z.ZodIntersection<z.ZodUnion<readonly [z.ZodObject<{
4596
+ parentAdapterSessionId: z.ZodNull;
4597
+ forkPointMessageId: z.ZodNull;
4598
+ kind: z.ZodNull;
4599
+ }, z.core.$strip>, z.ZodObject<{
4600
+ kind: z.ZodLiteral<"fork">;
4601
+ parentAdapterSessionId: z.ZodString;
4602
+ forkPointMessageId: z.ZodString;
4603
+ }, z.core.$strip>, z.ZodObject<{
4604
+ kind: z.ZodLiteral<"subagent">;
4605
+ parentAdapterSessionId: z.ZodString;
4606
+ forkPointMessageId: z.ZodNull;
4607
+ }, z.core.$strip>, z.ZodObject<{
4608
+ kind: z.ZodLiteral<"compress">;
4609
+ parentAdapterSessionId: z.ZodString;
4610
+ forkPointMessageId: z.ZodNull;
4611
+ }, z.core.$strip>]>, z.ZodObject<{
4612
+ model: z.ZodNullable<z.ZodString>;
4613
+ cwd: z.ZodNullable<z.ZodString>;
4614
+ title: z.ZodNullable<z.ZodString>;
4615
+ }, z.core.$strip>>;
4616
+ existingSessionId: z.ZodOptional<z.ZodString>;
4617
+ }, z.core.$strip>;
4618
+ response: z.ZodObject<{
4619
+ sessionId: z.ZodString;
4620
+ created: z.ZodBoolean;
4621
+ }, z.core.$strip>;
4622
+ };
4623
+ }>, "storage:adapterSession">;
4624
+ //#endregion
4625
+ //#region packages/services/core/src/session/adapter-sessions/drizzle-handler.d.ts
4626
+ /**
4627
+ * Register Drizzle-based adapter session storage handlers.
4628
+ *
4629
+ * Manages adapter session persistence in SQLite/libSQL via Drizzle ORM.
4630
+ * Adapter sessions track sessions discovered from external adapter logs
4631
+ * and maintain lineage information for fork detection.
4632
+ * @param bus - The bus instance to register handlers on
4633
+ * @param db - The Drizzle database instance
4634
+ * @param _ctx - Extension context (unused; reserved for future use)
4635
+ * @returns Cleanup function to unsubscribe all handlers
4636
+ */
4637
+ declare function registerDrizzleAdapterSessionStorage(bus: IMakaioBus, db: MakaioDatabase, _ctx: ExtensionContext): () => void;
4638
+ //#endregion
4639
+ //#region packages/services/core/src/session/adapter-sessions/handlers.d.ts
4640
+ /**
4641
+ * Parameters for the unified session creation and linking helper.
4642
+ */
4643
+ interface CreateAndLinkParams {
4644
+ /** Bus instance for storage writes and lifecycle emissions. */
4645
+ bus: IMakaioBus;
4646
+ /** Adapter-specific session identifier. */
4647
+ adapterSessionId: string;
4648
+ /** Adapter type name (e.g., 'claude-code'). */
4649
+ adapterName: string;
4650
+ /** Adapter instance ID (machine/installation specific). */
4651
+ adapterId: string;
4652
+ /** Session metadata from the adapter. */
4653
+ metadata: CreateAndLinkMetadata;
4654
+ /** Existing Makaio sessionId to reuse (e.g., from discovery stub). */
4655
+ existingSessionId?: string;
4656
+ }
4657
+ /**
4658
+ * Result returned from {@link createAndLinkImportedSession}.
4659
+ */
4660
+ interface CreateAndLinkResult {
4661
+ /** The Makaio session ID (either newly created or pre-existing). */
4662
+ sessionId: string;
4663
+ /** Whether a new session record was created during this call. */
4664
+ created: boolean;
4665
+ }
4666
+ /**
4667
+ * Unified helper that creates and links a Makaio session for an adapter session.
4668
+ *
4669
+ * Consolidates both the discovery path (`registerSessionDiscoveredHandler`) and the
4670
+ * import path into a single authoritative flow:
4671
+ *
4672
+ * 1. Early-exit if the adapter session is already linked (idempotent).
4673
+ * 2. Eagerly resolve `parentSessionId`/`rootSessionId` via `resolveLineage`.
4674
+ * 3. Create the Makaio session record via `SessionStorageSubjects.set` with `ifAbsent`.
4675
+ * 4. Link, emit `SessionSubjects.created`, and clean up on failure via `linkAndEmit`.
4676
+ * @param params - Parameters for the unified session creation/linking flow.
4677
+ * @returns The session ID and whether a new record was created.
4678
+ */
4679
+ declare function createAndLinkImportedSession(params: CreateAndLinkParams): Promise<CreateAndLinkResult>;
4680
+ /**
4681
+ * Register a bus handler for the `createAndLink` subject.
4682
+ *
4683
+ * Exposes {@link createAndLinkImportedSession} as a bus RPC so cross-package
4684
+ * callers (e.g., `@makaio/services-log-import`) can invoke it without a
4685
+ * direct import dependency on `@makaio/services-core/session`.
4686
+ * @param bus - The bus instance to register the handler on
4687
+ * @returns Cleanup function to unsubscribe the handler
4688
+ */
4689
+ declare function registerCreateAndLinkHandler(bus: IMakaioBus): () => void;
4690
+ /**
4691
+ * Register handler for adapter.session.discovered events.
4692
+ *
4693
+ * When a session is discovered from log import:
4694
+ * 1. Upsert adapter_sessions record with lineage info and log file path
4695
+ * 2. Create and link a Makaio session with all available metadata via the unified helper
4696
+ * @param bus - The bus instance to register handlers on
4697
+ * @returns Cleanup function to unsubscribe the handler
4698
+ */
4699
+ declare function registerSessionDiscoveredHandler(bus: IMakaioBus): () => void;
4700
+ //#endregion
4701
+ //#region packages/services/core/src/session/adapter-sessions/parent-resolver.d.ts
4702
+ /**
4703
+ * Register handler to resolve parent relationships when sessions are linked.
4704
+ *
4705
+ * When `adapter.session.linked` is emitted:
4706
+ * 1. Query adapter_sessions for children referencing this adapterSessionId as parent
4707
+ * 2. For each child with a linked sessionId, update the child's Makaio session parentSessionId
4708
+ * @param bus - The bus instance to register handlers on
4709
+ * @param db - The Drizzle database instance for direct queries
4710
+ * @returns Cleanup function to unsubscribe the handler
4711
+ * @example
4712
+ * ```typescript
4713
+ * import { registerParentResolver } from '@makaio/framework/services/session';
4714
+ *
4715
+ * const cleanup = registerParentResolver(bus, db);
4716
+ *
4717
+ * // Later, when shutting down:
4718
+ * cleanup();
4719
+ * ```
4720
+ */
4721
+ declare function registerParentResolver(bus: IMakaioBus, db: MakaioDatabase): () => void;
4722
+ //#endregion
4723
+ //#region packages/services/core/src/session/adapter-sessions/compress-lineage-resolver.d.ts
4724
+ /**
4725
+ * Re-parents post-compaction subagents from the parent session to the compress child.
4726
+ *
4727
+ * Handles two scenarios triggered by `adapter.session.linked`:
4728
+ *
4729
+ * **Path A — compress child linked first (batch import)**:
4730
+ * When a compress child is linked, subagents spawned after compaction are
4731
+ * already parented to the parent Makaio session (by the parent-resolver).
4732
+ * This path scans the compress child's messages and re-parents matching subagents.
4733
+ *
4734
+ * **Path B — subagent linked after compress child (incremental / separate files)**:
4735
+ * When a subagent is linked and its parent has compress children, the compress
4736
+ * children and their messages already exist. This path scans those compress
4737
+ * children for the subagent's spawning tool_call and re-parents when found.
4738
+ *
4739
+ * Must be registered BEFORE registerSpawningToolCallResolver so it runs
4740
+ * first on `adapter.session.linked` (bus handlers fire in registration order).
4741
+ * @param bus - The bus instance to register handlers on
4742
+ * @returns Cleanup function to unsubscribe the handler
4743
+ * @example
4744
+ * ```typescript
4745
+ * import { registerCompressLineageResolver } from '@makaio/framework/services/session';
4746
+ *
4747
+ * const cleanup = registerCompressLineageResolver(bus);
4748
+ *
4749
+ * // Later, when shutting down:
4750
+ * cleanup();
4751
+ * ```
4752
+ */
4753
+ declare function registerCompressLineageResolver(bus: IMakaioBus): () => void;
4754
+ //#endregion
4755
+ //#region packages/services/core/src/session/adapter-sessions/spawning-tool-call-resolver.d.ts
4756
+ /**
4757
+ * Register handler to backfill `spawningToolCallId` for imported subagent sessions.
4758
+ *
4759
+ * When `adapter.session.linked` is emitted:
4760
+ * 1. Fetch children of the newly linked parent session.
4761
+ * 2. Filter to subagent children with no `spawningToolCallId`.
4762
+ * 3. Fetch parent session messages and scan for Agent/spawn_subagent tool_call blocks.
4763
+ * 4. Match each unmatched child to a tool_call by tool_output content reference
4764
+ * (session ID in output string). Unmatched children are left as null.
4765
+ * 5. Update matched children via `SessionStorageSubjects.update`.
4766
+ * @param bus - The bus instance to register handlers on
4767
+ * @returns Cleanup function to unsubscribe the handler
4768
+ * @example
4769
+ * ```typescript
4770
+ * import { registerSpawningToolCallResolver } from '@makaio/framework/services/session';
4771
+ *
4772
+ * const cleanup = registerSpawningToolCallResolver(bus);
4773
+ *
4774
+ * // Later, when shutting down:
4775
+ * cleanup();
4776
+ * ```
4777
+ */
4778
+ declare function registerSpawningToolCallResolver(bus: IMakaioBus): () => void;
4779
+ //#endregion
4780
+ //#region packages/services/core/src/session/adapter-sessions/lineage-utils.d.ts
4781
+ /**
4782
+ * Maps adapter-level session lineage kind to Makaio session branch kind.
4783
+ * Root sessions have no branch kind (undefined).
4784
+ * @param kind - The adapter session's lineage kind
4785
+ * @returns The corresponding BranchKind, or undefined for root sessions
4786
+ */
4787
+ declare function kindToBranchKind(kind: SessionLineageKind): BranchKind | undefined;
4788
+ //#endregion
4789
+ //#region packages/services/core/src/session/context/types.d.ts
4790
+ /**
4791
+ * Options for building session context.
4792
+ */
4793
+ interface BuildContextOptions {
4794
+ /** Session ID to build context for */
4795
+ sessionId: string;
4796
+ /** Maximum messages to return (for token budgeting, default: no limit) */
4797
+ limit?: number;
4798
+ }
4799
+ /**
4800
+ * Result of context assembly.
4801
+ */
4802
+ interface ContextAssemblyResult {
4803
+ /** Assembled messages in chronological order */
4804
+ messages: SessionMessage[];
4805
+ /** Whether a squash boundary was encountered */
4806
+ hasSquashBoundary: boolean;
4807
+ /** Sessions traversed (for debugging) */
4808
+ sessionChain: string[];
4809
+ /** Whether results were truncated due to limit or pagination */
4810
+ truncated: boolean;
4811
+ /** Whether parent chain is incomplete (missing session in ancestry) */
4812
+ incomplete: boolean;
4813
+ }
4814
+ //#endregion
4815
+ //#region packages/services/core/src/session/context/build-context.d.ts
4816
+ /**
4817
+ * Build context for a single session by walking session_events.
4818
+ *
4819
+ * Respects squash boundaries: if a squash event is encountered,
4820
+ * messages before it are replaced with the summary.
4821
+ * Paginates through all events until no more cursors or message limit is reached.
4822
+ * @param bus - Bus instance for RPC calls
4823
+ * @param options - Build context options
4824
+ * @returns Assembled context result
4825
+ */
4826
+ declare function buildSessionContext(bus: IMakaioBus, options: BuildContextOptions): Promise<ContextAssemblyResult>;
4827
+ //#endregion
4828
+ //#region packages/services/core/src/session/context/get-full-conversation.d.ts
4829
+ /**
4830
+ * Get full conversation for a session, traversing parent chain.
4831
+ *
4832
+ * For forked sessions, this walks up the parent chain and assembles
4833
+ * messages from each ancestor, respecting forkPointMessageId boundaries.
4834
+ *
4835
+ * IMPORTANT: forkPointMessageId must be a Makaio message ID (not adapter ID).
4836
+ * Normalization happens at adapter session link time.
4837
+ * @param bus - Bus instance for RPC calls
4838
+ * @param sessionId - Session to get conversation for
4839
+ * @returns Full conversation with lineage
4840
+ */
4841
+ declare function getFullConversation(bus: IMakaioBus, sessionId: string): Promise<ContextAssemblyResult>;
4842
+ //#endregion
4843
+ export { mapAgentsBySession as $, extractTextContent as $t, MessageRoutingSubjects as A, registerBuiltInActions as At, registerDrizzleTurnStorage as B, RecoveryConfig as Bt, MakaioSessionConfig as C, assembleForkContext as Ct, messageRouting as D, normalizeSelectionString as Dt, SelectMessageRouting as E, CONNECTOR_SWAP_DEFAULT_PIPELINE as Et, registerDrizzleMessageStorage as F, ContextWindowTracker as Ft, SessionLoggerOptions as G, verifyAndRecoverAgents as Gt, importCursors as H, ensureAgentCwd as Ht, InsertTurn as I, AgentContextState as It, InsertSessionEvent as J, resolveExecutionTarget as Jt, registerDrizzleSessionEventStorage as K, buildRecoveryContext as Kt, SelectTurn as L, ContextWindowTrackerConfig as Lt, SelectMessage as M, actionRegistry as Mt, messages as N, registerGetStatusCountsHandler as Nt, registerDrizzleMessageRoutingStorage as O, resolveAdapterNameById as Ot, registerMemoryMessageStorage as P, registerResumeHandler as Pt, fetchSessionPreviewMaps as Q, resolveTargetAgents as Qt, turns as R, SessionContextWindowState as Rt, MakaioSession as S, createAttachmentArtifacts as St, InsertMessageRouting as T, pickFallbackRuntimeOptions as Tt, EventTransform as U, ensureAgentModel as Ut, registerDrizzleImportCursorStorage as V, buildRecoveryContextWithPipeline as Vt, SessionLogger as W, recoverAgent as Wt, sessionEvents as X, findTurnByAgent as Xt, SelectSessionEvent as Y, resolveModelCapabilities as Yt, SessionPreviewMaps as Z, getOrCreateSession as Zt, AdapterSessionStorageNamespace as _, SessionBridge as _t, kindToBranchKind as a, registerCoreSessionServiceHandlers as an, fetchPreviewBySession as at, SelectAdapterSession as b, StoreArtifactFn as bt, registerParentResolver as c, registerFtsSearchHandler as ct, createAndLinkImportedSession as d, registerDrizzleSessionStorage as dt, normalizeToBlocks as en, mapToSession as et, registerCreateAndLinkHandler as f, registerMemorySessionStorage as ft, AdapterSessionStatus as g, createSessionExtensionContext as gt, AdapterSessionRecord as h, SessionExtensionContextImpl as ht, ContextAssemblyResult as i, SessionOrchestrator as in, fetchMessageCountsBySession as it, InsertMessage as j, resetBuiltInActionsRegistration as jt, MessageRoutingNamespace as k, registerListActionsHandler as kt, CreateAndLinkParams as l, registerDrizzleAgentStorage as lt, registerDrizzleAdapterSessionStorage as m, AgentStorageSubjects as mt, buildSessionContext as n, AdapterRegistry as nn, SearchSessionRow as nt, registerSpawningToolCallResolver as o, MakaioSessionService as on, mapRowToSession as ot, registerSessionDiscoveredHandler as p, AgentStorageNamespace as pt, registerMemorySessionEventStorage as q, resolveAdapterId as qt, BuildContextOptions as r, ISessionOrchestrator as rn, fetchAgentsBySession as rt, registerCompressLineageResolver as s, parseForkTransforms as st, getFullConversation as t, TurnContextEnricher as tn, SearchFilters as tt, CreateAndLinkResult as u, registerMemoryAgentStorage as ut, AdapterSessionStorageSubjects as v, AttachmentArtifactInput as vt, StartTurnOptions as w, FallbackRuntimeOptions as wt, adapterSessions as x, StoreArtifactResult as xt, InsertAdapterSession as y, AttachmentArtifactMetadata as yt, registerMemoryTurnStorage as z, buildTurnInitiator as zt };