@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,543 @@
1
+ import { dayFileKey, restoreStagingPrefix, restoredFileKey, listHistoryFolder, historyFileOf } from './chunk-KP7TYHWT.mjs';
2
+ import { resolveSetting } from './chunk-H4KHPLHJ.mjs';
3
+ import { openCountsFile, encodeCountsFile } from './chunk-6L3XJXGU.mjs';
4
+ import { DAY_MS, SCRAMBLED_ID_BYTES, QUERY_HISTORY_ARCHIVE_PREFIX, MIN_PHRASE_TABLE_CAPACITY, PERSON_TABLE_MIN_SLOTS, PAIR_PAGE_BLOCKS, PAIR_BLOCK_SLOTS } from './chunk-5YNRKI2C.mjs';
5
+
6
+ // src/query-suggestions/day-counts.ts
7
+ var EMPTY_SLOT = -1;
8
+ var NO_BLOCK = -1;
9
+ function nextPowerOfTwo(value) {
10
+ let power = 1;
11
+ while (power < value) power *= 2;
12
+ return power;
13
+ }
14
+ function idsEqual(left, leftOffset, right, rightOffset) {
15
+ for (let i = 0; i < SCRAMBLED_ID_BYTES; i++) {
16
+ if (left[leftOffset + i] !== right[rightOffset + i]) return false;
17
+ }
18
+ return true;
19
+ }
20
+ function hashOfId(id, offset) {
21
+ return (id[offset] | id[offset + 1] << 8 | id[offset + 2] << 16 | id[offset + 3] << 24) >>> 0;
22
+ }
23
+ var DayCounts = class {
24
+ day;
25
+ limits;
26
+ groups = /* @__PURE__ */ new Map();
27
+ phraseCount = 0;
28
+ phraseTexts = [];
29
+ phraseGroups = [];
30
+ phraseCounts = new Uint32Array(0);
31
+ phrasePeopleLengths = new Uint16Array(0);
32
+ phrasePeople = new Uint8Array(0);
33
+ personCount = 0;
34
+ personIds = new Uint8Array(0);
35
+ personPairs = new Uint16Array(0);
36
+ personHeads = new Int32Array(0);
37
+ personTails = new Int32Array(0);
38
+ personSlots = new Int32Array(0);
39
+ pairPages = [];
40
+ linkPages = [];
41
+ blockCount = 0;
42
+ changed = false;
43
+ constructor(day, limits) {
44
+ this.day = day;
45
+ this.limits = limits;
46
+ }
47
+ get phrases() {
48
+ return this.phraseCount;
49
+ }
50
+ get people() {
51
+ return this.personCount;
52
+ }
53
+ get groupNames() {
54
+ return this.groups.keys();
55
+ }
56
+ get isChanged() {
57
+ return this.changed;
58
+ }
59
+ markSaved() {
60
+ this.changed = false;
61
+ }
62
+ markChanged() {
63
+ this.changed = true;
64
+ }
65
+ get groupTables() {
66
+ return this.groups;
67
+ }
68
+ get peopleBytes() {
69
+ return this.phrasePeople;
70
+ }
71
+ countOf(phraseNumber) {
72
+ return this.phraseCounts[phraseNumber];
73
+ }
74
+ peopleLengthOf(phraseNumber) {
75
+ return this.phrasePeopleLengths[phraseNumber];
76
+ }
77
+ peopleOffsetOf(phraseNumber) {
78
+ return phraseNumber * this.limits.minPeople * SCRAMBLED_ID_BYTES;
79
+ }
80
+ hasGroup(group) {
81
+ return this.groups.has(group);
82
+ }
83
+ count(group, phrase, scrambledId, groupAllowed) {
84
+ const groupPhrases = this.groups.get(group);
85
+ const existingPhrase = groupPhrases?.get(phrase);
86
+ const person = this.findPerson(scrambledId);
87
+ if (person !== EMPTY_SLOT && existingPhrase !== void 0 && this.personHasPhrase(person, existingPhrase)) {
88
+ return "repeat";
89
+ }
90
+ if (person !== EMPTY_SLOT && this.personPairs[person] >= this.limits.maxPhrasesPerPerson) return "person-limit";
91
+ if (existingPhrase === void 0 && this.phraseCount >= this.limits.maxPhrasesPerDay) return "phrase-limit";
92
+ if (person === EMPTY_SLOT && this.personCount >= this.limits.maxPeoplePerDay) return "people-limit";
93
+ if (groupPhrases === void 0 && (!groupAllowed || this.groups.size >= this.limits.maxGroups)) {
94
+ return "group-limit";
95
+ }
96
+ const phraseNumber = existingPhrase ?? this.addPhrase(group, phrase, groupPhrases);
97
+ const personNumber = person === EMPTY_SLOT ? this.addPerson(scrambledId) : person;
98
+ this.appendPair(personNumber, phraseNumber);
99
+ this.phraseCounts[phraseNumber] += 1;
100
+ this.addToPeople(phraseNumber, scrambledId, 0);
101
+ this.changed = true;
102
+ return "recorded";
103
+ }
104
+ restorePhrase(group, phrase, count, people, peopleCount) {
105
+ const groupPhrases = this.groups.get(group);
106
+ if (groupPhrases?.has(phrase) === true) return false;
107
+ if (this.phraseCount >= this.limits.maxPhrasesPerDay) return false;
108
+ if (groupPhrases === void 0 && this.groups.size >= this.limits.maxGroups) return false;
109
+ const phraseNumber = this.addPhrase(group, phrase, groupPhrases);
110
+ for (let i = 0; i < peopleCount; i++) this.addToPeople(phraseNumber, people, i * SCRAMBLED_ID_BYTES);
111
+ this.phraseCounts[phraseNumber] = Math.max(count, this.phrasePeopleLengths[phraseNumber]);
112
+ return true;
113
+ }
114
+ addPhrase(group, phrase, existing) {
115
+ const groupPhrases = existing ?? /* @__PURE__ */ new Map();
116
+ if (existing === void 0) this.groups.set(group, groupPhrases);
117
+ if (this.phraseCount === this.phraseCounts.length) this.growPhrases();
118
+ const number = this.phraseCount;
119
+ this.phraseCount += 1;
120
+ groupPhrases.set(phrase, number);
121
+ this.phraseTexts.push(phrase);
122
+ this.phraseGroups.push(group);
123
+ return number;
124
+ }
125
+ growPhrases() {
126
+ const capacity = Math.min(
127
+ this.limits.maxPhrasesPerDay,
128
+ Math.max(MIN_PHRASE_TABLE_CAPACITY, this.phraseCounts.length * 2)
129
+ );
130
+ const counts = new Uint32Array(capacity);
131
+ counts.set(this.phraseCounts);
132
+ this.phraseCounts = counts;
133
+ const lengths = new Uint16Array(capacity);
134
+ lengths.set(this.phrasePeopleLengths);
135
+ this.phrasePeopleLengths = lengths;
136
+ const people = new Uint8Array(capacity * this.limits.minPeople * SCRAMBLED_ID_BYTES);
137
+ people.set(this.phrasePeople);
138
+ this.phrasePeople = people;
139
+ }
140
+ addToPeople(phraseNumber, id, idOffset) {
141
+ const length = this.phrasePeopleLengths[phraseNumber];
142
+ if (length >= this.limits.minPeople) return;
143
+ const base = phraseNumber * this.limits.minPeople * SCRAMBLED_ID_BYTES;
144
+ for (let i = 0; i < length; i++) {
145
+ if (idsEqual(this.phrasePeople, base + i * SCRAMBLED_ID_BYTES, id, idOffset)) return;
146
+ }
147
+ this.phrasePeople.set(id.subarray(idOffset, idOffset + SCRAMBLED_ID_BYTES), base + length * SCRAMBLED_ID_BYTES);
148
+ this.phrasePeopleLengths[phraseNumber] = length + 1;
149
+ }
150
+ findPerson(id) {
151
+ if (this.personSlots.length === 0) return EMPTY_SLOT;
152
+ const mask = this.personSlots.length - 1;
153
+ let slot = hashOfId(id, 0) & mask;
154
+ for (; ; ) {
155
+ const person = this.personSlots[slot];
156
+ if (person === EMPTY_SLOT) return EMPTY_SLOT;
157
+ if (idsEqual(this.personIds, person * SCRAMBLED_ID_BYTES, id, 0)) return person;
158
+ slot = slot + 1 & mask;
159
+ }
160
+ }
161
+ addPerson(id) {
162
+ if (this.personCount === this.personPairs.length) this.growPeople();
163
+ const person = this.personCount;
164
+ this.personCount += 1;
165
+ this.personIds.set(id.subarray(0, SCRAMBLED_ID_BYTES), person * SCRAMBLED_ID_BYTES);
166
+ this.personHeads[person] = NO_BLOCK;
167
+ this.personTails[person] = NO_BLOCK;
168
+ this.insertSlot(person);
169
+ return person;
170
+ }
171
+ insertSlot(person) {
172
+ const mask = this.personSlots.length - 1;
173
+ let slot = hashOfId(this.personIds, person * SCRAMBLED_ID_BYTES) & mask;
174
+ while (this.personSlots[slot] !== EMPTY_SLOT) slot = slot + 1 & mask;
175
+ this.personSlots[slot] = person;
176
+ }
177
+ growPeople() {
178
+ const capacity = Math.min(
179
+ this.limits.maxPeoplePerDay,
180
+ Math.max(PERSON_TABLE_MIN_SLOTS / 2, this.personPairs.length * 2)
181
+ );
182
+ const ids = new Uint8Array(capacity * SCRAMBLED_ID_BYTES);
183
+ ids.set(this.personIds);
184
+ this.personIds = ids;
185
+ const pairs = new Uint16Array(capacity);
186
+ pairs.set(this.personPairs);
187
+ this.personPairs = pairs;
188
+ const heads = new Int32Array(capacity);
189
+ heads.set(this.personHeads);
190
+ this.personHeads = heads;
191
+ const tails = new Int32Array(capacity);
192
+ tails.set(this.personTails);
193
+ this.personTails = tails;
194
+ this.personSlots = new Int32Array(nextPowerOfTwo(capacity * 2)).fill(EMPTY_SLOT);
195
+ for (let person = 0; person < this.personCount; person++) this.insertSlot(person);
196
+ }
197
+ personHasPhrase(person, phraseNumber) {
198
+ let remaining = this.personPairs[person];
199
+ let block = this.personHeads[person];
200
+ while (block !== NO_BLOCK && remaining > 0) {
201
+ const page = this.pairPages[Math.floor(block / PAIR_PAGE_BLOCKS)];
202
+ const start = block % PAIR_PAGE_BLOCKS * PAIR_BLOCK_SLOTS;
203
+ const used = Math.min(remaining, PAIR_BLOCK_SLOTS);
204
+ for (let i = 0; i < used; i++) {
205
+ if (page[start + i] === phraseNumber) return true;
206
+ }
207
+ remaining -= used;
208
+ block = this.linkPages[Math.floor(block / PAIR_PAGE_BLOCKS)][block % PAIR_PAGE_BLOCKS];
209
+ }
210
+ return false;
211
+ }
212
+ appendPair(person, phraseNumber) {
213
+ const pairs = this.personPairs[person];
214
+ const slot = pairs % PAIR_BLOCK_SLOTS;
215
+ let block = this.personTails[person];
216
+ if (slot === 0) {
217
+ const fresh = this.allocateBlock();
218
+ if (block === NO_BLOCK) this.personHeads[person] = fresh;
219
+ else this.linkPages[Math.floor(block / PAIR_PAGE_BLOCKS)][block % PAIR_PAGE_BLOCKS] = fresh;
220
+ this.personTails[person] = fresh;
221
+ block = fresh;
222
+ }
223
+ const page = this.pairPages[Math.floor(block / PAIR_PAGE_BLOCKS)];
224
+ page[block % PAIR_PAGE_BLOCKS * PAIR_BLOCK_SLOTS + slot] = phraseNumber;
225
+ this.personPairs[person] = pairs + 1;
226
+ }
227
+ allocateBlock() {
228
+ const block = this.blockCount;
229
+ if (block % PAIR_PAGE_BLOCKS === 0) {
230
+ this.pairPages.push(new Uint16Array(PAIR_PAGE_BLOCKS * PAIR_BLOCK_SLOTS));
231
+ this.linkPages.push(new Int32Array(PAIR_PAGE_BLOCKS).fill(NO_BLOCK));
232
+ }
233
+ this.blockCount += 1;
234
+ return block;
235
+ }
236
+ };
237
+
238
+ // src/query-suggestions/history-groups.ts
239
+ var HistoryGroups = class {
240
+ host;
241
+ fingerprint;
242
+ held = /* @__PURE__ */ new Map();
243
+ constructor(host, fingerprint) {
244
+ this.host = host;
245
+ this.fingerprint = fingerprint;
246
+ }
247
+ async of(indexName, cutoff) {
248
+ const held = this.held.get(indexName);
249
+ if (held !== void 0 && held.cutoff <= cutoff) {
250
+ if (held.cutoff < cutoff) {
251
+ for (const [group, day] of held.newestDay) if (day < cutoff) held.newestDay.delete(group);
252
+ held.cutoff = cutoff;
253
+ }
254
+ return held.newestDay.keys();
255
+ }
256
+ const newestDay = await this.load(indexName, cutoff);
257
+ this.held.set(indexName, { cutoff, newestDay });
258
+ return newestDay.keys();
259
+ }
260
+ note(indexName, day, groups) {
261
+ const held = this.held.get(indexName);
262
+ if (held === void 0 || day < held.cutoff) return;
263
+ for (const group of groups) {
264
+ const newest = held.newestDay.get(group);
265
+ if (newest === void 0 || newest < day) held.newestDay.set(group, day);
266
+ }
267
+ }
268
+ forget(indexName) {
269
+ this.held.delete(indexName);
270
+ }
271
+ async load(indexName, cutoff) {
272
+ const newestDay = /* @__PURE__ */ new Map();
273
+ const expectedUuid = this.host.view(indexName)?.indexUuid ?? null;
274
+ for (const key of await listHistoryFolder(this.host.files, indexName)) {
275
+ const file = historyFileOf(indexName, key);
276
+ if (file === null || file.day < cutoff) continue;
277
+ const bytes = await this.host.files.read(key);
278
+ if (!(bytes instanceof Uint8Array)) continue;
279
+ const opened = await openCountsFile(bytes, file.day, this.fingerprint);
280
+ if (opened.kind !== "counts") continue;
281
+ if (this.host.clustered && (opened.indexUuid === null || opened.indexUuid !== expectedUuid)) continue;
282
+ for (const group of opened.groupNames()) {
283
+ const newest = newestDay.get(group);
284
+ if (newest === void 0 || newest < file.day) newestDay.set(group, file.day);
285
+ }
286
+ }
287
+ return newestDay;
288
+ }
289
+ };
290
+
291
+ // src/query-suggestions/day-store.ts
292
+ function dayOf(instant) {
293
+ return new Date(instant).toISOString().slice(0, 10);
294
+ }
295
+ function limitsOf(setting) {
296
+ return {
297
+ minPeople: setting.minPeople,
298
+ maxPhrasesPerDay: setting.maxPhrasesPerDay,
299
+ maxPhrasesPerPerson: setting.maxPhrasesPerPerson,
300
+ maxPeoplePerDay: setting.maxPeoplePerDay,
301
+ maxGroups: setting.maxGroups
302
+ };
303
+ }
304
+ function sameLimits(left, right) {
305
+ return left.minPeople === right.minPeople && left.maxPhrasesPerDay === right.maxPhrasesPerDay && left.maxPhrasesPerPerson === right.maxPhrasesPerPerson && left.maxPeoplePerDay === right.maxPeoplePerDay && left.maxGroups === right.maxGroups;
306
+ }
307
+ var DayStore = class {
308
+ host;
309
+ scrambler;
310
+ history;
311
+ days = /* @__PURE__ */ new Map();
312
+ unsavedDays = /* @__PURE__ */ new Map();
313
+ turns = /* @__PURE__ */ new Map();
314
+ warnedLimits = /* @__PURE__ */ new Map();
315
+ generations = /* @__PURE__ */ new Map();
316
+ constructor(host, scrambler) {
317
+ this.host = host;
318
+ this.scrambler = scrambler;
319
+ this.history = new HistoryGroups(host, scrambler.fingerprint);
320
+ }
321
+ hasUnsaved(indexName) {
322
+ return this.days.get(indexName)?.isChanged === true || this.unsavedDays.has(indexName);
323
+ }
324
+ indexes() {
325
+ return [.../* @__PURE__ */ new Set([...this.days.keys(), ...this.unsavedDays.keys()])];
326
+ }
327
+ inTurn(indexName, work) {
328
+ const previous = this.turns.get(indexName) ?? Promise.resolve();
329
+ const next = previous.then(work, work);
330
+ const settled = next.catch(() => void 0);
331
+ this.turns.set(indexName, settled);
332
+ void settled.then(() => {
333
+ if (this.turns.get(indexName) === settled) this.turns.delete(indexName);
334
+ });
335
+ return next;
336
+ }
337
+ count(indexName, setting, now, request) {
338
+ return this.inTurn(indexName, async () => {
339
+ if (!request.stillEnabled()) return null;
340
+ if (request.isBanned()) return "banned";
341
+ const counts = await this.currentDay(indexName, setting, now);
342
+ const groupAllowed = counts.hasGroup(request.group) || request.groupAllowed(await this.knownGroups(indexName, counts, dayOf(now - setting.retentionDays * DAY_MS)));
343
+ const outcome = counts.count(request.group, request.phrase, this.scrambler.scramble(request.person), groupAllowed);
344
+ if (outcome === "phrase-limit" || outcome === "people-limit") this.warnLimit(indexName, counts.day, outcome);
345
+ return outcome;
346
+ });
347
+ }
348
+ save(indexName) {
349
+ return this.inTurn(indexName, () => this.saveNow(indexName));
350
+ }
351
+ retire(indexName, today) {
352
+ return this.inTurn(indexName, async () => {
353
+ await this.saveNow(indexName);
354
+ const counts = this.days.get(indexName);
355
+ if (counts === void 0 || counts.day >= today || counts.isChanged) return;
356
+ this.history.note(indexName, counts.day, counts.groupNames);
357
+ this.days.delete(indexName);
358
+ });
359
+ }
360
+ forgetHistoryGroups(indexName) {
361
+ return this.inTurn(indexName, async () => this.history.forget(indexName));
362
+ }
363
+ discard(indexName) {
364
+ return this.inTurn(indexName, async () => {
365
+ this.days.delete(indexName);
366
+ this.unsavedDays.delete(indexName);
367
+ this.history.forget(indexName);
368
+ this.warnedLimits.delete(indexName);
369
+ this.generations.set(indexName, (this.generations.get(indexName) ?? 0) + 1);
370
+ });
371
+ }
372
+ async knownGroups(indexName, counts, cutoff) {
373
+ const known = new Set(counts.groupNames);
374
+ for (const unsaved of this.unsavedDays.get(indexName) ?? []) {
375
+ for (const group of unsaved.groupNames) known.add(group);
376
+ }
377
+ for (const group of await this.history.of(indexName, cutoff)) known.add(group);
378
+ return known;
379
+ }
380
+ warnLimit(indexName, day, reason) {
381
+ const mark = `${day}:${reason}`;
382
+ const warned = this.warnedLimits.get(indexName) ?? "";
383
+ if (warned.split("|").includes(mark)) return;
384
+ this.warnedLimits.set(indexName, warned === "" ? mark : `${warned}|${mark}`);
385
+ this.host.emit("querySuggestionsWarning", { indexName, reason });
386
+ }
387
+ async currentDay(indexName, setting, now) {
388
+ const day = dayOf(now);
389
+ const limits = limitsOf(setting);
390
+ const current = this.days.get(indexName);
391
+ if (current !== void 0 && current.day === day && sameLimits(current.limits, limits)) return current;
392
+ if (current !== void 0) {
393
+ await this.saveNow(indexName);
394
+ if (current.isChanged) {
395
+ if (current.day === day) return current;
396
+ this.unsavedDays.set(indexName, [...this.unsavedDays.get(indexName) ?? [], current]);
397
+ }
398
+ this.history.note(indexName, current.day, current.groupNames);
399
+ this.days.delete(indexName);
400
+ }
401
+ const loaded = await this.load(indexName, day, limits);
402
+ this.days.set(indexName, loaded);
403
+ return loaded;
404
+ }
405
+ async load(indexName, day, limits) {
406
+ const counts = new DayCounts(day, limits);
407
+ const key = dayFileKey(indexName, day);
408
+ const bytes = await this.host.files.read(key);
409
+ if (bytes === null) return counts;
410
+ if (bytes === "too-long") {
411
+ this.host.emit("querySuggestionsWarning", { indexName, reason: "damaged-file", file: key });
412
+ return counts;
413
+ }
414
+ const opened = await openCountsFile(bytes, day, this.scrambler.fingerprint);
415
+ if (opened.kind !== "counts") {
416
+ const reason = opened.kind === "other-key" ? "other-key" : "damaged-file";
417
+ this.host.emit("querySuggestionsWarning", { indexName, reason, file: key });
418
+ return counts;
419
+ }
420
+ if (this.host.clustered && opened.indexUuid !== (this.host.view(indexName)?.indexUuid ?? null)) return counts;
421
+ opened.visit((group, phrase, count, people) => {
422
+ const ids = new Uint8Array(people.offsets.length * SCRAMBLED_ID_BYTES);
423
+ people.offsets.forEach((offset, i) => {
424
+ ids.set(people.source.subarray(offset, offset + SCRAMBLED_ID_BYTES), i * SCRAMBLED_ID_BYTES);
425
+ });
426
+ counts.restorePhrase(group, phrase, count, ids, people.offsets.length);
427
+ });
428
+ return counts;
429
+ }
430
+ async saveNow(indexName) {
431
+ const unsaved = this.unsavedDays.get(indexName);
432
+ if (unsaved !== void 0) {
433
+ const stillUnsaved = [];
434
+ for (const counts2 of unsaved) {
435
+ await this.write(indexName, counts2);
436
+ if (counts2.isChanged) stillUnsaved.push(counts2);
437
+ }
438
+ if (this.unsavedDays.get(indexName) === unsaved) {
439
+ if (stillUnsaved.length === 0) this.unsavedDays.delete(indexName);
440
+ else this.unsavedDays.set(indexName, stillUnsaved);
441
+ }
442
+ }
443
+ const counts = this.days.get(indexName);
444
+ if (counts !== void 0) await this.write(indexName, counts);
445
+ }
446
+ async write(indexName, counts) {
447
+ if (!counts.isChanged) return;
448
+ const generation = this.generations.get(indexName) ?? 0;
449
+ const view = this.host.view(indexName);
450
+ const bytes = encodeCountsFile(counts, {
451
+ fingerprint: this.scrambler.fingerprint,
452
+ savedAt: Date.now(),
453
+ indexUuid: this.host.clustered ? view?.indexUuid ?? null : null
454
+ });
455
+ counts.markSaved();
456
+ try {
457
+ if ((this.generations.get(indexName) ?? 0) !== generation) return;
458
+ await this.host.files.write(dayFileKey(indexName, counts.day), bytes);
459
+ } catch (error) {
460
+ counts.markChanged();
461
+ this.host.emit("querySuggestionsWarning", {
462
+ indexName,
463
+ reason: "save-failed",
464
+ message: error instanceof Error ? error.message : String(error)
465
+ });
466
+ }
467
+ }
468
+ };
469
+
470
+ // src/query-suggestions/restored-history.ts
471
+ async function collect(chunks) {
472
+ const parts = [];
473
+ let length = 0;
474
+ for await (const chunk of chunks) {
475
+ parts.push(chunk);
476
+ length += chunk.byteLength;
477
+ }
478
+ const bytes = new Uint8Array(length);
479
+ let offset = 0;
480
+ for (const part of parts) {
481
+ bytes.set(part, offset);
482
+ offset += part.byteLength;
483
+ }
484
+ return bytes;
485
+ }
486
+ var RestoredHistory = class {
487
+ runtime;
488
+ indexName;
489
+ cutoff;
490
+ prefix = restoreStagingPrefix();
491
+ staged = [];
492
+ received = 0;
493
+ constructor(runtime, indexName, setting) {
494
+ this.runtime = runtime;
495
+ this.indexName = indexName;
496
+ this.cutoff = dayOf(Date.now() - resolveSetting(setting).retentionDays * DAY_MS);
497
+ }
498
+ async add(chunks) {
499
+ const position = this.received;
500
+ this.received += 1;
501
+ const bytes = await collect(chunks);
502
+ const scrambler = this.runtime.scrambler;
503
+ if (scrambler === null) return;
504
+ const opened = await openCountsFile(bytes, null, scrambler.fingerprint);
505
+ if (opened.kind !== "counts") {
506
+ this.runtime.host.emit("querySuggestionsWarning", {
507
+ indexName: this.indexName,
508
+ reason: opened.kind === "other-key" ? "other-key" : "damaged-file",
509
+ file: `${QUERY_HISTORY_ARCHIVE_PREFIX}${position}`
510
+ });
511
+ return;
512
+ }
513
+ if (opened.day < this.cutoff) return;
514
+ const key = `${this.prefix}${position}.nrsl`;
515
+ const indexUuid = this.runtime.host.clustered ? this.runtime.host.view(this.indexName)?.indexUuid ?? null : null;
516
+ await this.runtime.host.files.write(key, opened.withIndexUuid(indexUuid, opened.savedAt));
517
+ this.staged.push({ key, day: opened.day });
518
+ }
519
+ async commit() {
520
+ if (this.received === 0) return;
521
+ const { files } = this.runtime.host;
522
+ await this.runtime.discardHistory(this.indexName);
523
+ const sequences = /* @__PURE__ */ new Map();
524
+ const ordered = [...this.staged].sort((left, right) => left.day < right.day ? -1 : left.day > right.day ? 1 : 0);
525
+ for (const file of ordered) {
526
+ const bytes = await files.read(file.key);
527
+ if (bytes instanceof Uint8Array) {
528
+ const sequence = sequences.get(file.day) ?? 0;
529
+ sequences.set(file.day, sequence + 1);
530
+ await files.write(restoredFileKey(this.indexName, file.day, sequence), bytes);
531
+ }
532
+ await files.remove(file.key);
533
+ }
534
+ this.staged.length = 0;
535
+ await this.runtime.days?.forgetHistoryGroups(this.indexName);
536
+ }
537
+ async abandon() {
538
+ for (const file of this.staged) await this.runtime.host.files.remove(file.key);
539
+ this.staged.length = 0;
540
+ }
541
+ };
542
+
543
+ export { DayStore, RestoredHistory, dayOf };
@@ -1,12 +1,12 @@
1
- import { osqCodeBytes, osqStagedQueryBytes, osqRecordBytes, unpackLevels, readTrailer, stageQueryLevels, writeRecord } from './chunk-37CD3OKS.mjs';
2
1
  import { stopUsingTheNativeSearchCore, nativeSearchCoreIsEnabled, noteFallback } from './chunk-DJHHF2L5.mjs';
