@graphrefly/graphrefly 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/backoff-HPZMEZNF.js +1 -0
  2. package/dist/cascading-B-5zmAUv.d.cts +180 -0
  3. package/dist/cascading-D9WG1-9L.d.ts +180 -0
  4. package/dist/chunk-2FOAM3OR.js +1 -0
  5. package/dist/chunk-2PMCKKRK.js +1 -0
  6. package/dist/chunk-3JXNEPCD.js +2 -0
  7. package/dist/chunk-3R5HFPX7.js +78 -0
  8. package/dist/chunk-4GKB4OUJ.js +1 -0
  9. package/dist/chunk-4VVTGLXJ.js +1 -0
  10. package/dist/chunk-5QDBSZBV.js +1 -0
  11. package/dist/chunk-6QZNQS5B.js +1 -0
  12. package/dist/chunk-6V3SEX2I.js +1 -0
  13. package/dist/chunk-76A3HVQE.js +9 -0
  14. package/dist/chunk-7H6LGFUG.js +64 -0
  15. package/dist/chunk-CK2E7BTU.js +1 -0
  16. package/dist/chunk-CKCSDI7T.js +6 -0
  17. package/dist/chunk-CRXTH3SH.js +1 -0
  18. package/dist/chunk-CWLN3X3N.js +1 -0
  19. package/dist/chunk-D7A7DBE4.js +1 -0
  20. package/dist/chunk-DBGGMN3D.js +1 -0
  21. package/dist/chunk-DQA3UIQ2.js +1 -0
  22. package/dist/chunk-ERLIRFPA.js +1 -0
  23. package/dist/chunk-ESMPEKEV.js +1 -0
  24. package/dist/chunk-ETWTCCJI.js +1 -0
  25. package/dist/chunk-FNYWM6JC.js +1 -0
  26. package/dist/chunk-GHJJR5P4.js +1 -0
  27. package/dist/chunk-GPW2V3RE.js +1 -0
  28. package/dist/chunk-I6VIH3VA.js +1 -0
  29. package/dist/chunk-K2GNMCQT.js +1 -0
  30. package/dist/chunk-LBTDSCCO.js +3 -0
  31. package/dist/chunk-LQ3Y5NJS.js +1 -0
  32. package/dist/chunk-MIQTDPY4.js +5 -0
  33. package/dist/chunk-MTTAAPCK.js +1 -0
  34. package/dist/chunk-OAWLCNJJ.js +1 -0
  35. package/dist/chunk-OBKQQA5I.js +1 -0
  36. package/dist/chunk-OYHGKYQM.js +1 -0
  37. package/dist/chunk-PIOGHC63.js +1 -0
  38. package/dist/chunk-QWAPKG3O.js +2 -0
  39. package/dist/chunk-QYADASLV.js +1 -0
  40. package/dist/chunk-RHESUC3V.js +43 -0
  41. package/dist/chunk-S35VARIR.js +1 -0
  42. package/dist/chunk-SC3U7ETD.js +1 -0
  43. package/dist/chunk-U3AICJKU.js +1 -0
  44. package/dist/chunk-UMBIDLJ4.js +1 -0
  45. package/dist/chunk-UPHHLMHE.js +1 -0
  46. package/dist/chunk-UPXUCFMX.js +1 -0
  47. package/dist/chunk-UWJE5FQA.js +18 -0
  48. package/dist/chunk-V6YQICXZ.js +1 -0
  49. package/dist/chunk-VIMF6LGM.js +1 -0
  50. package/dist/chunk-VJLMUKOI.js +1 -0
  51. package/dist/chunk-VPYBOXVT.js +1 -0
  52. package/dist/chunk-VTPVOGHH.js +1 -0
  53. package/dist/chunk-WQ2BN6X6.js +1 -0
  54. package/dist/chunk-XAUNPIMX.js +1 -0
  55. package/dist/chunk-Y2EMPB3I.js +1 -0
  56. package/dist/chunk-Z4HDAS2Q.js +1 -0
  57. package/dist/chunk-ZB5EHBIO.js +1 -0
  58. package/dist/chunk-ZV2DXV5A.js +23 -0
  59. package/dist/compat/index.cjs +14 -7656
  60. package/dist/compat/index.d.cts +15 -14
  61. package/dist/compat/index.d.ts +15 -14
  62. package/dist/compat/index.js +1 -49
  63. package/dist/compat/jotai/index.cjs +1 -2048
  64. package/dist/compat/jotai/index.d.cts +2 -2
  65. package/dist/compat/jotai/index.d.ts +2 -2
  66. package/dist/compat/jotai/index.js +1 -9
  67. package/dist/compat/nanostores/index.cjs +1 -2175
  68. package/dist/compat/nanostores/index.d.cts +2 -2
  69. package/dist/compat/nanostores/index.d.ts +2 -2
  70. package/dist/compat/nanostores/index.js +1 -23
  71. package/dist/compat/nestjs/index.cjs +14 -6782
  72. package/dist/compat/nestjs/index.d.cts +7 -6
  73. package/dist/compat/nestjs/index.d.ts +7 -6
  74. package/dist/compat/nestjs/index.js +1 -82
  75. package/dist/compat/react/index.cjs +1 -141
  76. package/dist/compat/react/index.d.cts +2 -2
  77. package/dist/compat/react/index.d.ts +2 -2
  78. package/dist/compat/react/index.js +1 -12
  79. package/dist/compat/solid/index.cjs +1 -128
  80. package/dist/compat/solid/index.d.cts +2 -2
  81. package/dist/compat/solid/index.d.ts +2 -2
  82. package/dist/compat/solid/index.js +1 -12
  83. package/dist/compat/svelte/index.cjs +1 -131
  84. package/dist/compat/svelte/index.d.cts +2 -2
  85. package/dist/compat/svelte/index.d.ts +2 -2
  86. package/dist/compat/svelte/index.js +1 -12
  87. package/dist/compat/vue/index.cjs +1 -146
  88. package/dist/compat/vue/index.d.cts +2 -2
  89. package/dist/compat/vue/index.d.ts +2 -2
  90. package/dist/compat/vue/index.js +1 -12
  91. package/dist/compat/zustand/index.cjs +6 -4931
  92. package/dist/compat/zustand/index.d.cts +5 -5
  93. package/dist/compat/zustand/index.d.ts +5 -5
  94. package/dist/compat/zustand/index.js +1 -12
  95. package/dist/composite-B-xqw4Kk.d.cts +69 -0
  96. package/dist/composite-BhbKHbOS.d.ts +69 -0
  97. package/dist/core/index.cjs +1 -2271
  98. package/dist/core/index.d.cts +4 -3
  99. package/dist/core/index.d.ts +4 -3
  100. package/dist/core/index.js +1 -110
  101. package/dist/extra/browser.cjs +1 -0
  102. package/dist/extra/browser.d.cts +3 -0
  103. package/dist/extra/browser.d.ts +3 -0
  104. package/dist/extra/browser.js +1 -0
  105. package/dist/extra/index.cjs +23 -9971
  106. package/dist/extra/index.d.cts +13 -5
  107. package/dist/extra/index.d.ts +13 -5
  108. package/dist/extra/index.js +1 -375
  109. package/dist/extra/node.cjs +3 -0
  110. package/dist/extra/node.d.cts +81 -0
  111. package/dist/extra/node.d.ts +81 -0
  112. package/dist/extra/node.js +2 -0
  113. package/dist/extra/operators.cjs +1 -0
  114. package/dist/extra/operators.d.cts +910 -0
  115. package/dist/extra/operators.d.ts +910 -0
  116. package/dist/extra/operators.js +1 -0
  117. package/dist/extra/reactive.cjs +1 -0
  118. package/dist/extra/reactive.d.cts +352 -0
  119. package/dist/extra/reactive.d.ts +352 -0
  120. package/dist/extra/reactive.js +1 -0
  121. package/dist/extra/sources.cjs +1 -2486
  122. package/dist/extra/sources.d.cts +6 -2
  123. package/dist/extra/sources.d.ts +6 -2
  124. package/dist/extra/sources.js +1 -57
  125. package/dist/extra/storage-browser.cjs +1 -0
  126. package/dist/extra/storage-browser.d.cts +71 -0
  127. package/dist/extra/storage-browser.d.ts +71 -0
  128. package/dist/extra/storage-browser.js +1 -0
  129. package/dist/extra/storage-core.cjs +1 -0
  130. package/dist/extra/storage-core.d.cts +98 -0
  131. package/dist/extra/storage-core.d.ts +98 -0
  132. package/dist/extra/storage-core.js +1 -0
  133. package/dist/extra/storage-node.cjs +2 -0
  134. package/dist/extra/storage-node.d.cts +60 -0
  135. package/dist/extra/storage-node.d.ts +60 -0
  136. package/dist/extra/storage-node.js +1 -0
  137. package/dist/fallback-BaTS7vVY.d.cts +258 -0
  138. package/dist/fallback-eOm3LNxP.d.ts +258 -0
  139. package/dist/graph/index.cjs +6 -5030
  140. package/dist/graph/index.d.cts +6 -5
  141. package/dist/graph/index.d.ts +6 -5
  142. package/dist/graph/index.js +1 -50
  143. package/dist/{graph-6tZ5jEzr.d.cts → graph-BZGRXwOm.d.ts} +134 -31
  144. package/dist/{graph-DQ69XU0g.d.ts → graph-D48Qw9Cg.d.cts} +134 -31
  145. package/dist/index-8FSVk4Uf.d.ts +135 -0
  146. package/dist/index-9oDeHH2u.d.cts +291 -0
  147. package/dist/index-B0c4cmIO.d.ts +207 -0
  148. package/dist/{index-CDAjUFIv.d.ts → index-B1AmmSlb.d.ts} +1 -1
  149. package/dist/{index-Bd_fwmLf.d.cts → index-B2pwesl9.d.cts} +1 -1
  150. package/dist/index-BHvIquRZ.d.ts +1957 -0
  151. package/dist/{index-CPgZ5wRl.d.ts → index-BVHOrDwO.d.ts} +1 -1
  152. package/dist/{index-DrISNAOm.d.ts → index-BWJV63ti.d.ts} +1 -1
  153. package/dist/{index-B_IP40nB.d.cts → index-B_agccPe.d.cts} +1 -1
  154. package/dist/index-BgyGlizc.d.ts +163 -0
  155. package/dist/index-BpA5c4G9.d.ts +357 -0
  156. package/dist/index-BpIFjILY.d.cts +357 -0
  157. package/dist/{index-qldRdbQw.d.ts → index-Bqachn9_.d.ts} +1 -1
  158. package/dist/index-Btib9rsU.d.ts +607 -0
  159. package/dist/{index-BYOHF0zP.d.ts → index-BwM9BEkt.d.ts} +1 -1
  160. package/dist/index-BxJ86YZZ.d.cts +105 -0
  161. package/dist/index-C73n7lo-.d.cts +251 -0
  162. package/dist/index-CEXXwWVH.d.cts +192 -0
  163. package/dist/index-CHEswufn.d.cts +163 -0
  164. package/dist/{index-xdGjv0nO.d.ts → index-CMn8S8Hw.d.ts} +1 -1
  165. package/dist/{index-QBpffFW-.d.cts → index-CRO83MmV.d.cts} +1 -1
  166. package/dist/{index-BjI6ty9z.d.ts → index-CloUk1kY.d.ts} +9 -9
  167. package/dist/index-CpgYhnrG.d.ts +291 -0
  168. package/dist/{index-CUyrtuOf.d.cts → index-Cyojz0AE.d.cts} +1 -1
  169. package/dist/{demo-shell-DEp-nMTl.d.ts → index-CzobVSMr.d.ts} +14 -14
  170. package/dist/index-Czq6ynh8.d.ts +143 -0
  171. package/dist/index-D-YB-Vl3.d.ts +195 -0
  172. package/dist/index-DAlweici.d.ts +231 -0
  173. package/dist/index-DEwTb_fm.d.cts +1957 -0
  174. package/dist/{index-DFhjO4Gg.d.cts → index-DL-rYJrx.d.cts} +1 -1
  175. package/dist/index-DP4ZTkdw.d.ts +139 -0
  176. package/dist/{index-BeIdBfcb.d.cts → index-DUqMOlKZ.d.cts} +200 -2366
  177. package/dist/{index-Bxb5ZYc9.d.cts → index-D_NwnRYS.d.cts} +1 -1
  178. package/dist/index-DaLJvH8Z.d.ts +105 -0
  179. package/dist/index-DcXZBF5a.d.cts +135 -0
  180. package/dist/index-DfyOkTvs.d.ts +321 -0
  181. package/dist/{index-CmnuOibw.d.ts → index-DiOXyAwt.d.ts} +1 -1
  182. package/dist/index-DpHe5e0Q.d.ts +186 -0
  183. package/dist/index-DraikLjn.d.ts +86 -0
  184. package/dist/{index-BEfE8H_G.d.cts → index-DxsnAMWD.d.cts} +9 -9
  185. package/dist/index-DyxjtScX.d.cts +207 -0
  186. package/dist/index-HDpJe9hX.d.ts +251 -0
  187. package/dist/index-O6TgGUBV.d.cts +195 -0
  188. package/dist/{index-B4MP_8V_.d.cts → index-Oi8d8w4R.d.cts} +1 -1
  189. package/dist/{index-BW1z3BN9.d.ts → index-ROpQmGjE.d.ts} +30 -6
  190. package/dist/index-RukJ4DLS.d.cts +607 -0
  191. package/dist/{index-DdD5MVDL.d.ts → index-ZftwfxJM.d.ts} +200 -2366
  192. package/dist/{index-CuYwdKO-.d.ts → index-cByzxQIC.d.cts} +10 -195
  193. package/dist/index-dtN7YA2x.d.cts +143 -0
  194. package/dist/{index-C8mdwMXc.d.cts → index-fM6y00vT.d.cts} +30 -6
  195. package/dist/{index-_oMEWlDq.d.cts → index-m-yHof5p.d.ts} +10 -195
  196. package/dist/index-pXrDMpRO.d.cts +231 -0
  197. package/dist/index-rHJSKsU8.d.cts +186 -0
  198. package/dist/index-rX8HBM5h.d.cts +321 -0
  199. package/dist/{index-CUwyr1Kk.d.cts → index-rnwQly8X.d.cts} +147 -20
  200. package/dist/index-sm373fsH.d.ts +192 -0
  201. package/dist/index-tbf2gKHd.d.cts +139 -0
  202. package/dist/{demo-shell-26p5fVxn.d.cts → index-u15meRxL.d.cts} +14 -14
  203. package/dist/{index-eJ6T_qGM.d.ts → index-umtoWT8K.d.ts} +147 -20
  204. package/dist/index-vscRDkjW.d.cts +86 -0
  205. package/dist/index.cjs +150 -24142
  206. package/dist/index.d.cts +69 -3756
  207. package/dist/index.d.ts +69 -3756
  208. package/dist/index.js +1 -7292
  209. package/dist/{meta-C0-8XW6Q.d.cts → meta-Cgj6zeji.d.cts} +5 -5
  210. package/dist/{meta-BGqSZ7mt.d.ts → meta-CwesDrMD.d.ts} +5 -5
  211. package/dist/{node-C_IBuvX2.d.cts → node-Cc1TniY8.d.cts} +36 -9
  212. package/dist/{node-C_IBuvX2.d.ts → node-Cc1TniY8.d.ts} +36 -9
  213. package/dist/{observable-DCk45RH5.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
  214. package/dist/{observable-Crr1jgzx.d.cts → observable-glXQoGj2.d.cts} +1 -1
  215. package/dist/patterns/ai/browser.cjs +25 -0
  216. package/dist/patterns/ai/browser.d.cts +127 -0
  217. package/dist/patterns/ai/browser.d.ts +127 -0
  218. package/dist/patterns/ai/browser.js +3 -0
  219. package/dist/patterns/ai/index.cjs +91 -0
  220. package/dist/patterns/ai/index.d.cts +17 -0
  221. package/dist/patterns/ai/index.d.ts +17 -0
  222. package/dist/patterns/ai/index.js +1 -0
  223. package/dist/patterns/ai/node.cjs +2 -0
  224. package/dist/patterns/ai/node.d.cts +58 -0
  225. package/dist/patterns/ai/node.d.ts +58 -0
  226. package/dist/patterns/ai/node.js +1 -0
  227. package/dist/patterns/audit/index.cjs +6 -0
  228. package/dist/patterns/audit/index.d.cts +6 -0
  229. package/dist/patterns/audit/index.d.ts +6 -0
  230. package/dist/patterns/audit/index.js +1 -0
  231. package/dist/patterns/cqrs/index.cjs +6 -0
  232. package/dist/patterns/cqrs/index.d.cts +5 -0
  233. package/dist/patterns/cqrs/index.d.ts +5 -0
  234. package/dist/patterns/cqrs/index.js +1 -0
  235. package/dist/patterns/demo-shell/index.cjs +7 -0
  236. package/dist/patterns/demo-shell/index.d.cts +6 -0
  237. package/dist/patterns/demo-shell/index.d.ts +6 -0
  238. package/dist/patterns/demo-shell/index.js +1 -0
  239. package/dist/patterns/domain-templates/index.cjs +6 -0
  240. package/dist/patterns/domain-templates/index.d.cts +5 -0
  241. package/dist/patterns/domain-templates/index.d.ts +5 -0
  242. package/dist/patterns/domain-templates/index.js +1 -0
  243. package/dist/patterns/graphspec/index.cjs +83 -0
  244. package/dist/patterns/graphspec/index.d.cts +7 -0
  245. package/dist/patterns/graphspec/index.d.ts +7 -0
  246. package/dist/patterns/graphspec/index.js +1 -0
  247. package/dist/patterns/guarded-execution/index.cjs +6 -0
  248. package/dist/patterns/guarded-execution/index.d.cts +7 -0
  249. package/dist/patterns/guarded-execution/index.d.ts +7 -0
  250. package/dist/patterns/guarded-execution/index.js +1 -0
  251. package/dist/patterns/harness/index.cjs +48 -0
  252. package/dist/patterns/harness/index.d.cts +8 -0
  253. package/dist/patterns/harness/index.d.ts +8 -0
  254. package/dist/patterns/harness/index.js +1 -0
  255. package/dist/patterns/job-queue/index.cjs +6 -0
  256. package/dist/patterns/job-queue/index.d.cts +5 -0
  257. package/dist/patterns/job-queue/index.d.ts +5 -0
  258. package/dist/patterns/job-queue/index.js +1 -0
  259. package/dist/patterns/lens/index.cjs +6 -0
  260. package/dist/patterns/lens/index.d.cts +7 -0
  261. package/dist/patterns/lens/index.d.ts +7 -0
  262. package/dist/patterns/lens/index.js +1 -0
  263. package/dist/patterns/memory/index.cjs +6 -0
  264. package/dist/patterns/memory/index.d.cts +5 -0
  265. package/dist/patterns/memory/index.d.ts +5 -0
  266. package/dist/patterns/memory/index.js +1 -0
  267. package/dist/patterns/messaging/index.cjs +6 -0
  268. package/dist/patterns/messaging/index.d.cts +5 -0
  269. package/dist/patterns/messaging/index.d.ts +5 -0
  270. package/dist/patterns/messaging/index.js +1 -0
  271. package/dist/patterns/orchestration/index.cjs +6 -0
  272. package/dist/patterns/orchestration/index.d.cts +6 -0
  273. package/dist/patterns/orchestration/index.d.ts +6 -0
  274. package/dist/patterns/orchestration/index.js +1 -0
  275. package/dist/patterns/reactive-layout/index.cjs +7 -6444
  276. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  277. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  278. package/dist/patterns/reactive-layout/index.js +1 -56
  279. package/dist/patterns/reduction/index.cjs +6 -0
  280. package/dist/patterns/reduction/index.d.cts +5 -0
  281. package/dist/patterns/reduction/index.d.ts +5 -0
  282. package/dist/patterns/reduction/index.js +1 -0
  283. package/dist/patterns/refine-loop/index.cjs +8 -0
  284. package/dist/patterns/refine-loop/index.d.cts +7 -0
  285. package/dist/patterns/refine-loop/index.d.ts +7 -0
  286. package/dist/patterns/refine-loop/index.js +1 -0
  287. package/dist/patterns/resilient-pipeline/index.cjs +1 -0
  288. package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
  289. package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
  290. package/dist/patterns/resilient-pipeline/index.js +1 -0
  291. package/dist/patterns/surface/index.cjs +14 -0
  292. package/dist/patterns/surface/index.d.cts +8 -0
  293. package/dist/patterns/surface/index.d.ts +8 -0
  294. package/dist/patterns/surface/index.js +1 -0
  295. package/dist/{reactive-layout-BaOQefHu.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
  296. package/dist/{reactive-layout-D9gejYXE.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
  297. package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
  298. package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
  299. package/dist/reactive-map-CdbNoSgP.d.ts +238 -0
  300. package/dist/reactive-map-DUeRmb9d.d.cts +238 -0
  301. package/dist/resilience-Ba5-b4WD.d.cts +493 -0
  302. package/dist/resilience-CGRzhnD3.d.ts +493 -0
  303. package/dist/resilience-QAHKANT5.js +1 -0
  304. package/dist/sugar-BV0htudb.d.cts +205 -0
  305. package/dist/sugar-Dtyrq2_q.d.ts +205 -0
  306. package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
  307. package/dist/topology-tree-DROUdq5B.d.cts +25 -0
  308. package/dist/types-O3GzJY2U.d.cts +401 -0
  309. package/dist/types-u64Ose53.d.ts +401 -0
  310. package/package.json +267 -7
  311. package/dist/chunk-3ZWCKRHX.js +0 -117
  312. package/dist/chunk-3ZWCKRHX.js.map +0 -1
  313. package/dist/chunk-6LDQFTYS.js +0 -102
  314. package/dist/chunk-6LDQFTYS.js.map +0 -1
  315. package/dist/chunk-7TAQJHQV.js +0 -103
  316. package/dist/chunk-7TAQJHQV.js.map +0 -1
  317. package/dist/chunk-AMCG74RZ.js +0 -7000
  318. package/dist/chunk-AMCG74RZ.js.map +0 -1
  319. package/dist/chunk-BVZYTZ5H.js +0 -599
  320. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  321. package/dist/chunk-FQMKGR6L.js +0 -330
  322. package/dist/chunk-FQMKGR6L.js.map +0 -1
  323. package/dist/chunk-HXZEYDUR.js +0 -94
  324. package/dist/chunk-HXZEYDUR.js.map +0 -1
  325. package/dist/chunk-IZYUSJC7.js +0 -1369
  326. package/dist/chunk-IZYUSJC7.js.map +0 -1
  327. package/dist/chunk-J22W6HV3.js +0 -107
  328. package/dist/chunk-J22W6HV3.js.map +0 -1
  329. package/dist/chunk-JSCT3CR4.js +0 -38
  330. package/dist/chunk-JSCT3CR4.js.map +0 -1
  331. package/dist/chunk-JYXEWPH4.js +0 -62
  332. package/dist/chunk-JYXEWPH4.js.map +0 -1
  333. package/dist/chunk-LCE3GF5P.js +0 -866
  334. package/dist/chunk-LCE3GF5P.js.map +0 -1
  335. package/dist/chunk-MJ2NKQQL.js +0 -119
  336. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  337. package/dist/chunk-N6UR7YVY.js +0 -198
  338. package/dist/chunk-N6UR7YVY.js.map +0 -1
  339. package/dist/chunk-OHISZPOJ.js +0 -97
  340. package/dist/chunk-OHISZPOJ.js.map +0 -1
  341. package/dist/chunk-PHOUUNK7.js +0 -2291
  342. package/dist/chunk-PHOUUNK7.js.map +0 -1
  343. package/dist/chunk-RB6QPHJ7.js +0 -393
  344. package/dist/chunk-RB6QPHJ7.js.map +0 -1
  345. package/dist/chunk-SN4YWWYO.js +0 -171
  346. package/dist/chunk-SN4YWWYO.js.map +0 -1
  347. package/dist/chunk-SX52TAR4.js +0 -110
  348. package/dist/chunk-SX52TAR4.js.map +0 -1
  349. package/dist/chunk-THTWHNU4.js +0 -2712
  350. package/dist/chunk-THTWHNU4.js.map +0 -1
  351. package/dist/chunk-VYPWMZ6H.js +0 -98
  352. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  353. package/dist/chunk-XGPU467M.js +0 -136
  354. package/dist/chunk-XGPU467M.js.map +0 -1
  355. package/dist/chunk-ZQMEI34O.js +0 -713
  356. package/dist/chunk-ZQMEI34O.js.map +0 -1
  357. package/dist/compat/index.cjs.map +0 -1
  358. package/dist/compat/index.js.map +0 -1
  359. package/dist/compat/jotai/index.cjs.map +0 -1
  360. package/dist/compat/jotai/index.js.map +0 -1
  361. package/dist/compat/nanostores/index.cjs.map +0 -1
  362. package/dist/compat/nanostores/index.js.map +0 -1
  363. package/dist/compat/nestjs/index.cjs.map +0 -1
  364. package/dist/compat/nestjs/index.js.map +0 -1
  365. package/dist/compat/react/index.cjs.map +0 -1
  366. package/dist/compat/react/index.js.map +0 -1
  367. package/dist/compat/solid/index.cjs.map +0 -1
  368. package/dist/compat/solid/index.js.map +0 -1
  369. package/dist/compat/svelte/index.cjs.map +0 -1
  370. package/dist/compat/svelte/index.js.map +0 -1
  371. package/dist/compat/vue/index.cjs.map +0 -1
  372. package/dist/compat/vue/index.js.map +0 -1
  373. package/dist/compat/zustand/index.cjs.map +0 -1
  374. package/dist/compat/zustand/index.js.map +0 -1
  375. package/dist/core/index.cjs.map +0 -1
  376. package/dist/core/index.js.map +0 -1
  377. package/dist/extra/index.cjs.map +0 -1
  378. package/dist/extra/index.js.map +0 -1
  379. package/dist/extra/sources.cjs.map +0 -1
  380. package/dist/extra/sources.js.map +0 -1
  381. package/dist/graph/index.cjs.map +0 -1
  382. package/dist/graph/index.js.map +0 -1
  383. package/dist/index-C0ZXMaXO.d.cts +0 -392
  384. package/dist/index-CY2TljO4.d.ts +0 -392
  385. package/dist/index.cjs.map +0 -1
  386. package/dist/index.js.map +0 -1
  387. package/dist/patterns/demo-shell.cjs +0 -5604
  388. package/dist/patterns/demo-shell.cjs.map +0 -1
  389. package/dist/patterns/demo-shell.d.cts +0 -6
  390. package/dist/patterns/demo-shell.d.ts +0 -6
  391. package/dist/patterns/demo-shell.js +0 -15
  392. package/dist/patterns/demo-shell.js.map +0 -1
  393. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  394. package/dist/patterns/reactive-layout/index.js.map +0 -1
  395. package/dist/storage-BMycWEh2.d.ts +0 -190
  396. package/dist/storage-DiqWHzVI.d.cts +0 -190
@@ -1,4 +1,4 @@
1
- import { v as NodeDescribeKind, N as Node, A as Actor } from './node-C_IBuvX2.cjs';
1
+ import { e as NodeDescribeKind, a as Node, A as Actor } from './node-Cc1TniY8.cjs';
2
2
 
3
3
  /**
4
4
  * JSON-shaped slice of a node for `Graph.describe()`
@@ -25,11 +25,11 @@ type DescribeNodeOutput = {
25
25
  timestamp_ns: number;
26
26
  }>;
27
27
  /**
28
- * Latest reason annotation attached via `graph.trace(path, reason)`,
29
- * when present. Populated by `Graph.describe` only — `describeNode`
30
- * has no graph context.
28
+ * Latest annotation attached via `graph.trace(path, annotation)` or via
29
+ * `graph.add(node, { name: path, annotation })`, when present. Populated by
30
+ * `Graph.describe` only — `describeNode` has no graph context.
31
31
  */
32
- reason?: string;
32
+ annotation?: string;
33
33
  };
34
34
  /** Detail level for progressive disclosure (Phase 3.3b). */
35
35
  type DescribeDetail = "minimal" | "standard" | "full";
@@ -1,4 +1,4 @@
1
- import { v as NodeDescribeKind, N as Node, A as Actor } from './node-C_IBuvX2.js';
1
+ import { e as NodeDescribeKind, a as Node, A as Actor } from './node-Cc1TniY8.js';
2
2
 
3
3
  /**
4
4
  * JSON-shaped slice of a node for `Graph.describe()`
@@ -25,11 +25,11 @@ type DescribeNodeOutput = {
25
25
  timestamp_ns: number;
26
26
  }>;
27
27
  /**
28
- * Latest reason annotation attached via `graph.trace(path, reason)`,
29
- * when present. Populated by `Graph.describe` only — `describeNode`
30
- * has no graph context.
28
+ * Latest annotation attached via `graph.trace(path, annotation)` or via
29
+ * `graph.add(node, { name: path, annotation })`, when present. Populated by
30
+ * `Graph.describe` only — `describeNode` has no graph context.
31
31
  */
32
- reason?: string;
32
+ annotation?: string;
33
33
  };
34
34
  /** Detail level for progressive disclosure (Phase 3.3b). */
35
35
  type DescribeDetail = "minimal" | "standard" | "full";
@@ -600,12 +600,31 @@ type NodeTransportOptions = {
600
600
  };
601
601
  /**
602
602
  * Cleanup return shape from a node {@link NodeFn}.
603
- * - `() => void` — fires before the next fn run AND on deactivation (default).
604
- * - `{ deactivation: () => void }` — fires only on deactivation (persistent
605
- * resources that should survive across fn re-runs).
603
+ *
604
+ * Two forms, discriminated on return type:
605
+ *
606
+ * - `() => void` — fires before the next fn run AND on deactivation AND on
607
+ * INVALIDATE. The simplest form: one cleanup function for every transition
608
+ * away from the current run. Use when the same teardown logic applies to
609
+ * all three.
610
+ *
611
+ * - `{ beforeRun?, deactivate?, invalidate? }` — granular hooks. Each hook
612
+ * fires exactly once on its named transition; missing hooks are no-ops.
613
+ * Use when only some transitions should flush resources (e.g. a measurement
614
+ * cache that should survive re-runs but reset on deactivation).
615
+ *
616
+ * - `beforeRun` fires before the next fn invocation (same point as the
617
+ * function-form cleanup's pre-run hook).
618
+ * - `deactivate` fires on deactivation (last-sink unsubscribe or TEARDOWN).
619
+ * - `invalidate` fires on INVALIDATE (spec v0.4 graph-wide flush signal).
620
+ *
621
+ * Closure access: both forms are declared inside `NodeFn`, so hooks see the
622
+ * same closure as the fn body (per-run locals, `ctx.store`, dep refs).
606
623
  */
607
624
  type NodeFnCleanup = (() => void) | {
608
- deactivation: () => void;
625
+ beforeRun?: () => void;
626
+ deactivate?: () => void;
627
+ invalidate?: () => void;
609
628
  };
610
629
  /**
611
630
  * Fn-time context exposing per-wave metadata and a per-node persistent
@@ -647,8 +666,10 @@ interface FnCtx {
647
666
  * the latest; iterate for multi-emission processing.
648
667
  *
649
668
  * Emission is explicit via `actions.emit(v)` (sugar: equals + framing) or
650
- * `actions.down(msgs)` (raw). Return a cleanup function (or
651
- * `{ deactivation }`) to register teardown any non-cleanup return value
669
+ * `actions.down(msgs)` (raw). Return a cleanup shape to register teardown:
670
+ * `() => void` (fires on every transition) or
671
+ * `{ beforeRun?, deactivate?, invalidate? }` (each hook fires on its named
672
+ * transition only). See {@link NodeFnCleanup}. Any non-cleanup return value
652
673
  * is ignored. The `| void` leg lets arrow-block bodies satisfy `NodeFn`
653
674
  * without an explicit `return undefined`.
654
675
  *
@@ -1092,8 +1113,14 @@ declare class NodeImpl<T = unknown> implements Node<T> {
1092
1113
  private _maybeRunFnOnSettlement;
1093
1114
  private _maybeAutoTerminalAfterWave;
1094
1115
  /**
1095
- * @internal Runs the node fn once. Default cleanup (function form) fires
1096
- * before the new run; `{ deactivation }` cleanup survives.
1116
+ * @internal Runs the node fn once.
1117
+ *
1118
+ * Cleanup firing:
1119
+ * - Function-form cleanup — fires here (pre-run) AND on deactivation AND
1120
+ * on INVALIDATE. Cleared before the new fn runs.
1121
+ * - Object-form cleanup — only `beforeRun` fires here; `deactivate` and
1122
+ * `invalidate` hooks survive across re-runs. The cleanup reference
1123
+ * itself is preserved so `deactivate`/`invalidate` still fire later.
1097
1124
  */
1098
1125
  private _execFn;
1099
1126
  private _clearWaveFlags;
@@ -1212,4 +1239,4 @@ declare class NodeImpl<T = unknown> implements Node<T> {
1212
1239
  */
1213
1240
  declare function node<T = unknown>(depsOrFn?: readonly Node[] | NodeFn | NodeOptions<T>, fnOrOpts?: NodeFn | NodeOptions<T>, optsArg?: NodeOptions<T>): Node<T>;
1214
1241
 
1215
- export { START_MSG as $, type Actor as A, type NodeInspectorHook as B, COMPLETE as C, DATA as D, ERROR as E, type FnCtx as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, type NodeInspectorHookEvent as J, type NodeSink as K, type NodeStatus as L, type Message as M, type Node as N, type NodeTransportOptions as O, type PolicyRuleData as P, type NodeVersionInfo as Q, type OnMessageHandler as R, type OnSubscribeHandler as S, PAUSE as T, type PolicyAllow as U, type PolicyDeny as V, RESOLVED as W, RESOLVED_MSG as X, RESOLVED_ONLY_BATCH as Y, RESUME as Z, START as _, type NodeOptions as a, type SubscribeContext as a0, TEARDOWN as a1, TEARDOWN_MSG as a2, TEARDOWN_ONLY_BATCH as a3, type V0 as a4, type V1 as a5, type VersioningLevel as a6, type VersioningOptions as a7, accessHintForGuard as a8, advanceVersion as a9, configure as aa, createVersioning as ab, defaultConfig as ac, defaultHash as ad, isV1 as ae, node as af, normalizeActor as ag, policy as ah, policyFromRules as ai, registerBuiltins as aj, type NodeActions as b, COMPLETE_MSG as c, COMPLETE_ONLY_BATCH as d, DEFAULT_ACTOR as e, DIRTY as f, DIRTY_MSG as g, DIRTY_ONLY_BATCH as h, type DepRecord as i, type GlobalInspectorEvent as j, type GlobalInspectorHook as k, GraphReFlyConfig as l, GuardDenied as m, type GuardDeniedDetails as n, INVALIDATE_MSG as o, INVALIDATE_ONLY_BATCH as p, type MessageContext as q, type MessageTypeRegistration as r, type MessageTypeRegistrationInput as s, type Messages as t, type NodeCtx as u, type NodeDescribeKind as v, type NodeFn as w, type NodeFnCleanup as x, type NodeGuard as y, NodeImpl as z };
1242
+ export { START as $, type Actor as A, type NodeInspectorHook as B, COMPLETE as C, DATA as D, ERROR as E, type FnCtx as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, type NodeInspectorHookEvent as J, type NodeSink as K, type NodeStatus as L, type Message as M, type NodeOptions as N, type NodeTransportOptions as O, type PolicyRuleData as P, type NodeVersionInfo as Q, type OnMessageHandler as R, type OnSubscribeHandler as S, PAUSE as T, type PolicyAllow as U, type VersioningLevel as V, type PolicyDeny as W, RESOLVED as X, RESOLVED_MSG as Y, RESOLVED_ONLY_BATCH as Z, RESUME as _, type Node as a, START_MSG as a0, type SubscribeContext as a1, TEARDOWN as a2, TEARDOWN_MSG as a3, TEARDOWN_ONLY_BATCH as a4, type V0 as a5, type V1 as a6, type VersioningOptions as a7, accessHintForGuard as a8, advanceVersion as a9, configure as aa, createVersioning as ab, defaultConfig as ac, defaultHash as ad, isV1 as ae, node as af, normalizeActor as ag, policy as ah, policyFromRules as ai, registerBuiltins as aj, type Messages as b, type NodeActions as c, type NodeFnCleanup as d, type NodeDescribeKind as e, COMPLETE_MSG as f, COMPLETE_ONLY_BATCH as g, DEFAULT_ACTOR as h, DIRTY as i, DIRTY_MSG as j, DIRTY_ONLY_BATCH as k, type DepRecord as l, type GlobalInspectorEvent as m, type GlobalInspectorHook as n, GraphReFlyConfig as o, GuardDenied as p, type GuardDeniedDetails as q, INVALIDATE_MSG as r, INVALIDATE_ONLY_BATCH as s, type MessageContext as t, type MessageTypeRegistration as u, type MessageTypeRegistrationInput as v, type NodeCtx as w, type NodeFn as x, type NodeGuard as y, NodeImpl as z };
@@ -600,12 +600,31 @@ type NodeTransportOptions = {
600
600
  };
601
601
  /**
602
602
  * Cleanup return shape from a node {@link NodeFn}.
603
- * - `() => void` — fires before the next fn run AND on deactivation (default).
604
- * - `{ deactivation: () => void }` — fires only on deactivation (persistent
605
- * resources that should survive across fn re-runs).
603
+ *
604
+ * Two forms, discriminated on return type:
605
+ *
606
+ * - `() => void` — fires before the next fn run AND on deactivation AND on
607
+ * INVALIDATE. The simplest form: one cleanup function for every transition
608
+ * away from the current run. Use when the same teardown logic applies to
609
+ * all three.
610
+ *
611
+ * - `{ beforeRun?, deactivate?, invalidate? }` — granular hooks. Each hook
612
+ * fires exactly once on its named transition; missing hooks are no-ops.
613
+ * Use when only some transitions should flush resources (e.g. a measurement
614
+ * cache that should survive re-runs but reset on deactivation).
615
+ *
616
+ * - `beforeRun` fires before the next fn invocation (same point as the
617
+ * function-form cleanup's pre-run hook).
618
+ * - `deactivate` fires on deactivation (last-sink unsubscribe or TEARDOWN).
619
+ * - `invalidate` fires on INVALIDATE (spec v0.4 graph-wide flush signal).
620
+ *
621
+ * Closure access: both forms are declared inside `NodeFn`, so hooks see the
622
+ * same closure as the fn body (per-run locals, `ctx.store`, dep refs).
606
623
  */
607
624
  type NodeFnCleanup = (() => void) | {
608
- deactivation: () => void;
625
+ beforeRun?: () => void;
626
+ deactivate?: () => void;
627
+ invalidate?: () => void;
609
628
  };
610
629
  /**
611
630
  * Fn-time context exposing per-wave metadata and a per-node persistent
@@ -647,8 +666,10 @@ interface FnCtx {
647
666
  * the latest; iterate for multi-emission processing.
648
667
  *
649
668
  * Emission is explicit via `actions.emit(v)` (sugar: equals + framing) or
650
- * `actions.down(msgs)` (raw). Return a cleanup function (or
651
- * `{ deactivation }`) to register teardown any non-cleanup return value
669
+ * `actions.down(msgs)` (raw). Return a cleanup shape to register teardown:
670
+ * `() => void` (fires on every transition) or
671
+ * `{ beforeRun?, deactivate?, invalidate? }` (each hook fires on its named
672
+ * transition only). See {@link NodeFnCleanup}. Any non-cleanup return value
652
673
  * is ignored. The `| void` leg lets arrow-block bodies satisfy `NodeFn`
653
674
  * without an explicit `return undefined`.
654
675
  *
@@ -1092,8 +1113,14 @@ declare class NodeImpl<T = unknown> implements Node<T> {
1092
1113
  private _maybeRunFnOnSettlement;
1093
1114
  private _maybeAutoTerminalAfterWave;
1094
1115
  /**
1095
- * @internal Runs the node fn once. Default cleanup (function form) fires
1096
- * before the new run; `{ deactivation }` cleanup survives.
1116
+ * @internal Runs the node fn once.
1117
+ *
1118
+ * Cleanup firing:
1119
+ * - Function-form cleanup — fires here (pre-run) AND on deactivation AND
1120
+ * on INVALIDATE. Cleared before the new fn runs.
1121
+ * - Object-form cleanup — only `beforeRun` fires here; `deactivate` and
1122
+ * `invalidate` hooks survive across re-runs. The cleanup reference
1123
+ * itself is preserved so `deactivate`/`invalidate` still fire later.
1097
1124
  */
1098
1125
  private _execFn;
1099
1126
  private _clearWaveFlags;
@@ -1212,4 +1239,4 @@ declare class NodeImpl<T = unknown> implements Node<T> {
1212
1239
  */
1213
1240
  declare function node<T = unknown>(depsOrFn?: readonly Node[] | NodeFn | NodeOptions<T>, fnOrOpts?: NodeFn | NodeOptions<T>, optsArg?: NodeOptions<T>): Node<T>;
1214
1241
 
1215
- export { START_MSG as $, type Actor as A, type NodeInspectorHook as B, COMPLETE as C, DATA as D, ERROR as E, type FnCtx as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, type NodeInspectorHookEvent as J, type NodeSink as K, type NodeStatus as L, type Message as M, type Node as N, type NodeTransportOptions as O, type PolicyRuleData as P, type NodeVersionInfo as Q, type OnMessageHandler as R, type OnSubscribeHandler as S, PAUSE as T, type PolicyAllow as U, type PolicyDeny as V, RESOLVED as W, RESOLVED_MSG as X, RESOLVED_ONLY_BATCH as Y, RESUME as Z, START as _, type NodeOptions as a, type SubscribeContext as a0, TEARDOWN as a1, TEARDOWN_MSG as a2, TEARDOWN_ONLY_BATCH as a3, type V0 as a4, type V1 as a5, type VersioningLevel as a6, type VersioningOptions as a7, accessHintForGuard as a8, advanceVersion as a9, configure as aa, createVersioning as ab, defaultConfig as ac, defaultHash as ad, isV1 as ae, node as af, normalizeActor as ag, policy as ah, policyFromRules as ai, registerBuiltins as aj, type NodeActions as b, COMPLETE_MSG as c, COMPLETE_ONLY_BATCH as d, DEFAULT_ACTOR as e, DIRTY as f, DIRTY_MSG as g, DIRTY_ONLY_BATCH as h, type DepRecord as i, type GlobalInspectorEvent as j, type GlobalInspectorHook as k, GraphReFlyConfig as l, GuardDenied as m, type GuardDeniedDetails as n, INVALIDATE_MSG as o, INVALIDATE_ONLY_BATCH as p, type MessageContext as q, type MessageTypeRegistration as r, type MessageTypeRegistrationInput as s, type Messages as t, type NodeCtx as u, type NodeDescribeKind as v, type NodeFn as w, type NodeFnCleanup as x, type NodeGuard as y, NodeImpl as z };
1242
+ export { START as $, type Actor as A, type NodeInspectorHook as B, COMPLETE as C, DATA as D, ERROR as E, type FnCtx as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, type NodeInspectorHookEvent as J, type NodeSink as K, type NodeStatus as L, type Message as M, type NodeOptions as N, type NodeTransportOptions as O, type PolicyRuleData as P, type NodeVersionInfo as Q, type OnMessageHandler as R, type OnSubscribeHandler as S, PAUSE as T, type PolicyAllow as U, type VersioningLevel as V, type PolicyDeny as W, RESOLVED as X, RESOLVED_MSG as Y, RESOLVED_ONLY_BATCH as Z, RESUME as _, type Node as a, START_MSG as a0, type SubscribeContext as a1, TEARDOWN as a2, TEARDOWN_MSG as a3, TEARDOWN_ONLY_BATCH as a4, type V0 as a5, type V1 as a6, type VersioningOptions as a7, accessHintForGuard as a8, advanceVersion as a9, configure as aa, createVersioning as ab, defaultConfig as ac, defaultHash as ad, isV1 as ae, node as af, normalizeActor as ag, policy as ah, policyFromRules as ai, registerBuiltins as aj, type Messages as b, type NodeActions as c, type NodeFnCleanup as d, type NodeDescribeKind as e, COMPLETE_MSG as f, COMPLETE_ONLY_BATCH as g, DEFAULT_ACTOR as h, DIRTY as i, DIRTY_MSG as j, DIRTY_ONLY_BATCH as k, type DepRecord as l, type GlobalInspectorEvent as m, type GlobalInspectorHook as n, GraphReFlyConfig as o, GuardDenied as p, type GuardDeniedDetails as q, INVALIDATE_MSG as r, INVALIDATE_ONLY_BATCH as s, type MessageContext as t, type MessageTypeRegistration as u, type MessageTypeRegistrationInput as v, type NodeCtx as w, type NodeFn as x, type NodeGuard as y, NodeImpl as z };
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { N as Node, t as Messages } from './node-C_IBuvX2.js';
2
+ import { a as Node, b as Messages } from './node-Cc1TniY8.js';
3
3
 
4
4
  /** Options for {@link toObservable}. */
5
5
  type ToObservableOptions = {
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { N as Node, t as Messages } from './node-C_IBuvX2.cjs';
2
+ import { a as Node, b as Messages } from './node-Cc1TniY8.cjs';
3
3
 
4
4
  /** Options for {@link toObservable}. */
5
5
  type ToObservableOptions = {
@@ -0,0 +1,25 @@
1
+ "use strict";var Ie=Object.create;var P=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var M=(e,t)=>()=>(e&&(t=e(e=0)),t);var je=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},te=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of De(t))!Ke.call(e,i)&&i!==r&&P(e,i,{get:()=>t[i],enumerable:!(n=Ue(t,i))||n.enumerable});return e};var Be=(e,t,r)=>(r=e!=null?Ie(Fe(e)):{},te(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),Ge=e=>te(P({},"__esModule",{value:!0}),e);function h(){return Math.trunc(performance.now()*1e6)}function I(){return Date.now()*1e6}var A=M(()=>{"use strict"});var T,V=M(()=>{"use strict";T=class{_timer;_gen=0;start(t,r){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&r()},t)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Xe,de,ue,pe,Qe,Ze,Y,fe,et,tt,nt,Kt,rt,ot,jt,Bt,Gt,$t,Wt,me=M(()=>{"use strict";Xe=Symbol.for("graphrefly/START"),de=Symbol.for("graphrefly/DATA"),ue=Symbol.for("graphrefly/DIRTY"),pe=Symbol.for("graphrefly/RESOLVED"),Qe=Symbol.for("graphrefly/INVALIDATE"),Ze=Symbol.for("graphrefly/TEARDOWN"),Y=Symbol.for("graphrefly/COMPLETE"),fe=Symbol.for("graphrefly/ERROR"),et=Object.freeze([ue]),tt=Object.freeze([pe]),nt=Object.freeze([Qe]),Kt=Object.freeze([Xe]),rt=Object.freeze([Y]),ot=Object.freeze([Ze]),jt=Object.freeze([et]),Bt=Object.freeze([tt]),Gt=Object.freeze([nt]),$t=Object.freeze([rt]),Wt=Object.freeze([ot])});function ge(e){return new Promise((t,r)=>{let n=!1,i=!1,a;a=e.subscribe(s=>{for(let o of s){if(n)return;if(o[0]===de){n=!0,t(o[1]),a?(a(),a=void 0):i=!0;return}if(o[0]===fe){n=!0,r(o[1]),a?(a(),a=void 0):i=!0;return}if(o[0]===Y){n=!0,r(new Error("completed without DATA")),a?(a(),a=void 0):i=!0;return}}}),i&&(a?.(),a=void 0)})}var ye=M(()=>{"use strict";me()});function At(e){return e<0?0:e}function Ne(e){let t=Math.max(1,e?.failureThreshold??5),r=At(e?.cooldownNs??30*1e9),n=e?.cooldown??null,i=Math.max(1,e?.halfOpenMax??1),a=e?.now??h,s="closed",o=0,c=0,u=0,l=r,d=0;function p(){if(!n)return r;let g=n(c);return g!==null?g:r}function m(){s="open",l=p(),u=a(),d=0}return{canExecute(){return s==="closed"?!0:s==="open"?a()-u>=l?(s="half-open",d=1,!0):!1:d<i?(d++,!0):!1},recordSuccess(){s==="half-open"?(s="closed",o=0,c=0):s==="closed"&&(o=0)},recordFailure(g){if(s==="half-open"){c++,m();return}s==="closed"&&(o++,o>=t&&m())},get state(){return s},get failureCount(){return o},reset(){s="closed",o=0,c=0,d=0}}}var Pe=M(()=>{"use strict";A()});var Tt={};je(Tt,{chromeNanoAdapter:()=>C,cloudFirstPreset:()=>xt,localFirstPreset:()=>Lt,offlinePreset:()=>Rt,webllmAdapter:()=>S});module.exports=Ge(Tt);A();function ne(){let e=new Error("aborted");return e.name="AbortError",e}function C(e={}){let t=e.streamMode??"accumulated",r=e.navigatorOverride??globalThis.navigator,n=()=>{let o=r?.ai;if(!o?.languageModel)throw new Error("chromeNanoAdapter: Chrome AI languageModel not available (requires Chrome 131+ with flag/OT).");return o},i=async o=>n().languageModel.create({systemPrompt:o?.systemPrompt??e.systemPrompt,temperature:o?.temperature??e.temperature,topK:e.topK,signal:o?.signal}),a=o=>{let c=[];for(let u of o)u.role!=="system"&&c.push(`${u.role}: ${u.content}`);return c.join(`
2
+
3
+ `)},s=()=>({input:{regular:0},output:{regular:0}});return{provider:"chrome-nano",model:"chrome-nano",async invoke(o,c){let u=await i(c);try{let l=a(o),d=h(),p=await u.prompt(l,{signal:c?.signal}),m=Math.max(0,(h()-d)/1e6);return{content:p,usage:s(),finishReason:"stop",latencyMs:m,model:"chrome-nano",provider:"chrome-nano"}}finally{u.destroy?.()}},async*stream(o,c){let u=await i(c);try{let l=a(o);if(t==="delta")for await(let d of u.promptStreaming(l,{signal:c?.signal})){if(c?.signal?.aborted)throw ne();d&&(yield{type:"token",delta:d})}else{let d="";for await(let p of u.promptStreaming(l,{signal:c?.signal})){if(c?.signal?.aborted)throw ne();let m=p.startsWith(d)?p.slice(d.length):p;d=p,m&&(yield{type:"token",delta:m})}}yield{type:"usage",usage:s()},yield{type:"finish",reason:"stop"}}finally{u.destroy?.()}}}}A();function $e(){let e=new Error("aborted");return e.name="AbortError",e}function S(e){let t=e.engine,r=async()=>{if(t)return t;if(!We(e.navigatorOverride))throw new Error("webllmAdapter: WebGPU not available in this environment");let s=(await import("@mlc-ai/web-llm").catch(()=>{throw new Error("webllmAdapter: @mlc-ai/web-llm not installed. Add it as a peer dependency or pass opts.engine.")})).CreateMLCEngine;if(!s)throw new Error("webllmAdapter: @mlc-ai/web-llm missing CreateMLCEngine export");return t=await s(e.model,{initProgressCallback:e.initProgressCallback}),t},n=(a,s)=>{let o=[];s?.systemPrompt&&o.push({role:"system",content:s.systemPrompt});for(let c of a)o.push({role:c.role==="tool"?"user":c.role,content:c.content});return o},i=a=>({input:{regular:a?.prompt_tokens??0},output:{regular:a?.completion_tokens??0},raw:a});return{provider:"webllm",model:e.model,async invoke(a,s){let o=await r(),c=h(),u=await o.chat.completions.create({model:s?.model??e.model,messages:n(a,s),max_tokens:s?.maxTokens,temperature:s?.temperature},{signal:s?.signal}),l=Math.max(0,(h()-c)/1e6),d=u.choices?.[0];return{content:d?.message?.content??"",usage:i(u.usage),finishReason:d?.finish_reason,latencyMs:l,model:e.model,provider:"webllm"}},async*stream(a,s){let c=await(await r()).chat.completions.create({model:s?.model??e.model,messages:n(a,s),max_tokens:s?.maxTokens,temperature:s?.temperature,stream:!0},{signal:s?.signal}),u,l;for await(let d of c){if(s?.signal?.aborted)throw $e();let p=d.choices?.[0];p?.delta?.content&&(yield{type:"token",delta:p.delta.content}),p?.finish_reason&&(l=p.finish_reason),d.usage&&(u=d.usage)}u&&(yield{type:"usage",usage:i(u)}),yield{type:"finish",reason:l??"stop"}}}}function We(e){let t=e??globalThis.navigator;return!!(t&&"gpu"in t&&t.gpu)}A();function ae(e={}){return e.sdk?Ye(e):He(e)}function U(e,t,r,n){let i=t?.model??r;if(!i)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:a,chat:s}=Je(e,t?.systemPrompt),o={model:i,messages:s.map(qe),max_tokens:t?.maxTokens??4096};return a&&(o.system=a),t?.temperature!=null&&(o.temperature=t.temperature),t?.tools&&t.tools.length>0&&(o.tools=t.tools.map(Ve)),t?.maxReasoningTokens!=null&&(o.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,n&&(o.stream=!0),t?.providerExtras&&Object.assign(o,t.providerExtras),o}function Je(e,t){let r=[];t&&r.push(t);let n=[];for(let i of e)i.role==="system"?r.push(i.content):n.push(i);return{system:r.length>0?r.join(`
4
+
5
+ `):void 0,chat:n}}function qe(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let r of e.toolCalls)t.push({type:"tool_use",id:r.id,name:r.name,input:r.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function Ve(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function D(e,t){if(!e)return{...t};let r={...e};return t.input_tokens!=null&&(r.input_tokens=t.input_tokens),t.output_tokens!=null&&(r.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(r.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(r.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(r.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(r.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),r}function q(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function ie(e,t){let r=[],n=[];for(let i of e.content)if(i.type==="text"&&typeof i.text=="string")r.push(i.text);else if(i.type==="tool_use"){let a=i;n.push({id:a.id,name:a.name,arguments:a.input??{}})}return{content:r.join(""),toolCalls:n.length>0?n:void 0,usage:q(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function He(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,r=e.baseURL??"https://api.anthropic.com",n=e.anthropicVersion??"2023-06-01",i=e.fetchImpl??fetch,a=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":n,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(s,o){let c=U(s,o,e.model,!1),u=h(),l=await i(`${r}/v1/messages`,{method:"POST",headers:a(),body:JSON.stringify(c),signal:o?.signal});if(!l.ok)throw await se(l);let d=await l.json(),p=Math.max(0,(h()-u)/1e6);return ie(d,p)},async*stream(s,o){let c=U(s,o,e.model,!0),u=await i(`${r}/v1/messages`,{method:"POST",headers:{...a(),accept:"text/event-stream"},body:JSON.stringify(c),signal:o?.signal});if(!u.ok)throw await se(u);if(!u.body)throw new Error("anthropicAdapter: streaming response has no body");let l,d,p=new Map;for await(let m of ze(u.body)){let w=m.data;if(!w)continue;let g;try{g=JSON.parse(w)}catch{continue}switch(g.type){case"message_start":{l=D(l,g.message.usage);break}case"content_block_start":{let f=g,y=f.content_block;y.type==="tool_use"&&(p.set(f.index,{id:String(y.id??""),name:String(y.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(y.id??""),name:String(y.name??"")}});break}case"content_block_delta":{let f=g,y=f.delta;if(y.type==="text_delta"&&typeof y.text=="string")yield{type:"token",delta:y.text};else if(y.type==="input_json_delta"&&typeof y.partial_json=="string"){let k=p.get(f.index);k&&(k.argBuf+=y.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:y.partial_json}}}else y.type==="thinking_delta"&&typeof y.thinking=="string"&&(yield{type:"thinking",delta:y.thinking});break}case"message_delta":{let f=g;f.delta.stop_reason&&(d=f.delta.stop_reason),f.delta.usage&&(l=D(l,f.delta.usage));break}case"message_stop":break}}l&&(yield{type:"usage",usage:q(l)}),yield{type:"finish",reason:d??"stop"}}}}function Ye(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(r,n){let i=U(r,n,e.model,!1),a=h(),s=await t.messages.create(i,{signal:n?.signal}),o=Math.max(0,(h()-a)/1e6);return ie(s,o)},async*stream(r,n){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let i=U(r,n,e.model,!0),a,s;for await(let o of t.messages.stream(i,{signal:n?.signal}))switch(o.type){case"message_start":a=D(a,o.message.usage);break;case"content_block_delta":{let c=o.delta;c?.type==="text_delta"&&typeof c.text=="string"?yield{type:"token",delta:c.text}:c?.type==="input_json_delta"&&typeof c.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:c.partial_json}}:c?.type==="thinking_delta"&&typeof c.thinking=="string"&&(yield{type:"thinking",delta:c.thinking});break}case"message_delta":{let c=o;c.delta.stop_reason&&(s=c.delta.stop_reason),c.delta.usage&&(a=D(a,c.delta.usage));break}}a&&(yield{type:"usage",usage:q(a)}),yield{type:"finish",reason:s??"stop"}}}}async function*ze(e){let t=e.getReader(),r=new TextDecoder,n="";try{for(;;){let{done:i,value:a}=await t.read();if(i){n.length>0&&(yield re(n));return}n+=r.decode(a,{stream:!0});let s=oe(n);for(;s!==null;){let o=n.slice(0,s.index);n=n.slice(s.index+s.length);let c=re(o);(c.data||c.event)&&(yield c),s=oe(n)}}}finally{t.releaseLock()}}function re(e){let t={},r=[];for(let n of e.split(`
6
+ `)){let i=n.endsWith("\r")?n.slice(0,-1):n;if(!i||i.startsWith(":"))continue;let a=i.indexOf(":"),s=a===-1?i:i.slice(0,a),o=a===-1?"":i.slice(a+1).replace(/^ /,"");s==="data"?r.push(o):s==="event"?t.event=o:s==="id"&&(t.id=o)}return r.length>0&&(t.data=r.join(`
7
+ `)),t}function oe(e){let t=e.indexOf(`\r
8
+ \r
9
+ `),r=e.indexOf(`
10
+
11
+ `),n=null;return t!==-1&&(n={index:t,length:4}),r!==-1&&(n===null||r<n.index)&&(n={index:r,length:2}),n}async function se(e){let t;try{t=await e.text()}catch{t=""}let r=new Error(`Anthropic API ${e.status}: ${e.statusText}${t?` \u2014 ${t}`:""}`);return r.status=e.status,r.headers=e.headers,r}V();function F(){let e=new Error("aborted");return e.name="AbortError",e}function ce(e,t){return e<=0?Promise.resolve():t?.aborted?Promise.reject(F()):new Promise((r,n)=>{let i=new T,a,s=()=>{i.cancel(),t&&a&&t.removeEventListener("abort",a)};i.start(e,()=>{s(),r()}),t&&(a=()=>{s(),n(F())},t.addEventListener("abort",a,{once:!0}))})}function K(e={}){let t=e.provider??"dry-run",r=e.model??"dry-run-v1",n=e.latencyMs??0,i=Math.max(1,e.streamChunkSize??16),a=e.respond??(o=>{let c=[...o].reverse().find(u=>u.role==="user");return c?`echo: ${c.content}`:"dry-run: no user message"}),s=e.usage??((o,c)=>{let u=o.reduce((l,d)=>l+d.content.length,0);return{input:{regular:Math.ceil(u/4)},output:{regular:Math.ceil(c.length/4)}}});return{provider:t,model:r,async invoke(o,c){if(await ce(n,c?.signal),c?.signal?.aborted)throw F();let u=a(o,c),l=s(o,u);return{content:u,usage:l,finishReason:"stop",model:c?.model??r,provider:t,tier:c?.tier,metadata:{dryRun:!0}}},async*stream(o,c){let u=a(o,c),l=s(o,u),d=Math.ceil(u.length/i)||1,p=n>0?n/d:0;for(let m=0;m<u.length;m+=i){if(c?.signal?.aborted)throw F();await ce(p,c?.signal),yield{type:"token",delta:u.slice(m,m+i)}}yield{type:"usage",usage:l},yield{type:"finish",reason:"stop"}}}}A();async function j(e){let t=typeof e=="string"?new TextEncoder().encode(e):e,r=await globalThis.crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r),i="";for(let a=0;a<n.length;a++)i+=le[n[a]];return i}var le=new Array(256);for(let e=0;e<256;e++)le[e]=e.toString(16).padStart(2,"0");function H(){let e=new Map;return{save(t,r){e.set(t,JSON.parse(JSON.stringify(r)))},load(t){let r=e.get(t);return r===void 0?null:JSON.parse(JSON.stringify(r))},clear(t){e.delete(t)},list(){return[...e.keys()].sort()}}}A();ye();function he(e,t={}){let r=t.keyFn??(i=>String(i)),n=new Map;return i=>{let a=r(i),s=n.get(a);if(s)return s;let o=e(i),c;o!=null&&typeof o.then=="function"?c=Promise.resolve(o):o!=null&&typeof o=="object"&&"subscribe"in o&&"cache"in o?c=ge(o):o!=null&&typeof o=="object"&&Symbol.asyncIterator in o?c=(async()=>{let d=o[Symbol.asyncIterator]();try{let{value:p,done:m}=await d.next();if(m)throw new Error("singleFromAny: factory returned empty async iterable");return p}finally{await d.return?.()}})():o!=null&&typeof o=="object"&&Symbol.iterator in o?c=(async()=>{let d=o[Symbol.iterator]();try{let{value:p,done:m}=d.next();if(m)throw new Error("singleFromAny: factory returned empty iterable");return p}finally{d.return?.()}})():c=Promise.resolve(o);let u,l=()=>{n.get(a)===u&&n.delete(a)};return u=c.then(d=>(l(),d),d=>{throw l(),d}),n.set(a,u),u}}V();var E=class extends Error{constructor(r,n){super(`withReplayCache: no cached response for ${n} (key=${r}, mode=read-strict)`);this.key=r;this.method=n}name="ReplayCacheMissError"};function be(e,t){let r=t.mode??"read-write",n=t.cacheStreaming??!1,i=t.captureStreamCadence??!1,a=t.replaySpeed??1,s=t.keyPrefix??"llm-replay",o=t.storage,c=r==="read"||r==="read-strict",u=async(g,f)=>{if(t.keyFn){let R=t.keyFn;if(R.length<=1){let v={messages:g,opts:f,context:f?.keyContext},b=await R(v);return`${s}:${b}`}let N=await R(g,f);return`${s}:${N}`}let{signal:y,keyContext:k,...x}=f??{},_=z({messages:g,opts:x}),O=await j(_);return`${s}:${O}`},l=async g=>{if(r==="write-only")return;let f=await o.load(g);if(f!=null)try{return typeof f=="string"?JSON.parse(f):f}catch{return}},d=async g=>(await l(g))?.response,p=async(g,f,y)=>{if(c)return;let k={response:f,storedAtNs:I(),...y?{streamChunks:y.chunks,streamCadenceMs:y.delaysMs}:{}};await o.save(g,k)},m=g=>g<=0?Promise.resolve():new Promise(f=>{new T().start(g,()=>f())}),w=he(async({messages:g,invokeOpts:f})=>{let y=e.invoke(g,f);return await st(y)},{keyFn:({_precomputedKey:g})=>g});return{provider:e.provider,model:e.model,capabilities:e.capabilities?.bind(e),async invoke(g,f){let y=await u(g,f),k=await d(y);if(k)return{...k,metadata:{...k.metadata??{},replayCache:"hit"}};if(r==="read-strict")throw new E(y,"invoke");let x=await w({messages:g,invokeOpts:f,_precomputedKey:y});return await p(y,x),x},async*stream(g,f){if(!n){for await(let b of e.stream(g,f))yield b;return}let y=await u(g,f),k=await l(y);if(k){let b=k.response;if(k.streamChunks&&k.streamCadenceMs)for(let L=0;L<k.streamChunks.length;L++){let J=k.streamCadenceMs[L]??0,ee=a>0?J/a:0;ee>0&&await m(ee),yield{type:"token",delta:k.streamChunks[L]?.delta??""}}else b.content&&(yield{type:"token",delta:b.content});b.usage&&(yield{type:"usage",usage:b.usage}),yield{type:"finish",reason:b.finishReason??"stop"};return}if(r==="read-strict")throw new E(y,"stream");let x="",_,O,R=[],N=[],v;for await(let b of e.stream(g,f)){if(b.type==="token"&&(x+=b.delta,i)){let L=h(),J=v===void 0?0:(L-v)/1e6;N.push(J),v=L,R.push({delta:b.delta})}b.type==="usage"&&(_=b.usage),b.type==="finish"&&(O=b.reason),yield b}if(x||_){let b={content:x,usage:_??{input:{regular:0},output:{regular:0}},finishReason:O,model:e.model??f?.model??"",provider:e.provider};await p(y,b,i?{chunks:R,delaysMs:N}:void 0)}}}}function z(e){let t=new Set,r=n=>{if(n===null||typeof n!="object")return n;let i=n;if(t.has(i))return{__cycle:!0};t.add(i);try{if(Array.isArray(n))return n.map(r);let a={};for(let s of Object.keys(n).sort())a[s]=r(n[s]);return a}finally{t.delete(i)}};return JSON.stringify(r(e))}async function st(e){if(e!=null&&typeof e.then=="function")return await e;if(e&&typeof e=="object"&&"content"in e)return e;throw new Error("withReplayCache: adapter.invoke must return Promise or LLMResponse (Node input not supported in cache path)")}function ke(e,t){return{content:"[fallback: no cached response available for this request]",usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:t,provider:e,metadata:{degraded:!0,reason:"no-fixture"}}}function we(e,t,r){return typeof e=="string"?{content:e,usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:r,provider:t,metadata:{degraded:!0,reason:"respond"}}:e}async function at(e,t){if("key"in e)return e.key;let r=z({messages:e.messages,opts:e.invokeOpts??{}}),n=await j(r);return`${t}:${n}`}function it(e){let t={response:e.response,storedAtNs:I()};if("key"in e&&e.stream){let r=e.stream.chunks.filter(n=>n.type==="token");return{...t,streamChunks:r.map(n=>({delta:n.delta})),streamCadenceMs:e.stream.delaysMs??r.map(()=>0)}}return t}function ct(e,t){let r=[];if(e.fixtures!=null&&r.push("fixtures"),e.fixturesStorage!=null&&r.push("fixturesStorage"),r.length>1)throw new TypeError(`fallbackAdapter: \`fixtures\` and \`fixturesStorage\` are mutually exclusive; got both ${r.join(" and ")}. Pick one source. For filesystem directories use the node subpath's \`fallbackAdapter\`.`);if(e.fixtures){let n=H(),i=e.fixtures,a=(async()=>{for(let s of i){let o=await at(s,t);await n.save(o,it(s))}})();return a.catch(()=>{}),{tier:n,seedReady:a}}return e.fixturesStorage?{tier:e.fixturesStorage,seedReady:Promise.resolve()}:{tier:void 0,seedReady:Promise.resolve()}}function Ae(e={}){let t=e.provider??"fallback",r=e.model??"fallback",n=e.onMiss??"respond",i=e.keyPrefix??"fallback",a=e.record?e.record.adapter:n==="throw"?K({provider:t,model:r,respond:()=>"[unreachable: read-strict mode throws on miss]"}):{provider:t,model:r,async invoke(l,d){let p=e.respond?e.respond(l,d):ke(t,r);return we(p,t,r)},async*stream(l,d){let p=e.respond?e.respond(l,d):ke(t,r),m=we(p,t,r);yield{type:"token",delta:m.content},m.usage&&(yield{type:"usage",usage:m.usage}),yield{type:"finish",reason:m.finishReason??"stop"}}},s,o=Promise.resolve();if(e.record){if(!e.record.storage)throw new TypeError("fallbackAdapter: `record.storage` is required in record mode. For filesystem `record.dir` convenience, use the node subpath's `fallbackAdapter`.");s=e.record.storage}else{let l=ct(e,i);s=l.tier??H(),o=l.seedReady}let c=e.record?"read-write":n==="throw"?"read-strict":"read",u=be(a,{storage:s,mode:c,keyPrefix:i,cacheStreaming:!0,captureStreamCadence:!0,replaySpeed:e.replaySpeed,...e.keyFn?{keyFn:e.keyFn}:{}});return{provider:t,model:r,capabilities:u.capabilities?.bind(u),async invoke(l,d){return await o,u.invoke(l,d)},async*stream(l,d){await o;for await(let p of u.stream(l,d))yield p}}}A();function Te(e={}){return e.sdk?pt(e):ut(e)}function B(e,t){let r=[],n=[];t?.systemPrompt&&r.push(t.systemPrompt);for(let s of e){if(s.role==="system"){r.push(s.content);continue}if(s.role==="tool"){n.push({role:"user",parts:[{functionResponse:{name:s.name??s.toolCallId??"tool",response:{result:s.content}}}]});continue}if(s.role==="assistant"&&s.toolCalls&&s.toolCalls.length>0){let o=[];s.content&&o.push({text:s.content});for(let c of s.toolCalls)o.push({functionCall:{name:c.name,args:c.arguments}});n.push({role:"model",parts:o});continue}n.push({role:s.role==="assistant"?"model":"user",parts:[{text:s.content}]})}let i={contents:n};r.length>0&&(i.systemInstruction={role:"system",parts:[{text:r.join(`
12
+
13
+ `)}]});let a={};return t?.maxTokens!=null&&(a.maxOutputTokens=t.maxTokens),t?.temperature!=null&&(a.temperature=t.temperature),t?.maxReasoningTokens!=null&&(a.thinkingConfig={thinkingBudget:t.maxReasoningTokens}),Object.keys(a).length>0&&(i.generationConfig=a),t?.tools&&t.tools.length>0&&(i.tools=[{functionDeclarations:t.tools.map(lt)}]),t?.providerExtras&&Object.assign(i,t.providerExtras),i}function lt(e){return{name:e.name,description:e.description,parameters:e.parameters}}function X(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let r=e.promptTokenCount??0,n=e.cachedContentTokenCount??0;if(t.input.regular=Math.max(0,r-n),n>0&&(t.input.cacheRead=n),e.toolUsePromptTokenCount&&(t.input.toolUse=e.toolUsePromptTokenCount),e.promptTokensDetails)for(let i of e.promptTokensDetails){let a=i.modality?.toLowerCase();a==="image"?t.input.image=(t.input.image??0)+i.tokenCount:a==="audio"?t.input.audio=(t.input.audio??0)+i.tokenCount:a==="video"&&(t.input.video=(t.input.video??0)+i.tokenCount)}return t.output.regular=e.candidatesTokenCount??0,e.thoughtsTokenCount&&(t.output.reasoning=e.thoughtsTokenCount),t}function _e(e,t){let r=e.candidates?.[0],n=r?.content?.parts??[],i=[],a=[],s=0;for(let o of n)typeof o.text=="string"&&i.push(o.text),o.functionCall&&a.push({id:`${o.functionCall.name}-${s++}`,name:o.functionCall.name,arguments:o.functionCall.args??{}});return{content:i.join(""),toolCalls:a.length>0?a:void 0,usage:X(e.usageMetadata),finishReason:r?.finishReason,latencyMs:t,model:e.modelVersion,provider:"google"}}function dt(e){if(e.apiKey)return e.apiKey;let t=globalThis.process?.env;return t?.GOOGLE_API_KEY??t?.GEMINI_API_KEY}function ut(e){let t=e.baseURL??"https://generativelanguage.googleapis.com/v1beta",r=e.fetchImpl??fetch,n=a=>{let s=a?.model??e.model;if(!s)throw new Error("googleAdapter: model must be set via options.model or invokeOpts.model");return s},i=()=>{let a=dt(e);if(!a)throw new Error("googleAdapter: apiKey required for invoke/stream");return`key=${encodeURIComponent(a)}`};return{provider:"google",model:e.model,async invoke(a,s){let o=n(s),c=B(a,s),u=h(),l=`${t}/models/${encodeURIComponent(o)}:generateContent?${i()}`,d=await r(l,{method:"POST",headers:{"content-type":"application/json",...e.headers??{}},body:JSON.stringify(c),signal:s?.signal});if(!d.ok)throw await Re(d);let p=await d.json(),m=Math.max(0,(h()-u)/1e6);return _e(p,m)},async*stream(a,s){let o=n(s),c=B(a,s),u=`${t}/models/${encodeURIComponent(o)}:streamGenerateContent?alt=sse&${i()}`,l=await r(u,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream",...e.headers??{}},body:JSON.stringify(c),signal:s?.signal});if(!l.ok)throw await Re(l);if(!l.body)throw new Error("googleAdapter: streaming response has no body");let d,p;for await(let m of ft(l.body)){if(!m.data)continue;let w;try{w=JSON.parse(m.data)}catch{continue}let g=w.candidates?.[0];for(let f of g?.content?.parts??[])typeof f.text=="string"&&(f.thought?yield{type:"thinking",delta:f.text}:yield{type:"token",delta:f.text}),f.functionCall&&(yield{type:"tool-call-delta",delta:{name:f.functionCall.name,argumentsDelta:JSON.stringify(f.functionCall.args??{})}});g?.finishReason&&(p=g.finishReason),w.usageMetadata&&(d=w.usageMetadata)}d&&(yield{type:"usage",usage:X(d)}),yield{type:"finish",reason:p??"stop"}}}}function pt(e){let t=e.sdk;if(!t)throw new Error("sdkBackedGoogle: sdk instance required");return{provider:"google",model:e.model,async invoke(r,n){let i=B(r,n),a=n?.model??e.model;if(!a)throw new Error("googleAdapter: model required");let s=h(),o=await t.models.generateContent({...i,model:a},{signal:n?.signal}),c=Math.max(0,(h()-s)/1e6);return _e(o,c)},async*stream(r,n){if(!t.models.generateContentStream)throw new Error("sdkBackedGoogle: SDK instance does not expose generateContentStream");let i=B(r,n),a=n?.model??e.model;if(!a)throw new Error("googleAdapter: model required");let s,o;for await(let c of t.models.generateContentStream({...i,model:a},{signal:n?.signal})){let u=c.candidates?.[0];for(let l of u?.content?.parts??[])typeof l.text=="string"&&(l.thought?yield{type:"thinking",delta:l.text}:yield{type:"token",delta:l.text}),l.functionCall&&(yield{type:"tool-call-delta",delta:{name:l.functionCall.name,argumentsDelta:JSON.stringify(l.functionCall.args??{})}});u?.finishReason&&(o=u.finishReason),c.usageMetadata&&(s=c.usageMetadata)}s&&(yield{type:"usage",usage:X(s)}),yield{type:"finish",reason:o??"stop"}}}}async function*ft(e){let t=e.getReader(),r=new TextDecoder,n="";try{for(;;){let{done:i,value:a}=await t.read();if(i){n.length>0&&(yield xe(n));return}n+=r.decode(a,{stream:!0});let s=Le(n);for(;s!==null;){let o=n.slice(0,s.index);n=n.slice(s.index+s.length);let c=xe(o);(c.data||c.event)&&(yield c),s=Le(n)}}}finally{t.releaseLock()}}function xe(e){let t={},r=[];for(let n of e.split(`
14
+ `)){let i=n.endsWith("\r")?n.slice(0,-1):n;if(!i||i.startsWith(":"))continue;let a=i.indexOf(":"),s=a===-1?i:i.slice(0,a),o=a===-1?"":i.slice(a+1).replace(/^ /,"");s==="data"?r.push(o):s==="event"?t.event=o:s==="id"&&(t.id=o)}return r.length>0&&(t.data=r.join(`
15
+ `)),t}function Le(e){let t=e.indexOf(`\r
16
+ \r
17
+ `),r=e.indexOf(`
18
+
19
+ `),n=null;return t!==-1&&(n={index:t,length:4}),r!==-1&&(n===null||r<n.index)&&(n={index:r,length:2}),n}async function Re(e){let t;try{t=await e.text()}catch{t=""}let r=new Error(`Google API ${e.status}: ${e.statusText}${t?` \u2014 ${t}`:""}`);return r.status=e.status,r.headers=e.headers,r}A();var mt={openai:{baseURL:"https://api.openai.com/v1",apiKeyEnv:"OPENAI_API_KEY",provider:"openai"},openrouter:{baseURL:"https://openrouter.ai/api/v1",apiKeyEnv:"OPENROUTER_API_KEY",provider:"openrouter"},groq:{baseURL:"https://api.groq.com/openai/v1",apiKeyEnv:"GROQ_API_KEY",provider:"groq"},ollama:{baseURL:"http://localhost:11434/v1",provider:"ollama"},deepseek:{baseURL:"https://api.deepseek.com/v1",apiKeyEnv:"DEEPSEEK_API_KEY",provider:"deepseek"},xai:{baseURL:"https://api.x.ai/v1",apiKeyEnv:"XAI_API_KEY",provider:"xai"}};function Se(e={}){return e.sdk?kt(e):bt(e)}function G(e,t,r,n,i){let a=t?.model??r;if(!a)throw new Error("openAICompatAdapter: model must be set via options.model or invokeOpts.model");let s=e.map(gt);t?.systemPrompt&&!e.some(c=>c.role==="system")&&s.unshift({role:"system",content:t.systemPrompt});let o={model:a,messages:s};return t?.maxTokens!=null&&(o.max_tokens=t.maxTokens),t?.temperature!=null&&(o.temperature=t.temperature),t?.tools&&t.tools.length>0&&(o.tools=t.tools.map(yt)),t?.maxReasoningTokens!=null&&(o.reasoning={max_tokens:t.maxReasoningTokens}),n&&(o.stream=!0,o.stream_options={include_usage:!0}),i&&Object.assign(o,i),t?.providerExtras&&Object.assign(o,t.providerExtras),o}function gt(e){return e.role==="tool"?{role:"tool",tool_call_id:e.toolCallId,content:e.content}:e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0?{role:"assistant",content:e.content||null,tool_calls:e.toolCalls.map(t=>({id:t.id,type:"function",function:{name:t.name,arguments:JSON.stringify(t.arguments)}}))}:{role:e.role,content:e.content}}function yt(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}}}function Q(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let r=e.prompt_tokens??0,n=e.prompt_tokens_details?.cached_tokens??0;e.prompt_cache_hit_tokens!=null?(n=e.prompt_cache_hit_tokens,t.input.regular=e.prompt_cache_miss_tokens??Math.max(0,r-n)):t.input.regular=Math.max(0,r-n),n>0&&(t.input.cacheRead=n),e.prompt_tokens_details?.audio_tokens&&(t.input.audio=e.prompt_tokens_details.audio_tokens);let i=e.completion_tokens??0,a=e.completion_tokens_details?.reasoning_tokens??0;return t.output.regular=Math.max(0,i-a),a>0&&(t.output.reasoning=a),e.completion_tokens_details?.audio_tokens&&(t.output.audio=e.completion_tokens_details.audio_tokens),e.completion_tokens_details?.accepted_prediction_tokens&&(t.output.predictionAccepted=e.completion_tokens_details.accepted_prediction_tokens),e.completion_tokens_details?.rejected_prediction_tokens&&(t.output.predictionRejected=e.completion_tokens_details.rejected_prediction_tokens),t}function Ee(e,t,r){let n=e.choices[0],i=n?.message,a=i?.content??"",s=(i?.tool_calls??[]).map(o=>({id:o.id,name:o.function.name,arguments:ht(o.function.arguments)}));return{content:a,toolCalls:s.length>0?s:void 0,usage:Q(e.usage),finishReason:n?.finish_reason,latencyMs:t,model:e.model,provider:r}}function ht(e){try{let t=JSON.parse(e);return typeof t=="object"&&t!=null?t:{_raw:e}}catch{return{_raw:e}}}function Oe(e){let t=e.preset??"openai",r=mt[t],n=e.baseURL??r.baseURL,i=e.provider??r.provider,a=r.apiKeyEnv,s=e.apiKey??(a?globalThis.process?.env?.[a]:void 0);return{provider:i,baseURL:n,apiKey:s}}function bt(e){let{provider:t,baseURL:r,apiKey:n}=Oe(e),i=e.fetchImpl??fetch,a=t!=="ollama",s=()=>{let o={"content-type":"application/json",...e.headers??{}};if(a){if(!n)throw new Error(`openAICompatAdapter[${t}]: apiKey required for invoke/stream`);o.authorization=`Bearer ${n}`}return o};return{provider:t,model:e.model,async invoke(o,c){let u=G(o,c,e.model,!1,e.bodyExtras),l=h(),d=await i(`${r}/chat/completions`,{method:"POST",headers:s(),body:JSON.stringify(u),signal:c?.signal});if(!d.ok)throw await Ce(d,t);let p=await d.json(),m=Math.max(0,(h()-l)/1e6);return Ee(p,m,t)},async*stream(o,c){let u=G(o,c,e.model,!0,e.bodyExtras),l=await i(`${r}/chat/completions`,{method:"POST",headers:{...s(),accept:"text/event-stream"},body:JSON.stringify(u),signal:c?.signal});if(!l.ok)throw await Ce(l,t);if(!l.body)throw new Error(`openAICompatAdapter[${t}]: streaming response has no body`);let d,p;for await(let m of wt(l.body)){if(!m.data||m.data==="[DONE]")continue;let w;try{w=JSON.parse(m.data)}catch{continue}let g=w.choices;if(g){let f=g[0];if(f?.delta?.content&&(yield{type:"token",delta:f.delta.content}),f?.delta?.reasoning_content&&(yield{type:"thinking",delta:f.delta.reasoning_content}),f?.delta?.tool_calls)for(let y of f.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:y.id,name:y.function?.name,argumentsDelta:y.function?.arguments}};f?.finish_reason&&(p=f.finish_reason)}w.usage&&(d=w.usage,yield{type:"usage",usage:Q(d)})}yield{type:"finish",reason:p??"stop"}}}}function kt(e){let t=e.sdk;if(!t)throw new Error("sdkBackedOpenAI: sdk instance required");let{provider:r}=Oe(e);return{provider:r,model:e.model,async invoke(n,i){let a=G(n,i,e.model,!1,e.bodyExtras),s=h(),o=await t.chat.completions.create(a,{signal:i?.signal}),c=Math.max(0,(h()-s)/1e6);return Ee(o,c,r)},async*stream(n,i){let a=G(n,i,e.model,!0,e.bodyExtras),s=await t.chat.completions.create(a,{signal:i?.signal}),o,c;for await(let u of s){let l=u.choices;if(l){let p=l[0];if(p?.delta?.content&&(yield{type:"token",delta:p.delta.content}),p?.delta?.reasoning_content&&(yield{type:"thinking",delta:p.delta.reasoning_content}),p?.delta?.tool_calls)for(let m of p.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:m.id,name:m.function?.name,argumentsDelta:m.function?.arguments}};p?.finish_reason&&(c=p.finish_reason)}let d=u.usage;d&&(o=d,yield{type:"usage",usage:Q(d)})}yield{type:"finish",reason:c??"stop"}}}}async function*wt(e){let t=e.getReader(),r=new TextDecoder,n="";try{for(;;){let{done:i,value:a}=await t.read();if(i){n.length>0&&(yield ve(n));return}n+=r.decode(a,{stream:!0});let s=Me(n);for(;s!==null;){let o=n.slice(0,s.index);n=n.slice(s.index+s.length);let c=ve(o);(c.data||c.event)&&(yield c),s=Me(n)}}}finally{t.releaseLock()}}function ve(e){let t={},r=[];for(let n of e.split(`
20
+ `)){let i=n.endsWith("\r")?n.slice(0,-1):n;if(!i||i.startsWith(":"))continue;let a=i.indexOf(":"),s=a===-1?i:i.slice(0,a),o=a===-1?"":i.slice(a+1).replace(/^ /,"");s==="data"?r.push(o):s==="event"?t.event=o:s==="id"&&(t.id=o)}return r.length>0&&(t.data=r.join(`
21
+ `)),t}function Me(e){let t=e.indexOf(`\r
22
+ \r
23
+ `),r=e.indexOf(`
24
+
25
+ `),n=null;return t!==-1&&(n={index:t,length:4}),r!==-1&&(n===null||r<n.index)&&(n={index:r,length:2}),n}async function Ce(e,t){let r;try{r=await e.text()}catch{r=""}let n=new Error(`${t} API ${e.status}: ${e.statusText}${r?` \u2014 ${r}`:""}`);return n.status=e.status,n.headers=e.headers,n}function Z(e){switch(e.provider){case"anthropic":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return ae(t)}case"google":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return Te(t)}case"dry-run":{let t={model:e.model,...e.extras};return K(t)}case"fallback":{let t={provider:e.provider,model:e.model,...e.extras};return Ae(t)}case"openai":case"openrouter":case"groq":case"ollama":case"deepseek":case"xai":{let t={preset:e.provider,apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,bodyExtras:e.bodyExtras,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return Se(t)}default:{let t=e.provider;throw new Error(`createAdapter: unknown provider: ${String(t)}`)}}}Pe();var $=class extends Error{name="AllTiersExhaustedError";skipped;failed;constructor(t){let r=[];t.failed.size>0&&r.push(`failed=[${[...t.failed.keys()].join(",")}]`),t.skipped.length>0&&r.push(`skipped=[${t.skipped.map(n=>`${n.name}(${n.reason})`).join(",")}]`),super(`All LLM adapter tiers exhausted: ${r.join(" ")}`),this.skipped=t.skipped,this.failed=t.failed}};function W(e,t={}){if(e.length===0)throw new RangeError("cascadingLlmAdapter: tiers must be non-empty");let r=e.map(i=>({name:i.name,adapter:i.adapter,filter:i.filter,breaker:i.breaker?"canExecute"in i.breaker?i.breaker:Ne(i.breaker):void 0})),n=t.streamRetryBeforeFirstChunk??!0;return{provider:"cascading",model:void 0,async invoke(i,a){let s=[],o=new Map;for(let u=0;u<r.length;u++){let l=r[u];if(l.filter&&!l.filter(i,a)){s.push({name:l.name,reason:"filter"});continue}if(l.breaker&&!l.breaker.canExecute()){s.push({name:l.name,reason:"breaker"});continue}try{let d=await Promise.resolve(l.adapter.invoke(i,a));return l.breaker?.recordSuccess(),{...d,metadata:{...d.metadata??{},tier:l.name}}}catch(d){o.set(l.name,d),l.breaker?.recordFailure(d);let p=r[u+1];p&&t.onFallback?.(l.name,p.name,d)}}let c={skipped:s,failed:o};throw t.onExhausted?.(c),new $(c)},async*stream(i,a){let s=[],o=new Map;for(let u=0;u<r.length;u++){let l=r[u];if(l.filter&&!l.filter(i,a)){s.push({name:l.name,reason:"filter"});continue}if(l.breaker&&!l.breaker.canExecute()){s.push({name:l.name,reason:"breaker"});continue}let d=!1;try{for await(let p of l.adapter.stream(i,a))d=!0,yield p;l.breaker?.recordSuccess();return}catch(p){if(o.set(l.name,p),l.breaker?.recordFailure(p),d||!n)throw p;let m=r[u+1];m&&t.onFallback?.(l.name,m.name,p)}}let c={skipped:s,failed:o};throw t.onExhausted?.(c),new $(c)}}}function xt(e){let t=[{name:"cloud",adapter:Z(e.cloud)}];return e.webllmModel&&t.push({name:"webllm",adapter:S({model:e.webllmModel})}),e.chromeNano!==!1&&t.push({name:"chrome-nano",adapter:C(),filter:(r,n)=>!n?.tools||n.tools.length===0}),W(t,e.cascade)}function Lt(e){let t=[{name:"ollama",adapter:Z({provider:"ollama",model:e.ollamaModel,baseURL:e.ollamaBaseURL})}];return e.webllmModel&&t.push({name:"webllm",adapter:S({model:e.webllmModel})}),e.chromeNano!==!1&&t.push({name:"chrome-nano",adapter:C(),filter:(r,n)=>!n?.tools||n.tools.length===0}),W(t,e.cascade)}function Rt(e){let t=[{name:"webllm",adapter:S({model:e.webllmModel})}];return e.chromeNano!==!1&&t.push({name:"chrome-nano",adapter:C(),filter:(r,n)=>!n?.tools||n.tools.length===0}),W(t,e.cascade)}0&&(module.exports={chromeNanoAdapter,cloudFirstPreset,localFirstPreset,offlinePreset,webllmAdapter});
@@ -0,0 +1,127 @@
1
+ import { L as LLMAdapter } from '../../types-O3GzJY2U.cjs';
2
+ import { c as createAdapter, C as CascadingLlmAdapterOptions } from '../../cascading-B-5zmAUv.cjs';
3
+ import '../../extra/sources.cjs';
4
+ import '../../node-Cc1TniY8.cjs';
5
+ import '../../resilience-Ba5-b4WD.cjs';
6
+
7
+ /**
8
+ * ChromeNanoAdapter — Chrome Built-in AI Prompt API.
9
+ *
10
+ * Uses `navigator.ai.languageModel` (Chrome 131+, origin trial / flag gated).
11
+ * Zero download, instant startup — but limited capability (no tool use on
12
+ * most versions, no rich system prompts on some).
13
+ *
14
+ * **Stream mode:** Chrome AI has historically switched between emitting
15
+ * accumulated (each chunk is the full text so far) and delta (each chunk is
16
+ * only the new tokens) streams across versions. Default `streamMode: "accumulated"`
17
+ * matches current behavior; pass `"delta"` if you've verified your browser
18
+ * emits pure deltas.
19
+ */
20
+
21
+ interface ChromeNanoAdapterOptions {
22
+ /** Override the navigator object (for tests). */
23
+ navigatorOverride?: Navigator;
24
+ /** Initial system prompt for the session (Chrome AI supports it in 131+). */
25
+ systemPrompt?: string;
26
+ /** Temperature (0..1). */
27
+ temperature?: number;
28
+ /** Top-K sampling (Chrome AI only). */
29
+ topK?: number;
30
+ /**
31
+ * Stream chunk shape. `"accumulated"` (default) — each chunk contains the
32
+ * full cumulative text; adapter computes deltas by string diffing.
33
+ * `"delta"` — each chunk already contains only the new tokens; adapter
34
+ * forwards directly.
35
+ */
36
+ streamMode?: "accumulated" | "delta";
37
+ }
38
+ declare function chromeNanoAdapter(opts?: ChromeNanoAdapterOptions): LLMAdapter;
39
+
40
+ /**
41
+ * WebLLMAdapter — browser-only, WebGPU-based inference via `@mlc-ai/web-llm`.
42
+ *
43
+ * Dynamic import + WebGPU feature detection. No server dependency. Typical
44
+ * use: fallback tier in `cascadingLlmAdapter` after a BYOK cloud adapter.
45
+ */
46
+
47
+ interface WebLLMAdapterOptions {
48
+ model: string;
49
+ /**
50
+ * User-provided engine instance (from `CreateMLCEngine(...)`). If omitted,
51
+ * the adapter lazy-creates one on first call via dynamic import.
52
+ */
53
+ engine?: WebLLMEngineLike;
54
+ /** Pass-through to `CreateMLCEngine`. */
55
+ initProgressCallback?: (progress: unknown) => void;
56
+ /** Navigator override (for tests). */
57
+ navigatorOverride?: Navigator;
58
+ }
59
+ interface WebLLMEngineLike {
60
+ chat: {
61
+ completions: {
62
+ create(params: Record<string, unknown>, opts?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<{
65
+ choices: ReadonlyArray<{
66
+ message?: {
67
+ content?: string;
68
+ };
69
+ finish_reason?: string;
70
+ }>;
71
+ usage?: {
72
+ prompt_tokens?: number;
73
+ completion_tokens?: number;
74
+ };
75
+ }>;
76
+ };
77
+ };
78
+ }
79
+ declare function webllmAdapter(opts: WebLLMAdapterOptions): LLMAdapter;
80
+
81
+ /**
82
+ * Curated `cascadingLlmAdapter` presets that depend on browser-only adapters
83
+ * (`webllmAdapter`, `chromeNanoAdapter`).
84
+ *
85
+ * Split out from `routing/presets.ts` so that importing `patterns/ai` in a
86
+ * Node bundle doesn't transitively pull in `@mlc-ai/web-llm` / Chrome Nano
87
+ * dynamic imports, and so browser-only consumers can opt in cleanly via
88
+ * the `@graphrefly/graphrefly/patterns/ai/browser` subpath.
89
+ *
90
+ * @module
91
+ */
92
+
93
+ interface CloudFirstPresetOptions {
94
+ /** BYOK config — passed directly to `createAdapter`. */
95
+ cloud: Parameters<typeof createAdapter>[0];
96
+ /** WebLLM model name. Pass `null` to skip the WebLLM tier. */
97
+ webllmModel?: string | null;
98
+ /** Pass `null` to skip the Chrome Nano tier. */
99
+ chromeNano?: boolean;
100
+ /** Cascade options. */
101
+ cascade?: CascadingLlmAdapterOptions;
102
+ }
103
+ /**
104
+ * Cloud-first with local fallback: BYOK → WebLLM → Chrome Nano.
105
+ */
106
+ declare function cloudFirstPreset(opts: CloudFirstPresetOptions): LLMAdapter;
107
+ interface LocalFirstPresetOptions {
108
+ /** Ollama model. */
109
+ ollamaModel: string;
110
+ /** Ollama base URL. Default http://localhost:11434/v1. */
111
+ ollamaBaseURL?: string;
112
+ webllmModel?: string | null;
113
+ chromeNano?: boolean;
114
+ cascade?: CascadingLlmAdapterOptions;
115
+ }
116
+ /**
117
+ * Local-first: nothing leaves the machine. Ollama → WebLLM → Chrome Nano.
118
+ */
119
+ declare function localFirstPreset(opts: LocalFirstPresetOptions): LLMAdapter;
120
+ interface OfflinePresetOptions {
121
+ webllmModel: string;
122
+ chromeNano?: boolean;
123
+ cascade?: CascadingLlmAdapterOptions;
124
+ }
125
+ declare function offlinePreset(opts: OfflinePresetOptions): LLMAdapter;
126
+
127
+ export { type ChromeNanoAdapterOptions, type CloudFirstPresetOptions, type LocalFirstPresetOptions, type OfflinePresetOptions, type WebLLMAdapterOptions, type WebLLMEngineLike, chromeNanoAdapter, cloudFirstPreset, localFirstPreset, offlinePreset, webllmAdapter };
@@ -0,0 +1,127 @@
1
+ import { L as LLMAdapter } from '../../types-u64Ose53.js';
2
+ import { c as createAdapter, C as CascadingLlmAdapterOptions } from '../../cascading-D9WG1-9L.js';
3
+ import '../../extra/sources.js';
4
+ import '../../node-Cc1TniY8.js';
5
+ import '../../resilience-CGRzhnD3.js';
6
+
7
+ /**
8
+ * ChromeNanoAdapter — Chrome Built-in AI Prompt API.
9
+ *
10
+ * Uses `navigator.ai.languageModel` (Chrome 131+, origin trial / flag gated).
11
+ * Zero download, instant startup — but limited capability (no tool use on
12
+ * most versions, no rich system prompts on some).
13
+ *
14
+ * **Stream mode:** Chrome AI has historically switched between emitting
15
+ * accumulated (each chunk is the full text so far) and delta (each chunk is
16
+ * only the new tokens) streams across versions. Default `streamMode: "accumulated"`
17
+ * matches current behavior; pass `"delta"` if you've verified your browser
18
+ * emits pure deltas.
19
+ */
20
+
21
+ interface ChromeNanoAdapterOptions {
22
+ /** Override the navigator object (for tests). */
23
+ navigatorOverride?: Navigator;
24
+ /** Initial system prompt for the session (Chrome AI supports it in 131+). */
25
+ systemPrompt?: string;
26
+ /** Temperature (0..1). */
27
+ temperature?: number;
28
+ /** Top-K sampling (Chrome AI only). */
29
+ topK?: number;
30
+ /**
31
+ * Stream chunk shape. `"accumulated"` (default) — each chunk contains the
32
+ * full cumulative text; adapter computes deltas by string diffing.
33
+ * `"delta"` — each chunk already contains only the new tokens; adapter
34
+ * forwards directly.
35
+ */
36
+ streamMode?: "accumulated" | "delta";
37
+ }
38
+ declare function chromeNanoAdapter(opts?: ChromeNanoAdapterOptions): LLMAdapter;
39
+
40
+ /**
41
+ * WebLLMAdapter — browser-only, WebGPU-based inference via `@mlc-ai/web-llm`.
42
+ *
43
+ * Dynamic import + WebGPU feature detection. No server dependency. Typical
44
+ * use: fallback tier in `cascadingLlmAdapter` after a BYOK cloud adapter.
45
+ */
46
+
47
+ interface WebLLMAdapterOptions {
48
+ model: string;
49
+ /**
50
+ * User-provided engine instance (from `CreateMLCEngine(...)`). If omitted,
51
+ * the adapter lazy-creates one on first call via dynamic import.
52
+ */
53
+ engine?: WebLLMEngineLike;
54
+ /** Pass-through to `CreateMLCEngine`. */
55
+ initProgressCallback?: (progress: unknown) => void;
56
+ /** Navigator override (for tests). */
57
+ navigatorOverride?: Navigator;
58
+ }
59
+ interface WebLLMEngineLike {
60
+ chat: {
61
+ completions: {
62
+ create(params: Record<string, unknown>, opts?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<{
65
+ choices: ReadonlyArray<{
66
+ message?: {
67
+ content?: string;
68
+ };
69
+ finish_reason?: string;
70
+ }>;
71
+ usage?: {
72
+ prompt_tokens?: number;
73
+ completion_tokens?: number;
74
+ };
75
+ }>;
76
+ };
77
+ };
78
+ }
79
+ declare function webllmAdapter(opts: WebLLMAdapterOptions): LLMAdapter;
80
+
81
+ /**
82
+ * Curated `cascadingLlmAdapter` presets that depend on browser-only adapters
83
+ * (`webllmAdapter`, `chromeNanoAdapter`).
84
+ *
85
+ * Split out from `routing/presets.ts` so that importing `patterns/ai` in a
86
+ * Node bundle doesn't transitively pull in `@mlc-ai/web-llm` / Chrome Nano
87
+ * dynamic imports, and so browser-only consumers can opt in cleanly via
88
+ * the `@graphrefly/graphrefly/patterns/ai/browser` subpath.
89
+ *
90
+ * @module
91
+ */
92
+
93
+ interface CloudFirstPresetOptions {
94
+ /** BYOK config — passed directly to `createAdapter`. */
95
+ cloud: Parameters<typeof createAdapter>[0];
96
+ /** WebLLM model name. Pass `null` to skip the WebLLM tier. */
97
+ webllmModel?: string | null;
98
+ /** Pass `null` to skip the Chrome Nano tier. */
99
+ chromeNano?: boolean;
100
+ /** Cascade options. */
101
+ cascade?: CascadingLlmAdapterOptions;
102
+ }
103
+ /**
104
+ * Cloud-first with local fallback: BYOK → WebLLM → Chrome Nano.
105
+ */
106
+ declare function cloudFirstPreset(opts: CloudFirstPresetOptions): LLMAdapter;
107
+ interface LocalFirstPresetOptions {
108
+ /** Ollama model. */
109
+ ollamaModel: string;
110
+ /** Ollama base URL. Default http://localhost:11434/v1. */
111
+ ollamaBaseURL?: string;
112
+ webllmModel?: string | null;
113
+ chromeNano?: boolean;
114
+ cascade?: CascadingLlmAdapterOptions;
115
+ }
116
+ /**
117
+ * Local-first: nothing leaves the machine. Ollama → WebLLM → Chrome Nano.
118
+ */
119
+ declare function localFirstPreset(opts: LocalFirstPresetOptions): LLMAdapter;
120
+ interface OfflinePresetOptions {
121
+ webllmModel: string;
122
+ chromeNano?: boolean;
123
+ cascade?: CascadingLlmAdapterOptions;
124
+ }
125
+ declare function offlinePreset(opts: OfflinePresetOptions): LLMAdapter;
126
+
127
+ export { type ChromeNanoAdapterOptions, type CloudFirstPresetOptions, type LocalFirstPresetOptions, type OfflinePresetOptions, type WebLLMAdapterOptions, type WebLLMEngineLike, chromeNanoAdapter, cloudFirstPreset, localFirstPreset, offlinePreset, webllmAdapter };
@@ -0,0 +1,3 @@
1
+ import{d as y,f}from"../../chunk-ZV2DXV5A.js";import"../../chunk-CRXTH3SH.js";import"../../chunk-4GKB4OUJ.js";import"../../chunk-K2GNMCQT.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-I6VIH3VA.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-2PMCKKRK.js";import{o as p}from"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";function L(){let e=new Error("aborted");return e.name="AbortError",e}function h(e={}){let r=e.streamMode??"accumulated",d=e.navigatorOverride??globalThis.navigator,i=()=>{let a=d?.ai;if(!a?.languageModel)throw new Error("chromeNanoAdapter: Chrome AI languageModel not available (requires Chrome 131+ with flag/OT).");return a},g=async a=>i().languageModel.create({systemPrompt:a?.systemPrompt??e.systemPrompt,temperature:a?.temperature??e.temperature,topK:e.topK,signal:a?.signal}),l=a=>{let n=[];for(let o of a)o.role!=="system"&&n.push(`${o.role}: ${o.content}`);return n.join(`
2
+
3
+ `)},t=()=>({input:{regular:0},output:{regular:0}});return{provider:"chrome-nano",model:"chrome-nano",async invoke(a,n){let o=await g(n);try{let c=l(a),s=p(),m=await o.prompt(c,{signal:n?.signal}),u=Math.max(0,(p()-s)/1e6);return{content:m,usage:t(),finishReason:"stop",latencyMs:u,model:"chrome-nano",provider:"chrome-nano"}}finally{o.destroy?.()}},async*stream(a,n){let o=await g(n);try{let c=l(a);if(r==="delta")for await(let s of o.promptStreaming(c,{signal:n?.signal})){if(n?.signal?.aborted)throw L();s&&(yield{type:"token",delta:s})}else{let s="";for await(let m of o.promptStreaming(c,{signal:n?.signal})){if(n?.signal?.aborted)throw L();let u=m.startsWith(s)?m.slice(s.length):m;s=m,u&&(yield{type:"token",delta:u})}}yield{type:"usage",usage:t()},yield{type:"finish",reason:"stop"}}finally{o.destroy?.()}}}}function A(){let e=new Error("aborted");return e.name="AbortError",e}function b(e){let r=e.engine,d=async()=>{if(r)return r;if(!w(e.navigatorOverride))throw new Error("webllmAdapter: WebGPU not available in this environment");let t=(await import("@mlc-ai/web-llm").catch(()=>{throw new Error("webllmAdapter: @mlc-ai/web-llm not installed. Add it as a peer dependency or pass opts.engine.")})).CreateMLCEngine;if(!t)throw new Error("webllmAdapter: @mlc-ai/web-llm missing CreateMLCEngine export");return r=await t(e.model,{initProgressCallback:e.initProgressCallback}),r},i=(l,t)=>{let a=[];t?.systemPrompt&&a.push({role:"system",content:t.systemPrompt});for(let n of l)a.push({role:n.role==="tool"?"user":n.role,content:n.content});return a},g=l=>({input:{regular:l?.prompt_tokens??0},output:{regular:l?.completion_tokens??0},raw:l});return{provider:"webllm",model:e.model,async invoke(l,t){let a=await d(),n=p(),o=await a.chat.completions.create({model:t?.model??e.model,messages:i(l,t),max_tokens:t?.maxTokens,temperature:t?.temperature},{signal:t?.signal}),c=Math.max(0,(p()-n)/1e6),s=o.choices?.[0];return{content:s?.message?.content??"",usage:g(o.usage),finishReason:s?.finish_reason,latencyMs:c,model:e.model,provider:"webllm"}},async*stream(l,t){let n=await(await d()).chat.completions.create({model:t?.model??e.model,messages:i(l,t),max_tokens:t?.maxTokens,temperature:t?.temperature,stream:!0},{signal:t?.signal}),o,c;for await(let s of n){if(t?.signal?.aborted)throw A();let m=s.choices?.[0];m?.delta?.content&&(yield{type:"token",delta:m.delta.content}),m?.finish_reason&&(c=m.finish_reason),s.usage&&(o=s.usage)}o&&(yield{type:"usage",usage:g(o)}),yield{type:"finish",reason:c??"stop"}}}}function w(e){let r=e??globalThis.navigator;return!!(r&&"gpu"in r&&r.gpu)}function N(e){let r=[{name:"cloud",adapter:y(e.cloud)}];return e.webllmModel&&r.push({name:"webllm",adapter:b({model:e.webllmModel})}),e.chromeNano!==!1&&r.push({name:"chrome-nano",adapter:h(),filter:(d,i)=>!i?.tools||i.tools.length===0}),f(r,e.cascade)}function S(e){let r=[{name:"ollama",adapter:y({provider:"ollama",model:e.ollamaModel,baseURL:e.ollamaBaseURL})}];return e.webllmModel&&r.push({name:"webllm",adapter:b({model:e.webllmModel})}),e.chromeNano!==!1&&r.push({name:"chrome-nano",adapter:h(),filter:(d,i)=>!i?.tools||i.tools.length===0}),f(r,e.cascade)}function R(e){let r=[{name:"webllm",adapter:b({model:e.webllmModel})}];return e.chromeNano!==!1&&r.push({name:"chrome-nano",adapter:h(),filter:(d,i)=>!i?.tools||i.tools.length===0}),f(r,e.cascade)}export{h as chromeNanoAdapter,N as cloudFirstPreset,S as localFirstPreset,R as offlinePreset,b as webllmAdapter};