mcard-js 2.1.41 → 2.1.43

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 (388) hide show
  1. package/dist/{CardCollection-MXTUJV4J.js → CardCollection-7DKJWKAG.js} +3 -2
  2. package/dist/CardCollection-S4RE3RXP.js +10 -0
  3. package/dist/CardCollection-VPN7AAAX.js +10 -0
  4. package/dist/{IndexedDBEngine-2G5KCISA.js → IndexedDBEngine-7JOGM2MM.js} +3 -2
  5. package/dist/IndexedDBEngine-BGZHJK5L.js +12 -0
  6. package/dist/IndexedDBEngine-ZJ442GI7.js +12 -0
  7. package/dist/{LLMRuntime-GIGDMDEZ.js → LLMRuntime-OZNVAPXJ.js} +4 -3
  8. package/dist/{LLMRuntime-LBWUJ7ON.js → LLMRuntime-UPSEDSIK.js} +2 -2
  9. package/dist/{LambdaRuntime-B6D6IQKZ.js → LambdaRuntime-JZ4Q56TI.js} +6 -5
  10. package/dist/LambdaRuntime-PM3OUFHU.js +19 -0
  11. package/dist/LambdaRuntime-WBEK37AF.js +19 -0
  12. package/dist/LambdaRuntime-YKSBAT65.js +19 -0
  13. package/dist/{Loader-3LSJXJQG.js → Loader-7HQVYDPA.js} +2 -2
  14. package/dist/{Loader-BM56B2TX.js → Loader-NYWTV7CQ.js} +4 -3
  15. package/dist/{Loader-CYLAA4XU.js → Loader-OLKPY6HT.js} +3 -3
  16. package/dist/{MCard-H56VOJLR.js → MCard-OYI73CUI.js} +1 -1
  17. package/dist/{MCard-5LIREV2B.js → MCard-XHG3BZC7.js} +2 -2
  18. package/dist/{NetworkRuntime-IAFHPQSX.js → NetworkRuntime-VYCC5HSY.js} +16 -11
  19. package/dist/{NetworkRuntime-JNGKW3DY.js → NetworkRuntime-XQX3LDDI.js} +61 -33
  20. package/dist/{NetworkRuntime-CXPKIAOQ.js → NetworkRuntime-XZR733M5.js} +17 -12
  21. package/dist/{OllamaProvider-QPX2JXL2.js → OllamaProvider-FBZ5WW72.js} +1 -1
  22. package/dist/OllamaProvider-W6TPZNHD.js +9 -0
  23. package/dist/chunk-2NFGZ6PA.js +170 -0
  24. package/dist/{chunk-VXV35I5J.js → chunk-4TYRTQ4V.js} +48 -17
  25. package/dist/chunk-4VWWTGRW.js +497 -0
  26. package/dist/{chunk-4PDYHPR6.js → chunk-5GHZP7E5.js} +4 -2
  27. package/dist/{chunk-42VF42KH.js → chunk-5HZNWJFT.js} +4 -2
  28. package/dist/{chunk-DEYMHG5A.js → chunk-6MG5ZHAP.js} +58 -22
  29. package/dist/{chunk-7V37AAPK.js → chunk-7B4PABOL.js} +16 -7
  30. package/dist/chunk-A5S2PI37.js +47 -0
  31. package/dist/chunk-BFD4WSWU.js +497 -0
  32. package/dist/chunk-BSEFN25Q.js +32 -0
  33. package/dist/{chunk-3LPY36OG.js → chunk-CBEVE7RG.js} +20 -15
  34. package/dist/{chunk-A5AB4WQN.js → chunk-DPA3ZK4Q.js} +30 -21
  35. package/dist/{chunk-5FA54AMM.js → chunk-EJHX3VZL.js} +54 -21
  36. package/dist/{chunk-QXPHMSPA.js → chunk-GNF4WAPV.js} +22 -9
  37. package/dist/{chunk-XPG6B5IW.js → chunk-JHIA2BQK.js} +26 -13
  38. package/dist/{chunk-4I5IZILN.js → chunk-KGPICAQW.js} +10 -7
  39. package/dist/{chunk-4WBJPHZP.js → chunk-MST5AZXJ.js} +17 -8
  40. package/dist/{chunk-K35KFTEA.js → chunk-N6KDHCBC.js} +58 -33
  41. package/dist/{chunk-2R4ESMZB.js → chunk-NFO5NU6B.js} +5 -3
  42. package/dist/chunk-OKWBHCKC.js +170 -0
  43. package/dist/{chunk-FIE4LAJG.js → chunk-OX3K6UZJ.js} +5 -3
  44. package/dist/{chunk-6SEX42H2.js → chunk-R3K7DG7O.js} +21 -16
  45. package/dist/chunk-RB35Z35T.js +44 -0
  46. package/dist/{chunk-AWGFLRLI.js → chunk-SP4YPKPR.js} +51 -318
  47. package/dist/chunk-U7TSFDKX.js +217 -0
  48. package/dist/chunk-UP3SQX56.js +112 -0
  49. package/dist/{chunk-4EUEU4SM.js → chunk-VGIRC3HX.js} +13 -110
  50. package/dist/chunk-WGG7526Z.js +112 -0
  51. package/dist/{chunk-3JBSRALP.js → chunk-WNKP66IR.js} +10 -7
  52. package/dist/{chunk-DOC55MPG.js → chunk-WR6ISHCS.js} +11 -3
  53. package/dist/{chunk-52UNWVOD.js → chunk-ZVOPQ5BM.js} +54 -21
  54. package/dist/chunk-ZZMOPQER.js +217 -0
  55. package/dist/index.browser.cjs +79 -1454
  56. package/dist/index.browser.d.cts +2 -17
  57. package/dist/index.browser.d.ts +2 -17
  58. package/dist/index.browser.js +7 -6
  59. package/dist/index.cjs +306 -1631
  60. package/dist/index.d.cts +3 -1
  61. package/dist/index.d.ts +3 -1
  62. package/dist/index.js +49 -35
  63. package/dist/storage/SqliteNodeEngine.cjs +59 -1335
  64. package/dist/storage/SqliteNodeEngine.js +4 -3
  65. package/dist/storage/SqliteWasmEngine.cjs +57 -1335
  66. package/dist/storage/SqliteWasmEngine.js +4 -3
  67. package/package.json +12 -8
  68. package/dist/CardCollection-4OFJ6XQJ.js +0 -9
  69. package/dist/CardCollection-7PDWM24F.js +0 -9
  70. package/dist/CardCollection-CEFQ5PA6.js +0 -9
  71. package/dist/CardCollection-GUEYGN2Y.js +0 -9
  72. package/dist/CardCollection-KDO4CQ4B.js +0 -9
  73. package/dist/CardCollection-PB7ZY73E.js +0 -9
  74. package/dist/CardCollection-RK4DVH63.js +0 -9
  75. package/dist/CardCollection-T376E3TS.js +0 -9
  76. package/dist/CardCollection-WGCKKUOD.js +0 -9
  77. package/dist/CardCollection-XON2IWDU.js +0 -9
  78. package/dist/CardCollection-ZEI6FMP3.js +0 -9
  79. package/dist/EventProducer-MW6QF4IO.js +0 -47
  80. package/dist/EventProducer-V7RY2KKR.js +0 -47
  81. package/dist/FileIO.d.ts +0 -44
  82. package/dist/FileIO.d.ts.map +0 -1
  83. package/dist/FileIO.js +0 -203
  84. package/dist/FileIO.js.map +0 -1
  85. package/dist/IndexedDBEngine-7JI2CL32.js +0 -10
  86. package/dist/IndexedDBEngine-7OHQIRTI.js +0 -10
  87. package/dist/IndexedDBEngine-E5YJQG4U.js +0 -10
  88. package/dist/IndexedDBEngine-NV625E7L.js +0 -10
  89. package/dist/IndexedDBEngine-RPQS7ILF.js +0 -10
  90. package/dist/IndexedDBEngine-S3ZWCSI7.js +0 -10
  91. package/dist/IndexedDBEngine-T7OC5GRR.js +0 -10
  92. package/dist/LLMRuntime-BKB3CLXM.js +0 -16
  93. package/dist/LLMRuntime-BQUUFLAB.js +0 -16
  94. package/dist/LLMRuntime-TNBC4JCB.js +0 -16
  95. package/dist/LambdaRuntime-4YILF3G7.js +0 -15
  96. package/dist/LambdaRuntime-53TPVENI.js +0 -16
  97. package/dist/LambdaRuntime-73BSWP2G.js +0 -16
  98. package/dist/LambdaRuntime-AL5SBDCA.js +0 -17
  99. package/dist/LambdaRuntime-BYBUI7H5.js +0 -17
  100. package/dist/LambdaRuntime-JDZP3HIQ.js +0 -17
  101. package/dist/LambdaRuntime-JEI7RVWG.js +0 -16
  102. package/dist/LambdaRuntime-LCTHBYMV.js +0 -17
  103. package/dist/LambdaRuntime-LDA3G7IR.js +0 -16
  104. package/dist/LambdaRuntime-LF4FR6YA.js +0 -16
  105. package/dist/LambdaRuntime-O7JBVHO2.js +0 -16
  106. package/dist/LambdaRuntime-OFOTT464.js +0 -17
  107. package/dist/LambdaRuntime-Q6ISCHAD.js +0 -16
  108. package/dist/LambdaRuntime-TCZ42XCB.js +0 -16
  109. package/dist/LambdaRuntime-UKUOKJIW.js +0 -17
  110. package/dist/LambdaRuntime-VKLON4IB.js +0 -17
  111. package/dist/LambdaRuntime-WNYDBTS6.js +0 -16
  112. package/dist/LambdaRuntime-WPTX76CX.js +0 -17
  113. package/dist/Loader-4P7PEBCL.js +0 -11
  114. package/dist/Loader-HQ3QKMYM.js +0 -11
  115. package/dist/Loader-NCATGB67.js +0 -11
  116. package/dist/Loader-NRHGDQBD.js +0 -11
  117. package/dist/Loader-RT4NI6AT.js +0 -11
  118. package/dist/Loader-SSRY57SS.js +0 -11
  119. package/dist/Loader-W72QZ3T7.js +0 -11
  120. package/dist/Loader-WECRIXQW.js +0 -11
  121. package/dist/Loader-XFBIHCQF.js +0 -11
  122. package/dist/Loader.d.ts +0 -34
  123. package/dist/Loader.d.ts.map +0 -1
  124. package/dist/Loader.js +0 -190
  125. package/dist/Loader.js.map +0 -1
  126. package/dist/MCard-4J6WSBRF.js +0 -8
  127. package/dist/MCard-E3MRPTJF.js +0 -8
  128. package/dist/MCard-FCOIB6BP.js +0 -8
  129. package/dist/MCard-G4HUWHY5.js +0 -8
  130. package/dist/MCard-HFL7AFIH.js +0 -8
  131. package/dist/MCard-JOW6RBSO.js +0 -8
  132. package/dist/MCard-M4LKN4U2.js +0 -8
  133. package/dist/MCard-VB7UDUTN.js +0 -8
  134. package/dist/MCard-WOHE6SX6.js +0 -8
  135. package/dist/NetworkRuntime-2H7AQITA.js +0 -1571
  136. package/dist/NetworkRuntime-3MIUBNOF.js +0 -1571
  137. package/dist/NetworkRuntime-AOE2EJIM.js +0 -1571
  138. package/dist/NetworkRuntime-BQMDBUDO.js +0 -1570
  139. package/dist/NetworkRuntime-GMANLCAB.js +0 -1542
  140. package/dist/NetworkRuntime-L7P4VCGK.js +0 -1542
  141. package/dist/NetworkRuntime-LC7SUAOF.js +0 -1542
  142. package/dist/NetworkRuntime-OJWCWPBI.js +0 -1570
  143. package/dist/NetworkRuntime-ZJ3B4T3A.js +0 -1542
  144. package/dist/OllamaProvider-32RC36HD.js +0 -8
  145. package/dist/OllamaProvider-MQXSXLCA.js +0 -8
  146. package/dist/OllamaProvider-Q45BMOVN.js +0 -8
  147. package/dist/SqliteNodeEngine-WKVFWBNH.js +0 -9
  148. package/dist/StorageAdapter-DdDUiIvH.d.cts +0 -391
  149. package/dist/StorageAdapter-DdDUiIvH.d.ts +0 -391
  150. package/dist/StorageAdapter-Dw1BeOam.d.cts +0 -380
  151. package/dist/StorageAdapter-Dw1BeOam.d.ts +0 -380
  152. package/dist/chunk-23GCCCXB.js +0 -402
  153. package/dist/chunk-2ECISK2I.js +0 -354
  154. package/dist/chunk-2MRBTM72.js +0 -354
  155. package/dist/chunk-2THXO6FH.js +0 -2313
  156. package/dist/chunk-2VNRWIBZ.js +0 -389
  157. package/dist/chunk-2VOQRXWH.js +0 -296
  158. package/dist/chunk-34AYBZRO.js +0 -920
  159. package/dist/chunk-37EEYISR.js +0 -372
  160. package/dist/chunk-3E2TKOCZ.js +0 -354
  161. package/dist/chunk-3MMMJ7NH.js +0 -1068
  162. package/dist/chunk-437JTYVP.js +0 -292
  163. package/dist/chunk-4MQINOOG.js +0 -1218
  164. package/dist/chunk-4UIWXZHY.js +0 -1049
  165. package/dist/chunk-53S2EZCY.js +0 -290
  166. package/dist/chunk-5BIDGXA6.js +0 -987
  167. package/dist/chunk-5HXLTWYN.js +0 -296
  168. package/dist/chunk-5W2FDGUF.js +0 -371
  169. package/dist/chunk-6R4ERZMG.js +0 -1136
  170. package/dist/chunk-74YSNHEM.js +0 -2309
  171. package/dist/chunk-7H2BQZDK.js +0 -270
  172. package/dist/chunk-7KEWCCES.js +0 -1136
  173. package/dist/chunk-7PN2BUYF.js +0 -371
  174. package/dist/chunk-A2ZJA2EV.js +0 -389
  175. package/dist/chunk-ARPIBGRP.js +0 -1236
  176. package/dist/chunk-ATHNEEAG.js +0 -2309
  177. package/dist/chunk-AVXJOPUE.js +0 -354
  178. package/dist/chunk-B7VEU4S2.js +0 -204
  179. package/dist/chunk-C2TKISBR.js +0 -1213
  180. package/dist/chunk-CBH4YKB4.js +0 -2309
  181. package/dist/chunk-DP7HBRDL.js +0 -2309
  182. package/dist/chunk-DV7ZSH4W.js +0 -2309
  183. package/dist/chunk-DWXNZ5AJ.js +0 -642
  184. package/dist/chunk-EFKMZTT2.js +0 -270
  185. package/dist/chunk-FXJYXHG6.js +0 -266
  186. package/dist/chunk-G466I6RT.js +0 -229
  187. package/dist/chunk-GATPBTHL.js +0 -1142
  188. package/dist/chunk-GMQAHPBC.js +0 -292
  189. package/dist/chunk-GMWA2IJJ.js +0 -1105
  190. package/dist/chunk-GVX5LDLH.js +0 -371
  191. package/dist/chunk-HGENNKOJ.js +0 -355
  192. package/dist/chunk-HM2NBYHU.js +0 -292
  193. package/dist/chunk-IZWB5GCG.js +0 -389
  194. package/dist/chunk-J4HOFUKM.js +0 -2309
  195. package/dist/chunk-JIK2G3EH.js +0 -2313
  196. package/dist/chunk-JRXNWGSW.js +0 -1136
  197. package/dist/chunk-KRKK3KP6.js +0 -1081
  198. package/dist/chunk-KYXZHRUG.js +0 -389
  199. package/dist/chunk-L36L2VDL.js +0 -371
  200. package/dist/chunk-L5PZCES6.js +0 -204
  201. package/dist/chunk-L5U77ZEM.js +0 -1142
  202. package/dist/chunk-LQEKGX2T.js +0 -204
  203. package/dist/chunk-LWMUDMMQ.js +0 -1144
  204. package/dist/chunk-MLKGABMK.js +0 -9
  205. package/dist/chunk-NZ6OQ7UT.js +0 -92
  206. package/dist/chunk-O2UMNZGF.js +0 -903
  207. package/dist/chunk-OFHDMLNM.js +0 -355
  208. package/dist/chunk-PDBMNUMB.js +0 -316
  209. package/dist/chunk-PW4XS7M3.js +0 -850
  210. package/dist/chunk-QA2XQMMJ.js +0 -2313
  211. package/dist/chunk-QL2JFNA7.js +0 -389
  212. package/dist/chunk-QPZ2HNSU.js +0 -912
  213. package/dist/chunk-QVGVU6OS.js +0 -296
  214. package/dist/chunk-RCEU7PFH.js +0 -270
  215. package/dist/chunk-RSTKX7WM.js +0 -907
  216. package/dist/chunk-RXL2CW64.js +0 -266
  217. package/dist/chunk-RXUF6Y43.js +0 -2309
  218. package/dist/chunk-SIAA4J6H.js +0 -21
  219. package/dist/chunk-SOJ2UMO2.js +0 -986
  220. package/dist/chunk-T3AG6DXY.js +0 -296
  221. package/dist/chunk-TPCNKMGZ.js +0 -355
  222. package/dist/chunk-TPT3S5AX.js +0 -204
  223. package/dist/chunk-TXWGIEVH.js +0 -2313
  224. package/dist/chunk-TZFI54AU.js +0 -2313
  225. package/dist/chunk-U3FWUPD3.js +0 -717
  226. package/dist/chunk-UFW2VW2D.js +0 -266
  227. package/dist/chunk-UTAOS5Y7.js +0 -2313
  228. package/dist/chunk-V7VX5OJ6.js +0 -389
  229. package/dist/chunk-W2XGNMYB.js +0 -355
  230. package/dist/chunk-W3M4HJ4U.js +0 -2309
  231. package/dist/chunk-WMJGGREP.js +0 -296
  232. package/dist/chunk-WTNVQ5WS.js +0 -732
  233. package/dist/chunk-WVFWNVT2.js +0 -1050
  234. package/dist/chunk-WY7EYSYC.js +0 -1236
  235. package/dist/chunk-X42F7DE3.js +0 -373
  236. package/dist/chunk-XC7Y4I7L.js +0 -290
  237. package/dist/chunk-YFULZTKP.js +0 -270
  238. package/dist/chunk-YSVHXKSZ.js +0 -373
  239. package/dist/chunk-YWGVK5OS.js +0 -292
  240. package/dist/chunk-Z4BRNTO5.js +0 -2313
  241. package/dist/chunk-ZDUXDKPD.js +0 -292
  242. package/dist/chunk-ZXQ2W7LO.js +0 -355
  243. package/dist/chunk-ZXQELXXO.js +0 -378
  244. package/dist/index.browser.d.ts.map +0 -1
  245. package/dist/index.browser.js.map +0 -1
  246. package/dist/index.d.ts.map +0 -1
  247. package/dist/index.js.map +0 -1
  248. package/dist/lib-4XS34IPZ.js +0 -778
  249. package/dist/model/CardCollection.d.ts +0 -147
  250. package/dist/model/CardCollection.d.ts.map +0 -1
  251. package/dist/model/CardCollection.js +0 -272
  252. package/dist/model/CardCollection.js.map +0 -1
  253. package/dist/model/ContentTypeInterpreter.d.ts +0 -28
  254. package/dist/model/ContentTypeInterpreter.d.ts.map +0 -1
  255. package/dist/model/ContentTypeInterpreter.js +0 -147
  256. package/dist/model/ContentTypeInterpreter.js.map +0 -1
  257. package/dist/model/EventProducer.d.ts +0 -10
  258. package/dist/model/EventProducer.d.ts.map +0 -1
  259. package/dist/model/EventProducer.js +0 -46
  260. package/dist/model/EventProducer.js.map +0 -1
  261. package/dist/model/GTime.d.ts +0 -44
  262. package/dist/model/GTime.d.ts.map +0 -1
  263. package/dist/model/GTime.js +0 -91
  264. package/dist/model/GTime.js.map +0 -1
  265. package/dist/model/Handle.d.ts +0 -37
  266. package/dist/model/Handle.d.ts.map +0 -1
  267. package/dist/model/Handle.js +0 -90
  268. package/dist/model/Handle.js.map +0 -1
  269. package/dist/model/MCard.d.ts +0 -145
  270. package/dist/model/MCard.d.ts.map +0 -1
  271. package/dist/model/MCard.js +0 -180
  272. package/dist/model/MCard.js.map +0 -1
  273. package/dist/model/PCard.d.ts +0 -271
  274. package/dist/model/PCard.d.ts.map +0 -1
  275. package/dist/model/PCard.js +0 -558
  276. package/dist/model/PCard.js.map +0 -1
  277. package/dist/model/VCard.d.ts +0 -277
  278. package/dist/model/VCard.d.ts.map +0 -1
  279. package/dist/model/VCard.js +0 -573
  280. package/dist/model/VCard.js.map +0 -1
  281. package/dist/model/constants.d.ts +0 -45
  282. package/dist/model/constants.d.ts.map +0 -1
  283. package/dist/model/constants.js +0 -27
  284. package/dist/model/constants.js.map +0 -1
  285. package/dist/model/vcard_vocabulary.d.ts +0 -174
  286. package/dist/model/vcard_vocabulary.d.ts.map +0 -1
  287. package/dist/model/vcard_vocabulary.js +0 -187
  288. package/dist/model/vcard_vocabulary.js.map +0 -1
  289. package/dist/monads/Either.d.ts +0 -51
  290. package/dist/monads/Either.d.ts.map +0 -1
  291. package/dist/monads/Either.js +0 -82
  292. package/dist/monads/Either.js.map +0 -1
  293. package/dist/monads/IO.d.ts +0 -38
  294. package/dist/monads/IO.d.ts.map +0 -1
  295. package/dist/monads/IO.js +0 -66
  296. package/dist/monads/IO.js.map +0 -1
  297. package/dist/monads/Maybe.d.ts +0 -45
  298. package/dist/monads/Maybe.d.ts.map +0 -1
  299. package/dist/monads/Maybe.js +0 -73
  300. package/dist/monads/Maybe.js.map +0 -1
  301. package/dist/monads/Reader.d.ts +0 -29
  302. package/dist/monads/Reader.d.ts.map +0 -1
  303. package/dist/monads/Reader.js +0 -44
  304. package/dist/monads/Reader.js.map +0 -1
  305. package/dist/monads/State.d.ts +0 -33
  306. package/dist/monads/State.d.ts.map +0 -1
  307. package/dist/monads/State.js +0 -50
  308. package/dist/monads/State.js.map +0 -1
  309. package/dist/monads/Writer.d.ts +0 -29
  310. package/dist/monads/Writer.d.ts.map +0 -1
  311. package/dist/monads/Writer.js +0 -46
  312. package/dist/monads/Writer.js.map +0 -1
  313. package/dist/ptr/Bridgelet.d.ts +0 -180
  314. package/dist/ptr/Bridgelet.d.ts.map +0 -1
  315. package/dist/ptr/Bridgelet.js +0 -296
  316. package/dist/ptr/Bridgelet.js.map +0 -1
  317. package/dist/ptr/CLMIntrospection.d.ts +0 -169
  318. package/dist/ptr/CLMIntrospection.d.ts.map +0 -1
  319. package/dist/ptr/CLMIntrospection.js +0 -329
  320. package/dist/ptr/CLMIntrospection.js.map +0 -1
  321. package/dist/ptr/FaroSidecar.d.ts +0 -56
  322. package/dist/ptr/FaroSidecar.d.ts.map +0 -1
  323. package/dist/ptr/FaroSidecar.js +0 -102
  324. package/dist/ptr/FaroSidecar.js.map +0 -1
  325. package/dist/ptr/LensProtocol.d.ts +0 -84
  326. package/dist/ptr/LensProtocol.d.ts.map +0 -1
  327. package/dist/ptr/LensProtocol.js +0 -98
  328. package/dist/ptr/LensProtocol.js.map +0 -1
  329. package/dist/ptr/OpenTelemetrySidecar.d.ts +0 -144
  330. package/dist/ptr/OpenTelemetrySidecar.d.ts.map +0 -1
  331. package/dist/ptr/OpenTelemetrySidecar.js +0 -232
  332. package/dist/ptr/OpenTelemetrySidecar.js.map +0 -1
  333. package/dist/ptr/SandboxWorker.d.ts +0 -79
  334. package/dist/ptr/SandboxWorker.d.ts.map +0 -1
  335. package/dist/ptr/SandboxWorker.js +0 -298
  336. package/dist/ptr/SandboxWorker.js.map +0 -1
  337. package/dist/ptr/common_types.d.ts +0 -39
  338. package/dist/ptr/common_types.d.ts.map +0 -1
  339. package/dist/ptr/common_types.js +0 -12
  340. package/dist/ptr/common_types.js.map +0 -1
  341. package/dist/rag/GraphRAGEngine.d.ts +0 -26
  342. package/dist/rag/GraphRAGEngine.d.ts.map +0 -1
  343. package/dist/rag/GraphRAGEngine.js +0 -166
  344. package/dist/rag/GraphRAGEngine.js.map +0 -1
  345. package/dist/rag/HandleVectorStore.d.ts +0 -201
  346. package/dist/rag/HandleVectorStore.d.ts.map +0 -1
  347. package/dist/rag/HandleVectorStore.js +0 -527
  348. package/dist/rag/HandleVectorStore.js.map +0 -1
  349. package/dist/rag/PersistentIndexer.d.ts +0 -148
  350. package/dist/rag/PersistentIndexer.d.ts.map +0 -1
  351. package/dist/rag/PersistentIndexer.js +0 -302
  352. package/dist/rag/PersistentIndexer.js.map +0 -1
  353. package/dist/rag/index.d.ts +0 -20
  354. package/dist/rag/index.d.ts.map +0 -1
  355. package/dist/rag/index.js +0 -26
  356. package/dist/rag/index.js.map +0 -1
  357. package/dist/rag/semanticVersioning.d.ts +0 -187
  358. package/dist/rag/semanticVersioning.d.ts.map +0 -1
  359. package/dist/rag/semanticVersioning.js +0 -253
  360. package/dist/rag/semanticVersioning.js.map +0 -1
  361. package/dist/storage/IndexedDBEngine.d.ts +0 -33
  362. package/dist/storage/IndexedDBEngine.d.ts.map +0 -1
  363. package/dist/storage/IndexedDBEngine.js +0 -198
  364. package/dist/storage/IndexedDBEngine.js.map +0 -1
  365. package/dist/storage/SqliteNodeEngine.d.ts.map +0 -1
  366. package/dist/storage/SqliteNodeEngine.js.map +0 -1
  367. package/dist/storage/SqliteWasmEngine.d.ts.map +0 -1
  368. package/dist/storage/SqliteWasmEngine.js.map +0 -1
  369. package/dist/storage/StorageAdapter.d.ts +0 -42
  370. package/dist/storage/StorageAdapter.d.ts.map +0 -1
  371. package/dist/storage/StorageAdapter.js +0 -2
  372. package/dist/storage/StorageAdapter.js.map +0 -1
  373. package/dist/storage/VectorStore.d.ts +0 -202
  374. package/dist/storage/VectorStore.d.ts.map +0 -1
  375. package/dist/storage/VectorStore.js +0 -557
  376. package/dist/storage/VectorStore.js.map +0 -1
  377. package/dist/storage/schema.d.ts +0 -162
  378. package/dist/storage/schema.d.ts.map +0 -1
  379. package/dist/storage/schema.js +0 -335
  380. package/dist/storage/schema.js.map +0 -1
  381. package/dist/storage/schema_constants.d.ts +0 -7
  382. package/dist/storage/schema_constants.d.ts.map +0 -1
  383. package/dist/storage/schema_constants.js +0 -415
  384. package/dist/storage/schema_constants.js.map +0 -1
  385. package/dist/types/dots.d.ts +0 -206
  386. package/dist/types/dots.d.ts.map +0 -1
  387. package/dist/types/dots.js +0 -201
  388. package/dist/types/dots.js.map +0 -1
