@delali/narsil 0.3.1-next.153 → 0.3.1-next.155

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 (330) hide show
  1. package/README.md +3 -1
  2. package/dist/adapters/filesystem.mjs +2 -2
  3. package/dist/adapters/gcs.mjs +2 -2
  4. package/dist/adapters/indexeddb.mjs +1 -1
  5. package/dist/adapters/s3.mjs +2 -2
  6. package/dist/{analysis-change-2OYM7ARW.mjs → analysis-change-3TFIHT5E.mjs} +32 -23
  7. package/dist/{react-native/chunks/analysis-change-entry-CXNRW324.mjs → analysis-change-entry-KA6JAO4X.mjs} +1 -1
  8. package/dist/archive-history-E4R73RWD.mjs +29 -0
  9. package/dist/browser/{analysis-change-2V2HZ2NY.mjs → analysis-change-TC36BU47.mjs} +39 -10
  10. package/dist/{analysis-change-entry-QD7YNDEE.mjs → browser/analysis-change-entry-4MH3CZXH.mjs} +1 -1
  11. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  12. package/dist/browser/chunk-23XRXIBW.mjs +85 -0
  13. package/dist/browser/chunk-3UIEB4QF.mjs +63 -0
  14. package/dist/browser/{chunk-CSCKZBVJ.mjs → chunk-4EWUGZYZ.mjs} +4 -4
  15. package/dist/browser/chunk-4WCVMOU3.mjs +151 -0
  16. package/dist/browser/{chunk-QJCO3TJU.mjs → chunk-56W3HQVJ.mjs} +9 -150
  17. package/dist/{react-native/chunks/chunk-VGUWIZFQ.mjs → browser/chunk-5TCXK5SB.mjs} +2 -2
  18. package/dist/browser/chunk-5W3MMTLG.mjs +19 -0
  19. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  20. package/dist/browser/chunk-A5KUEGDY.mjs +241 -0
  21. package/dist/browser/{chunk-HT7J73QL.mjs → chunk-ABCXENU5.mjs} +2 -2
  22. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  23. package/dist/browser/chunk-BXM5XOCA.mjs +315 -0
  24. package/dist/browser/chunk-CJSYBQ4J.mjs +100 -0
  25. package/dist/browser/chunk-DSXIBE6N.mjs +78 -0
  26. package/dist/browser/chunk-ELV4OZOI.mjs +29 -0
  27. package/dist/{react-native/chunks/chunk-QC4ZRBSX.mjs → browser/chunk-EXQZGUQH.mjs} +2 -79
  28. package/dist/browser/{chunk-2A2IPRC3.mjs → chunk-FNIFPFB7.mjs} +5 -31
  29. package/dist/browser/chunk-G64Q6OJF.mjs +96 -0
  30. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  31. package/dist/browser/chunk-IKDKX5VQ.mjs +1007 -0
  32. package/dist/browser/chunk-JIJXMI42.mjs +1829 -0
  33. package/dist/browser/chunk-JVBP5EYO.mjs +1106 -0
  34. package/dist/browser/{chunk-TQ5UMFG5.mjs → chunk-K4GCSZLI.mjs} +15 -6
  35. package/dist/browser/{chunk-PM4MUM5N.mjs → chunk-K5AXJBLL.mjs} +6 -5
  36. package/dist/browser/chunk-KKAMCABR.mjs +432 -0
  37. package/dist/browser/{chunk-IAXZAVYL.mjs → chunk-LFIWRCEA.mjs} +1 -159
  38. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  39. package/dist/browser/chunk-ML7THVLJ.mjs +38 -0
  40. package/dist/browser/chunk-NLWTBAGB.mjs +111 -0
  41. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  42. package/dist/browser/{chunk-MPK76GVS.mjs → chunk-RA6LSBCM.mjs} +1 -21
  43. package/dist/browser/{chunk-GJKXW3SF.mjs → chunk-RND5CLX3.mjs} +147 -253
  44. package/dist/{react-native/chunks/chunk-DFQJ4IJB.mjs → browser/chunk-RQBUNZQW.mjs} +2 -2
  45. package/dist/browser/{chunk-VD7JEUIR.mjs → chunk-RRO3EV4C.mjs} +9 -8
  46. package/dist/browser/{chunk-KWYQ6KX4.mjs → chunk-SMEQ36NT.mjs} +162 -2019
  47. package/dist/{chunk-MDF6PDIA.mjs → browser/chunk-SRMZXJSL.mjs} +8 -1
  48. package/dist/browser/{chunk-7ZJTRUVW.mjs → chunk-SUDNZKPL.mjs} +2 -2
  49. package/dist/browser/{chunk-LURXVCHG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  50. package/dist/browser/chunk-VI7BQR4U.mjs +21 -0
  51. package/dist/browser/{chunk-B3JM6Z74.mjs → chunk-XY4VVBBO.mjs} +3 -2
  52. package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
  53. package/dist/browser/chunk-ZI2V4VD7.mjs +21 -0
  54. package/dist/browser/{cold-module-YECAK4MN.mjs → cold-module-NEUGHUPA.mjs} +21 -14
  55. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  56. package/dist/browser/{durability-wiring-LM7WFL6X.mjs → durability-wiring-CVGPRO6D.mjs} +1299 -881
  57. package/dist/browser/engine-hooks-YXMPHZKZ.mjs +16 -0
  58. package/dist/browser/import-OM6QAW45.mjs +18 -0
  59. package/dist/browser/methods-KTQCSIN4.mjs +30 -0
  60. package/dist/browser/{module-XQLEOYNM.mjs → module-3HNFCBJ5.mjs} +10 -8
  61. package/dist/browser/{module-KAMRAJLE.mjs → module-E33X4AOK.mjs} +17 -10
  62. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  63. package/dist/browser/{phrase-module-CNKMUY4U.mjs → phrase-module-ZXXU7S3B.mjs} +1 -1
  64. package/dist/browser/{pool-DTYSPBMQ.mjs → pool-3JLET5RO.mjs} +3 -2
  65. package/dist/browser/restore-hooks-IF2ZROUP.mjs +113 -0
  66. package/dist/browser/restore-queue-ZBS7CJA6.mjs +55 -0
  67. package/dist/browser/retention-ASWUHAYI.mjs +209 -0
  68. package/dist/browser/{runtime-D2ULZGCN.mjs → runtime-OTAGEFQW.mjs} +1 -1
  69. package/dist/browser/{snapshot-UGZVMP4H.mjs → snapshot-PN7ZW6Q4.mjs} +80 -315
  70. package/dist/browser/start-ZIRB7MQ2.mjs +24 -0
  71. package/dist/browser/sync-state-P5XG6LTQ.mjs +15 -0
  72. package/dist/browser/{write-I5P5MW4O.mjs → write-HMDYCTV2.mjs} +17 -11
  73. package/dist/{capabilities-BT-HLDC8.d.ts → capabilities-Da4ywVVl.d.ts} +94 -7
  74. package/dist/{chunk-LDGGR7YT.mjs → chunk-2MANFZJ3.mjs} +2 -2
  75. package/dist/{chunk-IZT3G24Q.mjs → chunk-2NE7VCYE.mjs} +2 -2
  76. package/dist/{chunk-3TVDTACC.mjs → chunk-3C7MTCCI.mjs} +1 -1
  77. package/dist/chunk-3HB3PEC6.mjs +240 -0
  78. package/dist/chunk-3HHQLEEQ.mjs +1092 -0
  79. package/dist/chunk-3OH67G7R.mjs +214 -0
  80. package/dist/{chunk-ZS6CMXAE.mjs → chunk-3R4UZWQG.mjs} +98 -250
  81. package/dist/{chunk-65WCV5JO.mjs → chunk-4BYWRYPM.mjs} +1 -1
  82. package/dist/{chunk-SOUZMPME.mjs → chunk-4KRC2APY.mjs} +7 -194
  83. package/dist/{chunk-5QMHMELB.mjs → chunk-5FLRXF73.mjs} +8 -1
  84. package/dist/chunk-5FVU47TB.mjs +20 -0
  85. package/dist/chunk-5YNRKI2C.mjs +81 -0
  86. package/dist/chunk-6L3XJXGU.mjs +470 -0
  87. package/dist/chunk-6MSZ543Y.mjs +32 -0
  88. package/dist/{chunk-T4CJDBBE.mjs → chunk-6OEGXLBX.mjs} +1 -1
  89. package/dist/{chunk-3SBJVQLL.mjs → chunk-6RC4K46J.mjs} +2 -2
  90. package/dist/chunk-7GXJUJ24.mjs +49 -0
  91. package/dist/{chunk-FNBNZCGP.mjs → chunk-AILVAOLX.mjs} +2 -2
  92. package/dist/chunk-BDRIVYOK.mjs +72 -0
  93. package/dist/chunk-BUMREPLU.mjs +15 -0
  94. package/dist/chunk-BY6ZDGYS.mjs +50 -0
  95. package/dist/{chunk-5WB2A3XU.mjs → chunk-DCNKVEDB.mjs} +511 -27
  96. package/dist/{chunk-NITCPDFL.mjs → chunk-DIBHI6W5.mjs} +2 -2
  97. package/dist/{chunk-4QCSHLNM.mjs → chunk-DUOLGBTE.mjs} +3 -3
  98. package/dist/chunk-GES7U2PM.mjs +68 -0
  99. package/dist/chunk-GH4WQ22V.mjs +34 -0
  100. package/dist/chunk-GQPTDQCL.mjs +54 -0
  101. package/dist/chunk-H4KHPLHJ.mjs +382 -0
  102. package/dist/{chunk-7TE2AJIH.mjs → chunk-H6VIGE62.mjs} +13 -10
  103. package/dist/{chunk-J7M73VY7.mjs → chunk-HJJI72X7.mjs} +1 -1
  104. package/dist/{chunk-DGRM4EZZ.mjs → chunk-HNVVEQP7.mjs} +1 -1
  105. package/dist/{chunk-RBEHLIKX.mjs → chunk-HW5TNXBO.mjs} +35 -11
  106. package/dist/{chunk-KYVRZAYP.mjs → chunk-I54T6CQP.mjs} +2 -69
  107. package/dist/{chunk-IRWP524D.mjs → chunk-INJYO3BU.mjs} +1 -1
  108. package/dist/chunk-IPN7S4KX.mjs +130 -0
  109. package/dist/{chunk-CSHHU7PA.mjs → chunk-J4IWBIVY.mjs} +11 -30
  110. package/dist/{chunk-G5KHSM6E.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  111. package/dist/{chunk-6RKSY3BX.mjs → chunk-KBDBPVLN.mjs} +5 -5
  112. package/dist/{chunk-J4BDAH2W.mjs → chunk-KBKEXQZA.mjs} +2 -2
  113. package/dist/{chunk-IJSFWGVW.mjs → chunk-KFLK5NA2.mjs} +3 -3
  114. package/dist/{chunk-YGQOPB2Z.mjs → chunk-KHKIRS5D.mjs} +1 -1
  115. package/dist/chunk-KJ3RTZDJ.mjs +101 -0
  116. package/dist/{chunk-2PNYKG2D.mjs → chunk-KMUNHGBQ.mjs} +139 -432
  117. package/dist/chunk-KP7TYHWT.mjs +92 -0
  118. package/dist/{chunk-VP6XRMWR.mjs → chunk-KPIV4RUC.mjs} +6 -32
  119. package/dist/{chunk-NPXVQS33.mjs → chunk-KXCVQWOR.mjs} +4 -3
  120. package/dist/chunk-KYYABCSW.mjs +72 -0
  121. package/dist/{chunk-6F6USYII.mjs → chunk-L7ZD4L3K.mjs} +267 -265
  122. package/dist/{chunk-U46IZNCW.mjs → chunk-LC3FDWTX.mjs} +3 -2
  123. package/dist/{chunk-6BWLDLS3.mjs → chunk-LHKOSI2J.mjs} +1 -1
  124. package/dist/chunk-LNGE7SLY.mjs +151 -0
  125. package/dist/{react-native/chunks/chunk-YH7W556M.mjs → chunk-MP7ABPTD.mjs} +12 -2
  126. package/dist/chunk-MT2NRTA6.mjs +216 -0
  127. package/dist/chunk-NF4DT3IH.mjs +85 -0
  128. package/dist/{chunk-POUYICOU.mjs → chunk-OIJ64LGT.mjs} +1 -1
  129. package/dist/{chunk-SEAJS664.mjs → chunk-PCRA7HTI.mjs} +5 -5
  130. package/dist/chunk-PHQNACDT.mjs +63 -0
  131. package/dist/chunk-Q622CTMC.mjs +74 -0
  132. package/dist/{chunk-NVTFQFUL.mjs → chunk-Q7G3BV3Y.mjs} +1 -1
  133. package/dist/chunk-QDZJM7NI.mjs +23 -0
  134. package/dist/{chunk-52QQWEBS.mjs → chunk-QH3YIQP4.mjs} +36 -7
  135. package/dist/chunk-QJVOLKU6.mjs +111 -0
  136. package/dist/chunk-QUJHMPTP.mjs +30 -0
  137. package/dist/{chunk-3E4RRF5J.mjs → chunk-RSVULW4Q.mjs} +100 -8
  138. package/dist/{chunk-IJPK5PGM.mjs → chunk-RVGRFOGN.mjs} +1 -1
  139. package/dist/chunk-RZWWB2XR.mjs +96 -0
  140. package/dist/{chunk-KQJVNPRM.mjs → chunk-S2EQU2GE.mjs} +19 -16
  141. package/dist/chunk-S5LN746F.mjs +10 -0
  142. package/dist/{chunk-LJ4ENXOD.mjs → chunk-SG3JBNHY.mjs} +2 -2
  143. package/dist/{chunk-B2FTZNNF.mjs → chunk-SMVH6JBE.mjs} +34 -14
  144. package/dist/chunk-SY3EWKQY.mjs +242 -0
  145. package/dist/{chunk-NYSONUB7.mjs → chunk-TQXHPFWT.mjs} +1 -1
  146. package/dist/{chunk-ZHAXP7SD.mjs → chunk-U4BS74YN.mjs} +26 -238
  147. package/dist/chunk-UHICS3JI.mjs +83 -0
  148. package/dist/chunk-UZRZKNNZ.mjs +101 -0
  149. package/dist/chunk-V6EUBAIT.mjs +19 -0
  150. package/dist/{chunk-TTCKT2RT.mjs → chunk-VGF7CFRP.mjs} +134 -11
  151. package/dist/chunk-VHBNF4MA.mjs +543 -0
  152. package/dist/{chunk-AWNHDBKV.mjs → chunk-VQEUR6T6.mjs} +16 -8
  153. package/dist/chunk-WQRN64Q6.mjs +196 -0
  154. package/dist/{chunk-DMNPYF54.mjs → chunk-WZ7YV54N.mjs} +2 -2
  155. package/dist/chunk-Y4WPNHMC.mjs +50 -0
  156. package/dist/{chunk-2HJWQPR6.mjs → chunk-YEDIDCR7.mjs} +6 -122
  157. package/dist/chunk-YEKL4JBK.mjs +96 -0
  158. package/dist/{chunk-UGVUW27S.mjs → chunk-Z2BE2MAM.mjs} +14 -10
  159. package/dist/{chunk-3HV7M5OJ.mjs → chunk-ZAUJFLEN.mjs} +11 -135
  160. package/dist/{chunk-FDG4KXX5.mjs → chunk-ZHCUZZE5.mjs} +6 -4
  161. package/dist/chunk-ZTW5WTGG.mjs +167 -0
  162. package/dist/chunk-ZYAY26KG.mjs +29 -0
  163. package/dist/{client-Cn3gNxUU.d.ts → client-DRv7UVeY.d.ts} +193 -11
  164. package/dist/client.d.ts +9 -7
  165. package/dist/client.mjs +120 -7
  166. package/dist/{cold-module-PYSSBIL7.mjs → cold-module-7XXCEGTZ.mjs} +43 -33
  167. package/dist/config-CoSig5Ox.d.ts +482 -0
  168. package/dist/{config-CfhH1IWQ.d.ts → config-DMwffLKn.d.ts} +20 -5
  169. package/dist/{direct-executor-WYALQSMD.mjs → direct-executor-G5TK7NLA.mjs} +18 -13
  170. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  171. package/dist/distribution/coordinator/etcd.mjs +1 -1
  172. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  173. package/dist/distribution/transport/grpc.mjs +4 -4
  174. package/dist/distribution/transport/in-memory.mjs +2 -2
  175. package/dist/distribution/transport/tcp.mjs +3 -3
  176. package/dist/distribution.d.ts +41 -9
  177. package/dist/distribution.mjs +9304 -7271
  178. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  179. package/dist/{durability-wiring-7VBZEJLG.mjs → durability-wiring-NCKUC5EO.mjs} +1293 -872
  180. package/dist/embeddings/openai.mjs +2 -2
  181. package/dist/{config-aIsy7mcL.d.ts → engine-CFxPYqEk.d.ts} +716 -407
  182. package/dist/engine-hooks-DHCMOADY.mjs +47 -0
  183. package/dist/{import-GJOMB2HC.mjs → import-NBFXFCSG.mjs} +32 -24
  184. package/dist/{index-MsF7e5hL.d.ts → index-C4AmUnl1.d.ts} +1 -1
  185. package/dist/index.browser.mjs +9 -4
  186. package/dist/index.d.ts +7 -6
  187. package/dist/index.mjs +29 -21
  188. package/dist/index.react-native.mjs +19 -12
  189. package/dist/{long-query-thread-SCUE62TO.mjs → long-query-thread-J4DVRM4A.mjs} +33 -19
  190. package/dist/methods-7IOINERF.mjs +30 -0
  191. package/dist/{module-6RLIKSZQ.mjs → module-DWKPBSMN.mjs} +38 -28
  192. package/dist/{module-AVQEIB7O.mjs → module-UN76TF7I.mjs} +14 -14
  193. package/dist/operations-G5EP6JPX.mjs +5 -0
  194. package/dist/{paged-partition-archive-KGRW366Y.mjs → paged-partition-archive-DPNWVSK2.mjs} +46 -31
  195. package/dist/partial-words.mjs +7 -5
  196. package/dist/pattern.mjs +4 -3
  197. package/dist/persistence/durability/checkpoint-worker.d.ts +16 -1
  198. package/dist/persistence/durability/checkpoint-worker.mjs +40 -29
  199. package/dist/{phrase-module-OUQIRUQU.mjs → phrase-module-ZI4WSQVH.mjs} +1 -1
  200. package/dist/{pool-UPV5PVPY.mjs → pool-Y4A46T36.mjs} +2 -2
  201. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  202. package/dist/query-suggestions/merge-worker.mjs +81 -0
  203. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  204. package/dist/query-suggestions.browser.mjs +246 -0
  205. package/dist/query-suggestions.d.ts +20 -0
  206. package/dist/query-suggestions.mjs +62 -0
  207. package/dist/react-native/chunks/{analysis-change-DXPZRGWF.mjs → analysis-change-6BPDPH6K.mjs} +50 -19
  208. package/dist/{browser/analysis-change-entry-JL5U2N3Q.mjs → react-native/chunks/analysis-change-entry-JLL42PH6.mjs} +1 -1
  209. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  210. package/dist/react-native/chunks/chunk-3JIBF3XT.mjs +191 -0
  211. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +1 -0
  212. package/dist/react-native/chunks/{chunk-UFNCLEQM.mjs → chunk-4DII3ZSM.mjs} +1 -1
  213. package/dist/react-native/chunks/{chunk-BRNAVOKP.mjs → chunk-4J74WHQM.mjs} +2 -2
  214. package/dist/react-native/chunks/chunk-4LCEN2IU.mjs +315 -0
  215. package/dist/react-native/chunks/{chunk-PU55IOG4.mjs → chunk-4Y53T4YE.mjs} +6 -190
  216. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  217. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  218. package/dist/react-native/chunks/chunk-6WA3C3DV.mjs +85 -0
  219. package/dist/react-native/chunks/chunk-7GRCBBME.mjs +63 -0
  220. package/dist/react-native/chunks/{chunk-2J2727V4.mjs → chunk-7PXRWYUU.mjs} +1 -1
  221. package/dist/{browser/chunk-VBX2TI5V.mjs → react-native/chunks/chunk-ALOIBXWN.mjs} +2 -2
  222. package/dist/react-native/chunks/{chunk-FS7BYE23.mjs → chunk-C3PTWYKT.mjs} +10 -153
  223. package/dist/react-native/chunks/{chunk-DKJTZ625.mjs → chunk-C5G6TJ7A.mjs} +2 -69
  224. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +43 -0
  225. package/dist/react-native/chunks/{chunk-LRGWK367.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  226. package/dist/react-native/chunks/chunk-CUH5F57W.mjs +242 -0
  227. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  228. package/dist/{browser/chunk-55WYRLDZ.mjs → react-native/chunks/chunk-DVDX4SDR.mjs} +2 -2
  229. package/dist/{browser/chunk-PIS7ZAP7.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +12 -2
  230. package/dist/react-native/chunks/{chunk-KOCTCUXW.mjs → chunk-EIOYM5TO.mjs} +17 -9
  231. package/dist/react-native/chunks/chunk-F753DA54.mjs +23 -0
  232. package/dist/react-native/chunks/chunk-GIZTJXYW.mjs +1007 -0
  233. package/dist/react-native/chunks/{chunk-CLE3LZ77.mjs → chunk-GJFXPHXI.mjs} +5 -4
  234. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  235. package/dist/react-native/chunks/{chunk-IDFMNRIC.mjs → chunk-HUOYZJ3Q.mjs} +140 -430
  236. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +111 -0
  237. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +38 -0
  238. package/dist/react-native/chunks/{chunk-LQAKO5QV.mjs → chunk-JLIIWJUV.mjs} +2 -2
  239. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +15 -0
  240. package/dist/react-native/chunks/chunk-KJIG57UD.mjs +1106 -0
  241. package/dist/react-native/chunks/{chunk-KLZGAOLT.mjs → chunk-KTTAU63H.mjs} +5 -5
  242. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +68 -0
  243. package/dist/{browser/chunk-NVEJJP4R.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +2 -79
  244. package/dist/react-native/chunks/{chunk-3CTWSQRW.mjs → chunk-MJDQU5MW.mjs} +4 -30
  245. package/dist/react-native/chunks/{chunk-NFGBOI46.mjs → chunk-MVXELMJX.mjs} +1 -1
  246. package/dist/react-native/chunks/{chunk-D7LFYPYI.mjs → chunk-N2WUOWLL.mjs} +12 -10
  247. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +78 -0
  248. package/dist/react-native/chunks/{chunk-JYL35A4A.mjs → chunk-OL3WDV53.mjs} +7 -33
  249. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +29 -0
  250. package/dist/react-native/chunks/{chunk-UCJU6WNH.mjs → chunk-PEHS2UO3.mjs} +7 -6
  251. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  252. package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
  253. package/dist/react-native/chunks/chunk-QJXTNPLQ.mjs +100 -0
  254. package/dist/react-native/chunks/{chunk-ZCKNBPQ4.mjs → chunk-RDWG33MM.mjs} +2 -2
  255. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +96 -0
  256. package/dist/react-native/chunks/chunk-TYIRMPD3.mjs +432 -0
  257. package/dist/react-native/chunks/{chunk-TLYD7IJ2.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  258. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +68 -0
  259. package/dist/react-native/chunks/{chunk-7IQR3SZO.mjs → chunk-VXGE4ZXL.mjs} +151 -257
  260. package/dist/react-native/chunks/{chunk-R4OPUZQ5.mjs → chunk-WBYQRHDY.mjs} +2 -2
  261. package/dist/react-native/chunks/chunk-YH7QY657.mjs +288 -0
  262. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  263. package/dist/react-native/chunks/{cold-module-KFGEWYEL.mjs → cold-module-5PHF6DZR.mjs} +31 -22
  264. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  265. package/dist/react-native/chunks/{durability-wiring-QKJB2QBT.mjs → durability-wiring-KO565FZC.mjs} +1309 -889
  266. package/dist/react-native/chunks/engine-hooks-MVRRHH6B.mjs +28 -0
  267. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  268. package/dist/react-native/chunks/import-YVZA4V4V.mjs +30 -0
  269. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +30 -0
  270. package/dist/react-native/chunks/{module-UJ5VUARS.mjs → module-H5MVPSP2.mjs} +13 -11
  271. package/dist/react-native/chunks/module-ZL5ZG6YB.mjs +34 -0
  272. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  273. package/dist/react-native/chunks/{phrase-module-76UAPPSG.mjs → phrase-module-RTVKEWJT.mjs} +1 -1
  274. package/dist/react-native/chunks/{pool-CD4ANYUI.mjs → pool-JR3NJCAF.mjs} +3 -2
  275. package/dist/react-native/chunks/restore-hooks-SILFPU6B.mjs +125 -0
  276. package/dist/react-native/chunks/restore-queue-HSYP2AEC.mjs +55 -0
  277. package/dist/react-native/chunks/retention-7I7UAWYK.mjs +221 -0
  278. package/dist/react-native/chunks/{runtime-3MCDLJAF.mjs → runtime-R5E3TB3J.mjs} +1 -1
  279. package/dist/react-native/chunks/{snapshot-KVBD4LRC.mjs → snapshot-EZYB6SLF.mjs} +90 -323
  280. package/dist/react-native/chunks/start-SHVZ72I5.mjs +36 -0
  281. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +15 -0
  282. package/dist/react-native/chunks/{write-ES5A3WUA.mjs → write-JUESXHDL.mjs} +27 -19
  283. package/dist/react-native/partial-words.mjs +8 -5
  284. package/dist/react-native/pattern.mjs +4 -3
  285. package/dist/react-native/query-suggestions.mjs +258 -0
  286. package/dist/react-native/sync.mjs +2299 -0
  287. package/dist/react-native/synonyms.mjs +7 -4
  288. package/dist/react.d.ts +11 -10
  289. package/dist/react.mjs +8 -1
  290. package/dist/{rerank-3W54N6P2.mjs → rerank-MQ37IYRV.mjs} +4 -4
  291. package/dist/rerankers/http.mjs +2 -2
  292. package/dist/restore-hooks-HZ3ILAMO.mjs +146 -0
  293. package/dist/restore-queue-JVGENGGE.mjs +55 -0
  294. package/dist/retention-HROPV2QU.mjs +59 -0
  295. package/dist/{runtime-L2DZYY6N.mjs → runtime-COIUORCN.mjs} +5 -5
  296. package/dist/{schema-D33CyXCy.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  297. package/dist/server.d.ts +119 -20
  298. package/dist/server.mjs +1123 -58
  299. package/dist/{snapshot-WMX6JCLP.mjs → snapshot-4HS2G2UM.mjs} +106 -49
  300. package/dist/start-UTWHGH42.mjs +59 -0
  301. package/dist/sync/filesystem.d.ts +30 -0
  302. package/dist/sync/filesystem.mjs +271 -0
  303. package/dist/sync/indexeddb.d.ts +30 -0
  304. package/dist/sync/indexeddb.mjs +237 -0
  305. package/dist/sync-state-ZWHLAFLE.mjs +15 -0
  306. package/dist/sync.browser.mjs +2294 -0
  307. package/dist/sync.d.ts +23 -0
  308. package/dist/sync.mjs +2268 -0
  309. package/dist/synonyms.mjs +6 -4
  310. package/dist/{tasks-C4ElXr4P.d.ts → tasks-qrJojgST.d.ts} +13 -5
  311. package/dist/thread-6MOXY2KD.mjs +45 -0
  312. package/dist/types-BZCGjfLn.d.ts +227 -0
  313. package/dist/vector/search-worker.d.ts +1 -1
  314. package/dist/vector/search-worker.mjs +7 -7
  315. package/dist/workers/entry.mjs +8 -8
  316. package/dist/{write-SKJ6HW7O.mjs → write-GTTWWRRG.mjs} +36 -28
  317. package/openapi.json +912 -5
  318. package/package.json +45 -8
  319. package/dist/browser/import-QOY6ZH6X.mjs +0 -12
  320. package/dist/browser/restore-queue-UQ6AAUVX.mjs +0 -41
  321. package/dist/chunk-7LDMWKP6.mjs +0 -209
  322. package/dist/engine-CJRUHXgf.d.ts +0 -664
  323. package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +0 -110
  324. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  325. package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +0 -3
  326. package/dist/react-native/chunks/import-XFBCCENV.mjs +0 -22
  327. package/dist/react-native/chunks/module-FHJ2GOBI.mjs +0 -25
  328. package/dist/react-native/chunks/restore-queue-H5VCN453.mjs +0 -41
  329. package/dist/restore-queue-AOF5OTQV.mjs +0 -41
  330. package/dist/thread-I7DVHHW7.mjs +0 -31
@@ -0,0 +1,151 @@
1
+ // src/persistence/durability/sha256.ts
2
+ var ROUND_CONSTANTS = new Uint32Array([
3
+ 1116352408,
4
+ 1899447441,
5
+ 3049323471,
6
+ 3921009573,
7
+ 961987163,
8
+ 1508970993,
9
+ 2453635748,
10
+ 2870763221,
11
+ 3624381080,
12
+ 310598401,
13
+ 607225278,
14
+ 1426881987,
15
+ 1925078388,
16
+ 2162078206,
17
+ 2614888103,
18
+ 3248222580,
19
+ 3835390401,
20
+ 4022224774,
21
+ 264347078,
22
+ 604807628,
23
+ 770255983,
24
+ 1249150122,
25
+ 1555081692,
26
+ 1996064986,
27
+ 2554220882,
28
+ 2821834349,
29
+ 2952996808,
30
+ 3210313671,
31
+ 3336571891,
32
+ 3584528711,
33
+ 113926993,
34
+ 338241895,
35
+ 666307205,
36
+ 773529912,
37
+ 1294757372,
38
+ 1396182291,
39
+ 1695183700,
40
+ 1986661051,
41
+ 2177026350,
42
+ 2456956037,
43
+ 2730485921,
44
+ 2820302411,
45
+ 3259730800,
46
+ 3345764771,
47
+ 3516065817,
48
+ 3600352804,
49
+ 4094571909,
50
+ 275423344,
51
+ 430227734,
52
+ 506948616,
53
+ 659060556,
54
+ 883997877,
55
+ 958139571,
56
+ 1322822218,
57
+ 1537002063,
58
+ 1747873779,
59
+ 1955562222,
60
+ 2024104815,
61
+ 2227730452,
62
+ 2361852424,
63
+ 2428436474,
64
+ 2756734187,
65
+ 3204031479,
66
+ 3329325298
67
+ ]);
68
+ var SHA256_INITIAL_STATE = [
69
+ 1779033703,
70
+ 3144134277,
71
+ 1013904242,
72
+ 2773480762,
73
+ 1359893119,
74
+ 2600822924,
75
+ 528734635,
76
+ 1541459225
77
+ ];
78
+ var SHA256_BLOCK_BYTES = 64;
79
+ var LENGTH_BYTES = 8;
80
+ function rotateRight(value, bits) {
81
+ return value >>> bits | value << 32 - bits;
82
+ }
83
+ function paddedSha256Message(bytes, precedingBytes = 0) {
84
+ const total = Math.ceil((bytes.byteLength + 1 + LENGTH_BYTES) / SHA256_BLOCK_BYTES) * SHA256_BLOCK_BYTES;
85
+ const message = new Uint8Array(total);
86
+ message.set(bytes);
87
+ message[bytes.byteLength] = 128;
88
+ const view = new DataView(message.buffer);
89
+ const bitLength = (precedingBytes + bytes.byteLength) * 8;
90
+ view.setUint32(total - LENGTH_BYTES, Math.floor(bitLength / 4294967296), false);
91
+ view.setUint32(total - 4, bitLength >>> 0, false);
92
+ return view;
93
+ }
94
+ function compressSha256Block(state, view, block, words) {
95
+ for (let i = 0; i < 16; i++) words[i] = view.getUint32(block + i * 4, false);
96
+ for (let i = 16; i < 64; i++) {
97
+ const w15 = words[i - 15];
98
+ const w2 = words[i - 2];
99
+ const s0 = rotateRight(w15, 7) ^ rotateRight(w15, 18) ^ w15 >>> 3;
100
+ const s1 = rotateRight(w2, 17) ^ rotateRight(w2, 19) ^ w2 >>> 10;
101
+ words[i] = words[i - 16] + s0 + words[i - 7] + s1 >>> 0;
102
+ }
103
+ let a = state[0];
104
+ let b = state[1];
105
+ let c = state[2];
106
+ let d = state[3];
107
+ let e = state[4];
108
+ let f = state[5];
109
+ let g = state[6];
110
+ let h = state[7];
111
+ for (let i = 0; i < 64; i++) {
112
+ const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
113
+ const choice = e & f ^ ~e & g;
114
+ const t1 = h + s1 + choice + ROUND_CONSTANTS[i] + words[i] >>> 0;
115
+ const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
116
+ const majority = a & b ^ a & c ^ b & c;
117
+ const t2 = s0 + majority >>> 0;
118
+ h = g;
119
+ g = f;
120
+ f = e;
121
+ e = d + t1 >>> 0;
122
+ d = c;
123
+ c = b;
124
+ b = a;
125
+ a = t1 + t2 >>> 0;
126
+ }
127
+ state[0] = state[0] + a >>> 0;
128
+ state[1] = state[1] + b >>> 0;
129
+ state[2] = state[2] + c >>> 0;
130
+ state[3] = state[3] + d >>> 0;
131
+ state[4] = state[4] + e >>> 0;
132
+ state[5] = state[5] + f >>> 0;
133
+ state[6] = state[6] + g >>> 0;
134
+ state[7] = state[7] + h >>> 0;
135
+ }
136
+ function sha256Digest(state) {
137
+ const digest = new Uint8Array(32);
138
+ const out = new DataView(digest.buffer);
139
+ for (let i = 0; i < 8; i++) out.setUint32(i * 4, state[i], false);
140
+ return digest;
141
+ }
142
+ function sha256(bytes) {
143
+ const view = paddedSha256Message(bytes);
144
+ const state = Uint32Array.from(SHA256_INITIAL_STATE);
145
+ const words = new Uint32Array(64);
146
+ for (let block = 0; block < view.byteLength; block += SHA256_BLOCK_BYTES)
147
+ compressSha256Block(state, view, block, words);
148
+ return sha256Digest(state);
149
+ }
150
+
151
+ export { SHA256_BLOCK_BYTES, SHA256_INITIAL_STATE, compressSha256Block, paddedSha256Message, sha256, sha256Digest };
@@ -34,6 +34,12 @@ var ErrorCodes = {
34
34
  BACKUP_STORE_CLAIMED: "BACKUP_STORE_CLAIMED",
35
35
  BACKUP_STORE_NOT_CONFIGURED: "BACKUP_STORE_NOT_CONFIGURED",
36
36
  BACKUP_NOT_READY: "BACKUP_NOT_READY",
37
+ SYNC_DURABILITY_REQUIRED: "SYNC_DURABILITY_REQUIRED",
38
+ SYNC_BACKUP_STORE_REQUIRED: "SYNC_BACKUP_STORE_REQUIRED",
39
+ SYNC_NOT_READY: "SYNC_NOT_READY",
40
+ SYNC_NOT_ENABLED: "SYNC_NOT_ENABLED",
41
+ SYNC_SNAPSHOT_PREPARING: "SYNC_SNAPSHOT_PREPARING",
42
+ QUERY_SUGGESTIONS_NOT_ENABLED: "QUERY_SUGGESTIONS_NOT_ENABLED",
37
43
  SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD",
38
44
  VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH",
39
45
  SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER",
@@ -143,7 +149,8 @@ var ClientErrorCodes = {
143
149
  CLIENT_REQUEST_ABORTED: "CLIENT_REQUEST_ABORTED",
144
150
  CLIENT_INVALID_RESPONSE: "CLIENT_INVALID_RESPONSE",
145
151
  CLIENT_TASK_TIMEOUT: "CLIENT_TASK_TIMEOUT",
146
- CLIENT_UNEXPECTED_ERROR: "CLIENT_UNEXPECTED_ERROR"
152
+ CLIENT_UNEXPECTED_ERROR: "CLIENT_UNEXPECTED_ERROR",
153
+ SYNC_ANALYSIS_UNAVAILABLE: "SYNC_ANALYSIS_UNAVAILABLE"
147
154
  };
148
155
  var NarsilError = class extends Error {
149
156
  /** This says which failure it is. */
@@ -175,5 +182,8 @@ function isNarsilError(value) {
175
182
  function createNarsilError(code, message, details) {
176
183
  return new NarsilError(code, message, details);
177
184
  }
185
+ function describeError(error) {
186
+ return error instanceof Error ? error.message : String(error);
187
+ }
178
188
 
179
- export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, createNarsilError, isNarsilError };
189
+ export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, createNarsilError, describeError, isNarsilError };
@@ -0,0 +1,216 @@
1
+ import { suggestionsIndexName, markedSuggestionIndexes, ensureSuggestionsIndex, suggestionDocument, ORIGIN_MANUAL, removeSuggestions, enabledSetting, mergeHistory, groupsToWrite, meetsMinResults } from './chunk-3HHQLEEQ.mjs';
2
+ import { normaliseBan, banListFromInput, withState } from './chunk-UZRZKNNZ.mjs';
3
+ import { invalidSetting, resolveSetting, validateSetting, requireFieldsInSchema } from './chunk-H4KHPLHJ.mjs';
4
+ import { isGroup, GROUP_FORMAT, acceptedPhrase } from './chunk-GQPTDQCL.mjs';
5
+ import { MAX_MANUAL_SUGGESTION_COUNT, MAX_SOURCE_INDEX_NAME_LENGTH, DEFAULT_PREVIEW_LIMIT, MAX_PREVIEW_LIMIT } from './chunk-5YNRKI2C.mjs';
6
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
7
+
8
+ // src/query-suggestions/preview.ts
9
+ function previewOrder(left, right) {
10
+ if (left.count !== right.count) return right.count - left.count;
11
+ if (left.group !== right.group) return left.group < right.group ? -1 : 1;
12
+ return left.query < right.query ? -1 : left.query > right.query ? 1 : 0;
13
+ }
14
+ async function previewBuild(ctx, indexName, max) {
15
+ const setting = enabledSetting(ctx.host, indexName);
16
+ const merged = await mergeHistory(ctx, indexName, setting, Date.now());
17
+ const { groups } = groupsToWrite(ctx, indexName, setting, merged.result);
18
+ const banned = new Set(ctx.host.view(indexName)?.state?.bannedQueries ?? []);
19
+ const candidates = [];
20
+ for (const group of groups) {
21
+ for (const { phrase, count } of merged.result.groups[group] ?? []) {
22
+ if (!banned.has(phrase)) candidates.push({ group, query: phrase, count });
23
+ }
24
+ }
25
+ candidates.sort(previewOrder);
26
+ const checked = /* @__PURE__ */ new Map();
27
+ const entries = [];
28
+ let next = 0;
29
+ while (next < candidates.length && entries.length < max) {
30
+ const candidate = candidates[next];
31
+ next += 1;
32
+ if (candidate === void 0) break;
33
+ let passes = checked.get(candidate.query);
34
+ if (passes === void 0) {
35
+ passes = await meetsMinResults(ctx, indexName, setting, candidate.query);
36
+ checked.set(candidate.query, passes);
37
+ }
38
+ if (passes) entries.push(candidate);
39
+ }
40
+ return { entries, truncated: next < candidates.length };
41
+ }
42
+
43
+ // src/query-suggestions/operations.ts
44
+ function requireView(runtime, indexName) {
45
+ const view = runtime.host.view(indexName);
46
+ if (view === null) {
47
+ throw new NarsilError(ErrorCodes.INDEX_NOT_FOUND, `Index "${indexName}" does not exist`, { indexName });
48
+ }
49
+ return view;
50
+ }
51
+ function requireSourceView(runtime, indexName) {
52
+ const view = requireView(runtime, indexName);
53
+ if (view.state?.querySuggestionsSource !== void 0) {
54
+ invalidSetting(`Index "${indexName}" is a suggestions index, so it takes no query suggestions of its own`, {
55
+ indexName
56
+ });
57
+ }
58
+ if (indexName.length > MAX_SOURCE_INDEX_NAME_LENGTH) {
59
+ invalidSetting(
60
+ `Index "${indexName}" has a name longer than ${MAX_SOURCE_INDEX_NAME_LENGTH} characters, which leaves no room for the names of its suggestions indexes`,
61
+ { indexName }
62
+ );
63
+ }
64
+ return view;
65
+ }
66
+ function requireAcceptable(runtime, indexName, setting) {
67
+ const view = requireSourceView(runtime, indexName);
68
+ requireFieldsInSchema(setting, view.schema);
69
+ if (!setting.enabled) return;
70
+ if (runtime.scrambler === null) {
71
+ invalidSetting("This engine has no query suggestions key, so it cannot turn the feature on", { indexName });
72
+ }
73
+ if (view.hasSync) {
74
+ invalidSetting(
75
+ `Index "${indexName}" has device sync on, and a device receives the whole index of one user while a suggestion comes from the searches of several people`,
76
+ { indexName }
77
+ );
78
+ }
79
+ }
80
+ async function updateSetting(runtime, indexName, raw) {
81
+ const setting = validateSetting(raw);
82
+ requireAcceptable(runtime, indexName, setting);
83
+ await runtime.host.updateState(indexName, (current) => {
84
+ requireAcceptable(runtime, indexName, setting);
85
+ return withState(current, { querySuggestions: setting });
86
+ });
87
+ if (!setting.enabled) await runtime.discardHistory(indexName);
88
+ runtime.settingChanged(indexName);
89
+ }
90
+ async function status(runtime, indexName) {
91
+ const view = requireView(runtime, indexName);
92
+ return {
93
+ indexName,
94
+ setting: view.state?.querySuggestions ?? null,
95
+ lastBuild: await runtime.builds.lastBuild(indexName),
96
+ nextBuildAt: runtime.timers.nextBuildAt(indexName),
97
+ suggestionIndexes: [...markedSuggestionIndexes(runtime.host, indexName).values()].sort()
98
+ };
99
+ }
100
+ function previewLimitOf(limit) {
101
+ if (limit === void 0) return DEFAULT_PREVIEW_LIMIT;
102
+ if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1 || limit > MAX_PREVIEW_LIMIT) {
103
+ invalidSetting(`The preview limit must be a whole number from 1 to ${MAX_PREVIEW_LIMIT}`);
104
+ }
105
+ return limit;
106
+ }
107
+ async function preview(runtime, indexName, limit) {
108
+ const max = previewLimitOf(limit);
109
+ runtime.enabledSetting(indexName);
110
+ const scrambler = runtime.scrambler;
111
+ if (scrambler === null) invalidSetting("This engine has no query suggestions key, so it holds no counts");
112
+ const context = {
113
+ host: runtime.host,
114
+ scrambler,
115
+ saveDay: (name) => runtime.saveDay(name),
116
+ withWriteLock: (name, work) => runtime.withWriteLock(name, work),
117
+ isStopping: () => runtime.isStopping
118
+ };
119
+ return previewBuild(context, indexName, max);
120
+ }
121
+ async function banPhrases(runtime, indexName, next) {
122
+ requireSourceView(runtime, indexName);
123
+ let added = [];
124
+ let stored = [];
125
+ await runtime.host.updateState(indexName, (current) => {
126
+ requireSourceView(runtime, indexName);
127
+ const previous = current?.bannedQueries ?? [];
128
+ stored = next(previous);
129
+ const before = new Set(previous);
130
+ added = stored.filter((phrase) => !before.has(phrase));
131
+ return withState(current, { bannedQueries: stored });
132
+ });
133
+ return { stored, added };
134
+ }
135
+ async function removeFromSuggestions(runtime, indexName, phrases) {
136
+ let holders = 0;
137
+ if (phrases.length === 0) return holders;
138
+ for (const name of markedSuggestionIndexes(runtime.host, indexName).values()) {
139
+ if (await removeSuggestions(runtime.host, name, phrases) > 0) holders += 1;
140
+ }
141
+ return holders;
142
+ }
143
+ function updateBans(runtime, indexName, raw) {
144
+ const phrases = banListFromInput(raw);
145
+ return runtime.withWriteLock(indexName, async () => {
146
+ const { stored, added } = await banPhrases(runtime, indexName, () => phrases);
147
+ await removeFromSuggestions(runtime, indexName, added);
148
+ return stored;
149
+ });
150
+ }
151
+ function removeQuery(runtime, indexName, raw) {
152
+ const phrase = normaliseBan(raw);
153
+ return runtime.withWriteLock(indexName, async () => {
154
+ await banPhrases(runtime, indexName, (current) => current.includes(phrase) ? [...current] : [...current, phrase]);
155
+ return removeFromSuggestions(runtime, indexName, [phrase]);
156
+ });
157
+ }
158
+ function manualCountOf(count) {
159
+ if (count === void 0) return 0;
160
+ if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0 || count > MAX_MANUAL_SUGGESTION_COUNT) {
161
+ invalidSetting(`A suggestion's count must be a whole number from 0 to ${MAX_MANUAL_SUGGESTION_COUNT}`);
162
+ }
163
+ return count;
164
+ }
165
+ function addSuggestion(runtime, indexName, raw) {
166
+ const { group, query, count } = raw ?? {};
167
+ if (!isGroup(group)) invalidSetting(`A suggestion needs a group of ${GROUP_FORMAT}`);
168
+ if (typeof query !== "string") invalidSetting("A suggestion needs its query as a string");
169
+ const documentCount = manualCountOf(count);
170
+ return runtime.withWriteLock(indexName, async () => {
171
+ const view = requireSourceView(runtime, indexName);
172
+ const setting = resolveSetting(view.state?.querySuggestions ?? { enabled: false, fields: [] });
173
+ const phrase = acceptedPhrase(query, setting);
174
+ if (phrase === null) invalidSetting("The suggestion is not a phrase that the setting of the index accepts");
175
+ if ((view.state?.bannedQueries ?? []).includes(phrase)) {
176
+ invalidSetting("The ban list of the index holds this phrase", { indexName });
177
+ }
178
+ const marked = markedSuggestionIndexes(runtime.host, indexName);
179
+ if (!marked.has(group) && marked.size >= setting.maxGroups) {
180
+ invalidSetting(`Index "${indexName}" already has ${setting.maxGroups} groups`, { indexName });
181
+ }
182
+ const name = await ensureSuggestionsIndex(runtime.host, indexName, group);
183
+ const document = suggestionDocument(phrase, documentCount, ORIGIN_MANUAL);
184
+ if (await runtime.host.engine.has(name, phrase)) await runtime.host.engine.update(name, phrase, document);
185
+ else await runtime.host.engine.insert(name, document);
186
+ return name;
187
+ });
188
+ }
189
+ function querySuggestionsOf(runtime) {
190
+ return {
191
+ recordQuery: async (indexName, query) => (await runtime()).record(indexName, query),
192
+ updateSetting: async (indexName, setting) => updateSetting(await runtime(), indexName, setting),
193
+ status: async (indexName) => status(await runtime(), indexName),
194
+ build: async (indexName) => (await runtime()).builds.start(indexName, "caller"),
195
+ preview: async (indexName, limit) => preview(await runtime(), indexName, limit),
196
+ bans: async (indexName) => [...requireView(await runtime(), indexName).state?.bannedQueries ?? []],
197
+ updateBans: async (indexName, phrases) => updateBans(await runtime(), indexName, phrases),
198
+ removeQuery: async (indexName, query) => removeQuery(await runtime(), indexName, query),
199
+ addSuggestion: async (indexName, suggestion) => addSuggestion(await runtime(), indexName, suggestion),
200
+ suggestionsIndexName: (indexName, group) => {
201
+ if (!isGroup(group)) invalidSetting(`A group holds ${GROUP_FORMAT}`);
202
+ return suggestionsIndexName(indexName, group);
203
+ }
204
+ };
205
+ }
206
+
207
+ // src/query-suggestions/providers.ts
208
+ var providers = /* @__PURE__ */ new WeakMap();
209
+ function bindQuerySuggestions(owner, provide) {
210
+ providers.set(owner, provide);
211
+ }
212
+ function boundQuerySuggestionsOf(owner) {
213
+ return providers.get(owner);
214
+ }
215
+
216
+ export { bindQuerySuggestions, boundQuerySuggestionsOf, querySuggestionsOf };
@@ -0,0 +1,85 @@
1
+ import { fnv1a } from './chunk-KAKQ74LS.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
+
4
+ // src/persistence/durability/segment/layout.ts
5
+ var SEGMENT_ID_WIDTH = 16;
6
+ function manifestKey(indexName) {
7
+ return `${indexName}/manifest`;
8
+ }
9
+ function snapshotBundleKey(indexName) {
10
+ return `${indexName}/snapshot`;
11
+ }
12
+ function segmentPrefix(indexName, partitionId) {
13
+ return `${indexName}/segments/${partitionId}/`;
14
+ }
15
+ function segmentKey(indexName, partitionId, segmentId) {
16
+ return `${segmentPrefix(indexName, partitionId)}s${formatSegmentId(segmentId)}`;
17
+ }
18
+ function segmentsPrefix(indexName) {
19
+ return `${indexName}/segments/`;
20
+ }
21
+ function vectorFileKey(indexName, fieldPath, fileId) {
22
+ return `${segmentsPrefix(indexName)}vec-${encodeFieldPath(fieldPath)}-f${formatSegmentId(fileId)}`;
23
+ }
24
+ function requireGeneration(generation) {
25
+ if (Number.isSafeInteger(generation) && generation > 0) return;
26
+ throw new NarsilError(
27
+ ErrorCodes.PERSISTENCE_SAVE_FAILED,
28
+ `Vector graph generation ${generation} must be a positive integer`,
29
+ { generation }
30
+ );
31
+ }
32
+ function graphPartKey(indexName, fieldPath, generation, part) {
33
+ requireGeneration(generation);
34
+ return `${segmentsPrefix(indexName)}vec-${encodeFieldPath(fieldPath)}-graph-g${generation}-p${formatSegmentId(part)}`;
35
+ }
36
+ function formatSegmentId(segmentId) {
37
+ if (!Number.isInteger(segmentId) || segmentId < 0) {
38
+ throw new NarsilError(
39
+ ErrorCodes.PERSISTENCE_SAVE_FAILED,
40
+ `Segment id ${segmentId} must be a non-negative integer`,
41
+ { segmentId }
42
+ );
43
+ }
44
+ return segmentId.toString().padStart(SEGMENT_ID_WIDTH, "0");
45
+ }
46
+ var FIELD_PATH_PATTERN = /^[A-Za-z0-9_.]+$/;
47
+ function encodeFieldPath(fieldPath) {
48
+ if (!FIELD_PATH_PATTERN.test(fieldPath)) {
49
+ throw new NarsilError(
50
+ ErrorCodes.PERSISTENCE_SAVE_FAILED,
51
+ `Vector field path "${fieldPath}" contains characters that cannot be encoded in a segment key`,
52
+ { fieldPath }
53
+ );
54
+ }
55
+ const fingerprint = fnv1a(fieldPath).toString(36);
56
+ return `${fieldPath.replace(/\./g, "_")}-${fingerprint}`;
57
+ }
58
+
59
+ // src/persistence/durability/segment/manifest.ts
60
+ var SEGMENT_MANIFEST_VERSION = 7;
61
+ var EARLIER_SEGMENT_MANIFEST_VERSION = 6;
62
+ var MANIFEST_ENVELOPE_VERSION = 2;
63
+ var MAX_SEGMENTS_PER_PARTITION = 65536;
64
+ var MAX_SEGMENT_ID = 281474976710655;
65
+ function manifestReferencedKeys(manifest) {
66
+ const keys = /* @__PURE__ */ new Set();
67
+ for (const partition of manifest.partitions) {
68
+ for (const segment of partition.segments) {
69
+ keys.add(segment.key);
70
+ }
71
+ }
72
+ for (const vector of manifest.vectors) {
73
+ for (const file of vector.files) keys.add(file.key);
74
+ for (const part of vector.graphParts) keys.add(part.key);
75
+ }
76
+ return keys;
77
+ }
78
+ function manifestFileRefs(manifest) {
79
+ const refs = [];
80
+ for (const partition of manifest.partitions) refs.push(...partition.segments);
81
+ for (const vector of manifest.vectors) refs.push(...vector.files, ...vector.graphParts);
82
+ return refs;
83
+ }
84
+
85
+ export { EARLIER_SEGMENT_MANIFEST_VERSION, MANIFEST_ENVELOPE_VERSION, MAX_SEGMENTS_PER_PARTITION, MAX_SEGMENT_ID, SEGMENT_MANIFEST_VERSION, graphPartKey, manifestFileRefs, manifestKey, manifestReferencedKeys, segmentKey, segmentsPrefix, snapshotBundleKey, vectorFileKey };
@@ -1,4 +1,4 @@
1
- import { ReplicationMessageTypes } from './chunk-5QMHMELB.mjs';
1
+ import { ReplicationMessageTypes } from './chunk-5FLRXF73.mjs';
2
2
 
3
3
  // src/distribution/transport/reply-deadline.ts
4
4
  function replyDeadlineMs(messageType, config) {
@@ -1,11 +1,11 @@
1
- import { untagDocumentLine } from './chunk-NYSONUB7.mjs';
1
+ import { untagDocumentLine } from './chunk-TQXHPFWT.mjs';
2
+ import { restoredConfigFields, restoredEmbedding } from './chunk-INJYO3BU.mjs';
2
3
  import { chunksOf } from './chunk-CZQ33DLW.mjs';
3
- import { restoredConfigFields, restoredEmbedding } from './chunk-IRWP524D.mjs';
4
- import { requireConfigurationShape } from './chunk-2PNYKG2D.mjs';
5
4
  import { MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_IMPORT_REFUSALS_REPORTED } from './chunk-EEBCDP36.mjs';
5
+ import { requireConfigurationShape } from './chunk-GH4WQ22V.mjs';
6
+ import { flattenSchema } from './chunk-WQRN64Q6.mjs';
6
7
  import { turnsAreBudgeted, turnIsSpent, yieldTurn } from './chunk-LQG5G2LY.mjs';
7
- import { flattenSchema } from './chunk-SOUZMPME.mjs';
8
- import { NarsilError, ErrorCodes } from './chunk-MDF6PDIA.mjs';
8
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
9
9
 
10
10
  // src/engine/export/lines.ts
11
11
  var NEWLINE = 10;
@@ -0,0 +1,63 @@
1
+ import { attachedRuntimeOf } from './chunk-S5LN746F.mjs';
2
+ import { emitWriteEventAfter, dropEngineIndex } from './chunk-KMUNHGBQ.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
4
+
5
+ // src/query-suggestions/engine-hooks.ts
6
+ function suggestionIndexesOf(core, sourceName) {
7
+ const names = [];
8
+ for (const [name, entry] of core.indexRegistry) {
9
+ if (name !== sourceName && entry.querySuggestions?.querySuggestionsSource?.index === sourceName) names.push(name);
10
+ }
11
+ return names;
12
+ }
13
+ async function dropSuggestionIndexesOf(core, sourceName) {
14
+ if (core.mutationCtx.capacityScope === "partition") return;
15
+ for (const name of suggestionIndexesOf(core, sourceName)) {
16
+ if (!core.indexRegistry.has(name)) continue;
17
+ await emitWriteEventAfter(core, name, dropEngineIndex(core, name));
18
+ }
19
+ }
20
+ async function clearLeftoversOfName(core, name) {
21
+ if (core.mutationCtx.capacityScope === "partition") return;
22
+ await dropSuggestionIndexesOf(core, name);
23
+ await core.durability?.manager.removeQueryHistory?.(name);
24
+ }
25
+ function hooksOf(core) {
26
+ return {
27
+ async beforeCreate(indexName) {
28
+ await clearLeftoversOfName(core, indexName);
29
+ if (core.indexRegistry.has(indexName)) {
30
+ throw new NarsilError(ErrorCodes.INDEX_ALREADY_EXISTS, `Index "${indexName}" already exists`, { indexName });
31
+ }
32
+ },
33
+ beforeDrop: (indexName) => dropSuggestionIndexesOf(core, indexName),
34
+ async afterDrop(indexName) {
35
+ await attachedRuntimeOf(core)?.onDrop(indexName);
36
+ },
37
+ async shutdown() {
38
+ await attachedRuntimeOf(core)?.stop().catch(() => void 0);
39
+ }
40
+ };
41
+ }
42
+ function installSuggestionHooks(core) {
43
+ core.querySuggestionHooks ??= hooksOf(core);
44
+ }
45
+ function holdsEnabledSetting(core) {
46
+ for (const entry of core.indexRegistry.values()) {
47
+ if (entry.querySuggestions?.querySuggestions?.enabled === true) return true;
48
+ }
49
+ return false;
50
+ }
51
+ async function startQuerySuggestions(core, engine, config) {
52
+ installSuggestionHooks(core);
53
+ if (config?.querySuggestions === void 0 && !holdsEnabledSetting(core)) return;
54
+ try {
55
+ const { localRuntimeOf } = await import('./start-UTWHGH42.mjs');
56
+ await localRuntimeOf(core, engine, config);
57
+ } catch (error) {
58
+ await engine.shutdown().catch(() => void 0);
59
+ throw error;
60
+ }
61
+ }
62
+
63
+ export { clearLeftoversOfName, dropSuggestionIndexesOf, installSuggestionHooks, startQuerySuggestions };
@@ -0,0 +1,74 @@
1
+ import { ARCHIVE_CONFIG_ENTRY, ARCHIVE_MANIFEST_ENTRY, tarEntryHeaders, tarPadding, tarEnd, ARCHIVE_ENTRY_ESTIMATE_BYTES, ARCHIVE_FILE_CHUNK_BYTES } from './chunk-U4BS74YN.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
+
4
+ // src/persistence/archive/range-layout.ts
5
+ function archiveLayout(config, manifestBytes, files) {
6
+ const parts = [];
7
+ let at = 0;
8
+ const inline = (bytes) => {
9
+ if (bytes.byteLength === 0) return;
10
+ parts.push({ start: at, length: bytes.byteLength, inline: bytes });
11
+ at += bytes.byteLength;
12
+ };
13
+ for (const [name, bytes] of [
14
+ [ARCHIVE_CONFIG_ENTRY, config],
15
+ [ARCHIVE_MANIFEST_ENTRY, manifestBytes]
16
+ ]) {
17
+ for (const header of tarEntryHeaders(name, bytes.byteLength)) inline(header);
18
+ inline(bytes);
19
+ inline(tarPadding(bytes.byteLength));
20
+ }
21
+ for (const file of files) {
22
+ for (const header of tarEntryHeaders(file.name, file.bytes)) inline(header);
23
+ if (file.bytes > 0) {
24
+ parts.push({ start: at, length: file.bytes, file });
25
+ at += file.bytes;
26
+ }
27
+ inline(tarPadding(file.bytes));
28
+ }
29
+ inline(tarEnd());
30
+ return { parts, byteLength: at };
31
+ }
32
+ function estimatedArchiveBytes(files) {
33
+ let total = 0;
34
+ for (const file of files) total += file.bytes + ARCHIVE_ENTRY_ESTIMATE_BYTES;
35
+ return total;
36
+ }
37
+ function firstPartAt(parts, offset) {
38
+ let low = 0;
39
+ let high = parts.length - 1;
40
+ while (low < high) {
41
+ const middle = low + high + 1 >>> 1;
42
+ if (parts[middle].start <= offset) low = middle;
43
+ else high = middle - 1;
44
+ }
45
+ return low;
46
+ }
47
+ async function* archiveRange(layout, start, endExclusive) {
48
+ const end = Math.min(endExclusive, layout.byteLength);
49
+ if (start >= end) return;
50
+ for (let index = firstPartAt(layout.parts, start); index < layout.parts.length; index++) {
51
+ const part = layout.parts[index];
52
+ if (part.start >= end) return;
53
+ const from = Math.max(start, part.start) - part.start;
54
+ const to = Math.min(end, part.start + part.length) - part.start;
55
+ if ("inline" in part) {
56
+ yield part.inline.subarray(from, to);
57
+ continue;
58
+ }
59
+ for (let offset = from; offset < to; offset += ARCHIVE_FILE_CHUNK_BYTES) {
60
+ const length = Math.min(ARCHIVE_FILE_CHUNK_BYTES, to - offset);
61
+ const bytes = await part.file.read(offset, length);
62
+ if (bytes.byteLength !== length) {
63
+ throw new NarsilError(
64
+ ErrorCodes.PERSISTENCE_LOAD_FAILED,
65
+ `The archive file "${part.file.name}" ends before the bytes that its manifest lists`,
66
+ { name: part.file.name, offset, length }
67
+ );
68
+ }
69
+ yield bytes;
70
+ }
71
+ }
72
+ }
73
+
74
+ export { archiveLayout, archiveRange, estimatedArchiveBytes };
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from './chunk-MDF6PDIA.mjs';
1
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
2
2
  import { existsSync } from 'fs';
3
3
  import { createRequire } from 'module';
4
4
  import { join, dirname } from 'path';
@@ -0,0 +1,23 @@
1
+ // src/persistence/durability/constants.ts
2
+ var DEFAULT_CHECKPOINT_INTERVAL_MS = 3e5;
3
+ var DEFAULT_CHECKPOINT_MUTATION_THRESHOLD = 1e5;
4
+ var DEFAULT_ASYNC_FLUSH_INTERVAL_MS = 1e3;
5
+ var DIRECTORY_IDENTITY_CHECK_INTERVAL_MS = 1e3;
6
+ var DIRECTORY_LOCK_ATTEMPTS = 3;
7
+ var DIRECTORY_LOCK_SETTLE_MS = 50;
8
+ var DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS = 1e3;
9
+ var DEFAULT_SEGMENT_MAX_BYTES = 67108864;
10
+ var DEFAULT_COMPACTION_THRESHOLD = 12;
11
+ var COMPACTION_LARGEST_MERGED_DOCUMENT_COUNT = 2e5;
12
+ var SEGMENT_FILE_FRAMING_SLACK_BYTES = 65536;
13
+ var SEGMENT_TOKEN_TABLE_SHARE_OF_FILE = 0.25;
14
+ var WHOLE_PARTITION_MIN_CHANGED_SHARE = 0.5;
15
+ var WHOLE_PARTITION_LARGEST_DOCUMENT_COUNT = 1e5;
16
+ var LOG_RECORDS_PER_CHECKPOINT = 1e5;
17
+ var WRITES_STALL_ABOVE_UNCHECKPOINTED_BYTES = 2147483648;
18
+ var CHECKPOINT_WORKER_TIMEOUT_MS = 6e5;
19
+ var CHECKPOINT_WORKER_HEARTBEAT_MS = 5e3;
20
+ var CHECKPOINT_WORKER_IDLE_MS = 5e3;
21
+ var CHECKPOINT_TIMEOUT_RECOVERY_BACKOFF_MS = 50;
22
+
23
+ export { CHECKPOINT_TIMEOUT_RECOVERY_BACKOFF_MS, CHECKPOINT_WORKER_HEARTBEAT_MS, CHECKPOINT_WORKER_IDLE_MS, CHECKPOINT_WORKER_TIMEOUT_MS, COMPACTION_LARGEST_MERGED_DOCUMENT_COUNT, DEFAULT_ASYNC_FLUSH_INTERVAL_MS, DEFAULT_CHECKPOINT_INTERVAL_MS, DEFAULT_CHECKPOINT_MUTATION_THRESHOLD, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_SEGMENT_MAX_BYTES, DIRECTORY_IDENTITY_CHECK_INTERVAL_MS, DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS, DIRECTORY_LOCK_SETTLE_MS, LOG_RECORDS_PER_CHECKPOINT, SEGMENT_FILE_FRAMING_SLACK_BYTES, SEGMENT_TOKEN_TABLE_SHARE_OF_FILE, WHOLE_PARTITION_LARGEST_DOCUMENT_COUNT, WHOLE_PARTITION_MIN_CHANGED_SHARE, WRITES_STALL_ABOVE_UNCHECKPOINTED_BYTES };