@delali/narsil 0.3.1-next.98 → 0.4.0

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 (426) hide show
  1. package/NOTICE +45 -0
  2. package/README.md +27 -8
  3. package/dist/adapters/filesystem.d.ts +1 -1
  4. package/dist/adapters/filesystem.mjs +101 -13
  5. package/dist/adapters/gcs.d.ts +49 -0
  6. package/dist/adapters/gcs.mjs +213 -0
  7. package/dist/adapters/indexeddb.d.ts +1 -1
  8. package/dist/adapters/indexeddb.mjs +2 -7
  9. package/dist/adapters/memory.d.ts +1 -1
  10. package/dist/adapters/memory.mjs +5 -0
  11. package/dist/adapters/s3.d.ts +53 -0
  12. package/dist/adapters/s3.mjs +263 -0
  13. package/dist/{adapters-BQFQ4PRz.d.ts → adapters-pljAqmrC.d.ts} +33 -0
  14. package/dist/browser/chunk-4E5APHTM.mjs +1459 -0
  15. package/dist/browser/chunk-NDYADQ4Y.mjs +23426 -0
  16. package/dist/browser/chunk-QAOVAYAG.mjs +564 -0
  17. package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
  18. package/dist/browser/chunk-YINZFPLT.mjs +1239 -0
  19. package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
  20. package/dist/browser/{chunk-Z7QH2XHB.mjs → core-leaf-HWAXCEWX.mjs} +3987 -2103
  21. package/dist/browser/custom-token-results-R5BIX7SL.mjs +59 -0
  22. package/dist/browser/digest-leaf-64IPRPZD.mjs +151 -0
  23. package/dist/browser/durability-config-75NSFCQN.mjs +97 -0
  24. package/dist/browser/embed-GG6PS3EA.mjs +264 -0
  25. package/dist/browser/geo-index-GNHY4PUB.mjs +1484 -0
  26. package/dist/browser/gzip-JF3S6PPT.mjs +31 -0
  27. package/dist/browser/module-ZZTNG5JZ.mjs +5762 -0
  28. package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
  29. package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
  30. package/dist/browser/optional-writes-76DWMRQH.mjs +3603 -0
  31. package/dist/browser/phrase-module-6UGFVW5J.mjs +617 -0
  32. package/dist/browser/resolve-vector-text-XRR2OVHE.mjs +85 -0
  33. package/dist/browser/restore-queue-SG5O735W.mjs +196 -0
  34. package/dist/browser/{runtime-NYE5TB6O.mjs → runtime-OMKE7DF4.mjs} +83 -25
  35. package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
  36. package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
  37. package/dist/browser/storage-leaf-5UTR5K7J.mjs +19829 -0
  38. package/dist/browser/store-leaf-3L33V35P.mjs +2070 -0
  39. package/dist/browser/suggestions-leaf-UBNDVKBD.mjs +1430 -0
  40. package/dist/browser/worker-copies-JXSGYR5X.mjs +2951 -0
  41. package/dist/{capabilities-BTTIs96E.d.ts → capabilities-DMte5K9_.d.ts} +162 -18
  42. package/dist/chunk-2AFZE7Y3.mjs +72 -0
  43. package/dist/chunk-2CKDCC65.mjs +47 -0
  44. package/dist/chunk-3ECIRFS5.mjs +61 -0
  45. package/dist/chunk-44W3CBNG.mjs +7 -0
  46. package/dist/chunk-4H4RG2FR.mjs +13 -0
  47. package/dist/chunk-4PY4JYMY.mjs +11 -0
  48. package/dist/chunk-4ZPVAHWF.mjs +1289 -0
  49. package/dist/chunk-5EI5CXO6.mjs +197 -0
  50. package/dist/chunk-5F5MXWS5.mjs +283 -0
  51. package/dist/{chunk-OHP7QR33.mjs → chunk-5FLRXF73.mjs} +25 -4
  52. package/dist/chunk-6FOENO4E.mjs +273 -0
  53. package/dist/chunk-6GHX35ZM.mjs +108 -0
  54. package/dist/chunk-6MSZ543Y.mjs +32 -0
  55. package/dist/chunk-6N6HHBCQ.mjs +4596 -0
  56. package/dist/{chunk-LXPIXDUJ.mjs → chunk-7P5YWDRQ.mjs} +403 -169
  57. package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
  58. package/dist/{chunk-GGSH6KBQ.mjs → chunk-ASZLNVWW.mjs} +23 -3
  59. package/dist/chunk-AVBPB3MI.mjs +602 -0
  60. package/dist/{chunk-UCDF35PU.mjs → chunk-AVGUEEQ3.mjs} +494 -245
  61. package/dist/chunk-BUMREPLU.mjs +15 -0
  62. package/dist/chunk-BY6NALRK.mjs +31921 -0
  63. package/dist/chunk-C4ZMXXTL.mjs +92 -0
  64. package/dist/{chunk-2WYMG3OZ.mjs → chunk-C74KPRR7.mjs} +274 -19
  65. package/dist/{chunk-RSRVGAIQ.mjs → chunk-D456ZFPQ.mjs} +3 -2
  66. package/dist/chunk-DXZ6JDWG.mjs +797 -0
  67. package/dist/chunk-FJXJZUWF.mjs +209 -0
  68. package/dist/chunk-FS3HPPSC.mjs +212 -0
  69. package/dist/chunk-FT4KLZXW.mjs +1164 -0
  70. package/dist/chunk-GR5GMFJJ.mjs +104 -0
  71. package/dist/chunk-GXCDWLQI.mjs +193 -0
  72. package/dist/chunk-GXED6R3Q.mjs +271 -0
  73. package/dist/chunk-HLPRHOSO.mjs +17 -0
  74. package/dist/chunk-IL5DRCNU.mjs +3041 -0
  75. package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
  76. package/dist/chunk-K5HSUPYS.mjs +11 -0
  77. package/dist/chunk-KYIRXTCA.mjs +100 -0
  78. package/dist/chunk-LFXS6OF7.mjs +289 -0
  79. package/dist/chunk-LNGE7SLY.mjs +151 -0
  80. package/dist/chunk-M2Z5WVWW.mjs +194 -0
  81. package/dist/{chunk-45AVKHMJ.mjs → chunk-M3B7SGJB.mjs} +63 -50
  82. package/dist/chunk-M3OW2XSP.mjs +40 -0
  83. package/dist/chunk-MFPSQZ6P.mjs +127 -0
  84. package/dist/chunk-MRCJBWJZ.mjs +1292 -0
  85. package/dist/chunk-MSIN4NM3.mjs +25 -0
  86. package/dist/chunk-MW3CJVGP.mjs +219 -0
  87. package/dist/chunk-MYM6CAVK.mjs +76 -0
  88. package/dist/chunk-NJJN4FMM.mjs +84 -0
  89. package/dist/chunk-NM7I3BM7.mjs +59 -0
  90. package/dist/chunk-OIJ64LGT.mjs +19 -0
  91. package/dist/{chunk-K7D4ZTSW.mjs → chunk-P4F4UWLC.mjs} +1 -1
  92. package/dist/chunk-Q2AP2FSN.mjs +15 -0
  93. package/dist/chunk-R2PJKSNL.mjs +54 -0
  94. package/dist/{chunk-HXJBSHXF.mjs → chunk-R724DJSG.mjs} +5056 -2619
  95. package/dist/chunk-S2POFTLN.mjs +10 -0
  96. package/dist/chunk-S5QMWECL.mjs +7 -0
  97. package/dist/chunk-SLAC5PAB.mjs +5008 -0
  98. package/dist/chunk-T4HMSZCX.mjs +5 -0
  99. package/dist/chunk-TACP6VK6.mjs +111 -0
  100. package/dist/chunk-TGPKS2UM.mjs +125 -0
  101. package/dist/chunk-TKKXPKEO.mjs +979 -0
  102. package/dist/chunk-V6EUBAIT.mjs +19 -0
  103. package/dist/chunk-XL56L4IR.mjs +228 -0
  104. package/dist/chunk-XQIAMDAG.mjs +3076 -0
  105. package/dist/chunk-YTUZ4R22.mjs +1063 -0
  106. package/dist/{chunk-KV3AZFT3.mjs → chunk-ZKOQR7EA.mjs} +45 -1
  107. package/dist/chunk-ZPJFGGGI.mjs +638 -0
  108. package/dist/chunk-ZXX5GZEX.mjs +17 -0
  109. package/dist/{client-i9eLJrw5.d.ts → client-BKqtl0_V.d.ts} +442 -22
  110. package/dist/client.d.ts +11 -10
  111. package/dist/client.mjs +8 -898
  112. package/dist/config-Bnl7L-0H.d.ts +608 -0
  113. package/dist/{config-P__Diiy4.d.ts → config-CJ-jfI0a.d.ts} +119 -9
  114. package/dist/core-leaf-6JVHEVFB.mjs +8 -0
  115. package/dist/custom-token-results-NXHBVY7U.mjs +59 -0
  116. package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
  117. package/dist/direct-executor-V3WOYU2Y.mjs +17 -0
  118. package/dist/distribution/coordinator/etcd.d.ts +63 -7
  119. package/dist/distribution/coordinator/etcd.mjs +725 -81
  120. package/dist/distribution/coordinator/in-memory.d.ts +3 -3
  121. package/dist/distribution/coordinator/in-memory.mjs +65 -10
  122. package/dist/distribution/transport/grpc.d.ts +2 -2
  123. package/dist/distribution/transport/grpc.mjs +39 -10
  124. package/dist/distribution/transport/in-memory.d.ts +2 -2
  125. package/dist/distribution/transport/in-memory.mjs +9 -6
  126. package/dist/distribution/transport/tcp.d.ts +2 -2
  127. package/dist/distribution/transport/tcp.mjs +20 -15
  128. package/dist/distribution.d.ts +267 -56
  129. package/dist/distribution.mjs +23156 -11362
  130. package/dist/durability-config-VWS2K24E.mjs +96 -0
  131. package/dist/embed-4PHHKGBK.mjs +263 -0
  132. package/dist/embeddings/openai.d.ts +1 -1
  133. package/dist/embeddings/openai.mjs +2 -2
  134. package/dist/{memory-CUEDwr-F.d.ts → engine-qjAxJSKk.d.ts} +2254 -1123
  135. package/dist/geo-index-2ZMMWWSK.mjs +1484 -0
  136. package/dist/gzip-2UCZW2MM.mjs +31 -0
  137. package/dist/{index-lcdGLyJH.d.ts → index-B_vmxpgW.d.ts} +260 -102
  138. package/dist/index.browser.mjs +4 -4
  139. package/dist/index.d.ts +2133 -57
  140. package/dist/index.mjs +16 -32
  141. package/dist/index.react-native.mjs +12 -0
  142. package/dist/invalidation/broadcast-channel.d.ts +1 -1
  143. package/dist/invalidation/filesystem.d.ts +1 -1
  144. package/dist/invalidation/filesystem.mjs +1 -2
  145. package/dist/invalidation/noop.d.ts +1 -1
  146. package/dist/languages/albanian.mjs +1 -1
  147. package/dist/languages/amharic.mjs +1 -1
  148. package/dist/languages/arabic.mjs +1 -1
  149. package/dist/languages/armenian.mjs +1 -1
  150. package/dist/languages/azerbaijani.mjs +1 -1
  151. package/dist/languages/bambara.mjs +1 -1
  152. package/dist/languages/basque.mjs +1 -1
  153. package/dist/languages/belarusian.mjs +1 -1
  154. package/dist/languages/bengali.mjs +1 -1
  155. package/dist/languages/bosnian.mjs +1 -1
  156. package/dist/languages/breton.mjs +1 -1
  157. package/dist/languages/bulgarian.mjs +1 -1
  158. package/dist/languages/burmese.mjs +1 -1
  159. package/dist/languages/catalan.mjs +1 -1
  160. package/dist/languages/chinese.mjs +1 -1
  161. package/dist/languages/croatian.mjs +1 -1
  162. package/dist/languages/czech.mjs +1 -1
  163. package/dist/languages/dagbani.mjs +1 -1
  164. package/dist/languages/danish.mjs +1 -1
  165. package/dist/languages/dutch.mjs +1 -1
  166. package/dist/languages/english.mjs +1 -1
  167. package/dist/languages/esperanto.mjs +1 -1
  168. package/dist/languages/estonian.mjs +1 -1
  169. package/dist/languages/ewe.mjs +1 -1
  170. package/dist/languages/faroese.mjs +1 -1
  171. package/dist/languages/fijian.mjs +1 -1
  172. package/dist/languages/finnish.mjs +1 -1
  173. package/dist/languages/french.mjs +1 -1
  174. package/dist/languages/ga.mjs +1 -1
  175. package/dist/languages/galician.mjs +1 -1
  176. package/dist/languages/georgian.mjs +1 -1
  177. package/dist/languages/german.mjs +1 -1
  178. package/dist/languages/greek.mjs +1 -1
  179. package/dist/languages/guarani.mjs +1 -1
  180. package/dist/languages/gujarati.mjs +1 -1
  181. package/dist/languages/haitian-creole.mjs +1 -1
  182. package/dist/languages/hausa.mjs +1 -1
  183. package/dist/languages/hawaiian.mjs +1 -1
  184. package/dist/languages/hebrew.mjs +1 -1
  185. package/dist/languages/hindi.mjs +1 -1
  186. package/dist/languages/hungarian.mjs +1 -1
  187. package/dist/languages/icelandic.mjs +1 -1
  188. package/dist/languages/igbo.mjs +1 -1
  189. package/dist/languages/indonesian.mjs +1 -1
  190. package/dist/languages/irish.mjs +1 -1
  191. package/dist/languages/italian.mjs +1 -1
  192. package/dist/languages/japanese.mjs +1 -1
  193. package/dist/languages/kannada.mjs +1 -1
  194. package/dist/languages/kazakh.mjs +1 -1
  195. package/dist/languages/khmer.mjs +1 -1
  196. package/dist/languages/kinyarwanda.mjs +1 -1
  197. package/dist/languages/kirundi.mjs +1 -1
  198. package/dist/languages/korean.mjs +1 -1
  199. package/dist/languages/kurmanji.mjs +1 -1
  200. package/dist/languages/kyrgyz.mjs +1 -1
  201. package/dist/languages/lao.mjs +1 -1
  202. package/dist/languages/latin.mjs +1 -1
  203. package/dist/languages/latvian.mjs +1 -1
  204. package/dist/languages/lingala.mjs +1 -1
  205. package/dist/languages/lithuanian.mjs +1 -1
  206. package/dist/languages/luxembourgish.mjs +1 -1
  207. package/dist/languages/macedonian.mjs +1 -1
  208. package/dist/languages/malagasy.mjs +1 -1
  209. package/dist/languages/malay.mjs +1 -1
  210. package/dist/languages/malayalam.mjs +1 -1
  211. package/dist/languages/maltese.mjs +1 -1
  212. package/dist/languages/maori.mjs +1 -1
  213. package/dist/languages/marathi.mjs +1 -1
  214. package/dist/languages/nepali.mjs +1 -1
  215. package/dist/languages/norwegian.mjs +1 -1
  216. package/dist/languages/oromo.mjs +1 -1
  217. package/dist/languages/persian.mjs +1 -1
  218. package/dist/languages/polish.mjs +1 -1
  219. package/dist/languages/portuguese.mjs +1 -1
  220. package/dist/languages/punjabi.mjs +1 -1
  221. package/dist/languages/romanian.mjs +1 -1
  222. package/dist/languages/russian.mjs +1 -1
  223. package/dist/languages/samoan.mjs +1 -1
  224. package/dist/languages/sanskrit.mjs +1 -1
  225. package/dist/languages/scottish-gaelic.mjs +1 -1
  226. package/dist/languages/serbian.mjs +1 -1
  227. package/dist/languages/shona.mjs +1 -1
  228. package/dist/languages/sinhala.mjs +1 -1
  229. package/dist/languages/slovak.mjs +1 -1
  230. package/dist/languages/slovenian.mjs +1 -1
  231. package/dist/languages/sorani.mjs +1 -1
  232. package/dist/languages/spanish.mjs +1 -1
  233. package/dist/languages/swahili.mjs +1 -1
  234. package/dist/languages/swedish.mjs +1 -1
  235. package/dist/languages/tagalog.mjs +1 -1
  236. package/dist/languages/tamil.mjs +1 -1
  237. package/dist/languages/tatar.mjs +1 -1
  238. package/dist/languages/telugu.mjs +1 -1
  239. package/dist/languages/thai.mjs +1 -1
  240. package/dist/languages/tibetan.mjs +1 -1
  241. package/dist/languages/tigrinya.mjs +1 -1
  242. package/dist/languages/tongan.mjs +1 -1
  243. package/dist/languages/turkish.mjs +1 -1
  244. package/dist/languages/twi.mjs +1 -1
  245. package/dist/languages/ukrainian.mjs +1 -1
  246. package/dist/languages/urdu.mjs +1 -1
  247. package/dist/languages/vietnamese.mjs +1 -1
  248. package/dist/languages/welsh.mjs +1 -1
  249. package/dist/languages/wolof.mjs +1 -1
  250. package/dist/languages/xhosa.mjs +1 -1
  251. package/dist/languages/yoruba.mjs +1 -1
  252. package/dist/languages/zulu.mjs +1 -1
  253. package/dist/long-query-thread-UCRK7MSI.mjs +154 -0
  254. package/dist/module-5ZSLUQII.mjs +3729 -0
  255. package/dist/msgpack-leaf-H5ZYW7S7.mjs +9 -0
  256. package/dist/optional-reads-5HFMF2QZ.mjs +3373 -0
  257. package/dist/optional-writes-4UOQKETU.mjs +247 -0
  258. package/dist/paged-partition-archive-BBRLZCIF.mjs +253 -0
  259. package/dist/partial-words.browser.mjs +1650 -0
  260. package/dist/partial-words.mjs +17 -11
  261. package/dist/{chunk-ASY5PHYI.mjs → pattern.browser.mjs} +253 -311
  262. package/dist/pattern.mjs +6 -7
  263. package/dist/persistence/durability/checkpoint-worker.d.ts +93 -25
  264. package/dist/persistence/durability/checkpoint-worker.mjs +51 -41
  265. package/dist/phrase-module-EFESWOCR.mjs +635 -0
  266. package/dist/query-actions-HMJUVWGT.mjs +119 -0
  267. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  268. package/dist/query-suggestions/merge-worker.mjs +53 -0
  269. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  270. package/dist/query-suggestions.browser.mjs +47 -0
  271. package/dist/query-suggestions.d.ts +20 -0
  272. package/dist/query-suggestions.mjs +19 -0
  273. package/dist/react-native/chunks/chunk-3OEFSHVV.mjs +970 -0
  274. package/dist/{browser/chunk-RELZRJNR.mjs → react-native/chunks/chunk-43R4GCM7.mjs} +49 -50
  275. package/dist/react-native/chunks/chunk-AKRYHAVG.mjs +6729 -0
  276. package/dist/react-native/chunks/chunk-CW2ZFXSE.mjs +14 -0
  277. package/dist/react-native/chunks/chunk-G3WCDTOF.mjs +29640 -0
  278. package/dist/react-native/chunks/chunk-GXXHHA2T.mjs +212 -0
  279. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  280. package/dist/react-native/chunks/chunk-HQEVQEDJ.mjs +52 -0
  281. package/dist/react-native/chunks/chunk-HRDMIQ63.mjs +131 -0
  282. package/dist/react-native/chunks/chunk-HTBY4GON.mjs +565 -0
  283. package/dist/react-native/chunks/chunk-LX62Y4B5.mjs +61 -0
  284. package/dist/react-native/chunks/chunk-MRH36RN3.mjs +902 -0
  285. package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
  286. package/dist/react-native/chunks/chunk-UE4ANHSX.mjs +127 -0
  287. package/dist/react-native/chunks/chunk-UNZPWLVL.mjs +1063 -0
  288. package/dist/react-native/chunks/chunk-UO44MA5M.mjs +232 -0
  289. package/dist/react-native/chunks/chunk-UYKIV2KT.mjs +42 -0
  290. package/dist/react-native/chunks/chunk-VUJCSQG5.mjs +11 -0
  291. package/dist/react-native/chunks/chunk-WVHF4ZAK.mjs +802 -0
  292. package/dist/react-native/chunks/chunk-ZUJCUPVS.mjs +54 -0
  293. package/dist/react-native/chunks/core-leaf-S2KNBWDY.mjs +7 -0
  294. package/dist/react-native/chunks/custom-token-results-3OZEMRE7.mjs +59 -0
  295. package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
  296. package/dist/react-native/chunks/durability-config-FCSD4MXY.mjs +96 -0
  297. package/dist/react-native/chunks/embed-HA2I7RCF.mjs +263 -0
  298. package/dist/react-native/chunks/geo-index-QEYKEVPH.mjs +1484 -0
  299. package/dist/react-native/chunks/gzip.react-native-CVM4NQG2.mjs +12 -0
  300. package/dist/react-native/chunks/module-FMBX75GP.mjs +5209 -0
  301. package/dist/react-native/chunks/msgpack-leaf-JMNGSTRW.mjs +7 -0
  302. package/dist/react-native/chunks/optional-reads-AFPO2FEB.mjs +3364 -0
  303. package/dist/react-native/chunks/optional-writes-XOH25XZI.mjs +296 -0
  304. package/dist/react-native/chunks/phrase-module-IGYBK7XH.mjs +636 -0
  305. package/dist/react-native/chunks/replace-IMZUVUOE.mjs +57 -0
  306. package/dist/react-native/chunks/resolve-vector-text-GE2CRJKI.mjs +84 -0
  307. package/dist/react-native/chunks/restore-queue-LLNMYB4Z.mjs +187 -0
  308. package/dist/react-native/chunks/runtime-UOHD2XUJ.mjs +615 -0
  309. package/dist/react-native/chunks/segment-codec-leaf-VR6O5GLC.mjs +13 -0
  310. package/dist/react-native/chunks/segment-merge-leaf-LLMWU4EW.mjs +14 -0
  311. package/dist/react-native/chunks/storage-leaf-JD7PIDO4.mjs +19633 -0
  312. package/dist/react-native/chunks/store-leaf-4UVCMYGN.mjs +15 -0
  313. package/dist/react-native/chunks/suggestions-leaf-J5VT5RHY.mjs +1321 -0
  314. package/dist/react-native/chunks/worker-copies-ZYHY7FKJ.mjs +2831 -0
  315. package/dist/react-native/partial-words.mjs +1658 -0
  316. package/dist/react-native/pattern.mjs +2570 -0
  317. package/dist/react-native/query-suggestions.mjs +55 -0
  318. package/dist/react-native/sync.mjs +2759 -0
  319. package/dist/react-native/synonyms.mjs +676 -0
  320. package/dist/react.d.ts +12 -8
  321. package/dist/react.mjs +45 -1
  322. package/dist/{rerank-NWTKK636.mjs → rerank-RI2PMNOD.mjs} +22 -12
  323. package/dist/rerankers/http.d.ts +1 -1
  324. package/dist/rerankers/http.mjs +2 -2
  325. package/dist/resolve-vector-text-OD4J3WHF.mjs +3 -0
  326. package/dist/restore-queue-PCKWDAKQ.mjs +192 -0
  327. package/dist/runtime-USQYKN3I.mjs +615 -0
  328. package/dist/{schema-4W_7tk1f.d.ts → schema-CzG9OUw5.d.ts} +70 -30
  329. package/dist/segment-codec-leaf-QJM7I6QG.mjs +18 -0
  330. package/dist/segment-merge-leaf-4BJGIJHY.mjs +18 -0
  331. package/dist/server.d.ts +348 -22
  332. package/dist/server.mjs +2211 -327
  333. package/dist/storage-leaf-GRRRI7UV.mjs +5962 -0
  334. package/dist/store-leaf-6VMMSVBE.mjs +20 -0
  335. package/dist/stored-values-BWIMpiT_.d.ts +25 -0
  336. package/dist/suggestions-leaf-4KPTMPTL.mjs +54 -0
  337. package/dist/sync/filesystem.d.ts +30 -0
  338. package/dist/sync/filesystem.mjs +288 -0
  339. package/dist/sync/indexeddb.browser.mjs +287 -0
  340. package/dist/sync/indexeddb.d.ts +30 -0
  341. package/dist/sync/indexeddb.mjs +242 -0
  342. package/dist/sync.browser.mjs +1271 -0
  343. package/dist/sync.d.ts +23 -0
  344. package/dist/sync.mjs +2712 -0
  345. package/dist/synonyms.browser.mjs +658 -0
  346. package/dist/synonyms.mjs +17 -7
  347. package/dist/tasks-65b6t6lk.d.ts +782 -0
  348. package/dist/thread-UJ3W5LVI.mjs +31 -0
  349. package/dist/{types-B3b68nfF.d.ts → types-Ck97nB3D.d.ts} +1 -1
  350. package/dist/types-CpCg-Gq-.d.ts +227 -0
  351. package/dist/{types-Cb9kiY5P.d.ts → types-DvncmvuQ.d.ts} +12 -1
  352. package/dist/vector/search-worker.d.ts +10 -2
  353. package/dist/vector/search-worker.mjs +11 -11
  354. package/dist/worker-copies-YSXZXIGC.mjs +2232 -0
  355. package/dist/workers/entry.mjs +75 -15
  356. package/openapi.json +6840 -0
  357. package/package.json +406 -19
  358. package/dist/browser/chunk-CN4I4FZU.mjs +0 -602
  359. package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
  360. package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
  361. package/dist/browser/chunk-LD55ZGU3.mjs +0 -347
  362. package/dist/browser/chunk-NAFT3K6X.mjs +0 -24546
  363. package/dist/browser/chunk-NNG3EEB6.mjs +0 -2728
  364. package/dist/browser/chunk-QWES44AW.mjs +0 -473
  365. package/dist/browser/durability-wiring-PY3L7DES.mjs +0 -3679
  366. package/dist/browser/module-PDXYHT75.mjs +0 -2822
  367. package/dist/browser/release-76MXRPGV.mjs +0 -33
  368. package/dist/browser/restore-queue-DVIYJ7RU.mjs +0 -35
  369. package/dist/browser/snapshot-J57MZK6L.mjs +0 -1207
  370. package/dist/browser/write-L7FAQA47.mjs +0 -208
  371. package/dist/chunk-37CD3OKS.mjs +0 -87
  372. package/dist/chunk-5XNIRLFC.mjs +0 -96
  373. package/dist/chunk-7X5JST5L.mjs +0 -114
  374. package/dist/chunk-AV4IJKD2.mjs +0 -35
  375. package/dist/chunk-AY3AQ3UH.mjs +0 -73
  376. package/dist/chunk-BKB3XTMI.mjs +0 -707
  377. package/dist/chunk-C7SLA6CM.mjs +0 -19
  378. package/dist/chunk-COVCQ73F.mjs +0 -587
  379. package/dist/chunk-DJHHF2L5.mjs +0 -17
  380. package/dist/chunk-E74YLAIG.mjs +0 -24
  381. package/dist/chunk-FMWRCP2C.mjs +0 -57
  382. package/dist/chunk-GES7U2PM.mjs +0 -68
  383. package/dist/chunk-HJSN7UYG.mjs +0 -10
  384. package/dist/chunk-JFRNNBOM.mjs +0 -35
  385. package/dist/chunk-K25LZA54.mjs +0 -8484
  386. package/dist/chunk-KEHK2O6P.mjs +0 -13
  387. package/dist/chunk-KOKM4PQN.mjs +0 -52
  388. package/dist/chunk-KZ3NX2P7.mjs +0 -21
  389. package/dist/chunk-L3L5YFXC.mjs +0 -614
  390. package/dist/chunk-L5ORED7V.mjs +0 -25
  391. package/dist/chunk-LH4NZNJJ.mjs +0 -1731
  392. package/dist/chunk-LU2CE5AE.mjs +0 -507
  393. package/dist/chunk-LXWDQLTW.mjs +0 -30
  394. package/dist/chunk-MHOSCQCQ.mjs +0 -948
  395. package/dist/chunk-NKRBEGJZ.mjs +0 -1705
  396. package/dist/chunk-NTRMFARG.mjs +0 -462
  397. package/dist/chunk-NW4XDSP2.mjs +0 -212
  398. package/dist/chunk-OOEXLUGR.mjs +0 -117
  399. package/dist/chunk-ORBLD3EL.mjs +0 -6
  400. package/dist/chunk-OWNZYMRE.mjs +0 -3591
  401. package/dist/chunk-PPY2GSIB.mjs +0 -44
  402. package/dist/chunk-QY7GC2MW.mjs +0 -33
  403. package/dist/chunk-R6A773WK.mjs +0 -226
  404. package/dist/chunk-R6PR4WYZ.mjs +0 -68
  405. package/dist/chunk-R7EEKAJE.mjs +0 -593
  406. package/dist/chunk-RONEOEON.mjs +0 -426
  407. package/dist/chunk-VWULPWRJ.mjs +0 -7469
  408. package/dist/chunk-WCJKUGHB.mjs +0 -262
  409. package/dist/chunk-WQBCBKY3.mjs +0 -8
  410. package/dist/chunk-X5CV2E2B.mjs +0 -1
  411. package/dist/chunk-YA7XLE2R.mjs +0 -1256
  412. package/dist/chunk-YTJCGKM4.mjs +0 -56
  413. package/dist/chunk-ZG477IPV.mjs +0 -526
  414. package/dist/chunk-ZYNAMIYX.mjs +0 -113
  415. package/dist/config-BGB_fDtq.d.ts +0 -237
  416. package/dist/direct-executor-CXZ66ACP.mjs +0 -22
  417. package/dist/durability-wiring-QTHOGFMZ.mjs +0 -3229
  418. package/dist/engine-BGCEm9E_.d.ts +0 -577
  419. package/dist/module-3NONKBZX.mjs +0 -1860
  420. package/dist/release-BH3DKW3T.mjs +0 -33
  421. package/dist/restore-queue-JPRBUYII.mjs +0 -35
  422. package/dist/runtime-ZKYZFJJC.mjs +0 -177
  423. package/dist/snapshot-HOGXNO5W.mjs +0 -793
  424. package/dist/tasks-HG3rlxx6.d.ts +0 -302
  425. package/dist/thread-B657LQXK.mjs +0 -692
  426. package/dist/write-XLIGTXBU.mjs +0 -238
