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
@@ -255,937 +255,47 @@ var GTime = class {
255
255
  }
256
256
  };
257
257
 
258
- // src/model/detectors/BinaryDetector.ts
259
- var BinarySignatureDetector = class _BinarySignatureDetector {
260
- contentTypeName = "binary";
261
- // Signatures map: [Signature Bytes, Mime Type]
262
- static SIGNATURES = [
263
- [new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), "image/png"],
264
- [new Uint8Array([255, 216, 255]), "image/jpeg"],
265
- [new Uint8Array([71, 73, 70, 56, 55, 97]), "image/gif"],
266
- // GIF87a
267
- [new Uint8Array([71, 73, 70, 56, 57, 97]), "image/gif"],
268
- // GIF89a
269
- [new Uint8Array([66, 77]), "image/bmp"],
270
- // BM
271
- [new Uint8Array([0, 0, 1, 0]), "image/x-icon"],
272
- [new Uint8Array([0, 0, 2, 0]), "image/x-icon"],
273
- [new Uint8Array([37, 80, 68, 70]), "application/pdf"],
274
- // %PDF
275
- [new Uint8Array([80, 75, 3, 4]), "application/zip"],
276
- // PK..
277
- [new Uint8Array([31, 139, 8]), "application/gzip"],
278
- [new Uint8Array([82, 97, 114, 33, 26, 7, 0]), "application/x-rar-compressed"],
279
- [new Uint8Array([55, 122, 188, 175, 39, 28]), "application/x-7z-compressed"],
280
- [new Uint8Array([83, 81, 76, 105, 116, 101, 32, 102, 111, 114, 109, 97, 116, 32, 51, 0]), "application/x-sqlite3"]
281
- ];
282
- // Extension-to-MIME mapping for binary types (used when byte detection fails)
283
- static EXT_TO_MIME = {
284
- // Video
285
- ".mp4": "video/mp4",
286
- ".webm": "video/webm",
287
- ".avi": "video/x-msvideo",
288
- ".mov": "video/quicktime",
289
- ".mkv": "video/x-matroska",
290
- ".wmv": "video/x-ms-wmv",
291
- ".flv": "video/x-flv",
292
- ".m4v": "video/x-m4v",
293
- // Audio
294
- ".mp3": "audio/mpeg",
295
- ".ogg": "audio/ogg",
296
- ".flac": "audio/flac",
297
- ".aac": "audio/aac",
298
- ".m4a": "audio/mp4",
299
- ".wma": "audio/x-ms-wma",
300
- // Images (backup for when signature detection fails)
301
- ".png": "image/png",
302
- ".jpg": "image/jpeg",
303
- ".jpeg": "image/jpeg",
304
- ".gif": "image/gif",
305
- ".bmp": "image/bmp",
306
- ".ico": "image/x-icon",
307
- ".webp": "image/webp",
308
- ".svg": "image/svg+xml",
309
- // Documents
310
- ".pdf": "application/pdf",
311
- // Archives
312
- ".zip": "application/zip",
313
- ".gz": "application/gzip",
314
- ".rar": "application/x-rar-compressed",
315
- ".7z": "application/x-7z-compressed",
316
- ".tar": "application/x-tar",
317
- // Database
318
- ".db": "application/x-sqlite3",
319
- ".sqlite": "application/x-sqlite3",
320
- ".sqlite3": "application/x-sqlite3",
321
- // Fonts
322
- ".woff": "font/woff",
323
- ".woff2": "font/woff2",
324
- ".ttf": "font/ttf",
325
- ".otf": "font/otf",
326
- ".eot": "application/vnd.ms-fontobject"
327
- };
328
- detect(contentSample, lines, firstLine, fileExtension) {
329
- const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
330
- return mime && mime !== "application/octet-stream" ? 0.95 : 0;
331
- }
332
- getMimeType(contentSample, lines, firstLine, fileExtension) {
333
- const bytes = this.toBytes(contentSample);
334
- const detected = this.detectFromBytes(bytes);
335
- if (detected !== "application/octet-stream") {
336
- return detected;
337
- }
338
- if (fileExtension) {
339
- let ext = fileExtension.toLowerCase();
340
- const lastDotIndex = ext.lastIndexOf(".");
341
- if (lastDotIndex > -1) {
342
- ext = ext.substring(lastDotIndex);
343
- } else if (!ext.startsWith(".")) {
344
- if (ext.includes("/") || ext.includes("\\")) {
345
- return "application/octet-stream";
346
- }
347
- ext = "." + ext;
348
- }
349
- const extMime = _BinarySignatureDetector.EXT_TO_MIME[ext];
350
- if (extMime) {
351
- return extMime;
352
- }
353
- }
354
- return "application/octet-stream";
355
- }
356
- /**
357
- * Detect MIME type directly from bytes.
358
- */
359
- detectFromBytes(bytes) {
360
- if (this.startsWith(bytes, new Uint8Array([82, 73, 70, 70]))) {
361
- return this.detectRiffFormat(bytes);
362
- }
363
- for (const [sig, mime] of _BinarySignatureDetector.SIGNATURES) {
364
- if (this.startsWith(bytes, sig)) {
365
- if (mime === "application/zip") {
366
- return this.detectZipType(bytes);
367
- }
368
- return mime;
369
- }
370
- }
371
- return "application/octet-stream";
372
- }
373
- toBytes(content) {
374
- if (content instanceof Uint8Array) return content;
375
- return new TextEncoder().encode(content);
376
- }
377
- startsWith(data, prefix) {
378
- if (data.length < prefix.length) return false;
379
- for (let i = 0; i < prefix.length; i++) {
380
- if (data[i] !== prefix[i]) return false;
381
- }
382
- return true;
383
- }
384
- detectRiffFormat(bytes) {
385
- if (bytes.length < 12) return "application/octet-stream";
386
- const format = new TextDecoder().decode(bytes.slice(8, 12));
387
- if (format === "WAVE") return "audio/wav";
388
- if (format === "WEBP") return "image/webp";
389
- return "application/octet-stream";
390
- }
391
- detectZipType(bytes) {
392
- const header = new TextDecoder().decode(bytes.slice(0, 2048));
393
- if (header.includes("[Content_Types].xml") && header.includes("_rels/.rels")) {
394
- if (header.includes("word/")) return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
395
- if (header.includes("xl/")) return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
396
- if (header.includes("ppt/")) return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
397
- }
398
- return "application/zip";
399
- }
400
- };
401
-
402
- // src/model/detectors/LanguageDetector.ts
403
- var ProgrammingLanguageDetector = class {
404
- contentTypeName = "code";
405
- detect(contentSample, lines, firstLine, fileExtension) {
406
- const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
407
- return mime && mime !== "text/plain" ? 0.95 : 0;
408
- }
409
- getMimeType(contentSample, lines, firstLine, fileExtension) {
410
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
411
- if (this.isPython(firstLine, text, lines)) {
412
- return "text/x-python";
413
- }
414
- const cType = this.detectCFamily(text);
415
- if (cType) return cType;
416
- const jsType = this.detectJsType(text);
417
- if (jsType) return jsType;
418
- if (this.isTypescript(text)) {
419
- return "text/typescript";
420
- }
421
- return "text/plain";
422
- }
423
- isPython(firstLine, text, lines) {
424
- if (/^\s*import\s+(\w+|\w+\.\w+)/m.test(text) || /^\s*from\s+(\w+|\w+\.\w+)\s+import\s+/m.test(text)) {
425
- const stdLibs = ["os", "sys", "re", "json", "math", "random", "datetime"];
426
- if (stdLibs.some((lib) => text.includes(`import ${lib}`) || text.includes(`from ${lib}`))) {
427
- return true;
428
- }
429
- }
430
- if (firstLine.startsWith("#!") && firstLine.toLowerCase().includes("python")) return true;
431
- if (text.includes("if __name__ ==") && text.includes("__main__")) return true;
432
- if (/^\s*def\s+\w+\s*\(/.test(text) && !text.includes("function")) return true;
433
- if (/^\s*class\s+\w+\s*[\(:]/m.test(text)) return true;
434
- if (/^\s*@\w+/m.test(text)) return true;
435
- let count = 0;
436
- const patterns = [
437
- /\bif\b.*?:/,
438
- /\belif\b.*?:/,
439
- /\belse\s*:/,
440
- /\bfor\b.*?\bin\b.*?:/,
441
- /\bwhile\b.*?:/,
442
- /\btry\s*:/,
443
- /\bexcept\b.*?:/,
444
- /\bfinally\s*:/,
445
- /\bNone\b/,
446
- /\bTrue\b/,
447
- /\bFalse\b/,
448
- /f["'].*?\{.*?\}["']/,
449
- // f-string
450
- /\bdef\b/,
451
- /\bclass\b/,
452
- /\bimport\b/,
453
- /\bfrom\b/,
454
- /\blambda\b.*?:/
455
- ];
456
- for (const p of patterns) {
457
- if (p.test(text)) count++;
458
- }
459
- const nonEmptyLines = lines.filter((l) => l.trim().length > 0).length;
460
- if (nonEmptyLines <= 5 && count >= 1) {
461
- return true;
462
- }
463
- return count >= 3;
464
- }
465
- detectCFamily(text) {
466
- const cPatterns = [
467
- /#include\s*<.*?>/,
468
- /#include\s*".*?"/,
469
- /\b(int|void|char|float|double)\s+main\s*\(.*\)\s*\{/,
470
- /\bstruct\s+\w+\s*\{/,
471
- /#define\s+\w+/,
472
- /printf\(.*?\);/,
473
- /scanf\(.*?\);/
474
- ];
475
- const cppPatterns = [
476
- /\bclass\s+\w+\s*\{/,
477
- /\bnamespace\s+\w+\s*\{/,
478
- /\btemplate\s*<.*?>/,
479
- /::/,
480
- /\bstd::/,
481
- /\bcout\s*<</,
482
- /\bcin\s*>>/,
483
- /\bnew\s+\w+/,
484
- /\bdelete\s+\w+/,
485
- /#include\s*<iostream>/
486
- ];
487
- let cCount = 0;
488
- let cppCount = 0;
489
- cPatterns.forEach((p) => {
490
- if (p.test(text)) cCount++;
491
- });
492
- cppPatterns.forEach((p) => {
493
- if (p.test(text)) cppCount++;
494
- });
495
- if (cppCount >= 2 || cppCount >= 1 && text.includes("std::")) return "text/x-c++";
496
- if (cCount >= 2) return "text/x-c";
497
- return null;
498
- }
499
- detectJsType(text) {
500
- const jsPatterns = [
501
- /function\s+\w+\s*\(/.test(text),
502
- // function foo(
503
- /\bconst\s+\w+\s*=/.test(text),
504
- /\blet\s+\w+\s*=/.test(text),
505
- /\bvar\s+\w+\s*=/.test(text),
506
- /\bimport\s+.*\s+from/.test(text),
507
- /\bexport\s+/.test(text),
508
- /\=\>\s*\{/.test(text),
509
- // Arrow func
510
- /console\.log\(/.test(text)
511
- ];
512
- const jsxPatterns = [
513
- /<\w+(>|\s+.*?>)[\s\S]*?<\/\w+>/m.test(text),
514
- /<\w+\s+\/>/m.test(text),
515
- /className=/.test(text),
516
- /React\.createElement/.test(text)
517
- ];
518
- const jsCount = jsPatterns.filter(Boolean).length;
519
- const jsxCount = jsxPatterns.filter(Boolean).length;
520
- if (jsxCount > 0 && (text.includes("import React") || text.includes('from "react"'))) return "text/jsx";
521
- if (jsxCount >= 2) return "text/jsx";
522
- if (jsCount >= 2) {
523
- const stripped = text.trim();
524
- if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
525
- try {
526
- JSON.parse(text);
527
- if (jsCount < 2) return null;
528
- } catch {
529
- }
530
- }
531
- return "text/javascript";
532
- }
533
- return null;
534
- }
535
- isTypescript(text) {
536
- const tsPatterns = [
537
- /:\s*(string|number|boolean|any|void|null|undefined)\b/,
538
- /\binterface\s+\w+\s*\{/,
539
- /\bclass\s+\w+\s+implements\s+\w+/,
540
- /\btype\s+\w+\s*=/,
541
- /\b(public|private|protected)\s+/,
542
- /\bnamespace\s+\w+\s*\{/,
543
- /<\w+>/
544
- // Generics (simple check)
545
- ];
546
- let count = 0;
547
- tsPatterns.forEach((p) => {
548
- if (p.test(text)) count++;
549
- });
550
- return count >= 2;
551
- }
552
- };
553
-
554
- // src/model/detectors/MarkupDetectors.ts
555
- var XMLDetector = class _XMLDetector {
556
- contentTypeName = "xml";
557
- static XML_DECLARATION = /^\s*<\?xml/i;
558
- static BASIC_TAG_PAIR = /<(\w+)[^>]*>.*?<\/\1>/s;
559
- detect(contentSample, lines, firstLine, fileExtension) {
560
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
561
- let confidence = 0;
562
- if (fileExtension && fileExtension.toLowerCase() === ".xml") {
563
- confidence = Math.max(confidence, 0.95);
564
- }
565
- if (_XMLDetector.XML_DECLARATION.test(firstLine) || text.trim().startsWith("<?xml")) {
566
- confidence = Math.max(confidence, 0.95);
567
- }
568
- if (text.includes("<") && text.includes(">") && text.includes("</")) {
569
- confidence = Math.max(confidence, 0.5);
570
- if (_XMLDetector.BASIC_TAG_PAIR.test(text)) {
571
- confidence = Math.max(confidence, 0.7);
572
- }
573
- }
574
- if (text.toLowerCase().includes("<!doctype html")) {
575
- if (confidence > 0.3) confidence -= 0.4;
576
- }
577
- return Math.min(Math.max(confidence, 0), 1);
578
- }
579
- getMimeType(contentSample, lines, firstLine, fileExtension) {
580
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
581
- if (fileExtension === ".xml") return "application/xml";
582
- if (text.toLowerCase().includes("<svg")) return "image/svg+xml";
583
- if (text.toLowerCase().includes("<html") || text.toLowerCase().includes("<!doctype html")) return "text/html";
584
- if (this.detect(contentSample, lines, firstLine, fileExtension) > 0.5) return "application/xml";
585
- return "text/plain";
586
- }
587
- };
588
- var MarkdownDetector = class _MarkdownDetector {
589
- contentTypeName = "markdown";
590
- static MD_PATTERNS = [
591
- /^#{1,6}\s+\S+/,
592
- // ATX Headers
593
- /^\s*[\*\+\-]\s+\S+/,
594
- // List items
595
- /^\s*\d+\.\s+\S+/,
596
- // Ordered list items
597
- /`{1,3}[^`]+`{1,3}/,
598
- // Inline code
599
- /\[[^\]]+\]\([^\)]+\)/,
600
- // Links
601
- /!\[[^\]]+\]\([^\)]+\)/,
602
- // Images
603
- /^\s*>.*/
604
- // Blockquotes
605
- ];
606
- static SETEXT_HEADER = /^.*\n(?:={3,}|-{3,})\s*$/m;
607
- detect(contentSample, lines, firstLine, fileExtension) {
608
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
609
- let confidence = 0;
610
- if (fileExtension && [".md", ".markdown"].includes(fileExtension.toLowerCase())) {
611
- confidence = Math.max(confidence, 0.95);
612
- }
613
- let mdFeatures = 0;
614
- if (_MarkdownDetector.SETEXT_HEADER.test(text)) mdFeatures += 2;
615
- for (const line of lines.slice(0, 20)) {
616
- if (_MarkdownDetector.MD_PATTERNS.some((p) => p.test(line))) {
617
- mdFeatures++;
618
- }
619
- }
620
- const hasCodeFence = text.includes("```");
621
- if (hasCodeFence) mdFeatures++;
622
- if (mdFeatures > 1 && hasCodeFence) confidence = Math.max(confidence, 0.85);
623
- if (mdFeatures > 3 && hasCodeFence) confidence = Math.max(confidence, 0.95);
624
- else if (mdFeatures > 1) confidence = Math.max(confidence, 0.6);
625
- else if (mdFeatures > 3) confidence = Math.max(confidence, 0.8);
626
- else if (mdFeatures > 5) confidence = Math.max(confidence, 0.9);
627
- const stripped = text.trim();
628
- if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
629
- try {
630
- JSON.parse(text);
631
- if (confidence > 0.3) confidence -= 0.4;
632
- } catch {
633
- }
634
- }
635
- if (stripped.startsWith("<") && text.includes("<?xml")) {
636
- if (confidence > 0.3) confidence -= 0.4;
637
- }
638
- return Math.min(Math.max(confidence, 0), 1);
639
- }
640
- getMimeType(contentSample, lines, firstLine, fileExtension) {
641
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/markdown" : "text/plain";
642
- }
643
- };
644
- var PlainTextDetector = class _PlainTextDetector {
645
- contentTypeName = "text";
646
- static IMAGE_EXTS = [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg", ".webp"];
647
- detect(contentSample, lines, firstLine, fileExtension) {
648
- if (!contentSample && lines.length === 0) return 0.1;
649
- if (fileExtension) {
650
- const ext = fileExtension.toLowerCase();
651
- if (_PlainTextDetector.IMAGE_EXTS.includes(ext) || ext === ".pdf") return 0;
652
- }
653
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
654
- if (text.includes(",") && lines.length < 5) {
655
- const commaLines = lines.filter((l) => l.includes(",")).length;
656
- if (commaLines > 0 && commaLines === lines.length) {
657
- return 0.8;
658
- }
659
- }
660
- return 0.15;
661
- }
662
- getMimeType(contentSample, lines, firstLine, fileExtension) {
663
- return "text/plain";
664
- }
665
- };
666
-
667
- // src/model/detectors/DataFormatDetectors.ts
668
- var SQLDetector = class _SQLDetector {
669
- contentTypeName = "sql";
670
- // Keywords (case insensitive checking handled in method)
671
- static KEYWORDS = [
672
- "SELECT ",
673
- "INSERT ",
674
- "UPDATE ",
675
- "DELETE ",
676
- "CREATE ",
677
- "DROP ",
678
- "ALTER ",
679
- "FROM ",
680
- "WHERE ",
681
- "JOIN ",
682
- "TABLE ",
683
- "INTO ",
684
- "VALUES ",
685
- "SET ",
686
- "PRIMARY KEY"
687
- ];
688
- detect(contentSample, lines, firstLine, fileExtension) {
689
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
690
- let confidence = 0;
691
- if (fileExtension && fileExtension.toLowerCase() === ".sql") {
692
- confidence = Math.max(confidence, 0.95);
693
- }
694
- let hits = 0;
695
- const upperText = text.toUpperCase();
696
- for (const line of lines.slice(0, 10)) {
697
- const upperLine = line.toUpperCase();
698
- for (const kw of _SQLDetector.KEYWORDS) {
699
- if (upperLine.includes(kw)) {
700
- hits++;
701
- }
702
- }
703
- }
704
- if (hits >= 2) confidence = Math.max(confidence, 0.85);
705
- else if (hits === 1) confidence = Math.max(confidence, 0.6);
706
- return Math.min(confidence, 1);
707
- }
708
- getMimeType(contentSample, lines, firstLine, fileExtension) {
709
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/x-sql" : "text/plain";
710
- }
711
- };
712
- var JSONDetector = class {
713
- contentTypeName = "json";
714
- detect(contentSample, lines, firstLine, fileExtension) {
715
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
716
- if (fileExtension && fileExtension.toLowerCase() === ".json") {
717
- return this.verifyJsonStructure(text) ? 0.95 : 0.6;
718
- }
719
- const stripped = text.trim();
720
- if (!(stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]"))) {
721
- return 0;
722
- }
723
- for (const line of lines.slice(0, 5)) {
724
- const l = line.trim();
725
- if (l.startsWith("//") || l.startsWith("/*")) return 0;
726
- }
727
- try {
728
- JSON.parse(text);
729
- return 0.9;
730
- } catch (e) {
731
- return 0;
732
- }
733
- }
734
- getMimeType(contentSample, lines, firstLine, fileExtension) {
735
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/json" : "text/plain";
736
- }
737
- verifyJsonStructure(text) {
738
- try {
739
- JSON.parse(text);
740
- return true;
741
- } catch {
742
- return false;
743
- }
744
- }
745
- };
746
- var YAMLDetector = class _YAMLDetector {
747
- contentTypeName = "yaml";
748
- static YAML_START_PATTERNS = [/^---\s*$/, /^%YAML/];
749
- static KEY_VALUE_PATTERN = /^\s*[\w.-]+:\s+(?![=\{\[])/;
750
- static LIST_ITEM_PATTERN = /^\s*-\s+[\w\'\"]/;
751
- detect(contentSample, lines, firstLine, fileExtension) {
752
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
753
- let confidence = 0;
754
- if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
755
- confidence = Math.max(confidence, 0.95);
756
- }
757
- if (_YAMLDetector.YAML_START_PATTERNS.some((p) => p.test(firstLine))) {
758
- confidence = Math.max(confidence, 0.9);
759
- }
760
- let yamlFeatures = 0;
761
- if (_YAMLDetector.YAML_START_PATTERNS.some((p) => new RegExp(p.source, "m").test(text))) {
762
- yamlFeatures += 2;
763
- }
764
- for (const line of lines.slice(0, 20)) {
765
- const stripped = line.trim();
766
- if (_YAMLDetector.KEY_VALUE_PATTERN.test(stripped)) yamlFeatures++;
767
- else if (_YAMLDetector.LIST_ITEM_PATTERN.test(stripped)) yamlFeatures++;
768
- }
769
- const firstNonEmpty = lines.find((l) => l.trim().length > 0) || "";
770
- if (firstNonEmpty.trim() === "---") {
771
- if (yamlFeatures > 1) confidence = Math.max(confidence, 0.5);
772
- if (yamlFeatures > 3) confidence = Math.max(confidence, 0.75);
773
- if (yamlFeatures > 5) confidence = Math.max(confidence, 0.9);
774
- } else {
775
- if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
776
- }
777
- }
778
- return Math.min(Math.max(confidence, 0), 1);
779
- }
780
- getMimeType(contentSample, lines, firstLine, fileExtension) {
781
- const conf = this.detect(contentSample, lines, firstLine, fileExtension);
782
- return conf > 0.5 ? "application/x-yaml" : "text/plain";
783
- }
784
- };
785
- var CSVDetector = class {
786
- contentTypeName = "csv";
787
- detect(contentSample, lines, firstLine, fileExtension) {
788
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
789
- if (fileExtension && fileExtension.toLowerCase() === ".csv") {
790
- return this.verifyCsvStructure(lines) ? 0.95 : 0.6;
791
- }
792
- const hasComma = lines.some((l) => l.includes(","));
793
- if (hasComma) {
794
- if (lines.length < 3) {
795
- const commaLines = lines.filter((l) => l.includes(",")).length;
796
- if (commaLines > 0 && commaLines === lines.length) {
797
- const delimCounts = lines.filter((l) => l.trim()).map((l) => (l.match(/,/g) || []).length);
798
- if (delimCounts.length > 0 && delimCounts.every((c) => c <= 2)) {
799
- return 0;
800
- }
801
- }
802
- }
803
- }
804
- return this.analyzeCsvContent(lines);
805
- }
806
- getMimeType(contentSample, lines, firstLine, fileExtension) {
807
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/csv" : "text/plain";
808
- }
809
- verifyCsvStructure(lines) {
810
- const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
811
- if (sampleLines.length === 0) return false;
812
- if (!sampleLines.every((l) => l.includes(","))) return false;
813
- const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
814
- const uniqueCounts = [...new Set(counts)];
815
- if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return true;
816
- if (sampleLines.length > 1) {
817
- const dataCounts = counts.slice(1);
818
- const uniqueData = [...new Set(dataCounts)];
819
- if (uniqueData.length === 1 && uniqueData[0] > 0) return true;
820
- }
821
- return false;
822
- }
823
- analyzeCsvContent(lines) {
824
- if (!lines || lines.length === 0) return 0;
825
- const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
826
- if (sampleLines.length === 0 || !sampleLines.every((l) => l.includes(","))) return 0;
827
- const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
828
- const uniqueCounts = [...new Set(counts)];
829
- if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return 0.9;
830
- if (sampleLines.length > 1) {
831
- const dataCounts = counts.slice(1);
832
- const uniqueData = [...new Set(dataCounts)];
833
- if (uniqueData.length === 1 && uniqueData[0] > 0) return 0.8;
834
- }
835
- if (counts.every((c) => c > 0)) return 0.5;
836
- return 0;
837
- }
838
- };
839
-
840
- // src/model/detectors/OBJDetector.ts
841
- var OBJDetector = class _OBJDetector {
842
- contentTypeName = "obj";
843
- // Check for 'v ' (vertex), 'f ' (face), 'vn ', 'vt '
844
- static COMMANDS = ["v ", "vt ", "vn ", "f ", "g ", "o ", "s ", "mtllib ", "usemtl "];
845
- detect(contentSample, lines, firstLine, fileExtension) {
846
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
847
- let confidence = 0;
848
- if (fileExtension && fileExtension.toLowerCase() === ".obj") {
849
- confidence = Math.max(confidence, 0.95);
850
- }
851
- const validLines = lines.filter((l) => l.trim().length > 0 && !l.trim().startsWith("#"));
852
- let commandCount = 0;
853
- for (const line of validLines.slice(0, 20)) {
854
- const trimmed = line.trim();
855
- for (const cmd of _OBJDetector.COMMANDS) {
856
- if (trimmed.startsWith(cmd)) {
857
- commandCount++;
858
- break;
859
- }
860
- }
861
- }
862
- if (commandCount >= 2) {
863
- if (commandCount > 10) confidence = Math.max(confidence, 0.9);
864
- else if (commandCount > 5) confidence = Math.max(confidence, 0.8);
865
- else confidence = Math.max(confidence, 0.7);
866
- }
867
- const codeKeywords = ["def ", "class ", "import ", "function ", "var ", "let ", "const "];
868
- if (codeKeywords.some((k) => text.includes(k))) {
869
- return 0;
870
- }
871
- return Math.min(confidence, 1);
872
- }
873
- getMimeType(contentSample, lines, firstLine, fileExtension) {
874
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/3d-obj" : "text/plain";
875
- }
876
- };
877
-
878
- // src/model/detectors/registry.ts
879
- var DetectorRegistry = class {
880
- detectors;
881
- constructor() {
882
- this.detectors = [
883
- new BinarySignatureDetector(),
884
- // Programming languages
885
- new ProgrammingLanguageDetector(),
886
- // Structured data
887
- new XMLDetector(),
888
- new JSONDetector(),
889
- new OBJDetector(),
890
- // Markup
891
- new MarkdownDetector(),
892
- // Data formats (lower priority)
893
- new SQLDetector(),
894
- new CSVDetector(),
895
- new YAMLDetector(),
896
- // Fallback
897
- new PlainTextDetector()
898
- ];
899
- }
900
- /**
901
- * Get the active detectors.
902
- */
903
- getDetectors() {
904
- return this.detectors;
905
- }
906
- };
907
- var registry = new DetectorRegistry();
908
-
909
- // ../mime_extensions.json
910
- var mime_extensions_default = {
911
- textMimeTypes: [
912
- "text/plain",
913
- "text/html",
914
- "text/xml",
915
- "text/csv",
916
- "text/css",
917
- "text/javascript",
918
- "text/markdown",
919
- "text/x-python",
920
- "text/x-java",
921
- "text/x-c",
922
- "text/x-c++",
923
- "text/x-sql",
924
- "text/jsx",
925
- "text/typescript",
926
- "application/json",
927
- "application/xml",
928
- "application/x-yaml",
929
- "application/javascript",
930
- "application/x-httpd-php",
931
- "application/x-sh",
932
- "application/x-tex",
933
- "application/3d-obj",
934
- "text/vnd.graphviz",
935
- "text/x-mermaid",
936
- "text/x-plantuml",
937
- "application/x-properties",
938
- "application/toml"
939
- ],
940
- mimeToExtension: {
941
- "image/png": "png",
942
- "image/jpeg": "jpg",
943
- "image/gif": "gif",
944
- "image/bmp": "bmp",
945
- "image/x-icon": "ico",
946
- "image/svg+xml": "svg",
947
- "image/djvu": "djvu",
948
- "image/vnd.djvu": "djv",
949
- "image/webp": "webp",
950
- "audio/wav": "wav",
951
- "audio/x-wav": "wav",
952
- "video/mp4": "mp4",
953
- "video/quicktime": "mov",
954
- "application/pdf": "pdf",
955
- "application/msword": "doc",
956
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
957
- "application/vnd.ms-excel": "xls",
958
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
959
- "application/vnd.ms-powerpoint": "ppt",
960
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
961
- "application/zip": "zip",
962
- "application/gzip": "gz",
963
- "application/x-rar-compressed": "rar",
964
- "application/x-7z-compressed": "7z",
965
- "application/x-sqlite3": "db",
966
- "application/x-parquet": "parquet",
967
- "text/plain": "txt",
968
- "text/html": "html",
969
- "text/xml": "xml",
970
- "text/csv": "csv",
971
- "text/css": "css",
972
- "text/javascript": "js",
973
- "text/markdown": "md",
974
- "text/x-python": "py",
975
- "text/x-java": "java",
976
- "text/x-c": "c",
977
- "text/x-sql": "sql",
978
- "text/jsx": "js",
979
- "application/json": "json",
980
- "application/xml": "xml",
981
- "application/x-yaml": "yaml",
982
- "application/javascript": "js",
983
- "application/x-httpd-php": "php",
984
- "application/x-sh": "sh",
985
- "application/x-tex": "tex",
986
- "text/vnd.graphviz": "dot",
987
- "text/x-mermaid": "mmd",
988
- "text/x-plantuml": "puml",
989
- "application/3d-obj": "obj",
990
- "application/x-properties": "properties",
991
- "application/toml": "toml"
992
- }
993
- };
994
-
995
- // src/config/constants.ts
996
- var DEFAULT_PAGE_SIZE = 10;
997
- var DETECTION_SAMPLE_CAP = 8192;
998
- var MAX_FILE_SIZE = 50 * 1024 * 1024;
999
- var KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
1000
- var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
1001
- var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
1002
- var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
1003
- var DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
1004
-
1005
- // src/model/strategies/DetectionStrategy.ts
1006
- function loadSharedMimeData() {
1007
- return {
1008
- textMimeTypes: new Set(mime_extensions_default.textMimeTypes || []),
1009
- mimeToExtension: mime_extensions_default.mimeToExtension || {}
1010
- };
1011
- }
1012
- var _sharedData = loadSharedMimeData();
1013
- function withDot(ext) {
1014
- return ext.startsWith(".") ? ext : `.${ext}`;
1015
- }
1016
- var DefaultDetectionStrategy = class _DefaultDetectionStrategy {
1017
- constructor(customRegistry) {
1018
- this.customRegistry = customRegistry;
1019
- }
1020
- // Loaded from the shared JSON
1021
- static extensionsRegistry = Object.fromEntries(
1022
- Object.entries(_sharedData.mimeToExtension).map(([k, v]) => [k, withDot(v)])
1023
- );
1024
- static textMimeTypes = _sharedData.textMimeTypes;
1025
- static registerExtension(mimeType, extension) {
1026
- this.extensionsRegistry[mimeType] = extension;
1027
- }
1028
- static loadExtensions(mapping) {
1029
- for (const [mime, ext] of Object.entries(mapping)) {
1030
- this.extensionsRegistry[mime] = ext;
1031
- }
1032
- }
1033
- static getExtension(mimeType) {
1034
- return this.extensionsRegistry[mimeType] || "";
1035
- }
1036
- detect(content, fileExtension) {
1037
- const contentSample = typeof content === "string" ? content.slice(0, DETECTION_SAMPLE_CAP) : content.slice(0, DETECTION_SAMPLE_CAP);
1038
- const textSample = this.getTextSample(contentSample);
1039
- const lines = textSample.split("\n").slice(0, 20);
1040
- const firstLine = lines[0] || "";
1041
- const detectors = this.customRegistry ? this.customRegistry.getDetectors() : registry.getDetectors();
1042
- let bestConfidence = 0;
1043
- let mimeType = "text/plain";
1044
- for (const detector of detectors) {
1045
- const confidence = detector.detect(contentSample, lines, firstLine, fileExtension);
1046
- if (confidence > bestConfidence) {
1047
- const detectedMime = detector.getMimeType(contentSample, lines, firstLine, fileExtension);
1048
- if (detectedMime) {
1049
- bestConfidence = confidence;
1050
- mimeType = detectedMime;
1051
- if (confidence >= 0.99) break;
1052
- }
1053
- }
1054
- }
1055
- let extension = this.getExtension(mimeType);
1056
- if (fileExtension && extension) {
1057
- if (fileExtension.toLowerCase() === extension || fileExtension.toLowerCase() === `.${extension}`) {
1058
- extension = fileExtension;
1059
- }
1060
- }
1061
- if (!extension && fileExtension) {
1062
- extension = fileExtension;
1063
- }
1064
- if (!extension) {
1065
- extension = ".txt";
1066
- }
1067
- return { mimeType, extension };
1068
- }
1069
- getTextSample(content) {
1070
- if (typeof content === "string") {
1071
- return content.slice(0, DETECTION_SAMPLE_CAP);
1072
- }
1073
- return new TextDecoder("utf-8", { fatal: false }).decode(content.slice(0, DETECTION_SAMPLE_CAP));
1074
- }
1075
- getExtension(mimeType) {
1076
- return _DefaultDetectionStrategy.getExtension(mimeType);
1077
- }
1078
- };
1079
-
1080
- // src/model/utils/ContentAnalyzer.ts
1081
- var ContentAnalyzer = class {
1082
- /**
1083
- * Check if content should be treated as binary.
1084
- */
1085
- static isBinaryContent(content, mimeType) {
1086
- if (mimeType) {
1087
- if (mimeType.startsWith("text/") || mimeType.includes("json") || mimeType.includes("xml") || mimeType.includes("javascript") || mimeType.includes("ecmascript")) {
1088
- return false;
1089
- }
1090
- return true;
1091
- }
1092
- if (typeof content === "string") return false;
1093
- if (content.indexOf(0) !== -1) {
1094
- return true;
1095
- }
1096
- try {
1097
- const decoder = new TextDecoder("utf-8", { fatal: true });
1098
- const decoded = decoder.decode(content);
1099
- const sample = content.slice(0, 4096);
1100
- if (sample.length === 0) return false;
1101
- let nonTextChars = 0;
1102
- for (let i = 0; i < sample.length; i++) {
1103
- const b = sample[i];
1104
- if (b < 9 || b > 13 && b < 32 || b > 126) {
1105
- nonTextChars++;
1106
- }
1107
- }
1108
- const textRatio = 1 - nonTextChars / sample.length;
1109
- return textRatio < 0.7;
1110
- } catch (e) {
1111
- return true;
1112
- }
1113
- }
1114
- static isKnownLongLineExtension(extension) {
1115
- if (!extension) return false;
1116
- const ext = extension.toLowerCase();
1117
- return [".min.js", ".min.css", ".map", ".svg", ".json", ".geojson"].some((e) => ext.endsWith(e));
1118
- }
1119
- static isUnstructuredBinary(sample) {
1120
- if (sample.length < 512) return false;
1121
- let nullCount = 0;
1122
- let controlCount = 0;
1123
- const len = Math.min(sample.length, 32 * 1024);
1124
- for (let i = 0; i < len; i++) {
1125
- const byte = sample[i];
1126
- if (byte === 0) {
1127
- nullCount++;
1128
- }
1129
- if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
1130
- controlCount++;
1131
- }
1132
- }
1133
- const nullRatio = nullCount / len;
1134
- const controlRatio = controlCount / len;
1135
- return nullRatio > 0.1 || controlRatio > 0.2;
1136
- }
1137
- static hasPathologicalLines(sample, isKnownType) {
1138
- if (isKnownType || sample.length < 32768) return false;
1139
- for (let i = 0; i < sample.length; i++) {
1140
- if (sample[i] === 10 || sample[i] === 13) return false;
1141
- }
1142
- return true;
1143
- }
1144
- };
1145
-
1146
258
  // src/model/ContentTypeInterpreter.ts
259
+ var import_mcard_wasm = require("mcard-wasm");
1147
260
  var ContentTypeInterpreter = class {
1148
- static strategy = new DefaultDetectionStrategy();
1149
- /**
1150
- * Convenience method to detect MIME type only.
1151
- * Matches the API expected by MCard/PCard/VCard.
1152
- */
1153
261
  static detect(content) {
1154
262
  return this.detectContentType(content).mimeType;
1155
263
  }
1156
- /**
1157
- * Detect content type and suggest extension.
1158
- *
1159
- * @param content Content string or binary buffer
1160
- * @param fileExtension Optional file extension hint
1161
- * @returns Object containing detected mimeType and suggested extension
1162
- */
1163
264
  static detectContentType(content, fileExtension) {
1164
- return this.strategy.detect(content, fileExtension);
1165
- }
1166
- static registerExtension(mimeType, extension) {
1167
- DefaultDetectionStrategy.registerExtension(mimeType, extension);
1168
- }
1169
- static registerExtensions(mapping) {
1170
- DefaultDetectionStrategy.loadExtensions(mapping);
265
+ const buffer = typeof content === "string" ? new TextEncoder().encode(content) : content;
266
+ const result = (0, import_mcard_wasm.detect_content_type)(buffer, fileExtension);
267
+ return { mimeType: result[0], extension: result[1] };
1171
268
  }
1172
269
  static getExtension(mimeType) {
1173
- return DefaultDetectionStrategy.getExtension(mimeType);
270
+ return (0, import_mcard_wasm.get_extension)(mimeType) || "bin";
1174
271
  }
1175
- /**
1176
- * Check if content should be treated as binary.
1177
- */
1178
272
  static isBinaryContent(content, mimeType) {
1179
- return ContentAnalyzer.isBinaryContent(content, mimeType);
273
+ const buffer = typeof content === "string" ? new TextEncoder().encode(content) : content;
274
+ return (0, import_mcard_wasm.is_binary_content)(buffer);
275
+ }
276
+ // Stub or bypass irrelevant manual TS rules now managed by mcard-core
277
+ static registerExtension(mimeType, extension) {
278
+ }
279
+ static registerExtensions(mapping) {
1180
280
  }
1181
281
  static isKnownLongLineExtension(extension) {
1182
- return ContentAnalyzer.isKnownLongLineExtension(extension);
282
+ return false;
1183
283
  }
1184
284
  static isUnstructuredBinary(sample) {
1185
- return ContentAnalyzer.isUnstructuredBinary(sample);
285
+ if (sample.length < 512) return false;
286
+ let nullCount = 0;
287
+ let controlChars = 0;
288
+ for (let i = 0; i < sample.length; i++) {
289
+ const b = sample[i];
290
+ if (b === 0) nullCount++;
291
+ if (b < 32 && b !== 9 && b !== 10 && b !== 13) controlChars++;
292
+ }
293
+ const nullRatio = nullCount / sample.length;
294
+ const controlRatio = controlChars / sample.length;
295
+ return nullRatio > 0.1 || controlRatio > 0.2;
1186
296
  }
1187
297
  static hasPathologicalLines(sample, isKnownType) {
1188
- return ContentAnalyzer.hasPathologicalLines(sample, isKnownType);
298
+ return false;
1189
299
  }
1190
300
  };
1191
301
 
@@ -1265,16 +375,16 @@ var MCard = class _MCard {
1265
375
  }
1266
376
  /**
1267
377
  * Get DOTS vocabulary metadata for this MCard
1268
- *
378
+ *
1269
379
  * Returns the DOTS role information that positions this MCard
1270
380
  * in the Double Operadic Theory of Systems framework.
1271
- *
381
+ *
1272
382
  * MCard is always a CARRIER object in the Data Plane.
1273
- *
383
+ *
1274
384
  * @param tightRefs - Optional array of prerequisite MCard hashes (vertical composition)
1275
385
  * @param looseRefs - Optional array of alternative MCard hashes (horizontal composition)
1276
386
  * @returns DOTSMetadata describing this card's role in the compositional system
1277
- *
387
+ *
1278
388
  * @example
1279
389
  * ```typescript
1280
390
  * const card = await MCard.create('Hello World');
@@ -1288,419 +398,8 @@ var MCard = class _MCard {
1288
398
  }
1289
399
  };
1290
400
 
1291
- // src/storage/schema_constants.ts
1292
- 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
1293
- -- MCard Unified Database Schema (Monadic Core)
1294
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1295
- --
1296
- -- STABILITY WARNING: This schema is the invariant "seeding meta-language" for all
1297
- -- Domain Specific Languages (DSLs). It must remain as stable as possible.
1298
- --
1299
- -- THE UNIFICATION THESIS:
1300
- -- This design unites three distinct namespaces into a single relational network
1301
- -- by leveraging the power of cryptographic hash functions:
1302
- -- 1. CONTENT SPACE (Intrinsic Identity): Content-Addressable Storage (CAS).
1303
- -- 2. HANDLE SPACE (Reserved Words): Mapping human logic to content hashes.
1304
- -- 3. VERSION SPACE (Temporal Evolution): Tracking state transitions via hash history.
1305
- --
1306
- -- TURING MACHINE ANALOGY (The Infinitely Long Tape):
1307
- -- The \`card\` table stores content blobs with unique identities, emulating the
1308
- -- "Infinitely Long Tape" of the Turing Machine formalism. By using relational
1309
- -- queries, this tape can be dynamically constructed and traversed for different
1310
- -- DSLs, providing a flexible substrate for practically all computable languages.
1311
- --
1312
- -- By using hash values as the universal primitives across content, handles, and
1313
- -- time, we create a "Wordless Book" \u2014 a minimal substrate capable of seeding any
1314
- -- domain-specific knowledge system without requiring schema changes.
1315
- --
1316
- -- Monadic Mapping (See: Monadic Justification for Schema Design.md):
1317
- -- 1. Card = Monad (Perception/State/Exponent) - Intrinsic Identity
1318
- -- 2. Handle = Registry (Appetition/Reader/Sum) - Mutable Reference
1319
- -- 3. Version = History (Harmony/Writer/Product) - Coordinated Evolution
1320
- --
1321
- -- Version: 3.0.2 (Turing Tape Refinement)
1322
- -- Last Updated: 2025-12-20
1323
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1324
-
1325
-
1326
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1327
- -- LAYER 1: CORE CONTENT-ADDRESSABLE STORAGE (The Monad / Exponent)
1328
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1329
- -- The fundamental MCard storage: content-addressed by cryptographic hash.
1330
- -- "Each Monad ... mirrors the universe"
1331
-
1332
- -- @table card
1333
- -- @description Core content-addressable storage table (Monad/State)
1334
- -- @column hash - SHA-256 hash of content (primary key)
1335
- -- @column content - The actual content (BLOB for binary safety)
1336
- -- @column g_time - Generation timestamp (ISO 8601)
1337
- CREATE TABLE IF NOT EXISTS card (
1338
- hash TEXT PRIMARY KEY,
1339
- content BLOB NOT NULL,
1340
- g_time TEXT NOT NULL
1341
- );
1342
-
1343
-
1344
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1345
- -- LAYER 2: HANDLE SYSTEM (Appetition / Sum)
1346
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1347
- -- The mutable pointer that "desires" to reference new content.
1348
- -- "Appetition: the tendency to move to new states"
1349
-
1350
- -- @table handle_registry (Monadic Role: Handle)
1351
- -- @description Maps human-readable handles to current content hashes
1352
- -- @column handle - UTF-8 handle name (primary key)
1353
- -- @column current_hash - FK to card.hash of current version
1354
- -- @column created_at - When handle was first created
1355
- -- @column updated_at - When handle was last updated
1356
- CREATE TABLE IF NOT EXISTS handle_registry (
1357
- handle TEXT PRIMARY KEY,
1358
- current_hash TEXT NOT NULL,
1359
- created_at TEXT NOT NULL,
1360
- updated_at TEXT NOT NULL,
1361
- FOREIGN KEY (current_hash) REFERENCES card(hash)
1362
- );
1363
-
1364
- -- @index idx_handle_current_hash
1365
- -- @description Efficient reverse lookup from hash to handles
1366
- CREATE INDEX IF NOT EXISTS idx_handle_current_hash
1367
- ON handle_registry(current_hash);
1368
-
1369
- -- @table handle_history (Monadic Role: Version / Product)
1370
- -- @description Audit trail for handle pointer changes (Pre-Established Harmony)
1371
- -- @column id - Auto-increment primary key
1372
- -- @column handle - The handle that was updated
1373
- -- @column previous_hash - Hash it pointed to before update
1374
- -- @column changed_at - When the change occurred
1375
- CREATE TABLE IF NOT EXISTS handle_history (
1376
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1377
- handle TEXT NOT NULL,
1378
- previous_hash TEXT NOT NULL,
1379
- changed_at TEXT NOT NULL,
1380
- FOREIGN KEY (handle) REFERENCES handle_registry(handle),
1381
- FOREIGN KEY (previous_hash) REFERENCES card(hash)
1382
- );
1383
-
1384
- -- @index idx_handle_history_handle
1385
- -- @description Efficient lookup of history by handle
1386
- CREATE INDEX IF NOT EXISTS idx_handle_history_handle
1387
- ON handle_history(handle);
1388
-
1389
-
1390
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1391
- -- LEGACY SUPPORT: FTS5 Documents Table
1392
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1393
- -- KEPT FOR BACKWARD COMPATIBILITY with existing codebase.
1394
- -- New implementations should use mcard_vector_schema.sql -> mcard_fts
1395
-
1396
- -- @virtual_table documents
1397
- -- @description Legacy FTS table for backward compatibility
1398
- -- @note Synced with card table via triggers
1399
- CREATE VIRTUAL TABLE IF NOT EXISTS documents USING fts5(content);
1400
-
1401
-
1402
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1403
- -- SCHEMA METADATA
1404
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1405
-
1406
- -- @table schema_version
1407
- -- @description Tracks schema version for migrations
1408
- CREATE TABLE IF NOT EXISTS schema_version (
1409
- version TEXT PRIMARY KEY,
1410
- applied_at TEXT NOT NULL,
1411
- description TEXT
1412
- );
1413
-
1414
- -- Insert current schema version
1415
- INSERT OR IGNORE INTO schema_version (version, applied_at, description)
1416
- VALUES ('3.0.0', datetime('now'), 'Monadic Core Schema (split vectors to mcard_vector_schema.sql)');
1417
- `;
1418
- 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
1419
- -- MCard Vector Database Schema (mcard_vectors.db)
1420
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1421
- --
1422
- -- This schema defines the structure for "Secondary Qualities" (Extrinsic Embeddings).
1423
- -- It is separated from the core mcard.db (Monadic Intrinsic Properties) to ensure:
1424
- -- 1. Separation of Concerns (Intrinsic vs Extrinsic)
1425
- -- 2. Linearity (Vectors are observer-dependent and large)
1426
- -- 3. Upgradability (Embedding models change frequently)
1427
- --
1428
- -- See: Monadic Justification for Schema Design.md
1429
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1430
-
1431
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1432
- -- LAYER 3: VECTOR STORAGE (Semantic Embeddings)
1433
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1434
- -- Storage for vector embeddings enabling semantic search.
1435
- -- Links to content via hash for content-addressing.
1436
-
1437
- -- @table mcard_vector_metadata
1438
- -- @description Metadata for stored embeddings
1439
- -- @column id - Auto-increment primary key
1440
- -- @column hash - FK to card.hash
1441
- -- @column model_name - Embedding model used (e.g., "nomic-embed-text")
1442
- -- @column dimensions - Vector dimensions
1443
- -- @column chunk_index - Index for chunked documents (0 = first/whole)
1444
- -- @column chunk_total - Total chunks for this document
1445
- -- @column chunk_text - Preview text for this chunk
1446
- -- @column created_at - When embedding was created
1447
- CREATE TABLE IF NOT EXISTS mcard_vector_metadata (
1448
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1449
- hash TEXT NOT NULL,
1450
- model_name TEXT NOT NULL,
1451
- dimensions INTEGER NOT NULL,
1452
- chunk_index INTEGER DEFAULT 0,
1453
- chunk_total INTEGER DEFAULT 1,
1454
- chunk_text TEXT,
1455
- created_at TEXT NOT NULL,
1456
- UNIQUE(hash, chunk_index)
1457
- );
1458
-
1459
- -- @index idx_vector_metadata_hash
1460
- -- @description Efficient lookup of embeddings by content hash
1461
- CREATE INDEX IF NOT EXISTS idx_vector_metadata_hash
1462
- ON mcard_vector_metadata(hash);
1463
-
1464
- -- @table mcard_embeddings
1465
- -- @description Fallback embedding storage when sqlite-vec is unavailable
1466
- -- @column id - Auto-increment primary key
1467
- -- @column metadata_id - FK to mcard_vector_metadata.id
1468
- -- @column embedding - Serialized float32 vector as BLOB
1469
- CREATE TABLE IF NOT EXISTS mcard_embeddings (
1470
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1471
- metadata_id INTEGER NOT NULL,
1472
- embedding BLOB NOT NULL,
1473
- UNIQUE(metadata_id),
1474
- FOREIGN KEY (metadata_id) REFERENCES mcard_vector_metadata(id)
1475
- );
1476
-
1477
- -- @virtual_table mcard_fts
1478
- -- @description Full-text search for hybrid retrieval
1479
- -- @note Uses Porter stemming with Unicode support
1480
- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_fts USING fts5(
1481
- hash,
1482
- content,
1483
- tokenize='porter unicode61'
1484
- );
1485
-
1486
- -- Note: sqlite-vec virtual table is created dynamically with dimensions:
1487
- -- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_vec USING vec0(
1488
- -- metadata_id INTEGER PRIMARY KEY,
1489
- -- embedding float[\${dimensions}]
1490
- -- );
1491
-
1492
-
1493
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1494
- -- LAYER 4: SEMANTIC VERSIONING (Handle-Vector Bridge)
1495
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1496
- -- Bridges handles to vector embeddings for semantic version comparison.
1497
- -- Enables measuring semantic drift between document versions.
1498
-
1499
- -- @table handle_version_vectors
1500
- -- @description Links handle versions to their semantic embeddings
1501
- -- @column id - Auto-increment primary key
1502
- -- @column handle - FK to handle_registry.handle
1503
- -- @column hash - FK to card.hash (this version)
1504
- -- @column parent_hash - FK to card.hash (previous version)
1505
- -- @column version_order - 0 = current, 1 = previous, etc.
1506
- -- @column is_current - TRUE if this is the current version
1507
- -- @column embedding_id - FK to mcard_vector_metadata.id
1508
- -- @column semantic_delta_from_parent - Cosine similarity to parent [-1, 1]
1509
- -- @column upgrade_type - Classification: 'trivial' | 'minor' | 'major' | 'breaking'
1510
- -- @column created_at - When this version was linked
1511
- CREATE TABLE IF NOT EXISTS handle_version_vectors (
1512
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1513
- handle TEXT NOT NULL,
1514
- hash TEXT NOT NULL,
1515
- parent_hash TEXT,
1516
- version_order INTEGER NOT NULL,
1517
- is_current BOOLEAN DEFAULT FALSE,
1518
- embedding_id INTEGER,
1519
- semantic_delta_from_parent REAL,
1520
- upgrade_type TEXT,
1521
- created_at TEXT NOT NULL,
1522
- UNIQUE(handle, hash),
1523
- FOREIGN KEY (embedding_id) REFERENCES mcard_vector_metadata(id)
1524
- );
1525
-
1526
- -- @index idx_hvv_handle
1527
- -- @description Efficient lookup of versions by handle
1528
- CREATE INDEX IF NOT EXISTS idx_hvv_handle
1529
- ON handle_version_vectors(handle);
1530
-
1531
- -- @index idx_hvv_hash
1532
- -- @description Efficient lookup of versions by hash
1533
- CREATE INDEX IF NOT EXISTS idx_hvv_hash
1534
- ON handle_version_vectors(hash);
1535
-
1536
- -- @index idx_hvv_current
1537
- -- @description Efficient lookup of current versions
1538
- CREATE INDEX IF NOT EXISTS idx_hvv_current
1539
- ON handle_version_vectors(is_current);
1540
-
1541
- -- @index idx_hvv_parent
1542
- -- @description Efficient lookup by parent hash
1543
- CREATE INDEX IF NOT EXISTS idx_hvv_parent
1544
- ON handle_version_vectors(parent_hash);
1545
-
1546
- -- @table version_similarity_cache
1547
- -- @description Precomputed pairwise similarities for performance
1548
- -- @column id - Auto-increment primary key
1549
- -- @column handle - Handle these versions belong to
1550
- -- @column hash_a - First version hash
1551
- -- @column hash_b - Second version hash
1552
- -- @column similarity_score - Cosine similarity [-1, 1]
1553
- -- @column distance_euclidean - L2 distance [0, \u221E)
1554
- -- @column computed_at - When similarity was computed
1555
- CREATE TABLE IF NOT EXISTS version_similarity_cache (
1556
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1557
- handle TEXT NOT NULL,
1558
- hash_a TEXT NOT NULL,
1559
- hash_b TEXT NOT NULL,
1560
- similarity_score REAL NOT NULL,
1561
- distance_euclidean REAL,
1562
- computed_at TEXT NOT NULL,
1563
- UNIQUE(handle, hash_a, hash_b)
1564
- );
1565
-
1566
- -- @index idx_vsc_handle
1567
- -- @description Efficient lookup of cached similarities by handle
1568
- CREATE INDEX IF NOT EXISTS idx_vsc_handle
1569
- ON version_similarity_cache(handle);
1570
-
1571
-
1572
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1573
- -- LAYER 5: KNOWLEDGE GRAPH (GraphRAG)
1574
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1575
- -- Storage for extracted knowledge graph entities and relationships.
1576
-
1577
- -- @table graph_entities
1578
- -- @description Nodes in the knowledge graph
1579
- -- @column id - Auto-increment primary key
1580
- -- @column name - Entity name
1581
- -- @column type - Entity type (e.g., "Person", "Organization")
1582
- -- @column description - Optional description
1583
- -- @column source_hash - FK to card.hash where entity was extracted
1584
- -- @column embedding - Optional entity embedding
1585
- -- @column created_at - When entity was created
1586
- CREATE TABLE IF NOT EXISTS graph_entities (
1587
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1588
- name TEXT NOT NULL,
1589
- type TEXT NOT NULL,
1590
- description TEXT,
1591
- source_hash TEXT NOT NULL,
1592
- embedding BLOB,
1593
- created_at TEXT NOT NULL,
1594
- UNIQUE(name, type, source_hash)
1595
- );
1596
-
1597
- -- @index idx_entity_name
1598
- -- @description Efficient entity lookup by name
1599
- CREATE INDEX IF NOT EXISTS idx_entity_name
1600
- ON graph_entities(name);
1601
-
1602
- -- @index idx_entity_type
1603
- -- @description Efficient entity lookup by type
1604
- CREATE INDEX IF NOT EXISTS idx_entity_type
1605
- ON graph_entities(type);
1606
-
1607
- -- @index idx_entity_source
1608
- -- @description Efficient entity lookup by source document
1609
- CREATE INDEX IF NOT EXISTS idx_entity_source
1610
- ON graph_entities(source_hash);
1611
-
1612
- -- @table graph_relationships
1613
- -- @description Edges in the knowledge graph
1614
- -- @column id - Auto-increment primary key
1615
- -- @column source_entity_id - FK to graph_entities.id (from)
1616
- -- @column target_entity_id - FK to graph_entities.id (to)
1617
- -- @column relationship - Relationship type/label
1618
- -- @column description - Optional description
1619
- -- @column weight - Relationship strength
1620
- -- @column source_hash - FK to card.hash where relationship was extracted
1621
- -- @column created_at - When relationship was created
1622
- CREATE TABLE IF NOT EXISTS graph_relationships (
1623
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1624
- source_entity_id INTEGER NOT NULL,
1625
- target_entity_id INTEGER NOT NULL,
1626
- relationship TEXT NOT NULL,
1627
- description TEXT,
1628
- weight REAL DEFAULT 1.0,
1629
- source_hash TEXT NOT NULL,
1630
- created_at TEXT NOT NULL,
1631
- UNIQUE(source_entity_id, target_entity_id, relationship, source_hash),
1632
- FOREIGN KEY (source_entity_id) REFERENCES graph_entities(id),
1633
- FOREIGN KEY (target_entity_id) REFERENCES graph_entities(id)
1634
- );
1635
-
1636
- -- @index idx_rel_source
1637
- -- @description Efficient lookup of relationships by source entity
1638
- CREATE INDEX IF NOT EXISTS idx_rel_source
1639
- ON graph_relationships(source_entity_id);
1640
-
1641
- -- @index idx_rel_target
1642
- -- @description Efficient lookup of relationships by target entity
1643
- CREATE INDEX IF NOT EXISTS idx_rel_target
1644
- ON graph_relationships(target_entity_id);
1645
-
1646
- -- @table graph_communities
1647
- -- @description Hierarchical community summaries (GraphRAG)
1648
- -- @column id - Auto-increment primary key
1649
- -- @column level - Hierarchy level (0 = leaf)
1650
- -- @column title - Community title
1651
- -- @column summary - AI-generated summary
1652
- -- @column embedding - Community embedding
1653
- -- @column member_entity_ids - JSON array of entity IDs
1654
- -- @column parent_community_id - FK to parent community
1655
- -- @column created_at - When community was created
1656
- CREATE TABLE IF NOT EXISTS graph_communities (
1657
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1658
- level INTEGER NOT NULL DEFAULT 0,
1659
- title TEXT,
1660
- summary TEXT NOT NULL,
1661
- embedding BLOB,
1662
- member_entity_ids TEXT,
1663
- parent_community_id INTEGER,
1664
- created_at TEXT NOT NULL,
1665
- FOREIGN KEY (parent_community_id) REFERENCES graph_communities(id)
1666
- );
1667
-
1668
- -- @index idx_community_level
1669
- -- @description Efficient lookup of communities by level
1670
- CREATE INDEX IF NOT EXISTS idx_community_level
1671
- ON graph_communities(level);
1672
-
1673
- -- @table graph_extractions
1674
- -- @description Tracks which documents have been processed for entity extraction
1675
- -- @column hash - FK to card.hash (primary key)
1676
- -- @column entity_count - Number of entities extracted
1677
- -- @column relationship_count - Number of relationships extracted
1678
- -- @column extracted_at - When extraction was performed
1679
- CREATE TABLE IF NOT EXISTS graph_extractions (
1680
- hash TEXT PRIMARY KEY,
1681
- entity_count INTEGER DEFAULT 0,
1682
- relationship_count INTEGER DEFAULT 0,
1683
- extracted_at TEXT NOT NULL
1684
- );
1685
-
1686
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1687
- -- SCHEMA METADATA (Vector DB)
1688
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1689
-
1690
- -- @table schema_version
1691
- -- @description Tracks schema version for migrations
1692
- CREATE TABLE IF NOT EXISTS vector_schema_version (
1693
- version TEXT PRIMARY KEY,
1694
- applied_at TEXT NOT NULL,
1695
- description TEXT
1696
- );
1697
-
1698
- -- Insert current schema version
1699
- INSERT OR IGNORE INTO vector_schema_version (version, applied_at, description)
1700
- VALUES ('1.0.0', datetime('now'), 'Initial MCard Vector Schema');
1701
- `;
1702
-
1703
401
  // src/storage/schema.ts
402
+ var import_mcard_wasm2 = require("mcard-wasm");
1704
403
  var TABLE_LAYERS = {
1705
404
  // Layer 1: Core
1706
405
  "card": "core",
@@ -1750,10 +449,11 @@ var MCardSchema = class _MCardSchema {
1750
449
  }
1751
450
  load() {
1752
451
  if (this.loaded) return;
1753
- this.schemaPath = "IN_MEMORY_CONSTANTS";
1754
- this.rawSql = MCARD_SCHEMA_SQL;
1755
- if (MCARD_VECTOR_SCHEMA_SQL) {
1756
- this.rawSql += "\n\n" + MCARD_VECTOR_SCHEMA_SQL;
452
+ this.schemaPath = "WASM_MEMORY_SPACE";
453
+ this.rawSql = (0, import_mcard_wasm2.get_core_schema)();
454
+ const vectorSql = (0, import_mcard_wasm2.get_vector_schema)();
455
+ if (vectorSql) {
456
+ this.rawSql += "\n\n" + vectorSql;
1757
457
  }
1758
458
  this.statements = this.parseStatements(this.rawSql);
1759
459
  for (const stmt of this.statements) {
@@ -1938,6 +638,28 @@ function createPage(items, totalItems, pageNumber, pageSize) {
1938
638
  };
1939
639
  }
1940
640
 
641
+ // src/config/constants.ts
642
+ var DEFAULT_PAGE_SIZE = 10;
643
+ var MAX_FILE_SIZE = 50 * 1024 * 1024;
644
+ var KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
645
+ var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
646
+ var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
647
+ var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
648
+ var getEnvUrl = (key, fallback) => {
649
+ try {
650
+ if (typeof process !== "undefined" && process.env && process.env[key]) {
651
+ return process.env[key];
652
+ }
653
+ } catch (e) {
654
+ }
655
+ return fallback;
656
+ };
657
+ var DEFAULT_OLLAMA_BASE_URL = getEnvUrl("OLLAMA_BASE_URL", "http://localhost:11434");
658
+ var DEFAULT_OTLP_ENDPOINT = getEnvUrl("OTLP_ENDPOINT", "http://localhost:4317");
659
+ var DEFAULT_VLLM_BASE_URL = getEnvUrl("VLLM_BASE_URL", "http://localhost:8000");
660
+ var DEFAULT_LMSTUDIO_BASE_URL = getEnvUrl("LMSTUDIO_BASE_URL", "http://localhost:1234");
661
+ var DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
662
+
1941
663
  // src/storage/engines/AbstractSqlEngine.ts
1942
664
  var AbstractSqlEngine = class {
1943
665
  /**