@graphrefly/graphrefly 0.45.0 → 0.46.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 (714) hide show
  1. package/README.md +1 -2
  2. package/dist/_internal-B23BagFd.d.cts +33 -0
  3. package/dist/_internal-B23BagFd.d.ts +33 -0
  4. package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
  5. package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
  6. package/dist/agents-C0Ji9ldU.d.cts +629 -0
  7. package/dist/agents-C9zexT7I.d.ts +629 -0
  8. package/dist/audit-BAXb3VOg.d.ts +246 -0
  9. package/dist/audit-C_bPfkqS.d.cts +246 -0
  10. package/dist/backoff-7KIK3WQW.js +24 -0
  11. package/dist/backoff-7KIK3WQW.js.map +1 -0
  12. package/dist/backoff-Bnb9OoPh.d.cts +6 -0
  13. package/dist/backoff-Bnb9OoPh.d.ts +6 -0
  14. package/dist/base/composition/index.cjs +811 -0
  15. package/dist/base/composition/index.cjs.map +1 -0
  16. package/dist/base/composition/index.d.cts +469 -0
  17. package/dist/base/composition/index.d.ts +469 -0
  18. package/dist/base/composition/index.js +40 -0
  19. package/dist/base/composition/index.js.map +1 -0
  20. package/dist/base/index.cjs +6336 -0
  21. package/dist/base/index.cjs.map +1 -0
  22. package/dist/base/index.d.cts +22 -0
  23. package/dist/base/index.d.ts +22 -0
  24. package/dist/base/index.js +259 -0
  25. package/dist/base/index.js.map +1 -0
  26. package/dist/base/io/index.cjs +3270 -0
  27. package/dist/base/io/index.cjs.map +1 -0
  28. package/dist/base/io/index.d.cts +2245 -0
  29. package/dist/base/io/index.d.ts +2245 -0
  30. package/dist/base/io/index.js +117 -0
  31. package/dist/base/io/index.js.map +1 -0
  32. package/dist/base/meta/index.cjs +43 -0
  33. package/dist/base/meta/index.cjs.map +1 -0
  34. package/dist/base/meta/index.d.cts +45 -0
  35. package/dist/base/meta/index.d.ts +45 -0
  36. package/dist/base/meta/index.js +13 -0
  37. package/dist/base/meta/index.js.map +1 -0
  38. package/dist/base/mutation/index.cjs +200 -0
  39. package/dist/base/mutation/index.cjs.map +1 -0
  40. package/dist/base/mutation/index.d.cts +177 -0
  41. package/dist/base/mutation/index.d.ts +177 -0
  42. package/dist/base/mutation/index.js +22 -0
  43. package/dist/base/mutation/index.js.map +1 -0
  44. package/dist/base/render/index.cjs +1120 -0
  45. package/dist/base/render/index.cjs.map +1 -0
  46. package/dist/base/render/index.d.cts +227 -0
  47. package/dist/base/render/index.d.ts +227 -0
  48. package/dist/base/render/index.js +24 -0
  49. package/dist/base/render/index.js.map +1 -0
  50. package/dist/base/sources/browser/index.cjs +172 -0
  51. package/dist/base/sources/browser/index.cjs.map +1 -0
  52. package/dist/base/sources/browser/index.d.cts +84 -0
  53. package/dist/base/sources/browser/index.d.ts +84 -0
  54. package/dist/base/sources/browser/index.js +151 -0
  55. package/dist/base/sources/browser/index.js.map +1 -0
  56. package/dist/base/sources/event/index.cjs +98 -0
  57. package/dist/base/sources/event/index.cjs.map +1 -0
  58. package/dist/base/sources/event/index.d.cts +91 -0
  59. package/dist/base/sources/event/index.d.ts +91 -0
  60. package/dist/base/sources/event/index.js +13 -0
  61. package/dist/base/sources/event/index.js.map +1 -0
  62. package/dist/base/sources/index.cjs +755 -0
  63. package/dist/base/sources/index.cjs.map +1 -0
  64. package/dist/base/sources/index.d.cts +357 -0
  65. package/dist/base/sources/index.d.ts +357 -0
  66. package/dist/base/sources/index.js +42 -0
  67. package/dist/base/sources/index.js.map +1 -0
  68. package/dist/base/sources/node/index.cjs +320 -0
  69. package/dist/base/sources/node/index.cjs.map +1 -0
  70. package/dist/base/sources/node/index.d.cts +185 -0
  71. package/dist/base/sources/node/index.d.ts +185 -0
  72. package/dist/base/sources/node/index.js +306 -0
  73. package/dist/base/sources/node/index.js.map +1 -0
  74. package/dist/base/utils/index.cjs +37 -0
  75. package/dist/base/utils/index.cjs.map +1 -0
  76. package/dist/base/utils/index.d.cts +37 -0
  77. package/dist/base/utils/index.d.ts +37 -0
  78. package/dist/base/utils/index.js +11 -0
  79. package/dist/base/utils/index.js.map +1 -0
  80. package/dist/base/worker/index.cjs +548 -0
  81. package/dist/base/worker/index.cjs.map +1 -0
  82. package/dist/base/worker/index.d.cts +207 -0
  83. package/dist/base/worker/index.d.ts +207 -0
  84. package/dist/base/worker/index.js +20 -0
  85. package/dist/base/worker/index.js.map +1 -0
  86. package/dist/breaker-C9skL3d8.d.ts +175 -0
  87. package/dist/breaker-ugSdq54q.d.cts +175 -0
  88. package/dist/cascading-CSSbKGrJ.d.ts +199 -0
  89. package/dist/cascading-baGkiihI.d.cts +199 -0
  90. package/dist/chunk-255UCBG4.js +58 -0
  91. package/dist/chunk-255UCBG4.js.map +1 -0
  92. package/dist/chunk-2LO3EL4W.js +1 -0
  93. package/dist/chunk-2LO3EL4W.js.map +1 -0
  94. package/dist/chunk-2OB3CEJS.js +1065 -0
  95. package/dist/chunk-2OB3CEJS.js.map +1 -0
  96. package/dist/chunk-36NMM65U.js +144 -0
  97. package/dist/chunk-36NMM65U.js.map +1 -0
  98. package/dist/chunk-3CEXCBN6.js +1 -0
  99. package/dist/chunk-3CEXCBN6.js.map +1 -0
  100. package/dist/chunk-3MUSLI6E.js +105 -0
  101. package/dist/chunk-3MUSLI6E.js.map +1 -0
  102. package/dist/chunk-3PSLNJDU.js +884 -0
  103. package/dist/chunk-3PSLNJDU.js.map +1 -0
  104. package/dist/chunk-3QZY5BI7.js +92 -0
  105. package/dist/chunk-3QZY5BI7.js.map +1 -0
  106. package/dist/chunk-42FQ27MQ.js +594 -0
  107. package/dist/chunk-42FQ27MQ.js.map +1 -0
  108. package/dist/chunk-4GYMCUDZ.js +1085 -0
  109. package/dist/chunk-4GYMCUDZ.js.map +1 -0
  110. package/dist/chunk-4S53H2KR.js +382 -0
  111. package/dist/chunk-4S53H2KR.js.map +1 -0
  112. package/dist/chunk-4XCHZRUJ.js +128 -0
  113. package/dist/chunk-4XCHZRUJ.js.map +1 -0
  114. package/dist/chunk-5THCXDWY.js +725 -0
  115. package/dist/chunk-5THCXDWY.js.map +1 -0
  116. package/dist/chunk-6XZYT4SW.js +256 -0
  117. package/dist/chunk-6XZYT4SW.js.map +1 -0
  118. package/dist/chunk-7EGRP2VX.js +76 -0
  119. package/dist/chunk-7EGRP2VX.js.map +1 -0
  120. package/dist/chunk-A7KV5UK4.js +150 -0
  121. package/dist/chunk-A7KV5UK4.js.map +1 -0
  122. package/dist/chunk-APY2SS5X.js +156 -0
  123. package/dist/chunk-APY2SS5X.js.map +1 -0
  124. package/dist/chunk-AZDQPQ3V.js +66 -0
  125. package/dist/chunk-AZDQPQ3V.js.map +1 -0
  126. package/dist/chunk-BU3SEFA5.js +90 -0
  127. package/dist/chunk-BU3SEFA5.js.map +1 -0
  128. package/dist/chunk-BXGZFGZ4.js +189 -0
  129. package/dist/chunk-BXGZFGZ4.js.map +1 -0
  130. package/dist/chunk-CGHORL6G.js +579 -0
  131. package/dist/chunk-CGHORL6G.js.map +1 -0
  132. package/dist/chunk-CXANAIZU.js +530 -0
  133. package/dist/chunk-CXANAIZU.js.map +1 -0
  134. package/dist/chunk-CZQHCKKG.js +1 -0
  135. package/dist/chunk-CZQHCKKG.js.map +1 -0
  136. package/dist/chunk-DKNHAICT.js +133 -0
  137. package/dist/chunk-DKNHAICT.js.map +1 -0
  138. package/dist/chunk-DM4OMPWK.js +584 -0
  139. package/dist/chunk-DM4OMPWK.js.map +1 -0
  140. package/dist/chunk-DMSNO6ZB.js +452 -0
  141. package/dist/chunk-DMSNO6ZB.js.map +1 -0
  142. package/dist/chunk-E5OZPDIW.js +229 -0
  143. package/dist/chunk-E5OZPDIW.js.map +1 -0
  144. package/dist/chunk-EVYY4X5A.js +509 -0
  145. package/dist/chunk-EVYY4X5A.js.map +1 -0
  146. package/dist/chunk-FDFD67UO.js +1 -0
  147. package/dist/chunk-FDFD67UO.js.map +1 -0
  148. package/dist/chunk-FMPF42Q4.js +13 -0
  149. package/dist/chunk-FMPF42Q4.js.map +1 -0
  150. package/dist/chunk-FR6RGA3B.js +1277 -0
  151. package/dist/chunk-FR6RGA3B.js.map +1 -0
  152. package/dist/chunk-FW23JYNQ.js +454 -0
  153. package/dist/chunk-FW23JYNQ.js.map +1 -0
  154. package/dist/chunk-GBCENOLN.js +1575 -0
  155. package/dist/chunk-GBCENOLN.js.map +1 -0
  156. package/dist/chunk-HL7HUJIX.js +1 -0
  157. package/dist/chunk-HL7HUJIX.js.map +1 -0
  158. package/dist/chunk-HULCUY35.js +2508 -0
  159. package/dist/chunk-HULCUY35.js.map +1 -0
  160. package/dist/chunk-IHTWQEDR.js +169 -0
  161. package/dist/chunk-IHTWQEDR.js.map +1 -0
  162. package/dist/chunk-IJRR6YAI.js +128 -0
  163. package/dist/chunk-IJRR6YAI.js.map +1 -0
  164. package/dist/chunk-JGFRAFDL.js +221 -0
  165. package/dist/chunk-JGFRAFDL.js.map +1 -0
  166. package/dist/chunk-KIIXR252.js +211 -0
  167. package/dist/chunk-KIIXR252.js.map +1 -0
  168. package/dist/chunk-KN3H5CNT.js +11 -0
  169. package/dist/chunk-KN3H5CNT.js.map +1 -0
  170. package/dist/chunk-KPG3DGLA.js +1 -0
  171. package/dist/chunk-KPG3DGLA.js.map +1 -0
  172. package/dist/chunk-KRNQ6RGQ.js +1 -0
  173. package/dist/chunk-KRNQ6RGQ.js.map +1 -0
  174. package/dist/chunk-LBAJK24K.js +1071 -0
  175. package/dist/chunk-LBAJK24K.js.map +1 -0
  176. package/dist/chunk-MLTPJMH6.js +417 -0
  177. package/dist/chunk-MLTPJMH6.js.map +1 -0
  178. package/dist/chunk-N3SZ7BMH.js +95 -0
  179. package/dist/chunk-N3SZ7BMH.js.map +1 -0
  180. package/dist/chunk-NDUD3IMO.js +540 -0
  181. package/dist/chunk-NDUD3IMO.js.map +1 -0
  182. package/dist/chunk-NY2PYHNC.js +873 -0
  183. package/dist/chunk-NY2PYHNC.js.map +1 -0
  184. package/dist/chunk-O3MT7DYI.js +225 -0
  185. package/dist/chunk-O3MT7DYI.js.map +1 -0
  186. package/dist/chunk-OCUDSN63.js +2386 -0
  187. package/dist/chunk-OCUDSN63.js.map +1 -0
  188. package/dist/chunk-OIWU3NYV.js +199 -0
  189. package/dist/chunk-OIWU3NYV.js.map +1 -0
  190. package/dist/chunk-OO5BM6CJ.js +1153 -0
  191. package/dist/chunk-OO5BM6CJ.js.map +1 -0
  192. package/dist/chunk-OQUIJT7A.js +1 -0
  193. package/dist/chunk-OQUIJT7A.js.map +1 -0
  194. package/dist/chunk-P5LBT622.js +105 -0
  195. package/dist/chunk-P5LBT622.js.map +1 -0
  196. package/dist/chunk-PKGQG5QQ.js +519 -0
  197. package/dist/chunk-PKGQG5QQ.js.map +1 -0
  198. package/dist/chunk-PKPO3JTZ.js +561 -0
  199. package/dist/chunk-PKPO3JTZ.js.map +1 -0
  200. package/dist/chunk-PL5UDIQ5.js +118 -0
  201. package/dist/chunk-PL5UDIQ5.js.map +1 -0
  202. package/dist/chunk-PZWISPIQ.js +432 -0
  203. package/dist/chunk-PZWISPIQ.js.map +1 -0
  204. package/dist/chunk-Q3EYOCZB.js +510 -0
  205. package/dist/chunk-Q3EYOCZB.js.map +1 -0
  206. package/dist/chunk-QMBYUVRL.js +15 -0
  207. package/dist/chunk-QMBYUVRL.js.map +1 -0
  208. package/dist/chunk-RAGGHLCV.js +200 -0
  209. package/dist/chunk-RAGGHLCV.js.map +1 -0
  210. package/dist/chunk-RGL53X5G.js +574 -0
  211. package/dist/chunk-RGL53X5G.js.map +1 -0
  212. package/dist/chunk-RJOG4IJU.js +1039 -0
  213. package/dist/chunk-RJOG4IJU.js.map +1 -0
  214. package/dist/chunk-SOOKUYVM.js +403 -0
  215. package/dist/chunk-SOOKUYVM.js.map +1 -0
  216. package/dist/chunk-T5BN5KG7.js +1 -0
  217. package/dist/chunk-T5BN5KG7.js.map +1 -0
  218. package/dist/chunk-TP7244Y6.js +207 -0
  219. package/dist/chunk-TP7244Y6.js.map +1 -0
  220. package/dist/chunk-TSBFTJKM.js +57 -0
  221. package/dist/chunk-TSBFTJKM.js.map +1 -0
  222. package/dist/chunk-URQ2CBBF.js +143 -0
  223. package/dist/chunk-URQ2CBBF.js.map +1 -0
  224. package/dist/chunk-W2BOPXTI.js +1 -0
  225. package/dist/chunk-W2BOPXTI.js.map +1 -0
  226. package/dist/chunk-WKSWLSCX.js +207 -0
  227. package/dist/chunk-WKSWLSCX.js.map +1 -0
  228. package/dist/chunk-Y52CS6YA.js +88 -0
  229. package/dist/chunk-Y52CS6YA.js.map +1 -0
  230. package/dist/chunk-YCBUWK77.js +92 -0
  231. package/dist/chunk-YCBUWK77.js.map +1 -0
  232. package/dist/chunk-YJ4U2D2C.js +314 -0
  233. package/dist/chunk-YJ4U2D2C.js.map +1 -0
  234. package/dist/chunk-Z4YXAUDN.js +239 -0
  235. package/dist/chunk-Z4YXAUDN.js.map +1 -0
  236. package/dist/chunk-Z6EGP5D7.js +92 -0
  237. package/dist/chunk-Z6EGP5D7.js.map +1 -0
  238. package/dist/compat/index.cjs +3083 -2
  239. package/dist/compat/index.cjs.map +1 -1
  240. package/dist/compat/index.d.cts +116 -1
  241. package/dist/compat/index.d.ts +116 -1
  242. package/dist/compat/index.js +175 -2
  243. package/dist/compat/index.js.map +1 -1
  244. package/dist/compat/jotai/index.cjs +130 -2
  245. package/dist/compat/jotai/index.cjs.map +1 -1
  246. package/dist/compat/jotai/index.d.cts +2 -1
  247. package/dist/compat/jotai/index.d.ts +2 -1
  248. package/dist/compat/jotai/index.js +7 -2
  249. package/dist/compat/jotai/index.js.map +1 -1
  250. package/dist/compat/nanostores/index.cjs +186 -2
  251. package/dist/compat/nanostores/index.cjs.map +1 -1
  252. package/dist/compat/nanostores/index.d.cts +2 -1
  253. package/dist/compat/nanostores/index.d.ts +2 -1
  254. package/dist/compat/nanostores/index.js +21 -2
  255. package/dist/compat/nanostores/index.js.map +1 -1
  256. package/dist/compat/nestjs/index.cjs +2224 -2
  257. package/dist/compat/nestjs/index.cjs.map +1 -1
  258. package/dist/compat/nestjs/index.d.cts +10 -1
  259. package/dist/compat/nestjs/index.d.ts +10 -1
  260. package/dist/compat/nestjs/index.js +77 -2
  261. package/dist/compat/nestjs/index.js.map +1 -1
  262. package/dist/compat/react/index.cjs +95 -2
  263. package/dist/compat/react/index.cjs.map +1 -1
  264. package/dist/compat/react/index.d.cts +2 -1
  265. package/dist/compat/react/index.d.ts +2 -1
  266. package/dist/compat/react/index.js +11 -2
  267. package/dist/compat/react/index.js.map +1 -1
  268. package/dist/compat/solid/index.cjs +82 -2
  269. package/dist/compat/solid/index.cjs.map +1 -1
  270. package/dist/compat/solid/index.d.cts +2 -1
  271. package/dist/compat/solid/index.d.ts +2 -1
  272. package/dist/compat/solid/index.js +11 -2
  273. package/dist/compat/solid/index.js.map +1 -1
  274. package/dist/compat/svelte/index.cjs +85 -2
  275. package/dist/compat/svelte/index.cjs.map +1 -1
  276. package/dist/compat/svelte/index.d.cts +2 -1
  277. package/dist/compat/svelte/index.d.ts +2 -1
  278. package/dist/compat/svelte/index.js +11 -2
  279. package/dist/compat/svelte/index.js.map +1 -1
  280. package/dist/compat/vue/index.cjs +100 -2
  281. package/dist/compat/vue/index.cjs.map +1 -1
  282. package/dist/compat/vue/index.d.cts +3 -1
  283. package/dist/compat/vue/index.d.ts +3 -1
  284. package/dist/compat/vue/index.js +11 -2
  285. package/dist/compat/vue/index.js.map +1 -1
  286. package/dist/compat/zustand/index.cjs +50 -2
  287. package/dist/compat/zustand/index.cjs.map +1 -1
  288. package/dist/compat/zustand/index.d.cts +2 -1
  289. package/dist/compat/zustand/index.d.ts +2 -1
  290. package/dist/compat/zustand/index.js +7 -2
  291. package/dist/compat/zustand/index.js.map +1 -1
  292. package/dist/distill-De6Rnn15.d.cts +48 -0
  293. package/dist/distill-De6Rnn15.d.ts +48 -0
  294. package/dist/external-register-CWyroXb_.d.cts +138 -0
  295. package/dist/external-register-CWyroXb_.d.ts +138 -0
  296. package/dist/fallback-Bx46zqky.d.cts +243 -0
  297. package/dist/fallback-pIWW8A2d.d.ts +243 -0
  298. package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
  299. package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
  300. package/dist/index-5SU_O78r.d.cts +754 -0
  301. package/dist/index-B6pxYJzO.d.cts +36 -0
  302. package/dist/index-B6pxYJzO.d.ts +36 -0
  303. package/dist/index-BFsng6v1.d.cts +44 -0
  304. package/dist/index-BFsng6v1.d.ts +44 -0
  305. package/dist/index-Bg-LwEt-.d.cts +45 -0
  306. package/dist/index-Bg-LwEt-.d.ts +45 -0
  307. package/dist/index-Brp888t0.d.cts +127 -0
  308. package/dist/index-Brp888t0.d.ts +127 -0
  309. package/dist/index-CDfk6jHN.d.cts +37 -0
  310. package/dist/index-CDfk6jHN.d.ts +37 -0
  311. package/dist/index-CEXCtYYJ.d.ts +754 -0
  312. package/dist/index-DLAxYaN5.d.cts +169 -0
  313. package/dist/index-DLAxYaN5.d.ts +169 -0
  314. package/dist/index-DeWbQzMe.d.cts +34 -0
  315. package/dist/index-DeWbQzMe.d.ts +34 -0
  316. package/dist/index-dX9IzPqj.d.cts +86 -0
  317. package/dist/index-dX9IzPqj.d.ts +86 -0
  318. package/dist/index.cjs +25950 -0
  319. package/dist/index.cjs.map +1 -1
  320. package/dist/index.d.cts +56 -42
  321. package/dist/index.d.ts +56 -42
  322. package/dist/index.js +849 -0
  323. package/dist/index.js.map +1 -1
  324. package/dist/layout-types-B5aiHYgk.d.cts +72 -0
  325. package/dist/layout-types-B5aiHYgk.d.ts +72 -0
  326. package/dist/memory-composers-BryDrRBX.d.cts +529 -0
  327. package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
  328. package/dist/observable-BXQoW1P-.d.cts +36 -0
  329. package/dist/observable-BXQoW1P-.d.ts +36 -0
  330. package/dist/pipeline-graph-Ce47CB6Y.d.cts +145 -0
  331. package/dist/pipeline-graph-DXCwY9vG.d.ts +145 -0
  332. package/dist/presets/ai/index.cjs +4377 -0
  333. package/dist/presets/ai/index.cjs.map +1 -0
  334. package/dist/presets/ai/index.d.cts +98 -0
  335. package/dist/presets/ai/index.d.ts +98 -0
  336. package/dist/presets/ai/index.js +54 -0
  337. package/dist/presets/ai/index.js.map +1 -0
  338. package/dist/presets/harness/index.cjs +5929 -0
  339. package/dist/presets/harness/index.cjs.map +1 -0
  340. package/dist/presets/harness/index.d.cts +566 -0
  341. package/dist/presets/harness/index.d.ts +566 -0
  342. package/dist/presets/harness/index.js +71 -0
  343. package/dist/presets/harness/index.js.map +1 -0
  344. package/dist/presets/index.cjs +9782 -0
  345. package/dist/presets/index.cjs.map +1 -0
  346. package/dist/presets/index.d.cts +28 -0
  347. package/dist/presets/index.d.ts +28 -0
  348. package/dist/presets/index.js +129 -0
  349. package/dist/presets/index.js.map +1 -0
  350. package/dist/presets/inspect/index.cjs +1087 -0
  351. package/dist/presets/inspect/index.cjs.map +1 -0
  352. package/dist/presets/inspect/index.d.cts +172 -0
  353. package/dist/presets/inspect/index.d.ts +172 -0
  354. package/dist/presets/inspect/index.js +21 -0
  355. package/dist/presets/inspect/index.js.map +1 -0
  356. package/dist/presets/resilience/index.cjs +1593 -0
  357. package/dist/presets/resilience/index.cjs.map +1 -0
  358. package/dist/presets/resilience/index.d.cts +205 -0
  359. package/dist/presets/resilience/index.d.ts +205 -0
  360. package/dist/presets/resilience/index.js +18 -0
  361. package/dist/presets/resilience/index.js.map +1 -0
  362. package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
  363. package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
  364. package/dist/reactive-layout-fswlBUvX.d.cts +195 -0
  365. package/dist/reactive-layout-fswlBUvX.d.ts +195 -0
  366. package/dist/retry-BDbRZ_gx.d.ts +125 -0
  367. package/dist/retry-DWuhjvsA.d.cts +125 -0
  368. package/dist/solutions/index.cjs +8200 -0
  369. package/dist/solutions/index.cjs.map +1 -0
  370. package/dist/solutions/index.d.cts +23 -0
  371. package/dist/solutions/index.d.ts +23 -0
  372. package/dist/solutions/index.js +55 -0
  373. package/dist/solutions/index.js.map +1 -0
  374. package/dist/spawnable-5mDY501F.d.cts +746 -0
  375. package/dist/spawnable-D3lR0oQu.d.ts +746 -0
  376. package/dist/status-U-rUI79b.d.cts +84 -0
  377. package/dist/status-U-rUI79b.d.ts +84 -0
  378. package/dist/timeout-U5O4ESK3.js +12 -0
  379. package/dist/timeout-U5O4ESK3.js.map +1 -0
  380. package/dist/types-BB5Lw-pB.d.cts +442 -0
  381. package/dist/types-BB5Lw-pB.d.ts +442 -0
  382. package/dist/types-CJWIMJiZ.d.ts +548 -0
  383. package/dist/types-vCq7ShIm.d.cts +548 -0
  384. package/dist/utils/ai/browser.cjs +2169 -0
  385. package/dist/utils/ai/browser.cjs.map +1 -0
  386. package/dist/utils/ai/browser.d.cts +129 -0
  387. package/dist/utils/ai/browser.d.ts +129 -0
  388. package/dist/utils/ai/browser.js +255 -0
  389. package/dist/utils/ai/browser.js.map +1 -0
  390. package/dist/utils/ai/index.cjs +8468 -0
  391. package/dist/utils/ai/index.cjs.map +1 -0
  392. package/dist/utils/ai/index.d.cts +1777 -0
  393. package/dist/utils/ai/index.d.ts +1777 -0
  394. package/dist/utils/ai/index.js +173 -0
  395. package/dist/utils/ai/index.js.map +1 -0
  396. package/dist/utils/ai/node.cjs +648 -0
  397. package/dist/utils/ai/node.cjs.map +1 -0
  398. package/dist/utils/ai/node.d.cts +57 -0
  399. package/dist/utils/ai/node.d.ts +57 -0
  400. package/dist/utils/ai/node.js +84 -0
  401. package/dist/utils/ai/node.js.map +1 -0
  402. package/dist/utils/cqrs/index.cjs +1036 -0
  403. package/dist/utils/cqrs/index.cjs.map +1 -0
  404. package/dist/utils/cqrs/index.d.cts +438 -0
  405. package/dist/utils/cqrs/index.d.ts +438 -0
  406. package/dist/utils/cqrs/index.js +18 -0
  407. package/dist/utils/cqrs/index.js.map +1 -0
  408. package/dist/utils/demo-shell/index.cjs +865 -0
  409. package/dist/utils/demo-shell/index.cjs.map +1 -0
  410. package/dist/utils/demo-shell/index.d.cts +90 -0
  411. package/dist/utils/demo-shell/index.d.ts +90 -0
  412. package/dist/utils/demo-shell/index.js +13 -0
  413. package/dist/utils/demo-shell/index.js.map +1 -0
  414. package/dist/utils/domain-templates/index.cjs +732 -0
  415. package/dist/utils/domain-templates/index.cjs.map +1 -0
  416. package/dist/utils/domain-templates/index.d.cts +214 -0
  417. package/dist/utils/domain-templates/index.d.ts +214 -0
  418. package/dist/utils/domain-templates/index.js +17 -0
  419. package/dist/utils/domain-templates/index.js.map +1 -0
  420. package/dist/utils/graphspec/index.cjs +1174 -0
  421. package/dist/utils/graphspec/index.cjs.map +1 -0
  422. package/dist/utils/graphspec/index.d.cts +449 -0
  423. package/dist/utils/graphspec/index.d.ts +449 -0
  424. package/dist/utils/graphspec/index.js +35 -0
  425. package/dist/utils/graphspec/index.js.map +1 -0
  426. package/dist/utils/harness/index.cjs +656 -0
  427. package/dist/utils/harness/index.cjs.map +1 -0
  428. package/dist/utils/harness/index.d.cts +542 -0
  429. package/dist/utils/harness/index.d.ts +542 -0
  430. package/dist/utils/harness/index.js +56 -0
  431. package/dist/utils/harness/index.js.map +1 -0
  432. package/dist/utils/index.cjs +17609 -0
  433. package/dist/utils/index.cjs.map +1 -0
  434. package/dist/utils/index.d.cts +96 -0
  435. package/dist/utils/index.d.ts +96 -0
  436. package/dist/utils/index.js +514 -0
  437. package/dist/utils/index.js.map +1 -0
  438. package/dist/utils/inspect/index.cjs +807 -0
  439. package/dist/utils/inspect/index.cjs.map +1 -0
  440. package/dist/utils/inspect/index.d.cts +123 -0
  441. package/dist/utils/inspect/index.d.ts +123 -0
  442. package/dist/utils/inspect/index.js +30 -0
  443. package/dist/utils/inspect/index.js.map +1 -0
  444. package/dist/utils/job-queue/index.cjs +717 -0
  445. package/dist/utils/job-queue/index.cjs.map +1 -0
  446. package/dist/utils/job-queue/index.d.cts +200 -0
  447. package/dist/utils/job-queue/index.d.ts +200 -0
  448. package/dist/utils/job-queue/index.js +18 -0
  449. package/dist/utils/job-queue/index.js.map +1 -0
  450. package/dist/utils/memory/index.cjs +1451 -0
  451. package/dist/utils/memory/index.cjs.map +1 -0
  452. package/dist/utils/memory/index.d.cts +582 -0
  453. package/dist/utils/memory/index.d.ts +582 -0
  454. package/dist/utils/memory/index.js +19 -0
  455. package/dist/utils/memory/index.js.map +1 -0
  456. package/dist/utils/messaging/index.cjs +666 -0
  457. package/dist/utils/messaging/index.cjs.map +1 -0
  458. package/dist/utils/messaging/index.d.cts +562 -0
  459. package/dist/utils/messaging/index.d.ts +562 -0
  460. package/dist/utils/messaging/index.js +50 -0
  461. package/dist/utils/messaging/index.js.map +1 -0
  462. package/dist/utils/orchestration/index.cjs +876 -0
  463. package/dist/utils/orchestration/index.cjs.map +1 -0
  464. package/dist/utils/orchestration/index.d.cts +233 -0
  465. package/dist/utils/orchestration/index.d.ts +233 -0
  466. package/dist/utils/orchestration/index.js +19 -0
  467. package/dist/utils/orchestration/index.js.map +1 -0
  468. package/dist/utils/process/index.cjs +743 -0
  469. package/dist/utils/process/index.cjs.map +1 -0
  470. package/dist/utils/process/index.d.cts +411 -0
  471. package/dist/utils/process/index.d.ts +411 -0
  472. package/dist/utils/process/index.js +14 -0
  473. package/dist/utils/process/index.js.map +1 -0
  474. package/dist/utils/reactive-layout/index.cjs +1607 -0
  475. package/dist/utils/reactive-layout/index.cjs.map +1 -0
  476. package/dist/utils/reactive-layout/index.d.cts +492 -0
  477. package/dist/utils/reactive-layout/index.d.ts +492 -0
  478. package/dist/utils/reactive-layout/index.js +52 -0
  479. package/dist/utils/reactive-layout/index.js.map +1 -0
  480. package/dist/utils/reduction/index.cjs +203 -0
  481. package/dist/utils/reduction/index.cjs.map +1 -0
  482. package/dist/utils/reduction/index.d.cts +102 -0
  483. package/dist/utils/reduction/index.d.ts +102 -0
  484. package/dist/utils/reduction/index.js +14 -0
  485. package/dist/utils/reduction/index.js.map +1 -0
  486. package/dist/utils/resilience/index.cjs +1617 -0
  487. package/dist/utils/resilience/index.cjs.map +1 -0
  488. package/dist/utils/resilience/index.d.cts +9 -0
  489. package/dist/utils/resilience/index.d.ts +9 -0
  490. package/dist/utils/resilience/index.js +44 -0
  491. package/dist/utils/resilience/index.js.map +1 -0
  492. package/dist/utils/surface/index.cjs +1070 -0
  493. package/dist/utils/surface/index.cjs.map +1 -0
  494. package/dist/utils/surface/index.d.cts +240 -0
  495. package/dist/utils/surface/index.d.ts +240 -0
  496. package/dist/utils/surface/index.js +30 -0
  497. package/dist/utils/surface/index.js.map +1 -0
  498. package/dist/utils/topology-view/index.cjs +620 -0
  499. package/dist/utils/topology-view/index.cjs.map +1 -0
  500. package/dist/utils/topology-view/index.d.cts +68 -0
  501. package/dist/utils/topology-view/index.d.ts +68 -0
  502. package/dist/utils/topology-view/index.js +11 -0
  503. package/dist/utils/topology-view/index.js.map +1 -0
  504. package/package.json +293 -237
  505. package/dist/core/index.cjs +0 -21
  506. package/dist/core/index.cjs.map +0 -1
  507. package/dist/core/index.d.cts +0 -1
  508. package/dist/core/index.d.ts +0 -1
  509. package/dist/core/index.js +0 -3
  510. package/dist/core/index.js.map +0 -1
  511. package/dist/extra/browser.cjs +0 -21
  512. package/dist/extra/browser.cjs.map +0 -1
  513. package/dist/extra/browser.d.cts +0 -1
  514. package/dist/extra/browser.d.ts +0 -1
  515. package/dist/extra/browser.js +0 -3
  516. package/dist/extra/browser.js.map +0 -1
  517. package/dist/extra/index.cjs +0 -21
  518. package/dist/extra/index.cjs.map +0 -1
  519. package/dist/extra/index.d.cts +0 -1
  520. package/dist/extra/index.d.ts +0 -1
  521. package/dist/extra/index.js +0 -3
  522. package/dist/extra/index.js.map +0 -1
  523. package/dist/extra/node.cjs +0 -21
  524. package/dist/extra/node.cjs.map +0 -1
  525. package/dist/extra/node.d.cts +0 -1
  526. package/dist/extra/node.d.ts +0 -1
  527. package/dist/extra/node.js +0 -3
  528. package/dist/extra/node.js.map +0 -1
  529. package/dist/extra/operators.cjs +0 -21
  530. package/dist/extra/operators.cjs.map +0 -1
  531. package/dist/extra/operators.d.cts +0 -1
  532. package/dist/extra/operators.d.ts +0 -1
  533. package/dist/extra/operators.js +0 -3
  534. package/dist/extra/operators.js.map +0 -1
  535. package/dist/extra/reactive.cjs +0 -21
  536. package/dist/extra/reactive.cjs.map +0 -1
  537. package/dist/extra/reactive.d.cts +0 -1
  538. package/dist/extra/reactive.d.ts +0 -1
  539. package/dist/extra/reactive.js +0 -3
  540. package/dist/extra/reactive.js.map +0 -1
  541. package/dist/extra/render/index.cjs +0 -21
  542. package/dist/extra/render/index.cjs.map +0 -1
  543. package/dist/extra/render/index.d.cts +0 -1
  544. package/dist/extra/render/index.d.ts +0 -1
  545. package/dist/extra/render/index.js +0 -3
  546. package/dist/extra/render/index.js.map +0 -1
  547. package/dist/extra/sources.cjs +0 -21
  548. package/dist/extra/sources.cjs.map +0 -1
  549. package/dist/extra/sources.d.cts +0 -1
  550. package/dist/extra/sources.d.ts +0 -1
  551. package/dist/extra/sources.js +0 -3
  552. package/dist/extra/sources.js.map +0 -1
  553. package/dist/extra/storage-browser.cjs +0 -21
  554. package/dist/extra/storage-browser.cjs.map +0 -1
  555. package/dist/extra/storage-browser.d.cts +0 -1
  556. package/dist/extra/storage-browser.d.ts +0 -1
  557. package/dist/extra/storage-browser.js +0 -3
  558. package/dist/extra/storage-browser.js.map +0 -1
  559. package/dist/extra/storage-core.cjs +0 -21
  560. package/dist/extra/storage-core.cjs.map +0 -1
  561. package/dist/extra/storage-core.d.cts +0 -1
  562. package/dist/extra/storage-core.d.ts +0 -1
  563. package/dist/extra/storage-core.js +0 -3
  564. package/dist/extra/storage-core.js.map +0 -1
  565. package/dist/extra/storage-node.cjs +0 -21
  566. package/dist/extra/storage-node.cjs.map +0 -1
  567. package/dist/extra/storage-node.d.cts +0 -1
  568. package/dist/extra/storage-node.d.ts +0 -1
  569. package/dist/extra/storage-node.js +0 -3
  570. package/dist/extra/storage-node.js.map +0 -1
  571. package/dist/extra/storage-tiers-browser.cjs +0 -21
  572. package/dist/extra/storage-tiers-browser.cjs.map +0 -1
  573. package/dist/extra/storage-tiers-browser.d.cts +0 -1
  574. package/dist/extra/storage-tiers-browser.d.ts +0 -1
  575. package/dist/extra/storage-tiers-browser.js +0 -3
  576. package/dist/extra/storage-tiers-browser.js.map +0 -1
  577. package/dist/extra/storage-tiers-node.cjs +0 -21
  578. package/dist/extra/storage-tiers-node.cjs.map +0 -1
  579. package/dist/extra/storage-tiers-node.d.cts +0 -1
  580. package/dist/extra/storage-tiers-node.d.ts +0 -1
  581. package/dist/extra/storage-tiers-node.js +0 -3
  582. package/dist/extra/storage-tiers-node.js.map +0 -1
  583. package/dist/extra/storage-tiers.cjs +0 -21
  584. package/dist/extra/storage-tiers.cjs.map +0 -1
  585. package/dist/extra/storage-tiers.d.cts +0 -1
  586. package/dist/extra/storage-tiers.d.ts +0 -1
  587. package/dist/extra/storage-tiers.js +0 -3
  588. package/dist/extra/storage-tiers.js.map +0 -1
  589. package/dist/extra/storage-wal.cjs +0 -21
  590. package/dist/extra/storage-wal.cjs.map +0 -1
  591. package/dist/extra/storage-wal.d.cts +0 -1
  592. package/dist/extra/storage-wal.d.ts +0 -1
  593. package/dist/extra/storage-wal.js +0 -3
  594. package/dist/extra/storage-wal.js.map +0 -1
  595. package/dist/graph/index.cjs +0 -21
  596. package/dist/graph/index.cjs.map +0 -1
  597. package/dist/graph/index.d.cts +0 -1
  598. package/dist/graph/index.d.ts +0 -1
  599. package/dist/graph/index.js +0 -3
  600. package/dist/graph/index.js.map +0 -1
  601. package/dist/patterns/ai/browser.cjs +0 -21
  602. package/dist/patterns/ai/browser.cjs.map +0 -1
  603. package/dist/patterns/ai/browser.d.cts +0 -1
  604. package/dist/patterns/ai/browser.d.ts +0 -1
  605. package/dist/patterns/ai/browser.js +0 -3
  606. package/dist/patterns/ai/browser.js.map +0 -1
  607. package/dist/patterns/ai/index.cjs +0 -21
  608. package/dist/patterns/ai/index.cjs.map +0 -1
  609. package/dist/patterns/ai/index.d.cts +0 -1
  610. package/dist/patterns/ai/index.d.ts +0 -1
  611. package/dist/patterns/ai/index.js +0 -3
  612. package/dist/patterns/ai/index.js.map +0 -1
  613. package/dist/patterns/ai/node.cjs +0 -21
  614. package/dist/patterns/ai/node.cjs.map +0 -1
  615. package/dist/patterns/ai/node.d.cts +0 -1
  616. package/dist/patterns/ai/node.d.ts +0 -1
  617. package/dist/patterns/ai/node.js +0 -3
  618. package/dist/patterns/ai/node.js.map +0 -1
  619. package/dist/patterns/cqrs/index.cjs +0 -21
  620. package/dist/patterns/cqrs/index.cjs.map +0 -1
  621. package/dist/patterns/cqrs/index.d.cts +0 -1
  622. package/dist/patterns/cqrs/index.d.ts +0 -1
  623. package/dist/patterns/cqrs/index.js +0 -3
  624. package/dist/patterns/cqrs/index.js.map +0 -1
  625. package/dist/patterns/demo-shell/index.cjs +0 -21
  626. package/dist/patterns/demo-shell/index.cjs.map +0 -1
  627. package/dist/patterns/demo-shell/index.d.cts +0 -1
  628. package/dist/patterns/demo-shell/index.d.ts +0 -1
  629. package/dist/patterns/demo-shell/index.js +0 -3
  630. package/dist/patterns/demo-shell/index.js.map +0 -1
  631. package/dist/patterns/domain-templates/index.cjs +0 -21
  632. package/dist/patterns/domain-templates/index.cjs.map +0 -1
  633. package/dist/patterns/domain-templates/index.d.cts +0 -1
  634. package/dist/patterns/domain-templates/index.d.ts +0 -1
  635. package/dist/patterns/domain-templates/index.js +0 -3
  636. package/dist/patterns/domain-templates/index.js.map +0 -1
  637. package/dist/patterns/graphspec/index.cjs +0 -21
  638. package/dist/patterns/graphspec/index.cjs.map +0 -1
  639. package/dist/patterns/graphspec/index.d.cts +0 -1
  640. package/dist/patterns/graphspec/index.d.ts +0 -1
  641. package/dist/patterns/graphspec/index.js +0 -3
  642. package/dist/patterns/graphspec/index.js.map +0 -1
  643. package/dist/patterns/harness/index.cjs +0 -21
  644. package/dist/patterns/harness/index.cjs.map +0 -1
  645. package/dist/patterns/harness/index.d.cts +0 -1
  646. package/dist/patterns/harness/index.d.ts +0 -1
  647. package/dist/patterns/harness/index.js +0 -3
  648. package/dist/patterns/harness/index.js.map +0 -1
  649. package/dist/patterns/inspect/index.cjs +0 -21
  650. package/dist/patterns/inspect/index.cjs.map +0 -1
  651. package/dist/patterns/inspect/index.d.cts +0 -1
  652. package/dist/patterns/inspect/index.d.ts +0 -1
  653. package/dist/patterns/inspect/index.js +0 -3
  654. package/dist/patterns/inspect/index.js.map +0 -1
  655. package/dist/patterns/job-queue/index.cjs +0 -21
  656. package/dist/patterns/job-queue/index.cjs.map +0 -1
  657. package/dist/patterns/job-queue/index.d.cts +0 -1
  658. package/dist/patterns/job-queue/index.d.ts +0 -1
  659. package/dist/patterns/job-queue/index.js +0 -3
  660. package/dist/patterns/job-queue/index.js.map +0 -1
  661. package/dist/patterns/memory/index.cjs +0 -21
  662. package/dist/patterns/memory/index.cjs.map +0 -1
  663. package/dist/patterns/memory/index.d.cts +0 -1
  664. package/dist/patterns/memory/index.d.ts +0 -1
  665. package/dist/patterns/memory/index.js +0 -3
  666. package/dist/patterns/memory/index.js.map +0 -1
  667. package/dist/patterns/messaging/index.cjs +0 -21
  668. package/dist/patterns/messaging/index.cjs.map +0 -1
  669. package/dist/patterns/messaging/index.d.cts +0 -1
  670. package/dist/patterns/messaging/index.d.ts +0 -1
  671. package/dist/patterns/messaging/index.js +0 -3
  672. package/dist/patterns/messaging/index.js.map +0 -1
  673. package/dist/patterns/orchestration/index.cjs +0 -21
  674. package/dist/patterns/orchestration/index.cjs.map +0 -1
  675. package/dist/patterns/orchestration/index.d.cts +0 -1
  676. package/dist/patterns/orchestration/index.d.ts +0 -1
  677. package/dist/patterns/orchestration/index.js +0 -3
  678. package/dist/patterns/orchestration/index.js.map +0 -1
  679. package/dist/patterns/process/index.cjs +0 -21
  680. package/dist/patterns/process/index.cjs.map +0 -1
  681. package/dist/patterns/process/index.d.cts +0 -1
  682. package/dist/patterns/process/index.d.ts +0 -1
  683. package/dist/patterns/process/index.js +0 -3
  684. package/dist/patterns/process/index.js.map +0 -1
  685. package/dist/patterns/reactive-layout/index.cjs +0 -21
  686. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  687. package/dist/patterns/reactive-layout/index.d.cts +0 -1
  688. package/dist/patterns/reactive-layout/index.d.ts +0 -1
  689. package/dist/patterns/reactive-layout/index.js +0 -3
  690. package/dist/patterns/reactive-layout/index.js.map +0 -1
  691. package/dist/patterns/reduction/index.cjs +0 -21
  692. package/dist/patterns/reduction/index.cjs.map +0 -1
  693. package/dist/patterns/reduction/index.d.cts +0 -1
  694. package/dist/patterns/reduction/index.d.ts +0 -1
  695. package/dist/patterns/reduction/index.js +0 -3
  696. package/dist/patterns/reduction/index.js.map +0 -1
  697. package/dist/patterns/surface/index.cjs +0 -21
  698. package/dist/patterns/surface/index.cjs.map +0 -1
  699. package/dist/patterns/surface/index.d.cts +0 -1
  700. package/dist/patterns/surface/index.d.ts +0 -1
  701. package/dist/patterns/surface/index.js +0 -3
  702. package/dist/patterns/surface/index.js.map +0 -1
  703. package/dist/patterns/topology-view/index.cjs +0 -21
  704. package/dist/patterns/topology-view/index.cjs.map +0 -1
  705. package/dist/patterns/topology-view/index.d.cts +0 -1
  706. package/dist/patterns/topology-view/index.d.ts +0 -1
  707. package/dist/patterns/topology-view/index.js +0 -3
  708. package/dist/patterns/topology-view/index.js.map +0 -1
  709. package/dist/testing/index.cjs +0 -21
  710. package/dist/testing/index.cjs.map +0 -1
  711. package/dist/testing/index.d.cts +0 -1
  712. package/dist/testing/index.d.ts +0 -1
  713. package/dist/testing/index.js +0 -3
  714. package/dist/testing/index.js.map +0 -1