@@ -1,56 +0,0 @@
1
- // src/core/ordering/code-points.ts
2
- function exceedsCodePoints(value, maximum) {
3
- if (value.length <= maximum) return false;
4
- let counted = 0;
5
- let i = 0;
6
- while (i < value.length) {
7
- const unit = value.charCodeAt(i);
8
- if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
9
- const low = value.charCodeAt(i + 1);
10
- if (low >= 56320 && low < 57344) i++;
11
- }
12
- i++;
13
- counted++;
14
- if (counted > maximum) return true;
15
- }
16
- return false;
17
- }
18
- var SURROGATE_UNIT = /[\ud800-\udfff]/;
19
- function holdsUnpairedSurrogate(value) {
20
- if (!SURROGATE_UNIT.test(value)) return false;
21
- for (let i = 0; i < value.length; i++) {
22
- const unit = value.charCodeAt(i);
23
- if (unit < 55296 || unit >= 57344) continue;
24
- if (unit >= 56320) return true;
25
- const low = value.charCodeAt(i + 1);
26
- if (!(low >= 56320 && low < 57344)) return true;
27
- i++;
28
- }
29
- return false;
30
- }
31
- function codePointCount(value) {
32
- let counted = 0;
33
- for (let i = 0; i < value.length; i++) {
34
- const unit = value.charCodeAt(i);
35
- if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
36
- const low = value.charCodeAt(i + 1);
37
- if (low >= 56320 && low < 57344) i++;
38
- }
39
- counted++;
40
- }
41
- return counted;
42
- }
43
- function adjustUtf16Unit(unit) {
44
- if (unit < 55296) return unit;
45
- if (unit < 57344) return unit + 8192;
46
- return unit - 2048;
47
- }
48
- function compareCodePoints(a, b) {
49
- const shorter = a.length < b.length ? a.length : b.length;
50
- let i = 0;
51
- while (i < shorter && a.charCodeAt(i) === b.charCodeAt(i)) i++;
52
- if (i === shorter) return a.length - b.length;
53
- return adjustUtf16Unit(a.charCodeAt(i)) - adjustUtf16Unit(b.charCodeAt(i));
54
- }
55
-
56
- export { codePointCount, compareCodePoints, exceedsCodePoints, holdsUnpairedSurrogate };
@@ -1,526 +0,0 @@
1
- import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead, VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-WCJKUGHB.mjs';
2
- import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, readSegmentFile, readListedFile, requireListedChecksum, vectorFileKey, graphPartKey } from './chunk-LH4NZNJJ.mjs';
3
- import { VERSION, rulesOfStoredSynonyms, openChecksummedEnvelope, HEADER_SIZE, packChecksummedEnvelope } from './chunk-VWULPWRJ.mjs';
4
- import { MAX_FILE_BYTES } from './chunk-AY3AQ3UH.mjs';
5
- import { decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays } from './chunk-OWNZYMRE.mjs';
6
- import { flattenSchema, requireValidFieldTypes } from './chunk-LXPIXDUJ.mjs';
7
- import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
8
- import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
9
- import { decode, encode } from '@msgpack/msgpack';
10
-
11
- // src/engine/durability-metadata.ts
12
- function metadataFromConfig(indexName, config, partitionCount, documentCount) {
13
- const metadata = {
14
- indexName,
15
- schema: config.schema,
16
- language: config.language,
17
- partitionCount: partitionCount ?? config.partitionCount,
18
- bm25Params: { k1: config.k1, b: config.b },
19
- createdAt: Date.now(),
20
- engineVersion: VERSION
21
- };
22
- metadata.documentCount = documentCount ?? config.documentCount;
23
- if (config.embedding) {
24
- metadata.embedding = config.embedding;
25
- }
26
- if (config.surfaceForms !== void 0) {
27
- metadata.surfaceForms = config.surfaceForms;
28
- }
29
- if (config.analysisRevision !== void 0) {
30
- metadata.analysisRevision = config.analysisRevision;
31
- }
32
- if (config.tokenizer !== void 0) {
33
- metadata.tokenizer = config.tokenizer;
34
- }
35
- if (config.stopWords !== void 0) {
36
- metadata.stopWords = config.stopWords;
37
- }
38
- if (config.stopWordList !== void 0) {
39
- metadata.stopWordList = config.stopWordList;
40
- }
41
- if (config.partitionLimits !== void 0) {
42
- metadata.partitionLimits = config.partitionLimits;
43
- }
44
- if (config.defaultScoring !== void 0) {
45
- metadata.defaultScoring = config.defaultScoring;
46
- }
47
- if (config.trackPositions !== void 0) {
48
- metadata.trackPositions = config.trackPositions;
49
- }
50
- if (config.strict !== void 0) {
51
- metadata.strict = config.strict;
52
- }
53
- if (config.required !== void 0) {
54
- metadata.required = config.required;
55
- }
56
- if (config.vectorPromotion !== void 0) {
57
- metadata.vectorPromotion = config.vectorPromotion;
58
- }
59
- if (config.patternValueLimit !== void 0) {
60
- metadata.patternValueLimit = config.patternValueLimit;
61
- }
62
- if (config.indexUuid !== void 0) {
63
- metadata.indexUuid = config.indexUuid;
64
- }
65
- if (config.synonyms !== void 0) {
66
- metadata.synonyms = config.synonyms;
67
- }
68
- if (config.heldPartitions !== void 0) {
69
- metadata.heldPartitions = config.heldPartitions;
70
- }
71
- return metadata;
72
- }
73
- function metadataConfigOf(entry) {
74
- const embedding = entry.config.embedding ? {
75
- fields: entry.config.embedding.fields,
76
- ...entry.embeddingAdapterName !== null ? { adapter: entry.embeddingAdapterName } : {}
77
- } : void 0;
78
- return {
79
- ...entry.indexUuid !== null ? { indexUuid: entry.indexUuid } : {},
80
- ...entry.heldPartitions !== null ? { heldPartitions: entry.heldPartitions } : {},
81
- documentCount: entry.documentCount,
82
- partitionCount: entry.partitionCount,
83
- schema: flattenSchema(entry.config.schema),
84
- language: entry.language.name,
85
- k1: entry.config.bm25?.k1 ?? 1.2,
86
- b: entry.config.bm25?.b ?? 0.75,
87
- ...embedding !== void 0 ? { embedding } : {},
88
- surfaceForms: entry.config.surfaceForms !== false,
89
- ...entry.analysisRevision !== null ? { analysisRevision: entry.analysisRevision } : {},
90
- ...typeof entry.config.tokenizer === "string" ? { tokenizer: entry.config.tokenizer } : {},
91
- ...typeof entry.config.stopWords === "string" ? { stopWords: entry.config.stopWords } : {},
92
- ...entry.config.stopWords instanceof Set ? { stopWordList: [...entry.config.stopWords].sort(compareCodePoints) } : {},
93
- ...entry.config.partitions !== void 0 ? { partitionLimits: entry.config.partitions } : {},
94
- ...entry.config.defaultScoring !== void 0 ? { defaultScoring: entry.config.defaultScoring } : {},
95
- ...entry.config.trackPositions !== void 0 ? { trackPositions: entry.config.trackPositions } : {},
96
- ...entry.config.strict !== void 0 ? { strict: entry.config.strict } : {},
97
- ...entry.config.required !== void 0 ? { required: entry.config.required } : {},
98
- ...entry.config.vectorPromotion !== void 0 ? { vectorPromotion: entry.config.vectorPromotion } : {},
99
- ...entry.config.patternValueLimit !== void 0 ? { patternValueLimit: entry.config.patternValueLimit } : {},
100
- ...entry.synonyms !== null ? { synonyms: rulesOfStoredSynonyms(entry.synonyms) } : {}
101
- };
102
- }
103
- function indexMetadataOf(indexName, entry, partitionCount) {
104
- return metadataFromConfig(indexName, metadataConfigOf(entry), partitionCount);
105
- }
106
-
107
- // src/persistence/durability/segment/manifest-fields.ts
108
- function invalidManifest(message, details) {
109
- throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, `Segment manifest ${message}`, details);
110
- }
111
- function isRecord(value) {
112
- return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Uint8Array);
113
- }
114
- function isId(value) {
115
- return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= MAX_SEGMENT_ID;
116
- }
117
- function isUint32(value) {
118
- return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 4294967295;
119
- }
120
- function isSequenceNumber(value) {
121
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
122
- }
123
- function readFileRef(raw, expectedKey, what) {
124
- if (raw.key !== expectedKey) {
125
- invalidManifest(`lists the ${what} under the key "${String(raw.key)}" where it belongs at "${expectedKey}"`, {
126
- key: raw.key,
127
- expected: expectedKey
128
- });
129
- }
130
- const bytes = raw.bytes;
131
- if (typeof bytes !== "number" || !Number.isInteger(bytes) || bytes < HEADER_SIZE || bytes > MAX_FILE_BYTES) {
132
- invalidManifest(`gives the ${what} "${expectedKey}" an invalid length`, { key: expectedKey, bytes });
133
- }
134
- if (!isUint32(raw.checksum)) invalidManifest(`gives the ${what} "${expectedKey}" an invalid checksum`);
135
- return { key: expectedKey, bytes, checksum: raw.checksum };
136
- }
137
-
138
- // src/persistence/durability/segment/manifest-vectors-decode.ts
139
- function normalizeFile(raw, indexName, fieldPath, nextFileId, seenIds) {
140
- if (!isRecord(raw) || !isId(raw.id)) invalidManifest("has an invalid vector file reference", { fieldPath });
141
- if (raw.id >= nextFileId || seenIds.has(raw.id)) {
142
- invalidManifest(`lists vector file ${raw.id} of "${fieldPath}" twice or at its next file id`, { fieldPath });
143
- }
144
- seenIds.add(raw.id);
145
- const count = raw.count;
146
- if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > VECTOR_FILE_MAX_VECTORS) {
147
- invalidManifest(`gives vector file ${raw.id} of "${fieldPath}" an invalid count`, { fieldPath, count });
148
- }
149
- const dead = raw.dead ?? null;
150
- if (dead !== null && !(dead instanceof Uint8Array)) invalidManifest("has dead vectors that are not bytes");
151
- if (dead !== null && dead.byteLength !== deadBytesFor(count)) {
152
- invalidManifest(`marks the dead vectors of file ${raw.id} of "${fieldPath}" with the wrong number of bytes`);
153
- }
154
- const ref = readFileRef(raw, vectorFileKey(indexName, fieldPath, raw.id), "vector file");
155
- return { ...ref, id: raw.id, count, dead };
156
- }
157
- function normalizeGraphParts(raw, indexName, fieldPath, generation) {
158
- if (!Array.isArray(raw)) invalidManifest(`gives "${fieldPath}" no list of graph parts`, { fieldPath });
159
- if (raw.length > 0 && generation === 0) invalidManifest(`lists graph parts of "${fieldPath}" at generation 0`);
160
- return raw.map((part, at) => {
161
- if (!isRecord(part)) invalidManifest(`has an invalid graph part of "${fieldPath}"`, { fieldPath });
162
- return readFileRef(part, graphPartKey(indexName, fieldPath, generation, at), "graph part");
163
- });
164
- }
165
- function normalizeField(raw, indexName, seenFields) {
166
- if (!isRecord(raw) || typeof raw.fieldPath !== "string") invalidManifest("has an invalid vector reference");
167
- const fieldPath = raw.fieldPath;
168
- if (seenFields.has(fieldPath)) invalidManifest(`lists the vector field "${fieldPath}" twice`, { fieldPath });
169
- seenFields.add(fieldPath);
170
- if (!isId(raw.nextFileId)) invalidManifest(`gives "${fieldPath}" an invalid next file id`, { fieldPath });
171
- if (!Array.isArray(raw.files)) invalidManifest(`gives "${fieldPath}" no list of vector files`, { fieldPath });
172
- if (!isId(raw.graphGeneration)) invalidManifest(`gives "${fieldPath}" an invalid graph generation`, { fieldPath });
173
- const nextFileId = raw.nextFileId;
174
- const seenIds = /* @__PURE__ */ new Set();
175
- return {
176
- fieldPath,
177
- nextFileId,
178
- files: raw.files.map((file) => normalizeFile(file, indexName, fieldPath, nextFileId, seenIds)),
179
- graphGeneration: raw.graphGeneration,
180
- graphParts: normalizeGraphParts(raw.graphParts, indexName, fieldPath, raw.graphGeneration)
181
- };
182
- }
183
- function normalizeVectorFields(raw, indexName) {
184
- if (!Array.isArray(raw)) invalidManifest("has malformed vector references");
185
- const seenFields = /* @__PURE__ */ new Set();
186
- return raw.map((field) => normalizeField(field, indexName, seenFields));
187
- }
188
-
189
- // src/persistence/durability/segment/manifest-decode.ts
190
- async function openManifestPayload(data) {
191
- const { payload } = await openChecksummedEnvelope(data, {
192
- envelopeFormatVersion: MANIFEST_ENVELOPE_VERSION,
193
- what: "segment manifest",
194
- allowsCompression: true
195
- });
196
- const raw = decode(payload);
197
- if (!isRecord(raw)) invalidManifest("is not a map");
198
- return raw;
199
- }
200
- function listedKeysOf(raw) {
201
- const keys = [];
202
- for (const partition of Array.isArray(raw.partitions) ? raw.partitions : []) {
203
- if (!isRecord(partition) || !Array.isArray(partition.segments)) continue;
204
- for (const segment of partition.segments)
205
- if (isRecord(segment) && typeof segment.key === "string") keys.push(segment.key);
206
- }
207
- for (const field of Array.isArray(raw.vectors) ? raw.vectors : []) {
208
- if (!isRecord(field)) continue;
209
- for (const list of [field.files, field.graphParts]) {
210
- if (!Array.isArray(list)) continue;
211
- for (const file of list) if (isRecord(file) && typeof file.key === "string") keys.push(file.key);
212
- }
213
- }
214
- return keys;
215
- }
216
- async function decodeSegmentManifest(data, indexName) {
217
- return decodeManifestPayload(await openManifestPayload(data), indexName);
218
- }
219
- function decodeManifestPayload(raw, indexName) {
220
- if (raw.version === EARLIER_SEGMENT_MANIFEST_VERSION) return { kind: "earlier", payload: raw };
221
- if (raw.version !== SEGMENT_MANIFEST_VERSION) {
222
- throw new NarsilError(
223
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
224
- `The segment manifest of index "${indexName}" holds layout ${String(raw.version)}, which this release cannot open. Export the index with the release that wrote it and import the export`,
225
- { indexName, version: raw.version }
226
- );
227
- }
228
- const schema = raw.schema;
229
- if (!isRecord(schema)) invalidManifest("is missing its schema");
230
- requireValidFieldTypes(schema);
231
- if (typeof raw.language !== "string") invalidManifest("is missing its language");
232
- return {
233
- kind: "current",
234
- manifest: {
235
- version: SEGMENT_MANIFEST_VERSION,
236
- schema,
237
- language: raw.language,
238
- checkpoint: normalizeCheckpoint(raw.checkpoint),
239
- partitions: normalizePartitions(raw.partitions, indexName),
240
- vectors: normalizeVectorFields(raw.vectors, indexName)
241
- }
242
- };
243
- }
244
- function normalizeCheckpoint(raw) {
245
- if (!Array.isArray(raw)) invalidManifest("is missing its checkpoint list");
246
- const seen = /* @__PURE__ */ new Set();
247
- return raw.map((entry) => {
248
- if (!isRecord(entry) || !isUint32(entry.partitionId) || !isSequenceNumber(entry.lastSeqNo) || !isSequenceNumber(entry.primaryTerm) || seen.has(entry.partitionId)) {
249
- invalidManifest("has an invalid partition checkpoint", { entry });
250
- }
251
- seen.add(entry.partitionId);
252
- return { partitionId: entry.partitionId, lastSeqNo: entry.lastSeqNo, primaryTerm: entry.primaryTerm };
253
- });
254
- }
255
- function normalizePartitions(raw, indexName) {
256
- if (!Array.isArray(raw)) invalidManifest("is missing partition entries");
257
- const seen = /* @__PURE__ */ new Set();
258
- return raw.map((entry) => {
259
- if (!isRecord(entry) || !isUint32(entry.partitionId) || seen.has(entry.partitionId)) {
260
- invalidManifest("has a partition without a valid id", { partitionId: isRecord(entry) ? entry.partitionId : null });
261
- }
262
- seen.add(entry.partitionId);
263
- const segments = normalizeSegments(entry.segments, indexName, entry.partitionId);
264
- return {
265
- partitionId: entry.partitionId,
266
- nextSegmentId: readNextSegmentId(entry.nextSegmentId, segments, entry.partitionId),
267
- segments
268
- };
269
- });
270
- }
271
- function normalizeSegments(raw, indexName, partitionId) {
272
- if (!Array.isArray(raw)) invalidManifest("has malformed segment references", { partitionId });
273
- if (raw.length > MAX_SEGMENTS_PER_PARTITION) {
274
- invalidManifest(`lists ${raw.length} segments for partition ${partitionId}, above ${MAX_SEGMENTS_PER_PARTITION}`);
275
- }
276
- const seenIds = /* @__PURE__ */ new Set();
277
- return raw.map((segment) => {
278
- if (!isRecord(segment) || !isId(segment.id) || !isUint32(segment.docCount) || !isUint32(segment.tombstoneCount)) {
279
- invalidManifest("has an invalid segment reference", { partitionId });
280
- }
281
- if (seenIds.has(segment.id)) invalidManifest(`reuses segment id ${segment.id} in partition ${partitionId}`);
282
- seenIds.add(segment.id);
283
- const ref = readFileRef(segment, segmentKey(indexName, partitionId, segment.id), "segment");
284
- return { ...ref, id: segment.id, docCount: segment.docCount, tombstoneCount: segment.tombstoneCount };
285
- });
286
- }
287
- function readNextSegmentId(value, segments, partitionId) {
288
- if (!isId(value)) invalidManifest("has an invalid next segment id", { partitionId });
289
- for (const segment of segments) {
290
- if (segment.id >= value) {
291
- invalidManifest(`next segment id ${value} does not exceed segment id ${segment.id}`, { partitionId });
292
- }
293
- }
294
- return value;
295
- }
296
- var VECTOR_FILE_ENVELOPE_VERSION = 2;
297
- var GRAPH_PART_ENVELOPE_VERSION = 2;
298
- function liveVectorsOf(ref) {
299
- let live = 0;
300
- for (const file of ref.files) live += file.count - countDead(file.dead, file.count);
301
- return live;
302
- }
303
- async function openListedFile(store, ref, what, allowsCompression) {
304
- const bytes = await readListedFile(store, ref.key, { bytes: ref.bytes, what });
305
- const { header, payload } = await openChecksummedEnvelope(bytes, {
306
- envelopeFormatVersion: VECTOR_FILE_ENVELOPE_VERSION,
307
- what: `${what} "${ref.key}"`,
308
- allowsCompression
309
- });
310
- requireListedChecksum(what, ref.key, header.checksum, ref.checksum);
311
- return { payload, payloadLength: header.payloadLength };
312
- }
313
- async function readGraphParts(store, ref) {
314
- if (ref.graphParts.length === 0) return null;
315
- const parts = [];
316
- for (const part of ref.graphParts) {
317
- const { payload } = await openListedFile(store, part, "graph part", true);
318
- const decoded = decodeVectorGraphPartPayload(decode(payload));
319
- if (decoded.fieldName !== ref.fieldPath) {
320
- throw new NarsilError(
321
- ErrorCodes.PERSISTENCE_LOAD_FAILED,
322
- `The graph part "${part.key}" names field "${decoded.fieldName}" where the manifest lists "${ref.fieldPath}"`,
323
- { key: part.key }
324
- );
325
- }
326
- parts.push(decoded);
327
- }
328
- return assembleGraphParts(parts);
329
- }
330
- async function readVectorFile(store, file, fieldPath) {
331
- const { payload: bytes, payloadLength } = await openListedFile(store, file, "vector file", false);
332
- const payload = decodeVectorFilePayload(decode(bytes));
333
- if (payload.docIds.length !== file.count) {
334
- throw new NarsilError(
335
- ErrorCodes.PERSISTENCE_LOAD_FAILED,
336
- `The vector file "${file.key}" holds ${payload.docIds.length} vectors where the manifest counts ${file.count}`,
337
- { key: file.key, held: payload.docIds.length, count: file.count }
338
- );
339
- }
340
- if (payload.fieldName !== fieldPath) {
341
- throw new NarsilError(
342
- ErrorCodes.PERSISTENCE_LOAD_FAILED,
343
- `The vector file "${file.key}" names field "${payload.fieldName}" where the manifest lists "${fieldPath}"`,
344
- { key: file.key }
345
- );
346
- }
347
- return { payload, payloadLength };
348
- }
349
- async function loadVectorField(store, ref, vectorIndex) {
350
- const restore = vectorIndex.restoreCheckpoint({
351
- liveVectors: liveVectorsOf(ref),
352
- holdsGraph: ref.graphParts.length > 0,
353
- graph: await readGraphParts(store, ref)
354
- });
355
- for (const file of ref.files) {
356
- const { payload, payloadLength } = await readVectorFile(store, file, ref.fieldPath);
357
- restore.addFile({
358
- id: file.id,
359
- key: file.key,
360
- payload,
361
- dead: file.dead,
362
- location: store.pathOf === void 0 ? null : {
363
- path: await store.pathOf(file.key),
364
- vectorsOffset: HEADER_SIZE + payloadLength - payload.vectors.byteLength
365
- }
366
- });
367
- }
368
- restore.finish();
369
- }
370
- var EMPTY_BIN = new Uint8Array(0);
371
- var EMPTY_BIN_BYTES = 2;
372
- var BIN8 = 196;
373
- var BIN16 = 197;
374
- var BIN32 = 198;
375
- var BIN8_MAX_BYTES = 255;
376
- var BIN16_MAX_BYTES = 65535;
377
- function binHeader(byteLength) {
378
- if (byteLength <= BIN8_MAX_BYTES) return Uint8Array.of(BIN8, byteLength);
379
- if (byteLength <= BIN16_MAX_BYTES) return Uint8Array.of(BIN16, byteLength >> 8, byteLength & 255);
380
- const header = new Uint8Array(5);
381
- header[0] = BIN32;
382
- new DataView(header.buffer).setUint32(1, byteLength, false);
383
- return header;
384
- }
385
- function chunksEndingInBytes(withTheBytes, withEmptyBytesInTheirPlace, bytes) {
386
- const head = encode(withEmptyBytesInTheirPlace);
387
- const endsWithTheEmptyBin = head[head.length - EMPTY_BIN_BYTES] === BIN8 && head[head.length - 1] === 0;
388
- if (!endsWithTheEmptyBin) return [encode(withTheBytes)];
389
- return [head.subarray(0, head.length - EMPTY_BIN_BYTES), binHeader(bytes.byteLength), bytes];
390
- }
391
- function vectorPartChunks(part) {
392
- return chunksEndingInBytes(part, { ...part, vectors: EMPTY_BIN }, part.vectors);
393
- }
394
-
395
- // src/persistence/durability/segment/vector-write.ts
396
- function keptFileRef(input, prior, kept) {
397
- const listed = prior?.files.find((file) => file.key === kept.key) ?? input.priorFileRefs?.get(kept.key);
398
- if (listed === void 0) {
399
- throw new NarsilError(
400
- ErrorCodes.PERSISTENCE_SAVE_FAILED,
401
- `The checkpoint keeps the vector file "${kept.key}", which the previous manifest does not list`,
402
- { key: kept.key }
403
- );
404
- }
405
- return { ...kept, bytes: listed.bytes, checksum: listed.checksum };
406
- }
407
- async function writeGraphParts(input, fieldPath, plan, generation) {
408
- const parts = plan.graphParts ?? [];
409
- const refs = [];
410
- for (let part = 0; part < parts.length; part++) {
411
- const key = graphPartKey(input.indexName, fieldPath, generation, part);
412
- const packed = await packChecksummedEnvelope(
413
- [encode(parts[part])],
414
- GRAPH_PART_ENVELOPE_VERSION,
415
- `graph part "${key}"`
416
- );
417
- await input.store.write(key, packed.chunks);
418
- refs.push({ key, bytes: packed.byteLength, checksum: packed.checksum });
419
- }
420
- return refs;
421
- }
422
- async function writeField(input, fieldPath, plan, outcome) {
423
- const prior = input.priorVectors.find((ref) => ref.fieldPath === fieldPath);
424
- if (plan.unchanged && prior !== void 0) {
425
- outcome.refs.push(prior);
426
- return;
427
- }
428
- let nextFileId = prior?.nextFileId ?? 0;
429
- const files = plan.kept.map((kept) => keptFileRef(input, prior, kept));
430
- const written = [];
431
- for (let index = 0; index < plan.newFiles; index++) {
432
- const { payload, ordinals, dead } = plan.readNewFile(index);
433
- const id = nextFileId;
434
- nextFileId += 1;
435
- const key = vectorFileKey(input.indexName, fieldPath, id);
436
- const packed = await packChecksummedEnvelope(
437
- vectorPartChunks(payload),
438
- VECTOR_FILE_ENVELOPE_VERSION,
439
- `vector file "${key}"`
440
- );
441
- await input.store.write(key, packed.chunks);
442
- files.push({ id, key, count: payload.docIds.length, dead, bytes: packed.byteLength, checksum: packed.checksum });
443
- written.push({ id, key, ordinals });
444
- outcome.layouts.push({
445
- fieldPath,
446
- key,
447
- docIds: payload.docIds,
448
- dead,
449
- vectorsOffset: packed.byteLength - payload.vectors.byteLength
450
- });
451
- }
452
- const priorGeneration = prior?.graphGeneration ?? 0;
453
- const holdsGraph = plan.graphParts !== null && plan.graphParts.length > 0;
454
- const graphGeneration = holdsGraph ? priorGeneration + 1 : priorGeneration;
455
- const graphParts = holdsGraph ? await writeGraphParts(input, fieldPath, plan, graphGeneration) : [];
456
- outcome.refs.push({ fieldPath, nextFileId, files, graphGeneration, graphParts });
457
- outcome.written.push({ fieldPath, plan, files: written });
458
- }
459
- async function writeLiveVectors(input) {
460
- const outcome = { refs: [], layouts: [], written: [] };
461
- for (const [fieldPath, plan] of input.plans) await writeField(input, fieldPath, plan, outcome);
462
- return outcome;
463
- }
464
-
465
- // src/persistence/durability/seq-owner.ts
466
- var SINGLE_NODE_PRIMARY_TERM = 1;
467
- function createSeqOwner(startSeqNo, primaryTerm = SINGLE_NODE_PRIMARY_TERM) {
468
- let current = startSeqNo;
469
- return {
470
- next() {
471
- current += 1;
472
- return current;
473
- },
474
- get current() {
475
- return current;
476
- },
477
- get primaryTerm() {
478
- return primaryTerm;
479
- }
480
- };
481
- }
482
-
483
- // src/persistence/durability/segment/load-partition.ts
484
- function requireAgreedSchema(agreed, schema, key) {
485
- for (const [field, type] of Object.entries(schema)) {
486
- const existing = agreed[field];
487
- if (existing !== void 0 && existing !== type) {
488
- throw new NarsilError(
489
- ErrorCodes.PERSISTENCE_LOAD_FAILED,
490
- `The segment "${key}" gives field "${field}" the type "${type}", while the index gives it "${existing}"`,
491
- { key, field, existing, found: type }
492
- );
493
- }
494
- }
495
- }
496
- function removeWhatTheSegmentReplaces(manager, segment, contents) {
497
- manager.beginBatchRemove();
498
- try {
499
- for (const docId of contents.tombstones) {
500
- if (manager.has(docId)) manager.remove(docId);
501
- }
502
- const ids = segment.arrays.idTable;
503
- for (let ordinal = 0; ordinal < ids.count; ordinal++) {
504
- const docId = ids.idAt(ordinal);
505
- if (manager.has(docId)) manager.remove(docId);
506
- }
507
- } finally {
508
- manager.endBatchRemove();
509
- }
510
- }
511
- function yieldToEventLoop() {
512
- return new Promise((resolve) => setTimeout(resolve, 0));
513
- }
514
- async function loadPartitionSegments(store, partition, manager, options) {
515
- for (const ref of partition.segments) {
516
- const contents = await readSegmentFile(store, ref);
517
- requireAgreedSchema(options.schema, contents.schema, ref.key);
518
- if (options.decodesEveryDocument) decodeEveryStoredDocument(contents.arrays.documentTable);
519
- const segment = createSharedFrozenSegment(shareSegmentArrays(contents.arrays, manager.partialWordAnalysis));
520
- removeWhatTheSegmentReplaces(manager, segment, contents);
521
- if (contents.arrays.documentCount > 0) manager.attachFrozenSegment(partition.partitionId, segment);
522
- await yieldToEventLoop();
523
- }
524
- }
525
-
526
- export { SINGLE_NODE_PRIMARY_TERM, VECTOR_FILE_ENVELOPE_VERSION, createSeqOwner, decodeManifestPayload, decodeSegmentManifest, indexMetadataOf, invalidManifest, isId, isRecord, isSequenceNumber, isUint32, listedKeysOf, loadPartitionSegments, loadVectorField, metadataConfigOf, metadataFromConfig, openManifestPayload, readGraphParts, readVectorFile, writeLiveVectors };
@@ -1,113 +0,0 @@
1
- import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
2
-
3
- // src/rerank/call.ts
4
- function unregistered(adapters, name) {
5
- const registered = [...adapters.keys()].sort();
6
- return new NarsilError(
7
- ErrorCodes.RERANK_CONFIG_INVALID,
8
- `The query gives rerank adapter "${name}", which this engine has not registered. Register it with registerRerankAdapter or the rerankAdapters setting`,
9
- { adapter: name, registered }
10
- );
11
- }
12
- function scoresOf(raw, expected, name) {
13
- const list = Array.isArray(raw) ? raw : ArrayBuffer.isView(raw) && !(raw instanceof DataView) ? Array.from(raw) : null;
14
- if (list === null) {
15
- throw new NarsilError(
16
- ErrorCodes.RERANK_FAILED,
17
- `Rerank adapter "${name}" returned ${typeof raw}, expected a list of scores`,
18
- {
19
- adapter: name
20
- }
21
- );
22
- }
23
- if (list.length !== expected) {
24
- throw new NarsilError(
25
- ErrorCodes.RERANK_FAILED,
26
- `Rerank adapter "${name}" returned ${list.length} scores for ${expected} documents`,
27
- { adapter: name, expected, actual: list.length }
28
- );
29
- }
30
- const scores = new Array(expected);
31
- for (let i = 0; i < expected; i++) {
32
- const score = list[i];
33
- if (typeof score !== "number" || !Number.isFinite(score)) {
34
- throw new NarsilError(
35
- ErrorCodes.RERANK_FAILED,
36
- `Rerank adapter "${name}" returned a score that is not a finite number at position ${i}`,
37
- { adapter: name, position: i }
38
- );
39
- }
40
- scores[i] = score;
41
- }
42
- return scores;
43
- }
44
- function requireRerankAdapter(adapters, name) {
45
- const adapter = adapters.get(name);
46
- if (adapter === void 0) throw unregistered(adapters, name);
47
- return adapter;
48
- }
49
- function timedOut(name, timeoutMs) {
50
- return new NarsilError(
51
- ErrorCodes.RERANK_FAILED,
52
- `Rerank adapter "${name}" did not answer within ${timeoutMs} ms, so the engine cancelled the call`,
53
- { adapter: name, timeoutMs }
54
- );
55
- }
56
- function cancelled(name) {
57
- return new NarsilError(ErrorCodes.RERANK_FAILED, `The engine cancelled the call to rerank adapter "${name}"`, {
58
- adapter: name
59
- });
60
- }
61
- function wrapped(err, name) {
62
- if (err instanceof NarsilError && err.code === ErrorCodes.RERANK_FAILED) return err;
63
- const message = err instanceof Error ? err.message : String(err);
64
- return new NarsilError(ErrorCodes.RERANK_FAILED, `Rerank adapter "${name}" failed: ${message}`, {
65
- adapter: name,
66
- cause: message,
67
- ...err instanceof NarsilError ? { causeCode: err.code } : {}
68
- });
69
- }
70
- async function callRerankAdapter(adapters, name, query, documents, options) {
71
- const adapter = requireRerankAdapter(adapters, name);
72
- if (documents.length === 0) return [];
73
- const outer = options.signal;
74
- if (outer?.aborted) throw cancelled(name);
75
- const controller = new AbortController();
76
- let timer;
77
- let detach;
78
- const stopped = new Promise((_resolve, reject) => {
79
- timer = setTimeout(() => {
80
- controller.abort();
81
- reject(timedOut(name, options.timeoutMs));
82
- }, options.timeoutMs);
83
- if (outer !== void 0) {
84
- const onAbort = () => {
85
- controller.abort();
86
- reject(cancelled(name));
87
- };
88
- outer.addEventListener("abort", onAbort, { once: true });
89
- detach = () => outer.removeEventListener("abort", onAbort);
90
- }
91
- });
92
- let raw;
93
- try {
94
- raw = await Promise.race([
95
- Promise.resolve().then(() => adapter.rerank(query, documents, controller.signal)),
96
- stopped
97
- ]);
98
- } catch (err) {
99
- throw wrapped(err, name);
100
- } finally {
101
- clearTimeout(timer);
102
- detach?.();
103
- }
104
- return scoresOf(raw, documents.length, name);
105
- }
106
- function rerankOnHost(host, name, query, documents) {
107
- return callRerankAdapter(host.rerankAdapters, name, query, documents, {
108
- timeoutMs: host.rerankSettings.timeoutMs,
109
- signal: host.abortController.signal
110
- });
111
- }
112
-
113
- export { rerankOnHost };