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
@@ -372,939 +372,47 @@ module.exports = __toCommonJS(index_browser_exports);
372
372
  init_HashValidator();
373
373
  init_GTime();
374
374
 
375
- // src/model/detectors/BinaryDetector.ts
376
- var BinarySignatureDetector = class _BinarySignatureDetector {
377
- contentTypeName = "binary";
378
- // Signatures map: [Signature Bytes, Mime Type]
379
- static SIGNATURES = [
380
- [new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), "image/png"],
381
- [new Uint8Array([255, 216, 255]), "image/jpeg"],
382
- [new Uint8Array([71, 73, 70, 56, 55, 97]), "image/gif"],
383
- // GIF87a
384
- [new Uint8Array([71, 73, 70, 56, 57, 97]), "image/gif"],
385
- // GIF89a
386
- [new Uint8Array([66, 77]), "image/bmp"],
387
- // BM
388
- [new Uint8Array([0, 0, 1, 0]), "image/x-icon"],
389
- [new Uint8Array([0, 0, 2, 0]), "image/x-icon"],
390
- [new Uint8Array([37, 80, 68, 70]), "application/pdf"],
391
- // %PDF
392
- [new Uint8Array([80, 75, 3, 4]), "application/zip"],
393
- // PK..
394
- [new Uint8Array([31, 139, 8]), "application/gzip"],
395
- [new Uint8Array([82, 97, 114, 33, 26, 7, 0]), "application/x-rar-compressed"],
396
- [new Uint8Array([55, 122, 188, 175, 39, 28]), "application/x-7z-compressed"],
397
- [new Uint8Array([83, 81, 76, 105, 116, 101, 32, 102, 111, 114, 109, 97, 116, 32, 51, 0]), "application/x-sqlite3"]
398
- ];
399
- // Extension-to-MIME mapping for binary types (used when byte detection fails)
400
- static EXT_TO_MIME = {
401
- // Video
402
- ".mp4": "video/mp4",
403
- ".webm": "video/webm",
404
- ".avi": "video/x-msvideo",
405
- ".mov": "video/quicktime",
406
- ".mkv": "video/x-matroska",
407
- ".wmv": "video/x-ms-wmv",
408
- ".flv": "video/x-flv",
409
- ".m4v": "video/x-m4v",
410
- // Audio
411
- ".mp3": "audio/mpeg",
412
- ".ogg": "audio/ogg",
413
- ".flac": "audio/flac",
414
- ".aac": "audio/aac",
415
- ".m4a": "audio/mp4",
416
- ".wma": "audio/x-ms-wma",
417
- // Images (backup for when signature detection fails)
418
- ".png": "image/png",
419
- ".jpg": "image/jpeg",
420
- ".jpeg": "image/jpeg",
421
- ".gif": "image/gif",
422
- ".bmp": "image/bmp",
423
- ".ico": "image/x-icon",
424
- ".webp": "image/webp",
425
- ".svg": "image/svg+xml",
426
- // Documents
427
- ".pdf": "application/pdf",
428
- // Archives
429
- ".zip": "application/zip",
430
- ".gz": "application/gzip",
431
- ".rar": "application/x-rar-compressed",
432
- ".7z": "application/x-7z-compressed",
433
- ".tar": "application/x-tar",
434
- // Database
435
- ".db": "application/x-sqlite3",
436
- ".sqlite": "application/x-sqlite3",
437
- ".sqlite3": "application/x-sqlite3",
438
- // Fonts
439
- ".woff": "font/woff",
440
- ".woff2": "font/woff2",
441
- ".ttf": "font/ttf",
442
- ".otf": "font/otf",
443
- ".eot": "application/vnd.ms-fontobject"
444
- };
445
- detect(contentSample, lines, firstLine, fileExtension) {
446
- const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
447
- return mime && mime !== "application/octet-stream" ? 0.95 : 0;
448
- }
449
- getMimeType(contentSample, lines, firstLine, fileExtension) {
450
- const bytes = this.toBytes(contentSample);
451
- const detected = this.detectFromBytes(bytes);
452
- if (detected !== "application/octet-stream") {
453
- return detected;
454
- }
455
- if (fileExtension) {
456
- let ext = fileExtension.toLowerCase();
457
- const lastDotIndex = ext.lastIndexOf(".");
458
- if (lastDotIndex > -1) {
459
- ext = ext.substring(lastDotIndex);
460
- } else if (!ext.startsWith(".")) {
461
- if (ext.includes("/") || ext.includes("\\")) {
462
- return "application/octet-stream";
463
- }
464
- ext = "." + ext;
465
- }
466
- const extMime = _BinarySignatureDetector.EXT_TO_MIME[ext];
467
- if (extMime) {
468
- return extMime;
469
- }
470
- }
471
- return "application/octet-stream";
472
- }
473
- /**
474
- * Detect MIME type directly from bytes.
475
- */
476
- detectFromBytes(bytes) {
477
- if (this.startsWith(bytes, new Uint8Array([82, 73, 70, 70]))) {
478
- return this.detectRiffFormat(bytes);
479
- }
480
- for (const [sig, mime] of _BinarySignatureDetector.SIGNATURES) {
481
- if (this.startsWith(bytes, sig)) {
482
- if (mime === "application/zip") {
483
- return this.detectZipType(bytes);
484
- }
485
- return mime;
486
- }
487
- }
488
- return "application/octet-stream";
489
- }
490
- toBytes(content) {
491
- if (content instanceof Uint8Array) return content;
492
- return new TextEncoder().encode(content);
493
- }
494
- startsWith(data, prefix) {
495
- if (data.length < prefix.length) return false;
496
- for (let i = 0; i < prefix.length; i++) {
497
- if (data[i] !== prefix[i]) return false;
498
- }
499
- return true;
500
- }
501
- detectRiffFormat(bytes) {
502
- if (bytes.length < 12) return "application/octet-stream";
503
- const format = new TextDecoder().decode(bytes.slice(8, 12));
504
- if (format === "WAVE") return "audio/wav";
505
- if (format === "WEBP") return "image/webp";
506
- return "application/octet-stream";
507
- }
508
- detectZipType(bytes) {
509
- const header = new TextDecoder().decode(bytes.slice(0, 2048));
510
- if (header.includes("[Content_Types].xml") && header.includes("_rels/.rels")) {
511
- if (header.includes("word/")) return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
512
- if (header.includes("xl/")) return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
513
- if (header.includes("ppt/")) return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
514
- }
515
- return "application/zip";
516
- }
517
- };
518
-
519
- // src/model/detectors/LanguageDetector.ts
520
- var ProgrammingLanguageDetector = class {
521
- contentTypeName = "code";
522
- detect(contentSample, lines, firstLine, fileExtension) {
523
- const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
524
- return mime && mime !== "text/plain" ? 0.95 : 0;
525
- }
526
- getMimeType(contentSample, lines, firstLine, fileExtension) {
527
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
528
- if (this.isPython(firstLine, text, lines)) {
529
- return "text/x-python";
530
- }
531
- const cType = this.detectCFamily(text);
532
- if (cType) return cType;
533
- const jsType = this.detectJsType(text);
534
- if (jsType) return jsType;
535
- if (this.isTypescript(text)) {
536
- return "text/typescript";
537
- }
538
- return "text/plain";
539
- }
540
- isPython(firstLine, text, lines) {
541
- if (/^\s*import\s+(\w+|\w+\.\w+)/m.test(text) || /^\s*from\s+(\w+|\w+\.\w+)\s+import\s+/m.test(text)) {
542
- const stdLibs = ["os", "sys", "re", "json", "math", "random", "datetime"];
543
- if (stdLibs.some((lib) => text.includes(`import ${lib}`) || text.includes(`from ${lib}`))) {
544
- return true;
545
- }
546
- }
547
- if (firstLine.startsWith("#!") && firstLine.toLowerCase().includes("python")) return true;
548
- if (text.includes("if __name__ ==") && text.includes("__main__")) return true;
549
- if (/^\s*def\s+\w+\s*\(/.test(text) && !text.includes("function")) return true;
550
- if (/^\s*class\s+\w+\s*[\(:]/m.test(text)) return true;
551
- if (/^\s*@\w+/m.test(text)) return true;
552
- let count = 0;
553
- const patterns = [
554
- /\bif\b.*?:/,
555
- /\belif\b.*?:/,
556
- /\belse\s*:/,
557
- /\bfor\b.*?\bin\b.*?:/,
558
- /\bwhile\b.*?:/,
559
- /\btry\s*:/,
560
- /\bexcept\b.*?:/,
561
- /\bfinally\s*:/,
562
- /\bNone\b/,
563
- /\bTrue\b/,
564
- /\bFalse\b/,
565
- /f["'].*?\{.*?\}["']/,
566
- // f-string
567
- /\bdef\b/,
568
- /\bclass\b/,
569
- /\bimport\b/,
570
- /\bfrom\b/,
571
- /\blambda\b.*?:/
572
- ];
573
- for (const p of patterns) {
574
- if (p.test(text)) count++;
575
- }
576
- const nonEmptyLines = lines.filter((l) => l.trim().length > 0).length;
577
- if (nonEmptyLines <= 5 && count >= 1) {
578
- return true;
579
- }
580
- return count >= 3;
581
- }
582
- detectCFamily(text) {
583
- const cPatterns = [
584
- /#include\s*<.*?>/,
585
- /#include\s*".*?"/,
586
- /\b(int|void|char|float|double)\s+main\s*\(.*\)\s*\{/,
587
- /\bstruct\s+\w+\s*\{/,
588
- /#define\s+\w+/,
589
- /printf\(.*?\);/,
590
- /scanf\(.*?\);/
591
- ];
592
- const cppPatterns = [
593
- /\bclass\s+\w+\s*\{/,
594
- /\bnamespace\s+\w+\s*\{/,
595
- /\btemplate\s*<.*?>/,
596
- /::/,
597
- /\bstd::/,
598
- /\bcout\s*<</,
599
- /\bcin\s*>>/,
600
- /\bnew\s+\w+/,
601
- /\bdelete\s+\w+/,
602
- /#include\s*<iostream>/
603
- ];
604
- let cCount = 0;
605
- let cppCount = 0;
606
- cPatterns.forEach((p) => {
607
- if (p.test(text)) cCount++;
608
- });
609
- cppPatterns.forEach((p) => {
610
- if (p.test(text)) cppCount++;
611
- });
612
- if (cppCount >= 2 || cppCount >= 1 && text.includes("std::")) return "text/x-c++";
613
- if (cCount >= 2) return "text/x-c";
614
- return null;
615
- }
616
- detectJsType(text) {
617
- const jsPatterns = [
618
- /function\s+\w+\s*\(/.test(text),
619
- // function foo(
620
- /\bconst\s+\w+\s*=/.test(text),
621
- /\blet\s+\w+\s*=/.test(text),
622
- /\bvar\s+\w+\s*=/.test(text),
623
- /\bimport\s+.*\s+from/.test(text),
624
- /\bexport\s+/.test(text),
625
- /\=\>\s*\{/.test(text),
626
- // Arrow func
627
- /console\.log\(/.test(text)
628
- ];
629
- const jsxPatterns = [
630
- /<\w+(>|\s+.*?>)[\s\S]*?<\/\w+>/m.test(text),
631
- /<\w+\s+\/>/m.test(text),
632
- /className=/.test(text),
633
- /React\.createElement/.test(text)
634
- ];
635
- const jsCount = jsPatterns.filter(Boolean).length;
636
- const jsxCount = jsxPatterns.filter(Boolean).length;
637
- if (jsxCount > 0 && (text.includes("import React") || text.includes('from "react"'))) return "text/jsx";
638
- if (jsxCount >= 2) return "text/jsx";
639
- if (jsCount >= 2) {
640
- const stripped = text.trim();
641
- if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
642
- try {
643
- JSON.parse(text);
644
- if (jsCount < 2) return null;
645
- } catch {
646
- }
647
- }
648
- return "text/javascript";
649
- }
650
- return null;
651
- }
652
- isTypescript(text) {
653
- const tsPatterns = [
654
- /:\s*(string|number|boolean|any|void|null|undefined)\b/,
655
- /\binterface\s+\w+\s*\{/,
656
- /\bclass\s+\w+\s+implements\s+\w+/,
657
- /\btype\s+\w+\s*=/,
658
- /\b(public|private|protected)\s+/,
659
- /\bnamespace\s+\w+\s*\{/,
660
- /<\w+>/
661
- // Generics (simple check)
662
- ];
663
- let count = 0;
664
- tsPatterns.forEach((p) => {
665
- if (p.test(text)) count++;
666
- });
667
- return count >= 2;
668
- }
669
- };
670
-
671
- // src/model/detectors/MarkupDetectors.ts
672
- var XMLDetector = class _XMLDetector {
673
- contentTypeName = "xml";
674
- static XML_DECLARATION = /^\s*<\?xml/i;
675
- static BASIC_TAG_PAIR = /<(\w+)[^>]*>.*?<\/\1>/s;
676
- detect(contentSample, lines, firstLine, fileExtension) {
677
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
678
- let confidence = 0;
679
- if (fileExtension && fileExtension.toLowerCase() === ".xml") {
680
- confidence = Math.max(confidence, 0.95);
681
- }
682
- if (_XMLDetector.XML_DECLARATION.test(firstLine) || text.trim().startsWith("<?xml")) {
683
- confidence = Math.max(confidence, 0.95);
684
- }
685
- if (text.includes("<") && text.includes(">") && text.includes("</")) {
686
- confidence = Math.max(confidence, 0.5);
687
- if (_XMLDetector.BASIC_TAG_PAIR.test(text)) {
688
- confidence = Math.max(confidence, 0.7);
689
- }
690
- }
691
- if (text.toLowerCase().includes("<!doctype html")) {
692
- if (confidence > 0.3) confidence -= 0.4;
693
- }
694
- return Math.min(Math.max(confidence, 0), 1);
695
- }
696
- getMimeType(contentSample, lines, firstLine, fileExtension) {
697
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
698
- if (fileExtension === ".xml") return "application/xml";
699
- if (text.toLowerCase().includes("<svg")) return "image/svg+xml";
700
- if (text.toLowerCase().includes("<html") || text.toLowerCase().includes("<!doctype html")) return "text/html";
701
- if (this.detect(contentSample, lines, firstLine, fileExtension) > 0.5) return "application/xml";
702
- return "text/plain";
703
- }
704
- };
705
- var MarkdownDetector = class _MarkdownDetector {
706
- contentTypeName = "markdown";
707
- static MD_PATTERNS = [
708
- /^#{1,6}\s+\S+/,
709
- // ATX Headers
710
- /^\s*[\*\+\-]\s+\S+/,
711
- // List items
712
- /^\s*\d+\.\s+\S+/,
713
- // Ordered list items
714
- /`{1,3}[^`]+`{1,3}/,
715
- // Inline code
716
- /\[[^\]]+\]\([^\)]+\)/,
717
- // Links
718
- /!\[[^\]]+\]\([^\)]+\)/,
719
- // Images
720
- /^\s*>.*/
721
- // Blockquotes
722
- ];
723
- static SETEXT_HEADER = /^.*\n(?:={3,}|-{3,})\s*$/m;
724
- detect(contentSample, lines, firstLine, fileExtension) {
725
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
726
- let confidence = 0;
727
- if (fileExtension && [".md", ".markdown"].includes(fileExtension.toLowerCase())) {
728
- confidence = Math.max(confidence, 0.95);
729
- }
730
- let mdFeatures = 0;
731
- if (_MarkdownDetector.SETEXT_HEADER.test(text)) mdFeatures += 2;
732
- for (const line of lines.slice(0, 20)) {
733
- if (_MarkdownDetector.MD_PATTERNS.some((p) => p.test(line))) {
734
- mdFeatures++;
735
- }
736
- }
737
- const hasCodeFence = text.includes("```");
738
- if (hasCodeFence) mdFeatures++;
739
- if (mdFeatures > 1 && hasCodeFence) confidence = Math.max(confidence, 0.85);
740
- if (mdFeatures > 3 && hasCodeFence) confidence = Math.max(confidence, 0.95);
741
- else if (mdFeatures > 1) confidence = Math.max(confidence, 0.6);
742
- else if (mdFeatures > 3) confidence = Math.max(confidence, 0.8);
743
- else if (mdFeatures > 5) confidence = Math.max(confidence, 0.9);
744
- const stripped = text.trim();
745
- if (stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]")) {
746
- try {
747
- JSON.parse(text);
748
- if (confidence > 0.3) confidence -= 0.4;
749
- } catch {
750
- }
751
- }
752
- if (stripped.startsWith("<") && text.includes("<?xml")) {
753
- if (confidence > 0.3) confidence -= 0.4;
754
- }
755
- return Math.min(Math.max(confidence, 0), 1);
756
- }
757
- getMimeType(contentSample, lines, firstLine, fileExtension) {
758
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/markdown" : "text/plain";
759
- }
760
- };
761
- var PlainTextDetector = class _PlainTextDetector {
762
- contentTypeName = "text";
763
- static IMAGE_EXTS = [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg", ".webp"];
764
- detect(contentSample, lines, firstLine, fileExtension) {
765
- if (!contentSample && lines.length === 0) return 0.1;
766
- if (fileExtension) {
767
- const ext = fileExtension.toLowerCase();
768
- if (_PlainTextDetector.IMAGE_EXTS.includes(ext) || ext === ".pdf") return 0;
769
- }
770
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
771
- if (text.includes(",") && lines.length < 5) {
772
- const commaLines = lines.filter((l) => l.includes(",")).length;
773
- if (commaLines > 0 && commaLines === lines.length) {
774
- return 0.8;
775
- }
776
- }
777
- return 0.15;
778
- }
779
- getMimeType(contentSample, lines, firstLine, fileExtension) {
780
- return "text/plain";
781
- }
782
- };
783
-
784
- // src/model/detectors/DataFormatDetectors.ts
785
- var SQLDetector = class _SQLDetector {
786
- contentTypeName = "sql";
787
- // Keywords (case insensitive checking handled in method)
788
- static KEYWORDS = [
789
- "SELECT ",
790
- "INSERT ",
791
- "UPDATE ",
792
- "DELETE ",
793
- "CREATE ",
794
- "DROP ",
795
- "ALTER ",
796
- "FROM ",
797
- "WHERE ",
798
- "JOIN ",
799
- "TABLE ",
800
- "INTO ",
801
- "VALUES ",
802
- "SET ",
803
- "PRIMARY KEY"
804
- ];
805
- detect(contentSample, lines, firstLine, fileExtension) {
806
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
807
- let confidence = 0;
808
- if (fileExtension && fileExtension.toLowerCase() === ".sql") {
809
- confidence = Math.max(confidence, 0.95);
810
- }
811
- let hits = 0;
812
- const upperText = text.toUpperCase();
813
- for (const line of lines.slice(0, 10)) {
814
- const upperLine = line.toUpperCase();
815
- for (const kw of _SQLDetector.KEYWORDS) {
816
- if (upperLine.includes(kw)) {
817
- hits++;
818
- }
819
- }
820
- }
821
- if (hits >= 2) confidence = Math.max(confidence, 0.85);
822
- else if (hits === 1) confidence = Math.max(confidence, 0.6);
823
- return Math.min(confidence, 1);
824
- }
825
- getMimeType(contentSample, lines, firstLine, fileExtension) {
826
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/x-sql" : "text/plain";
827
- }
828
- };
829
- var JSONDetector = class {
830
- contentTypeName = "json";
831
- detect(contentSample, lines, firstLine, fileExtension) {
832
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
833
- if (fileExtension && fileExtension.toLowerCase() === ".json") {
834
- return this.verifyJsonStructure(text) ? 0.95 : 0.6;
835
- }
836
- const stripped = text.trim();
837
- if (!(stripped.startsWith("{") && stripped.endsWith("}") || stripped.startsWith("[") && stripped.endsWith("]"))) {
838
- return 0;
839
- }
840
- for (const line of lines.slice(0, 5)) {
841
- const l = line.trim();
842
- if (l.startsWith("//") || l.startsWith("/*")) return 0;
843
- }
844
- try {
845
- JSON.parse(text);
846
- return 0.9;
847
- } catch (e) {
848
- return 0;
849
- }
850
- }
851
- getMimeType(contentSample, lines, firstLine, fileExtension) {
852
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/json" : "text/plain";
853
- }
854
- verifyJsonStructure(text) {
855
- try {
856
- JSON.parse(text);
857
- return true;
858
- } catch {
859
- return false;
860
- }
861
- }
862
- };
863
- var YAMLDetector = class _YAMLDetector {
864
- contentTypeName = "yaml";
865
- static YAML_START_PATTERNS = [/^---\s*$/, /^%YAML/];
866
- static KEY_VALUE_PATTERN = /^\s*[\w.-]+:\s+(?![=\{\[])/;
867
- static LIST_ITEM_PATTERN = /^\s*-\s+[\w\'\"]/;
868
- detect(contentSample, lines, firstLine, fileExtension) {
869
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
870
- let confidence = 0;
871
- if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
872
- confidence = Math.max(confidence, 0.95);
873
- }
874
- if (_YAMLDetector.YAML_START_PATTERNS.some((p) => p.test(firstLine))) {
875
- confidence = Math.max(confidence, 0.9);
876
- }
877
- let yamlFeatures = 0;
878
- if (_YAMLDetector.YAML_START_PATTERNS.some((p) => new RegExp(p.source, "m").test(text))) {
879
- yamlFeatures += 2;
880
- }
881
- for (const line of lines.slice(0, 20)) {
882
- const stripped = line.trim();
883
- if (_YAMLDetector.KEY_VALUE_PATTERN.test(stripped)) yamlFeatures++;
884
- else if (_YAMLDetector.LIST_ITEM_PATTERN.test(stripped)) yamlFeatures++;
885
- }
886
- const firstNonEmpty = lines.find((l) => l.trim().length > 0) || "";
887
- if (firstNonEmpty.trim() === "---") {
888
- if (yamlFeatures > 1) confidence = Math.max(confidence, 0.5);
889
- if (yamlFeatures > 3) confidence = Math.max(confidence, 0.75);
890
- if (yamlFeatures > 5) confidence = Math.max(confidence, 0.9);
891
- } else {
892
- if (fileExtension && [".yaml", ".yml"].includes(fileExtension.toLowerCase())) {
893
- }
894
- }
895
- return Math.min(Math.max(confidence, 0), 1);
896
- }
897
- getMimeType(contentSample, lines, firstLine, fileExtension) {
898
- const conf = this.detect(contentSample, lines, firstLine, fileExtension);
899
- return conf > 0.5 ? "application/x-yaml" : "text/plain";
900
- }
901
- };
902
- var CSVDetector = class {
903
- contentTypeName = "csv";
904
- detect(contentSample, lines, firstLine, fileExtension) {
905
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
906
- if (fileExtension && fileExtension.toLowerCase() === ".csv") {
907
- return this.verifyCsvStructure(lines) ? 0.95 : 0.6;
908
- }
909
- const hasComma = lines.some((l) => l.includes(","));
910
- if (hasComma) {
911
- if (lines.length < 3) {
912
- const commaLines = lines.filter((l) => l.includes(",")).length;
913
- if (commaLines > 0 && commaLines === lines.length) {
914
- const delimCounts = lines.filter((l) => l.trim()).map((l) => (l.match(/,/g) || []).length);
915
- if (delimCounts.length > 0 && delimCounts.every((c) => c <= 2)) {
916
- return 0;
917
- }
918
- }
919
- }
920
- }
921
- return this.analyzeCsvContent(lines);
922
- }
923
- getMimeType(contentSample, lines, firstLine, fileExtension) {
924
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "text/csv" : "text/plain";
925
- }
926
- verifyCsvStructure(lines) {
927
- const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
928
- if (sampleLines.length === 0) return false;
929
- if (!sampleLines.every((l) => l.includes(","))) return false;
930
- const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
931
- const uniqueCounts = [...new Set(counts)];
932
- if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return true;
933
- if (sampleLines.length > 1) {
934
- const dataCounts = counts.slice(1);
935
- const uniqueData = [...new Set(dataCounts)];
936
- if (uniqueData.length === 1 && uniqueData[0] > 0) return true;
937
- }
938
- return false;
939
- }
940
- analyzeCsvContent(lines) {
941
- if (!lines || lines.length === 0) return 0;
942
- const sampleLines = lines.slice(0, 10).filter((l) => l.trim().length > 0);
943
- if (sampleLines.length === 0 || !sampleLines.every((l) => l.includes(","))) return 0;
944
- const counts = sampleLines.map((l) => (l.match(/,/g) || []).length);
945
- const uniqueCounts = [...new Set(counts)];
946
- if (uniqueCounts.length === 1 && uniqueCounts[0] > 0) return 0.9;
947
- if (sampleLines.length > 1) {
948
- const dataCounts = counts.slice(1);
949
- const uniqueData = [...new Set(dataCounts)];
950
- if (uniqueData.length === 1 && uniqueData[0] > 0) return 0.8;
951
- }
952
- if (counts.every((c) => c > 0)) return 0.5;
953
- return 0;
954
- }
955
- };
956
-
957
- // src/model/detectors/OBJDetector.ts
958
- var OBJDetector = class _OBJDetector {
959
- contentTypeName = "obj";
960
- // Check for 'v ' (vertex), 'f ' (face), 'vn ', 'vt '
961
- static COMMANDS = ["v ", "vt ", "vn ", "f ", "g ", "o ", "s ", "mtllib ", "usemtl "];
962
- detect(contentSample, lines, firstLine, fileExtension) {
963
- const text = typeof contentSample === "string" ? contentSample : new TextDecoder().decode(contentSample);
964
- let confidence = 0;
965
- if (fileExtension && fileExtension.toLowerCase() === ".obj") {
966
- confidence = Math.max(confidence, 0.95);
967
- }
968
- const validLines = lines.filter((l) => l.trim().length > 0 && !l.trim().startsWith("#"));
969
- let commandCount = 0;
970
- for (const line of validLines.slice(0, 20)) {
971
- const trimmed = line.trim();
972
- for (const cmd of _OBJDetector.COMMANDS) {
973
- if (trimmed.startsWith(cmd)) {
974
- commandCount++;
975
- break;
976
- }
977
- }
978
- }
979
- if (commandCount >= 2) {
980
- if (commandCount > 10) confidence = Math.max(confidence, 0.9);
981
- else if (commandCount > 5) confidence = Math.max(confidence, 0.8);
982
- else confidence = Math.max(confidence, 0.7);
983
- }
984
- const codeKeywords = ["def ", "class ", "import ", "function ", "var ", "let ", "const "];
985
- if (codeKeywords.some((k) => text.includes(k))) {
986
- return 0;
987
- }
988
- return Math.min(confidence, 1);
989
- }
990
- getMimeType(contentSample, lines, firstLine, fileExtension) {
991
- return this.detect(contentSample, lines, firstLine, fileExtension) > 0.5 ? "application/3d-obj" : "text/plain";
992
- }
993
- };
994
-
995
- // src/model/detectors/registry.ts
996
- var DetectorRegistry = class {
997
- detectors;
998
- constructor() {
999
- this.detectors = [
1000
- new BinarySignatureDetector(),
1001
- // Programming languages
1002
- new ProgrammingLanguageDetector(),
1003
- // Structured data
1004
- new XMLDetector(),
1005
- new JSONDetector(),
1006
- new OBJDetector(),
1007
- // Markup
1008
- new MarkdownDetector(),
1009
- // Data formats (lower priority)
1010
- new SQLDetector(),
1011
- new CSVDetector(),
1012
- new YAMLDetector(),
1013
- // Fallback
1014
- new PlainTextDetector()
1015
- ];
1016
- }
1017
- /**
1018
- * Get the active detectors.
1019
- */
1020
- getDetectors() {
1021
- return this.detectors;
1022
- }
1023
- };
1024
- var registry = new DetectorRegistry();
1025
-
1026
- // ../mime_extensions.json
1027
- var mime_extensions_default = {
1028
- textMimeTypes: [
1029
- "text/plain",
1030
- "text/html",
1031
- "text/xml",
1032
- "text/csv",
1033
- "text/css",
1034
- "text/javascript",
1035
- "text/markdown",
1036
- "text/x-python",
1037
- "text/x-java",
1038
- "text/x-c",
1039
- "text/x-c++",
1040
- "text/x-sql",
1041
- "text/jsx",
1042
- "text/typescript",
1043
- "application/json",
1044
- "application/xml",
1045
- "application/x-yaml",
1046
- "application/javascript",
1047
- "application/x-httpd-php",
1048
- "application/x-sh",
1049
- "application/x-tex",
1050
- "application/3d-obj",
1051
- "text/vnd.graphviz",
1052
- "text/x-mermaid",
1053
- "text/x-plantuml",
1054
- "application/x-properties",
1055
- "application/toml"
1056
- ],
1057
- mimeToExtension: {
1058
- "image/png": "png",
1059
- "image/jpeg": "jpg",
1060
- "image/gif": "gif",
1061
- "image/bmp": "bmp",
1062
- "image/x-icon": "ico",
1063
- "image/svg+xml": "svg",
1064
- "image/djvu": "djvu",
1065
- "image/vnd.djvu": "djv",
1066
- "image/webp": "webp",
1067
- "audio/wav": "wav",
1068
- "audio/x-wav": "wav",
1069
- "video/mp4": "mp4",
1070
- "video/quicktime": "mov",
1071
- "application/pdf": "pdf",
1072
- "application/msword": "doc",
1073
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
1074
- "application/vnd.ms-excel": "xls",
1075
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
1076
- "application/vnd.ms-powerpoint": "ppt",
1077
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
1078
- "application/zip": "zip",
1079
- "application/gzip": "gz",
1080
- "application/x-rar-compressed": "rar",
1081
- "application/x-7z-compressed": "7z",
1082
- "application/x-sqlite3": "db",
1083
- "application/x-parquet": "parquet",
1084
- "text/plain": "txt",
1085
- "text/html": "html",
1086
- "text/xml": "xml",
1087
- "text/csv": "csv",
1088
- "text/css": "css",
1089
- "text/javascript": "js",
1090
- "text/markdown": "md",
1091
- "text/x-python": "py",
1092
- "text/x-java": "java",
1093
- "text/x-c": "c",
1094
- "text/x-sql": "sql",
1095
- "text/jsx": "js",
1096
- "application/json": "json",
1097
- "application/xml": "xml",
1098
- "application/x-yaml": "yaml",
1099
- "application/javascript": "js",
1100
- "application/x-httpd-php": "php",
1101
- "application/x-sh": "sh",
1102
- "application/x-tex": "tex",
1103
- "text/vnd.graphviz": "dot",
1104
- "text/x-mermaid": "mmd",
1105
- "text/x-plantuml": "puml",
1106
- "application/3d-obj": "obj",
1107
- "application/x-properties": "properties",
1108
- "application/toml": "toml"
1109
- }
1110
- };
1111
-
1112
- // src/config/constants.ts
1113
- var DEFAULT_PAGE_SIZE = 10;
1114
- var DETECTION_SAMPLE_CAP = 8192;
1115
- var MAX_FILE_SIZE = 50 * 1024 * 1024;
1116
- var KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
1117
- var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
1118
- var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
1119
- var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
1120
- var INDEXEDDB_DEFAULT_DB_NAME = "mcard-db";
1121
- var INDEXEDDB_DEFAULT_DB_VERSION = 1;
1122
- var DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
1123
-
1124
- // src/model/strategies/DetectionStrategy.ts
1125
- function loadSharedMimeData() {
1126
- return {
1127
- textMimeTypes: new Set(mime_extensions_default.textMimeTypes || []),
1128
- mimeToExtension: mime_extensions_default.mimeToExtension || {}
1129
- };
1130
- }
1131
- var _sharedData = loadSharedMimeData();
1132
- function withDot(ext) {
1133
- return ext.startsWith(".") ? ext : `.${ext}`;
1134
- }
1135
- var DefaultDetectionStrategy = class _DefaultDetectionStrategy {
1136
- constructor(customRegistry) {
1137
- this.customRegistry = customRegistry;
1138
- }
1139
- // Loaded from the shared JSON
1140
- static extensionsRegistry = Object.fromEntries(
1141
- Object.entries(_sharedData.mimeToExtension).map(([k, v]) => [k, withDot(v)])
1142
- );
1143
- static textMimeTypes = _sharedData.textMimeTypes;
1144
- static registerExtension(mimeType, extension) {
1145
- this.extensionsRegistry[mimeType] = extension;
1146
- }
1147
- static loadExtensions(mapping) {
1148
- for (const [mime, ext] of Object.entries(mapping)) {
1149
- this.extensionsRegistry[mime] = ext;
1150
- }
1151
- }
1152
- static getExtension(mimeType) {
1153
- return this.extensionsRegistry[mimeType] || "";
1154
- }
1155
- detect(content, fileExtension) {
1156
- const contentSample = typeof content === "string" ? content.slice(0, DETECTION_SAMPLE_CAP) : content.slice(0, DETECTION_SAMPLE_CAP);
1157
- const textSample = this.getTextSample(contentSample);
1158
- const lines = textSample.split("\n").slice(0, 20);
1159
- const firstLine = lines[0] || "";
1160
- const detectors = this.customRegistry ? this.customRegistry.getDetectors() : registry.getDetectors();
1161
- let bestConfidence = 0;
1162
- let mimeType = "text/plain";
1163
- for (const detector of detectors) {
1164
- const confidence = detector.detect(contentSample, lines, firstLine, fileExtension);
1165
- if (confidence > bestConfidence) {
1166
- const detectedMime = detector.getMimeType(contentSample, lines, firstLine, fileExtension);
1167
- if (detectedMime) {
1168
- bestConfidence = confidence;
1169
- mimeType = detectedMime;
1170
- if (confidence >= 0.99) break;
1171
- }
1172
- }
1173
- }
1174
- let extension = this.getExtension(mimeType);
1175
- if (fileExtension && extension) {
1176
- if (fileExtension.toLowerCase() === extension || fileExtension.toLowerCase() === `.${extension}`) {
1177
- extension = fileExtension;
1178
- }
1179
- }
1180
- if (!extension && fileExtension) {
1181
- extension = fileExtension;
1182
- }
1183
- if (!extension) {
1184
- extension = ".txt";
1185
- }
1186
- return { mimeType, extension };
1187
- }
1188
- getTextSample(content) {
1189
- if (typeof content === "string") {
1190
- return content.slice(0, DETECTION_SAMPLE_CAP);
1191
- }
1192
- return new TextDecoder("utf-8", { fatal: false }).decode(content.slice(0, DETECTION_SAMPLE_CAP));
1193
- }
1194
- getExtension(mimeType) {
1195
- return _DefaultDetectionStrategy.getExtension(mimeType);
1196
- }
1197
- };
1198
-
1199
- // src/model/utils/ContentAnalyzer.ts
1200
- var ContentAnalyzer = class {
1201
- /**
1202
- * Check if content should be treated as binary.
1203
- */
1204
- static isBinaryContent(content, mimeType) {
1205
- if (mimeType) {
1206
- if (mimeType.startsWith("text/") || mimeType.includes("json") || mimeType.includes("xml") || mimeType.includes("javascript") || mimeType.includes("ecmascript")) {
1207
- return false;
1208
- }
1209
- return true;
1210
- }
1211
- if (typeof content === "string") return false;
1212
- if (content.indexOf(0) !== -1) {
1213
- return true;
1214
- }
1215
- try {
1216
- const decoder = new TextDecoder("utf-8", { fatal: true });
1217
- const decoded = decoder.decode(content);
1218
- const sample = content.slice(0, 4096);
1219
- if (sample.length === 0) return false;
1220
- let nonTextChars = 0;
1221
- for (let i = 0; i < sample.length; i++) {
1222
- const b = sample[i];
1223
- if (b < 9 || b > 13 && b < 32 || b > 126) {
1224
- nonTextChars++;
1225
- }
1226
- }
1227
- const textRatio = 1 - nonTextChars / sample.length;
1228
- return textRatio < 0.7;
1229
- } catch (e) {
1230
- return true;
1231
- }
1232
- }
1233
- static isKnownLongLineExtension(extension) {
1234
- if (!extension) return false;
1235
- const ext = extension.toLowerCase();
1236
- return [".min.js", ".min.css", ".map", ".svg", ".json", ".geojson"].some((e) => ext.endsWith(e));
1237
- }
1238
- static isUnstructuredBinary(sample) {
1239
- if (sample.length < 512) return false;
1240
- let nullCount = 0;
1241
- let controlCount = 0;
1242
- const len = Math.min(sample.length, 32 * 1024);
1243
- for (let i = 0; i < len; i++) {
1244
- const byte = sample[i];
1245
- if (byte === 0) {
1246
- nullCount++;
1247
- }
1248
- if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
1249
- controlCount++;
1250
- }
1251
- }
1252
- const nullRatio = nullCount / len;
1253
- const controlRatio = controlCount / len;
1254
- return nullRatio > 0.1 || controlRatio > 0.2;
1255
- }
1256
- static hasPathologicalLines(sample, isKnownType) {
1257
- if (isKnownType || sample.length < 32768) return false;
1258
- for (let i = 0; i < sample.length; i++) {
1259
- if (sample[i] === 10 || sample[i] === 13) return false;
1260
- }
1261
- return true;
1262
- }
1263
- };
1264
-
1265
375
  // src/model/ContentTypeInterpreter.ts
376
+ var import_mcard_wasm = require("mcard-wasm");
1266
377
  var ContentTypeInterpreter = class {
1267
- static strategy = new DefaultDetectionStrategy();
1268
- /**
1269
- * Convenience method to detect MIME type only.
1270
- * Matches the API expected by MCard/PCard/VCard.
1271
- */
1272
378
  static detect(content) {
1273
379
  return this.detectContentType(content).mimeType;
1274
380
  }
1275
- /**
1276
- * Detect content type and suggest extension.
1277
- *
1278
- * @param content Content string or binary buffer
1279
- * @param fileExtension Optional file extension hint
1280
- * @returns Object containing detected mimeType and suggested extension
1281
- */
1282
381
  static detectContentType(content, fileExtension) {
1283
- return this.strategy.detect(content, fileExtension);
1284
- }
1285
- static registerExtension(mimeType, extension) {
1286
- DefaultDetectionStrategy.registerExtension(mimeType, extension);
1287
- }
1288
- static registerExtensions(mapping) {
1289
- DefaultDetectionStrategy.loadExtensions(mapping);
382
+ const buffer = typeof content === "string" ? new TextEncoder().encode(content) : content;
383
+ const result = (0, import_mcard_wasm.detect_content_type)(buffer, fileExtension);
384
+ return { mimeType: result[0], extension: result[1] };
1290
385
  }
1291
386
  static getExtension(mimeType) {
1292
- return DefaultDetectionStrategy.getExtension(mimeType);
387
+ return (0, import_mcard_wasm.get_extension)(mimeType) || "bin";
1293
388
  }
1294
- /**
1295
- * Check if content should be treated as binary.
1296
- */
1297
389
  static isBinaryContent(content, mimeType) {
1298
- return ContentAnalyzer.isBinaryContent(content, mimeType);
390
+ const buffer = typeof content === "string" ? new TextEncoder().encode(content) : content;
391
+ return (0, import_mcard_wasm.is_binary_content)(buffer);
392
+ }
393
+ // Stub or bypass irrelevant manual TS rules now managed by mcard-core
394
+ static registerExtension(mimeType, extension) {
395
+ }
396
+ static registerExtensions(mapping) {
1299
397
  }
1300
398
  static isKnownLongLineExtension(extension) {
1301
- return ContentAnalyzer.isKnownLongLineExtension(extension);
399
+ return false;
1302
400
  }
1303
401
  static isUnstructuredBinary(sample) {
1304
- return ContentAnalyzer.isUnstructuredBinary(sample);
402
+ if (sample.length < 512) return false;
403
+ let nullCount = 0;
404
+ let controlChars = 0;
405
+ for (let i = 0; i < sample.length; i++) {
406
+ const b = sample[i];
407
+ if (b === 0) nullCount++;
408
+ if (b < 32 && b !== 9 && b !== 10 && b !== 13) controlChars++;
409
+ }
410
+ const nullRatio = nullCount / sample.length;
411
+ const controlRatio = controlChars / sample.length;
412
+ return nullRatio > 0.1 || controlRatio > 0.2;
1305
413
  }
1306
414
  static hasPathologicalLines(sample, isKnownType) {
1307
- return ContentAnalyzer.hasPathologicalLines(sample, isKnownType);
415
+ return false;
1308
416
  }
1309
417
  };
1310
418
 
@@ -1384,16 +492,16 @@ var MCard = class _MCard {
1384
492
  }
1385
493
  /**
1386
494
  * Get DOTS vocabulary metadata for this MCard
1387
- *
495
+ *
1388
496
  * Returns the DOTS role information that positions this MCard
1389
497
  * in the Double Operadic Theory of Systems framework.
1390
- *
498
+ *
1391
499
  * MCard is always a CARRIER object in the Data Plane.
1392
- *
500
+ *
1393
501
  * @param tightRefs - Optional array of prerequisite MCard hashes (vertical composition)
1394
502
  * @param looseRefs - Optional array of alternative MCard hashes (horizontal composition)
1395
503
  * @returns DOTSMetadata describing this card's role in the compositional system
1396
- *
504
+ *
1397
505
  * @example
1398
506
  * ```typescript
1399
507
  * const card = await MCard.create('Hello World');
@@ -1411,6 +519,30 @@ var MCard = class _MCard {
1411
519
  init_GTime();
1412
520
  init_Handle();
1413
521
 
522
+ // src/config/constants.ts
523
+ var DEFAULT_PAGE_SIZE = 10;
524
+ var MAX_FILE_SIZE = 50 * 1024 * 1024;
525
+ var KNOWN_TYPE_SIZE_LIMIT = 1024 * 1024;
526
+ var BINARY_CHECK_SAMPLE_SIZE = 32 * 1024;
527
+ var CONTENT_DETECTION_SAMPLE_SIZE = 1024 * 1024;
528
+ var DEFAULT_MAX_PROBLEM_BYTES = 2 * 1024 * 1024;
529
+ var INDEXEDDB_DEFAULT_DB_NAME = "mcard-db";
530
+ var INDEXEDDB_DEFAULT_DB_VERSION = 1;
531
+ var getEnvUrl = (key, fallback) => {
532
+ try {
533
+ if (typeof process !== "undefined" && process.env && process.env[key]) {
534
+ return process.env[key];
535
+ }
536
+ } catch (e) {
537
+ }
538
+ return fallback;
539
+ };
540
+ var DEFAULT_OLLAMA_BASE_URL = getEnvUrl("OLLAMA_BASE_URL", "http://localhost:11434");
541
+ var DEFAULT_OTLP_ENDPOINT = getEnvUrl("OTLP_ENDPOINT", "http://localhost:4317");
542
+ var DEFAULT_VLLM_BASE_URL = getEnvUrl("VLLM_BASE_URL", "http://localhost:8000");
543
+ var DEFAULT_LMSTUDIO_BASE_URL = getEnvUrl("LMSTUDIO_BASE_URL", "http://localhost:1234");
544
+ var DEFAULT_SQLJS_WASM_URL = "https://sql.js.org/dist/";
545
+
1414
546
  // src/monads/Maybe.ts
1415
547
  var Maybe = class _Maybe {
1416
548
  constructor(_value, _isNothing) {
@@ -1974,419 +1106,8 @@ var IndexedDBEngine = class {
1974
1106
  }
1975
1107
  };
1976
1108
 
1977
- // src/storage/schema_constants.ts
1978
- 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
1979
- -- MCard Unified Database Schema (Monadic Core)
1980
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
1981
- --
1982
- -- STABILITY WARNING: This schema is the invariant "seeding meta-language" for all
1983
- -- Domain Specific Languages (DSLs). It must remain as stable as possible.
1984
- --
1985
- -- THE UNIFICATION THESIS:
1986
- -- This design unites three distinct namespaces into a single relational network
1987
- -- by leveraging the power of cryptographic hash functions:
1988
- -- 1. CONTENT SPACE (Intrinsic Identity): Content-Addressable Storage (CAS).
1989
- -- 2. HANDLE SPACE (Reserved Words): Mapping human logic to content hashes.
1990
- -- 3. VERSION SPACE (Temporal Evolution): Tracking state transitions via hash history.
1991
- --
1992
- -- TURING MACHINE ANALOGY (The Infinitely Long Tape):
1993
- -- The \`card\` table stores content blobs with unique identities, emulating the
1994
- -- "Infinitely Long Tape" of the Turing Machine formalism. By using relational
1995
- -- queries, this tape can be dynamically constructed and traversed for different
1996
- -- DSLs, providing a flexible substrate for practically all computable languages.
1997
- --
1998
- -- By using hash values as the universal primitives across content, handles, and
1999
- -- time, we create a "Wordless Book" \u2014 a minimal substrate capable of seeding any
2000
- -- domain-specific knowledge system without requiring schema changes.
2001
- --
2002
- -- Monadic Mapping (See: Monadic Justification for Schema Design.md):
2003
- -- 1. Card = Monad (Perception/State/Exponent) - Intrinsic Identity
2004
- -- 2. Handle = Registry (Appetition/Reader/Sum) - Mutable Reference
2005
- -- 3. Version = History (Harmony/Writer/Product) - Coordinated Evolution
2006
- --
2007
- -- Version: 3.0.2 (Turing Tape Refinement)
2008
- -- Last Updated: 2025-12-20
2009
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2010
-
2011
-
2012
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2013
- -- LAYER 1: CORE CONTENT-ADDRESSABLE STORAGE (The Monad / Exponent)
2014
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2015
- -- The fundamental MCard storage: content-addressed by cryptographic hash.
2016
- -- "Each Monad ... mirrors the universe"
2017
-
2018
- -- @table card
2019
- -- @description Core content-addressable storage table (Monad/State)
2020
- -- @column hash - SHA-256 hash of content (primary key)
2021
- -- @column content - The actual content (BLOB for binary safety)
2022
- -- @column g_time - Generation timestamp (ISO 8601)
2023
- CREATE TABLE IF NOT EXISTS card (
2024
- hash TEXT PRIMARY KEY,
2025
- content BLOB NOT NULL,
2026
- g_time TEXT NOT NULL
2027
- );
2028
-
2029
-
2030
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2031
- -- LAYER 2: HANDLE SYSTEM (Appetition / Sum)
2032
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2033
- -- The mutable pointer that "desires" to reference new content.
2034
- -- "Appetition: the tendency to move to new states"
2035
-
2036
- -- @table handle_registry (Monadic Role: Handle)
2037
- -- @description Maps human-readable handles to current content hashes
2038
- -- @column handle - UTF-8 handle name (primary key)
2039
- -- @column current_hash - FK to card.hash of current version
2040
- -- @column created_at - When handle was first created
2041
- -- @column updated_at - When handle was last updated
2042
- CREATE TABLE IF NOT EXISTS handle_registry (
2043
- handle TEXT PRIMARY KEY,
2044
- current_hash TEXT NOT NULL,
2045
- created_at TEXT NOT NULL,
2046
- updated_at TEXT NOT NULL,
2047
- FOREIGN KEY (current_hash) REFERENCES card(hash)
2048
- );
2049
-
2050
- -- @index idx_handle_current_hash
2051
- -- @description Efficient reverse lookup from hash to handles
2052
- CREATE INDEX IF NOT EXISTS idx_handle_current_hash
2053
- ON handle_registry(current_hash);
2054
-
2055
- -- @table handle_history (Monadic Role: Version / Product)
2056
- -- @description Audit trail for handle pointer changes (Pre-Established Harmony)
2057
- -- @column id - Auto-increment primary key
2058
- -- @column handle - The handle that was updated
2059
- -- @column previous_hash - Hash it pointed to before update
2060
- -- @column changed_at - When the change occurred
2061
- CREATE TABLE IF NOT EXISTS handle_history (
2062
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2063
- handle TEXT NOT NULL,
2064
- previous_hash TEXT NOT NULL,
2065
- changed_at TEXT NOT NULL,
2066
- FOREIGN KEY (handle) REFERENCES handle_registry(handle),
2067
- FOREIGN KEY (previous_hash) REFERENCES card(hash)
2068
- );
2069
-
2070
- -- @index idx_handle_history_handle
2071
- -- @description Efficient lookup of history by handle
2072
- CREATE INDEX IF NOT EXISTS idx_handle_history_handle
2073
- ON handle_history(handle);
2074
-
2075
-
2076
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2077
- -- LEGACY SUPPORT: FTS5 Documents Table
2078
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2079
- -- KEPT FOR BACKWARD COMPATIBILITY with existing codebase.
2080
- -- New implementations should use mcard_vector_schema.sql -> mcard_fts
2081
-
2082
- -- @virtual_table documents
2083
- -- @description Legacy FTS table for backward compatibility
2084
- -- @note Synced with card table via triggers
2085
- CREATE VIRTUAL TABLE IF NOT EXISTS documents USING fts5(content);
2086
-
2087
-
2088
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2089
- -- SCHEMA METADATA
2090
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2091
-
2092
- -- @table schema_version
2093
- -- @description Tracks schema version for migrations
2094
- CREATE TABLE IF NOT EXISTS schema_version (
2095
- version TEXT PRIMARY KEY,
2096
- applied_at TEXT NOT NULL,
2097
- description TEXT
2098
- );
2099
-
2100
- -- Insert current schema version
2101
- INSERT OR IGNORE INTO schema_version (version, applied_at, description)
2102
- VALUES ('3.0.0', datetime('now'), 'Monadic Core Schema (split vectors to mcard_vector_schema.sql)');
2103
- `;
2104
- 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
2105
- -- MCard Vector Database Schema (mcard_vectors.db)
2106
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2107
- --
2108
- -- This schema defines the structure for "Secondary Qualities" (Extrinsic Embeddings).
2109
- -- It is separated from the core mcard.db (Monadic Intrinsic Properties) to ensure:
2110
- -- 1. Separation of Concerns (Intrinsic vs Extrinsic)
2111
- -- 2. Linearity (Vectors are observer-dependent and large)
2112
- -- 3. Upgradability (Embedding models change frequently)
2113
- --
2114
- -- See: Monadic Justification for Schema Design.md
2115
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2116
-
2117
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2118
- -- LAYER 3: VECTOR STORAGE (Semantic Embeddings)
2119
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2120
- -- Storage for vector embeddings enabling semantic search.
2121
- -- Links to content via hash for content-addressing.
2122
-
2123
- -- @table mcard_vector_metadata
2124
- -- @description Metadata for stored embeddings
2125
- -- @column id - Auto-increment primary key
2126
- -- @column hash - FK to card.hash
2127
- -- @column model_name - Embedding model used (e.g., "nomic-embed-text")
2128
- -- @column dimensions - Vector dimensions
2129
- -- @column chunk_index - Index for chunked documents (0 = first/whole)
2130
- -- @column chunk_total - Total chunks for this document
2131
- -- @column chunk_text - Preview text for this chunk
2132
- -- @column created_at - When embedding was created
2133
- CREATE TABLE IF NOT EXISTS mcard_vector_metadata (
2134
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2135
- hash TEXT NOT NULL,
2136
- model_name TEXT NOT NULL,
2137
- dimensions INTEGER NOT NULL,
2138
- chunk_index INTEGER DEFAULT 0,
2139
- chunk_total INTEGER DEFAULT 1,
2140
- chunk_text TEXT,
2141
- created_at TEXT NOT NULL,
2142
- UNIQUE(hash, chunk_index)
2143
- );
2144
-
2145
- -- @index idx_vector_metadata_hash
2146
- -- @description Efficient lookup of embeddings by content hash
2147
- CREATE INDEX IF NOT EXISTS idx_vector_metadata_hash
2148
- ON mcard_vector_metadata(hash);
2149
-
2150
- -- @table mcard_embeddings
2151
- -- @description Fallback embedding storage when sqlite-vec is unavailable
2152
- -- @column id - Auto-increment primary key
2153
- -- @column metadata_id - FK to mcard_vector_metadata.id
2154
- -- @column embedding - Serialized float32 vector as BLOB
2155
- CREATE TABLE IF NOT EXISTS mcard_embeddings (
2156
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2157
- metadata_id INTEGER NOT NULL,
2158
- embedding BLOB NOT NULL,
2159
- UNIQUE(metadata_id),
2160
- FOREIGN KEY (metadata_id) REFERENCES mcard_vector_metadata(id)
2161
- );
2162
-
2163
- -- @virtual_table mcard_fts
2164
- -- @description Full-text search for hybrid retrieval
2165
- -- @note Uses Porter stemming with Unicode support
2166
- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_fts USING fts5(
2167
- hash,
2168
- content,
2169
- tokenize='porter unicode61'
2170
- );
2171
-
2172
- -- Note: sqlite-vec virtual table is created dynamically with dimensions:
2173
- -- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_vec USING vec0(
2174
- -- metadata_id INTEGER PRIMARY KEY,
2175
- -- embedding float[\${dimensions}]
2176
- -- );
2177
-
2178
-
2179
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2180
- -- LAYER 4: SEMANTIC VERSIONING (Handle-Vector Bridge)
2181
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2182
- -- Bridges handles to vector embeddings for semantic version comparison.
2183
- -- Enables measuring semantic drift between document versions.
2184
-
2185
- -- @table handle_version_vectors
2186
- -- @description Links handle versions to their semantic embeddings
2187
- -- @column id - Auto-increment primary key
2188
- -- @column handle - FK to handle_registry.handle
2189
- -- @column hash - FK to card.hash (this version)
2190
- -- @column parent_hash - FK to card.hash (previous version)
2191
- -- @column version_order - 0 = current, 1 = previous, etc.
2192
- -- @column is_current - TRUE if this is the current version
2193
- -- @column embedding_id - FK to mcard_vector_metadata.id
2194
- -- @column semantic_delta_from_parent - Cosine similarity to parent [-1, 1]
2195
- -- @column upgrade_type - Classification: 'trivial' | 'minor' | 'major' | 'breaking'
2196
- -- @column created_at - When this version was linked
2197
- CREATE TABLE IF NOT EXISTS handle_version_vectors (
2198
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2199
- handle TEXT NOT NULL,
2200
- hash TEXT NOT NULL,
2201
- parent_hash TEXT,
2202
- version_order INTEGER NOT NULL,
2203
- is_current BOOLEAN DEFAULT FALSE,
2204
- embedding_id INTEGER,
2205
- semantic_delta_from_parent REAL,
2206
- upgrade_type TEXT,
2207
- created_at TEXT NOT NULL,
2208
- UNIQUE(handle, hash),
2209
- FOREIGN KEY (embedding_id) REFERENCES mcard_vector_metadata(id)
2210
- );
2211
-
2212
- -- @index idx_hvv_handle
2213
- -- @description Efficient lookup of versions by handle
2214
- CREATE INDEX IF NOT EXISTS idx_hvv_handle
2215
- ON handle_version_vectors(handle);
2216
-
2217
- -- @index idx_hvv_hash
2218
- -- @description Efficient lookup of versions by hash
2219
- CREATE INDEX IF NOT EXISTS idx_hvv_hash
2220
- ON handle_version_vectors(hash);
2221
-
2222
- -- @index idx_hvv_current
2223
- -- @description Efficient lookup of current versions
2224
- CREATE INDEX IF NOT EXISTS idx_hvv_current
2225
- ON handle_version_vectors(is_current);
2226
-
2227
- -- @index idx_hvv_parent
2228
- -- @description Efficient lookup by parent hash
2229
- CREATE INDEX IF NOT EXISTS idx_hvv_parent
2230
- ON handle_version_vectors(parent_hash);
2231
-
2232
- -- @table version_similarity_cache
2233
- -- @description Precomputed pairwise similarities for performance
2234
- -- @column id - Auto-increment primary key
2235
- -- @column handle - Handle these versions belong to
2236
- -- @column hash_a - First version hash
2237
- -- @column hash_b - Second version hash
2238
- -- @column similarity_score - Cosine similarity [-1, 1]
2239
- -- @column distance_euclidean - L2 distance [0, \u221E)
2240
- -- @column computed_at - When similarity was computed
2241
- CREATE TABLE IF NOT EXISTS version_similarity_cache (
2242
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2243
- handle TEXT NOT NULL,
2244
- hash_a TEXT NOT NULL,
2245
- hash_b TEXT NOT NULL,
2246
- similarity_score REAL NOT NULL,
2247
- distance_euclidean REAL,
2248
- computed_at TEXT NOT NULL,
2249
- UNIQUE(handle, hash_a, hash_b)
2250
- );
2251
-
2252
- -- @index idx_vsc_handle
2253
- -- @description Efficient lookup of cached similarities by handle
2254
- CREATE INDEX IF NOT EXISTS idx_vsc_handle
2255
- ON version_similarity_cache(handle);
2256
-
2257
-
2258
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2259
- -- LAYER 5: KNOWLEDGE GRAPH (GraphRAG)
2260
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2261
- -- Storage for extracted knowledge graph entities and relationships.
2262
-
2263
- -- @table graph_entities
2264
- -- @description Nodes in the knowledge graph
2265
- -- @column id - Auto-increment primary key
2266
- -- @column name - Entity name
2267
- -- @column type - Entity type (e.g., "Person", "Organization")
2268
- -- @column description - Optional description
2269
- -- @column source_hash - FK to card.hash where entity was extracted
2270
- -- @column embedding - Optional entity embedding
2271
- -- @column created_at - When entity was created
2272
- CREATE TABLE IF NOT EXISTS graph_entities (
2273
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2274
- name TEXT NOT NULL,
2275
- type TEXT NOT NULL,
2276
- description TEXT,
2277
- source_hash TEXT NOT NULL,
2278
- embedding BLOB,
2279
- created_at TEXT NOT NULL,
2280
- UNIQUE(name, type, source_hash)
2281
- );
2282
-
2283
- -- @index idx_entity_name
2284
- -- @description Efficient entity lookup by name
2285
- CREATE INDEX IF NOT EXISTS idx_entity_name
2286
- ON graph_entities(name);
2287
-
2288
- -- @index idx_entity_type
2289
- -- @description Efficient entity lookup by type
2290
- CREATE INDEX IF NOT EXISTS idx_entity_type
2291
- ON graph_entities(type);
2292
-
2293
- -- @index idx_entity_source
2294
- -- @description Efficient entity lookup by source document
2295
- CREATE INDEX IF NOT EXISTS idx_entity_source
2296
- ON graph_entities(source_hash);
2297
-
2298
- -- @table graph_relationships
2299
- -- @description Edges in the knowledge graph
2300
- -- @column id - Auto-increment primary key
2301
- -- @column source_entity_id - FK to graph_entities.id (from)
2302
- -- @column target_entity_id - FK to graph_entities.id (to)
2303
- -- @column relationship - Relationship type/label
2304
- -- @column description - Optional description
2305
- -- @column weight - Relationship strength
2306
- -- @column source_hash - FK to card.hash where relationship was extracted
2307
- -- @column created_at - When relationship was created
2308
- CREATE TABLE IF NOT EXISTS graph_relationships (
2309
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2310
- source_entity_id INTEGER NOT NULL,
2311
- target_entity_id INTEGER NOT NULL,
2312
- relationship TEXT NOT NULL,
2313
- description TEXT,
2314
- weight REAL DEFAULT 1.0,
2315
- source_hash TEXT NOT NULL,
2316
- created_at TEXT NOT NULL,
2317
- UNIQUE(source_entity_id, target_entity_id, relationship, source_hash),
2318
- FOREIGN KEY (source_entity_id) REFERENCES graph_entities(id),
2319
- FOREIGN KEY (target_entity_id) REFERENCES graph_entities(id)
2320
- );
2321
-
2322
- -- @index idx_rel_source
2323
- -- @description Efficient lookup of relationships by source entity
2324
- CREATE INDEX IF NOT EXISTS idx_rel_source
2325
- ON graph_relationships(source_entity_id);
2326
-
2327
- -- @index idx_rel_target
2328
- -- @description Efficient lookup of relationships by target entity
2329
- CREATE INDEX IF NOT EXISTS idx_rel_target
2330
- ON graph_relationships(target_entity_id);
2331
-
2332
- -- @table graph_communities
2333
- -- @description Hierarchical community summaries (GraphRAG)
2334
- -- @column id - Auto-increment primary key
2335
- -- @column level - Hierarchy level (0 = leaf)
2336
- -- @column title - Community title
2337
- -- @column summary - AI-generated summary
2338
- -- @column embedding - Community embedding
2339
- -- @column member_entity_ids - JSON array of entity IDs
2340
- -- @column parent_community_id - FK to parent community
2341
- -- @column created_at - When community was created
2342
- CREATE TABLE IF NOT EXISTS graph_communities (
2343
- id INTEGER PRIMARY KEY AUTOINCREMENT,
2344
- level INTEGER NOT NULL DEFAULT 0,
2345
- title TEXT,
2346
- summary TEXT NOT NULL,
2347
- embedding BLOB,
2348
- member_entity_ids TEXT,
2349
- parent_community_id INTEGER,
2350
- created_at TEXT NOT NULL,
2351
- FOREIGN KEY (parent_community_id) REFERENCES graph_communities(id)
2352
- );
2353
-
2354
- -- @index idx_community_level
2355
- -- @description Efficient lookup of communities by level
2356
- CREATE INDEX IF NOT EXISTS idx_community_level
2357
- ON graph_communities(level);
2358
-
2359
- -- @table graph_extractions
2360
- -- @description Tracks which documents have been processed for entity extraction
2361
- -- @column hash - FK to card.hash (primary key)
2362
- -- @column entity_count - Number of entities extracted
2363
- -- @column relationship_count - Number of relationships extracted
2364
- -- @column extracted_at - When extraction was performed
2365
- CREATE TABLE IF NOT EXISTS graph_extractions (
2366
- hash TEXT PRIMARY KEY,
2367
- entity_count INTEGER DEFAULT 0,
2368
- relationship_count INTEGER DEFAULT 0,
2369
- extracted_at TEXT NOT NULL
2370
- );
2371
-
2372
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2373
- -- SCHEMA METADATA (Vector DB)
2374
- -- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
2375
-
2376
- -- @table schema_version
2377
- -- @description Tracks schema version for migrations
2378
- CREATE TABLE IF NOT EXISTS vector_schema_version (
2379
- version TEXT PRIMARY KEY,
2380
- applied_at TEXT NOT NULL,
2381
- description TEXT
2382
- );
2383
-
2384
- -- Insert current schema version
2385
- INSERT OR IGNORE INTO vector_schema_version (version, applied_at, description)
2386
- VALUES ('1.0.0', datetime('now'), 'Initial MCard Vector Schema');
2387
- `;
2388
-
2389
1109
  // src/storage/schema.ts
1110
+ var import_mcard_wasm2 = require("mcard-wasm");
2390
1111
  var TABLE_LAYERS = {
2391
1112
  // Layer 1: Core
2392
1113
  "card": "core",
@@ -2436,10 +1157,11 @@ var MCardSchema = class _MCardSchema {
2436
1157
  }
2437
1158
  load() {
2438
1159
  if (this.loaded) return;
2439
- this.schemaPath = "IN_MEMORY_CONSTANTS";
2440
- this.rawSql = MCARD_SCHEMA_SQL;
2441
- if (MCARD_VECTOR_SCHEMA_SQL) {
2442
- this.rawSql += "\n\n" + MCARD_VECTOR_SCHEMA_SQL;
1160
+ this.schemaPath = "WASM_MEMORY_SPACE";
1161
+ this.rawSql = (0, import_mcard_wasm2.get_core_schema)();
1162
+ const vectorSql = (0, import_mcard_wasm2.get_vector_schema)();
1163
+ if (vectorSql) {
1164
+ this.rawSql += "\n\n" + vectorSql;
2443
1165
  }
2444
1166
  this.statements = this.parseStatements(this.rawSql);
2445
1167
  for (const stmt of this.statements) {
@@ -3423,24 +2145,24 @@ var MCardStore = class {
3423
2145
  async setHandle(handle, newHash) {
3424
2146
  const db = await this.dbPromise;
3425
2147
  const tx = db.transaction(["handle_registry", "handle_history"], "readwrite");
3426
- const registry2 = tx.objectStore("handle_registry");
2148
+ const registry = tx.objectStore("handle_registry");
3427
2149
  const history = tx.objectStore("handle_history");
3428
2150
  const now = (/* @__PURE__ */ new Date()).toISOString();
3429
- const existing = await registry2.get(handle);
2151
+ const existing = await registry.get(handle);
3430
2152
  if (existing) {
3431
2153
  await history.add({
3432
2154
  handle,
3433
2155
  previous_hash: existing.current_hash,
3434
2156
  changed_at: now
3435
2157
  });
3436
- await registry2.put({
2158
+ await registry.put({
3437
2159
  handle,
3438
2160
  current_hash: newHash,
3439
2161
  created_at: existing.created_at,
3440
2162
  updated_at: now
3441
2163
  });
3442
2164
  } else {
3443
- await registry2.put({
2165
+ await registry.put({
3444
2166
  handle,
3445
2167
  current_hash: newHash,
3446
2168
  created_at: now,
@@ -3452,8 +2174,8 @@ var MCardStore = class {
3452
2174
  async resolveHandle(handle) {
3453
2175
  const db = await this.dbPromise;
3454
2176
  const tx = db.transaction(["handle_registry", "card"], "readonly");
3455
- const registry2 = tx.objectStore("handle_registry");
3456
- const entry = await registry2.get(handle);
2177
+ const registry = tx.objectStore("handle_registry");
2178
+ const entry = await registry.get(handle);
3457
2179
  if (!entry) return void 0;
3458
2180
  const cardStore = tx.objectStore("card");
3459
2181
  return cardStore.get(entry.current_hash);
@@ -3832,92 +2554,6 @@ var TextValidator = class _TextValidator extends BaseValidator {
3832
2554
  }
3833
2555
  };
3834
2556
 
3835
- // src/model/detectors/BinarySignatureDetector.ts
3836
- var BinarySignatureDetector2 = class _BinarySignatureDetector {
3837
- // Dictionary of binary signatures mapped to MIME types
3838
- // Note: In TS, we use numbers or number arrays for bytes
3839
- static SIGNATURES = {
3840
- // Images
3841
- "89504e470d0a1a0a": "image/png",
3842
- // \x89PNG\r\n\x1a\n
3843
- "ffd8ff": "image/jpeg",
3844
- "474946383761": "image/gif",
3845
- // GIF87a
3846
- "474946383961": "image/gif",
3847
- // GIF89a
3848
- "424d": "image/bmp",
3849
- // BM
3850
- "00000100": "image/x-icon",
3851
- "00000200": "image/x-icon",
3852
- // MP4
3853
- "00000018667479706d703432": "video/mp4",
3854
- // ...ftypmp42
3855
- "000000186674797069736f6d": "video/mp4",
3856
- // ...ftypisom
3857
- // ... (simplified for key common ones)
3858
- // Documents
3859
- "25504446": "application/pdf",
3860
- // %PDF
3861
- // Archives
3862
- "504b0304": "application/zip",
3863
- // PK\x03\x04
3864
- "1f8b08": "application/gzip",
3865
- "526172211a0700": "application/x-rar-compressed",
3866
- // Rar!
3867
- "377abcaf271c": "application/x-7z-compressed",
3868
- // 7z...
3869
- // Database
3870
- "53514c69746520666f726d6174203300": "application/x-sqlite3"
3871
- // SQLite format 3\0
3872
- };
3873
- static OLE_SIGNATURE = "d0cf11e0a1b11ae1";
3874
- /**
3875
- * Helper to convert hex string to Uint8Array for easy comparison if needed,
3876
- * but we will convert input bytes to hex for lookup.
3877
- */
3878
- detect(content) {
3879
- return this.detectFromBytes(content);
3880
- }
3881
- detectFromBytes(content) {
3882
- if (this.startsWithAscii(content, "RIFF")) {
3883
- return this.detectRiffFormat(content);
3884
- }
3885
- const hexHeader = this.toHex(content.slice(0, 32));
3886
- for (const [signature, mimeType] of Object.entries(_BinarySignatureDetector.SIGNATURES)) {
3887
- if (hexHeader.startsWith(signature)) {
3888
- if (signature === _BinarySignatureDetector.OLE_SIGNATURE) {
3889
- return "application/oleobject";
3890
- }
3891
- if (signature === "504b0304") {
3892
- return "application/zip";
3893
- }
3894
- return mimeType;
3895
- }
3896
- }
3897
- return "application/octet-stream";
3898
- }
3899
- detectRiffFormat(content) {
3900
- if (content.length < 12) return "application/octet-stream";
3901
- const formatType = this.toAscii(content.slice(8, 12));
3902
- if (formatType === "WAVE") return "audio/wav";
3903
- if (formatType === "WEBP") return "image/webp";
3904
- return "application/octet-stream";
3905
- }
3906
- startsWithAscii(content, str) {
3907
- if (content.length < str.length) return false;
3908
- for (let i = 0; i < str.length; i++) {
3909
- if (content[i] !== str.charCodeAt(i)) return false;
3910
- }
3911
- return true;
3912
- }
3913
- toAscii(content) {
3914
- return Array.from(content).map((b) => String.fromCharCode(b)).join("");
3915
- }
3916
- toHex(content) {
3917
- return Array.from(content).map((b) => b.toString(16).padStart(2, "0")).join("");
3918
- }
3919
- };
3920
-
3921
2557
  // src/model/validators/BinaryValidator.ts
3922
2558
  var BinaryValidator = class _BinaryValidator extends BaseValidator {
3923
2559
  static BINARY_MIME_TYPES = /* @__PURE__ */ new Set([
@@ -3931,7 +2567,6 @@ var BinaryValidator = class _BinaryValidator extends BaseValidator {
3931
2567
  "audio/wav",
3932
2568
  "application/octet-stream"
3933
2569
  ]);
3934
- detector = new BinarySignatureDetector2();
3935
2570
  canValidate(mimeType) {
3936
2571
  return _BinaryValidator.BINARY_MIME_TYPES.has(mimeType) || mimeType.startsWith("image/") || mimeType.startsWith("audio/") || mimeType.startsWith("video/");
3937
2572
  }
@@ -3959,29 +2594,19 @@ var BinaryValidator = class _BinaryValidator extends BaseValidator {
3959
2594
  } else if (mimeType === "image/gif" && content.length <= 6) {
3960
2595
  throw new ValidationError("Invalid GIF content: truncated file");
3961
2596
  }
3962
- const signatures = BinarySignatureDetector2.SIGNATURES;
3963
- let expectedSig = null;
3964
- for (const [sig, mime] of Object.entries(signatures)) {
3965
- if (mime === mimeType) {
3966
- expectedSig = sig;
3967
- }
3968
- }
3969
- if (expectedSig) {
3970
- const contentHex = this.toHex(content.slice(0, expectedSig.length / 2));
3971
- if (contentHex !== expectedSig) {
3972
- let hasMatch = false;
3973
- for (const [sig, mime] of Object.entries(signatures)) {
3974
- if (mime === mimeType) {
3975
- const currentHex = this.toHex(content.slice(0, sig.length / 2));
3976
- if (currentHex === sig) {
3977
- hasMatch = true;
3978
- break;
3979
- }
3980
- }
3981
- }
3982
- if (!hasMatch) {
3983
- throw new ValidationError(`Invalid ${mimeType} content: missing proper header`);
3984
- }
2597
+ const signatures = {
2598
+ "image/png": "89504e470d0a1a0a",
2599
+ // \x89PNG\r\n\x1a\n
2600
+ "image/jpeg": "ffd8ff",
2601
+ // \xff\xd8\xff
2602
+ "image/gif": "47494638"
2603
+ // GIF8
2604
+ };
2605
+ if (signatures[mimeType]) {
2606
+ const expectedSig = signatures[mimeType];
2607
+ const currentHex = this.toHex(content.slice(0, expectedSig.length / 2));
2608
+ if (!currentHex.startsWith(expectedSig) && currentHex !== expectedSig) {
2609
+ throw new ValidationError(`Invalid ${mimeType} content: missing proper header`);
3985
2610
  }
3986
2611
  }
3987
2612
  }
@@ -4019,7 +2644,7 @@ var ValidationRegistry = class {
4019
2644
  }
4020
2645
  /**
4021
2646
  * Validate content using appropriate validator.
4022
- *
2647
+ *
4023
2648
  * @param content The content to validate
4024
2649
  * @param mimeType The detected MIME type
4025
2650
  * @throws ValidationError If content is invalid