@graphrefly/graphrefly 0.27.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 (428) 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 -50
  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 -83
  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 -4
  99. package/dist/core/index.d.ts +4 -4
  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 -6
  107. package/dist/extra/index.d.ts +13 -6
  108. package/dist/extra/index.js +1 -381
  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-CCwGKLCm.d.ts → graph-BZGRXwOm.d.ts} +134 -31
  144. package/dist/{graph-DNCrvZSn.d.cts → 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/{messaging-XDoYablx.d.ts → index-B0c4cmIO.d.ts} +31 -93
  148. package/dist/{index-VdHQMPy1.d.ts → index-B1AmmSlb.d.ts} +1 -1
  149. package/dist/{index-VHqptjhu.d.cts → index-B2pwesl9.d.cts} +1 -1
  150. package/dist/index-BHvIquRZ.d.ts +1957 -0
  151. package/dist/{index-Dzk2hrlR.d.ts → index-BVHOrDwO.d.ts} +1 -1
  152. package/dist/{index-CxFrXH4m.d.ts → index-BWJV63ti.d.ts} +1 -1
  153. package/dist/{index-Xi3u0HCQ.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-3lsddbbS.d.ts → index-Bqachn9_.d.ts} +1 -1
  158. package/dist/index-Btib9rsU.d.ts +607 -0
  159. package/dist/{index-wEn0eFe8.d.ts → index-BwM9BEkt.d.ts} +1 -1
  160. package/dist/index-BxJ86YZZ.d.cts +105 -0
  161. package/dist/{audit-DRlSzBu9.d.ts → index-C73n7lo-.d.cts} +27 -21
  162. package/dist/index-CEXXwWVH.d.cts +192 -0
  163. package/dist/index-CHEswufn.d.cts +163 -0
  164. package/dist/{index-C0svESO4.d.ts → index-CMn8S8Hw.d.ts} +1 -1
  165. package/dist/{index-ByQxazQJ.d.cts → index-CRO83MmV.d.cts} +1 -1
  166. package/dist/{index-BuEoe-Qu.d.ts → index-CloUk1kY.d.ts} +9 -9
  167. package/dist/index-CpgYhnrG.d.ts +291 -0
  168. package/dist/{index-DO_6JN9Z.d.cts → index-Cyojz0AE.d.cts} +1 -1
  169. package/dist/{demo-shell-BDkOptd6.d.ts → index-CzobVSMr.d.ts} +14 -14
  170. package/dist/index-Czq6ynh8.d.ts +143 -0
  171. package/dist/{index-BaSM3aYt.d.ts → index-D-YB-Vl3.d.ts} +3 -3
  172. package/dist/index-DAlweici.d.ts +231 -0
  173. package/dist/index-DEwTb_fm.d.cts +1957 -0
  174. package/dist/{index-DYme44FM.d.cts → index-DL-rYJrx.d.cts} +1 -1
  175. package/dist/{memory-li6FL5RM.d.ts → index-DP4ZTkdw.d.ts} +26 -26
  176. package/dist/{index-BwfLUNw4.d.ts → index-DUqMOlKZ.d.cts} +173 -2040
  177. package/dist/{index-B1tloyhO.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-B9B7_HEY.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-D8wS_PeY.d.cts → index-DxsnAMWD.d.cts} +9 -9
  185. package/dist/{messaging-Gt4LPbyA.d.cts → index-DyxjtScX.d.cts} +31 -93
  186. package/dist/{audit-ClmqGOCx.d.cts → index-HDpJe9hX.d.ts} +27 -21
  187. package/dist/{index-DVGiGFGT.d.cts → index-O6TgGUBV.d.cts} +3 -3
  188. package/dist/{index-B6EhDnjH.d.cts → index-Oi8d8w4R.d.cts} +1 -1
  189. package/dist/{index-C8oil6M6.d.ts → index-ROpQmGjE.d.ts} +30 -6
  190. package/dist/index-RukJ4DLS.d.cts +607 -0
  191. package/dist/{index-BHlKbUwO.d.cts → index-ZftwfxJM.d.ts} +173 -2040
  192. package/dist/{index-BPVt8kqc.d.ts → index-cByzxQIC.d.cts} +10 -195
  193. package/dist/index-dtN7YA2x.d.cts +143 -0
  194. package/dist/{index-CI3DprxP.d.cts → index-fM6y00vT.d.cts} +30 -6
  195. package/dist/{index-DlLp-2Xn.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-CO8uBlUh.d.cts → index-rnwQly8X.d.cts} +147 -20
  200. package/dist/index-sm373fsH.d.ts +192 -0
  201. package/dist/{memory-C6Z2tGpC.d.cts → index-tbf2gKHd.d.cts} +26 -26
  202. package/dist/{demo-shell-Crid1WdR.d.cts → index-u15meRxL.d.cts} +14 -14
  203. package/dist/{index-B6D3QNSA.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 -2099
  207. package/dist/index.d.ts +69 -2099
  208. package/dist/index.js +1 -3868
  209. package/dist/{meta-CbznRPYJ.d.ts → meta-Cgj6zeji.d.cts} +5 -5
  210. package/dist/{meta-BxCA7rcr.d.cts → meta-CwesDrMD.d.ts} +5 -5
  211. package/dist/{node-BmerH3kS.d.cts → node-Cc1TniY8.d.cts} +36 -9
  212. package/dist/{node-BmerH3kS.d.ts → node-Cc1TniY8.d.ts} +36 -9
  213. package/dist/{observable-BgGUwcqp.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
  214. package/dist/{observable-DJt_AxzQ.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-MQP--J3F.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
  296. package/dist/{reactive-layout-u5Ulnqag.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/{composite-aUCvjZVR.d.ts → reactive-map-CdbNoSgP.d.ts} +2 -67
  300. package/dist/{composite-C7PcQvcs.d.cts → reactive-map-DUeRmb9d.d.cts} +2 -67
  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-D02n5JjF.d.cts → sugar-BV0htudb.d.cts} +8 -4
  305. package/dist/{sugar-CCOxXK1e.d.ts → sugar-Dtyrq2_q.d.ts} +8 -4
  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 +252 -22
  311. package/dist/ai-CaR_912Q.d.cts +0 -1033
  312. package/dist/ai-WlRltJV7.d.ts +0 -1033
  313. package/dist/chunk-3ZWCKRHX.js +0 -117
  314. package/dist/chunk-3ZWCKRHX.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-APFNLIRG.js +0 -62
  318. package/dist/chunk-APFNLIRG.js.map +0 -1
  319. package/dist/chunk-AT5LKYNL.js +0 -395
  320. package/dist/chunk-AT5LKYNL.js.map +0 -1
  321. package/dist/chunk-BQ6RQQFF.js +0 -5087
  322. package/dist/chunk-BQ6RQQFF.js.map +0 -1
  323. package/dist/chunk-BVZYTZ5H.js +0 -599
  324. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  325. package/dist/chunk-DST5DKZS.js +0 -1371
  326. package/dist/chunk-DST5DKZS.js.map +0 -1
  327. package/dist/chunk-GTE6PWRZ.js +0 -866
  328. package/dist/chunk-GTE6PWRZ.js.map +0 -1
  329. package/dist/chunk-HXZEYDUR.js +0 -94
  330. package/dist/chunk-HXZEYDUR.js.map +0 -1
  331. package/dist/chunk-J22W6HV3.js +0 -107
  332. package/dist/chunk-J22W6HV3.js.map +0 -1
  333. package/dist/chunk-J2VBW3DZ.js +0 -302
  334. package/dist/chunk-J2VBW3DZ.js.map +0 -1
  335. package/dist/chunk-JSCT3CR4.js +0 -38
  336. package/dist/chunk-JSCT3CR4.js.map +0 -1
  337. package/dist/chunk-JWBCY4NC.js +0 -330
  338. package/dist/chunk-JWBCY4NC.js.map +0 -1
  339. package/dist/chunk-K2AUJHVP.js +0 -2251
  340. package/dist/chunk-K2AUJHVP.js.map +0 -1
  341. package/dist/chunk-MJ2NKQQL.js +0 -119
  342. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  343. package/dist/chunk-N6UR7YVY.js +0 -198
  344. package/dist/chunk-N6UR7YVY.js.map +0 -1
  345. package/dist/chunk-NC6S43JJ.js +0 -456
  346. package/dist/chunk-NC6S43JJ.js.map +0 -1
  347. package/dist/chunk-OFVJBJXR.js +0 -98
  348. package/dist/chunk-OFVJBJXR.js.map +0 -1
  349. package/dist/chunk-OHISZPOJ.js +0 -97
  350. package/dist/chunk-OHISZPOJ.js.map +0 -1
  351. package/dist/chunk-OU5CQKNW.js +0 -102
  352. package/dist/chunk-OU5CQKNW.js.map +0 -1
  353. package/dist/chunk-PF7GRZMW.js +0 -2712
  354. package/dist/chunk-PF7GRZMW.js.map +0 -1
  355. package/dist/chunk-PHOUUNK7.js +0 -2291
  356. package/dist/chunk-PHOUUNK7.js.map +0 -1
  357. package/dist/chunk-RNHBMHKA.js +0 -1665
  358. package/dist/chunk-RNHBMHKA.js.map +0 -1
  359. package/dist/chunk-SX52TAR4.js +0 -110
  360. package/dist/chunk-SX52TAR4.js.map +0 -1
  361. package/dist/chunk-VYPWMZ6H.js +0 -98
  362. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  363. package/dist/chunk-WBZOVTYK.js +0 -171
  364. package/dist/chunk-WBZOVTYK.js.map +0 -1
  365. package/dist/chunk-WKNUIZOY.js +0 -354
  366. package/dist/chunk-WKNUIZOY.js.map +0 -1
  367. package/dist/chunk-X3VMZYBT.js +0 -713
  368. package/dist/chunk-X3VMZYBT.js.map +0 -1
  369. package/dist/chunk-X5R3GL6H.js +0 -525
  370. package/dist/chunk-X5R3GL6H.js.map +0 -1
  371. package/dist/chunk-XGPU467M.js +0 -136
  372. package/dist/chunk-XGPU467M.js.map +0 -1
  373. package/dist/compat/index.cjs.map +0 -1
  374. package/dist/compat/index.js.map +0 -1
  375. package/dist/compat/jotai/index.cjs.map +0 -1
  376. package/dist/compat/jotai/index.js.map +0 -1
  377. package/dist/compat/nanostores/index.cjs.map +0 -1
  378. package/dist/compat/nanostores/index.js.map +0 -1
  379. package/dist/compat/nestjs/index.cjs.map +0 -1
  380. package/dist/compat/nestjs/index.js.map +0 -1
  381. package/dist/compat/react/index.cjs.map +0 -1
  382. package/dist/compat/react/index.js.map +0 -1
  383. package/dist/compat/solid/index.cjs.map +0 -1
  384. package/dist/compat/solid/index.js.map +0 -1
  385. package/dist/compat/svelte/index.cjs.map +0 -1
  386. package/dist/compat/svelte/index.js.map +0 -1
  387. package/dist/compat/vue/index.cjs.map +0 -1
  388. package/dist/compat/vue/index.js.map +0 -1
  389. package/dist/compat/zustand/index.cjs.map +0 -1
  390. package/dist/compat/zustand/index.js.map +0 -1
  391. package/dist/core/index.cjs.map +0 -1
  392. package/dist/core/index.js.map +0 -1
  393. package/dist/extra/index.cjs.map +0 -1
  394. package/dist/extra/index.js.map +0 -1
  395. package/dist/extra/sources.cjs.map +0 -1
  396. package/dist/extra/sources.js.map +0 -1
  397. package/dist/graph/index.cjs.map +0 -1
  398. package/dist/graph/index.js.map +0 -1
  399. package/dist/index.cjs.map +0 -1
  400. package/dist/index.js.map +0 -1
  401. package/dist/patterns/ai.cjs +0 -7930
  402. package/dist/patterns/ai.cjs.map +0 -1
  403. package/dist/patterns/ai.d.cts +0 -10
  404. package/dist/patterns/ai.d.ts +0 -10
  405. package/dist/patterns/ai.js +0 -71
  406. package/dist/patterns/ai.js.map +0 -1
  407. package/dist/patterns/audit.cjs +0 -5805
  408. package/dist/patterns/audit.cjs.map +0 -1
  409. package/dist/patterns/audit.d.cts +0 -6
  410. package/dist/patterns/audit.d.ts +0 -6
  411. package/dist/patterns/audit.js +0 -29
  412. package/dist/patterns/audit.js.map +0 -1
  413. package/dist/patterns/demo-shell.cjs +0 -5604
  414. package/dist/patterns/demo-shell.cjs.map +0 -1
  415. package/dist/patterns/demo-shell.d.cts +0 -6
  416. package/dist/patterns/demo-shell.d.ts +0 -6
  417. package/dist/patterns/demo-shell.js +0 -15
  418. package/dist/patterns/demo-shell.js.map +0 -1
  419. package/dist/patterns/memory.cjs +0 -5283
  420. package/dist/patterns/memory.cjs.map +0 -1
  421. package/dist/patterns/memory.d.cts +0 -5
  422. package/dist/patterns/memory.d.ts +0 -5
  423. package/dist/patterns/memory.js +0 -20
  424. package/dist/patterns/memory.js.map +0 -1
  425. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  426. package/dist/patterns/reactive-layout/index.js.map +0 -1
  427. package/dist/storage-CMjUUuxn.d.ts +0 -190
  428. package/dist/storage-DdWlZo6U.d.cts +0 -190
@@ -0,0 +1,258 @@
1
+ import { StorageTier } from './extra/storage-core.cjs';
2
+ import { C as ChatMessage, a as LLMInvokeOptions, L as LLMAdapter, b as LLMResponse, S as StreamDelta } from './types-O3GzJY2U.cjs';
3
+
4
+ /**
5
+ * `withReplayCache` — content-addressed response cache over `StorageTier`.
6
+ *
7
+ * - Key: sha256 of canonicalized (messages + invoke options minus `signal`).
8
+ * - `"read-write"` (default): returns cached response if present; on miss,
9
+ * passes through and stores the result.
10
+ * - `"write-only"`: never reads; populates the cache for later runs.
11
+ * - `"read"`: reads only; on miss, passes through without writing.
12
+ * - `"read-strict"`: reads only; on miss, **throws `ReplayCacheMissError`**
13
+ * instead of passing through. Use for fixture-driven tests or offline
14
+ * fallback adapters where any cache miss is a test failure or a signal to
15
+ * degrade.
16
+ *
17
+ * Reuses the library's existing `StorageTier` abstraction — the same tiers
18
+ * that power `Graph.attachStorage` (memory / file / sqlite / indexeddb / custom).
19
+ *
20
+ * **Concurrent cache-miss dedup:** uses `singleFromAny` so two concurrent
21
+ * calls with the same key share one upstream request. Second caller sees the
22
+ * same response that the first caller fetched; no duplicate provider spend.
23
+ *
24
+ * **Circular-ref safe:** `canonicalJson` uses a seen-set replacer so
25
+ * user-supplied `ToolDefinition.parameters` with `$ref` cycles don't stack-
26
+ * overflow the key computation.
27
+ *
28
+ * **Stream cadence capture:** when `cacheStreaming: true` AND
29
+ * `captureStreamCadence: true`, per-chunk delays (ms since previous chunk)
30
+ * are recorded alongside the content. Replay honors the recorded cadence
31
+ * unless `replaySpeed` is set, which multiplies the effective per-chunk
32
+ * delay (`replaySpeed: 2` → 2× faster; `replaySpeed: 0` → instant).
33
+ * Without `captureStreamCadence`, replay is instant regardless.
34
+ */
35
+
36
+ type ReplayCacheMode = "read" | "read-strict" | "write-only" | "read-write";
37
+ declare class ReplayCacheMissError extends Error {
38
+ readonly key: string;
39
+ readonly method: "invoke" | "stream";
40
+ name: string;
41
+ constructor(key: string, method: "invoke" | "stream");
42
+ }
43
+ /**
44
+ * Context object passed to {@link WithReplayCacheOptions.keyFn}. Extending
45
+ * with additional fields is forward-compatible — current implementations
46
+ * ignoring unknown fields continue to work.
47
+ */
48
+ interface ReplayCacheKeyContext {
49
+ readonly messages: readonly ChatMessage[];
50
+ readonly opts: LLMInvokeOptions | undefined;
51
+ /** Shortcut to `opts?.keyContext` — avoids an extra guard in callers. */
52
+ readonly context: unknown;
53
+ }
54
+ interface WithReplayCacheOptions {
55
+ storage: StorageTier;
56
+ mode?: ReplayCacheMode;
57
+ /**
58
+ * Custom key function. Receives a {@link ReplayCacheKeyContext} with the
59
+ * chat messages, the invoke options, and the caller-supplied
60
+ * `opts.keyContext`. Defaults to sha256 of canonical JSON over
61
+ * `(messages, opts without signal/keyContext)`.
62
+ *
63
+ * Legacy 2-arg form `(messages, opts?)` also accepted — the adapter
64
+ * detects arity and dispatches. Prefer the object form for new code.
65
+ */
66
+ keyFn?: ((ctx: ReplayCacheKeyContext) => string | Promise<string>) | ((messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string | Promise<string>);
67
+ /** Prefix for cached keys (useful when sharing a tier across domains). */
68
+ keyPrefix?: string;
69
+ /**
70
+ * Whether to cache streaming responses (by consuming the full stream
71
+ * and replaying it as one synthetic token chunk). Default `false`.
72
+ */
73
+ cacheStreaming?: boolean;
74
+ /**
75
+ * When `cacheStreaming: true`, also record per-chunk delays (ms since
76
+ * previous chunk) so replay can honor the original streaming cadence.
77
+ * Default `false` (chunks replay instantly).
78
+ */
79
+ captureStreamCadence?: boolean;
80
+ /**
81
+ * Stream replay speed multiplier. `1` = original cadence (requires
82
+ * `captureStreamCadence`). `2` = 2× faster. `0` = instant. Default `1`.
83
+ */
84
+ replaySpeed?: number;
85
+ }
86
+ /** Wrap an adapter with a replay cache. */
87
+ declare function withReplayCache(inner: LLMAdapter, opts: WithReplayCacheOptions): LLMAdapter;
88
+ /**
89
+ * Canonical JSON — sorts object keys for stable sha256 while detecting true
90
+ * cycles (not sibling shared refs).
91
+ *
92
+ * We recurse manually with a **path stack** (`seen` contains only the current
93
+ * ancestor chain, not every previously-visited object). On enter we push; on
94
+ * exit we pop. Back-edges to ancestors serialize as `{"__cycle": true}`;
95
+ * siblings that share the same reference (legitimate for JSON Schema
96
+ * fragments reused across tool definitions) serialize normally, producing
97
+ * identical hashes to a freshly-reconstructed equivalent.
98
+ *
99
+ * Exported so `fallbackAdapter` (and other cache-adjacent code) can share
100
+ * the same key shape — fixtures produced by either tool stay interchangeable.
101
+ */
102
+ declare function canonicalJson(value: unknown): string;
103
+
104
+ /**
105
+ * `fallbackAdapter` — fixture-backed {@link LLMAdapter} for offline demos,
106
+ * deterministic tests, and graceful degradation in production.
107
+ *
108
+ * A peer of `anthropicAdapter` / `openAICompatAdapter` / `googleAdapter` /
109
+ * `ollamaAdapter` / `dryRunAdapter`, but whose role is to serve pre-recorded
110
+ * or canned responses when real providers aren't reachable. Install it as a
111
+ * tier via the existing routing primitives (no new composer needed):
112
+ *
113
+ * ```ts
114
+ * // Graceful offline fallback for a user app:
115
+ * resilientAdapter(anthropicAdapter({ ... }), {
116
+ * fallback: fallbackAdapter({ fixturesDir: "./fixtures" }),
117
+ * });
118
+ *
119
+ * // Or the general N-tier shape:
120
+ * cascadingLlmAdapter([
121
+ * { name: "primary", adapter: anthropicAdapter({ ... }) },
122
+ * { name: "fallback", adapter: fallbackAdapter({ fixturesDir: "./fixtures" }) },
123
+ * ]);
124
+ * ```
125
+ *
126
+ * The `provider` field is `"fallback"` so its role is self-documenting in
127
+ * logs, stats, cost tables, and audit trails.
128
+ *
129
+ * ## Three fixture sources (mutually exclusive)
130
+ *
131
+ * Pick exactly one of:
132
+ *
133
+ * 1. **`fixtures: FallbackFixture[]`** — inline, hand-authored. Supports
134
+ * both hash-keyed and messages-keyed shapes; the adapter computes the
135
+ * canonical hash for messages-keyed entries at init time. Ideal when you
136
+ * want full control in code (tests, small demos).
137
+ *
138
+ * 2. **`fixturesStorage: StorageTier`** — the escape hatch for any backend.
139
+ * Pass a `memoryStorage()`, `indexedDbStorage(...)`, `sqliteStorage(...)`,
140
+ * `cascadingCache(...)`, or a custom tier. You own the layout — no
141
+ * auto-namespacing.
142
+ *
143
+ * **Filesystem directories (Node only):** the core `fallbackAdapter`
144
+ * does NOT import `node:fs` / `node:path` — it's safe to bundle for
145
+ * browsers. For a directory convenience, import `fallbackAdapter` from
146
+ * `@graphrefly/graphrefly/patterns/ai/node` (node subpath);
147
+ * that variant adds `fixturesDir: string` (auto-namespaced to
148
+ * `join(dir, keyPrefix)`, cache-format validated at init).
149
+ *
150
+ * ## Record mode
151
+ *
152
+ * `record: { adapter: real, storage }` proxies every call to `real` AND
153
+ * persists the response through the provided tier. Use the node subpath's
154
+ * `fallbackAdapter` for `record.dir` (auto-namespaced + `record.dir` defaults
155
+ * to `fixturesDir` when both are file-backed).
156
+ *
157
+ * ## Three use cases, one implementation
158
+ *
159
+ * | Use case | Config |
160
+ * |---|---|
161
+ * | **User apps** — degrade when the cloud provider errors or network is down | `fallbackAdapter({ fixturesStorage: ... })` installed as a fallback tier |
162
+ * | **Tests** — deterministic replays, fail loudly on miss | `fallbackAdapter({ fixturesStorage: ..., onMiss: "throw" })` |
163
+ * | **Eval offline replay** — zero-spend repeat runs | `fallbackAdapter({ fixturesStorage: ... })` as the only adapter |
164
+ *
165
+ * ## Implementation
166
+ *
167
+ * Thin sugar over {@link withReplayCache}. Key shape comes from its
168
+ * `canonicalJson` — fixtures written by either tool are interchangeable.
169
+ *
170
+ * @module
171
+ */
172
+
173
+ type FallbackMissPolicy = "throw" | "respond";
174
+ /**
175
+ * Thrown when `fallbackAdapter({ onMiss: "throw" })` receives a request that
176
+ * has no matching fixture. Alias of `ReplayCacheMissError` for now — the
177
+ * adapter is a thin sugar over `withReplayCache` and shares its miss-error.
178
+ */
179
+ declare const FallbackMissError: typeof ReplayCacheMissError;
180
+ type FallbackMissError = ReplayCacheMissError;
181
+ /**
182
+ * One recorded fixture. Two authoring shapes:
183
+ * - **Hash-keyed** — `{ key, response, stream? }`. Key is `sha256(canonicalJson({messages, opts}))`
184
+ * with `fallback:` prefix. This is what `record` mode writes.
185
+ * - **Messages-keyed** — `{ messages, invokeOpts?, response }`. The adapter
186
+ * computes the key at init time. Ergonomic for hand-authored fixtures.
187
+ */
188
+ type FallbackFixture = {
189
+ readonly key: string;
190
+ readonly response: LLMResponse;
191
+ readonly stream?: {
192
+ readonly chunks: readonly StreamDelta[];
193
+ readonly delaysMs?: readonly number[];
194
+ };
195
+ } | {
196
+ readonly messages: readonly ChatMessage[];
197
+ readonly invokeOpts?: Omit<LLMInvokeOptions, "signal">;
198
+ readonly response: LLMResponse;
199
+ };
200
+ interface FallbackAdapterOptions {
201
+ /** Adapter provider label. Default `"fallback"`. */
202
+ readonly provider?: string;
203
+ /** Adapter model label. Default `"fallback"`. */
204
+ readonly model?: string;
205
+ /**
206
+ * Inline hand-authored fixtures. Supports both hash-keyed (`{key, response, stream?}`)
207
+ * and messages-keyed (`{messages, invokeOpts?, response}`) shapes — the adapter
208
+ * computes the canonical hash for messages-keyed entries at init time. Held in
209
+ * an internal `memoryStorage`. Mutually exclusive with `fixturesDir` and
210
+ * `fixturesStorage`.
211
+ */
212
+ readonly fixtures?: readonly FallbackFixture[];
213
+ /**
214
+ * Bring-your-own `StorageTier` (`memoryStorage`, `sqliteStorage`,
215
+ * `indexedDbStorage`, `cascadingCache`, or a custom tier). You own the
216
+ * layout — no auto-namespacing. Mutually exclusive with `fixtures`.
217
+ *
218
+ * For filesystem directories, use the node subpath's `fallbackAdapter`
219
+ * with its `fixturesDir` option (auto-namespaced + validated).
220
+ */
221
+ readonly fixturesStorage?: StorageTier;
222
+ /**
223
+ * Called on fixture miss when `onMiss === "respond"`. If not provided and
224
+ * `onMiss === "respond"`, a canned "service unavailable" response is
225
+ * returned (marked with `metadata.degraded: true`).
226
+ */
227
+ readonly respond?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string | LLMResponse;
228
+ /** Miss policy. Default `"respond"`. */
229
+ readonly onMiss?: FallbackMissPolicy;
230
+ /**
231
+ * Record mode. Proxies every call to `record.adapter` AND persists the
232
+ * result through `record.storage`. For filesystem `record.dir` convenience,
233
+ * use the node subpath's `fallbackAdapter`.
234
+ */
235
+ readonly record?: {
236
+ readonly adapter: LLMAdapter;
237
+ readonly storage?: StorageTier;
238
+ };
239
+ /** Stream replay speed multiplier. See {@link withReplayCache}. Default `1`. */
240
+ readonly replaySpeed?: number;
241
+ /** Key prefix. Kept compatible with `withReplayCache` defaults. Default `"fallback"`. */
242
+ readonly keyPrefix?: string;
243
+ /**
244
+ * Custom key function — forwarded directly to the underlying
245
+ * {@link withReplayCache}. Use to shard fixtures by `invokeOpts.keyContext`
246
+ * (tenant, session, feature flag). Accepts either the new
247
+ * {@link ReplayCacheKeyContext} object form or the legacy 2-arg
248
+ * `(messages, opts?)` form.
249
+ */
250
+ readonly keyFn?: ((ctx: ReplayCacheKeyContext) => string) | ((messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string);
251
+ }
252
+ /**
253
+ * Build a fixture-backed {@link LLMAdapter}. See module docs for use cases
254
+ * (offline demo, tests, degraded-mode) and recipe snippets.
255
+ */
256
+ declare function fallbackAdapter(opts?: FallbackAdapterOptions): LLMAdapter;
257
+
258
+ export { type FallbackAdapterOptions as F, type ReplayCacheKeyContext as R, type WithReplayCacheOptions as W, type FallbackFixture as a, FallbackMissError as b, type FallbackMissPolicy as c, ReplayCacheMissError as d, type ReplayCacheMode as e, canonicalJson as f, fallbackAdapter as g, withReplayCache as w };
@@ -0,0 +1,258 @@
1
+ import { StorageTier } from './extra/storage-core.js';
2
+ import { C as ChatMessage, a as LLMInvokeOptions, L as LLMAdapter, b as LLMResponse, S as StreamDelta } from './types-u64Ose53.js';
3
+
4
+ /**
5
+ * `withReplayCache` — content-addressed response cache over `StorageTier`.
6
+ *
7
+ * - Key: sha256 of canonicalized (messages + invoke options minus `signal`).
8
+ * - `"read-write"` (default): returns cached response if present; on miss,
9
+ * passes through and stores the result.
10
+ * - `"write-only"`: never reads; populates the cache for later runs.
11
+ * - `"read"`: reads only; on miss, passes through without writing.
12
+ * - `"read-strict"`: reads only; on miss, **throws `ReplayCacheMissError`**
13
+ * instead of passing through. Use for fixture-driven tests or offline
14
+ * fallback adapters where any cache miss is a test failure or a signal to
15
+ * degrade.
16
+ *
17
+ * Reuses the library's existing `StorageTier` abstraction — the same tiers
18
+ * that power `Graph.attachStorage` (memory / file / sqlite / indexeddb / custom).
19
+ *
20
+ * **Concurrent cache-miss dedup:** uses `singleFromAny` so two concurrent
21
+ * calls with the same key share one upstream request. Second caller sees the
22
+ * same response that the first caller fetched; no duplicate provider spend.
23
+ *
24
+ * **Circular-ref safe:** `canonicalJson` uses a seen-set replacer so
25
+ * user-supplied `ToolDefinition.parameters` with `$ref` cycles don't stack-
26
+ * overflow the key computation.
27
+ *
28
+ * **Stream cadence capture:** when `cacheStreaming: true` AND
29
+ * `captureStreamCadence: true`, per-chunk delays (ms since previous chunk)
30
+ * are recorded alongside the content. Replay honors the recorded cadence
31
+ * unless `replaySpeed` is set, which multiplies the effective per-chunk
32
+ * delay (`replaySpeed: 2` → 2× faster; `replaySpeed: 0` → instant).
33
+ * Without `captureStreamCadence`, replay is instant regardless.
34
+ */
35
+
36
+ type ReplayCacheMode = "read" | "read-strict" | "write-only" | "read-write";
37
+ declare class ReplayCacheMissError extends Error {
38
+ readonly key: string;
39
+ readonly method: "invoke" | "stream";
40
+ name: string;
41
+ constructor(key: string, method: "invoke" | "stream");
42
+ }
43
+ /**
44
+ * Context object passed to {@link WithReplayCacheOptions.keyFn}. Extending
45
+ * with additional fields is forward-compatible — current implementations
46
+ * ignoring unknown fields continue to work.
47
+ */
48
+ interface ReplayCacheKeyContext {
49
+ readonly messages: readonly ChatMessage[];
50
+ readonly opts: LLMInvokeOptions | undefined;
51
+ /** Shortcut to `opts?.keyContext` — avoids an extra guard in callers. */
52
+ readonly context: unknown;
53
+ }
54
+ interface WithReplayCacheOptions {
55
+ storage: StorageTier;
56
+ mode?: ReplayCacheMode;
57
+ /**
58
+ * Custom key function. Receives a {@link ReplayCacheKeyContext} with the
59
+ * chat messages, the invoke options, and the caller-supplied
60
+ * `opts.keyContext`. Defaults to sha256 of canonical JSON over
61
+ * `(messages, opts without signal/keyContext)`.
62
+ *
63
+ * Legacy 2-arg form `(messages, opts?)` also accepted — the adapter
64
+ * detects arity and dispatches. Prefer the object form for new code.
65
+ */
66
+ keyFn?: ((ctx: ReplayCacheKeyContext) => string | Promise<string>) | ((messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string | Promise<string>);
67
+ /** Prefix for cached keys (useful when sharing a tier across domains). */
68
+ keyPrefix?: string;
69
+ /**
70
+ * Whether to cache streaming responses (by consuming the full stream
71
+ * and replaying it as one synthetic token chunk). Default `false`.
72
+ */
73
+ cacheStreaming?: boolean;
74
+ /**
75
+ * When `cacheStreaming: true`, also record per-chunk delays (ms since
76
+ * previous chunk) so replay can honor the original streaming cadence.
77
+ * Default `false` (chunks replay instantly).
78
+ */
79
+ captureStreamCadence?: boolean;
80
+ /**
81
+ * Stream replay speed multiplier. `1` = original cadence (requires
82
+ * `captureStreamCadence`). `2` = 2× faster. `0` = instant. Default `1`.
83
+ */
84
+ replaySpeed?: number;
85
+ }
86
+ /** Wrap an adapter with a replay cache. */
87
+ declare function withReplayCache(inner: LLMAdapter, opts: WithReplayCacheOptions): LLMAdapter;
88
+ /**
89
+ * Canonical JSON — sorts object keys for stable sha256 while detecting true
90
+ * cycles (not sibling shared refs).
91
+ *
92
+ * We recurse manually with a **path stack** (`seen` contains only the current
93
+ * ancestor chain, not every previously-visited object). On enter we push; on
94
+ * exit we pop. Back-edges to ancestors serialize as `{"__cycle": true}`;
95
+ * siblings that share the same reference (legitimate for JSON Schema
96
+ * fragments reused across tool definitions) serialize normally, producing
97
+ * identical hashes to a freshly-reconstructed equivalent.
98
+ *
99
+ * Exported so `fallbackAdapter` (and other cache-adjacent code) can share
100
+ * the same key shape — fixtures produced by either tool stay interchangeable.
101
+ */
102
+ declare function canonicalJson(value: unknown): string;
103
+
104
+ /**
105
+ * `fallbackAdapter` — fixture-backed {@link LLMAdapter} for offline demos,
106
+ * deterministic tests, and graceful degradation in production.
107
+ *
108
+ * A peer of `anthropicAdapter` / `openAICompatAdapter` / `googleAdapter` /
109
+ * `ollamaAdapter` / `dryRunAdapter`, but whose role is to serve pre-recorded
110
+ * or canned responses when real providers aren't reachable. Install it as a
111
+ * tier via the existing routing primitives (no new composer needed):
112
+ *
113
+ * ```ts
114
+ * // Graceful offline fallback for a user app:
115
+ * resilientAdapter(anthropicAdapter({ ... }), {
116
+ * fallback: fallbackAdapter({ fixturesDir: "./fixtures" }),
117
+ * });
118
+ *
119
+ * // Or the general N-tier shape:
120
+ * cascadingLlmAdapter([
121
+ * { name: "primary", adapter: anthropicAdapter({ ... }) },
122
+ * { name: "fallback", adapter: fallbackAdapter({ fixturesDir: "./fixtures" }) },
123
+ * ]);
124
+ * ```
125
+ *
126
+ * The `provider` field is `"fallback"` so its role is self-documenting in
127
+ * logs, stats, cost tables, and audit trails.
128
+ *
129
+ * ## Three fixture sources (mutually exclusive)
130
+ *
131
+ * Pick exactly one of:
132
+ *
133
+ * 1. **`fixtures: FallbackFixture[]`** — inline, hand-authored. Supports
134
+ * both hash-keyed and messages-keyed shapes; the adapter computes the
135
+ * canonical hash for messages-keyed entries at init time. Ideal when you
136
+ * want full control in code (tests, small demos).
137
+ *
138
+ * 2. **`fixturesStorage: StorageTier`** — the escape hatch for any backend.
139
+ * Pass a `memoryStorage()`, `indexedDbStorage(...)`, `sqliteStorage(...)`,
140
+ * `cascadingCache(...)`, or a custom tier. You own the layout — no
141
+ * auto-namespacing.
142
+ *
143
+ * **Filesystem directories (Node only):** the core `fallbackAdapter`
144
+ * does NOT import `node:fs` / `node:path` — it's safe to bundle for
145
+ * browsers. For a directory convenience, import `fallbackAdapter` from
146
+ * `@graphrefly/graphrefly/patterns/ai/node` (node subpath);
147
+ * that variant adds `fixturesDir: string` (auto-namespaced to
148
+ * `join(dir, keyPrefix)`, cache-format validated at init).
149
+ *
150
+ * ## Record mode
151
+ *
152
+ * `record: { adapter: real, storage }` proxies every call to `real` AND
153
+ * persists the response through the provided tier. Use the node subpath's
154
+ * `fallbackAdapter` for `record.dir` (auto-namespaced + `record.dir` defaults
155
+ * to `fixturesDir` when both are file-backed).
156
+ *
157
+ * ## Three use cases, one implementation
158
+ *
159
+ * | Use case | Config |
160
+ * |---|---|
161
+ * | **User apps** — degrade when the cloud provider errors or network is down | `fallbackAdapter({ fixturesStorage: ... })` installed as a fallback tier |
162
+ * | **Tests** — deterministic replays, fail loudly on miss | `fallbackAdapter({ fixturesStorage: ..., onMiss: "throw" })` |
163
+ * | **Eval offline replay** — zero-spend repeat runs | `fallbackAdapter({ fixturesStorage: ... })` as the only adapter |
164
+ *
165
+ * ## Implementation
166
+ *
167
+ * Thin sugar over {@link withReplayCache}. Key shape comes from its
168
+ * `canonicalJson` — fixtures written by either tool are interchangeable.
169
+ *
170
+ * @module
171
+ */
172
+
173
+ type FallbackMissPolicy = "throw" | "respond";
174
+ /**
175
+ * Thrown when `fallbackAdapter({ onMiss: "throw" })` receives a request that
176
+ * has no matching fixture. Alias of `ReplayCacheMissError` for now — the
177
+ * adapter is a thin sugar over `withReplayCache` and shares its miss-error.
178
+ */
179
+ declare const FallbackMissError: typeof ReplayCacheMissError;
180
+ type FallbackMissError = ReplayCacheMissError;
181
+ /**
182
+ * One recorded fixture. Two authoring shapes:
183
+ * - **Hash-keyed** — `{ key, response, stream? }`. Key is `sha256(canonicalJson({messages, opts}))`
184
+ * with `fallback:` prefix. This is what `record` mode writes.
185
+ * - **Messages-keyed** — `{ messages, invokeOpts?, response }`. The adapter
186
+ * computes the key at init time. Ergonomic for hand-authored fixtures.
187
+ */
188
+ type FallbackFixture = {
189
+ readonly key: string;
190
+ readonly response: LLMResponse;
191
+ readonly stream?: {
192
+ readonly chunks: readonly StreamDelta[];
193
+ readonly delaysMs?: readonly number[];
194
+ };
195
+ } | {
196
+ readonly messages: readonly ChatMessage[];
197
+ readonly invokeOpts?: Omit<LLMInvokeOptions, "signal">;
198
+ readonly response: LLMResponse;
199
+ };
200
+ interface FallbackAdapterOptions {
201
+ /** Adapter provider label. Default `"fallback"`. */
202
+ readonly provider?: string;
203
+ /** Adapter model label. Default `"fallback"`. */
204
+ readonly model?: string;
205
+ /**
206
+ * Inline hand-authored fixtures. Supports both hash-keyed (`{key, response, stream?}`)
207
+ * and messages-keyed (`{messages, invokeOpts?, response}`) shapes — the adapter
208
+ * computes the canonical hash for messages-keyed entries at init time. Held in
209
+ * an internal `memoryStorage`. Mutually exclusive with `fixturesDir` and
210
+ * `fixturesStorage`.
211
+ */
212
+ readonly fixtures?: readonly FallbackFixture[];
213
+ /**
214
+ * Bring-your-own `StorageTier` (`memoryStorage`, `sqliteStorage`,
215
+ * `indexedDbStorage`, `cascadingCache`, or a custom tier). You own the
216
+ * layout — no auto-namespacing. Mutually exclusive with `fixtures`.
217
+ *
218
+ * For filesystem directories, use the node subpath's `fallbackAdapter`
219
+ * with its `fixturesDir` option (auto-namespaced + validated).
220
+ */
221
+ readonly fixturesStorage?: StorageTier;
222
+ /**
223
+ * Called on fixture miss when `onMiss === "respond"`. If not provided and
224
+ * `onMiss === "respond"`, a canned "service unavailable" response is
225
+ * returned (marked with `metadata.degraded: true`).
226
+ */
227
+ readonly respond?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string | LLMResponse;
228
+ /** Miss policy. Default `"respond"`. */
229
+ readonly onMiss?: FallbackMissPolicy;
230
+ /**
231
+ * Record mode. Proxies every call to `record.adapter` AND persists the
232
+ * result through `record.storage`. For filesystem `record.dir` convenience,
233
+ * use the node subpath's `fallbackAdapter`.
234
+ */
235
+ readonly record?: {
236
+ readonly adapter: LLMAdapter;
237
+ readonly storage?: StorageTier;
238
+ };
239
+ /** Stream replay speed multiplier. See {@link withReplayCache}. Default `1`. */
240
+ readonly replaySpeed?: number;
241
+ /** Key prefix. Kept compatible with `withReplayCache` defaults. Default `"fallback"`. */
242
+ readonly keyPrefix?: string;
243
+ /**
244
+ * Custom key function — forwarded directly to the underlying
245
+ * {@link withReplayCache}. Use to shard fixtures by `invokeOpts.keyContext`
246
+ * (tenant, session, feature flag). Accepts either the new
247
+ * {@link ReplayCacheKeyContext} object form or the legacy 2-arg
248
+ * `(messages, opts?)` form.
249
+ */
250
+ readonly keyFn?: ((ctx: ReplayCacheKeyContext) => string) | ((messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string);
251
+ }
252
+ /**
253
+ * Build a fixture-backed {@link LLMAdapter}. See module docs for use cases
254
+ * (offline demo, tests, degraded-mode) and recipe snippets.
255
+ */
256
+ declare function fallbackAdapter(opts?: FallbackAdapterOptions): LLMAdapter;
257
+
258
+ export { type FallbackAdapterOptions as F, type ReplayCacheKeyContext as R, type WithReplayCacheOptions as W, type FallbackFixture as a, FallbackMissError as b, type FallbackMissPolicy as c, ReplayCacheMissError as d, type ReplayCacheMode as e, canonicalJson as f, fallbackAdapter as g, withReplayCache as w };