@makaio/framework 1.0.0-dev-1781117225170 → 1.0.0-dev-1781260968078

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 (315) hide show
  1. package/README.md +29 -0
  2. package/dist/.makaio-build.json +2 -2
  3. package/dist/adapters/config/index.d.mts +1 -1
  4. package/dist/adapters/config/index.mjs +1 -1
  5. package/dist/adapters/index.d.mts +3 -3
  6. package/dist/adapters/index.mjs +1 -1
  7. package/dist/adapters/node.d.mts +1 -1
  8. package/dist/adapters/node.mjs +1 -1
  9. package/dist/bus/index.mjs +1 -1
  10. package/dist/client-BJVDImPV.d.mts +175 -0
  11. package/dist/clients/index.d.mts +105 -2
  12. package/dist/clients/index.mjs +2 -2
  13. package/dist/contracts/adapter/index.d.mts +2 -2
  14. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  15. package/dist/contracts/artifact/index.d.mts +1 -1
  16. package/dist/contracts/client/index.d.mts +2 -2
  17. package/dist/contracts/common/index.d.mts +1 -1
  18. package/dist/contracts/config/index.d.mts +1 -1
  19. package/dist/contracts/extension/index.d.mts +4 -4
  20. package/dist/contracts/extension/index.mjs +1 -1
  21. package/dist/contracts/facet/index.d.mts +1 -1
  22. package/dist/contracts/harness/index.d.mts +1 -1
  23. package/dist/contracts/host/index.d.mts +1 -1
  24. package/dist/contracts/index.d.mts +575 -62
  25. package/dist/contracts/index.mjs +1 -1
  26. package/dist/contracts/materialization/index.d.mts +3 -3
  27. package/dist/contracts/model-registry/index.d.mts +1 -1
  28. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  29. package/dist/contracts/platform/index.d.mts +1 -1
  30. package/dist/contracts/provider/index.d.mts +2 -2
  31. package/dist/contracts/session/index.d.mts +2 -2
  32. package/dist/contracts/shared/index.d.mts +1 -1
  33. package/dist/contracts/skill/index.d.mts +1 -1
  34. package/dist/contracts/telemetry/index.d.mts +1 -1
  35. package/dist/contracts/timeout/index.d.mts +1 -1
  36. package/dist/contracts/variant/index.d.mts +1 -1
  37. package/dist/{definition-Cp-5xJp_.d.mts → definition-SiimP25_.d.mts} +1 -1
  38. package/dist/{detached-extension-handle-oXbjv1tA.mjs → detached-extension-handle-Diiwgm13.mjs} +1 -1
  39. package/dist/drizzle/0001_messages_content_tsv.na.md +18 -0
  40. package/dist/drizzle/0012_legal_kate_bishop.sql +3 -0
  41. package/dist/drizzle/0013_eager_rhodey.sql +56 -0
  42. package/dist/drizzle/0014_fancy_ultimo.sql +1 -0
  43. package/dist/drizzle/meta/0012_snapshot.json +2934 -0
  44. package/dist/drizzle/meta/0013_snapshot.json +2954 -0
  45. package/dist/drizzle/meta/0014_snapshot.json +2959 -0
  46. package/dist/drizzle/meta/_journal.json +21 -0
  47. package/dist/drizzle-wjquQK2m.mjs +1 -0
  48. package/dist/extension-DfNcE0zm.mjs +1 -0
  49. package/dist/extension-ZBN4BGre.mjs +1 -0
  50. package/dist/{filesystem-service-CBJT7A5w.mjs → filesystem-service-BjfrUmGS.mjs} +1 -1
  51. package/dist/{globby-C0lgTOUl.mjs → globby-BIH65cbN.mjs} +1 -1
  52. package/dist/handler-DSfSAlxx.mjs +1 -0
  53. package/dist/handlers-C8EtpSqK.mjs +41 -0
  54. package/dist/{index-DfUBcVtG.d.mts → index-B2xbnMZe.d.mts} +1 -1
  55. package/dist/{index-uQl_1wQO.d.mts → index-BAhJKQLX.d.mts} +8 -8
  56. package/dist/{index-i7o6FtS0.d.mts → index-BDRKAxIV.d.mts} +129 -2
  57. package/dist/{index-kLBWooVu.d.mts → index-BQiHs8EF.d.mts} +12 -12
  58. package/dist/{index-SFkbbDxs.d.mts → index-BYkOUd0x.d.mts} +1 -1
  59. package/dist/{index-C1uZLARQ.d.mts → index-BvSyOgTY.d.mts} +1314 -46
  60. package/dist/{index-Bw8SkcWG.d.mts → index-Bw_zL7Rs.d.mts} +1 -1
  61. package/dist/{index-CXfWW8cP.d.mts → index-CARxIllg.d.mts} +7 -7
  62. package/dist/{index-t9Vt4Jbb.d.mts → index-Cb64d5c5.d.mts} +6 -6
  63. package/dist/{index-hWzUQtDn.d.mts → index-CgjslA5-.d.mts} +92 -19
  64. package/dist/{index-ClgVA8Rz.d.mts → index-D5CI1V5d.d.mts} +22 -22
  65. package/dist/{index-BY-fz0Jy.d.mts → index-DDQkhhRo.d.mts} +149 -141
  66. package/dist/{index-v2kRZnfw2.d.mts → index-DTdqGAfH2.d.mts} +20 -10
  67. package/dist/{index-CT-zFurA.d.mts → index-Drz_a7kW.d.mts} +1 -1
  68. package/dist/{index-BELri1Hy.d.mts → index-IekAD8Gp.d.mts} +8 -8
  69. package/dist/{index-C_jIVT40.d.mts → index-fVgKVvta.d.mts} +1 -1
  70. package/dist/kernel/cli/index.d.mts +2 -2
  71. package/dist/kernel/cli/register.d.mts +1 -1
  72. package/dist/kernel/extension/index.d.mts +1 -1
  73. package/dist/kernel/extension/index.mjs +1 -1
  74. package/dist/kernel/index.d.mts +5 -5
  75. package/dist/kernel/index.mjs +1 -1
  76. package/dist/kernel/namespace/index.d.mts +1 -1
  77. package/dist/kernel/observability/index.d.mts +1 -1
  78. package/dist/kernel/providers/index.d.mts +1 -1
  79. package/dist/kernel/window/index.d.mts +1 -1
  80. package/dist/{lib-zuQKc8ym.mjs → lib-Cq5R6Tx9.mjs} +1 -1
  81. package/dist/{lib-IkUYa2Qs.mjs → lib-nlcl5kRW.mjs} +1 -1
  82. package/dist/{load-extensions-DE8qDIqi.d.mts → load-extensions-D9nbDIiW.d.mts} +1 -1
  83. package/dist/{load-extensions-CwxilDj1.mjs → load-extensions-wELQ4BBN.mjs} +1 -1
  84. package/dist/mcp-http-server/index.mjs +1 -1
  85. package/dist/{namespace-CZPu_jvy.d.mts → namespace-7tsuJhQ9.d.mts} +66 -66
  86. package/dist/{namespace-ffepZB8Y.d.mts → namespace-B73Sxj5L.d.mts} +6 -6
  87. package/dist/{namespace-Da_dHfdm.d.mts → namespace-Ba4bxtHQ.d.mts} +11 -11
  88. package/dist/{namespace-DvHoeMUV.d.mts → namespace-DDCjoQUj.d.mts} +3 -3
  89. package/dist/namespace-DwE2g8Wm.mjs +1 -0
  90. package/dist/node/bus-server/index.d.mts +1 -1
  91. package/dist/node/bus-server/index.mjs +1 -1
  92. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  93. package/dist/node/bus-server/server-lifecycle.mjs +1 -1
  94. package/dist/{orchestrator-shared-FnWrPS09.mjs → orchestrator-shared-Dt4WDse7.mjs} +1 -1
  95. package/dist/package-Be2Ez4vv.mjs +1 -0
  96. package/dist/package.json +1 -1
  97. package/dist/primitive-runtime-Xrc9xh6p.mjs +1 -0
  98. package/dist/registry-RG-bkw3c.mjs +146 -0
  99. package/dist/rules/index.d.mts +1 -1
  100. package/dist/rules/index.mjs +1 -1
  101. package/dist/rules/schemas.d.mts +1 -1
  102. package/dist/runtime-bun/index.mjs +1 -1
  103. package/dist/runtime-node/extension-discovery.d.mts +1 -1
  104. package/dist/runtime-node/extension-validation.d.mts +1 -1
  105. package/dist/runtime-node/extension-validation.mjs +1 -1
  106. package/dist/runtime-node/index.d.mts +59 -38
  107. package/dist/runtime-node/index.mjs +26 -53
  108. package/dist/runtime-node/makaio-config.d.mts +1 -1
  109. package/dist/runtime-node/makaio-config.mjs +1 -1
  110. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  111. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  112. package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
  113. package/dist/{schema-CfuF2cXW.d.mts → schema-BNrM9LWb.d.mts} +218 -12
  114. package/dist/schema-BerZmr2q.mjs +1 -0
  115. package/dist/schema-BrnYlDwZ.mjs +1 -0
  116. package/dist/{schemas-SPI-Y87l2.d.mts → schemas-DAFYpgHk2.d.mts} +12 -12
  117. package/dist/services/adapter-runtime/index.d.mts +3 -3
  118. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  119. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  120. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  121. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  122. package/dist/services/agent-runtime/index.d.mts +2 -2
  123. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  124. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  125. package/dist/services/capability/index.d.mts +1 -1
  126. package/dist/services/codebase/index.d.mts +2 -2
  127. package/dist/services/codebase/namespace.d.mts +1 -1
  128. package/dist/services/codebase/schemas.d.mts +1 -1
  129. package/dist/services/compression/index.d.mts +2 -2
  130. package/dist/services/compression/namespace.d.mts +1 -1
  131. package/dist/services/compression/schemas.d.mts +1 -1
  132. package/dist/services/context-rules/index.d.mts +4 -4
  133. package/dist/services/execution-target/index.d.mts +3 -3
  134. package/dist/services/execution-target/namespace.d.mts +1 -1
  135. package/dist/services/execution-target/schemas.d.mts +1 -1
  136. package/dist/services/filesystem/index.d.mts +1 -1
  137. package/dist/services/filesystem/index.mjs +1 -1
  138. package/dist/services/filesystem/namespace.d.mts +12 -12
  139. package/dist/services/filesystem/schemas.d.mts +6 -6
  140. package/dist/services/git/namespace.d.mts +2 -2
  141. package/dist/services/git/schemas.d.mts +2 -2
  142. package/dist/services/harness/index.d.mts +32 -20
  143. package/dist/services/harness/index.mjs +1 -1
  144. package/dist/services/harness/storage/schema.d.mts +60 -16
  145. package/dist/services/harness/storage/schema.mjs +1 -1
  146. package/dist/services/index.d.mts +73 -73
  147. package/dist/services/index.mjs +1 -1
  148. package/dist/services/log-import/browser.d.mts +2 -2
  149. package/dist/services/log-import/index.d.mts +7 -12
  150. package/dist/services/log-import/index.mjs +2 -2
  151. package/dist/services/log-import/log-import.d.mts +1 -1
  152. package/dist/services/log-import/namespace.d.mts +2 -2
  153. package/dist/services/log-import/schemas.d.mts +1 -1
  154. package/dist/services/model-registry/index.d.mts +1 -1
  155. package/dist/services/preferences/index.d.mts +2 -2
  156. package/dist/services/preferences/schemas.d.mts +1 -1
  157. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  158. package/dist/services/provider-context/index.d.mts +1 -1
  159. package/dist/services/session/handlers/index.d.mts +1 -1
  160. package/dist/services/session/handlers/index.mjs +1 -1
  161. package/dist/services/session/index.d.mts +10 -10
  162. package/dist/services/session/index.mjs +1 -1
  163. package/dist/services/session/messages/namespace.d.mts +1 -1
  164. package/dist/services/session/messages/namespace.mjs +1 -1
  165. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  166. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  167. package/dist/services/session/session-events/namespace.d.mts +1 -1
  168. package/dist/services/session/session-events/namespace.mjs +1 -1
  169. package/dist/services/session/storage/namespace.d.mts +1 -1
  170. package/dist/services/session/storage/schema.d.mts +2 -2
  171. package/dist/services/session/storage/schema.mjs +1 -1
  172. package/dist/services/session/testing/index.d.mts +18 -2
  173. package/dist/services/session/testing/index.mjs +52 -3
  174. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  175. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  176. package/dist/services/session/turns/namespace.d.mts +1 -1
  177. package/dist/services/session/turns/namespace.mjs +1 -1
  178. package/dist/services/session-editor/index.d.mts +1 -1
  179. package/dist/services/settings/index.d.mts +3 -3
  180. package/dist/services/settings/namespace.d.mts +12 -12
  181. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  182. package/dist/services/settings/storage/index.d.mts +3 -3
  183. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  184. package/dist/services/subagent/index.d.mts +1 -1
  185. package/dist/services/subagent-template/index.d.mts +2 -2
  186. package/dist/services/subagent-template/namespace.d.mts +1 -1
  187. package/dist/services/subagent-template/schemas.d.mts +1 -1
  188. package/dist/services/tool-approval/index.d.mts +1 -1
  189. package/dist/services/tool-approval/index.mjs +1 -1
  190. package/dist/services/tools/index.d.mts +1 -1
  191. package/dist/services/tools/index.mjs +1 -1
  192. package/dist/services/tray-menu/index.d.mts +3 -3
  193. package/dist/services/tray-menu/namespace.d.mts +1 -1
  194. package/dist/services/tray-menu/schemas.d.mts +1 -1
  195. package/dist/services/turn/index.d.mts +1 -1
  196. package/dist/services/turn/namespace.d.mts +1 -1
  197. package/dist/session-KnewDVxt.mjs +39 -0
  198. package/dist/{session-lineage-CxHc3_bm.d.mts → session-lineage-CXzV_hAP.d.mts} +1 -1
  199. package/dist/{src-DI5TcYUW.mjs → src-CBG3IHUl.mjs} +1 -1
  200. package/dist/storage/drizzle/client.d.mts +2 -78
  201. package/dist/storage/drizzle/client.mjs +1 -1
  202. package/dist/storage/drizzle/columns/postgres.d.mts +88 -0
  203. package/dist/storage/drizzle/columns/postgres.mjs +1 -0
  204. package/dist/storage/drizzle/columns/sqlite.d.mts +81 -0
  205. package/dist/storage/drizzle/columns/sqlite.mjs +1 -0
  206. package/dist/storage/drizzle/index.d.mts +976 -23
  207. package/dist/storage/drizzle/index.mjs +1 -1
  208. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  209. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  210. package/dist/storage/handlers/index.d.mts +1 -1
  211. package/dist/storage/handlers/index.mjs +1 -1
  212. package/dist/testing/drizzle-harness.d.mts +52 -6
  213. package/dist/testing/drizzle-harness.mjs +1 -1
  214. package/dist/testing/index.d.mts +34 -2
  215. package/dist/testing/index.mjs +1 -1
  216. package/dist/{tool-approval-service-BgNcJvKx.mjs → tool-approval-service-Cb2F1yT6.mjs} +1 -1
  217. package/dist/tools-D5DVHC-R.mjs +1 -0
  218. package/dist/{types-C5Uy3WEy.d.mts → types-D5IMwOkJ.d.mts} +1 -1
  219. package/dist/{types-CZHV05Lu.d.mts → types-DLVitCZP.d.mts} +51 -51
  220. package/dist/ui-kernel/index.d.mts +1 -1
  221. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  222. package/dist/workflow-engine/index.d.mts +482 -86
  223. package/dist/workflow-engine/index.mjs +1 -1
  224. package/dist/workflow-engine/package.d.mts +1 -1
  225. package/dist/workflow-engine/package.mjs +1 -1
  226. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  227. package/dist/{workflow-worker-hDaQzTBl.mjs → workflow-worker-CK9Sqj7D.mjs} +1 -1
  228. package/package.json +40 -1
  229. package/dist/drizzle-DpjZFY_j.mjs +0 -1
  230. package/dist/extension--5Q190u_.mjs +0 -1
  231. package/dist/extension-DFIZ3FCJ.mjs +0 -1
  232. package/dist/handlers-Bev7-xjL.mjs +0 -41
  233. package/dist/namespace-CDiM5Bcr.mjs +0 -1
  234. package/dist/namespace-h0HIuqx0.mjs +0 -1
  235. package/dist/package-C9wOiMK9.mjs +0 -1
  236. package/dist/primitive-runtime-1Z3JbRUj.mjs +0 -1
  237. package/dist/schema-DCJyzRHe.mjs +0 -1
  238. package/dist/schema-DOnJmAPw.mjs +0 -1
  239. package/dist/session-BnfsJoZi.mjs +0 -134
  240. package/dist/tools-B8d8Iqqx.mjs +0 -1
  241. package/dist/types-yTKQTAok.d.mts +0 -31
  242. /package/dist/{ajv-0JG5NFEd.mjs → ajv-BA2z5ztb.mjs} +0 -0
  243. /package/dist/{await-trigger-CHuOd5co.mjs → await-trigger-DREnXCEJ.mjs} +0 -0
  244. /package/dist/{base-orchestrator-D-S9v5VY.d.mts → base-orchestrator-M5mAB5-w.d.mts} +0 -0
  245. /package/dist/{cleanEnvForAdapter-BlpmyXYk.mjs → cleanEnvForAdapter-vZfPGi0X.mjs} +0 -0
  246. /package/dist/{clients-namespace-E97p_GKF.d.mts → clients-namespace-SFk7OTop.d.mts} +0 -0
  247. /package/dist/{config-namespace-R_34Wfps.d.mts → config-namespace-BzAvE2nY.d.mts} +0 -0
  248. /package/dist/{create-static-mount-B9Szo_7y.mjs → create-static-mount-BB1MIQ9J.mjs} +0 -0
  249. /package/dist/{cross-spawn-CTptpCy4.mjs → cross-spawn-BL6EvJBv.mjs} +0 -0
  250. /package/dist/{cursor-storage-YikwAZR5.mjs → cursor-storage-CmKjSvKY.mjs} +0 -0
  251. /package/dist/{definition-CYzWS2eR.d.mts → definition-BSghHJpQ.d.mts} +0 -0
  252. /package/dist/{definition-CvOuzWNT.d.mts → definition-q6iLw11H.d.mts} +0 -0
  253. /package/dist/{descriptor-to-package-9nrAH_D5.mjs → descriptor-to-package-CY8oc2gl.mjs} +0 -0
  254. /package/dist/{esm-CglYG5aA.mjs → esm-CQVFKEW5.mjs} +0 -0
  255. /package/dist/{extension-discovery-BD1-oNU_.d.mts → extension-discovery-CkV_VRdJ.d.mts} +0 -0
  256. /package/dist/{filesystem-service-BcwRp4k1.d.mts → filesystem-service-Ddngll0j.d.mts} +0 -0
  257. /package/dist/{index-DJQew2k-.d.mts → index-9IDJUJ4X.d.mts} +0 -0
  258. /package/dist/{index-CNYPKkyH.d.mts → index-BBvcP-P0.d.mts} +0 -0
  259. /package/dist/{index-BFaeVdsn2.d.mts → index-BKKNWqkP2.d.mts} +0 -0
  260. /package/dist/{index-Dn9Uum3F.d.mts → index-BMpRB6iE.d.mts} +0 -0
  261. /package/dist/{index-CdNDnxXR.d.mts → index-BbCjtc3h.d.mts} +0 -0
  262. /package/dist/{index-B6RGNugn.d.mts → index-BnQSPC6c.d.mts} +0 -0
  263. /package/dist/{index-DUPZKsd3.d.mts → index-BpXX9WZJ.d.mts} +0 -0
  264. /package/dist/{index-DUhXk_q6.d.mts → index-BpniJgxu.d.mts} +0 -0
  265. /package/dist/{index-ChG8ZUNP.d.mts → index-Bsp0O_sI.d.mts} +0 -0
  266. /package/dist/{index-CmGvjpUG.d.mts → index-BtztOqaF.d.mts} +0 -0
  267. /package/dist/{index-CF7dnqQj.d.mts → index-Buo9H8RK.d.mts} +0 -0
  268. /package/dist/{index-9KnLzPYu.d.mts → index-BxFA1XcP.d.mts} +0 -0
  269. /package/dist/{index-AZ4iLe7O2.d.mts → index-C33Tq1ei2.d.mts} +0 -0
  270. /package/dist/{index--0CnhN0g.d.mts → index-C6BhKRnH.d.mts} +0 -0
  271. /package/dist/{index-BV8rSmDZ.d.mts → index-CDU_s69P.d.mts} +0 -0
  272. /package/dist/{index-BDlpFEsp2.d.mts → index-CGJjA-hR2.d.mts} +0 -0
  273. /package/dist/{index-Dsu1tPHm.d.mts → index-CZ_TcT6J.d.mts} +0 -0
  274. /package/dist/{index-DNGUXQGC.d.mts → index-Cz9JMjZK.d.mts} +0 -0
  275. /package/dist/{index-C-YBGCCG.d.mts → index-D0SUjZmU.d.mts} +0 -0
  276. /package/dist/{index-yNb7G73-.d.mts → index-D6Iyvz9T.d.mts} +0 -0
  277. /package/dist/{index-ziQTLYUO.d.mts → index-DOfq0qqv.d.mts} +0 -0
  278. /package/dist/{index-BYxgW2i0.d.mts → index-DSV1aFgK.d.mts} +0 -0
  279. /package/dist/{index-Dbwm5Y-Q.d.mts → index-Dsq2zKvu.d.mts} +0 -0
  280. /package/dist/{jsonl-transport-DBHQgcIm.mjs → jsonl-transport-C21tpVfe.mjs} +0 -0
  281. /package/dist/{lib-CaOdTS9F.mjs → lib-CNOQJtgs.mjs} +0 -0
  282. /package/dist/{namespace-DnZ4rS6T2.d.mts → namespace-B60mn8J-2.d.mts} +0 -0
  283. /package/dist/{namespace-DfYutvMT.d.mts → namespace-BBVtD1gu.d.mts} +0 -0
  284. /package/dist/{namespace-BaJJxBsI.d.mts → namespace-CHMszppN.d.mts} +0 -0
  285. /package/dist/{namespace-uGw5nK6d.d.mts → namespace-CqUGzG53.d.mts} +0 -0
  286. /package/dist/{namespace-Dik_dNeE.d.mts → namespace-D1Iw_d1P.d.mts} +0 -0
  287. /package/dist/{namespace-13uMtVGj.d.mts → namespace-DRFJN-_z.d.mts} +0 -0
  288. /package/dist/{namespace-TfZGCy7N.d.mts → namespace-DzVf1hVH.d.mts} +0 -0
  289. /package/dist/{namespace-QTFnJWHC.d.mts → namespace-XTGCaSXj.d.mts} +0 -0
  290. /package/dist/{namespace-CTrNKkxY.d.mts → namespace-nlsvvMtD.d.mts} +0 -0
  291. /package/dist/{namespace-DkDvQJhB.d.mts → namespace-uuR0Fg5r.d.mts} +0 -0
  292. /package/dist/{orchestrator-shared-BZVeoRfr.d.mts → orchestrator-shared-D91Wk7z-.d.mts} +0 -0
  293. /package/dist/{out-CiFds_ap.mjs → out-C1JFb2Bp.mjs} +0 -0
  294. /package/dist/{package-B2HkKyRz.d.mts → package-BSnp1zOR.d.mts} +0 -0
  295. /package/dist/{providers-namespace-Cc9FQ-Zt.d.mts → providers-namespace-BqWYkydw.d.mts} +0 -0
  296. /package/dist/{schemas-BD-1NGmS.d.mts → schemas-B5ToLwIs.d.mts} +0 -0
  297. /package/dist/{schemas-Hy-lsBpg.d.mts → schemas-B77Gi8Xr.d.mts} +0 -0
  298. /package/dist/{schemas-BzK1I1eX.d.mts → schemas-C792eVAZ.d.mts} +0 -0
  299. /package/dist/{schemas-CYS6bkht.d.mts → schemas-Chyj6HuZ.d.mts} +0 -0
  300. /package/dist/{schemas-BiMxSTUx.d.mts → schemas-CkOSG2eJ.d.mts} +0 -0
  301. /package/dist/{schemas-DL_bGYyZ.d.mts → schemas-DZUaRcYl.d.mts} +0 -0
  302. /package/dist/{schemas-DdZwjeF0.d.mts → schemas-Dv5FxHDT.d.mts} +0 -0
  303. /package/dist/{schemas-CsjB6gel.d.mts → schemas-Dyk7JuVl.d.mts} +0 -0
  304. /package/dist/{schemas-DFWGb4uj.d.mts → schemas-Kq33MTPY.d.mts} +0 -0
  305. /package/dist/{schemas-BFeP62V4.d.mts → schemas-lqvZ6UpK.d.mts} +0 -0
  306. /package/dist/{server-lifecycle-DVAbXQzg.d.mts → server-lifecycle-47mygK3E.d.mts} +0 -0
  307. /package/dist/{server-lifecycle-JTFuSJhg.mjs → server-lifecycle-Cg47L59Q.mjs} +0 -0
  308. /package/dist/{src-4_2jBceX.mjs → src-DedDL9iv.mjs} +0 -0
  309. /package/dist/{storage-namespace-I30TaZP7.d.mts → storage-namespace-BXmMUd7a.d.mts} +0 -0
  310. /package/dist/{storage-namespace-definition-ZNBL3v2h.d.mts → storage-namespace-definition-C3XbpiP8.d.mts} +0 -0
  311. /package/dist/{types-11QnNmpW.d.mts → types-5Gw3iVpK.d.mts} +0 -0
  312. /package/dist/{types-BKNpS4Xw.d.mts → types-B0BtvVAq.d.mts} +0 -0
  313. /package/dist/{types-0u6hpELc.d.mts → types-BMpIa4fx.d.mts} +0 -0
  314. /package/dist/{types-BtMNh2FS.d.mts → types-D-bP8RRE.d.mts} +0 -0
  315. /package/dist/{window-registry-QD1rTk_f.d.mts → window-registry-CfEi_Ji4.d.mts} +0 -0