2
+ import { osqCodeBytes, osqStagedQueryBytes, osqRecordBytes, unpackLevels, readTrailer, stageQueryLevels, writeRecord } from './chunk-37CD3OKS.mjs';
3
3
  import { markSimdUnavailable } from './chunk-KOKM4PQN.mjs';
4
- import { OSQ_STEPS, loadNativeCore, OSQ_GRID, OSQ_QUERY_BITS, NATIVE_OK, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ_PLACEMENT_QUERY_BITS, NATIVE_NEEDS_ROOM, OSQ_LAMBDA, NATIVE_GRAPH_NOT_HELD_ALONE } from './chunk-NVTFQFUL.mjs';
5
- import { turnsAreBudgeted, holdWrites, yieldBackgroundTurn, backgroundTurnIsSpent } from './chunk-LQG5G2LY.mjs';
4
+ import { OSQ_STEPS, loadNativeCore, OSQ_GRID, OSQ_QUERY_BITS, NATIVE_OK, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ_PLACEMENT_QUERY_BITS, NATIVE_NEEDS_ROOM, OSQ_LAMBDA, NATIVE_GRAPH_NOT_HELD_ALONE } from './chunk-Q7G3BV3Y.mjs';
6
5
  import { NATIVE_THREAD_SEARCH_SLOTS, VECTOR_SCRATCH_SLOTS, MAX_DOC_ID_TABLE_BYTES, MAX_VECTOR_ORDINALS, MAX_WASM_PAGES, WASM_PAGE_BYTES, UNPLACED_FLAG_CHUNK_ORDINALS, VECTOR_STORE_INITIAL_CAPACITY, VECTOR_BLOCK_INITIAL_SLOTS, NATIVE_ATTACH_RETRY_MS, LOCK_SPIN_ITERATIONS, LOCK_WAIT_SLICE_MS, GRAPH_LOCK_WAIT_SLICE_MS, GRAPH_LOCK_WAIT_DEADLINE_MS } from './chunk-BTPGQC6Z.mjs';