@@ -1,1081 +0,0 @@
1
- import {
2
- MCard
3
- } from "./chunk-PW4XS7M3.js";
4
-
5
- // src/model/Handle.ts
6
- var MAX_HANDLE_LENGTH = 255;
7
- function isValidStartChar(char) {
8
- return /^\p{L}$/u.test(char);
9
- }
10
- function isValidBodyChar(char) {
11
- return /^[\p{L}\p{N}_./ -]$/u.test(char);
12
- }
13
- var HandleValidationError = class extends Error {
14
- constructor(message) {
15
- super(message);
16
- this.name = "HandleValidationError";
17
- }
18
- };
19
- function validateHandle(handle) {
20
- if (!handle) {
21
- throw new HandleValidationError("Handle cannot be empty.");
22
- }
23
- const normalized = handle.trim().normalize("NFC").toLowerCase();
24
- if (normalized.length === 0) {
25
- throw new HandleValidationError("Handle cannot be empty after normalization.");
26
- }
27
- if (normalized.length > MAX_HANDLE_LENGTH) {
28
- throw new HandleValidationError(
29
- `Handle '${handle}' is too long (${normalized.length} chars). Maximum is ${MAX_HANDLE_LENGTH}.`
30
- );
31
- }
32
- if (!isValidStartChar(normalized[0])) {
33
- throw new HandleValidationError(
34
- `Invalid handle '${handle}'. Must start with a letter (any language).`
35
- );
36
- }
37
- for (let i = 1; i < normalized.length; i++) {
38
- if (!isValidBodyChar(normalized[i])) {
39
- throw new HandleValidationError(
40
- `Invalid character '${normalized[i]}' at position ${i} in handle '${handle}'.`
41
- );
42
- }
43
- }
44
- return normalized;
45
- }
46
- var ContentHandle = class {
47
- handle;
48
- currentHash;
49
- createdAt;
50
- updatedAt;
51
- constructor(handle, currentHash, createdAt, updatedAt) {
52
- this.handle = validateHandle(handle);
53
- this.currentHash = currentHash;
54
- this.createdAt = createdAt ?? /* @__PURE__ */ new Date();
55
- this.updatedAt = updatedAt ?? this.createdAt;
56
- }
57
- /**
58
- * Update handle to point to new hash
59
- * @returns Previous hash for history tracking
60
- */
61
- update(newHash) {
62
- const previousHash = this.currentHash;
63
- this.currentHash = newHash;
64
- this.updatedAt = /* @__PURE__ */ new Date();
65
- return previousHash;
66
- }
67
- toObject() {
68
- return {
69
- handle: this.handle,
70
- currentHash: this.currentHash,
71
- createdAt: this.createdAt.toISOString(),
72
- updatedAt: this.updatedAt.toISOString()
73
- };
74
- }
75
- };
76
-
77
- // src/storage/schema_constants.ts
78
- var MCARD_SCHEMA_SQL = `-- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
79
- -- MCard Unified Database Schema (Monadic Core)
80
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
81
- --
82
- -- STABILITY WARNING: This schema is the invariant "seeding meta-language" for all
83
- -- Domain Specific Languages (DSLs). It must remain as stable as possible.
84
- --
85
- -- THE UNIFICATION THESIS:
86
- -- This design unites three distinct namespaces into a single relational network
87
- -- by leveraging the power of cryptographic hash functions:
88
- -- 1. CONTENT SPACE (Intrinsic Identity): Content-Addressable Storage (CAS).
89
- -- 2. HANDLE SPACE (Reserved Words): Mapping human logic to content hashes.
90
- -- 3. VERSION SPACE (Temporal Evolution): Tracking state transitions via hash history.
91
- --
92
- -- TURING MACHINE ANALOGY (The Infinitely Long Tape):
93
- -- The \`card\` table stores content blobs with unique identities, emulating the
94
- -- "Infinitely Long Tape" of the Turing Machine formalism. By using relational
95
- -- queries, this tape can be dynamically constructed and traversed for different
96
- -- DSLs, providing a flexible substrate for practically all computable languages.
97
- --
98
- -- By using hash values as the universal primitives across content, handles, and
99
- -- time, we create a "Wordless Book" \u2014 a minimal substrate capable of seeding any
100
- -- domain-specific knowledge system without requiring schema changes.
101
- --
102
- -- Monadic Mapping (See: Monadic Justification for Schema Design.md):
103
- -- 1. Card = Monad (Perception/State/Exponent) - Intrinsic Identity
104
- -- 2. Handle = Registry (Appetition/Reader/Sum) - Mutable Reference
105
- -- 3. Version = History (Harmony/Writer/Product) - Coordinated Evolution
106
- --
107
- -- Version: 3.0.2 (Turing Tape Refinement)
108
- -- Last Updated: 2025-12-20
109
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
110
-
111
-
112
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
113
- -- LAYER 1: CORE CONTENT-ADDRESSABLE STORAGE (The Monad / Exponent)
114
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
115
- -- The fundamental MCard storage: content-addressed by cryptographic hash.
116
- -- "Each Monad ... mirrors the universe"
117
-
118
- -- @table card
119
- -- @description Core content-addressable storage table (Monad/State)
120
- -- @column hash - SHA-256 hash of content (primary key)
121
- -- @column content - The actual content (BLOB for binary safety)
122
- -- @column g_time - Generation timestamp (ISO 8601)
123
- CREATE TABLE IF NOT EXISTS card (
124
- hash TEXT PRIMARY KEY,
125
- content BLOB NOT NULL,
126
- g_time TEXT NOT NULL
127
- );
128
-
129
-
130
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
131
- -- LAYER 2: HANDLE SYSTEM (Appetition / Sum)
132
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
133
- -- The mutable pointer that "desires" to reference new content.
134
- -- "Appetition: the tendency to move to new states"
135
-
136
- -- @table handle_registry (Monadic Role: Handle)
137
- -- @description Maps human-readable handles to current content hashes
138
- -- @column handle - UTF-8 handle name (primary key)
139
- -- @column current_hash - FK to card.hash of current version
140
- -- @column created_at - When handle was first created
141
- -- @column updated_at - When handle was last updated
142
- CREATE TABLE IF NOT EXISTS handle_registry (
143
- handle TEXT PRIMARY KEY,
144
- current_hash TEXT NOT NULL,
145
- created_at TEXT NOT NULL,
146
- updated_at TEXT NOT NULL,
147
- FOREIGN KEY (current_hash) REFERENCES card(hash)
148
- );
149
-
150
- -- @index idx_handle_current_hash
151
- -- @description Efficient reverse lookup from hash to handles
152
- CREATE INDEX IF NOT EXISTS idx_handle_current_hash
153
- ON handle_registry(current_hash);
154
-
155
- -- @table handle_history (Monadic Role: Version / Product)
156
- -- @description Audit trail for handle pointer changes (Pre-Established Harmony)
157
- -- @column id - Auto-increment primary key
158
- -- @column handle - The handle that was updated
159
- -- @column previous_hash - Hash it pointed to before update
160
- -- @column changed_at - When the change occurred
161
- CREATE TABLE IF NOT EXISTS handle_history (
162
- id INTEGER PRIMARY KEY AUTOINCREMENT,
163
- handle TEXT NOT NULL,
164
- previous_hash TEXT NOT NULL,
165
- changed_at TEXT NOT NULL,
166
- FOREIGN KEY (handle) REFERENCES handle_registry(handle),
167
- FOREIGN KEY (previous_hash) REFERENCES card(hash)
168
- );
169
-
170
- -- @index idx_handle_history_handle
171
- -- @description Efficient lookup of history by handle
172
- CREATE INDEX IF NOT EXISTS idx_handle_history_handle
173
- ON handle_history(handle);
174
-
175
-
176
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
177
- -- LEGACY SUPPORT: FTS5 Documents Table
178
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
179
- -- KEPT FOR BACKWARD COMPATIBILITY with existing codebase.
180
- -- New implementations should use mcard_vector_schema.sql -> mcard_fts
181
-
182
- -- @virtual_table documents
183
- -- @description Legacy FTS table for backward compatibility
184
- -- @note Synced with card table via triggers
185
- CREATE VIRTUAL TABLE IF NOT EXISTS documents USING fts5(content);
186
-
187
-
188
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
189
- -- SCHEMA METADATA
190
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
191
-
192
- -- @table schema_version
193
- -- @description Tracks schema version for migrations
194
- CREATE TABLE IF NOT EXISTS schema_version (
195
- version TEXT PRIMARY KEY,
196
- applied_at TEXT NOT NULL,
197
- description TEXT
198
- );
199
-
200
- -- Insert current schema version
201
- INSERT OR IGNORE INTO schema_version (version, applied_at, description)
202
- VALUES ('3.0.0', datetime('now'), 'Monadic Core Schema (split vectors to mcard_vector_schema.sql)');
203
- `;
204
- var MCARD_VECTOR_SCHEMA_SQL = `-- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
205
- -- MCard Vector Database Schema (mcard_vectors.db)
206
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
207
- --
208
- -- This schema defines the structure for "Secondary Qualities" (Extrinsic Embeddings).
209
- -- It is separated from the core mcard.db (Monadic Intrinsic Properties) to ensure:
210
- -- 1. Separation of Concerns (Intrinsic vs Extrinsic)
211
- -- 2. Linearity (Vectors are observer-dependent and large)
212
- -- 3. Upgradability (Embedding models change frequently)
213
- --
214
- -- See: Monadic Justification for Schema Design.md
215
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
216
-
217
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
218
- -- LAYER 3: VECTOR STORAGE (Semantic Embeddings)
219
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
220
- -- Storage for vector embeddings enabling semantic search.
221
- -- Links to content via hash for content-addressing.
222
-
223
- -- @table mcard_vector_metadata
224
- -- @description Metadata for stored embeddings
225
- -- @column id - Auto-increment primary key
226
- -- @column hash - FK to card.hash
227
- -- @column model_name - Embedding model used (e.g., "nomic-embed-text")
228
- -- @column dimensions - Vector dimensions
229
- -- @column chunk_index - Index for chunked documents (0 = first/whole)
230
- -- @column chunk_total - Total chunks for this document
231
- -- @column chunk_text - Preview text for this chunk
232
- -- @column created_at - When embedding was created
233
- CREATE TABLE IF NOT EXISTS mcard_vector_metadata (
234
- id INTEGER PRIMARY KEY AUTOINCREMENT,
235
- hash TEXT NOT NULL,
236
- model_name TEXT NOT NULL,
237
- dimensions INTEGER NOT NULL,
238
- chunk_index INTEGER DEFAULT 0,
239
- chunk_total INTEGER DEFAULT 1,
240
- chunk_text TEXT,
241
- created_at TEXT NOT NULL,
242
- UNIQUE(hash, chunk_index)
243
- );
244
-
245
- -- @index idx_vector_metadata_hash
246
- -- @description Efficient lookup of embeddings by content hash
247
- CREATE INDEX IF NOT EXISTS idx_vector_metadata_hash
248
- ON mcard_vector_metadata(hash);
249
-
250
- -- @table mcard_embeddings
251
- -- @description Fallback embedding storage when sqlite-vec is unavailable
252
- -- @column id - Auto-increment primary key
253
- -- @column metadata_id - FK to mcard_vector_metadata.id
254
- -- @column embedding - Serialized float32 vector as BLOB
255
- CREATE TABLE IF NOT EXISTS mcard_embeddings (
256
- id INTEGER PRIMARY KEY AUTOINCREMENT,
257
- metadata_id INTEGER NOT NULL,
258
- embedding BLOB NOT NULL,
259
- UNIQUE(metadata_id),
260
- FOREIGN KEY (metadata_id) REFERENCES mcard_vector_metadata(id)
261
- );
262
-
263
- -- @virtual_table mcard_fts
264
- -- @description Full-text search for hybrid retrieval
265
- -- @note Uses Porter stemming with Unicode support
266
- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_fts USING fts5(
267
- hash,
268
- content,
269
- tokenize='porter unicode61'
270
- );
271
-
272
- -- Note: sqlite-vec virtual table is created dynamically with dimensions:
273
- -- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_vec USING vec0(
274
- -- metadata_id INTEGER PRIMARY KEY,
275
- -- embedding float[\${dimensions}]
276
- -- );
277
-
278
-
279
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
280
- -- LAYER 4: SEMANTIC VERSIONING (Handle-Vector Bridge)
281
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
282
- -- Bridges handles to vector embeddings for semantic version comparison.
283
- -- Enables measuring semantic drift between document versions.
284
-
285
- -- @table handle_version_vectors
286
- -- @description Links handle versions to their semantic embeddings
287
- -- @column id - Auto-increment primary key
288
- -- @column handle - FK to handle_registry.handle
289
- -- @column hash - FK to card.hash (this version)
290
- -- @column parent_hash - FK to card.hash (previous version)
291
- -- @column version_order - 0 = current, 1 = previous, etc.
292
- -- @column is_current - TRUE if this is the current version
293
- -- @column embedding_id - FK to mcard_vector_metadata.id
294
- -- @column semantic_delta_from_parent - Cosine similarity to parent [-1, 1]
295
- -- @column upgrade_type - Classification: 'trivial' | 'minor' | 'major' | 'breaking'
296
- -- @column created_at - When this version was linked
297
- CREATE TABLE IF NOT EXISTS handle_version_vectors (
298
- id INTEGER PRIMARY KEY AUTOINCREMENT,
299
- handle TEXT NOT NULL,
300
- hash TEXT NOT NULL,
301
- parent_hash TEXT,
302
- version_order INTEGER NOT NULL,
303
- is_current BOOLEAN DEFAULT FALSE,
304
- embedding_id INTEGER,
305
- semantic_delta_from_parent REAL,
306
- upgrade_type TEXT,
307
- created_at TEXT NOT NULL,
308
- UNIQUE(handle, hash),
309
- FOREIGN KEY (embedding_id) REFERENCES mcard_vector_metadata(id)
310
- );
311
-
312
- -- @index idx_hvv_handle
313
- -- @description Efficient lookup of versions by handle
314
- CREATE INDEX IF NOT EXISTS idx_hvv_handle
315
- ON handle_version_vectors(handle);
316
-
317
- -- @index idx_hvv_hash
318
- -- @description Efficient lookup of versions by hash
319
- CREATE INDEX IF NOT EXISTS idx_hvv_hash
320
- ON handle_version_vectors(hash);
321
-
322
- -- @index idx_hvv_current
323
- -- @description Efficient lookup of current versions
324
- CREATE INDEX IF NOT EXISTS idx_hvv_current
325
- ON handle_version_vectors(is_current);
326
-
327
- -- @index idx_hvv_parent
328
- -- @description Efficient lookup by parent hash
329
- CREATE INDEX IF NOT EXISTS idx_hvv_parent
330
- ON handle_version_vectors(parent_hash);
331
-
332
- -- @table version_similarity_cache
333
- -- @description Precomputed pairwise similarities for performance
334
- -- @column id - Auto-increment primary key
335
- -- @column handle - Handle these versions belong to
336
- -- @column hash_a - First version hash
337
- -- @column hash_b - Second version hash
338
- -- @column similarity_score - Cosine similarity [-1, 1]
339
- -- @column distance_euclidean - L2 distance [0, \u221E)
340
- -- @column computed_at - When similarity was computed
341
- CREATE TABLE IF NOT EXISTS version_similarity_cache (
342
- id INTEGER PRIMARY KEY AUTOINCREMENT,
343
- handle TEXT NOT NULL,
344
- hash_a TEXT NOT NULL,
345
- hash_b TEXT NOT NULL,
346
- similarity_score REAL NOT NULL,
347
- distance_euclidean REAL,
348
- computed_at TEXT NOT NULL,
349
- UNIQUE(handle, hash_a, hash_b)
350
- );
351
-
352
- -- @index idx_vsc_handle
353
- -- @description Efficient lookup of cached similarities by handle
354
- CREATE INDEX IF NOT EXISTS idx_vsc_handle
355
- ON version_similarity_cache(handle);
356
-
357
-
358
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
359
- -- LAYER 5: KNOWLEDGE GRAPH (GraphRAG)
360
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
361
- -- Storage for extracted knowledge graph entities and relationships.
362
-
363
- -- @table graph_entities
364
- -- @description Nodes in the knowledge graph
365
- -- @column id - Auto-increment primary key
366
- -- @column name - Entity name
367
- -- @column type - Entity type (e.g., "Person", "Organization")
368
- -- @column description - Optional description
369
- -- @column source_hash - FK to card.hash where entity was extracted
370
- -- @column embedding - Optional entity embedding
371
- -- @column created_at - When entity was created
372
- CREATE TABLE IF NOT EXISTS graph_entities (
373
- id INTEGER PRIMARY KEY AUTOINCREMENT,
374
- name TEXT NOT NULL,
375
- type TEXT NOT NULL,
376
- description TEXT,
377
- source_hash TEXT NOT NULL,
378
- embedding BLOB,
379
- created_at TEXT NOT NULL,
380
- UNIQUE(name, type, source_hash)
381
- );
382
-
383
- -- @index idx_entity_name
384
- -- @description Efficient entity lookup by name
385
- CREATE INDEX IF NOT EXISTS idx_entity_name
386
- ON graph_entities(name);
387
-
388
- -- @index idx_entity_type
389
- -- @description Efficient entity lookup by type
390
- CREATE INDEX IF NOT EXISTS idx_entity_type
391
- ON graph_entities(type);
392
-
393
- -- @index idx_entity_source
394
- -- @description Efficient entity lookup by source document
395
- CREATE INDEX IF NOT EXISTS idx_entity_source
396
- ON graph_entities(source_hash);
397
-
398
- -- @table graph_relationships
399
- -- @description Edges in the knowledge graph
400
- -- @column id - Auto-increment primary key
401
- -- @column source_entity_id - FK to graph_entities.id (from)
402
- -- @column target_entity_id - FK to graph_entities.id (to)
403
- -- @column relationship - Relationship type/label
404
- -- @column description - Optional description
405
- -- @column weight - Relationship strength
406
- -- @column source_hash - FK to card.hash where relationship was extracted
407
- -- @column created_at - When relationship was created
408
- CREATE TABLE IF NOT EXISTS graph_relationships (
409
- id INTEGER PRIMARY KEY AUTOINCREMENT,
410
- source_entity_id INTEGER NOT NULL,
411
- target_entity_id INTEGER NOT NULL,
412
- relationship TEXT NOT NULL,
413
- description TEXT,
414
- weight REAL DEFAULT 1.0,
415
- source_hash TEXT NOT NULL,
416
- created_at TEXT NOT NULL,
417
- UNIQUE(source_entity_id, target_entity_id, relationship, source_hash),
418
- FOREIGN KEY (source_entity_id) REFERENCES graph_entities(id),
419
- FOREIGN KEY (target_entity_id) REFERENCES graph_entities(id)
420
- );
421
-
422
- -- @index idx_rel_source
423
- -- @description Efficient lookup of relationships by source entity
424
- CREATE INDEX IF NOT EXISTS idx_rel_source
425
- ON graph_relationships(source_entity_id);
426
-
427
- -- @index idx_rel_target
428
- -- @description Efficient lookup of relationships by target entity
429
- CREATE INDEX IF NOT EXISTS idx_rel_target
430
- ON graph_relationships(target_entity_id);
431
-
432
- -- @table graph_communities
433
- -- @description Hierarchical community summaries (GraphRAG)
434
- -- @column id - Auto-increment primary key
435
- -- @column level - Hierarchy level (0 = leaf)
436
- -- @column title - Community title
437
- -- @column summary - AI-generated summary
438
- -- @column embedding - Community embedding
439
- -- @column member_entity_ids - JSON array of entity IDs
440
- -- @column parent_community_id - FK to parent community
441
- -- @column created_at - When community was created
442
- CREATE TABLE IF NOT EXISTS graph_communities (
443
- id INTEGER PRIMARY KEY AUTOINCREMENT,
444
- level INTEGER NOT NULL DEFAULT 0,
445
- title TEXT,
446
- summary TEXT NOT NULL,
447
- embedding BLOB,
448
- member_entity_ids TEXT,
449
- parent_community_id INTEGER,
450
- created_at TEXT NOT NULL,
451
- FOREIGN KEY (parent_community_id) REFERENCES graph_communities(id)
452
- );
453
-
454
- -- @index idx_community_level
455
- -- @description Efficient lookup of communities by level
456
- CREATE INDEX IF NOT EXISTS idx_community_level
457
- ON graph_communities(level);
458
-
459
- -- @table graph_extractions
460
- -- @description Tracks which documents have been processed for entity extraction
461
- -- @column hash - FK to card.hash (primary key)
462
- -- @column entity_count - Number of entities extracted
463
- -- @column relationship_count - Number of relationships extracted
464
- -- @column extracted_at - When extraction was performed
465
- CREATE TABLE IF NOT EXISTS graph_extractions (
466
- hash TEXT PRIMARY KEY,
467
- entity_count INTEGER DEFAULT 0,
468
- relationship_count INTEGER DEFAULT 0,
469
- extracted_at TEXT NOT NULL
470
- );
471
-
472
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
473
- -- SCHEMA METADATA (Vector DB)
474
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
475
-
476
- -- @table schema_version
477
- -- @description Tracks schema version for migrations
478
- CREATE TABLE IF NOT EXISTS vector_schema_version (
479
- version TEXT PRIMARY KEY,
480
- applied_at TEXT NOT NULL,
481
- description TEXT
482
- );
483
-
484
- -- Insert current schema version
485
- INSERT OR IGNORE INTO vector_schema_version (version, applied_at, description)
486
- VALUES ('1.0.0', datetime('now'), 'Initial MCard Vector Schema');
487
- `;
488
-
489
- // src/storage/schema.ts
490
- var TABLE_LAYERS = {
491
- // Layer 1: Core
492
- "card": "core",
493
- // Layer 2: Handle System
494
- "handle_registry": "handle",
495
- "handle_history": "handle",
496
- // Layer 3: Vector Storage
497
- "mcard_vector_metadata": "vector",
498
- "mcard_embeddings": "vector",
499
- "mcard_fts": "vector",
500
- // Layer 4: Semantic Versioning
501
- "handle_version_vectors": "semantic",
502
- "version_similarity_cache": "semantic",
503
- // Layer 5: Knowledge Graph
504
- "graph_entities": "graph",
505
- "graph_relationships": "graph",
506
- "graph_communities": "graph",
507
- "graph_extractions": "graph",
508
- // Metadata
509
- "schema_version": "metadata"
510
- };
511
- var MCardSchema = class _MCardSchema {
512
- static instance = null;
513
- schemaPath = "";
514
- rawSql = "";
515
- statements = [];
516
- tables = /* @__PURE__ */ new Map();
517
- indexes = /* @__PURE__ */ new Map();
518
- loaded = false;
519
- constructor() {
520
- }
521
- /**
522
- * Get the singleton instance.
523
- */
524
- static getInstance() {
525
- if (!_MCardSchema.instance) {
526
- _MCardSchema.instance = new _MCardSchema();
527
- _MCardSchema.instance.load();
528
- }
529
- return _MCardSchema.instance;
530
- }
531
- /**
532
- * Reset the singleton (for testing).
533
- */
534
- static resetInstance() {
535
- _MCardSchema.instance = null;
536
- }
537
- load() {
538
- if (this.loaded) return;
539
- this.schemaPath = "IN_MEMORY_CONSTANTS";
540
- this.rawSql = MCARD_SCHEMA_SQL;
541
- if (MCARD_VECTOR_SCHEMA_SQL) {
542
- this.rawSql += "\n\n" + MCARD_VECTOR_SCHEMA_SQL;
543
- }
544
- this.statements = this.parseStatements(this.rawSql);
545
- for (const stmt of this.statements) {
546
- const name = this.extractName(stmt);
547
- if (name) {
548
- const upper = stmt.toUpperCase();
549
- if (upper.includes("CREATE TABLE") || upper.includes("CREATE VIRTUAL TABLE")) {
550
- this.tables.set(name.toLowerCase(), stmt);
551
- } else if (upper.includes("CREATE INDEX")) {
552
- this.indexes.set(name.toLowerCase(), stmt);
553
- }
554
- }
555
- }
556
- this.loaded = true;
557
- }
558
- parseStatements(sql) {
559
- sql = sql.replace(/\/\*[\s\S]*?\*\//g, "");
560
- const statements = [];
561
- let current = [];
562
- for (const line of sql.split("\n")) {
563
- const stripped = line.split("--")[0].trim();
564
- if (!stripped) continue;
565
- current.push(stripped);
566
- if (stripped.endsWith(";")) {
567
- const statement = current.join(" ");
568
- if (!statement.trim().toUpperCase().startsWith("INSERT")) {
569
- statements.push(statement);
570
- }
571
- current = [];
572
- }
573
- }
574
- return statements.filter((s) => s.trim());
575
- }
576
- extractName(statement) {
577
- let match = statement.match(/CREATE\s+(?:VIRTUAL\s+)?TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)/i);
578
- if (match) return match[1];
579
- match = statement.match(/CREATE\s+INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)/i);
580
- if (match) return match[1];
581
- return null;
582
- }
583
- // ─────────────────────────────────────────────────────────────────────────
584
- // Schema Access
585
- // ─────────────────────────────────────────────────────────────────────────
586
- getSchemaPath() {
587
- return this.schemaPath;
588
- }
589
- getTable(tableName) {
590
- return this.tables.get(tableName.toLowerCase());
591
- }
592
- getIndex(indexName) {
593
- return this.indexes.get(indexName.toLowerCase());
594
- }
595
- getAllTables() {
596
- return new Map(this.tables);
597
- }
598
- getAllIndexes() {
599
- return new Map(this.indexes);
600
- }
601
- getAllStatements() {
602
- return [...this.statements];
603
- }
604
- getTablesByLayer(layer) {
605
- return Object.entries(TABLE_LAYERS).filter(([_, l]) => l === layer).map(([name, _]) => name);
606
- }
607
- getLayerStatements(layer) {
608
- const statements = [];
609
- const tables = this.getTablesByLayer(layer);
610
- for (const table of tables) {
611
- const stmt = this.getTable(table);
612
- if (stmt) statements.push(stmt);
613
- }
614
- for (const [_, stmt] of this.indexes) {
615
- const match = stmt.match(/ON\s+(\w+)/i);
616
- if (match && tables.includes(match[1].toLowerCase())) {
617
- statements.push(stmt);
618
- }
619
- }
620
- return statements;
621
- }
622
- // ─────────────────────────────────────────────────────────────────────────
623
- // Database Initialization
624
- // ─────────────────────────────────────────────────────────────────────────
625
- execStatements(db, statements) {
626
- for (const stmt of statements) {
627
- db.exec(stmt);
628
- }
629
- return statements.length;
630
- }
631
- initLayer(db, layer) {
632
- return this.execStatements(db, this.getLayerStatements(layer));
633
- }
634
- initCoreTables(db) {
635
- return this.initLayer(db, "core");
636
- }
637
- initHandleTables(db) {
638
- return this.initLayer(db, "handle");
639
- }
640
- initVectorTables(db, enableFts = true) {
641
- const statements = this.getLayerStatements("vector").filter((s) => enableFts || !s.toLowerCase().includes("fts"));
642
- return this.execStatements(db, statements);
643
- }
644
- initSemanticTables(db) {
645
- return this.initLayer(db, "semantic");
646
- }
647
- initGraphTables(db) {
648
- return this.initLayer(db, "graph");
649
- }
650
- initAllTables(db, options = {}) {
651
- const { enableFts = true, enableGraph = true, enableSemantic = true } = options;
652
- let count = 0;
653
- count += this.initCoreTables(db);
654
- count += this.initHandleTables(db);
655
- count += this.initVectorTables(db, enableFts);
656
- if (enableSemantic) {
657
- count += this.initSemanticTables(db);
658
- }
659
- if (enableGraph) {
660
- count += this.initGraphTables(db);
661
- }
662
- return count;
663
- }
664
- initVec0Table(db, dimensions) {
665
- db.exec(`
666
- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_vec USING vec0(
667
- metadata_id INTEGER PRIMARY KEY,
668
- embedding float[${dimensions}]
669
- )
670
- `);
671
- }
672
- };
673
- function getSchemaInstance() {
674
- return MCardSchema.getInstance();
675
- }
676
- var CARD_TABLE_SCHEMA = getSchemaInstance().getTable("card") || "";
677
- var HANDLE_REGISTRY_SCHEMA = getSchemaInstance().getTable("handle_registry") || "";
678
- var HANDLE_HISTORY_SCHEMA = getSchemaInstance().getTable("handle_history") || "";
679
- var HANDLE_INDEX_SCHEMA = getSchemaInstance().getIndex("idx_handle_current_hash") || "";
680
- var VECTOR_METADATA_SCHEMA = getSchemaInstance().getTable("mcard_vector_metadata") || "";
681
- var VECTOR_METADATA_INDEX = getSchemaInstance().getIndex("idx_vector_metadata_hash") || "";
682
- var VECTOR_EMBEDDINGS_SCHEMA = getSchemaInstance().getTable("mcard_embeddings") || "";
683
- var VECTOR_FTS_SCHEMA = getSchemaInstance().getTable("mcard_fts") || "";
684
- var HANDLE_VERSION_VECTORS_SCHEMA = getSchemaInstance().getTable("handle_version_vectors") || "";
685
- var HANDLE_VERSION_VECTORS_INDEXES = [
686
- getSchemaInstance().getIndex("idx_hvv_handle"),
687
- getSchemaInstance().getIndex("idx_hvv_hash"),
688
- getSchemaInstance().getIndex("idx_hvv_current"),
689
- getSchemaInstance().getIndex("idx_hvv_parent")
690
- ].filter(Boolean).join("; ");
691
- var VERSION_SIMILARITY_CACHE_SCHEMA = getSchemaInstance().getTable("version_similarity_cache") || "";
692
- var VERSION_SIMILARITY_CACHE_INDEX = getSchemaInstance().getIndex("idx_vsc_handle") || "";
693
- var GRAPH_ENTITY_SCHEMA = getSchemaInstance().getTable("graph_entities") || "";
694
- var GRAPH_ENTITY_INDEX_NAME = getSchemaInstance().getIndex("idx_entity_name") || "";
695
- var GRAPH_ENTITY_INDEX_TYPE = getSchemaInstance().getIndex("idx_entity_type") || "";
696
- var GRAPH_ENTITY_INDEX_SOURCE = getSchemaInstance().getIndex("idx_entity_source") || "";
697
- var GRAPH_RELATIONSHIP_SCHEMA = getSchemaInstance().getTable("graph_relationships") || "";
698
- var GRAPH_RELATIONSHIP_INDEX_SOURCE = getSchemaInstance().getIndex("idx_rel_source") || "";
699
- var GRAPH_RELATIONSHIP_INDEX_TARGET = getSchemaInstance().getIndex("idx_rel_target") || "";
700
- var GRAPH_COMMUNITY_SCHEMA = getSchemaInstance().getTable("graph_communities") || "";
701
- var GRAPH_COMMUNITY_INDEX_LEVEL = getSchemaInstance().getIndex("idx_community_level") || "";
702
- var GRAPH_EXTRACTION_SCHEMA = getSchemaInstance().getTable("graph_extractions") || "";
703
- var CORE_SCHEMAS = {
704
- card: CARD_TABLE_SCHEMA,
705
- handleRegistry: HANDLE_REGISTRY_SCHEMA,
706
- handleHistory: HANDLE_HISTORY_SCHEMA,
707
- handleIndex: HANDLE_INDEX_SCHEMA
708
- };
709
- function initCoreSchemas(db) {
710
- const schema = MCardSchema.getInstance();
711
- schema.initCoreTables(db);
712
- schema.initHandleTables(db);
713
- }
714
-
715
- // src/storage/SqliteNodeEngine.ts
716
- import { createRequire } from "module";
717
- var DEFAULT_PAGE_SIZE = 10;
718
- var SqliteNodeEngine = class {
719
- db;
720
- dbPath;
721
- /**
722
- * Create a new SqliteNodeEngine
723
- * @param dbPath Path to database file, or ':memory:' for in-memory database
724
- */
725
- constructor(dbPath = ":memory:") {
726
- this.dbPath = dbPath;
727
- const require2 = createRequire(import.meta.url);
728
- const Database = require2("better-sqlite3");
729
- this.db = new Database(dbPath);
730
- this.setupDatabase();
731
- }
732
- /**
733
- * Initialize database schema
734
- */
735
- setupDatabase() {
736
- initCoreSchemas(this.db);
737
- }
738
- /**
739
- * Close the database connection
740
- */
741
- close() {
742
- this.db.close();
743
- }
744
- /**
745
- * Get the database path
746
- */
747
- getDbPath() {
748
- return this.dbPath;
749
- }
750
- // =========== Card Operations ===========
751
- async add(card) {
752
- const stmt = this.db.prepare(
753
- "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)"
754
- );
755
- stmt.run(card.hash, Buffer.from(card.content), card.g_time);
756
- return card.hash;
757
- }
758
- /**
759
- * Add a card synchronously (for performance-critical paths)
760
- */
761
- addSync(card) {
762
- const stmt = this.db.prepare(
763
- "INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)"
764
- );
765
- stmt.run(card.hash, Buffer.from(card.content), card.g_time);
766
- return card.hash;
767
- }
768
- async get(hash) {
769
- return this.getSync(hash);
770
- }
771
- /**
772
- * Get a card synchronously
773
- */
774
- getSync(hash) {
775
- const stmt = this.db.prepare("SELECT hash, content, g_time FROM card WHERE hash = ?");
776
- const row = stmt.get(hash);
777
- if (!row) return null;
778
- const content = row.content instanceof Buffer ? new Uint8Array(row.content) : new Uint8Array(row.content);
779
- return MCard.fromData(content, row.hash, row.g_time);
780
- }
781
- async delete(hash) {
782
- this.deleteSync(hash);
783
- }
784
- /**
785
- * Delete a card synchronously
786
- */
787
- deleteSync(hash) {
788
- const stmt = this.db.prepare("DELETE FROM card WHERE hash = ?");
789
- const result = stmt.run(hash);
790
- return result.changes > 0;
791
- }
792
- async getPage(pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
793
- return this.getPageSync(pageNumber, pageSize);
794
- }
795
- /**
796
- * Get a page of cards synchronously
797
- */
798
- getPageSync(pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
799
- if (pageNumber < 1) throw new Error("Page number must be >= 1");
800
- if (pageSize < 1) throw new Error("Page size must be >= 1");
801
- const totalItems = this.countSync();
802
- const totalPages = Math.ceil(totalItems / pageSize) || 1;
803
- const offset = (pageNumber - 1) * pageSize;
804
- const stmt = this.db.prepare(
805
- "SELECT hash, content, g_time FROM card ORDER BY g_time DESC LIMIT ? OFFSET ?"
806
- );
807
- const rows = stmt.all(pageSize, offset);
808
- const items = rows.map((row) => {
809
- const content = row.content instanceof Buffer ? new Uint8Array(row.content) : new Uint8Array(row.content);
810
- return MCard.fromData(content, row.hash, row.g_time);
811
- });
812
- return {
813
- items,
814
- totalItems,
815
- pageNumber,
816
- pageSize,
817
- totalPages,
818
- hasNext: offset + items.length < totalItems,
819
- hasPrevious: pageNumber > 1
820
- };
821
- }
822
- async count() {
823
- return this.countSync();
824
- }
825
- /**
826
- * Count cards synchronously
827
- */
828
- countSync() {
829
- const stmt = this.db.prepare("SELECT COUNT(*) as count FROM card");
830
- const row = stmt.get();
831
- return row.count;
832
- }
833
- async searchByHash(hashPrefix) {
834
- const rows = this.db.prepare("SELECT hash, content, g_time FROM card WHERE hash LIKE ?").all(`${hashPrefix}%`);
835
- return rows.map(
836
- (row) => MCard.fromData(new Uint8Array(row.content), row.hash, row.g_time)
837
- );
838
- }
839
- async search(query, pageNumber, pageSize) {
840
- const offset = (pageNumber - 1) * pageSize;
841
- const searchPattern = `%${query}%`;
842
- const countResult = this.db.prepare("SELECT COUNT(*) as count FROM card WHERE CAST(content AS TEXT) LIKE ?").get(searchPattern);
843
- const totalItems = countResult.count;
844
- const totalPages = Math.ceil(totalItems / pageSize) || 1;
845
- const rows = this.db.prepare("SELECT hash, content, g_time FROM card WHERE CAST(content AS TEXT) LIKE ? LIMIT ? OFFSET ?").all(searchPattern, pageSize, offset);
846
- const items = rows.map(
847
- (row) => MCard.fromData(new Uint8Array(row.content), row.hash, row.g_time)
848
- );
849
- return {
850
- items,
851
- totalItems,
852
- pageNumber,
853
- pageSize,
854
- totalPages,
855
- hasNext: pageNumber < totalPages,
856
- hasPrevious: pageNumber > 1
857
- };
858
- }
859
- async getAll() {
860
- const rows = this.db.prepare("SELECT hash, content, g_time FROM card").all();
861
- return rows.map(
862
- (row) => MCard.fromData(new Uint8Array(row.content), row.hash, row.g_time)
863
- );
864
- }
865
- async clear() {
866
- this.clearSync();
867
- }
868
- /**
869
- * Clear all data synchronously
870
- * Delete in FK-safe order: children first, then parents
871
- */
872
- clearSync() {
873
- this.db.exec("DELETE FROM handle_history");
874
- this.db.exec("DELETE FROM handle_registry");
875
- this.db.exec("DELETE FROM card");
876
- }
877
- // =========== Search Operations ===========
878
- /**
879
- * Search cards by string in content, hash, or g_time
880
- */
881
- searchByString(searchString, pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
882
- if (pageNumber < 1) throw new Error("Page number must be >= 1");
883
- if (pageSize < 1) throw new Error("Page size must be >= 1");
884
- const pattern = `%${searchString}%`;
885
- const offset = (pageNumber - 1) * pageSize;
886
- const countStmt = this.db.prepare(`
887
- SELECT COUNT(*) as count FROM card
888
- WHERE hash LIKE ? OR g_time LIKE ? OR CAST(content AS TEXT) LIKE ?
889
- `);
890
- const countRow = countStmt.get(pattern, pattern, pattern);
891
- const totalItems = countRow.count;
892
- const totalPages = Math.ceil(totalItems / pageSize) || 1;
893
- const stmt = this.db.prepare(`
894
- SELECT hash, content, g_time FROM card
895
- WHERE hash LIKE ? OR g_time LIKE ? OR CAST(content AS TEXT) LIKE ?
896
- ORDER BY g_time DESC LIMIT ? OFFSET ?
897
- `);
898
- const rows = stmt.all(pattern, pattern, pattern, pageSize, offset);
899
- const items = rows.map((row) => {
900
- const content = row.content instanceof Buffer ? new Uint8Array(row.content) : new Uint8Array(row.content);
901
- return MCard.fromData(content, row.hash, row.g_time);
902
- });
903
- return {
904
- items,
905
- totalItems,
906
- pageNumber,
907
- pageSize,
908
- totalPages,
909
- hasNext: offset + items.length < totalItems,
910
- hasPrevious: pageNumber > 1
911
- };
912
- }
913
- /**
914
- * Search cards by content pattern (binary-safe)
915
- */
916
- searchByContent(searchPattern, pageNumber = 1, pageSize = DEFAULT_PAGE_SIZE) {
917
- if (pageNumber < 1) throw new Error("Page number must be >= 1");
918
- if (pageSize < 1) throw new Error("Page size must be >= 1");
919
- if (!searchPattern || typeof searchPattern === "string" && searchPattern.length === 0) {
920
- throw new Error("Search pattern cannot be empty");
921
- }
922
- const searchBytes = typeof searchPattern === "string" ? Buffer.from(searchPattern, "utf-8") : Buffer.from(searchPattern);
923
- const offset = (pageNumber - 1) * pageSize;
924
- const countStmt = this.db.prepare("SELECT COUNT(*) as count FROM card WHERE INSTR(content, ?) > 0");
925
- const countRow = countStmt.get(searchBytes);
926
- const totalItems = countRow.count;
927
- const totalPages = Math.ceil(totalItems / pageSize) || 1;
928
- const stmt = this.db.prepare(`
929
- SELECT hash, content, g_time FROM card
930
- WHERE INSTR(content, ?) > 0
931
- ORDER BY g_time DESC LIMIT ? OFFSET ?
932
- `);
933
- const rows = stmt.all(searchBytes, pageSize, offset);
934
- const items = rows.map((row) => {
935
- const content = row.content instanceof Buffer ? new Uint8Array(row.content) : new Uint8Array(row.content);
936
- return MCard.fromData(content, row.hash, row.g_time);
937
- });
938
- return {
939
- items,
940
- totalItems,
941
- pageNumber,
942
- pageSize,
943
- totalPages,
944
- hasNext: offset + items.length < totalItems,
945
- hasPrevious: pageNumber > 1
946
- };
947
- }
948
- /**
949
- * Get all cards (single page with all items)
950
- */
951
- getAllCards() {
952
- const stmt = this.db.prepare("SELECT hash, content, g_time FROM card ORDER BY g_time DESC");
953
- const rows = stmt.all();
954
- const items = rows.map((row) => {
955
- const content = row.content instanceof Buffer ? new Uint8Array(row.content) : new Uint8Array(row.content);
956
- return MCard.fromData(content, row.hash, row.g_time);
957
- });
958
- return {
959
- items,
960
- totalItems: items.length,
961
- pageNumber: 1,
962
- pageSize: items.length || 1,
963
- totalPages: 1,
964
- hasNext: false,
965
- hasPrevious: false
966
- };
967
- }
968
- // =========== Handle Operations ===========
969
- async registerHandle(handle, hash) {
970
- this.registerHandleSync(handle, hash);
971
- }
972
- /**
973
- * Register a handle synchronously
974
- */
975
- registerHandleSync(handle, hash) {
976
- const normalized = validateHandle(handle);
977
- const now = (/* @__PURE__ */ new Date()).toISOString();
978
- const checkStmt = this.db.prepare("SELECT handle FROM handle_registry WHERE handle = ?");
979
- const existing = checkStmt.get(normalized);
980
- if (existing) {
981
- throw new Error(`Handle '${handle}' already exists.`);
982
- }
983
- const stmt = this.db.prepare(
984
- "INSERT INTO handle_registry (handle, current_hash, created_at, updated_at) VALUES (?, ?, ?, ?)"
985
- );
986
- stmt.run(normalized, hash, now, now);
987
- }
988
- async resolveHandle(handle) {
989
- return this.resolveHandleSync(handle);
990
- }
991
- /**
992
- * Resolve a handle synchronously
993
- */
994
- resolveHandleSync(handle) {
995
- const normalized = validateHandle(handle);
996
- const stmt = this.db.prepare("SELECT current_hash FROM handle_registry WHERE handle = ?");
997
- const row = stmt.get(normalized);
998
- return row?.current_hash || null;
999
- }
1000
- async getByHandle(handle) {
1001
- return this.getByHandleSync(handle);
1002
- }
1003
- /**
1004
- * Get card by handle synchronously
1005
- */
1006
- getByHandleSync(handle) {
1007
- const hash = this.resolveHandleSync(handle);
1008
- if (!hash) return null;
1009
- return this.getSync(hash);
1010
- }
1011
- async updateHandle(handle, newHash) {
1012
- return this.updateHandleSync(handle, newHash);
1013
- }
1014
- /**
1015
- * Update a handle synchronously
1016
- */
1017
- updateHandleSync(handle, newHash) {
1018
- const normalized = validateHandle(handle);
1019
- const now = (/* @__PURE__ */ new Date()).toISOString();
1020
- const getStmt = this.db.prepare("SELECT current_hash FROM handle_registry WHERE handle = ?");
1021
- const row = getStmt.get(normalized);
1022
- if (!row) {
1023
- throw new Error(`Handle '${handle}' not found.`);
1024
- }
1025
- const previousHash = row.current_hash;
1026
- const historyStmt = this.db.prepare(
1027
- "INSERT INTO handle_history (handle, previous_hash, changed_at) VALUES (?, ?, ?)"
1028
- );
1029
- historyStmt.run(normalized, previousHash, now);
1030
- const updateStmt = this.db.prepare(
1031
- "UPDATE handle_registry SET current_hash = ?, updated_at = ? WHERE handle = ?"
1032
- );
1033
- updateStmt.run(newHash, now, normalized);
1034
- return previousHash;
1035
- }
1036
- async getHandleHistory(handle) {
1037
- return this.getHandleHistorySync(handle);
1038
- }
1039
- /**
1040
- * Get handle history synchronously
1041
- */
1042
- getHandleHistorySync(handle) {
1043
- const normalized = validateHandle(handle);
1044
- const stmt = this.db.prepare(
1045
- "SELECT previous_hash, changed_at FROM handle_history WHERE handle = ? ORDER BY id DESC"
1046
- );
1047
- const rows = stmt.all(normalized);
1048
- return rows.map((row) => ({
1049
- previousHash: row.previous_hash,
1050
- changedAt: row.changed_at
1051
- }));
1052
- }
1053
- async pruneHandleHistory(handle, options = {}) {
1054
- return this.pruneHandleHistorySync(handle, options);
1055
- }
1056
- /**
1057
- * Prune handle history synchronously
1058
- */
1059
- pruneHandleHistorySync(handle, options = {}) {
1060
- const normalized = validateHandle(handle);
1061
- let stmt;
1062
- if (options.deleteAll) {
1063
- stmt = this.db.prepare("DELETE FROM handle_history WHERE handle = ?");
1064
- const result = stmt.run(normalized);
1065
- return result.changes;
1066
- } else if (options.olderThan) {
1067
- stmt = this.db.prepare("DELETE FROM handle_history WHERE handle = ? AND changed_at < ?");
1068
- const result = stmt.run(normalized, options.olderThan);
1069
- return result.changes;
1070
- }
1071
- return 0;
1072
- }
1073
- };
1074
-
1075
- export {
1076
- HandleValidationError,
1077
- validateHandle,
1078
- ContentHandle,
1079
- CORE_SCHEMAS,
1080
- SqliteNodeEngine
1081
- };