@@ -1,9 +1,668 @@
1
- import { t as MakaioDatabase } from "../../types-yTKQTAok.mjs";
1
+ import { a as DATABASE_DIALECT, c as getDatabaseDialect, n as DatabaseClientConfig, o as MakaioDatabase, s as StorageDialect, t as DatabaseClient } from "../../client-BJVDImPV.mjs";
2
2
  import { IMakaioBus } from "@makaio/framework/bus";
3
3
  import { ExtensionContext } from "@makaio/framework/contracts";
4
- import { Table } from "drizzle-orm";
4
+ import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
5
+ import { SQLiteColumn, SQLiteColumnBuilderBase, SQLiteTable, SQLiteTableExtraConfigValue, SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
6
+ import * as _$drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
7
+ import { PgColumn, PgColumnBuilderBase, PgTable, PgTableExtraConfigValue, PgTableWithColumns } from "drizzle-orm/pg-core";
8
+ import * as _$drizzle_orm0 from "drizzle-orm";
9
+ import { $Type, BuildColumns, BuildExtraConfigColumns, ColumnBuilderBase, SQL, Table } from "drizzle-orm";
5
10
  import { StorageNamespace, StorageNamespaceConfig, StorageNamespaceExtensions, createStorageNamespace } from "@makaio/framework/storage";
6
11
 
12
+ //#region storage/drizzle/src/raw-sql.d.ts
13
+ /**
14
+ * Statement surface available both standalone and inside a pinned session.
15
+ */
16
+ interface RawSqlSession {
17
+ /**
18
+ * Execute one statement. Affected-row count where the driver reports one
19
+ * (drivers that report nothing yield `rowsAffected: 0`).
20
+ * @param query - SQL statement to execute.
21
+ * @returns Normalized write result.
22
+ */
23
+ run(query: SQL): Promise<{
24
+ rowsAffected: number;
25
+ }>;
26
+ /**
27
+ * Execute a query and return rows as column-name-keyed objects.
28
+ * @param query - SQL query to execute.
29
+ * @returns All result rows.
30
+ * @typeParam TRow - Expected row shape keyed by column name.
31
+ */
32
+ all<TRow extends Record<string, unknown>>(query: SQL): Promise<TRow[]>;
33
+ }
34
+ /**
35
+ * Dialect-portable raw SQL executor, attached to every handle by
36
+ * `createDatabaseClient`. The ONLY sanctioned path for raw statements.
37
+ *
38
+ * INVARIANT: raw transaction control (BEGIN/COMMIT/ROLLBACK) may only ever be
39
+ * issued inside {@link RawSqlExecutor.withSession}. On Postgres, standalone
40
+ * `run` goes through the pool — raw BEGIN there would stripe statements
41
+ * across connections.
42
+ */
43
+ interface RawSqlExecutor extends RawSqlSession {
44
+ /** Storage dialect this executor speaks. Matches the handle's brand. */
45
+ readonly dialect: StorageDialect;
46
+ /**
47
+ * Run `fn` with every statement pinned to one connection. Postgres: a
48
+ * checked-out `pool.connect()` client that is always released — returned to
49
+ * the pool on success, destroyed via `release(true)` when the callback
50
+ * rejects so a poisoned connection (open or aborted transaction) never
51
+ * re-enters the pool. SQLite: the single connection (trivial).
52
+ * @param fn - Work to execute against the pinned session.
53
+ * @returns The value resolved by `fn`.
54
+ * @typeParam T - Result type produced by the session callback.
55
+ */
56
+ withSession<T>(fn: (session: RawSqlSession) => Promise<T>): Promise<T>;
57
+ }
58
+ /**
59
+ * Attach the storage-dialect brand and the raw SQL executor to a drizzle
60
+ * database instance.
61
+ *
62
+ * Both properties are non-enumerable so they never leak through spreads or
63
+ * property enumeration, and non-writable/non-configurable so a handle's
64
+ * dialect and executor cannot change after creation (re-branding throws).
65
+ * Every branded handle carries an executor — `getRawSqlExecutor` relies on
66
+ * this invariant, so the executor's dialect must match the brand.
67
+ * @param db - Drizzle database instance to brand.
68
+ * @param dialect - Storage dialect served by the instance.
69
+ * @param executor - Raw SQL executor for the instance's connection(s).
70
+ * @returns The same instance, branded.
71
+ */
72
+ declare function brandDatabase<TDb extends object>(db: TDb, dialect: StorageDialect, executor: RawSqlExecutor): TDb;
73
+ /**
74
+ * Resolve the raw SQL executor for a database handle.
75
+ *
76
+ * Factory-created handles return the executor attached by
77
+ * `createDatabaseClient`. Unbranded handles that expose the native SQLite
78
+ * `run`/`all` API (hand-rolled test clients built directly on
79
+ * `drizzle-orm/libsql` or `drizzle-orm/bun-sqlite`) get a synthesized SQLite
80
+ * executor — mirroring the unbranded→`'sqlite'` dialect default.
81
+ * @param db - Database handle to resolve the executor for.
82
+ * @returns The handle's raw SQL executor.
83
+ * @throws Error when the handle carries no executor and exposes no native
84
+ * SQLite raw API — create handles with `createDatabaseClient` instead.
85
+ */
86
+ declare function getRawSqlExecutor(db: MakaioDatabase): RawSqlExecutor;
87
+ //#endregion
88
+ //#region storage/drizzle/src/import-runtime-module.d.ts
89
+ /**
90
+ * Bundler-opaque dynamic module loading.
91
+ *
92
+ * Leaf module with no package-internal imports so any layer (client factory,
93
+ * engine implementations, runtime hosts) can load optional or runtime-gated
94
+ * modules without creating import cycles.
95
+ * @packageDocumentation
96
+ */
97
+ /**
98
+ * Imports a module whose specifier must stay opaque to bundlers.
99
+ *
100
+ * `bun:sqlite` and `drizzle-orm/bun-sqlite` are optional or runtime-gated
101
+ * modules that may only be resolved when their branch is actually reached at
102
+ * runtime. A literal `import('pg')` — or a `const id = 'pg'; import(id)`
103
+ * indirection, which minifiers constant-fold back into the literal form — lets
104
+ * bundlers (Vite, esbuild, rolldown) resolve the specifier at bundle time and
105
+ * fail or inline it. Routing the specifier through a function parameter keeps
106
+ * the emitted call a fully dynamic `import(specifier)` that bundlers treat as
107
+ * runtime-only, in source and in minified distribution output alike.
108
+ *
109
+ * Resolution caveat: the `import()` resolves relative to this module, so this
110
+ * helper is only for modules that belong to this package's dependency closure.
111
+ * Host-installed optional packages must be resolved from a host-provided base
112
+ * before importing the resulting file URL.
113
+ * @param specifier - Bare module specifier to import at runtime.
114
+ * @typeParam TModule - Structural surface of the module the caller consumes.
115
+ * @returns Promise of the loaded module, typed by the caller.
116
+ */
117
+ declare function importRuntimeModule<TModule>(specifier: string): Promise<TModule>;
118
+ //#endregion
119
+ //#region storage/drizzle/src/fts/strategy.d.ts
120
+ /**
121
+ * Input for message-level full-text search operations.
122
+ */
123
+ interface FtsMessageSearchInput {
124
+ /**
125
+ * Raw search query as received from the caller. The strategy owns
126
+ * sanitization/trimming; callers must short-circuit empty/whitespace
127
+ * queries before calling the strategy.
128
+ */
129
+ readonly query: string;
130
+ /** Optional session scope; omitted searches across all sessions. */
131
+ readonly sessionId?: string | undefined;
132
+ /** Maximum number of rows to return (callers apply their own defaults). */
133
+ readonly limit: number;
134
+ }
135
+ /**
136
+ * One ranked excerpt hit returned by {@link FtsSearchStrategy.searchMessageExcerpts}.
137
+ */
138
+ interface FtsMessageExcerptHit {
139
+ /** Message identifier of the hit. */
140
+ readonly messageId: string;
141
+ /** Session the message belongs to. */
142
+ readonly sessionId: string;
143
+ /**
144
+ * Positive relevance score. Magnitudes are dialect-specific (negated bm25
145
+ * on SQLite, ts_rank on Postgres) — only relative ordering within one
146
+ * result set is meaningful.
147
+ */
148
+ readonly score: number;
149
+ /** Highlighted excerpt with `<mark>…</mark>` around matched terms. */
150
+ readonly excerpt: string;
151
+ }
152
+ /**
153
+ * Input for session-level full-text search.
154
+ */
155
+ interface FtsSessionSearchInput {
156
+ /**
157
+ * Normalized (trimmed) search query text matched against message content.
158
+ * Callers trim once because the LIKE pattern is derived from the same text.
159
+ */
160
+ readonly query: string;
161
+ /** Lowercased `%query%` pattern for the title LIKE match. */
162
+ readonly likePattern: string;
163
+ /** Maximum number of session rows to return. */
164
+ readonly limit: number;
165
+ /** Optional status filter; `undefined` means "any status". */
166
+ readonly status?: string | undefined;
167
+ /** Optional import-flag filter; `undefined` means "any". */
168
+ readonly isImported?: boolean | undefined;
169
+ }
170
+ /**
171
+ * Input for counting session-level matches — the search input minus the page
172
+ * window (totals are independent of pagination).
173
+ */
174
+ type FtsSessionCountInput = Omit<FtsSessionSearchInput, 'limit'>;
175
+ /**
176
+ * Dialect-owned full-text-search operations.
177
+ *
178
+ * The `messagesTable` parameters are typed as the canonical SQLite face; under
179
+ * Postgres the runtime object is the congruent twin resolved per handle (the
180
+ * same honesty model as `resolveSchema`). Strategies that build raw SQL
181
+ * against fixed physical names accept and ignore the parameter.
182
+ */
183
+ interface FtsSearchStrategy {
184
+ /** Storage dialect this strategy serves. */
185
+ readonly dialect: StorageDialect;
186
+ /**
187
+ * Provision the engine's search index over the `messages` table.
188
+ *
189
+ * Called after central migrations on every boot; implementations must be
190
+ * idempotent. Engines whose index ships through the regular migration chain
191
+ * implement this as a no-op.
192
+ * @param db - Database handle with the central schema already applied.
193
+ */
194
+ provisionSearchIndex(db: MakaioDatabase): Promise<void>;
195
+ /**
196
+ * Search full message rows ranked by relevance.
197
+ * @param db - Database handle to query.
198
+ * @param messagesTable - Resolved messages table of the handle's dialect.
199
+ * @param input - Query text, optional session scope, and page limit.
200
+ * @returns Ranked message rows plus the page-independent total match count.
201
+ * @typeParam TRow - Row shape produced by the messages table (callers pass
202
+ * their select-row type; the strategy returns rows column-compatible with
203
+ * the messages table).
204
+ */
205
+ searchMessages<TRow extends Record<string, unknown>>(db: MakaioDatabase, messagesTable: SQLiteTable, input: FtsMessageSearchInput): Promise<{
206
+ rows: TRow[];
207
+ total: number;
208
+ }>;
209
+ /**
210
+ * Search messages and return scored `<mark>`-highlighted excerpts instead
211
+ * of full rows.
212
+ * @param db - Database handle to query.
213
+ * @param messagesTable - Resolved messages table of the handle's dialect.
214
+ * @param input - Query text, optional session scope, and page limit.
215
+ * @returns Ranked excerpt hits plus the page-independent total match count.
216
+ */
217
+ searchMessageExcerpts(db: MakaioDatabase, messagesTable: SQLiteTable, input: FtsMessageSearchInput): Promise<{
218
+ results: FtsMessageExcerptHit[];
219
+ total: number;
220
+ }>;
221
+ /**
222
+ * Search sessions whose message content matches the query or whose title
223
+ * matches the LIKE pattern, newest activity first.
224
+ * @param db - Database handle to query.
225
+ * @param input - Query text, title pattern, page limit, and optional filters.
226
+ * @returns Matching session rows (snake_case physical column keys).
227
+ * @typeParam TRow - Session row shape expected by the caller.
228
+ */
229
+ searchSessionRows<TRow extends Record<string, unknown>>(db: MakaioDatabase, input: FtsSessionSearchInput): Promise<TRow[]>;
230
+ /**
231
+ * Count all sessions matching the query/pattern and filters, without
232
+ * pagination.
233
+ * @param db - Database handle to query.
234
+ * @param input - Query text, title pattern, and optional filters.
235
+ * @returns Total number of unique matching sessions.
236
+ */
237
+ countSessionMatches(db: MakaioDatabase, input: FtsSessionCountInput): Promise<number>;
238
+ /**
239
+ * Resolve the first user message per session as a preview, tie-breaking
240
+ * same-timestamp messages with the engine's deterministic ordering
241
+ * surrogate (rowid on SQLite, message_id on Postgres).
242
+ * @param db - Database handle to query.
243
+ * @param sessionIds - Session IDs to resolve previews for; an empty list
244
+ * resolves to an empty map without touching the database.
245
+ * @returns First user message text keyed by session ID.
246
+ */
247
+ fetchFirstUserMessagePreviews(db: MakaioDatabase, sessionIds: readonly string[]): Promise<Map<string, string | null>>;
248
+ }
249
+ //#endregion
250
+ //#region storage/drizzle/src/engine/types.d.ts
251
+ /**
252
+ * Dialect-specific classification of database errors.
253
+ *
254
+ * Raw DDL flows (migration adoption, idempotent CREATE) and bounded-retry
255
+ * write paths need to recognize driver failures portably. Each engine owns
256
+ * the knowledge of how its drivers report these conditions.
257
+ */
258
+ interface StorageEngineErrorClassifiers {
259
+ /**
260
+ * Returns `true` when the error (or any link in its cause chain) reports
261
+ * that a schema object (table, index, trigger, …) already exists.
262
+ *
263
+ * Used by the migration applicator to decide whether a failed first CREATE
264
+ * can be adopted into the ledger.
265
+ * @param error - Error thrown by a DDL statement.
266
+ * @returns Whether the failure is a duplicate-schema-object conflict.
267
+ */
268
+ isDuplicateObjectError(error: unknown): boolean;
269
+ /**
270
+ * Returns `true` when the error (or any link in its cause chain) reports a
271
+ * unique-constraint violation.
272
+ *
273
+ * Used by write paths that resolve write-write races through a bounded
274
+ * retry (for example MAX-based counter assignment). The optional
275
+ * `constraint` scope lets callers react to one specific index without
276
+ * swallowing unrelated violations; engines whose drivers do not report
277
+ * constraint names ignore the scope.
278
+ * @param error - Error thrown by a DML statement.
279
+ * @param constraint - Optional constraint/index name to scope the match.
280
+ * @returns Whether the failure is a unique-constraint violation.
281
+ */
282
+ isUniqueViolationError(error: unknown, constraint?: string): boolean;
283
+ }
284
+ /**
285
+ * Runtime capabilities a consumer can query instead of branching on the
286
+ * dialect identifier.
287
+ */
288
+ interface StorageEngineCapabilities {
289
+ /**
290
+ * SQL column type used for binary payloads in hand-written DDL
291
+ * (for example `'BLOB'` on SQLite, `'bytea'` on Postgres).
292
+ */
293
+ readonly binaryColumnType: string;
294
+ /**
295
+ * Whether concurrent MAX-based counter assignment can race under this
296
+ * engine's default isolation level and therefore needs a bounded
297
+ * unique-violation retry. `false` for engines whose writes serialize at the
298
+ * connection level.
299
+ */
300
+ readonly maxCounterAssignmentRaces: boolean;
301
+ /**
302
+ * Probe the engine's catalog for a table's existence.
303
+ * @param executor - Raw SQL executor of the target database handle.
304
+ * @param tableName - Unqualified table name to probe.
305
+ * @returns `true` when the table exists.
306
+ */
307
+ tableExists(executor: RawSqlExecutor, tableName: string): Promise<boolean>;
308
+ }
309
+ /**
310
+ * Migration behavior owned by an engine: ledger naming and DDL, journal
311
+ * dialect, chain directory layout, and transaction semantics.
312
+ *
313
+ * The statement texts and naming schemes exposed here are cross-version
314
+ * contracts — runners built from different framework versions must agree on
315
+ * them, otherwise concurrent runs stop serializing against each other or stop
316
+ * recognizing each other's ledgers.
317
+ */
318
+ interface StorageEngineMigrationBehavior {
319
+ /** Default migration ledger table name for this engine. */
320
+ readonly defaultLedgerTable: string;
321
+ /**
322
+ * `dialect` value expected in a migration chain's `_journal.json` for this
323
+ * engine (drizzle-kit vocabulary, e.g. `'sqlite'` or `'postgresql'`).
324
+ */
325
+ readonly journalDialect: string;
326
+ /**
327
+ * Name of the directory holding this engine's bundled migration chain
328
+ * inside a package's distribution artifacts.
329
+ */
330
+ readonly chainDirName: string;
331
+ /**
332
+ * Resolve the absolute source directory of this engine's migration chain.
333
+ *
334
+ * Optional extension point for engines whose chain ships outside the
335
+ * default location implied by {@link chainDirName}; engines that omit it
336
+ * use the caller's default chain discovery.
337
+ * @returns Absolute path to the chain directory.
338
+ */
339
+ resolveSourceChainDir?(): string;
340
+ /**
341
+ * Build the idempotent `CREATE TABLE IF NOT EXISTS` DDL for the migration
342
+ * ledger table. The exact statement text is a cross-version contract pinned
343
+ * by tests.
344
+ * @param tableName - Ledger table name (engine default or caller-provided).
345
+ * @returns Complete DDL statement text.
346
+ */
347
+ buildLedgerDdl(tableName: string): string;
348
+ /**
349
+ * `BEGIN` statement that opens a migration transaction, including any
350
+ * isolation-level pinning the engine's ledger recheck protocol requires.
351
+ */
352
+ readonly beginTransactionStatement: string;
353
+ /**
354
+ * Acquire the engine's cross-process migration lock inside an open
355
+ * transaction.
356
+ *
357
+ * Optional: engines whose writes already serialize at the connection level
358
+ * omit it. Presence of this member is the single seam the applicator
359
+ * derives all cross-process locking behavior from (locked ledger snapshot
360
+ * plus in-lock recheck) — there is no separate flag that could disagree.
361
+ * @param session - Pinned raw SQL session with the transaction open.
362
+ * @param ledgerTableName - Ledger table name the lock key is derived from.
363
+ * @returns Resolves once the lock is held for the transaction's lifetime.
364
+ */
365
+ acquireTransactionLock?(session: RawSqlSession, ledgerTableName: string): Promise<void>;
366
+ /**
367
+ * Derive the per-extension migration ledger table name from an extension
368
+ * source hash. The naming scheme is a cross-version contract: ledgers
369
+ * written by one framework version must be found by the next.
370
+ * @param sourceHash - Stable hash identifying the extension's migration source.
371
+ * @returns Ledger table name for that extension.
372
+ */
373
+ extensionLedgerName(sourceHash: string): string;
374
+ }
375
+ /**
376
+ * Everything dialect-specific about a storage backend, packaged behind one
377
+ * contract.
378
+ *
379
+ * Engines are registered with the engine registry (explicitly via
380
+ * `registerStorageEngine` or through host boot options); the built-in SQLite
381
+ * engine is pre-registered and serves as the default engine for every URL no
382
+ * registered engine claims.
383
+ */
384
+ interface StorageEngine {
385
+ /** Storage dialect this engine serves. */
386
+ readonly dialect: StorageDialect;
387
+ /**
388
+ * Returns `true` when a database URL selects this engine.
389
+ *
390
+ * Optional: the default engine (SQLite) omits it and serves every URL no
391
+ * registered engine claims.
392
+ * @param url - Database URL to test.
393
+ * @returns Whether the URL selects this engine.
394
+ */
395
+ matchesUrl?(url: string): boolean;
396
+ /**
397
+ * Create a database client for this engine.
398
+ * @param config - Database configuration options.
399
+ * @returns Database client with drizzle ORM instance and close method.
400
+ */
401
+ createClient(config: DatabaseClientConfig): Promise<DatabaseClient>;
402
+ /** Dialect-specific error classification. */
403
+ readonly errors: StorageEngineErrorClassifiers;
404
+ /** Runtime capabilities consumers query instead of branching on dialect. */
405
+ readonly capabilities: StorageEngineCapabilities;
406
+ /** Migration ledger, journal, and transaction behavior. */
407
+ readonly migrations: StorageEngineMigrationBehavior;
408
+ /**
409
+ * Full-text-search provisioning and query operations.
410
+ *
411
+ * Required: every built-in engine implements full-text search for real.
412
+ * Future engines without a search backend ship a refusing strategy rather
413
+ * than omitting the member, so the seam stays uniform for consumers.
414
+ */
415
+ readonly fts: FtsSearchStrategy;
416
+ }
417
+ /**
418
+ * Quote a SQL identifier (table, column, or index name) for safe inlining
419
+ * into hand-written statement text.
420
+ *
421
+ * Uses double-quote delimiters with embedded double quotes doubled — the
422
+ * standard SQL identifier escaping shared by SQLite and Postgres.
423
+ * @param name - Raw identifier to quote.
424
+ * @returns The quoted identifier, safe to interpolate into SQL text.
425
+ */
426
+ declare function quoteSqlIdentifier(name: string): string;
427
+ //#endregion
428
+ //#region storage/drizzle/src/engine/registry.d.ts
429
+ /**
430
+ * Register a storage engine for its dialect.
431
+ *
432
+ * Re-registering the same engine object is a no-op, so idempotent
433
+ * registration helpers and duplicated boot paths are safe. Registering a
434
+ * *different* engine object for an already-registered dialect throws: one
435
+ * dialect has exactly one engine per process, and silently replacing it would
436
+ * change behavior for every open handle.
437
+ * @param engine - Engine to register under its `dialect`.
438
+ * @throws Error when a different engine is already registered for the dialect.
439
+ */
440
+ declare function registerStorageEngine(engine: StorageEngine): void;
441
+ /**
442
+ * Resolve the engine registered for a dialect, throwing an actionable error
443
+ * when it is absent.
444
+ *
445
+ * For dialects with a known engine package (see the URL hint table) the error
446
+ * names the package to install; otherwise it points at
447
+ * {@link registerStorageEngine}.
448
+ * @param dialect - Storage dialect to resolve.
449
+ * @returns The registered engine.
450
+ * @throws Error when no engine is registered for the dialect.
451
+ */
452
+ declare function getStorageEngine(dialect: StorageDialect): StorageEngine;
453
+ /**
454
+ * Resolve the engine registered for a dialect, or `undefined` when absent.
455
+ * @param dialect - Storage dialect to look up.
456
+ * @returns The registered engine, or `undefined`.
457
+ */
458
+ declare function findStorageEngine(dialect: StorageDialect): StorageEngine | undefined;
459
+ /**
460
+ * Resolve the engine serving a database handle, via the handle's dialect
461
+ * brand (unbranded handles resolve to the SQLite default engine).
462
+ * @param db - Database handle to resolve the engine for.
463
+ * @returns The engine serving the handle's dialect.
464
+ * @throws Error when no engine is registered for the handle's dialect.
465
+ */
466
+ declare function resolveStorageEngine(db: MakaioDatabase<Record<string, unknown>>): StorageEngine;
467
+ /**
468
+ * Result of resolving a database URL against the engine registry.
469
+ *
470
+ * - `'engine'` — a registered engine serves the URL.
471
+ * - `'missing-engine'` — the URL is recognized (hint table) but the engine
472
+ * package is not registered; `packageName` names the package to install or
473
+ * auto-import.
474
+ * - `'default'` — no engine claims the URL; it belongs to the default
475
+ * (SQLite) engine.
476
+ */
477
+ type StorageEngineUrlResolution = {
478
+ kind: 'engine';
479
+ engine: StorageEngine;
480
+ } | {
481
+ kind: 'missing-engine';
482
+ dialect: StorageDialect;
483
+ packageName: string;
484
+ } | {
485
+ kind: 'default';
486
+ };
487
+ /**
488
+ * Resolve a database URL to the engine that serves it.
489
+ *
490
+ * Checks registered engines' `matchesUrl` claims in registration order, then
491
+ * the URL hint table, and falls back to `'default'`. A hint match is reported
492
+ * as `'missing-engine'` only when the hinted dialect truly has no registered
493
+ * engine — when one is registered (without claiming the URL itself), the
494
+ * registered engine wins so the result kind stays honest.
495
+ * @param url - Database URL to resolve.
496
+ * @returns The resolution: a serving engine, a missing-engine hint, or the default.
497
+ */
498
+ declare function resolveStorageEngineForUrl(url: string): StorageEngineUrlResolution;
499
+ //#endregion
500
+ //#region storage/drizzle/src/engine/hints.d.ts
501
+ /**
502
+ * Static mapping from a recognizable database URL shape to the package that
503
+ * provides the engine for it.
504
+ */
505
+ interface StorageEngineUrlHint {
506
+ /** Dialect the hinted engine serves. */
507
+ readonly dialect: StorageDialect;
508
+ /** Package that exports the engine as `storageEngine`. */
509
+ readonly packageName: string;
510
+ /**
511
+ * Returns `true` when a database URL belongs to the hinted engine.
512
+ * @param url - Database URL to test.
513
+ * @returns Whether the URL is recognized by this hint.
514
+ */
515
+ matchesUrl(url: string): boolean;
516
+ }
517
+ /**
518
+ * All known URL hints, in match order.
519
+ *
520
+ * Postgres: both `postgres://` and `postgresql://` schemes are accepted,
521
+ * case-insensitively. The engine lives in `@makaio/storage-pg`.
522
+ */
523
+ declare const STORAGE_ENGINE_URL_HINTS: readonly StorageEngineUrlHint[];
524
+ /**
525
+ * Build the actionable error message for a dialect whose engine is not
526
+ * registered.
527
+ *
528
+ * Single source of truth for both failure surfaces: the client factory's
529
+ * missing-engine rejection and the runtime host's boot error.
530
+ * @param dialect - Dialect the caller tried to resolve.
531
+ * @param packageName - Package that provides the missing engine.
532
+ * @returns Human-readable, actionable error message.
533
+ */
534
+ declare function describeMissingStorageEngine(dialect: StorageDialect, packageName: string): string;
535
+ //#endregion
536
+ //#region storage/drizzle/src/engine/generation.d.ts
537
+ /**
538
+ * One non-baseline engine's drizzle-kit generation leg.
539
+ *
540
+ * The baseline dialect (SQLite) has no entry here: its chain is generated by
541
+ * the orchestrator directly. Every other dialect that can contribute a chain
542
+ * declares its leg through this descriptor so the orchestrator stays free of
543
+ * per-engine wiring.
544
+ */
545
+ interface StorageEngineGenerationLeg {
546
+ /** Dialect this generation leg produces a migration chain for. */
547
+ readonly dialect: StorageDialect;
548
+ /** Package that provides the engine and its drizzle-kit generation assets. */
549
+ readonly enginePackageName: string;
550
+ /**
551
+ * Name of the directory holding this engine's generated migration chain,
552
+ * relative to the engine package root.
553
+ */
554
+ readonly chainDirName: string;
555
+ /**
556
+ * drizzle-kit config path for this engine, relative to the engine package
557
+ * root. The orchestrator resolves the package root, then joins this path to
558
+ * run `drizzle-kit generate --config <root>/<drizzleConfigSpecifier>`.
559
+ */
560
+ readonly drizzleConfigSpecifier: string;
561
+ /**
562
+ * Post-generation normalize script path for this engine, relative to the
563
+ * engine package root. Optional: engines whose generated chains need no
564
+ * normalization omit it.
565
+ */
566
+ readonly normalizeScriptSpecifier?: string;
567
+ }
568
+ /**
569
+ * All non-baseline generation legs, in run order.
570
+ *
571
+ * Postgres: the engine lives in `@makaio/storage-pg`, its chain lands in
572
+ * `drizzle-postgres`, drizzle-kit reads `drizzle.config.ts`, and the generated
573
+ * SQL is normalized by `scripts/normalize-migrations.ts` — all relative to the
574
+ * engine package root.
575
+ */
576
+ declare const NON_BASELINE_GENERATION_LEGS: readonly StorageEngineGenerationLeg[];
577
+ /**
578
+ * Find the generation leg for a dialect, if one exists.
579
+ * @param dialect - Storage dialect to look up.
580
+ * @returns The generation leg for the dialect, or `undefined` when the dialect
581
+ * has no non-baseline generation leg (the baseline dialect always returns
582
+ * `undefined`).
583
+ */
584
+ declare function findGenerationLegForDialect(dialect: StorageDialect): StorageEngineGenerationLeg | undefined;
585
+ //#endregion
586
+ //#region storage/drizzle/src/engine/sqlite/engine.d.ts
587
+ /**
588
+ * The built-in SQLite engine.
589
+ *
590
+ * This is the default engine: it deliberately omits {@link StorageEngine.matchesUrl}
591
+ * and serves every database URL no registered engine claims (local `file:`
592
+ * and `:memory:` databases as well as remote libSQL/Turso connections).
593
+ *
594
+ * Migration behavior keeps Drizzle's historical SQLite contracts byte-for-byte
595
+ * (`__drizzle_migrations` ledger name and DDL shape, bare `BEGIN`,
596
+ * `__drizzle_migrations_<hash>` extension ledgers) so existing ledgers keep
597
+ * matching across framework versions. No `acquireTransactionLock`: SQLite
598
+ * writes serialize at the connection level, so the migration applicator needs
599
+ * no cross-process lock protocol here.
600
+ */
601
+ declare const sqliteStorageEngine: StorageEngine;
602
+ //#endregion
603
+ //#region storage/drizzle/src/errors.d.ts
604
+ /**
605
+ * Engine-owned classification of database errors.
606
+ *
607
+ * Raw DDL flows (migration adoption, idempotent CREATE) and bounded-retry
608
+ * write paths need to recognize driver failures portably. Each storage engine
609
+ * owns the knowledge of how its drivers report these conditions; consumers go
610
+ * through `StorageEngine.errors` instead of branching on the dialect.
611
+ *
612
+ * This module hosts the SQLite classifiers backing the built-in engine, plus
613
+ * the cause-chain inspection helpers engine packages build their own
614
+ * classifiers from.
615
+ * @packageDocumentation
616
+ */
617
+ /**
618
+ * Walk an error's cause chain until a link satisfies the predicate.
619
+ *
620
+ * Building block for engine error classifiers: drivers and call sites
621
+ * routinely wrap failures (`new Error(..., { cause })`), so classification
622
+ * must consider every `Error` link in the chain, not just the outermost one.
623
+ * @param error - Error (or arbitrary thrown value) to inspect.
624
+ * @param predicate - Test applied to every `Error` link in the chain.
625
+ * @returns `true` when any link in the cause chain satisfies the predicate.
626
+ */
627
+ declare function someInCauseChain(error: unknown, predicate: (link: Error) => boolean): boolean;
628
+ /**
629
+ * Read a string `code` property off an error, if present.
630
+ *
631
+ * Driver errors (node-postgres `DatabaseError`, libsql errors) carry their
632
+ * SQLSTATE / driver code as a non-standard `code` property. Building block
633
+ * for engine error classifiers that match on those codes.
634
+ * @param error - Error link to read from.
635
+ * @returns The string code, or `undefined` when absent or non-string.
636
+ */
637
+ declare function readErrorCode(error: Error): string | undefined;
638
+ /**
639
+ * Returns `true` when the error (or any link in its cause chain) reports
640
+ * that a schema object already exists on SQLite.
641
+ *
642
+ * Matches the `already exists` message text — SQLite reports duplicate schema
643
+ * objects only through the error message. Used by the migration applicator to
644
+ * decide whether a failed first CREATE can be adopted into the ledger.
645
+ * @param error - Error thrown by a DDL statement.
646
+ * @returns Whether the failure is a duplicate-schema-object conflict.
647
+ */
648
+ declare function isSqliteDuplicateObjectError(error: unknown): boolean;
649
+ /**
650
+ * Returns `true` when the error (or any link in its cause chain) reports a
651
+ * SQLite unique-constraint violation.
652
+ *
653
+ * Matches the `UNIQUE constraint failed` message text. SQLite errors carry
654
+ * the violated column list, not constraint names, so constraint scoping is a
655
+ * Postgres-only concept honored by the Postgres engine's classifier — the
656
+ * built-in engine ignores the optional scope when delegating here.
657
+ *
658
+ * Used by write paths that resolve write-write races through a bounded retry
659
+ * (for example MAX-based counter assignment on engines whose default
660
+ * isolation level lets two concurrent statements compute the same next value).
661
+ * @param error - Error thrown by a DML statement.
662
+ * @returns Whether the failure is a unique-constraint violation.
663
+ */
664
+ declare function isSqliteUniqueViolationError(error: unknown): boolean;
665
+ //#endregion
7
666
  //#region storage/drizzle/src/transaction.d.ts
8
667
  type LibSQLTransactionExecutor = MakaioDatabase['transaction'];
9
668
  /**
@@ -19,9 +678,18 @@ type TransactionCallback<T> = Parameters<LibSQLTransactionExecutor>[0] extends (
19
678
  /**
20
679
  * Execute a database transaction through a shared transaction seam.
21
680
  *
22
- * Transaction work is serialized per database instance. SQLite permits only
23
- * one active transaction on a connection; without this queue, concurrent bus
24
- * handlers can fail at `BEGIN` with SQLITE_BUSY before busy_timeout can help.
681
+ * **Serialization contract:** transaction callbacks are serialized per
682
+ * database handle within this process, on every dialect. SQLite needs the
683
+ * queue for single-writer safety it permits only one active transaction
684
+ * per connection, and without the queue concurrent bus handlers fail at
685
+ * `BEGIN` with SQLITE_BUSY before busy_timeout can help. Postgres needs the
686
+ * queue so read-modify-write callbacks observe each other's commits: MVCC
687
+ * runs concurrent transactions against isolated snapshots, so two unqueued
688
+ * "read current state, then write" callbacks (e.g. clear the old default
689
+ * row, then mark the new one) can both act on the same stale read. The
690
+ * guarantee is process-local — multi-process Postgres deployments need
691
+ * database-level coordination (advisory locks or unique-constraint retries)
692
+ * at the caller seam.
25
693
  *
26
694
  * **Driver compatibility:** `MakaioDatabase` is typed as `LibSQLDatabase`
27
695
  * (Node.js async dialect), which runs the transaction asynchronously and
@@ -35,7 +703,7 @@ type TransactionCallback<T> = Parameters<LibSQLTransactionExecutor>[0] extends (
35
703
  */
36
704
  declare function executeTransaction<T>(db: MakaioDatabase, callback: TransactionCallback<T>): Promise<T>;
37
705
  //#endregion
38
- //#region storage/drizzle/src/fts.d.ts
706
+ //#region storage/drizzle/src/fts/sanitize.d.ts
39
707
  /**
40
708
  * FTS5 query utilities for SQLite full-text search.
41
709
  */
@@ -56,44 +724,73 @@ declare function executeTransaction<T>(db: MakaioDatabase, callback: Transaction
56
724
  */
57
725
  declare function sanitizeFtsQuery(query: string): string;
58
726
  //#endregion
727
+ //#region storage/drizzle/src/fts/preview-query.d.ts
728
+ /**
729
+ * Build the query resolving the first user message per session.
730
+ *
731
+ * Selects, for every given session, the user message no other user message of
732
+ * the same session precedes — "precedes" meaning an earlier timestamp, or an
733
+ * equal timestamp with the engine's tie-break predicate. Callers must not
734
+ * pass an empty `sessionIds` list (an empty `IN ()` list is invalid SQL);
735
+ * strategies short-circuit empty inputs before building the query.
736
+ * @param sessionIds - Session IDs to resolve previews for (deduplicated here).
737
+ * @param tieBreaker - Predicate over aliases `m2`/`m` that is `true` when
738
+ * `m2` precedes `m` among same-timestamp user messages.
739
+ * @returns Query yielding `sessionId` / `preview` rows.
740
+ */
741
+ declare function buildFirstUserMessagePreviewQuery(sessionIds: readonly string[], tieBreaker: SQL): SQL;
742
+ //#endregion
743
+ //#region storage/drizzle/src/engine/sqlite/fts-strategy.d.ts
744
+ /**
745
+ * The built-in SQLite FTS strategy: FTS5 provisioning, bm25-ranked message
746
+ * search, `snippet()` excerpts, and session search over `messages_fts`.
747
+ */
748
+ declare const sqliteFtsSearchStrategy: FtsSearchStrategy;
749
+ //#endregion
59
750
  //#region storage/drizzle/src/result.d.ts
60
751
  /**
61
752
  * Cross-driver result helpers for Drizzle write operations.
62
753
  *
63
- * The libsql dialect returns `{ rowsAffected: number }` while the bun-sqlite
64
- * dialect returns `{ changes: number }`. Consumers must not depend on either
65
- * field directly use {@link didAffectRows} to normalise across drivers.
754
+ * The libsql dialect returns `{ rowsAffected: number }`, the bun-sqlite
755
+ * dialect returns `{ changes: number }`, and the node-postgres dialect returns
756
+ * `{ rowCount: number }`. Consumers must not depend on any of these fields
757
+ * directly — use {@link didAffectRows} to normalise across drivers.
66
758
  * @packageDocumentation
67
759
  */
68
760
  /**
69
761
  * Shape emitted by Drizzle write operations across all supported drivers.
70
762
  *
71
- * The libsql (Node.js) driver populates `rowsAffected`; the bun-sqlite driver
72
- * populates `changes`. Both may be present when a future driver version unifies
73
- * the surface; either being absent is normal.
763
+ * The libsql (Node.js) driver populates `rowsAffected`, the bun-sqlite driver
764
+ * populates `changes`, and the node-postgres driver populates `rowCount`.
765
+ * Several may be present when a future driver version unifies the surface;
766
+ * any being absent is normal.
74
767
  */
75
768
  interface DrizzleWriteResult {
769
+ /** Affected-row count reported by the libsql driver. */
76
770
  readonly rowsAffected?: number | null;
771
+ /** Affected-row count reported by the bun-sqlite driver. */
77
772
  readonly changes?: number | null;
773
+ /** Affected-row count reported by the node-postgres driver. */
774
+ readonly rowCount?: number | null;
78
775
  }
79
776
  /**
80
- * Determine whether a Drizzle write operation mutated at least one row.
777
+ * Extract the affected row count from a Drizzle write result.
81
778
  *
82
- * Normalises the driver-specific result shape so callers do not need to know
83
- * which SQLite dialect is active at runtime.
779
+ * Returns the driver-appropriate count regardless of which supported driver
780
+ * is active at runtime.
84
781
  * @param result - Write result from a Drizzle `insert`, `update`, or `delete`.
85
- * @returns `true` when one or more rows were affected.
782
+ * @returns Number of affected rows, defaulting to `0` when no field is set.
86
783
  */
87
- declare function didAffectRows(result: DrizzleWriteResult): boolean;
784
+ declare function affectedRowCount(result: DrizzleWriteResult): number;
88
785
  /**
89
- * Extract the affected row count from a Drizzle write result.
786
+ * Determine whether a Drizzle write operation mutated at least one row.
90
787
  *
91
- * Returns the driver-appropriate count regardless of whether the libsql or
92
- * bun-sqlite dialect is active.
788
+ * Normalises the driver-specific result shape so callers do not need to know
789
+ * which dialect is active at runtime.
93
790
  * @param result - Write result from a Drizzle `insert`, `update`, or `delete`.
94
- * @returns Number of affected rows, defaulting to `0` when neither field is set.
791
+ * @returns `true` when one or more rows were affected.
95
792
  */
96
- declare function affectedRowCount(result: DrizzleWriteResult): number;
793
+ declare function didAffectRows(result: DrizzleWriteResult): boolean;
97
794
  //#endregion
98
795
  //#region storage/drizzle/src/register-handlers.d.ts
99
796
  /**
@@ -118,6 +815,262 @@ type DrizzleHandlerRegistration<TSchema extends Record<string, unknown> = Record
118
815
  */
119
816
  declare function registerDrizzleHandlers<TSchema extends Record<string, unknown> = Record<string, never>>(registration: DrizzleHandlerRegistration<TSchema>): (bus: IMakaioBus, db: unknown, ctx: ExtensionContext) => (() => void) | void;
120
817
  //#endregion
818
+ //#region storage/drizzle/src/dialect.d.ts
819
+ /**
820
+ * Bidirectional type equality — resolves to `true` only when `A` and `B` are
821
+ * mutually identical (not merely mutually assignable in one direction).
822
+ */
823
+ type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
824
+ /**
825
+ * The single Postgres-only generated column key that is exempt from the
826
+ * select-row equality check in {@link PostgresTwinSchema}.
827
+ *
828
+ * Only this named key is exempt; any other extra, missing, or mistyped
829
+ * Postgres column still fails compilation. The structural parity test
830
+ * (`schema-parity.test.ts`) polices the exempted key per-table via
831
+ * `PG_ONLY_COLUMNS`.
832
+ */
833
+ type PostgresOnlyGeneratedColumnKey = 'contentTsv';
834
+ /**
835
+ * Validation type for a Postgres twin record: for every SQLite table key, the
836
+ * twin's `$inferSelect` row — with the Postgres-only generated column omitted
837
+ * via {@link PostgresOnlyGeneratedColumnKey} — must be identical to the
838
+ * canonical table's. On drift the expected property type collapses to an
839
+ * error-literal object that names the offending table key in the compile error.
840
+ */
841
+ type PostgresTwinSchema<TSqlite extends Record<string, SQLiteTable>, TPostgres extends Record<keyof TSqlite, PgTable>> = { readonly [K in keyof TSqlite]: Equal<TSqlite[K]['$inferSelect'], Omit<TPostgres[K]['$inferSelect'], PostgresOnlyGeneratedColumnKey>> extends true ? TPostgres[K] : {
842
+ readonly 'postgres twin has select-row drift for table': K;
843
+ } };
844
+ /**
845
+ * A schema declared for both storage dialects — a per-dialect table registry
846
+ * whose keys ARE the closed `StorageDialect` union, so {@link resolveSchema}
847
+ * resolves by plain key lookup. `postgres` is intentionally typed as
848
+ * `TSqlite`: at runtime it holds real `pgTable` twins, presented through the
849
+ * canonical SQLite-typed face (the same documented honesty model as the
850
+ * driver cast in `client.ts`). Congruence is compiler-enforced by
851
+ * {@link PostgresTwinSchema} at construction and by the structural parity test.
852
+ */
853
+ interface DialectSchema<TSqlite extends Record<string, SQLiteTable>> {
854
+ readonly sqlite: TSqlite;
855
+ readonly postgres: TSqlite;
856
+ }
857
+ /**
858
+ * Build a {@link DialectSchema} from a canonical SQLite table record and its
859
+ * congruent Postgres twins. Compile-time net: a missing twin, a non-PgTable
860
+ * value, or any select-row drift (outside the named
861
+ * {@link PostgresOnlyGeneratedColumnKey} exemption) fails compilation naming
862
+ * the table key. `$inferInsert` is deliberately NOT pinned (identity columns
863
+ * are absent from PG insert models while optional on SQLite autoincrement).
864
+ * @param sqlite - Canonical SQLite table objects, keyed by export name.
865
+ * @param postgres - Postgres twin table objects under the same keys.
866
+ * @returns The dialect schema consumed by {@link resolveSchema}.
867
+ */
868
+ declare function defineDialectSchema<TSqlite extends Record<string, SQLiteTable>, TPostgres extends Record<keyof TSqlite, PgTable>>(sqlite: TSqlite, postgres: TPostgres & PostgresTwinSchema<TSqlite, TPostgres>): DialectSchema<TSqlite>;
869
+ /**
870
+ * Resolve the dialect-correct table objects for a database handle.
871
+ *
872
+ * {@link DialectSchema} is a per-dialect table registry keyed by
873
+ * `StorageDialect` — its keys ARE the closed dialect union — so resolution is
874
+ * a branch-free registry lookup by the handle's dialect brand. Returns the
875
+ * SQLite-typed view in both cases; under Postgres the runtime objects are the
876
+ * congruent twins, so drizzle compiles correct SQL and value mappings.
877
+ * @param db - Database handle (brand read via `getDatabaseDialect`; unbranded
878
+ * handles resolve to SQLite). The brand is schema-independent, so handles of
879
+ * any schema generic are accepted (plain `MakaioDatabase` is assignable to
880
+ * this parameter type).
881
+ * @param schema - Dialect schema built by {@link defineDialectSchema}.
882
+ * @returns The table record for the handle's active dialect.
883
+ */
884
+ declare function resolveSchema<TSqlite extends Record<string, SQLiteTable>>(db: MakaioDatabase<Record<string, unknown>>, schema: DialectSchema<TSqlite>): TSqlite;
885
+ //#endregion
886
+ //#region storage/drizzle/src/dual-table.d.ts
887
+ type NotNullOf<B, TBase> = B extends {
888
+ notNull(): infer R extends TBase;
889
+ } ? R : never;
890
+ type DefaultOf<B, TBase> = B extends {
891
+ default(value: never): infer R extends TBase;
892
+ } ? R : never;
893
+ type PrimaryKeyOf<B, TBase> = B extends {
894
+ primaryKey(): infer R extends TBase;
895
+ } ? R : never;
896
+ type UniqueOf<B, TBase> = B extends {
897
+ unique(name?: string): infer R extends TBase;
898
+ } ? R : never;
899
+ /** Data type accepted by `.default()` — honours `$type` pinning like drizzle does. */
900
+ type DataOf<B extends ColumnBuilderBase> = B['_'] extends {
901
+ $type: infer U;
902
+ } ? U : B['_']['data'];
903
+ /**
904
+ * Foreign-key actions — shared shape across both dialects (drizzle's
905
+ * `ReferenceConfig['actions']` is identical for sqlite-core and pg-core).
906
+ */
907
+ interface DualReferenceActions {
908
+ readonly onUpdate?: 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
909
+ readonly onDelete?: 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
910
+ }
911
+ /**
912
+ * A built foreign-key target as a pair of both dialects' columns. Returned by
913
+ * {@link DualTable.columnPair} and consumed by {@link DualColumnRef}.
914
+ */
915
+ interface DualColumnPair {
916
+ readonly sqlite: SQLiteColumn;
917
+ readonly postgres: PgColumn;
918
+ }
919
+ /**
920
+ * A dual reference target: a lazy thunk returning BOTH dialects' built
921
+ * columns. For a cross-table FK this is `() => other.columnPair('col')`; for a
922
+ * self-FK it is `() => self.columnPair('col')` resolved against the table this
923
+ * very builder is part of. `references()` forwards `.sqlite` to the SQLite
924
+ * builder and `.postgres` to the Postgres builder, so each dialect receives the
925
+ * dialect-correct column with NO per-dialect annotation at the call site — the
926
+ * per-dialect column annotation a hand-written twin needs is absorbed once,
927
+ * here.
928
+ */
929
+ type DualColumnRef = () => DualColumnPair;
930
+ /**
931
+ * Structural base used as the generic constraint in `defineDualTable` —
932
+ * deliberately WITHOUT the chain methods so concrete `DualBuilder`
933
+ * instantiations stay assignable to it.
934
+ */
935
+ interface DualColumnBuilderBase<S extends SQLiteColumnBuilderBase = SQLiteColumnBuilderBase, P extends PgColumnBuilderBase = PgColumnBuilderBase> {
936
+ readonly sqlite: S;
937
+ readonly postgres: P;
938
+ }
939
+ /** Chainable pair of one SQLite builder and one Postgres builder. */
940
+ interface DualBuilder<S extends SQLiteColumnBuilderBase, P extends PgColumnBuilderBase> extends DualColumnBuilderBase<S, P> {
941
+ notNull(): DualBuilder<NotNullOf<S, SQLiteColumnBuilderBase>, NotNullOf<P, PgColumnBuilderBase>>;
942
+ default(value: (DataOf<S> & DataOf<P>) | SQL): DualBuilder<DefaultOf<S, SQLiteColumnBuilderBase>, DefaultOf<P, PgColumnBuilderBase>>;
943
+ primaryKey(): DualBuilder<PrimaryKeyOf<S, SQLiteColumnBuilderBase>, PrimaryKeyOf<P, PgColumnBuilderBase>>;
944
+ unique(name?: string): DualBuilder<UniqueOf<S, SQLiteColumnBuilderBase>, UniqueOf<P, PgColumnBuilderBase>>;
945
+ $type<T>(): DualBuilder<$Type<S, T>, $Type<P, T>>;
946
+ /**
947
+ * Declare a foreign key for BOTH dialects from one call.
948
+ * `references()` returns `this` on both drizzle builders, so the dual type is
949
+ * unchanged — chaining stays exact.
950
+ * @param ref - Lazy dual column-pair thunk (cross-table or self-FK).
951
+ * @param actions - Optional `onDelete` / `onUpdate` (shared shape).
952
+ */
953
+ references(ref: DualColumnRef, actions?: DualReferenceActions): DualBuilder<S, P>;
954
+ }
955
+ declare const dualColumns: {
956
+ /**
957
+ * Plain text column — `text` on both dialects (drizzle core per dialect).
958
+ * @param name - SQL column name.
959
+ * @returns Dual builder for a `text` column.
960
+ */
961
+ text: <TName extends string>(name: TName) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<TName, [string, ...string[]], number | undefined>, _$drizzle_orm_pg_core0.PgTextBuilderInitial<TName, [string, ...string[]]>>;
962
+ /**
963
+ * Enum-config text — preserves the `enum` name-literal generic on BOTH
964
+ * dialects (`text(name, { enum })`).
965
+ *
966
+ * The signature mirrors drizzle's own `text` overload: generic over the
967
+ * element union `U` and the readonly tuple `T extends Readonly<[U, ...U[]]>`
968
+ * so the literal values flow into `$inferSelect` as `'a' | 'b'`, not `string`.
969
+ * A naive `{ enum: TEnum }` parameter widens the array literal to `string[]`
970
+ * and collapses the union.
971
+ * @param name - SQL column name.
972
+ * @param config - Drizzle text config carrying the `enum` literal tuple.
973
+ * @returns Dual builder for a `text` column narrowed to the enum union.
974
+ */
975
+ textEnum: <TName extends string, U extends string, T extends Readonly<[U, ...U[]]>>(name: TName, config: {
976
+ enum: T;
977
+ }) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<TName, _$drizzle_orm0.Writable<T>, number | undefined>, _$drizzle_orm_pg_core0.PgTextBuilderInitial<TName, _$drizzle_orm0.Writable<T>>>;
978
+ /**
979
+ * Unix-epoch-ms — SQLite `integer` / PG `bigint` ('number' mode).
980
+ * @param name - SQL column name.
981
+ * @returns Dual builder for a millisecond-epoch column.
982
+ */
983
+ epochMs: (name: string) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgBigInt53BuilderInitial<string>>;
984
+ /**
985
+ * Boolean — SQLite `integer` (boolean mode) / PG native `boolean`.
986
+ * @param name - SQL column name.
987
+ * @returns Dual builder for a boolean column.
988
+ */
989
+ bool: (name: string) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteBooleanBuilderInitial<string>, _$drizzle_orm_pg_core0.PgBooleanBuilderInitial<string>>;
990
+ /**
991
+ * Structured JSON — SQLite `text` (json mode) / PG `jsonb`, pinned to T.
992
+ * @param name - SQL column name.
993
+ * @returns Dual builder for a JSON column typed as `T`.
994
+ */
995
+ jsonCol: <T>(name: string) => DualBuilder<$Type<_$drizzle_orm_sqlite_core0.SQLiteTextJsonBuilderInitial<string>, T>, $Type<_$drizzle_orm_pg_core0.PgJsonbBuilderInitial<string>, T>>;
996
+ /**
997
+ * Auto PK — SQLite `integer PK AUTOINCREMENT` / PG identity `bigint` PK.
998
+ * @param name - SQL column name.
999
+ * @returns Dual builder for an auto-generated primary key column.
1000
+ */
1001
+ autoPk: (name: string) => DualBuilder<_$drizzle_orm0.IsPrimaryKey<_$drizzle_orm0.HasDefault<_$drizzle_orm0.NotNull<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>>>>, _$drizzle_orm0.IsPrimaryKey<_$drizzle_orm0.NotNull<_$drizzle_orm0.IsIdentity<_$drizzle_orm_pg_core0.PgBigInt53BuilderInitial<string>, "always">>>>;
1002
+ /**
1003
+ * 8-byte float — SQLite `real` / PG `double precision`.
1004
+ * @param name - SQL column name.
1005
+ * @returns Dual builder for an 8-byte floating-point column.
1006
+ */
1007
+ float8: (name: string) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteRealBuilderInitial<string>, _$drizzle_orm_pg_core0.PgDoublePrecisionBuilderInitial<string>>;
1008
+ /**
1009
+ * 32-bit integer — SQLite `integer` / PG `integer` (int4↔int4). For values
1010
+ * that fit comfortably in 32 bits (PIDs, ordinals, attempt counters).
1011
+ * @param name - SQL column name.
1012
+ * @returns Dual builder for a 32-bit integer column.
1013
+ */
1014
+ int4: (name: string) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgIntegerBuilderInitial<string>>;
1015
+ /**
1016
+ * 64-bit integer — SQLite `integer` / PG `bigint` ('number' mode, int53-safe).
1017
+ * For values that exceed the 32-bit range (byte cursors over large files).
1018
+ * Distinct from `epochMs` only in intent; identical SQL mapping.
1019
+ * @param name - SQL column name.
1020
+ * @returns Dual builder for a 64-bit integer column.
1021
+ */
1022
+ int8: (name: string) => DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgBigInt53BuilderInitial<string>>;
1023
+ };
1024
+ /**
1025
+ * Dialect-neutral column bundle passed to {@link defineDualTable}'s `colsFn`.
1026
+ *
1027
+ * Each helper builds both dialects' column builders from a single call, so a
1028
+ * column declared once can never silently drift between the SQLite and Postgres
1029
+ * faces.
1030
+ */
1031
+ type DualColumnBundle = typeof dualColumns;
1032
+ type SqliteSplit<TCols extends Record<string, DualColumnBuilderBase>> = { [K in keyof TCols]: TCols[K]['sqlite'] };
1033
+ type PgSplit<TCols extends Record<string, DualColumnBuilderBase>> = { [K in keyof TCols]: TCols[K]['postgres'] };
1034
+ /** Result of {@link defineDualTable}: both real drizzle tables, fully typed. */
1035
+ interface DualTable<TName extends string, TCols extends Record<string, DualColumnBuilderBase>> {
1036
+ readonly sqlite: SQLiteTableWithColumns<{
1037
+ name: TName;
1038
+ schema: undefined;
1039
+ columns: BuildColumns<TName, SqliteSplit<TCols>, 'sqlite'>;
1040
+ dialect: 'sqlite';
1041
+ }>;
1042
+ readonly postgres: PgTableWithColumns<{
1043
+ name: TName;
1044
+ schema: undefined;
1045
+ columns: BuildColumns<TName, PgSplit<TCols>, 'pg'>;
1046
+ dialect: 'pg';
1047
+ }>;
1048
+ /**
1049
+ * Lazy dual column-pair accessor for foreign-key targets. Returns the BUILT
1050
+ * columns of both faces under one key, so a referencing table can write
1051
+ * `() => target.columnPair('id')` and have each dialect resolve correctly.
1052
+ * @param key - Column key (the JS property name on the dual record).
1053
+ * @returns The SQLite and Postgres built columns for `key`.
1054
+ */
1055
+ columnPair<K extends keyof TCols>(key: K): DualColumnPair;
1056
+ }
1057
+ /**
1058
+ * Dialect-divergent extra config (indexes etc.). TWO callbacks: partial-index
1059
+ * predicates legitimately differ (`= 1` vs `= true`).
1060
+ */
1061
+ interface DualTableExtras<TName extends string, TCols extends Record<string, DualColumnBuilderBase>> {
1062
+ readonly sqlite?: (self: BuildColumns<TName, SqliteSplit<TCols>, 'sqlite'>) => SQLiteTableExtraConfigValue[];
1063
+ readonly postgres?: (self: BuildExtraConfigColumns<TName, PgSplit<TCols>, 'pg'>) => PgTableExtraConfigValue[];
1064
+ }
1065
+ /**
1066
+ * Define ONE table for BOTH dialects from a single column definition.
1067
+ * @param name - SQL table name (shared by both dialects).
1068
+ * @param colsFn - Column definition over the dialect-neutral bundle.
1069
+ * @param extras - Optional per-dialect indexes/constraints.
1070
+ * @returns A {@link DualTable} exposing both built table objects and `columnPair`.
1071
+ */
1072
+ declare function defineDualTable<TName extends string, TCols extends Record<string, DualColumnBuilderBase>>(name: TName, colsFn: (c: DualColumnBundle) => TCols, extras?: DualTableExtras<TName, TCols>): DualTable<TName, TCols>;
1073
+ //#endregion
121
1074
  //#region storage/drizzle/src/index.d.ts
122
1075
  /**
123
1076
  * Drizzle schema record type.
@@ -134,4 +1087,4 @@ declare module '@makaio/framework/storage' {
134
1087
  }
135
1088
  }
136
1089
  //#endregion
137
- export { type DrizzleHandlerRegistration, DrizzleSchemaRecord, type MakaioDatabase, type StorageNamespace, type StorageNamespaceConfig, type StorageNamespaceExtensions, type TransactionCallback, affectedRowCount, createStorageNamespace, didAffectRows, executeTransaction, registerDrizzleHandlers, sanitizeFtsQuery };
1090
+ export { DATABASE_DIALECT, type DialectSchema, type DrizzleHandlerRegistration, DrizzleSchemaRecord, type DrizzleWriteResult, type DualBuilder, type DualColumnBuilderBase, type DualColumnBundle, type DualColumnRef, type DualReferenceActions, type DualTable, type DualTableExtras, type Equal, type FtsMessageExcerptHit, type FtsMessageSearchInput, type FtsSearchStrategy, type FtsSessionCountInput, type FtsSessionSearchInput, type MakaioDatabase, NON_BASELINE_GENERATION_LEGS, type PostgresTwinSchema, type RawSqlExecutor, type RawSqlSession, STORAGE_ENGINE_URL_HINTS, type StorageDialect, type StorageEngine, type StorageEngineCapabilities, type StorageEngineErrorClassifiers, type StorageEngineGenerationLeg, type StorageEngineMigrationBehavior, type StorageEngineUrlHint, type StorageEngineUrlResolution, type StorageNamespace, type StorageNamespaceConfig, type StorageNamespaceExtensions, type TransactionCallback, affectedRowCount, brandDatabase, buildFirstUserMessagePreviewQuery, createStorageNamespace, defineDialectSchema, defineDualTable, describeMissingStorageEngine, didAffectRows, executeTransaction, findGenerationLegForDialect, findStorageEngine, getDatabaseDialect, getRawSqlExecutor, getStorageEngine, importRuntimeModule, isSqliteDuplicateObjectError, isSqliteUniqueViolationError, quoteSqlIdentifier, readErrorCode, registerDrizzleHandlers, registerStorageEngine, resolveSchema, resolveStorageEngine, resolveStorageEngineForUrl, sanitizeFtsQuery, someInCauseChain, sqliteFtsSearchStrategy, sqliteStorageEngine };