7
- import { threadSlotGone } from './chunk-RFBLQLLZ.mjs';
6
+ import { turnsAreBudgeted, holdWrites, yieldBackgroundTurn, backgroundTurnIsSpent } from './chunk-LQG5G2LY.mjs';
8
7
  import { DEFAULT_EF_SEARCH, COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, PLACEMENT_ROOM_REQUESTS, MAX_LAYER_CAP, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, CONNECT_RESTARTS_BEFORE_ONE_PASS, FARTHEST_REJECTED_LINKS_KEPT, CONNECT_STEPS_BETWEEN_CLOCK_CHECKS, NEAREST_LINK_FALLBACK_HOSTS } from './chunk-ZXX5GZEX.mjs';
9
- import { NarsilError, ErrorCodes } from './chunk-MDF6PDIA.mjs';
8
+ import { threadSlotGone } from './chunk-RFBLQLLZ.mjs';
9
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
10
10
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
11
11
 
12
12
  // src/vector/shared-buffers/memory-limits.ts
@@ -2016,6 +2016,7 @@ function writeKeepingLastLinks(state, ord, sorted, kept, held) {
2016
2016
 
2017
2017
  // src/vector/hnsw/nearest-links.ts
2018
2018
  var NOT_YET_FOUND = -2;
2019
+ var NOT_ANCHORED = -1;
2019
2020
  function nearer(a, b) {
2020
2021
  return nearerPair(a.distance, a.ord, b.distance, b.ord);
2021
2022
  }
@@ -2064,7 +2065,8 @@ function replaceableSlot(pass, host, list) {
2064
2065
  for (let i = 0; i < list.length; i++) {
2065
2066
  const neighbour = list[i];
2066
2067
  if (incomingCount(pass.state.adjacency, neighbour) < 2) continue;
2067
- if (isLive(pass.state, neighbour) && nearestInList(pass, neighbour) === host) continue;
2068
+ if (isLive(pass.state, neighbour) && (nearestInList(pass, neighbour) === host || pass.anchoredBy[neighbour] === host))
2069
+ continue;
2068
2070
  const distance = pass.distance(host, neighbour);
2069
2071
  if (farthest === -1 || nearerPair(farthestDistance, farthestOrd, distance, neighbour)) {
2070
2072
  farthest = i;
@@ -2079,12 +2081,16 @@ function linkFrom(pass, host, ord) {
2079
2081
  const base = layerBase(adjacency, host, 0);
2080
2082
  if (base === ABSENT) return false;
2081
2083
  const list = adjacency.level0.subarray(base + 1, base + 1 + adjacency.level0[base]);
2082
- if (list.includes(ord)) return true;
2084
+ if (list.includes(ord)) {
2085
+ pass.anchoredBy[ord] = host;
2086
+ return true;
2087
+ }
2083
2088
  if (list.length < pass.state.Mmax0) {
2084
2089
  adjacency.level0[base + list.length + 1] = ord;
2085
2090
  adjacency.level0[base] = list.length + 1;
2086
2091
  noteLinked(adjacency, ord);
2087
2092
  pass.nearest[host] = NOT_YET_FOUND;
2093
+ pass.anchoredBy[ord] = host;
2088
2094
  return true;
2089
2095
  }
2090
2096
  const slot = replaceableSlot(pass, host, list);
@@ -2094,6 +2100,7 @@ function linkFrom(pass, host, ord) {
2094
2100
  noteUnlinked(adjacency, replaced);
2095
2101
  noteLinked(adjacency, ord);
2096
2102
  pass.nearest[host] = NOT_YET_FOUND;
2103
+ pass.anchoredBy[ord] = host;
2097
2104
  return true;
2098
2105
  }
2099
2106
  function linkFromNearest(state) {
@@ -2106,7 +2113,8 @@ function* linkFromNearestSteps(state, pace) {
2106
2113
  const pass = {
2107
2114
  state,
2108
2115
  distance: nodeDistanceFunction(state, state.buildMetric),
2109
- nearest: new Int32Array(slots).fill(NOT_YET_FOUND)
2116
+ nearest: new Int32Array(slots).fill(NOT_YET_FOUND),
2117
+ anchoredBy: new Int32Array(slots).fill(NOT_ANCHORED)
2110
2118
  };
2111
2119
  for (let ord = 0; ord < slots; ord++) {
2112
2120
  if (stepTaken(pace)) yield;