@@ -0,0 +1,1777 @@
1
+ import { i as TokenUsage, L as LLMAdapter, g as PricingFn, a as ChatMessage, b as LLMInvokeOptions, k as ToolDefinition, c as LLMResponse, S as StreamDelta } from '../../types-BB5Lw-pB.cjs';
2
+ export { C as CapabilitiesRegistry, M as ModelCapabilities, d as ModelFeatures, e as ModelLimits, f as ModelPricing, P as PriceBreakdown, h as PricingRegistry, R as Rate, T as TieredRate, j as ToolCall, l as composePricing, m as computePrice, n as createCapabilitiesRegistry, o as createPricingRegistry, p as pricingFor, r as registryPricing, z as zeroPrice } from '../../types-BB5Lw-pB.cjs';
3
+ import { C as CascadeExhaustionReport } from '../../cascading-baGkiihI.cjs';
4
+ export { A as AdapterProvider, a as AdapterTier, b as AllTiersExhaustedError, c as CascadingLlmAdapterOptions, d as CreateAdapterOptions, O as OpenAICompatAdapterOptions, e as OpenAICompatPreset, f as OpenAISdkLike, g as cascadingLlmAdapter, h as createAdapter, o as openAICompatAdapter, t as tier } from '../../cascading-baGkiihI.cjs';
5
+ import { Node, Actor } from '@graphrefly/pure-ts/core';
6
+ import { ReactiveLogBundle, NodeInput } from '@graphrefly/pure-ts/extra';
7
+ import { a as CircuitBreakerOptions, C as CircuitBreaker } from '../../breaker-ugSdq54q.cjs';
8
+ export { b as CircuitOpenError } from '../../breaker-ugSdq54q.cjs';
9
+ import { R as RateLimitSignal, A as AdaptiveRateLimiterBundle } from '../../adaptive-rate-limiter-Dch_xYIi.cjs';
10
+ import { W as WithReplayCacheOptions } from '../../fallback-Bx46zqky.cjs';
11
+ export { F as FallbackAdapterOptions, a as FallbackFixture, b as FallbackMissError, c as FallbackMissPolicy, R as ReplayCacheKeyContext, d as ReplayCacheMissError, e as ReplayCacheMode, f as fallbackAdapter, w as withReplayCache } from '../../fallback-Bx46zqky.cjs';
12
+ import { E as Extraction } from '../../distill-De6Rnn15.cjs';
13
+ import { Graph } from '@graphrefly/pure-ts/graph';
14
+ import { TopicGraph } from '../messaging/index.cjs';
15
+ import { G as GateController, c as GateOptions } from '../../pipeline-graph-Ce47CB6Y.cjs';
16
+ export { C as ChatStreamGraph, a as ChatStreamOptions, M as MemoryRetrievalGraph, b as MemoryRetrievalOptions, c as MemoryTier, d as MemoryTiersBundle, e as MemoryTiersOptions, f as MemoryWithKGGraph, g as MemoryWithKGOptions, h as MemoryWithTiersGraph, i as MemoryWithTiersOptions, j as MemoryWithVectorsGraph, k as MemoryWithVectorsOptions, R as RetrievalEntry, l as RetrievalPipelineOptions, m as RetrievalQuery, n as RetrievalTrace, T as ToolExecutionOptions, o as ToolRegistryGraph, p as ToolRegistryOptions, q as ToolResult, r as chatStream, s as memoryRetrieval, t as memoryWithKG, u as memoryWithTiers, v as memoryWithVectors, w as toolExecution, x as toolRegistry } from '../../memory-composers-BryDrRBX.cjs';
17
+ import { GraphSpecCatalog } from '../graphspec/index.cjs';
18
+ export { DEFAULT_DECAY_RATE } from '../../base/utils/index.cjs';
19
+ import '../../_internal-B23BagFd.cjs';
20
+ import '../../backoff-Bnb9OoPh.cjs';
21
+ import '../../base/mutation/index.cjs';
22
+ import '../memory/index.cjs';
23
+
24
+ /**
25
+ * Observable adapter wrapper — the "inverted statistics" surface.
26
+ *
27
+ * The library emits structured facts (token counts, latency, timestamps)
28
+ * as reactive nodes. Users compose interpretation (pricing, dashboards,
29
+ * telemetry, budget breakers) as derived layers on top.
30
+ */
31
+
32
+ /** One call's structured statistics — emitted after `invoke()` / `stream()` settles. */
33
+ interface CallStatsEvent {
34
+ /** `monotonicNs()` at call completion — use for event ordering. */
35
+ readonly timestamp: number;
36
+ /** `wallClockNs()` at call start — use for human-readable attribution. */
37
+ readonly wallClock: number;
38
+ readonly provider: string;
39
+ readonly model: string;
40
+ readonly tier?: string;
41
+ readonly usage: TokenUsage;
42
+ readonly latencyMs: number;
43
+ /** `"invoke"` or `"stream"`. */
44
+ readonly method: "invoke" | "stream";
45
+ /** Populated when the call errored — usage may be zero or partial. */
46
+ readonly error?: {
47
+ readonly type: string;
48
+ readonly message: string;
49
+ };
50
+ }
51
+ interface AdapterStats {
52
+ /**
53
+ * Reactive node for the most-recent call event. Emits `null` initially
54
+ * (no calls yet); emits a {@link CallStatsEvent} after each call. Subscribe
55
+ * and filter `!= null` if you want a `Node<CallStatsEvent>`.
56
+ */
57
+ readonly lastCall: Node<CallStatsEvent | null>;
58
+ /** Full event log (bounded by `opts.logMax`, default 1000). */
59
+ readonly allCalls: ReactiveLogBundle<CallStatsEvent>;
60
+ /** Total calls observed since last reset. */
61
+ readonly totalCalls: Node<number>;
62
+ /** Sum of every input-token class across observed calls. */
63
+ readonly totalInputTokens: Node<number>;
64
+ /** Sum of every output-token class across observed calls. */
65
+ readonly totalOutputTokens: Node<number>;
66
+ /** Reset all counters + clear the log. */
67
+ reset(): void;
68
+ /**
69
+ * Release the internal keepalive subscriptions on the three counter
70
+ * derives (`totalCalls` / `totalInputTokens` / `totalOutputTokens`) so the
71
+ * bundle can be GC'd when the caller discards it. Idempotent. Long-lived
72
+ * adapter bundles (module-level singletons) can ignore; transient bundles
73
+ * (per-request / per-user) should call on teardown.
74
+ */
75
+ dispose(): void;
76
+ }
77
+ /**
78
+ * Wrap any {@link LLMAdapter} with a reactive stats bundle.
79
+ *
80
+ * Implementation (Unit 10 B):
81
+ * - `stats.lastCall` is a `state<CallStatsEvent | null>`.
82
+ * - Counters (`totalCalls` / `totalInputTokens` / `totalOutputTokens`) are
83
+ * **derived views** over `allCalls.entries` — self-maintaining, no manual
84
+ * `.cache + 1 + emit` pattern, visible topology in `describe()`.
85
+ * - `stats.allCalls` is a `reactiveLog<CallStatsEvent>` — bounded, supports
86
+ * `tail(n)` / `slice(start, stop)` for dashboard views.
87
+ * - The wrapped adapter passes DATA through via `adaptInvokeResult`, which
88
+ * uses `onFirstData` internally to guard against re-subscription double-fire
89
+ * and wires `.catch` for Promise-path error recording (Unit 10 A).
90
+ */
91
+ declare function observableAdapter(inner: LLMAdapter, opts?: {
92
+ logMax?: number;
93
+ name?: string;
94
+ }): {
95
+ adapter: LLMAdapter;
96
+ stats: AdapterStats;
97
+ };
98
+
99
+ /**
100
+ * `withBreaker` — circuit-breaker middleware for LLM adapters.
101
+ *
102
+ * Reuses the library's existing `circuitBreaker` primitive from
103
+ * `extra/resilience.ts`. When the breaker is open, calls throw
104
+ * `CircuitOpenError` instead of hitting the provider.
105
+ */
106
+
107
+ interface WithBreakerOptions extends CircuitBreakerOptions {
108
+ /**
109
+ * Optional external breaker — pass a shared instance to wire the same
110
+ * breaker across multiple adapters (e.g. all tiers of a `cascadingLlmAdapter`).
111
+ */
112
+ breaker?: CircuitBreaker;
113
+ }
114
+ declare function withLLMBreaker(inner: LLMAdapter, opts?: WithBreakerOptions): {
115
+ adapter: LLMAdapter;
116
+ breaker: CircuitBreaker;
117
+ };
118
+
119
+ /**
120
+ * `withBudgetGate` — cap an adapter by calls / tokens / USD.
121
+ *
122
+ * Totals are an O(1)-per-event running accumulator (a `state<BudgetTotals>`
123
+ * updated imperatively inside `record()`), not a derived reduce over the
124
+ * full log — avoids the quadratic cost at sustained traffic while preserving
125
+ * the reactive surface. The full log is still exposed via the bundle for
126
+ * dashboards / auditors.
127
+ *
128
+ * Budgets are enforced imperatively at `invoke()` / `stream()` entry — the
129
+ * running totals + `isOpen.cache` are read; if closed, the call rejects /
130
+ * throws `BudgetExhaustedError` without hitting the wrapped adapter. On
131
+ * success, the call's usage is appended to the log AND debits the running
132
+ * totals in a single synchronous update.
133
+ *
134
+ * Wave A Unit 11 Q4: rejected-Promise path now wires `.catch` (via
135
+ * `adaptInvokeResult.onError`) so failed invoke calls record a CallStatsEvent
136
+ * with `error` populated. Prior code silently dropped rejection from the
137
+ * `totals` / `log` surface.
138
+ */
139
+
140
+ declare class BudgetExhaustedError extends Error {
141
+ readonly which: string;
142
+ readonly limit: number;
143
+ readonly observed: number;
144
+ name: string;
145
+ constructor(which: string, limit: number, observed: number);
146
+ }
147
+ interface BudgetCaps {
148
+ calls?: number;
149
+ inputTokens?: number;
150
+ outputTokens?: number;
151
+ usd?: number;
152
+ }
153
+ interface BudgetTotals {
154
+ calls: number;
155
+ inputTokens: number;
156
+ outputTokens: number;
157
+ usd: number;
158
+ }
159
+ interface LLMBudgetGateBundle {
160
+ totals: Node<BudgetTotals>;
161
+ isOpen: Node<boolean>;
162
+ log: ReactiveLogBundle<CallStatsEvent>;
163
+ reset(): void;
164
+ /**
165
+ * QA D2 (Phase 13.6.B QA pass): release every long-lived
166
+ * subscription this gate holds — `keepalive(isOpen)`, the optional
167
+ * `onExhausted` subscription, and the Lock 3.C abort fan-out
168
+ * subscription on `isOpen`. Aborts any in-flight controllers as a
169
+ * defensive last gasp so callers waiting on a soon-to-be-disposed
170
+ * adapter don't hang.
171
+ *
172
+ * Idempotent: subsequent calls are no-ops. After `dispose()` the
173
+ * adapter wrapper continues to wrap `inner.invoke` / `inner.stream`
174
+ * but the budget machinery is best-effort: `record()` no longer
175
+ * emits `totals` updates, abort fan-out no longer fires. Treat the
176
+ * bundle as terminated once disposed; long-running apps should
177
+ * `dispose()` per gate instance to avoid the sub-leak documented
178
+ * in `docs/optimizations.md`.
179
+ */
180
+ dispose(): void;
181
+ }
182
+ interface WithBudgetGateOptions {
183
+ caps: BudgetCaps;
184
+ /**
185
+ * Optional pricing function for USD gating. If omitted, `caps.usd` is
186
+ * ignored (caps.calls / caps.inputTokens / caps.outputTokens still apply).
187
+ */
188
+ pricingFn?: PricingFn;
189
+ /**
190
+ * Edge-triggered: fires exactly once when the gate transitions from
191
+ * open to closed. Subsequent invoke/stream attempts against a closed
192
+ * gate do NOT re-fire `onExhausted` — use the reactive `isOpen` node
193
+ * if you need per-attempt notifications. Receives the cap key that
194
+ * triggered the transition.
195
+ */
196
+ onExhausted?: (which: keyof BudgetCaps) => void;
197
+ /** Name for logs / describe output. */
198
+ name?: string;
199
+ /** Max events retained in the log (default 1000). */
200
+ logMax?: number;
201
+ }
202
+ /**
203
+ * Wrap an adapter with budget enforcement. Returns `{adapter, budget}` so
204
+ * callers can subscribe to the bundle for dashboards.
205
+ */
206
+ declare function withBudgetGate(inner: LLMAdapter, opts: WithBudgetGateOptions): {
207
+ adapter: LLMAdapter;
208
+ budget: LLMBudgetGateBundle;
209
+ };
210
+
211
+ /**
212
+ * `withDryRun` — short-circuit to a fake adapter when a flag is on.
213
+ *
214
+ * Useful for CI / preflight / cost-safety pipelines: wrap a real adapter,
215
+ * pass `enabled: true` (or a reactive flag) to bypass the wire call. Default
216
+ * shim is {@link dryRunAdapter}; callers can supply their own.
217
+ *
218
+ * **Returns `{adapter, dispose}`** — call `dispose()` to release the internal
219
+ * keepalive on the reactive `enabled` input. Long-lived adapter instances
220
+ * (module-level singletons) can ignore dispose; transient adapters (per-
221
+ * request or per-user) should call it on teardown to allow the source to
222
+ * be GC'd.
223
+ */
224
+
225
+ interface WithDryRunOptions {
226
+ /**
227
+ * Toggle — `true` always dry-runs; `false` always passes through; a
228
+ * `NodeInput<boolean>` reads the current value at call time (factory-time
229
+ * seed pattern, live-tunable).
230
+ */
231
+ enabled: NodeInput<boolean>;
232
+ /** Dry-run adapter override. Default: `dryRunAdapter({ provider: inner.provider, model: inner.model })`. */
233
+ mock?: LLMAdapter;
234
+ }
235
+ interface WithDryRunBundle {
236
+ adapter: LLMAdapter;
237
+ /**
238
+ * Release the internal keepalive subscription on the reactive `enabled`
239
+ * input. Idempotent. Safe to ignore on long-lived adapters.
240
+ */
241
+ dispose(): void;
242
+ }
243
+ declare function withDryRun(inner: LLMAdapter, opts: WithDryRunOptions): WithDryRunBundle;
244
+
245
+ /**
246
+ * HTTP 429 / rate-limit parser.
247
+ *
248
+ * Produces a {@link RateLimitSignal} from provider HTTP errors so adaptive
249
+ * rate limiters can tighten effective limits. Normalizes:
250
+ * - `Retry-After` (seconds or HTTP-date)
251
+ * - `x-ratelimit-reset` / `x-ratelimit-reset-tokens` (epoch secs or duration)
252
+ * - `x-ratelimit-remaining-{requests,tokens}` + `x-ratelimit-limit-*`
253
+ * - Anthropic `anthropic-ratelimit-*` headers
254
+ * - OpenAI / OpenRouter / Groq headers (same family)
255
+ * - Error message regex fallbacks for providers without structured headers
256
+ */
257
+
258
+ interface HttpErrorLike {
259
+ status?: number;
260
+ headers?: Headers | Record<string, string | string[] | undefined>;
261
+ message?: string;
262
+ }
263
+ /**
264
+ * Extract a {@link RateLimitSignal} from a fetch-style error object, a Response,
265
+ * or any object exposing `.status` + `.headers` + `.message`.
266
+ *
267
+ * Returns `undefined` if no rate-limit information can be extracted.
268
+ */
269
+ declare function parseRateLimitFromError(err: unknown): RateLimitSignal | undefined;
270
+
271
+ /**
272
+ * `withRateLimiter` — adapter middleware bridging to the reactive
273
+ * `adaptiveRateLimiter` primitive.
274
+ *
275
+ * - Consumes live `rpm`/`tpm` caps as reactive `NodeInput<number>` so
276
+ * callers can retune at runtime (e.g. from a `ModelLimits.rpm` node).
277
+ * - Adapts to provider 429 responses via `http429Parser` fed into the
278
+ * limiter's `adaptation` signal.
279
+ * - `costFn` estimates token cost pre-call (e.g. char-based approximation);
280
+ * the post-call actual usage is fed back via `limiter.recordUsage()`.
281
+ */
282
+
283
+ interface WithRateLimiterOptions {
284
+ /** Live rpm cap (defaults to `Infinity`). */
285
+ rpm?: NodeInput<number>;
286
+ /** Live tpm cap (defaults to `Infinity`). */
287
+ tpm?: NodeInput<number>;
288
+ /**
289
+ * Pre-call token-cost estimate. Default: 0 (only rpm gates). Override with
290
+ * e.g. a char-based heuristic:
291
+ * `(msgs) => Math.ceil(msgs.reduce((s, m) => s + m.content.length, 0) / 4)`.
292
+ */
293
+ costFn?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => number;
294
+ /**
295
+ * Manual adaptation signal source. Defaults to a signal derived from
296
+ * provider errors via `parseRateLimitFromError` — users can supply a
297
+ * custom signal chain if they route errors elsewhere.
298
+ */
299
+ adaptation?: NodeInput<RateLimitSignal>;
300
+ burstMultiplier?: number;
301
+ name?: string;
302
+ /**
303
+ * Share an existing {@link AdaptiveRateLimiterBundle} across multiple
304
+ * adapter wraps. When provided, `withRateLimiter` reuses this bundle
305
+ * instead of constructing a new one — useful when the RPM/TPM cap is
306
+ * logically per-provider but the caller wants to harden multiple adapters
307
+ * (e.g. primary + fallback of the same vendor) against the shared cap.
308
+ *
309
+ * When `limiter` is set, `rpm` / `tpm` / `adaptation` / `burstMultiplier`
310
+ * / `name` are ignored (the supplied bundle owns those). `costFn` is still
311
+ * used per-wrap — each wrap supplies its own cost estimator.
312
+ */
313
+ limiter?: AdaptiveRateLimiterBundle;
314
+ }
315
+ /**
316
+ * Wrap an adapter with adaptive rate limiting. Returns `{adapter, limiter}`
317
+ * so callers can subscribe to limiter internals (rpmAvailable, pending, etc.)
318
+ * for dashboards.
319
+ */
320
+ declare function withRateLimiter(inner: LLMAdapter, opts?: WithRateLimiterOptions): {
321
+ adapter: LLMAdapter;
322
+ limiter: AdaptiveRateLimiterBundle;
323
+ };
324
+
325
+ /**
326
+ * `withRetry` — retry `invoke()` / `stream()` on transient errors.
327
+ *
328
+ * Streaming retry is tricky: we retry only if the stream fails before
329
+ * yielding any tokens. Once tokens have started flowing, we surface the
330
+ * error to avoid replaying from scratch (which would double-bill and
331
+ * confuse consumers). Opt out of streaming retry via `opts.retryStreaming = false`.
332
+ *
333
+ * Uses `ResettableTimer` for backoff sleeps (spec §5.10 escape hatch, same
334
+ * pattern as `extra/resilience.ts`). Abort-aware — early-aborts before the
335
+ * first attempt and cleans up the abort listener on both the timer-fires
336
+ * and abort paths.
337
+ */
338
+
339
+ interface WithRetryOptions {
340
+ /** Max total attempts (including the first). Default 3. */
341
+ attempts?: number;
342
+ /** Base delay in ms. Default 500. */
343
+ baseDelayMs?: number;
344
+ /** Max delay in ms. Default 10_000. */
345
+ maxDelayMs?: number;
346
+ /**
347
+ * Delay strategy. Default `"decorrelated"` — AWS-style `random(baseDelay,
348
+ * min(maxDelay, prev * 3))` which smooths retry storms and matches common
349
+ * SDK expectations. `"exp"` and `"linear"` produce deterministic schedules
350
+ * when `jitter: false`.
351
+ */
352
+ strategy?: "exp" | "linear" | "decorrelated";
353
+ /**
354
+ * Add randomized jitter. Ignored for `strategy: "decorrelated"` (which is
355
+ * inherently jittered). For `exp`/`linear`, symmetric jitter in `[0.5x,
356
+ * 1.5x]` of the nominal delay.
357
+ */
358
+ jitter?: boolean;
359
+ /**
360
+ * Predicate: should this error trigger a retry? Default retries network /
361
+ * 5xx / 429 / transient errors, but not 4xx (other than 429), aborts, or
362
+ * `BudgetExhaustedError` from upstream middleware.
363
+ */
364
+ shouldRetry?: (err: unknown, attempt: number) => boolean;
365
+ /** Retry streaming calls if they fail pre-first-token. Default true. */
366
+ retryStreaming?: boolean;
367
+ }
368
+ declare function withRetry(inner: LLMAdapter, opts?: WithRetryOptions): LLMAdapter;
369
+
370
+ /**
371
+ * `resilientAdapter` — compose `withRateLimiter` + `withBudgetGate` +
372
+ * `withLLMBreaker` + `withLLMTimeout` + `withRetry` + fallback over an {@link LLMAdapter}.
373
+ *
374
+ * Call-path peer of {@link resilientPipeline} (which operates on a reactive
375
+ * `Node<T>` chain). Use `resilientPipeline` when composing graph sources; use
376
+ * `resilientAdapter` when wrapping an adapter so downstream users see a
377
+ * single hardened `invoke`/`stream` surface.
378
+ *
379
+ * Composition order (innermost to outermost, mirrors `resilientPipeline`):
380
+ *
381
+ * ```text
382
+ * rateLimit → budget → breaker → timeout → retry → fallback
383
+ * ```
384
+ *
385
+ * Rationale:
386
+ * - **rateLimit innermost** — each attempt acquires a fresh slot; a retry
387
+ * after a 429 waits for admission rather than bursting past the cap.
388
+ * - **budget next** — per-attempt gate close short-circuits retries once a
389
+ * cap trips.
390
+ * - **breaker next** — each attempt observes circuit health; open breaker
391
+ * fast-fails retries into fallback.
392
+ * - **timeout before retry** — each retry re-arms a fresh per-attempt
393
+ * deadline. If `timeout` wrapped `retry`, a single deadline would cover
394
+ * the entire retry chain — surprising for callers.
395
+ * - **retry before fallback** — fallback is entered only after the primary
396
+ * exhausts its retry budget (or immediately fails in a way the predicate
397
+ * doesn't retry).
398
+ *
399
+ * Every option is optional — omit the field and that layer is skipped. The
400
+ * returned bundle exposes the primary adapter plus the internal bundles
401
+ * (`rateLimiter`, `budget`, `breaker`) so callers can wire them into
402
+ * dashboards, alerts, or `graphLens`.
403
+ *
404
+ * Fallback is implemented via {@link cascadingLlmAdapter}: when `fallback`
405
+ * is provided, the wrapped primary adapter is placed at tier 0 and the
406
+ * fallback adapter at tier 1. For N-tier cascades, use `cascadingLlmAdapter`
407
+ * directly and wrap each tier with `resilientAdapter`.
408
+ *
409
+ * @module
410
+ */
411
+
412
+ /** Options for {@link resilientAdapter}. Every field is optional — omit to skip that layer. */
413
+ interface ResilientAdapterOptions {
414
+ /** Admission control. See {@link withRateLimiter}. */
415
+ rateLimit?: WithRateLimiterOptions;
416
+ /** Cost/cap gate. See {@link withBudgetGate}. */
417
+ budget?: WithBudgetGateOptions;
418
+ /** Circuit breaker. See {@link withBreaker}. */
419
+ breaker?: WithBreakerOptions;
420
+ /** Per-attempt deadline in milliseconds. Omit to skip the timeout wrap. */
421
+ timeoutMs?: number;
422
+ /** Retry policy on transient errors. See {@link withRetry}. */
423
+ retry?: WithRetryOptions;
424
+ /**
425
+ * Fallback adapter engaged when the primary (post-retry) fails. Implemented
426
+ * via {@link cascadingLlmAdapter} — the primary becomes tier 0, the
427
+ * fallback becomes tier 1. For N-tier cascades, use `cascadingLlmAdapter`
428
+ * directly and wrap each tier with `resilientAdapter` as needed.
429
+ */
430
+ fallback?: LLMAdapter;
431
+ /** Name used as the primary tier name in the fallback cascade. Default `"primary"`. */
432
+ name?: string;
433
+ /**
434
+ * Called when the cascade switches from one tier to the next after a
435
+ * failure. Only fires when `fallback` is set. Threaded directly to the
436
+ * inner {@link cascadingLlmAdapter}.
437
+ */
438
+ onFallback?: (from: string, to: string, error: unknown) => void;
439
+ /**
440
+ * Called when every tier in the cascade has been exhausted (all failed,
441
+ * skipped by filter, or skipped by breaker). Only fires when `fallback`
442
+ * is set. Threaded directly to the inner {@link cascadingLlmAdapter}.
443
+ */
444
+ onExhausted?: (report: CascadeExhaustionReport) => void;
445
+ /**
446
+ * Content-addressed replay cache wrapped OUTERMOST — a cache HIT short-
447
+ * circuits the entire stack (rate-limit / budget / breaker / retry /
448
+ * fallback), saving money and latency. Cache MISSes flow through the
449
+ * normal stack; the successful result is stored on success. See
450
+ * {@link withReplayCache}.
451
+ */
452
+ cache?: WithReplayCacheOptions;
453
+ }
454
+ /** Output bundle of {@link resilientAdapter}. */
455
+ interface ResilientAdapterBundle {
456
+ /** The final hardened adapter. */
457
+ adapter: LLMAdapter;
458
+ /** Rate-limiter internals (for dashboards). Present only when `opts.rateLimit` was set. */
459
+ rateLimiter?: AdaptiveRateLimiterBundle;
460
+ /** Budget gate internals (for dashboards). Present only when `opts.budget` was set. */
461
+ budget?: LLMBudgetGateBundle;
462
+ /** Circuit breaker (for dashboards). Present only when `opts.breaker` was set. */
463
+ breaker?: CircuitBreaker;
464
+ }
465
+ /**
466
+ * Wrap `inner` with the standard resilience stack. See module docs for the
467
+ * composition order and rationale.
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * const { adapter, budget, breaker } = resilientAdapter(openai, {
472
+ * rateLimit: { rpm: 60, tpm: 90_000 },
473
+ * budget: { caps: { usd: 5 } },
474
+ * breaker: { failureThreshold: 5, resetTimeoutMs: 30_000 },
475
+ * timeoutMs: 30_000,
476
+ * retry: { attempts: 3 },
477
+ * fallback: webllm, // cascades to local on exhaustion
478
+ * });
479
+ *
480
+ * // `adapter` is drop-in for anything expecting LLMAdapter.
481
+ * // Subscribe to `budget.totals`, `breaker.state`, etc. for dashboards.
482
+ * ```
483
+ */
484
+ declare function resilientAdapter(inner: LLMAdapter, opts?: ResilientAdapterOptions): ResilientAdapterBundle;
485
+
486
+ /**
487
+ * `withLLMTimeout` — cancel `invoke()` / `stream()` after `ms` elapse.
488
+ *
489
+ * Wires a child AbortSignal so provider adapters can honor the cancellation
490
+ * (all shipped adapters forward `signal` through to their fetch / SDK call).
491
+ *
492
+ * Uses `ResettableTimer` rather than raw `setTimeout` — same pattern as
493
+ * `extra/resilience.ts` (spec §5.10 escape hatch documented on the class).
494
+ */
495
+
496
+ declare class LLMTimeoutError extends Error {
497
+ readonly ms: number;
498
+ name: string;
499
+ constructor(ms: number);
500
+ }
501
+ declare function withLLMTimeout(inner: LLMAdapter, ms: number): LLMAdapter;
502
+
503
+ /**
504
+ * AnthropicAdapter — default fetch-backed, optional SDK-backed.
505
+ *
506
+ * - `anthropicAdapter({ apiKey })` uses native `fetch` + SSE parsing.
507
+ * - `anthropicAdapter({ sdk })` delegates to a user-provided `@anthropic-ai/sdk` instance.
508
+ *
509
+ * Token usage mapping:
510
+ * - `input_tokens` → `input.regular`
511
+ * - `cache_read_input_tokens` → `input.cacheRead`
512
+ * - `cache_creation.ephemeral_5m_input_tokens` → `input.cacheWrite5m`
513
+ * - `cache_creation.ephemeral_1h_input_tokens` → `input.cacheWrite1h`
514
+ * - `cache_creation_input_tokens` (legacy) → `input.cacheWrite5m` (default TTL)
515
+ * - `output_tokens` → `output.regular`
516
+ * - `server_tool_use.web_search_requests` → `auxiliary.webSearchRequests`
517
+ */
518
+
519
+ interface AnthropicAdapterOptions {
520
+ /** API key. Falls back to `process.env.ANTHROPIC_API_KEY` on Node. */
521
+ apiKey?: string;
522
+ /** Default model (overridable per-call via `LLMInvokeOptions.model`). */
523
+ model?: string;
524
+ /** Override the base URL. Default `https://api.anthropic.com`. */
525
+ baseURL?: string;
526
+ /** API version header. Default `"2023-06-01"`. */
527
+ anthropicVersion?: string;
528
+ /** Additional headers to send on every request (overridden by per-call). */
529
+ headers?: Record<string, string>;
530
+ /**
531
+ * User-provided SDK instance. When present, the adapter delegates to it
532
+ * (uses `.messages.create`) instead of native fetch.
533
+ * Shape matches `@anthropic-ai/sdk` `.messages` API; any object with a
534
+ * compatible `create`/`stream` contract works.
535
+ */
536
+ sdk?: AnthropicSdkLike;
537
+ /** Custom fetch (useful for tests). Default `globalThis.fetch`. */
538
+ fetchImpl?: typeof fetch;
539
+ }
540
+ /** Minimal SDK shape we interoperate with. */
541
+ interface AnthropicSdkLike {
542
+ messages: {
543
+ create(params: Record<string, unknown>, opts?: {
544
+ signal?: AbortSignal;
545
+ }): Promise<AnthropicMessageResponse>;
546
+ stream?(params: Record<string, unknown>, opts?: {
547
+ signal?: AbortSignal;
548
+ }): AsyncIterable<AnthropicStreamEvent>;
549
+ };
550
+ }
551
+ interface AnthropicMessageResponse {
552
+ id: string;
553
+ content: ReadonlyArray<{
554
+ type: "text";
555
+ text: string;
556
+ } | {
557
+ type: "tool_use";
558
+ id: string;
559
+ name: string;
560
+ input: Record<string, unknown>;
561
+ } | {
562
+ type: "thinking";
563
+ thinking: string;
564
+ } | {
565
+ type: string;
566
+ [key: string]: unknown;
567
+ }>;
568
+ stop_reason?: string;
569
+ usage: AnthropicUsage;
570
+ model?: string;
571
+ }
572
+ interface AnthropicUsage {
573
+ input_tokens?: number;
574
+ output_tokens?: number;
575
+ cache_read_input_tokens?: number;
576
+ cache_creation_input_tokens?: number;
577
+ cache_creation?: {
578
+ ephemeral_5m_input_tokens?: number;
579
+ ephemeral_1h_input_tokens?: number;
580
+ };
581
+ server_tool_use?: {
582
+ web_search_requests?: number;
583
+ };
584
+ }
585
+ type AnthropicStreamEvent = {
586
+ type: "message_start";
587
+ message: {
588
+ usage: AnthropicUsage;
589
+ };
590
+ } | {
591
+ type: "content_block_start";
592
+ index: number;
593
+ content_block: Record<string, unknown>;
594
+ } | {
595
+ type: "content_block_delta";
596
+ index: number;
597
+ delta: Record<string, unknown>;
598
+ } | {
599
+ type: "content_block_stop";
600
+ index: number;
601
+ } | {
602
+ type: "message_delta";
603
+ delta: {
604
+ stop_reason?: string;
605
+ usage?: AnthropicUsage;
606
+ };
607
+ } | {
608
+ type: "message_stop";
609
+ } | {
610
+ type: string;
611
+ [key: string]: unknown;
612
+ };
613
+ declare function anthropicAdapter(opts?: AnthropicAdapterOptions): LLMAdapter;
614
+
615
+ /**
616
+ * DryRunAdapter — zero-cost mock provider.
617
+ *
618
+ * Returns a deterministic fake response (plus a configurable hook for
619
+ * customization). Useful for: pipeline smoke tests, CI without API keys,
620
+ * local development, and as the leaf of a `cascadingLlmAdapter` when every
621
+ * real tier fails.
622
+ *
623
+ * The library ships a minimal implementation only — richer scenario-
624
+ * scripted mocks (per-stage responses, call recording) belong at the test
625
+ * harness layer, not in the shipped library.
626
+ *
627
+ * Uses `ResettableTimer` for simulated latency (spec §5.10 escape hatch
628
+ * documented on the class), and throws an `AbortError`-named Error on
629
+ * abort so retry/timeout middleware can classify it.
630
+ */
631
+
632
+ interface DryRunAdapterOptions {
633
+ provider?: string;
634
+ model?: string;
635
+ /** Generate the fake response. Defaults to echoing the last user message. */
636
+ respond?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => string;
637
+ /**
638
+ * Generate a fake usage object. Defaults to a simple character-count
639
+ * heuristic (`input = sum(messages) / 4`, `output = content / 4`).
640
+ */
641
+ usage?: (messages: readonly ChatMessage[], content: string) => TokenUsage;
642
+ /** Simulated latency in milliseconds (applied to both invoke and stream). */
643
+ latencyMs?: number;
644
+ /** Stream chunk size in characters. Default 16. */
645
+ streamChunkSize?: number;
646
+ }
647
+ /**
648
+ * Create a DryRun adapter.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * const adapter = dryRunAdapter({ respond: (msgs) => "hello from dry-run" });
653
+ * const resp = await Promise.resolve(adapter.invoke([{ role: "user", content: "hi" }]));
654
+ * ```
655
+ */
656
+ declare function dryRunAdapter(opts?: DryRunAdapterOptions): LLMAdapter;
657
+
658
+ /**
659
+ * GoogleAdapter — default fetch-backed, optional SDK-backed.
660
+ *
661
+ * The SDK-backed path targets the `@google/genai` SDK shape:
662
+ * `client.models.generateContent({ model, contents, config })` — single
663
+ * param, with generation params and `abortSignal` under `config`. The
664
+ * legacy `@google/generative-ai` two-arg `(params, {signal})` shape is no
665
+ * longer accepted; pass a `GoogleGenAI` instance via `opts.sdk`.
666
+ *
667
+ * Maps Gemini `usageMetadata`:
668
+ * - `promptTokenCount` minus `cachedContentTokenCount` → `input.regular`
669
+ * - `cachedContentTokenCount` → `input.cacheRead`
670
+ * - `candidatesTokenCount` → `output.regular`
671
+ * - `thoughtsTokenCount` → `output.reasoning`
672
+ * - `toolUsePromptTokenCount` → `input.toolUse`
673
+ * - `promptTokensDetails[]` → `input.{image,audio,video}` per modality
674
+ */
675
+
676
+ interface GoogleAdapterOptions {
677
+ /** API key. Falls back to `process.env.GOOGLE_API_KEY` / `GEMINI_API_KEY` on Node. */
678
+ apiKey?: string;
679
+ model?: string;
680
+ baseURL?: string;
681
+ /** Extra headers on every request. */
682
+ headers?: Record<string, string>;
683
+ /**
684
+ * Optional `@google/genai` SDK instance (e.g. `new GoogleGenAI({apiKey})`).
685
+ * When omitted, the adapter uses the fetch-backed path against the
686
+ * Generative Language REST API.
687
+ */
688
+ sdk?: GoogleSdkLike;
689
+ fetchImpl?: typeof fetch;
690
+ }
691
+ /**
692
+ * Duck-type matching the `@google/genai` (`GoogleGenAI`) SDK shape:
693
+ * single-param `generateContent({ model, contents, config })` where
694
+ * generation parameters and `abortSignal` live under `config`.
695
+ *
696
+ * The `@google/generative-ai` predecessor's two-arg `(params, {signal})`
697
+ * shape is no longer accepted.
698
+ */
699
+ interface GoogleSdkLike {
700
+ models: {
701
+ generateContent(params: GoogleSdkRequestParams): Promise<GeminiResponse>;
702
+ generateContentStream?(params: GoogleSdkRequestParams): Promise<AsyncIterable<GeminiResponse>> | AsyncIterable<GeminiResponse>;
703
+ };
704
+ }
705
+ /** Single-param request shape consumed by `@google/genai`'s `models.generateContent`. */
706
+ interface GoogleSdkRequestParams {
707
+ model: string;
708
+ contents: unknown;
709
+ config?: GoogleSdkRequestConfig;
710
+ }
711
+ /**
712
+ * Generation config under the new SDK. `abortSignal` is the cancellation
713
+ * channel — there is no second-arg `{signal}`.
714
+ */
715
+ interface GoogleSdkRequestConfig {
716
+ abortSignal?: AbortSignal;
717
+ temperature?: number;
718
+ maxOutputTokens?: number;
719
+ systemInstruction?: unknown;
720
+ tools?: unknown;
721
+ thinkingConfig?: unknown;
722
+ [extra: string]: unknown;
723
+ }
724
+ interface GeminiResponse {
725
+ candidates?: ReadonlyArray<{
726
+ content?: {
727
+ role?: string;
728
+ parts?: ReadonlyArray<{
729
+ text?: string;
730
+ thought?: boolean;
731
+ functionCall?: {
732
+ name: string;
733
+ args: Record<string, unknown>;
734
+ };
735
+ }>;
736
+ };
737
+ finishReason?: string;
738
+ }>;
739
+ usageMetadata?: GeminiUsage;
740
+ modelVersion?: string;
741
+ }
742
+ interface GeminiUsage {
743
+ promptTokenCount?: number;
744
+ candidatesTokenCount?: number;
745
+ totalTokenCount?: number;
746
+ thoughtsTokenCount?: number;
747
+ cachedContentTokenCount?: number;
748
+ toolUsePromptTokenCount?: number;
749
+ promptTokensDetails?: ReadonlyArray<{
750
+ modality: string;
751
+ tokenCount: number;
752
+ }>;
753
+ candidatesTokensDetails?: ReadonlyArray<{
754
+ modality: string;
755
+ tokenCount: number;
756
+ }>;
757
+ cacheTokensDetails?: ReadonlyArray<{
758
+ modality: string;
759
+ tokenCount: number;
760
+ }>;
761
+ }
762
+ declare function googleAdapter(opts?: GoogleAdapterOptions): LLMAdapter;
763
+
764
+ /**
765
+ * `frozenContext` — prefix-cache-friendly snapshot of upstream context.
766
+ *
767
+ * @module
768
+ */
769
+
770
+ type FrozenContextOptions = {
771
+ /**
772
+ * Reactive signal that triggers re-materialization. Each `DATA` emission
773
+ * from this node re-reads the source and refreshes the frozen value.
774
+ * Typical shapes: `fromTimer(ms)` for periodic refresh, a stage-transition
775
+ * node for event-driven refresh, or a manual `state<number>` the caller
776
+ * increments via `setState(n + 1)`.
777
+ *
778
+ * When omitted, the frozen value is materialized exactly once (on first
779
+ * subscribe) and never refreshes for the lifetime of the activation —
780
+ * use this for session-start snapshots that must stay stable. The
781
+ * single-shot latch IS reset on `INVALIDATE` (graph-wide flush via
782
+ * `graph.signal([[INVALIDATE]])`), so callers who need an "evict and
783
+ * re-materialize" escape hatch get one through the standard graph
784
+ * lifecycle without having to wire a `refreshTrigger`.
785
+ */
786
+ refreshTrigger?: NodeInput<unknown>;
787
+ name?: string;
788
+ };
789
+ /**
790
+ * Freeze a reactive source into a stable snapshot that only re-materializes
791
+ * on explicit trigger. Built for long-running harness loops where system
792
+ * prompts include `agentMemory` / stage context — every reactive change to
793
+ * the source invalidates the LLM provider's prefix cache, so re-rendering
794
+ * the prompt every turn is expensive.
795
+ *
796
+ * `frozenContext(source)` reads the source once and caches the value;
797
+ * downstream `promptNode` compositions see a stable reference until the
798
+ * optional `refreshTrigger` fires.
799
+ *
800
+ * Trade-off: slightly stale context vs. prefix cache hit rate. For most
801
+ * harness apps, the memory snapshot at session start is "good enough" —
802
+ * refreshing on a coarse-grained trigger (`fromCron("*\/30min")`, stage
803
+ * transition) preserves 90%+ prefix cache hits while keeping context useful.
804
+ *
805
+ * @example
806
+ * ```ts
807
+ * // Freeze agent memory for the duration of a stage.
808
+ * const frozen = frozenContext(memory.context, {
809
+ * refreshTrigger: stage, // re-materialize on stage change
810
+ * });
811
+ * const reply = promptNode({ context: frozen, ... });
812
+ * ```
813
+ *
814
+ * @category patterns.ai
815
+ */
816
+ declare function frozenContext<T>(source: NodeInput<T>, opts?: FrozenContextOptions): Node<T | null>;
817
+
818
+ /** Options accepted by {@link promptCall}, {@link llmExtractor}, and {@link llmConsolidator}. */
819
+ type PromptCallOptions = {
820
+ adapter: LLMAdapter;
821
+ model?: string;
822
+ temperature?: number;
823
+ maxTokens?: number;
824
+ /**
825
+ * Optional name forwarded to the underlying `promptNode` (used as the
826
+ * `<name>::messages` / `<name>::response` / `<name>::output` path prefix).
827
+ * Defaults differ per call site so multiple `promptCall`s wired into the
828
+ * same graph don't collide on `prompt_node::output`.
829
+ */
830
+ name?: string;
831
+ };
832
+ /**
833
+ * Build a one-shot LLM JSON-call factory: each invocation wraps `input` in a
834
+ * fresh `node([], { initial: input })`, delegates to `promptNode({format: "json"})`, and
835
+ * returns a `NodeInput<TOut>` that the caller plugs into `distill` /
836
+ * `agentLoop` / any reactive composition that accepts `NodeInput`.
837
+ *
838
+ * **Per-call lifecycle.** The returned `NodeInput<TOut>` is a producer that
839
+ * emits exactly one `DATA` per upstream input (per Tier 1.2 Session C lock —
840
+ * `promptNode` guarantees one DATA per wave). When the consumer's switchMap
841
+ * supersedes it, the per-call `node([], { initial: input })` and the inner `prompt_node::response`
842
+ * tear down together.
843
+ *
844
+ * @param systemPrompt - System message sent on every call.
845
+ * @param buildUserContent - Per-input user-content builder (must be JSON-stringifiable).
846
+ * @param opts - Adapter + model/temperature/maxTokens + optional name prefix.
847
+ * @param defaultName - Path-prefix fallback when `opts.name` is omitted.
848
+ * @returns Factory `(input: TIn) => NodeInput<TOut>`.
849
+ *
850
+ * @category patterns
851
+ */
852
+ declare function promptCall<TIn, TOut>(systemPrompt: string, buildUserContent: (input: TIn) => string, opts: PromptCallOptions, defaultName: string): (input: TIn) => NodeInput<TOut>;
853
+ /** Options accepted by {@link llmExtractor} and {@link llmConsolidator}. */
854
+ type LLMExtractorOptions = PromptCallOptions & {
855
+ /**
856
+ * Cap the dedup-hint slice of `existingKeys` passed to the LLM. Larger
857
+ * stores ship more keys (better dedup recall) at the cost of prompt size.
858
+ * Default 100. Set to `Infinity` to forward every key.
859
+ */
860
+ maxExistingKeys?: number;
861
+ };
862
+ /** Alias for backward compatibility. */
863
+ type LLMConsolidatorOptions = LLMExtractorOptions;
864
+ /**
865
+ * Returns an `extractFn` callback for `distill()` that invokes an LLM to
866
+ * extract structured memories from raw input.
867
+ *
868
+ * The system prompt should instruct the LLM to return JSON matching
869
+ * `Extraction<TMem>` shape: `{ upsert: [{ key, value }], remove?: [key] }`.
870
+ *
871
+ * Built on `promptNode({format: "json"})` — inherits markdown-fence stripping
872
+ * and content-preview parse errors. Stack `withRetry` on the adapter for
873
+ * transient-error tolerance (see `patterns/ai/adapters/middleware/retry.ts`).
874
+ */
875
+ declare function llmExtractor<TRaw, TMem>(systemPrompt: string, opts: LLMExtractorOptions): (raw: TRaw, existing: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
876
+ /**
877
+ * Returns a `consolidateFn` callback for `distill()` that invokes an LLM to
878
+ * cluster and merge related memories.
879
+ */
880
+ declare function llmConsolidator<TMem>(systemPrompt: string, opts: LLMConsolidatorOptions): (entries: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
881
+
882
+ /**
883
+ * `promptNode` — universal LLM transform as a reactive derived node.
884
+ *
885
+ * The shape: `deps → messagesNode (derived) → switchMap → response (producer) → output`.
886
+ * Each upstream wave is one LLM call; superseding waves cancel the in-flight
887
+ * call via the abort signal threaded through `nodeSignal(opts.abort)`.
888
+ *
889
+ * The producer-shape on the inner is load-bearing: it emits exactly one DATA
890
+ * + COMPLETE per wave, so the outer switchMap sees one DATA per wave (matches
891
+ * the `HarnessExecutor` contract). A `node([response], (batchData, actions, ctx) => {
892
+ * const data = ...; actions.emit(parse(data[0]));
893
+ * }, { describeKind: "derived" })` would have its
894
+ * own first-run / push-on-subscribe semantics that can leak a transient null
895
+ * before the real response arrives — observed and reverted in an earlier
896
+ * attempt; see SESSION-ai-harness-module-review.md line 3654 for context.
897
+ * Locked as path (b) producer-based by Session C (2026-04-27); inner-node
898
+ * naming aligned to `prompt_node::response` per the C+D widening (2026-04-30).
899
+ *
900
+ * **Retry / replay-cache.** Stack middleware on the adapter:
901
+ *
902
+ * ```ts
903
+ * import { withRetry, withReplayCache } from "@graphrefly/graphrefly/patterns/ai";
904
+ *
905
+ * const adapter = withRetry(
906
+ * withReplayCache(baseAdapter, { keyFn: (ctx) => ctx.messages[0].content }),
907
+ * { count: 3, backoff: 200 },
908
+ * );
909
+ * const result = promptNode(adapter, [input], (q) => q);
910
+ * ```
911
+ *
912
+ * `promptNode` no longer ships `retries` / `cache` options — they duplicated
913
+ * middleware already at the adapter layer.
914
+ *
915
+ * **Cross-wave cache (COMPOSITION-GUIDE §32).** The switchMap output cache
916
+ * survives across new outer DATAs — `promptNode`'s cached value persists
917
+ * until the next wave fully resolves. Consumers that need to distinguish
918
+ * "fresh value for THIS session" from "stale cache from a prior session"
919
+ * (e.g. `agentLoop` resetting on new `run()`) must add a `node([])` mirror
920
+ * at their session boundary and depend on the mirror, not the `promptNode`
921
+ * output directly. `promptNode` itself stays primitive — it does not
922
+ * embed a state-mirror.
923
+ *
924
+ * @module
925
+ */
926
+
927
+ type PromptNodeOptions = {
928
+ name?: string;
929
+ model?: string;
930
+ temperature?: number;
931
+ maxTokens?: number;
932
+ /**
933
+ * Output format:
934
+ * - `"text"` (default) — emit the response content as a string.
935
+ * - `"json"` — `JSON.parse` the content (markdown fences stripped).
936
+ * - `"raw"` — emit the full {@link LLMResponse} object (subsumes the
937
+ * pre-Tier-2.3 `fromLLM` shape; use this when you need `usage` /
938
+ * `toolCalls` / `finishReason` alongside `content`).
939
+ */
940
+ format?: "text" | "json" | "raw";
941
+ /**
942
+ * Reactive tool definitions forwarded to the adapter. Pair with
943
+ * `format: "raw"` (or read `toolCalls` from a downstream parser) when
944
+ * tool-calling is in scope.
945
+ *
946
+ * **Reactive declared edge** (DF12, Tier 7): `tools` is a `Node` so the
947
+ * tools list participates in `describe()` topology and `explain()` causal
948
+ * chains. The tools Node is added to `messagesNode`'s declared deps —
949
+ * tools changes re-invoke the LLM (treated as a new call envelope).
950
+ * Wrap with `distinctUntilChanged` upstream if your tool selector emits
951
+ * noisy duplicates that would otherwise spam the adapter. See
952
+ * COMPOSITION-GUIDE §31 (Dynamic tool selection) for the canonical
953
+ * `toolSelector` pattern that produces this Node.
954
+ *
955
+ * **Activation note:** since `tools` is a real declared dep, `messagesNode`
956
+ * waits for the tools Node to DATA at least once before firing
957
+ * (push-on-subscribe SENTINEL gate). Pass a `node<ToolDefinition[]>([], { initial: [] })`
958
+ * if you want immediate activation with no tools, or the latest published
959
+ * `toolSelector.tools` Node.
960
+ */
961
+ tools?: Node<readonly ToolDefinition[]>;
962
+ /**
963
+ * Optional system prompt. Forwarded via `opts.systemPrompt` to the adapter
964
+ * only — never pushed as a `{role:"system"}` message (avoiding the
965
+ * double-send class of bug where adapters that normalize both shapes end
966
+ * up with two system entries).
967
+ */
968
+ systemPrompt?: string;
969
+ /**
970
+ * Optional reactive abort signal. When the node emits `true`, the in-flight
971
+ * `adapter.invoke()` call is cancelled via `AbortController.abort()`.
972
+ * Threaded through `nodeSignal(abort)` — a one-shot bridge. Useful inside
973
+ * agent state machines where a separate `aborted` state should cancel the
974
+ * current LLM call without superseding via switchMap.
975
+ */
976
+ abort?: Node<boolean>;
977
+ meta?: Record<string, unknown>;
978
+ };
979
+ /**
980
+ * Universal LLM transform: wraps a prompt template + model adapter into a reactive derived node.
981
+ * Re-invokes the LLM whenever any dep changes. Suitable for triage, QA, hypothesis, parity, etc.
982
+ *
983
+ * **Topology** (visible in `describe()`):
984
+ * ```
985
+ * <deps...>, [tools?] → <name>::messages (derived, meta.ai = prompt_node::messages)
986
+ * <name>::messages → <name>::output (switchMap product, meta.ai = prompt_node::output)
987
+ * per-wave inner: <name>::response (producer, meta.ai = prompt_node::response)
988
+ * ```
989
+ * When `opts.tools` is supplied, the tools `Node` is appended to
990
+ * `messagesNode`'s declared deps so it appears as a real edge in `describe()`
991
+ * / `explain()` (DF12, Tier 7).
992
+ *
993
+ * **No-input semantics** (matches the codebase-wide SENTINEL convention):
994
+ * - **Initial no-input** (no real input has ever arrived) — emits nothing.
995
+ * Outer cache stays `undefined`; `subscribe` consumers see no DATA event.
996
+ * Use this to keep downstream gating clean: a `withLatestFrom`-paired
997
+ * trigger won't fire until the LLM has actually produced something.
998
+ * - **Mid-flow no-input** (input dropped to nullish after at least one
999
+ * real LLM call) — emits `null` as a domain "input went away" signal.
1000
+ * Downstream consumers can distinguish "haven't started" from "input
1001
+ * gone."
1002
+ *
1003
+ * **Retries / caching:** stack `withRetry` / `withReplayCache` middleware on the
1004
+ * `adapter` argument — `promptNode` no longer ships its own duplicated retry /
1005
+ * cache loops (pre-1.0 cleanup, see review session 1).
1006
+ *
1007
+ * @param adapter - LLM adapter (provider-agnostic). Wrap with `withRetry` /
1008
+ * `withReplayCache` middleware for transient-error tolerance
1009
+ * or replay caching.
1010
+ * @param deps - Input nodes whose values feed the prompt.
1011
+ * @param prompt - Static string or template function receiving dep values.
1012
+ * @param opts - Optional configuration.
1013
+ * @returns `Node` emitting LLM responses (string or parsed JSON).
1014
+ */
1015
+ declare function promptNode(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts: PromptNodeOptions & {
1016
+ format: "raw";
1017
+ }): Node<LLMResponse | null>;
1018
+ declare function promptNode<T = string>(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: Omit<PromptNodeOptions, "format"> & {
1019
+ format?: "text" | "json";
1020
+ }): Node<T | null>;
1021
+
1022
+ /**
1023
+ * `streamingPromptNode` + `gatedStream` — streaming LLM transforms.
1024
+ *
1025
+ * **Wave A Unit 2 rewrite:**
1026
+ * - `StreamChunk` retired. The live stream surface is now `deltaTopic:
1027
+ * TopicGraph<StreamDelta & {seq, ts}>` — every adapter delta (token,
1028
+ * thinking, tool-call, usage, finish) is published in order. The previous
1029
+ * shape retained the accumulated text per-chunk, producing O(N²) memory;
1030
+ * the new shape stores only per-delta payloads (O(N)).
1031
+ * - New `accumulatedText: Node<string>` on the bundle — lazy-built via
1032
+ * `ctx.store` over token-type deltas. Text-only extractors (`streamExtractor`,
1033
+ * `keywordFlagExtractor`, `toolCallExtractor`) consume this node.
1034
+ * - `retainedLimit?: number` option exposed for the delta topic (no default —
1035
+ * session scale is domain-specific per Unit 2 Q2).
1036
+ * - Unconditional `keepalive(output)` removed — callers subscribe as needed.
1037
+ * - System-prompt double-send fixed (matches promptNode Unit 1 fix).
1038
+ * - `format: "json"` throws on parse error with a content-preview diagnostic
1039
+ * (parity with `promptNode`).
1040
+ * - Shared body between `streamingPromptNode` and `gatedStream` extracted
1041
+ * into `streamingInvoke` per Unit 2 locked scope.
1042
+ *
1043
+ * @module
1044
+ */
1045
+
1046
+ /**
1047
+ * A single delta published to the `deltaTopic`. Every adapter emission is
1048
+ * forwarded — not just token deltas — so consumers see the full event log
1049
+ * (thinking, tool-call-delta, usage, finish).
1050
+ */
1051
+ type StampedDelta = StreamDelta & {
1052
+ /** Monotonic per-stream counter starting at 0. */
1053
+ readonly seq: number;
1054
+ /** Wall-clock nanoseconds at publish time (spec §5.11 central timer). */
1055
+ readonly ts: number;
1056
+ };
1057
+ type StreamingPromptNodeOptions = {
1058
+ name?: string;
1059
+ model?: string;
1060
+ temperature?: number;
1061
+ maxTokens?: number;
1062
+ /** Output format — `"json"` attempts JSON.parse on accumulated text. Throws on parse failure. Default: `"text"`. */
1063
+ format?: "text" | "json";
1064
+ systemPrompt?: string;
1065
+ meta?: Record<string, unknown>;
1066
+ /**
1067
+ * Optional retention cap on the delta topic. Omit for unbounded retention
1068
+ * (the topic grows until `dispose()`). Recommended values: `8_192` for
1069
+ * single-shot 8K-token responses, `1_000_000` for persistent session
1070
+ * topics, or explicit `dispose()` for worker-pool patterns.
1071
+ */
1072
+ retainedLimit?: number;
1073
+ };
1074
+ /**
1075
+ * Bundle returned by {@link streamingPromptNode}.
1076
+ */
1077
+ type StreamingPromptNodeHandle<T> = {
1078
+ /** Final parsed result (emits once per invocation, after stream completes). */
1079
+ output: Node<T | null>;
1080
+ /** Live delta topic — every adapter delta in order, stamped with `seq` + `ts`. */
1081
+ deltaTopic: TopicGraph<StampedDelta>;
1082
+ /**
1083
+ * Reactive accumulated-text view — lazy-built over `deltaTopic.latest`
1084
+ * filtered on `type === "token"`. Text-only extractors compose on this.
1085
+ * Emits the empty string before any token arrives.
1086
+ */
1087
+ accumulatedText: Node<string>;
1088
+ /** Tear down the delta topic and release resources. */
1089
+ dispose: () => void;
1090
+ };
1091
+ /**
1092
+ * Streaming LLM transform: wraps a prompt template + adapter into a reactive
1093
+ * streaming pipeline. Re-invokes the LLM whenever any dep changes; the
1094
+ * previous in-flight stream is canceled automatically via `switchMap`.
1095
+ *
1096
+ * Every adapter delta is published to `deltaTopic` stamped with `seq` + `ts`.
1097
+ * Text consumers subscribe to `accumulatedText` (auto-maintained). Delta-
1098
+ * specific consumers (`costMeterExtractor` on `usage` deltas) subscribe to
1099
+ * `deltaTopic` directly and filter by `delta.type`.
1100
+ *
1101
+ * The async boundary is handled by `fromAny(asyncGenerator)` (spec §5.10).
1102
+ */
1103
+ declare function streamingPromptNode<T = string>(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: StreamingPromptNodeOptions): StreamingPromptNodeHandle<T>;
1104
+ type GatedStreamOptions = StreamingPromptNodeOptions & {
1105
+ /** Gate options (maxPending, startOpen). */
1106
+ gate?: Omit<GateOptions, "meta">;
1107
+ };
1108
+ /**
1109
+ * Bundle returned by {@link gatedStream}.
1110
+ */
1111
+ type GatedStreamHandle<T> = {
1112
+ /** Final parsed result (after gate approval). */
1113
+ output: Node<T | null>;
1114
+ /** Live delta topic — every adapter delta in order, stamped with `seq` + `ts`. */
1115
+ deltaTopic: TopicGraph<StampedDelta>;
1116
+ /** Reactive accumulated-text view. */
1117
+ accumulatedText: Node<string>;
1118
+ /**
1119
+ * Gate controller — approve, reject (aborts in-flight stream), modify.
1120
+ * The gate's DATA domain is `T` (not `T | null`): the pre-gate `filter`
1121
+ * drops nulls, so the pending queue never holds a null. The controller's
1122
+ * `node` output type stays `T | null` only because `gate.approve()` on an
1123
+ * empty queue would surface `null` — callers should treat `null` as "no
1124
+ * value" rather than as a modeled null signal.
1125
+ */
1126
+ gate: GateController<T>;
1127
+ /** Tear down the delta topic + gate keepalive. */
1128
+ dispose: () => void;
1129
+ };
1130
+ /**
1131
+ * Streaming LLM transform with human-in-the-loop gate integration.
1132
+ *
1133
+ * Composes {@link streamingPromptNode} with `gate` so that:
1134
+ * - `gate.reject()` discards the pending value **and** aborts the in-flight
1135
+ * stream (toggles an internal cancel signal → switchMap restart → abort).
1136
+ * - `gate.modify()` transforms the pending value before forwarding downstream.
1137
+ * - `gate.approve()` forwards the final result as normal.
1138
+ *
1139
+ * Wave A Unit 2 defers full `gatedStream` review to Wave B Unit 17 (the
1140
+ * `gate()` primitive itself is reviewed there). This implementation retains
1141
+ * the existing gate API while adopting the Unit 2 delta-topic shape.
1142
+ */
1143
+ declare function gatedStream<T = string>(graph: Graph, name: string, adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: GatedStreamOptions): GatedStreamHandle<T>;
1144
+
1145
+ /**
1146
+ * `systemPromptBuilder` — assembles a reactive system prompt from sections.
1147
+ *
1148
+ * @module
1149
+ */
1150
+
1151
+ /**
1152
+ * Assembles a system prompt from reactive sections. Each section is a
1153
+ * `NodeInput<string>` — the prompt updates when any section changes.
1154
+ */
1155
+ type SystemPromptHandle = Node<string> & {
1156
+ dispose: () => void;
1157
+ };
1158
+ declare function systemPromptBuilder(sections: readonly NodeInput<string>[], opts?: {
1159
+ separator?: string;
1160
+ name?: string;
1161
+ }): SystemPromptHandle;
1162
+
1163
+ /**
1164
+ * Cost meter extractor — derives live cost readings from the delta topic.
1165
+ *
1166
+ * **Wave A Unit 3 rewrite:** signature takes `deltaTopic: TopicGraph<StampedDelta>`
1167
+ * instead of the old `TopicGraph<StreamChunk>`. The meter prefers real
1168
+ * `usage` deltas from the adapter; when no `usage` has been seen yet it
1169
+ * falls back to a char-based estimate over token deltas and stamps
1170
+ * `estimated: true` on the reading. Chunk count is the count of
1171
+ * token-type deltas seen (was `chunk.index + 1`).
1172
+ *
1173
+ * @module
1174
+ */
1175
+
1176
+ /** A cost meter reading from the stream. */
1177
+ type CostMeterReading = {
1178
+ readonly chunkCount: number;
1179
+ readonly charCount: number;
1180
+ readonly estimatedTokens: number;
1181
+ /**
1182
+ * `true` when no adapter `usage` delta has been observed yet —
1183
+ * `estimatedTokens` is a char-based heuristic and should be treated as an
1184
+ * approximation. Flips to `false` once a real `usage` delta arrives.
1185
+ */
1186
+ readonly estimated: boolean;
1187
+ };
1188
+ type CostMeterOptions = {
1189
+ /** Characters per token approximation. Default: 4 (GPT-family). */
1190
+ charsPerToken?: number;
1191
+ name?: string;
1192
+ };
1193
+ /**
1194
+ * Mounts a cost meter on the delta topic. Prefers real `usage` deltas from
1195
+ * the provider; falls back to char-based estimation on token deltas alone
1196
+ * (with `meta.estimated: true` on the reading).
1197
+ *
1198
+ * Default structural equals suppresses DATA emission when two consecutive
1199
+ * readings are identical.
1200
+ */
1201
+ declare function costMeterExtractor(deltaTopic: TopicGraph<StampedDelta>, opts?: CostMeterOptions): Node<CostMeterReading>;
1202
+
1203
+ /**
1204
+ * Keyword-flag extractor — scans accumulated stream text for configured patterns.
1205
+ * @module
1206
+ */
1207
+
1208
+ /** A keyword match detected in the stream. */
1209
+ type KeywordFlag = {
1210
+ readonly label: string;
1211
+ readonly pattern: RegExp;
1212
+ readonly match: string;
1213
+ readonly position: number;
1214
+ };
1215
+ type KeywordFlagExtractorOptions = {
1216
+ patterns: readonly {
1217
+ pattern: RegExp;
1218
+ label: string;
1219
+ }[];
1220
+ name?: string;
1221
+ /**
1222
+ * Maximum length of any pattern's literal text. Used as an overlap window
1223
+ * when cursoring through the accumulated stream so matches that span
1224
+ * chunk boundaries aren't missed. Default: 128.
1225
+ */
1226
+ maxPatternLength?: number;
1227
+ };
1228
+ /**
1229
+ * Mounts a keyword-flag extractor on accumulated text. Scans for all
1230
+ * configured patterns and emits an array of matches.
1231
+ *
1232
+ * **Wave A Unit 3 rewrite:** signature takes `accumulatedText: Node<string>`
1233
+ * instead of the old `TopicGraph<StreamChunk>`. Patterns are compiled once
1234
+ * at factory time (was per-chunk). `maxPatternLength` is validated at
1235
+ * factory time — any pattern whose source exceeds the window throws
1236
+ * immediately.
1237
+ *
1238
+ * Use cases: design invariant violations (`setTimeout`, `EventEmitter`), PII
1239
+ * detection (SSN, email, phone), toxicity keywords, off-track reasoning.
1240
+ *
1241
+ * **Streaming optimization.** Maintains a cursor across waves in `ctx.store`
1242
+ * so each emission scans only the delta region `accumulated.slice(scannedTo -
1243
+ * maxPatternLength)` — not the full string. Reactivation clears `ctx.store`
1244
+ * and resumes from offset 0 (COMPOSITION-GUIDE §20 RAM semantics).
1245
+ *
1246
+ * Default structural equals suppresses DATA emission when no new flags were
1247
+ * found this wave.
1248
+ */
1249
+ declare function keywordFlagExtractor(accumulatedText: Node<string>, opts: KeywordFlagExtractorOptions): Node<readonly KeywordFlag[]>;
1250
+
1251
+ /**
1252
+ * Generic stream extractor — mounts an extract function on accumulated text.
1253
+ *
1254
+ * **Wave A Unit 3 rewrite:** signature changed from
1255
+ * `streamExtractor(topic: TopicGraph<StreamChunk>, fn)` to
1256
+ * `streamExtractor(accumulatedText: Node<string>, fn)`. The Unit 2 delta-
1257
+ * topic redesign removed the per-chunk `accumulated` field; callers pass
1258
+ * `streamingPromptNode(...).accumulatedText` (or any other `Node<string>`
1259
+ * source of accumulated text). Source-agnostic — the extractor doesn't care
1260
+ * whether the text came from an LLM, WebSocket, SSE tail, or file reader.
1261
+ *
1262
+ * @module
1263
+ */
1264
+
1265
+ /**
1266
+ * Mounts an extractor function on a reactive accumulated-text source. Returns
1267
+ * a derived node that emits extracted values as the text grows.
1268
+ *
1269
+ * @param accumulatedText - Reactive `Node<string>` of accumulated text.
1270
+ * @param extractFn - `(accumulated: string) => T | null`.
1271
+ * @param opts - Optional name + structural equals.
1272
+ * @returns Derived node emitting extracted values.
1273
+ */
1274
+ declare function streamExtractor<T>(accumulatedText: Node<string>, extractFn: (accumulated: string) => T | null, opts?: {
1275
+ name?: string;
1276
+ /**
1277
+ * Optional structural equals for the extractor output. When two
1278
+ * consecutive chunks produce structurally-equal outputs, the framework
1279
+ * emits `RESOLVED` instead of `DATA`, saving downstream work. Default:
1280
+ * reference equality (`Object.is`). The library cannot know your
1281
+ * output shape — supply this when your `extractFn` returns structured
1282
+ * objects or arrays.
1283
+ */
1284
+ equals?: (a: T | null, b: T | null) => boolean;
1285
+ }): Node<T | null>;
1286
+
1287
+ /**
1288
+ * Tool-call extractor — scans accumulated stream text for complete JSON tool call objects.
1289
+ * @module
1290
+ */
1291
+
1292
+ /** A tool call detected in the stream. */
1293
+ type ExtractedToolCall = {
1294
+ readonly name: string;
1295
+ readonly arguments: Record<string, unknown>;
1296
+ readonly raw: string;
1297
+ readonly startIndex: number;
1298
+ };
1299
+ /**
1300
+ * Mounts a tool-call extractor on a streaming topic. Scans accumulated text
1301
+ * for complete JSON objects containing `"name"` and `"arguments"` keys (the
1302
+ * standard tool_call shape). Partial JSON is ignored until the closing brace.
1303
+ *
1304
+ * Feeds into the tool interception chain for reactive tool gating mid-stream.
1305
+ *
1306
+ * **Streaming optimization.** Maintains a cursor (`scanFrom`) in `ctx.store`
1307
+ * so each chunk resumes brace-scanning from the position after the last
1308
+ * complete parse (or the last incomplete open brace). Already-parsed objects
1309
+ * are not re-parsed. Default structural equals suppresses DATA emission when
1310
+ * no new tool call completed this chunk.
1311
+ */
1312
+ declare function toolCallExtractor(accumulatedText: Node<string>, opts?: {
1313
+ name?: string;
1314
+ }): Node<readonly ExtractedToolCall[]>;
1315
+
1316
+ /**
1317
+ * Content gate — classifies accumulated stream text as allow / review / block.
1318
+ * @module
1319
+ */
1320
+
1321
+ /** Content safety decision. */
1322
+ type ContentDecision = "allow" | "block" | "review";
1323
+ /** Options for {@link contentGate}. */
1324
+ type ContentGateOptions = {
1325
+ /**
1326
+ * Hard-block threshold multiplier (default 1.5).
1327
+ * Scores above `threshold * hardMultiplier` emit `"block"`.
1328
+ * Scores between `threshold` and that emit `"review"`.
1329
+ */
1330
+ hardMultiplier?: number;
1331
+ name?: string;
1332
+ };
1333
+ /**
1334
+ * Derived node that classifies accumulated stream text as `"allow"`,
1335
+ * `"review"`, or `"block"` based on a classifier score.
1336
+ *
1337
+ * **Wave A Unit 3 rewrite:** signature now takes `accumulatedText: Node<string>`
1338
+ * instead of a `TopicGraph<StreamChunk>` (the `StreamChunk` shape was retired
1339
+ * when the delta topic replaced the per-chunk accumulated-text shape).
1340
+ *
1341
+ * Emits a three-way decision on every text change:
1342
+ * - `"allow"` — score below `threshold`
1343
+ * - `"review"` — score in `[threshold, threshold × hardMultiplier)`
1344
+ * - `"block"` — score at or above `threshold × hardMultiplier`
1345
+ *
1346
+ * @param accumulatedText - Reactive accumulated-text source
1347
+ * (`streamingPromptNode(...).accumulatedText`).
1348
+ * @param classifier - `(accumulated: string) => number` scoring function, or
1349
+ * a `Node<number>` for live scores.
1350
+ * @param threshold - Score at which output becomes `"review"` or `"block"`.
1351
+ */
1352
+ declare function contentGate(accumulatedText: Node<string>, classifier: ((accumulated: string) => number) | Node<number>, threshold: number, opts?: ContentGateOptions): Node<ContentDecision>;
1353
+
1354
+ /**
1355
+ * Redactor — stream extractor that replaces matched patterns in accumulated text.
1356
+ *
1357
+ * **Wave A Unit 3 rewrite:** signature now takes `accumulatedText: Node<string>`
1358
+ * instead of the retired `TopicGraph<StreamChunk>`. The output is a
1359
+ * `Node<string>` carrying the sanitized accumulated text — compose with
1360
+ * `contentGate` or downstream UI directly.
1361
+ *
1362
+ * @module
1363
+ */
1364
+
1365
+ /** Options for {@link redactor}. */
1366
+ type RedactorOptions = {
1367
+ name?: string;
1368
+ };
1369
+ /**
1370
+ * Derived node that replaces matched patterns in accumulated text.
1371
+ *
1372
+ * @param accumulatedText - Reactive accumulated-text source.
1373
+ * @param patterns - Array of RegExps to match against the text.
1374
+ * @param replaceFn - Replacement producer (default: always `"[REDACTED]"`).
1375
+ * @returns `Node<string>` emitting the sanitized accumulated text.
1376
+ */
1377
+ declare function redactor(accumulatedText: Node<string>, patterns: RegExp[], replaceFn?: (match: string, pattern: RegExp) => string, opts?: RedactorOptions): Node<string>;
1378
+
1379
+ /**
1380
+ * Options for {@link handoff}.
1381
+ */
1382
+ type HandoffOptions = {
1383
+ /**
1384
+ * Reactive gate: when this node's value is `true`, output flows from
1385
+ * `from` to the `to` specialist; when `false`, `from`'s output flows
1386
+ * through unchanged and `to` stays dormant. Omit to always hand off —
1387
+ * useful when `from` is itself a router whose output shape already
1388
+ * encodes routing intent.
1389
+ */
1390
+ condition?: NodeInput<boolean>;
1391
+ name?: string;
1392
+ };
1393
+ /**
1394
+ * Multi-agent handoff recipe — route `from`'s output into a specialist
1395
+ * agent `toFactory` when `condition` is open. Thin composition over
1396
+ * `switchMap` + gate; not a new primitive, just a named shape.
1397
+ *
1398
+ * The "handoff" pattern (popularized by the OpenAI Agents SDK) covers two
1399
+ * idioms:
1400
+ *
1401
+ * 1. **Full handoff** — a triage agent routes the conversation to a
1402
+ * specialist, and the specialist becomes the active agent for the rest
1403
+ * of the turn. Accumulated context (memory, tool definitions) can travel
1404
+ * along by threading the same `agentMemory` bundle into both.
1405
+ * 2. **Agents-as-tools** — the manager keeps control and calls the
1406
+ * specialist like a tool for a bounded subtask. Build this by registering
1407
+ * a `promptNode` instance as a `ToolDefinition` on the parent via
1408
+ * `toolRegistry`.
1409
+ *
1410
+ * This sugar covers (1) — a reactive route from one agent's output into a
1411
+ * specialist factory. For (2) wire a tool registry manually; the pattern is
1412
+ * additive with this one.
1413
+ *
1414
+ * @example Full handoff on a triage signal.
1415
+ * ```ts
1416
+ * import { handoff, promptNode } from "@graphrefly/graphrefly/patterns/ai";
1417
+ *
1418
+ * const triage = promptNode(adapter, [userMessage], (msg) =>
1419
+ * `Classify urgency of: ${msg}. Reply "high" or "normal".`);
1420
+ * const isUrgent = derived([triage], ([v]) => v === "high");
1421
+ *
1422
+ * const specialist = handoff(
1423
+ * userMessage,
1424
+ * (input) => promptNode(specialistAdapter, [input], (m) => `Respond urgently: ${m}`),
1425
+ * { condition: isUrgent },
1426
+ * );
1427
+ * ```
1428
+ *
1429
+ * @param from - Source node whose value is threaded into the specialist.
1430
+ * @param toFactory - Factory that takes `from` (as a reactive source) and
1431
+ * returns the specialist node. Called once, lazily, when the first
1432
+ * subscriber activates.
1433
+ * @param opts - Optional reactive `condition` gate + name.
1434
+ * @returns Node emitting the specialist's output when the gate is open, or
1435
+ * `from`'s value when the gate is closed. Null when `from` is null.
1436
+ *
1437
+ * **Performance caveat (Wave A Unit 5):** the specialist is mounted per
1438
+ * source emission — each `v != null` DATA on `from` allocates a fresh
1439
+ * `state<T>(v)` + invokes `toFactory`, and switchMap cancels the prior
1440
+ * branch. For per-turn routing (≤1 emit/sec) this is negligible. For
1441
+ * high-frequency sources (per-token routing, tight event loops), batch
1442
+ * upstream (e.g. via `audit`, `throttle`, or `distinctUntilChanged`) before
1443
+ * handing off — each mount/unmount cycle spins up full subgraphs
1444
+ * (`messagesNode` + adapter bridge + output for a `promptNode` specialist).
1445
+ *
1446
+ * @category patterns.ai
1447
+ */
1448
+ declare function handoff<T>(from: NodeInput<T | null>, toFactory: (input: Node<T>) => Node<T | null>, opts?: HandoffOptions): Node<T | null>;
1449
+
1450
+ /**
1451
+ * Options for {@link toolSelector}.
1452
+ */
1453
+ interface ToolSelectorOptions {
1454
+ readonly name?: string;
1455
+ }
1456
+ /**
1457
+ * Reactive tool availability (COMPOSITION-GUIDE §31). Given a base tool set
1458
+ * (reactive or static) and one or more reactive predicates, emit the filtered
1459
+ * subset of tools currently allowed. Feeds into `promptNode({ tools: Node<...> })`
1460
+ * so the LLM sees a reactive menu instead of a frozen config.
1461
+ *
1462
+ * Each predicate is a `NodeInput<(tool) => boolean>`. A tool is included iff
1463
+ * **every** predicate returns `true`. When any predicate value is `null` /
1464
+ * `undefined` (e.g. upstream not yet ready) that predicate is treated as a
1465
+ * pass-through — the tool isn't excluded on its basis. Predicate updates
1466
+ * recompute the selected set.
1467
+ *
1468
+ * Pairs with `toolInterceptor` (§D9 / §31): **selection** controls what's
1469
+ * offered to the LLM (pre-generation UX); **interception** gates what's
1470
+ * executed after the LLM chooses (post-generation security). Tool selection
1471
+ * is NOT a security boundary — an LLM can hallucinate tool calls outside
1472
+ * its offered set; always pair with `toolInterceptor` for enforcement.
1473
+ *
1474
+ * @example
1475
+ * ```ts
1476
+ * const hasBudget = node([costMeter], (batchData, actions, ctx) => {
1477
+ * const data = batchData.map((batch, i) => batch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i]);
1478
+ * actions.emit((data[0] as CostMeter).total < BUDGET);
1479
+ * }, { describeKind: "derived" });
1480
+ * const canDestroy = state(false, { name: "destructive-allowed" });
1481
+ * const tools = toolSelector(registry.schemas, [
1482
+ * node([hasBudget], (batchData, actions, ctx) => {
1483
+ * const data = batchData.map((batch, i) => batch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i]);
1484
+ * actions.emit((t) => !t.meta?.expensive || data[0] === true);
1485
+ * }, { describeKind: "derived" }),
1486
+ * node([canDestroy], (batchData, actions, ctx) => {
1487
+ * const data = batchData.map((batch, i) => batch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i]);
1488
+ * actions.emit((t) => !t.meta?.destructive || data[0] === true);
1489
+ * }, { describeKind: "derived" }),
1490
+ * ]);
1491
+ * const agent = promptNode(graph, "agent", { ..., tools });
1492
+ * ```
1493
+ */
1494
+ declare function toolSelector(allTools: NodeInput<readonly ToolDefinition[]>, constraints: readonly NodeInput<(tool: ToolDefinition) => boolean>[], opts?: ToolSelectorOptions): Node<readonly ToolDefinition[]>;
1495
+
1496
+ /** Generic per-dimension thresholds. Any dim below its threshold → reject. */
1497
+ type AdmissionThresholds<Dims extends string> = Partial<Record<Dims, number>>;
1498
+ type AdmissionScoredOptions<Dims extends string, TRaw = unknown> = {
1499
+ /** Score function — must return a finite number for every dimension named in `thresholds`. */
1500
+ scoreFn: (raw: TRaw) => Readonly<Record<Dims, number>>;
1501
+ /** Per-dim minimums. Dims absent here are scored but not gated. */
1502
+ thresholds?: AdmissionThresholds<Dims>;
1503
+ };
1504
+ /**
1505
+ * Generic N-dimension admission filter. Rejects any input where one of the
1506
+ * configured threshold dimensions scores below its minimum. Missing scores
1507
+ * (`undefined` / `null`) AND non-finite values (`NaN`, `±Infinity`) are
1508
+ * treated as below all thresholds — reject by default rather than admit.
1509
+ *
1510
+ * @example
1511
+ * ```ts
1512
+ * const filter = admissionScored({
1513
+ * scoreFn: (raw: Note) => ({ relevance: scoreRelevance(raw), age: ageScore(raw) }),
1514
+ * thresholds: { relevance: 0.4 }, // age scored but ungated
1515
+ * });
1516
+ * ```
1517
+ */
1518
+ declare function admissionScored<Dims extends string, TRaw = unknown>(opts: AdmissionScoredOptions<Dims, TRaw>): (raw: TRaw) => boolean;
1519
+ /** Scores for the three admission dimensions. Each 0–1. */
1520
+ type AdmissionScores = {
1521
+ readonly persistence: number;
1522
+ readonly structure: number;
1523
+ readonly personalValue: number;
1524
+ };
1525
+ type AdmissionScore3DOptions = {
1526
+ /** Custom scoring function. Required — the previous always-0.5 default was misleading. */
1527
+ scoreFn: (raw: unknown) => AdmissionScores;
1528
+ /** Minimum persistence score to admit (default 0.3). */
1529
+ persistenceThreshold?: number;
1530
+ /** Minimum personalValue score to admit (default 0.3). */
1531
+ personalValueThreshold?: number;
1532
+ /** Require structure score > 0 to admit (default false). */
1533
+ requireStructured?: boolean;
1534
+ };
1535
+ /**
1536
+ * 3D admission sugar — the persistence / structure / personalValue triple
1537
+ * commonly used in agent-memory literature. Composes `admissionScored`
1538
+ * with thresholds derived from the option fields. Use directly when those
1539
+ * three named dimensions match your domain, or use `admissionScored` with
1540
+ * an arbitrary dimension set instead.
1541
+ *
1542
+ * `requireStructured: true` rejects entries where `structure <= 0` (matches
1543
+ * the pre-Unit-8 `requireStructured && scores.structure <= 0` check).
1544
+ * Implemented as a final-step predicate around `admissionScored` rather
1545
+ * than a `Number.MIN_VALUE` threshold, which would have been a footgun for
1546
+ * future readers.
1547
+ */
1548
+ declare function admissionFilter3D(opts: AdmissionScore3DOptions): (raw: unknown) => boolean;
1549
+
1550
+ type GaugesAsContextOptions = {
1551
+ /** Group gauges by `meta.tags` (default true). */
1552
+ groupByTags?: boolean;
1553
+ /** Separator between gauge lines (default "\n"). */
1554
+ separator?: string;
1555
+ /**
1556
+ * V0 delta mode (§6.0b): only include nodes whose `v.version` exceeds
1557
+ * the corresponding entry in this map. Nodes without V0 or not in the
1558
+ * map are always included. Callers maintain this map across calls.
1559
+ *
1560
+ * The `id` field guards against node replacement: if a node is removed
1561
+ * and re-added under the same name (new id), it is always included.
1562
+ */
1563
+ sinceVersion?: ReadonlyMap<string, {
1564
+ id: string;
1565
+ version: number;
1566
+ }>;
1567
+ };
1568
+ /**
1569
+ * Format a graph's readable (gauge) nodes as a context string for LLM
1570
+ * system prompts.
1571
+ *
1572
+ * Gauges are nodes with `meta.description` or `meta.format`. Values are
1573
+ * formatted using `meta.format` and `meta.unit` hints.
1574
+ *
1575
+ * @param graph - The graph to introspect.
1576
+ * @param actor - Optional actor for guard-scoped describe.
1577
+ * @param options - Formatting options.
1578
+ * @returns A formatted string ready for system prompt injection.
1579
+ */
1580
+ declare function gaugesAsContext(graph: Graph, actor?: Actor, options?: GaugesAsContextOptions): string;
1581
+
1582
+ type GraphFromSpecOptions = {
1583
+ model?: string;
1584
+ temperature?: number;
1585
+ maxTokens?: number;
1586
+ /** Fn/source catalog for resolving named node factories from the LLM-generated spec. */
1587
+ catalog?: GraphSpecCatalog;
1588
+ /** Extra instructions appended to the system prompt. */
1589
+ systemPromptExtra?: string;
1590
+ /**
1591
+ * Optional AbortSignal forwarded to `adapter.invoke({ signal })`. Lets
1592
+ * callers cancel the in-flight LLM call (e.g. when the reactive variant
1593
+ * supersedes mid-flight). When the signal aborts, the underlying call
1594
+ * propagates the abort and `graphFromSpec` rejects with the abort reason.
1595
+ */
1596
+ signal?: AbortSignal;
1597
+ };
1598
+ /**
1599
+ * Ask an LLM to compose a Graph from a natural-language description.
1600
+ *
1601
+ * The LLM returns a JSON {@link GraphSpec} which is validated, catalog-expanded,
1602
+ * and instantiated via {@link compileSpec} (gains catalog validation, template
1603
+ * expansion, and feedback wiring that `Graph.fromSnapshot` bypasses).
1604
+ *
1605
+ * @param naturalLanguage - The problem/use-case description.
1606
+ * @param adapter - LLM adapter for the generation call.
1607
+ * @param opts - Model options and optional catalog for named node factories.
1608
+ * @returns A constructed Graph.
1609
+ * @throws On invalid LLM output, validation failure, or unresolvable deps.
1610
+ */
1611
+ declare function graphFromSpec(naturalLanguage: string, adapter: LLMAdapter, opts?: GraphFromSpecOptions): Promise<Graph>;
1612
+ /**
1613
+ * Reactive variant of {@link graphFromSpec}: re-invokes the LLM and
1614
+ * recompiles the graph whenever `input` emits a new natural-language
1615
+ * description. Useful inside the harness or refine loop when the spec text
1616
+ * itself is a reactive value (e.g. fed by a `node([], { initial: ... })` knob, a memory
1617
+ * snapshot, or an upstream `promptNode` output).
1618
+ *
1619
+ * **Supersede:** when the input changes mid-flight, switchMap tears the
1620
+ * inner producer down. The producer's cleanup aborts the in-flight LLM
1621
+ * call via an internal `AbortController` (threaded into `graphFromSpec`'s
1622
+ * new `signal` option) AND destroys any Graph that lands after cancel —
1623
+ * no token leak, no unreferenced compiled graphs. If the user's input
1624
+ * already changed by the time the LLM responds, the about-to-be-discarded
1625
+ * Graph is freed instead of orphaned.
1626
+ *
1627
+ * **Lifetime of the latest emitted Graph:** the caller owns each Graph
1628
+ * that actually reaches them. If you keep multiple historical values, call
1629
+ * `prev?.destroy()` before storing the new one.
1630
+ *
1631
+ * @param input - Reactive source of natural-language descriptions.
1632
+ * @param adapter - LLM adapter for the generation call.
1633
+ * @param opts - Model options and optional catalog for named node factories.
1634
+ * @returns `Node<Graph | null>` — emits the latest compiled graph, or `null`
1635
+ * while the input is empty / unsettled.
1636
+ */
1637
+ declare function graphFromSpecReactive(input: NodeInput<string>, adapter: LLMAdapter, opts?: GraphFromSpecOptions): Node<Graph | null>;
1638
+
1639
+ /** OpenAI function-calling tool schema. */
1640
+ type OpenAIToolSchema = {
1641
+ readonly type: "function";
1642
+ readonly function: {
1643
+ readonly name: string;
1644
+ readonly description: string;
1645
+ readonly parameters: Record<string, unknown>;
1646
+ };
1647
+ };
1648
+ /** MCP (Model Context Protocol) tool schema. */
1649
+ type McpToolSchema = {
1650
+ readonly name: string;
1651
+ readonly description: string;
1652
+ readonly inputSchema: Record<string, unknown>;
1653
+ };
1654
+ /** Result of {@link knobsAsTools}. */
1655
+ type KnobsAsToolsResult = {
1656
+ /** OpenAI function-calling tool schemas. */
1657
+ readonly openai: readonly OpenAIToolSchema[];
1658
+ /** MCP tool schemas. */
1659
+ readonly mcp: readonly McpToolSchema[];
1660
+ /** GraphReFly ToolDefinitions with handlers that call `graph.set()`. */
1661
+ readonly definitions: readonly ToolDefinition[];
1662
+ };
1663
+ /**
1664
+ * Derive tool schemas from a graph's writable (knob) nodes.
1665
+ *
1666
+ * Knobs are state nodes whose `meta.access` is `"llm"`, `"both"`, or absent
1667
+ * (default: writable). Each knob becomes a tool that calls `graph.set()`.
1668
+ *
1669
+ * Speaks **domain language** (spec §5.4): the returned schemas use node names
1670
+ * and meta descriptions — no protocol internals exposed.
1671
+ *
1672
+ * @param graph - The graph to introspect.
1673
+ * @param actor - Optional actor for guard-scoped describe.
1674
+ * @returns OpenAI, MCP, and GraphReFly tool schemas.
1675
+ */
1676
+ declare function knobsAsTools(graph: Graph, actor?: Actor): KnobsAsToolsResult;
1677
+
1678
+ /** A single operation in a strategy plan. */
1679
+ type StrategyOperation = {
1680
+ readonly type: "add_node";
1681
+ readonly name: string;
1682
+ readonly nodeType: string;
1683
+ readonly meta?: Record<string, unknown>;
1684
+ readonly initial?: unknown;
1685
+ } | {
1686
+ readonly type: "remove_node";
1687
+ readonly name: string;
1688
+ } | {
1689
+ readonly type: "connect";
1690
+ readonly from: string;
1691
+ readonly to: string;
1692
+ } | {
1693
+ readonly type: "disconnect";
1694
+ readonly from: string;
1695
+ readonly to: string;
1696
+ } | {
1697
+ readonly type: "set_value";
1698
+ readonly name: string;
1699
+ readonly value: unknown;
1700
+ } | {
1701
+ readonly type: "update_meta";
1702
+ readonly name: string;
1703
+ readonly key: string;
1704
+ readonly value: unknown;
1705
+ };
1706
+ /** Structured strategy plan returned by {@link suggestStrategy}. */
1707
+ type StrategyPlan = {
1708
+ readonly summary: string;
1709
+ readonly operations: readonly StrategyOperation[];
1710
+ readonly reasoning: string;
1711
+ };
1712
+ type SuggestStrategyOptions = {
1713
+ model?: string;
1714
+ temperature?: number;
1715
+ maxTokens?: number;
1716
+ actor?: Actor;
1717
+ /**
1718
+ * Optional AbortSignal forwarded to `adapter.invoke({ signal })`. Lets
1719
+ * callers cancel the in-flight LLM call (e.g. when the reactive variant
1720
+ * supersedes mid-flight). When the signal aborts, the underlying call
1721
+ * propagates the abort and `suggestStrategy` rejects with the abort reason.
1722
+ */
1723
+ signal?: AbortSignal;
1724
+ };
1725
+ /**
1726
+ * Ask an LLM to analyze a graph and suggest topology/parameter changes
1727
+ * to solve a stated problem.
1728
+ *
1729
+ * Returns a structured plan — does NOT auto-apply. The caller reviews
1730
+ * and selectively applies operations.
1731
+ *
1732
+ * @param graph - The graph to analyze.
1733
+ * @param problem - Natural-language problem statement.
1734
+ * @param adapter - LLM adapter for the analysis call.
1735
+ * @param opts - Model and actor options.
1736
+ * @returns A structured strategy plan.
1737
+ * @throws On invalid LLM output.
1738
+ */
1739
+ declare function suggestStrategy(graph: Graph, problem: string, adapter: LLMAdapter, opts?: SuggestStrategyOptions): Promise<StrategyPlan>;
1740
+ /**
1741
+ * Reactive variant of {@link suggestStrategy}: re-invokes the LLM whenever
1742
+ * the `problem` source emits, sampling the latest `graph` value (via
1743
+ * `withLatestFrom`) to describe. The graph is the *secondary* dep — only
1744
+ * problem changes re-trigger analysis. This breaks the feedback cycle that
1745
+ * would otherwise arise if downstream consumers wired `apply(plan)` back
1746
+ * into the same graph node (graph mutation must not auto-fire a re-analysis).
1747
+ *
1748
+ * @param graph - Reactive source of graphs to analyze.
1749
+ * @param problem - Reactive source of natural-language problem statements.
1750
+ * @param adapter - LLM adapter for the analysis call.
1751
+ * @param opts - Model and actor options.
1752
+ * @returns `Node<StrategyPlan | null>` — emits the latest plan, or `null`
1753
+ * while inputs are unsettled.
1754
+ */
1755
+ declare function suggestStrategyReactive(graph: Node<Graph | null>, problem: NodeInput<string>, adapter: LLMAdapter, opts?: SuggestStrategyOptions): Node<StrategyPlan | null>;
1756
+
1757
+ /** Validation result from {@link validateGraphDef}. */
1758
+ type GraphDefValidation = {
1759
+ readonly valid: boolean;
1760
+ readonly errors: readonly string[];
1761
+ };
1762
+ /**
1763
+ * Validate an LLM-generated graph definition before passing to
1764
+ * `Graph.fromSnapshot()`.
1765
+ *
1766
+ * Checks:
1767
+ * - Required fields: `name`, `nodes`, `edges`
1768
+ * - Node types are valid enum values
1769
+ * - Edge `from`/`to` reference existing nodes
1770
+ * - No duplicate edge entries
1771
+ *
1772
+ * @param def - The graph definition to validate (parsed JSON).
1773
+ * @returns Validation result with errors array.
1774
+ */
1775
+ declare function validateGraphDef(def: unknown): GraphDefValidation;
1776
+
1777
+ export { type AdapterStats, type AdmissionScore3DOptions, type AdmissionScoredOptions, type AdmissionScores, type AdmissionThresholds, type AnthropicAdapterOptions, type AnthropicSdkLike, type BudgetCaps, BudgetExhaustedError, type BudgetTotals, type CallStatsEvent, CascadeExhaustionReport, ChatMessage, type ContentDecision, type ContentGateOptions, type CostMeterOptions, type CostMeterReading, type DryRunAdapterOptions, type ExtractedToolCall, type FrozenContextOptions, type GatedStreamHandle, type GatedStreamOptions, type GaugesAsContextOptions, type GoogleAdapterOptions, type GoogleSdkLike, type GoogleSdkRequestConfig, type GoogleSdkRequestParams, type GraphDefValidation, type GraphFromSpecOptions, type HandoffOptions, type HttpErrorLike, type KeywordFlag, type KeywordFlagExtractorOptions, type KnobsAsToolsResult, LLMAdapter, type LLMBudgetGateBundle, type LLMConsolidatorOptions, type LLMExtractorOptions, LLMInvokeOptions, LLMResponse, LLMTimeoutError, type McpToolSchema, type OpenAIToolSchema, PricingFn, type PromptCallOptions, type PromptNodeOptions, type RedactorOptions, type ResilientAdapterBundle, type ResilientAdapterOptions, type StampedDelta, type StrategyOperation, type StrategyPlan, StreamDelta, type StreamingPromptNodeHandle, type StreamingPromptNodeOptions, type SuggestStrategyOptions, type SystemPromptHandle, TokenUsage, ToolDefinition, type ToolSelectorOptions, type WithBreakerOptions, type WithBudgetGateOptions, type WithDryRunBundle, type WithDryRunOptions, type WithRateLimiterOptions, WithReplayCacheOptions, type WithRetryOptions, admissionFilter3D, admissionScored, anthropicAdapter, contentGate, costMeterExtractor, dryRunAdapter, frozenContext, gatedStream, gaugesAsContext, googleAdapter, graphFromSpec, graphFromSpecReactive, handoff, keywordFlagExtractor, knobsAsTools, llmConsolidator, llmExtractor, observableAdapter, parseRateLimitFromError, promptCall, promptNode, redactor, resilientAdapter, streamExtractor, streamingPromptNode, suggestStrategy, suggestStrategyReactive, systemPromptBuilder, toolCallExtractor, toolSelector, validateGraphDef, withBudgetGate, withDryRun, withLLMBreaker, withLLMTimeout, withRateLimiter, withRetry };