@graphrefly/graphrefly 0.27.0 → 0.29.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.
- package/dist/backoff-HPZMEZNF.js +1 -0
- package/dist/cascading-Bp99ckMJ.d.ts +180 -0
- package/dist/cascading-CcAgRacD.d.cts +180 -0
- package/dist/chunk-22F4K3G7.js +1 -0
- package/dist/chunk-22SVXUPB.js +64 -0
- package/dist/chunk-2GQREQ6C.js +1 -0
- package/dist/chunk-3JXNEPCD.js +2 -0
- package/dist/chunk-4JJCCD5S.js +2 -0
- package/dist/chunk-4OFIQ66T.js +1 -0
- package/dist/chunk-4V4C7K56.js +1 -0
- package/dist/chunk-4VVTGLXJ.js +1 -0
- package/dist/chunk-567NWZ3T.js +1 -0
- package/dist/chunk-5JDE5JHE.js +1 -0
- package/dist/chunk-5QDBSZBV.js +1 -0
- package/dist/chunk-5Z4HDCO6.js +1 -0
- package/dist/chunk-63FFOHLA.js +1 -0
- package/dist/chunk-6QZNQS5B.js +1 -0
- package/dist/chunk-7JDLFI6N.js +1 -0
- package/dist/chunk-7TDOES3L.js +1 -0
- package/dist/chunk-A7IAQQ63.js +1 -0
- package/dist/chunk-AMG5VBHW.js +1 -0
- package/dist/chunk-AUY2YKCO.js +1 -0
- package/dist/chunk-AV3PIDFQ.js +1 -0
- package/dist/chunk-BA5URFYW.js +1 -0
- package/dist/chunk-BKPLTBL5.js +1 -0
- package/dist/chunk-BZP5T4X6.js +1 -0
- package/dist/chunk-CK2E7BTU.js +1 -0
- package/dist/chunk-CSJE2EKV.js +1 -0
- package/dist/chunk-E3AXATVZ.js +9 -0
- package/dist/chunk-ESMPEKEV.js +1 -0
- package/dist/chunk-GJR3P6JG.js +1 -0
- package/dist/chunk-GNCBXARM.js +1 -0
- package/dist/chunk-GPW2V3RE.js +1 -0
- package/dist/chunk-HSIEYSDY.js +1 -0
- package/dist/chunk-I6VIH3VA.js +1 -0
- package/dist/chunk-ISCENNXS.js +1 -0
- package/dist/chunk-JYOUF6UQ.js +1 -0
- package/dist/chunk-KASHOCF5.js +1 -0
- package/dist/chunk-LGSNR4LU.js +5 -0
- package/dist/chunk-LVGBLZM2.js +1 -0
- package/dist/chunk-MGKAO4EK.js +7 -0
- package/dist/chunk-NSG4C6BF.js +23 -0
- package/dist/chunk-OL33ZI6R.js +1 -0
- package/dist/chunk-PCZ35NXD.js +78 -0
- package/dist/chunk-PGMUCUHG.js +43 -0
- package/dist/chunk-QYADASLV.js +1 -0
- package/dist/chunk-RD52SNH2.js +1 -0
- package/dist/chunk-SLMYTGTU.js +1 -0
- package/dist/chunk-TWMEGG45.js +1 -0
- package/dist/chunk-UVJQ35G2.js +1 -0
- package/dist/chunk-VGTCGNRX.js +18 -0
- package/dist/chunk-VIMF6LGM.js +1 -0
- package/dist/chunk-VJLMUKOI.js +1 -0
- package/dist/chunk-VWPRPPKR.js +1 -0
- package/dist/chunk-W4TSQ6RJ.js +1 -0
- package/dist/chunk-WM7H7WTY.js +3 -0
- package/dist/chunk-Y32RJO24.js +1 -0
- package/dist/chunk-Y53B6NS4.js +1 -0
- package/dist/compat/index.cjs +15 -7656
- package/dist/compat/index.d.cts +15 -14
- package/dist/compat/index.d.ts +15 -14
- package/dist/compat/index.js +1 -50
- package/dist/compat/jotai/index.cjs +1 -2048
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -9
- package/dist/compat/nanostores/index.cjs +1 -2175
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -23
- package/dist/compat/nestjs/index.cjs +15 -6782
- package/dist/compat/nestjs/index.d.cts +7 -6
- package/dist/compat/nestjs/index.d.ts +7 -6
- package/dist/compat/nestjs/index.js +1 -83
- package/dist/compat/react/index.cjs +1 -141
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/react/index.js +1 -12
- package/dist/compat/solid/index.cjs +1 -128
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/solid/index.js +1 -12
- package/dist/compat/svelte/index.cjs +1 -131
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/svelte/index.js +1 -12
- package/dist/compat/vue/index.cjs +1 -146
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/vue/index.js +1 -12
- package/dist/compat/zustand/index.cjs +7 -4931
- package/dist/compat/zustand/index.d.cts +5 -5
- package/dist/compat/zustand/index.d.ts +5 -5
- package/dist/compat/zustand/index.js +1 -12
- package/dist/composite-BL-llbnE.d.ts +69 -0
- package/dist/composite-Dze--DaA.d.cts +69 -0
- package/dist/core/index.cjs +1 -2271
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -110
- package/dist/extra/browser.cjs +1 -0
- package/dist/extra/browser.d.cts +3 -0
- package/dist/extra/browser.d.ts +3 -0
- package/dist/extra/browser.js +1 -0
- package/dist/extra/index.cjs +24 -9971
- package/dist/extra/index.d.cts +13 -6
- package/dist/extra/index.d.ts +13 -6
- package/dist/extra/index.js +1 -381
- package/dist/extra/node.cjs +3 -0
- package/dist/extra/node.d.cts +81 -0
- package/dist/extra/node.d.ts +81 -0
- package/dist/extra/node.js +2 -0
- package/dist/extra/operators.cjs +1 -0
- package/dist/extra/operators.d.cts +910 -0
- package/dist/extra/operators.d.ts +910 -0
- package/dist/extra/operators.js +1 -0
- package/dist/extra/reactive.cjs +1 -0
- package/dist/extra/reactive.d.cts +352 -0
- package/dist/extra/reactive.d.ts +352 -0
- package/dist/extra/reactive.js +1 -0
- package/dist/extra/sources.cjs +1 -2486
- package/dist/extra/sources.d.cts +6 -2
- package/dist/extra/sources.d.ts +6 -2
- package/dist/extra/sources.js +1 -57
- package/dist/extra/storage-browser.cjs +1 -0
- package/dist/extra/storage-browser.d.cts +71 -0
- package/dist/extra/storage-browser.d.ts +71 -0
- package/dist/extra/storage-browser.js +1 -0
- package/dist/extra/storage-core.cjs +1 -0
- package/dist/extra/storage-core.d.cts +98 -0
- package/dist/extra/storage-core.d.ts +98 -0
- package/dist/extra/storage-core.js +1 -0
- package/dist/extra/storage-node.cjs +2 -0
- package/dist/extra/storage-node.d.cts +60 -0
- package/dist/extra/storage-node.d.ts +60 -0
- package/dist/extra/storage-node.js +1 -0
- package/dist/fallback-BaTS7vVY.d.cts +258 -0
- package/dist/fallback-eOm3LNxP.d.ts +258 -0
- package/dist/graph/index.cjs +7 -5030
- package/dist/graph/index.d.cts +6 -5
- package/dist/graph/index.d.ts +6 -5
- package/dist/graph/index.js +1 -50
- package/dist/{graph-DNCrvZSn.d.cts → graph-DgohqXK-.d.cts} +151 -32
- package/dist/{graph-CCwGKLCm.d.ts → graph-Qjg9gWHI.d.ts} +151 -32
- package/dist/{index-BwfLUNw4.d.ts → index-2BVuRCI4.d.ts} +173 -2040
- package/dist/{index-BPVt8kqc.d.ts → index-2NvguqQA.d.ts} +10 -195
- package/dist/index-A65LZhoM.d.ts +186 -0
- package/dist/{index-DlLp-2Xn.d.cts → index-B-8FCEua.d.cts} +10 -195
- package/dist/index-B-gqvYel.d.ts +135 -0
- package/dist/index-B2PRuolf.d.cts +86 -0
- package/dist/index-BJqt9EwW.d.ts +231 -0
- package/dist/{index-BHlKbUwO.d.cts → index-BKjT5DiZ.d.cts} +173 -2040
- package/dist/{index-C0svESO4.d.ts → index-BM8BU4q6.d.ts} +1 -1
- package/dist/{index-VdHQMPy1.d.ts → index-BQaEnxBf.d.ts} +1 -1
- package/dist/index-BSfwiy5B.d.ts +192 -0
- package/dist/index-BTSkeCZs.d.cts +291 -0
- package/dist/index-BUVtw1Ay.d.cts +186 -0
- package/dist/index-BUi57v_p.d.ts +163 -0
- package/dist/{messaging-Gt4LPbyA.d.cts → index-BanNUILp.d.cts} +31 -93
- package/dist/{audit-DRlSzBu9.d.ts → index-BayHDRx6.d.cts} +27 -21
- package/dist/{index-B6D3QNSA.d.ts → index-BiyjsZ0m.d.ts} +148 -20
- package/dist/index-BqZ6vB2A.d.ts +2057 -0
- package/dist/{memory-li6FL5RM.d.ts → index-BuVidq3D.d.cts} +26 -26
- package/dist/index-Byh-xTyp.d.ts +105 -0
- package/dist/index-C08QPDcV.d.cts +321 -0
- package/dist/{demo-shell-BDkOptd6.d.ts → index-C66RJiX8.d.ts} +14 -14
- package/dist/index-C8RfjffH.d.ts +291 -0
- package/dist/index-CA1Cu7Ud.d.ts +873 -0
- package/dist/{index-ByQxazQJ.d.cts → index-CABbltIu.d.cts} +1 -1
- package/dist/{index-VHqptjhu.d.cts → index-CHEBsnYv.d.cts} +1 -1
- package/dist/{index-BuEoe-Qu.d.ts → index-CI0yDnLp.d.ts} +9 -9
- package/dist/{index-B9B7_HEY.d.ts → index-CJ45TW-h.d.ts} +1 -1
- package/dist/{index-CO8uBlUh.d.cts → index-CJZKZoo4.d.cts} +148 -20
- package/dist/{index-wEn0eFe8.d.ts → index-CX2tFJL1.d.ts} +1 -1
- package/dist/{index-BaSM3aYt.d.ts → index-CcWOJ6F0.d.ts} +3 -3
- package/dist/{audit-ClmqGOCx.d.cts → index-CiaVoZGo.d.ts} +27 -21
- package/dist/{index-Dzk2hrlR.d.ts → index-Ct5CWc4E.d.ts} +1 -1
- package/dist/index-D38duMCv.d.cts +357 -0
- package/dist/{index-C8oil6M6.d.ts → index-D5XJ2tSx.d.ts} +30 -6
- package/dist/{index-DO_6JN9Z.d.cts → index-D80do5jX.d.cts} +1 -1
- package/dist/index-D9HKAH_-.d.cts +231 -0
- package/dist/index-DBe_8XW5.d.cts +143 -0
- package/dist/{memory-C6Z2tGpC.d.cts → index-DCeTyFlB.d.ts} +26 -26
- package/dist/index-DDy8eeXS.d.ts +321 -0
- package/dist/index-DJ5oNBc8.d.ts +143 -0
- package/dist/{index-CI3DprxP.d.cts → index-DP0_O3ls.d.cts} +30 -6
- package/dist/{demo-shell-Crid1WdR.d.cts → index-DX8xS-yB.d.cts} +14 -14
- package/dist/index-DiZejfCI.d.cts +2057 -0
- package/dist/index-DknyJ2Fu.d.cts +163 -0
- package/dist/index-DoWMs-Kk.d.cts +135 -0
- package/dist/{messaging-XDoYablx.d.ts → index-DuB5aO4-.d.ts} +31 -93
- package/dist/index-DwjJGKxV.d.ts +357 -0
- package/dist/{index-B6EhDnjH.d.cts → index-H_oxVec5.d.cts} +1 -1
- package/dist/{index-3lsddbbS.d.ts → index-IMAHq-ia.d.ts} +1 -1
- package/dist/{index-B1tloyhO.d.cts → index-U1nir7MX.d.cts} +1 -1
- package/dist/index-Vg7tORgk.d.ts +86 -0
- package/dist/index-dig-r2tQ.d.cts +873 -0
- package/dist/{index-CxFrXH4m.d.ts → index-gsT79Xu9.d.ts} +1 -1
- package/dist/{index-D8wS_PeY.d.cts → index-i99Ka8s7.d.cts} +9 -9
- package/dist/index-iKkyJosF.d.cts +105 -0
- package/dist/{index-Xi3u0HCQ.d.cts → index-jleeotBT.d.cts} +1 -1
- package/dist/{index-DVGiGFGT.d.cts → index-kykKWwV-.d.cts} +3 -3
- package/dist/index-vgcLF5TH.d.cts +192 -0
- package/dist/{index-DYme44FM.d.cts → index-y1RllPn4.d.cts} +1 -1
- package/dist/index.cjs +151 -24142
- package/dist/index.d.cts +69 -2099
- package/dist/index.d.ts +69 -2099
- package/dist/index.js +1 -3868
- package/dist/{meta-CbznRPYJ.d.ts → meta-CX7YsOzp.d.cts} +5 -5
- package/dist/{meta-BxCA7rcr.d.cts → meta-CckhhFRd.d.ts} +5 -5
- package/dist/{node-BmerH3kS.d.cts → node-Dd6wHSib.d.cts} +71 -11
- package/dist/{node-BmerH3kS.d.ts → node-Dd6wHSib.d.ts} +71 -11
- package/dist/{observable-BgGUwcqp.d.ts → observable-BZJgo616.d.ts} +1 -1
- package/dist/{observable-DJt_AxzQ.d.cts → observable-kwzpLvbi.d.cts} +1 -1
- package/dist/patterns/ai/browser.cjs +25 -0
- package/dist/patterns/ai/browser.d.cts +127 -0
- package/dist/patterns/ai/browser.d.ts +127 -0
- package/dist/patterns/ai/browser.js +3 -0
- package/dist/patterns/ai/index.cjs +92 -0
- package/dist/patterns/ai/index.d.cts +17 -0
- package/dist/patterns/ai/index.d.ts +17 -0
- package/dist/patterns/ai/index.js +1 -0
- package/dist/patterns/ai/node.cjs +2 -0
- package/dist/patterns/ai/node.d.cts +58 -0
- package/dist/patterns/ai/node.d.ts +58 -0
- package/dist/patterns/ai/node.js +1 -0
- package/dist/patterns/audit/index.cjs +7 -0
- package/dist/patterns/audit/index.d.cts +6 -0
- package/dist/patterns/audit/index.d.ts +6 -0
- package/dist/patterns/audit/index.js +1 -0
- package/dist/patterns/cqrs/index.cjs +7 -0
- package/dist/patterns/cqrs/index.d.cts +5 -0
- package/dist/patterns/cqrs/index.d.ts +5 -0
- package/dist/patterns/cqrs/index.js +1 -0
- package/dist/patterns/demo-shell/index.cjs +8 -0
- package/dist/patterns/demo-shell/index.d.cts +6 -0
- package/dist/patterns/demo-shell/index.d.ts +6 -0
- package/dist/patterns/demo-shell/index.js +1 -0
- package/dist/patterns/domain-templates/index.cjs +7 -0
- package/dist/patterns/domain-templates/index.d.cts +5 -0
- package/dist/patterns/domain-templates/index.d.ts +5 -0
- package/dist/patterns/domain-templates/index.js +1 -0
- package/dist/patterns/graphspec/index.cjs +84 -0
- package/dist/patterns/graphspec/index.d.cts +7 -0
- package/dist/patterns/graphspec/index.d.ts +7 -0
- package/dist/patterns/graphspec/index.js +1 -0
- package/dist/patterns/guarded-execution/index.cjs +7 -0
- package/dist/patterns/guarded-execution/index.d.cts +7 -0
- package/dist/patterns/guarded-execution/index.d.ts +7 -0
- package/dist/patterns/guarded-execution/index.js +1 -0
- package/dist/patterns/harness/index.cjs +49 -0
- package/dist/patterns/harness/index.d.cts +11 -0
- package/dist/patterns/harness/index.d.ts +11 -0
- package/dist/patterns/harness/index.js +1 -0
- package/dist/patterns/job-queue/index.cjs +7 -0
- package/dist/patterns/job-queue/index.d.cts +5 -0
- package/dist/patterns/job-queue/index.d.ts +5 -0
- package/dist/patterns/job-queue/index.js +1 -0
- package/dist/patterns/lens/index.cjs +7 -0
- package/dist/patterns/lens/index.d.cts +7 -0
- package/dist/patterns/lens/index.d.ts +7 -0
- package/dist/patterns/lens/index.js +1 -0
- package/dist/patterns/memory/index.cjs +7 -0
- package/dist/patterns/memory/index.d.cts +5 -0
- package/dist/patterns/memory/index.d.ts +5 -0
- package/dist/patterns/memory/index.js +1 -0
- package/dist/patterns/messaging/index.cjs +7 -0
- package/dist/patterns/messaging/index.d.cts +5 -0
- package/dist/patterns/messaging/index.d.ts +5 -0
- package/dist/patterns/messaging/index.js +1 -0
- package/dist/patterns/orchestration/index.cjs +7 -0
- package/dist/patterns/orchestration/index.d.cts +6 -0
- package/dist/patterns/orchestration/index.d.ts +6 -0
- package/dist/patterns/orchestration/index.js +1 -0
- package/dist/patterns/reactive-layout/index.cjs +8 -6444
- package/dist/patterns/reactive-layout/index.d.cts +6 -6
- package/dist/patterns/reactive-layout/index.d.ts +6 -6
- package/dist/patterns/reactive-layout/index.js +1 -56
- package/dist/patterns/reduction/index.cjs +7 -0
- package/dist/patterns/reduction/index.d.cts +5 -0
- package/dist/patterns/reduction/index.d.ts +5 -0
- package/dist/patterns/reduction/index.js +1 -0
- package/dist/patterns/refine-loop/index.cjs +9 -0
- package/dist/patterns/refine-loop/index.d.cts +7 -0
- package/dist/patterns/refine-loop/index.d.ts +7 -0
- package/dist/patterns/refine-loop/index.js +1 -0
- package/dist/patterns/resilient-pipeline/index.cjs +1 -0
- package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
- package/dist/patterns/resilient-pipeline/index.js +1 -0
- package/dist/patterns/surface/index.cjs +15 -0
- package/dist/patterns/surface/index.d.cts +8 -0
- package/dist/patterns/surface/index.d.ts +8 -0
- package/dist/patterns/surface/index.js +1 -0
- package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-BkBwVvwm.d.ts} +2 -2
- package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-PiFwVaWS.d.cts} +2 -2
- package/dist/reactive-log-1QTyx10a.d.ts +190 -0
- package/dist/reactive-log-BiVoSxke.d.cts +190 -0
- package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CwO_COHy.d.cts} +2 -67
- package/dist/{composite-C7PcQvcs.d.cts → reactive-map-FeuTVAJb.d.ts} +2 -67
- package/dist/resilience-CBfYJW5C.d.ts +493 -0
- package/dist/resilience-XRUF267O.js +1 -0
- package/dist/resilience-uBz4yvYB.d.cts +493 -0
- package/dist/{sugar-CCOxXK1e.d.ts → sugar-CY-MCfZ9.d.ts} +17 -15
- package/dist/{sugar-D02n5JjF.d.cts → sugar-DHttV0LX.d.cts} +17 -15
- package/dist/topology-tree-CVjt2gp7.d.cts +25 -0
- package/dist/topology-tree-one6oSKY.d.ts +25 -0
- package/dist/types-O3GzJY2U.d.cts +401 -0
- package/dist/types-u64Ose53.d.ts +401 -0
- package/package.json +252 -22
- package/dist/ai-CaR_912Q.d.cts +0 -1033
- package/dist/ai-WlRltJV7.d.ts +0 -1033
- package/dist/chunk-3ZWCKRHX.js +0 -117
- package/dist/chunk-3ZWCKRHX.js.map +0 -1
- package/dist/chunk-7TAQJHQV.js +0 -103
- package/dist/chunk-7TAQJHQV.js.map +0 -1
- package/dist/chunk-APFNLIRG.js +0 -62
- package/dist/chunk-APFNLIRG.js.map +0 -1
- package/dist/chunk-AT5LKYNL.js +0 -395
- package/dist/chunk-AT5LKYNL.js.map +0 -1
- package/dist/chunk-BQ6RQQFF.js +0 -5087
- package/dist/chunk-BQ6RQQFF.js.map +0 -1
- package/dist/chunk-BVZYTZ5H.js +0 -599
- package/dist/chunk-BVZYTZ5H.js.map +0 -1
- package/dist/chunk-DST5DKZS.js +0 -1371
- package/dist/chunk-DST5DKZS.js.map +0 -1
- package/dist/chunk-GTE6PWRZ.js +0 -866
- package/dist/chunk-GTE6PWRZ.js.map +0 -1
- package/dist/chunk-HXZEYDUR.js +0 -94
- package/dist/chunk-HXZEYDUR.js.map +0 -1
- package/dist/chunk-J22W6HV3.js +0 -107
- package/dist/chunk-J22W6HV3.js.map +0 -1
- package/dist/chunk-J2VBW3DZ.js +0 -302
- package/dist/chunk-J2VBW3DZ.js.map +0 -1
- package/dist/chunk-JSCT3CR4.js +0 -38
- package/dist/chunk-JSCT3CR4.js.map +0 -1
- package/dist/chunk-JWBCY4NC.js +0 -330
- package/dist/chunk-JWBCY4NC.js.map +0 -1
- package/dist/chunk-K2AUJHVP.js +0 -2251
- package/dist/chunk-K2AUJHVP.js.map +0 -1
- package/dist/chunk-MJ2NKQQL.js +0 -119
- package/dist/chunk-MJ2NKQQL.js.map +0 -1
- package/dist/chunk-N6UR7YVY.js +0 -198
- package/dist/chunk-N6UR7YVY.js.map +0 -1
- package/dist/chunk-NC6S43JJ.js +0 -456
- package/dist/chunk-NC6S43JJ.js.map +0 -1
- package/dist/chunk-OFVJBJXR.js +0 -98
- package/dist/chunk-OFVJBJXR.js.map +0 -1
- package/dist/chunk-OHISZPOJ.js +0 -97
- package/dist/chunk-OHISZPOJ.js.map +0 -1
- package/dist/chunk-OU5CQKNW.js +0 -102
- package/dist/chunk-OU5CQKNW.js.map +0 -1
- package/dist/chunk-PF7GRZMW.js +0 -2712
- package/dist/chunk-PF7GRZMW.js.map +0 -1
- package/dist/chunk-PHOUUNK7.js +0 -2291
- package/dist/chunk-PHOUUNK7.js.map +0 -1
- package/dist/chunk-RNHBMHKA.js +0 -1665
- package/dist/chunk-RNHBMHKA.js.map +0 -1
- package/dist/chunk-SX52TAR4.js +0 -110
- package/dist/chunk-SX52TAR4.js.map +0 -1
- package/dist/chunk-VYPWMZ6H.js +0 -98
- package/dist/chunk-VYPWMZ6H.js.map +0 -1
- package/dist/chunk-WBZOVTYK.js +0 -171
- package/dist/chunk-WBZOVTYK.js.map +0 -1
- package/dist/chunk-WKNUIZOY.js +0 -354
- package/dist/chunk-WKNUIZOY.js.map +0 -1
- package/dist/chunk-X3VMZYBT.js +0 -713
- package/dist/chunk-X3VMZYBT.js.map +0 -1
- package/dist/chunk-X5R3GL6H.js +0 -525
- package/dist/chunk-X5R3GL6H.js.map +0 -1
- package/dist/chunk-XGPU467M.js +0 -136
- package/dist/chunk-XGPU467M.js.map +0 -1
- package/dist/compat/index.cjs.map +0 -1
- package/dist/compat/index.js.map +0 -1
- package/dist/compat/jotai/index.cjs.map +0 -1
- package/dist/compat/jotai/index.js.map +0 -1
- package/dist/compat/nanostores/index.cjs.map +0 -1
- package/dist/compat/nanostores/index.js.map +0 -1
- package/dist/compat/nestjs/index.cjs.map +0 -1
- package/dist/compat/nestjs/index.js.map +0 -1
- package/dist/compat/react/index.cjs.map +0 -1
- package/dist/compat/react/index.js.map +0 -1
- package/dist/compat/solid/index.cjs.map +0 -1
- package/dist/compat/solid/index.js.map +0 -1
- package/dist/compat/svelte/index.cjs.map +0 -1
- package/dist/compat/svelte/index.js.map +0 -1
- package/dist/compat/vue/index.cjs.map +0 -1
- package/dist/compat/vue/index.js.map +0 -1
- package/dist/compat/zustand/index.cjs.map +0 -1
- package/dist/compat/zustand/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.js.map +0 -1
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/patterns/ai.cjs +0 -7930
- package/dist/patterns/ai.cjs.map +0 -1
- package/dist/patterns/ai.d.cts +0 -10
- package/dist/patterns/ai.d.ts +0 -10
- package/dist/patterns/ai.js +0 -71
- package/dist/patterns/ai.js.map +0 -1
- package/dist/patterns/audit.cjs +0 -5805
- package/dist/patterns/audit.cjs.map +0 -1
- package/dist/patterns/audit.d.cts +0 -6
- package/dist/patterns/audit.d.ts +0 -6
- package/dist/patterns/audit.js +0 -29
- package/dist/patterns/audit.js.map +0 -1
- package/dist/patterns/demo-shell.cjs +0 -5604
- package/dist/patterns/demo-shell.cjs.map +0 -1
- package/dist/patterns/demo-shell.d.cts +0 -6
- package/dist/patterns/demo-shell.d.ts +0 -6
- package/dist/patterns/demo-shell.js +0 -15
- package/dist/patterns/demo-shell.js.map +0 -1
- package/dist/patterns/memory.cjs +0 -5283
- package/dist/patterns/memory.cjs.map +0 -1
- package/dist/patterns/memory.d.cts +0 -5
- package/dist/patterns/memory.d.ts +0 -5
- package/dist/patterns/memory.js +0 -20
- package/dist/patterns/memory.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/storage-CMjUUuxn.d.ts +0 -190
- package/dist/storage-DdWlZo6U.d.cts +0 -190
package/dist/chunk-K2AUJHVP.js
DELETED
|
@@ -1,2251 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decay,
|
|
3
|
-
knowledgeGraph,
|
|
4
|
-
lightCollection,
|
|
5
|
-
vectorIndex
|
|
6
|
-
} from "./chunk-AT5LKYNL.js";
|
|
7
|
-
import {
|
|
8
|
-
distill,
|
|
9
|
-
switchMap
|
|
10
|
-
} from "./chunk-RNHBMHKA.js";
|
|
11
|
-
import {
|
|
12
|
-
topic
|
|
13
|
-
} from "./chunk-X5R3GL6H.js";
|
|
14
|
-
import {
|
|
15
|
-
domainMeta
|
|
16
|
-
} from "./chunk-JSCT3CR4.js";
|
|
17
|
-
import {
|
|
18
|
-
reactiveLog
|
|
19
|
-
} from "./chunk-J2VBW3DZ.js";
|
|
20
|
-
import {
|
|
21
|
-
fromAny,
|
|
22
|
-
fromTimer,
|
|
23
|
-
keepalive
|
|
24
|
-
} from "./chunk-BVZYTZ5H.js";
|
|
25
|
-
import {
|
|
26
|
-
GRAPH_META_SEGMENT,
|
|
27
|
-
Graph
|
|
28
|
-
} from "./chunk-PF7GRZMW.js";
|
|
29
|
-
import {
|
|
30
|
-
ResettableTimer
|
|
31
|
-
} from "./chunk-7TAQJHQV.js";
|
|
32
|
-
import {
|
|
33
|
-
batch,
|
|
34
|
-
derived,
|
|
35
|
-
effect,
|
|
36
|
-
monotonicNs,
|
|
37
|
-
node,
|
|
38
|
-
producer,
|
|
39
|
-
state
|
|
40
|
-
} from "./chunk-PHOUUNK7.js";
|
|
41
|
-
import {
|
|
42
|
-
COMPLETE,
|
|
43
|
-
DATA,
|
|
44
|
-
ERROR,
|
|
45
|
-
RESOLVED,
|
|
46
|
-
__export
|
|
47
|
-
} from "./chunk-SX52TAR4.js";
|
|
48
|
-
|
|
49
|
-
// src/patterns/ai.ts
|
|
50
|
-
var ai_exports = {};
|
|
51
|
-
__export(ai_exports, {
|
|
52
|
-
AgentLoopGraph: () => AgentLoopGraph,
|
|
53
|
-
ChatStreamGraph: () => ChatStreamGraph,
|
|
54
|
-
ToolRegistryGraph: () => ToolRegistryGraph,
|
|
55
|
-
admissionFilter3D: () => admissionFilter3D,
|
|
56
|
-
agentLoop: () => agentLoop,
|
|
57
|
-
agentMemory: () => agentMemory,
|
|
58
|
-
chatStream: () => chatStream,
|
|
59
|
-
contentGate: () => contentGate,
|
|
60
|
-
costMeterExtractor: () => costMeterExtractor,
|
|
61
|
-
fromLLM: () => fromLLM,
|
|
62
|
-
gatedStream: () => gatedStream,
|
|
63
|
-
gaugesAsContext: () => gaugesAsContext,
|
|
64
|
-
graphFromSpec: () => graphFromSpec,
|
|
65
|
-
keywordFlagExtractor: () => keywordFlagExtractor,
|
|
66
|
-
knobsAsTools: () => knobsAsTools,
|
|
67
|
-
llmConsolidator: () => llmConsolidator,
|
|
68
|
-
llmExtractor: () => llmExtractor,
|
|
69
|
-
promptNode: () => promptNode,
|
|
70
|
-
redactor: () => redactor,
|
|
71
|
-
streamExtractor: () => streamExtractor,
|
|
72
|
-
streamingPromptNode: () => streamingPromptNode,
|
|
73
|
-
suggestStrategy: () => suggestStrategy,
|
|
74
|
-
systemPromptBuilder: () => systemPromptBuilder,
|
|
75
|
-
toolCallExtractor: () => toolCallExtractor,
|
|
76
|
-
toolRegistry: () => toolRegistry,
|
|
77
|
-
validateGraphDef: () => validateGraphDef
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// src/patterns/orchestration.ts
|
|
81
|
-
var orchestration_exports = {};
|
|
82
|
-
__export(orchestration_exports, {
|
|
83
|
-
approval: () => approval,
|
|
84
|
-
branch: () => branch,
|
|
85
|
-
forEach: () => forEach,
|
|
86
|
-
gate: () => gate,
|
|
87
|
-
join: () => join,
|
|
88
|
-
loop: () => loop,
|
|
89
|
-
onFailure: () => onFailure,
|
|
90
|
-
pipeline: () => pipeline,
|
|
91
|
-
sensor: () => sensor,
|
|
92
|
-
subPipeline: () => subPipeline,
|
|
93
|
-
task: () => task,
|
|
94
|
-
valve: () => valve,
|
|
95
|
-
wait: () => wait
|
|
96
|
-
});
|
|
97
|
-
function resolveDep(graph, dep) {
|
|
98
|
-
if (typeof dep === "string") {
|
|
99
|
-
return { node: graph.resolve(dep), path: dep };
|
|
100
|
-
}
|
|
101
|
-
const path = findRegisteredNodePath(graph, dep);
|
|
102
|
-
if (!path) {
|
|
103
|
-
throw new Error(
|
|
104
|
-
"orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first"
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return { node: dep, path };
|
|
108
|
-
}
|
|
109
|
-
function findRegisteredNodePath(graph, target) {
|
|
110
|
-
const described = graph.describe();
|
|
111
|
-
const metaSegment = `::${GRAPH_META_SEGMENT}::`;
|
|
112
|
-
for (const path of Object.keys(described.nodes).sort()) {
|
|
113
|
-
if (path.includes(metaSegment)) continue;
|
|
114
|
-
try {
|
|
115
|
-
if (graph.resolve(path) === target) return path;
|
|
116
|
-
} catch {
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return void 0;
|
|
120
|
-
}
|
|
121
|
-
function registerStep(graph, name, step, depPaths) {
|
|
122
|
-
graph.add(name, step);
|
|
123
|
-
void depPaths;
|
|
124
|
-
}
|
|
125
|
-
function baseMeta(kind, meta) {
|
|
126
|
-
return domainMeta("orchestration", kind, meta);
|
|
127
|
-
}
|
|
128
|
-
function coerceLoopIterations(raw) {
|
|
129
|
-
const parseString = (value) => {
|
|
130
|
-
const trimmed = value.trim();
|
|
131
|
-
if (trimmed.length === 0) return 0;
|
|
132
|
-
return Number(trimmed);
|
|
133
|
-
};
|
|
134
|
-
let parsed;
|
|
135
|
-
if (typeof raw === "string") {
|
|
136
|
-
parsed = parseString(raw);
|
|
137
|
-
} else if (raw === null) {
|
|
138
|
-
parsed = 0;
|
|
139
|
-
} else {
|
|
140
|
-
parsed = Number(raw);
|
|
141
|
-
}
|
|
142
|
-
if (!Number.isFinite(parsed)) return 1;
|
|
143
|
-
return Math.max(0, Math.trunc(parsed));
|
|
144
|
-
}
|
|
145
|
-
function pipeline(name, opts) {
|
|
146
|
-
return new Graph(name, opts);
|
|
147
|
-
}
|
|
148
|
-
function task(graph, name, run, opts) {
|
|
149
|
-
const depRefs = opts?.deps ?? [];
|
|
150
|
-
const deps = depRefs.map((dep) => resolveDep(graph, dep));
|
|
151
|
-
const { deps: _deps, ...nodeOpts } = opts ?? {};
|
|
152
|
-
const wrapped = (batchData, actions, ctx) => {
|
|
153
|
-
const data = batchData.map(
|
|
154
|
-
(batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
|
|
155
|
-
);
|
|
156
|
-
actions.emit(run(data, ctx));
|
|
157
|
-
return void 0;
|
|
158
|
-
};
|
|
159
|
-
const step = node(
|
|
160
|
-
deps.map((d) => d.node),
|
|
161
|
-
wrapped,
|
|
162
|
-
{
|
|
163
|
-
...nodeOpts,
|
|
164
|
-
name,
|
|
165
|
-
describeKind: "derived",
|
|
166
|
-
meta: baseMeta("task", opts?.meta)
|
|
167
|
-
}
|
|
168
|
-
);
|
|
169
|
-
registerStep(
|
|
170
|
-
graph,
|
|
171
|
-
name,
|
|
172
|
-
step,
|
|
173
|
-
deps.flatMap((d) => d.path ? [d.path] : [])
|
|
174
|
-
);
|
|
175
|
-
return step;
|
|
176
|
-
}
|
|
177
|
-
function branch(graph, name, source, predicate, opts) {
|
|
178
|
-
const src = resolveDep(graph, source);
|
|
179
|
-
const step = derived(
|
|
180
|
-
[src.node],
|
|
181
|
-
([value]) => ({
|
|
182
|
-
branch: predicate(value) ? "then" : "else",
|
|
183
|
-
value
|
|
184
|
-
}),
|
|
185
|
-
{
|
|
186
|
-
...opts,
|
|
187
|
-
name,
|
|
188
|
-
meta: baseMeta("branch", opts?.meta)
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
registerStep(graph, name, step, src.path ? [src.path] : []);
|
|
192
|
-
return step;
|
|
193
|
-
}
|
|
194
|
-
function valve(graph, name, source, control, opts) {
|
|
195
|
-
const src = resolveDep(graph, source);
|
|
196
|
-
const ctrl = resolveDep(graph, control);
|
|
197
|
-
const step = node(
|
|
198
|
-
[src.node, ctrl.node],
|
|
199
|
-
(batchData, actions, ctx) => {
|
|
200
|
-
const batch0 = batchData[0];
|
|
201
|
-
const batch1 = batchData[1];
|
|
202
|
-
const ctrlVal = batch1 != null && batch1.length > 0 ? batch1.at(-1) : ctx.prevData[1];
|
|
203
|
-
if (batch0 == null || batch0.length === 0) {
|
|
204
|
-
if (batch1 != null && batch1.length > 0 && ctrlVal && ctx.prevData[0] !== void 0) {
|
|
205
|
-
actions.emit(ctx.prevData[0]);
|
|
206
|
-
} else {
|
|
207
|
-
actions.down([[RESOLVED]]);
|
|
208
|
-
}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (!ctrlVal) {
|
|
212
|
-
actions.down([[RESOLVED]]);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
for (const v of batch0) actions.emit(v);
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
...opts,
|
|
219
|
-
name,
|
|
220
|
-
describeKind: "derived",
|
|
221
|
-
meta: baseMeta("valve", opts?.meta)
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
registerStep(
|
|
225
|
-
graph,
|
|
226
|
-
name,
|
|
227
|
-
step,
|
|
228
|
-
[src.path, ctrl.path].filter((v) => typeof v === "string")
|
|
229
|
-
);
|
|
230
|
-
return step;
|
|
231
|
-
}
|
|
232
|
-
function approval(graph, name, source, approver, opts) {
|
|
233
|
-
const src = resolveDep(graph, source);
|
|
234
|
-
const ctrl = resolveDep(graph, approver);
|
|
235
|
-
const isApproved = opts?.isApproved ?? ((value) => Boolean(value));
|
|
236
|
-
const step = node(
|
|
237
|
-
[src.node, ctrl.node],
|
|
238
|
-
(batchData, actions, ctx) => {
|
|
239
|
-
const batch0 = batchData[0];
|
|
240
|
-
const batch1 = batchData[1];
|
|
241
|
-
const ctrlVal = batch1 != null && batch1.length > 0 ? batch1.at(-1) : ctx.prevData[1];
|
|
242
|
-
if (ctrlVal === void 0 || !isApproved(ctrlVal)) {
|
|
243
|
-
actions.down([[RESOLVED]]);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (batch0 == null || batch0.length === 0) {
|
|
247
|
-
if (batch1 != null && batch1.length > 0 && ctx.prevData[0] !== void 0) {
|
|
248
|
-
actions.emit(ctx.prevData[0]);
|
|
249
|
-
} else {
|
|
250
|
-
actions.down([[RESOLVED]]);
|
|
251
|
-
}
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
for (const v of batch0) actions.emit(v);
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
...opts,
|
|
258
|
-
name,
|
|
259
|
-
describeKind: "derived",
|
|
260
|
-
meta: baseMeta("approval", opts?.meta)
|
|
261
|
-
}
|
|
262
|
-
);
|
|
263
|
-
registerStep(
|
|
264
|
-
graph,
|
|
265
|
-
name,
|
|
266
|
-
step,
|
|
267
|
-
[src.path, ctrl.path].filter((v) => typeof v === "string")
|
|
268
|
-
);
|
|
269
|
-
return step;
|
|
270
|
-
}
|
|
271
|
-
function gate(graph, name, source, opts) {
|
|
272
|
-
const maxPending = opts?.maxPending ?? Infinity;
|
|
273
|
-
if (maxPending < 1 && maxPending !== Infinity) {
|
|
274
|
-
throw new RangeError("gate: maxPending must be >= 1");
|
|
275
|
-
}
|
|
276
|
-
const startOpen = opts?.startOpen ?? false;
|
|
277
|
-
const src = resolveDep(graph, source);
|
|
278
|
-
const pendingNode = state([], { name: "pending", equals: () => false });
|
|
279
|
-
const isOpenNode = state(startOpen, { name: "isOpen" });
|
|
280
|
-
const countNode = derived([pendingNode], ([arr]) => arr.length, {
|
|
281
|
-
name: "count"
|
|
282
|
-
});
|
|
283
|
-
let queue = [];
|
|
284
|
-
let torn = false;
|
|
285
|
-
let latestIsOpen = startOpen;
|
|
286
|
-
const isOpenUnsub = isOpenNode.subscribe((msgs) => {
|
|
287
|
-
for (const m of msgs) {
|
|
288
|
-
if (m[0] === DATA) latestIsOpen = m[1];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
function syncPending() {
|
|
292
|
-
pendingNode.down([[DATA, [...queue]]]);
|
|
293
|
-
}
|
|
294
|
-
function enqueue(value) {
|
|
295
|
-
queue.push(value);
|
|
296
|
-
if (queue.length > maxPending) queue.shift();
|
|
297
|
-
syncPending();
|
|
298
|
-
}
|
|
299
|
-
function dequeue(n) {
|
|
300
|
-
const items = queue.splice(0, n);
|
|
301
|
-
syncPending();
|
|
302
|
-
return items;
|
|
303
|
-
}
|
|
304
|
-
function guardTorn(method) {
|
|
305
|
-
if (torn) throw new Error(`gate: ${method}() called after gate was torn down`);
|
|
306
|
-
}
|
|
307
|
-
const output = node(
|
|
308
|
-
[src.node],
|
|
309
|
-
(batchData, actions, ctx) => {
|
|
310
|
-
const terminal = ctx.terminalDeps[0];
|
|
311
|
-
if (terminal !== void 0) {
|
|
312
|
-
torn = true;
|
|
313
|
-
queue = [];
|
|
314
|
-
syncPending();
|
|
315
|
-
actions.down(terminal === true ? [[COMPLETE]] : [[ERROR, terminal]]);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const batch0 = batchData[0];
|
|
319
|
-
if (batch0 == null || batch0.length === 0) {
|
|
320
|
-
actions.down([[RESOLVED]]);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
for (const v of batch0) {
|
|
324
|
-
if (latestIsOpen) {
|
|
325
|
-
actions.emit(v);
|
|
326
|
-
} else {
|
|
327
|
-
enqueue(v);
|
|
328
|
-
actions.down([[RESOLVED]]);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
name,
|
|
334
|
-
describeKind: "derived",
|
|
335
|
-
meta: baseMeta("gate", opts?.meta)
|
|
336
|
-
}
|
|
337
|
-
);
|
|
338
|
-
const controller = {
|
|
339
|
-
node: output,
|
|
340
|
-
pending: pendingNode,
|
|
341
|
-
count: countNode,
|
|
342
|
-
isOpen: isOpenNode,
|
|
343
|
-
approve(count = 1) {
|
|
344
|
-
guardTorn("approve");
|
|
345
|
-
const items = dequeue(count);
|
|
346
|
-
for (const item of items) {
|
|
347
|
-
if (torn) break;
|
|
348
|
-
output.down([[DATA, item]]);
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
reject(count = 1) {
|
|
352
|
-
guardTorn("reject");
|
|
353
|
-
dequeue(count);
|
|
354
|
-
},
|
|
355
|
-
modify(fn, count = 1) {
|
|
356
|
-
guardTorn("modify");
|
|
357
|
-
const snapshot = [...queue];
|
|
358
|
-
const items = dequeue(count);
|
|
359
|
-
for (let i = 0; i < items.length; i++) {
|
|
360
|
-
if (torn) break;
|
|
361
|
-
output.down([[DATA, fn(items[i], i, snapshot)]]);
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
open() {
|
|
365
|
-
guardTorn("open");
|
|
366
|
-
batch(() => {
|
|
367
|
-
isOpenNode.down([[DATA, true]]);
|
|
368
|
-
const items = dequeue(queue.length);
|
|
369
|
-
for (const item of items) {
|
|
370
|
-
if (torn) break;
|
|
371
|
-
output.down([[DATA, item]]);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
},
|
|
375
|
-
close() {
|
|
376
|
-
guardTorn("close");
|
|
377
|
-
isOpenNode.down([[DATA, false]]);
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
graph.addDisposer(countNode.subscribe(() => void 0));
|
|
381
|
-
graph.addDisposer(isOpenUnsub);
|
|
382
|
-
registerStep(graph, name, output, src.path ? [src.path] : []);
|
|
383
|
-
const internal = new Graph(`${name}_state`);
|
|
384
|
-
internal.add("pending", pendingNode);
|
|
385
|
-
internal.add("isOpen", isOpenNode);
|
|
386
|
-
internal.add("count", countNode);
|
|
387
|
-
graph.mount(`${name}_state`, internal);
|
|
388
|
-
return controller;
|
|
389
|
-
}
|
|
390
|
-
function forEach(graph, name, source, run, opts) {
|
|
391
|
-
const src = resolveDep(graph, source);
|
|
392
|
-
let terminated = false;
|
|
393
|
-
const step = node(
|
|
394
|
-
[src.node],
|
|
395
|
-
(batchData, actions, ctx) => {
|
|
396
|
-
if (terminated) {
|
|
397
|
-
actions.down([[RESOLVED]]);
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
const terminal = ctx.terminalDeps[0];
|
|
401
|
-
if (terminal !== void 0) {
|
|
402
|
-
terminated = true;
|
|
403
|
-
actions.down(terminal === true ? [[COMPLETE]] : [[ERROR, terminal]]);
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
const batch0 = batchData[0];
|
|
407
|
-
if (batch0 == null || batch0.length === 0) {
|
|
408
|
-
actions.down([[RESOLVED]]);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
for (const v of batch0) {
|
|
412
|
-
try {
|
|
413
|
-
run(v, actions);
|
|
414
|
-
} catch (err) {
|
|
415
|
-
terminated = true;
|
|
416
|
-
actions.down([[ERROR, err]]);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
...opts,
|
|
423
|
-
name,
|
|
424
|
-
describeKind: "effect",
|
|
425
|
-
completeWhenDepsComplete: false,
|
|
426
|
-
meta: baseMeta("forEach", opts?.meta)
|
|
427
|
-
}
|
|
428
|
-
);
|
|
429
|
-
registerStep(graph, name, step, src.path ? [src.path] : []);
|
|
430
|
-
return step;
|
|
431
|
-
}
|
|
432
|
-
function join(graph, name, deps, opts) {
|
|
433
|
-
const resolved = deps.map((dep) => resolveDep(graph, dep));
|
|
434
|
-
const step = derived(
|
|
435
|
-
resolved.map((d) => d.node),
|
|
436
|
-
(values) => values,
|
|
437
|
-
{
|
|
438
|
-
...opts,
|
|
439
|
-
name,
|
|
440
|
-
meta: baseMeta("join", opts?.meta)
|
|
441
|
-
}
|
|
442
|
-
);
|
|
443
|
-
registerStep(
|
|
444
|
-
graph,
|
|
445
|
-
name,
|
|
446
|
-
step,
|
|
447
|
-
resolved.flatMap((d) => d.path ? [d.path] : [])
|
|
448
|
-
);
|
|
449
|
-
return step;
|
|
450
|
-
}
|
|
451
|
-
function loop(graph, name, source, iterate, opts) {
|
|
452
|
-
const src = resolveDep(graph, source);
|
|
453
|
-
const iterRef = opts?.iterations;
|
|
454
|
-
const iterDep = typeof iterRef === "number" || iterRef === void 0 ? void 0 : resolveDep(graph, iterRef);
|
|
455
|
-
const staticIterations = typeof iterRef === "number" ? iterRef : void 0;
|
|
456
|
-
const step = node(
|
|
457
|
-
iterDep ? [src.node, iterDep.node] : [src.node],
|
|
458
|
-
(depValues, actions, ctx) => {
|
|
459
|
-
const batch0 = depValues[0];
|
|
460
|
-
let current = batch0 != null && batch0.length > 0 ? batch0.at(-1) : ctx.prevData[0];
|
|
461
|
-
const batch1 = iterDep ? depValues[1] : void 0;
|
|
462
|
-
const rawCount = staticIterations ?? (iterDep ? batch1 != null && batch1.length > 0 ? batch1.at(-1) : ctx.prevData[1] : 1);
|
|
463
|
-
const count = coerceLoopIterations(rawCount);
|
|
464
|
-
for (let i = 0; i < count; i += 1) {
|
|
465
|
-
current = iterate(current, i, actions);
|
|
466
|
-
}
|
|
467
|
-
actions.emit(current);
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
...opts,
|
|
471
|
-
name,
|
|
472
|
-
describeKind: "derived",
|
|
473
|
-
meta: baseMeta("loop", opts?.meta)
|
|
474
|
-
}
|
|
475
|
-
);
|
|
476
|
-
registerStep(
|
|
477
|
-
graph,
|
|
478
|
-
name,
|
|
479
|
-
step,
|
|
480
|
-
[src.path, iterDep?.path].filter((v) => typeof v === "string")
|
|
481
|
-
);
|
|
482
|
-
return step;
|
|
483
|
-
}
|
|
484
|
-
function subPipeline(graph, name, childOrBuild, opts) {
|
|
485
|
-
const child = childOrBuild instanceof Graph ? childOrBuild : pipeline(name, opts);
|
|
486
|
-
if (typeof childOrBuild === "function") {
|
|
487
|
-
childOrBuild(child);
|
|
488
|
-
}
|
|
489
|
-
graph.mount(name, child);
|
|
490
|
-
return child;
|
|
491
|
-
}
|
|
492
|
-
function sensor(graph, name, initial, opts) {
|
|
493
|
-
const source = node([], () => void 0, {
|
|
494
|
-
...opts,
|
|
495
|
-
name,
|
|
496
|
-
initial,
|
|
497
|
-
describeKind: "producer",
|
|
498
|
-
meta: baseMeta("sensor", opts?.meta)
|
|
499
|
-
});
|
|
500
|
-
registerStep(graph, name, source, []);
|
|
501
|
-
return {
|
|
502
|
-
node: source,
|
|
503
|
-
push(value) {
|
|
504
|
-
source.down([[DATA, value]]);
|
|
505
|
-
},
|
|
506
|
-
error(err) {
|
|
507
|
-
source.down([[ERROR, err]]);
|
|
508
|
-
},
|
|
509
|
-
complete() {
|
|
510
|
-
source.down([[COMPLETE]]);
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
function wait(graph, name, source, ms, opts) {
|
|
515
|
-
const src = resolveDep(graph, source);
|
|
516
|
-
const timers = /* @__PURE__ */ new Set();
|
|
517
|
-
let terminated = false;
|
|
518
|
-
let completed = false;
|
|
519
|
-
function clearAllTimers() {
|
|
520
|
-
for (const id of timers) clearTimeout(id);
|
|
521
|
-
timers.clear();
|
|
522
|
-
}
|
|
523
|
-
const srcVal = src.node.cache;
|
|
524
|
-
const initialOpt = srcVal !== void 0 ? { initial: srcVal } : {};
|
|
525
|
-
const step = node(
|
|
526
|
-
[],
|
|
527
|
-
(_deps, actions) => {
|
|
528
|
-
clearAllTimers();
|
|
529
|
-
terminated = false;
|
|
530
|
-
completed = false;
|
|
531
|
-
const unsub = src.node.subscribe((msgs) => {
|
|
532
|
-
for (const msg of msgs) {
|
|
533
|
-
if (terminated) return;
|
|
534
|
-
if (msg[0] === DATA) {
|
|
535
|
-
const id = setTimeout(() => {
|
|
536
|
-
timers.delete(id);
|
|
537
|
-
actions.down([msg]);
|
|
538
|
-
if (completed && timers.size === 0) {
|
|
539
|
-
actions.down([[COMPLETE]]);
|
|
540
|
-
}
|
|
541
|
-
}, ms);
|
|
542
|
-
timers.add(id);
|
|
543
|
-
} else if (msg[0] === COMPLETE) {
|
|
544
|
-
terminated = true;
|
|
545
|
-
completed = true;
|
|
546
|
-
if (timers.size === 0) {
|
|
547
|
-
actions.down([[COMPLETE]]);
|
|
548
|
-
}
|
|
549
|
-
} else if (msg[0] === ERROR) {
|
|
550
|
-
terminated = true;
|
|
551
|
-
clearAllTimers();
|
|
552
|
-
actions.down([msg]);
|
|
553
|
-
} else {
|
|
554
|
-
actions.down([msg]);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
return () => {
|
|
559
|
-
unsub();
|
|
560
|
-
clearAllTimers();
|
|
561
|
-
terminated = true;
|
|
562
|
-
};
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
...opts,
|
|
566
|
-
name,
|
|
567
|
-
...initialOpt,
|
|
568
|
-
describeKind: "derived",
|
|
569
|
-
completeWhenDepsComplete: false,
|
|
570
|
-
meta: baseMeta("wait", opts?.meta)
|
|
571
|
-
}
|
|
572
|
-
);
|
|
573
|
-
graph.add(name, step);
|
|
574
|
-
return step;
|
|
575
|
-
}
|
|
576
|
-
function onFailure(graph, name, source, recover, opts) {
|
|
577
|
-
const src = resolveDep(graph, source);
|
|
578
|
-
let terminated = false;
|
|
579
|
-
const step = node(
|
|
580
|
-
[],
|
|
581
|
-
(_data, actions) => {
|
|
582
|
-
const unsub = src.node.subscribe((msgs) => {
|
|
583
|
-
for (const msg of msgs) {
|
|
584
|
-
if (terminated) return;
|
|
585
|
-
if (msg[0] === ERROR) {
|
|
586
|
-
try {
|
|
587
|
-
actions.emit(recover(msg[1], actions));
|
|
588
|
-
} catch (err) {
|
|
589
|
-
terminated = true;
|
|
590
|
-
actions.down([[ERROR, err]]);
|
|
591
|
-
}
|
|
592
|
-
} else {
|
|
593
|
-
actions.down([msg]);
|
|
594
|
-
if (msg[0] === COMPLETE) terminated = true;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
return () => unsub();
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
...opts,
|
|
602
|
-
name,
|
|
603
|
-
describeKind: "derived",
|
|
604
|
-
completeWhenDepsComplete: false,
|
|
605
|
-
// onFailure handles errors via manual subscription (recover callback).
|
|
606
|
-
// Disable auto-propagation so dep-channel ERROR doesn't terminate this
|
|
607
|
-
// node before the recover callback has a chance to emit a replacement value.
|
|
608
|
-
errorWhenDepsError: false,
|
|
609
|
-
meta: baseMeta("onFailure", opts?.meta)
|
|
610
|
-
}
|
|
611
|
-
);
|
|
612
|
-
registerStep(graph, name, step, src.path ? [src.path] : []);
|
|
613
|
-
return step;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// src/patterns/ai.ts
|
|
617
|
-
function aiMeta(kind, extra) {
|
|
618
|
-
return domainMeta("ai", kind, extra);
|
|
619
|
-
}
|
|
620
|
-
function isPromiseLike(x) {
|
|
621
|
-
return x != null && typeof x.then === "function";
|
|
622
|
-
}
|
|
623
|
-
function isNodeLike(x) {
|
|
624
|
-
return typeof x === "object" && x !== null && "subscribe" in x && typeof x.subscribe === "function" && "cache" in x;
|
|
625
|
-
}
|
|
626
|
-
function isAsyncIterableLike(x) {
|
|
627
|
-
return x != null && typeof x === "object" && Symbol.asyncIterator in x && typeof x[Symbol.asyncIterator] === "function";
|
|
628
|
-
}
|
|
629
|
-
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
630
|
-
function firstDataFromNode(resolved, opts) {
|
|
631
|
-
if (resolved.status === "settled") {
|
|
632
|
-
const immediate = resolved.cache;
|
|
633
|
-
if (immediate !== void 0) {
|
|
634
|
-
return Promise.resolve(immediate);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
638
|
-
return new Promise((resolve, reject) => {
|
|
639
|
-
const timer = new ResettableTimer();
|
|
640
|
-
const unsub = resolved.subscribe((messages) => {
|
|
641
|
-
for (const msg of messages) {
|
|
642
|
-
if (msg[0] === DATA) {
|
|
643
|
-
timer.cancel();
|
|
644
|
-
unsub();
|
|
645
|
-
resolve(msg[1]);
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
if (msg[0] === ERROR) {
|
|
649
|
-
timer.cancel();
|
|
650
|
-
unsub();
|
|
651
|
-
reject(msg[1]);
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
if (msg[0] === COMPLETE) {
|
|
655
|
-
timer.cancel();
|
|
656
|
-
unsub();
|
|
657
|
-
reject(new Error("firstDataFromNode: completed without producing a value"));
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
timer.start(timeoutMs, () => {
|
|
663
|
-
unsub();
|
|
664
|
-
reject(new Error(`firstDataFromNode: timed out after ${timeoutMs}ms`));
|
|
665
|
-
});
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
async function resolveToolHandlerResult(value) {
|
|
669
|
-
if (isPromiseLike(value)) {
|
|
670
|
-
return resolveToolHandlerResult(await value);
|
|
671
|
-
}
|
|
672
|
-
if (isNodeLike(value)) {
|
|
673
|
-
return firstDataFromNode(value);
|
|
674
|
-
}
|
|
675
|
-
if (isAsyncIterableLike(value)) {
|
|
676
|
-
return firstDataFromNode(fromAny(value));
|
|
677
|
-
}
|
|
678
|
-
return value;
|
|
679
|
-
}
|
|
680
|
-
function fromLLM(adapter, messages, opts) {
|
|
681
|
-
const msgsNode = fromAny(messages);
|
|
682
|
-
const result = switchMap(msgsNode, (msgs) => {
|
|
683
|
-
if (!msgs || msgs.length === 0) {
|
|
684
|
-
return state(null);
|
|
685
|
-
}
|
|
686
|
-
const tools = opts?.tools;
|
|
687
|
-
return adapter.invoke(msgs, {
|
|
688
|
-
model: opts?.model,
|
|
689
|
-
temperature: opts?.temperature,
|
|
690
|
-
maxTokens: opts?.maxTokens,
|
|
691
|
-
tools,
|
|
692
|
-
systemPrompt: opts?.systemPrompt
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
return result;
|
|
696
|
-
}
|
|
697
|
-
function streamingPromptNode(adapter, deps, prompt, opts) {
|
|
698
|
-
const sourceName = opts?.name ?? "llm";
|
|
699
|
-
const format = opts?.format ?? "text";
|
|
700
|
-
const streamTopic = topic(`${sourceName}/stream`);
|
|
701
|
-
const messagesNode = derived(deps, (values) => {
|
|
702
|
-
if (values.some((v) => v == null)) return [];
|
|
703
|
-
const text = typeof prompt === "string" ? prompt : prompt(...values);
|
|
704
|
-
if (!text) return [];
|
|
705
|
-
const msgs = [];
|
|
706
|
-
if (opts?.systemPrompt) msgs.push({ role: "system", content: opts.systemPrompt });
|
|
707
|
-
msgs.push({ role: "user", content: text });
|
|
708
|
-
return msgs;
|
|
709
|
-
});
|
|
710
|
-
const output = switchMap(messagesNode, (msgs) => {
|
|
711
|
-
const chatMsgs = msgs;
|
|
712
|
-
if (!chatMsgs || chatMsgs.length === 0) {
|
|
713
|
-
return state(null);
|
|
714
|
-
}
|
|
715
|
-
const ac = new AbortController();
|
|
716
|
-
async function* pumpAndCollect() {
|
|
717
|
-
let accumulated = "";
|
|
718
|
-
let index = 0;
|
|
719
|
-
try {
|
|
720
|
-
for await (const token of adapter.stream(chatMsgs, {
|
|
721
|
-
model: opts?.model,
|
|
722
|
-
temperature: opts?.temperature,
|
|
723
|
-
maxTokens: opts?.maxTokens,
|
|
724
|
-
systemPrompt: opts?.systemPrompt,
|
|
725
|
-
signal: ac.signal
|
|
726
|
-
})) {
|
|
727
|
-
accumulated += token;
|
|
728
|
-
streamTopic.publish({
|
|
729
|
-
source: sourceName,
|
|
730
|
-
token,
|
|
731
|
-
accumulated,
|
|
732
|
-
index: index++
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
let result;
|
|
736
|
-
if (format === "json") {
|
|
737
|
-
try {
|
|
738
|
-
result = JSON.parse(stripFences(accumulated));
|
|
739
|
-
} catch {
|
|
740
|
-
result = null;
|
|
741
|
-
}
|
|
742
|
-
} else {
|
|
743
|
-
result = accumulated;
|
|
744
|
-
}
|
|
745
|
-
yield result;
|
|
746
|
-
} finally {
|
|
747
|
-
ac.abort();
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
return fromAny(pumpAndCollect());
|
|
751
|
-
});
|
|
752
|
-
const unsub = keepalive(output);
|
|
753
|
-
return {
|
|
754
|
-
output,
|
|
755
|
-
stream: streamTopic,
|
|
756
|
-
dispose: () => {
|
|
757
|
-
unsub();
|
|
758
|
-
streamTopic.destroy();
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
function streamExtractor(streamTopic, extractFn, opts) {
|
|
763
|
-
return derived(
|
|
764
|
-
[streamTopic.latest],
|
|
765
|
-
([chunk]) => {
|
|
766
|
-
if (chunk == null) return null;
|
|
767
|
-
return extractFn(chunk.accumulated);
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
name: opts?.name ?? "extractor",
|
|
771
|
-
describeKind: "derived",
|
|
772
|
-
initial: null,
|
|
773
|
-
meta: aiMeta("stream_extractor"),
|
|
774
|
-
...opts?.equals ? { equals: opts.equals } : {}
|
|
775
|
-
}
|
|
776
|
-
);
|
|
777
|
-
}
|
|
778
|
-
var keywordFlagsEqual = (a, b) => {
|
|
779
|
-
if (a === b) return true;
|
|
780
|
-
if (a == null || b == null) return a === b;
|
|
781
|
-
if (a.length !== b.length) return false;
|
|
782
|
-
for (let i = 0; i < a.length; i++) {
|
|
783
|
-
const x = a[i];
|
|
784
|
-
const y = b[i];
|
|
785
|
-
if (x.label !== y.label || x.pattern !== y.pattern || x.match !== y.match || x.position !== y.position) {
|
|
786
|
-
return false;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
return true;
|
|
790
|
-
};
|
|
791
|
-
function keywordFlagExtractor(streamTopic, opts) {
|
|
792
|
-
const maxPatternLength = opts.maxPatternLength ?? 128;
|
|
793
|
-
return derived(
|
|
794
|
-
[streamTopic.latest],
|
|
795
|
-
([chunk], ctx) => {
|
|
796
|
-
if (chunk == null) return [];
|
|
797
|
-
const accumulated = chunk.accumulated;
|
|
798
|
-
if (!("flags" in ctx.store)) {
|
|
799
|
-
ctx.store.flags = [];
|
|
800
|
-
ctx.store.scannedTo = 0;
|
|
801
|
-
}
|
|
802
|
-
const flags = ctx.store.flags;
|
|
803
|
-
const scannedTo = ctx.store.scannedTo;
|
|
804
|
-
const startOffset = Math.max(0, scannedTo - maxPatternLength);
|
|
805
|
-
const region = accumulated.slice(startOffset);
|
|
806
|
-
let added = false;
|
|
807
|
-
for (const { pattern, label } of opts.patterns) {
|
|
808
|
-
const re = new RegExp(pattern.source, `${pattern.flags.replace("g", "")}g`);
|
|
809
|
-
for (const m of region.matchAll(re)) {
|
|
810
|
-
const pos = startOffset + m.index;
|
|
811
|
-
if (pos + m[0].length <= scannedTo) continue;
|
|
812
|
-
flags.push({ label, pattern, match: m[0], position: pos });
|
|
813
|
-
added = true;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
ctx.store.scannedTo = accumulated.length;
|
|
817
|
-
return added ? [...flags] : flags.slice();
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
name: opts.name ?? "keyword-flag-extractor",
|
|
821
|
-
describeKind: "derived",
|
|
822
|
-
initial: [],
|
|
823
|
-
meta: aiMeta("keyword_flag_extractor"),
|
|
824
|
-
equals: keywordFlagsEqual
|
|
825
|
-
}
|
|
826
|
-
);
|
|
827
|
-
}
|
|
828
|
-
var toolCallsEqual = (a, b) => {
|
|
829
|
-
if (a === b) return true;
|
|
830
|
-
if (a == null || b == null) return a === b;
|
|
831
|
-
if (a.length !== b.length) return false;
|
|
832
|
-
for (let i = 0; i < a.length; i++) {
|
|
833
|
-
const x = a[i];
|
|
834
|
-
const y = b[i];
|
|
835
|
-
if (x.startIndex !== y.startIndex || x.name !== y.name || x.raw !== y.raw) {
|
|
836
|
-
return false;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
return true;
|
|
840
|
-
};
|
|
841
|
-
function toolCallExtractor(streamTopic, opts) {
|
|
842
|
-
return derived(
|
|
843
|
-
[streamTopic.latest],
|
|
844
|
-
([chunk], ctx) => {
|
|
845
|
-
if (chunk == null) return [];
|
|
846
|
-
const accumulated = chunk.accumulated;
|
|
847
|
-
if (!("calls" in ctx.store)) {
|
|
848
|
-
ctx.store.calls = [];
|
|
849
|
-
ctx.store.scanFrom = 0;
|
|
850
|
-
}
|
|
851
|
-
const calls = ctx.store.calls;
|
|
852
|
-
let i = ctx.store.scanFrom;
|
|
853
|
-
let added = false;
|
|
854
|
-
while (i < accumulated.length) {
|
|
855
|
-
const start = accumulated.indexOf("{", i);
|
|
856
|
-
if (start === -1) {
|
|
857
|
-
ctx.store.scanFrom = accumulated.length;
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
let depth = 0;
|
|
861
|
-
let end = -1;
|
|
862
|
-
let inString = false;
|
|
863
|
-
for (let j = start; j < accumulated.length; j++) {
|
|
864
|
-
const ch = accumulated[j];
|
|
865
|
-
if (inString) {
|
|
866
|
-
if (ch === "\\" && j + 1 < accumulated.length) {
|
|
867
|
-
j++;
|
|
868
|
-
} else if (ch === '"') {
|
|
869
|
-
inString = false;
|
|
870
|
-
}
|
|
871
|
-
} else if (ch === '"') {
|
|
872
|
-
inString = true;
|
|
873
|
-
} else if (ch === "{") {
|
|
874
|
-
depth++;
|
|
875
|
-
} else if (ch === "}") {
|
|
876
|
-
depth--;
|
|
877
|
-
if (depth === 0) {
|
|
878
|
-
end = j;
|
|
879
|
-
break;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
if (end === -1) {
|
|
884
|
-
ctx.store.scanFrom = start;
|
|
885
|
-
break;
|
|
886
|
-
}
|
|
887
|
-
const raw = accumulated.slice(start, end + 1);
|
|
888
|
-
try {
|
|
889
|
-
const parsed = JSON.parse(raw);
|
|
890
|
-
if (typeof parsed.name === "string" && parsed.arguments != null && typeof parsed.arguments === "object") {
|
|
891
|
-
calls.push({
|
|
892
|
-
name: parsed.name,
|
|
893
|
-
arguments: parsed.arguments,
|
|
894
|
-
raw,
|
|
895
|
-
startIndex: start
|
|
896
|
-
});
|
|
897
|
-
added = true;
|
|
898
|
-
}
|
|
899
|
-
} catch {
|
|
900
|
-
}
|
|
901
|
-
i = end + 1;
|
|
902
|
-
ctx.store.scanFrom = i;
|
|
903
|
-
}
|
|
904
|
-
return added ? [...calls] : calls.slice();
|
|
905
|
-
},
|
|
906
|
-
{
|
|
907
|
-
name: opts?.name ?? "tool-call-extractor",
|
|
908
|
-
describeKind: "derived",
|
|
909
|
-
initial: [],
|
|
910
|
-
meta: aiMeta("tool_call_extractor"),
|
|
911
|
-
equals: toolCallsEqual
|
|
912
|
-
}
|
|
913
|
-
);
|
|
914
|
-
}
|
|
915
|
-
var costMeterEqual = (a, b) => {
|
|
916
|
-
if (a === b) return true;
|
|
917
|
-
return a.chunkCount === b.chunkCount && a.charCount === b.charCount && a.estimatedTokens === b.estimatedTokens;
|
|
918
|
-
};
|
|
919
|
-
function costMeterExtractor(streamTopic, opts) {
|
|
920
|
-
const charsPerToken = opts?.charsPerToken ?? 4;
|
|
921
|
-
return derived(
|
|
922
|
-
[streamTopic.latest],
|
|
923
|
-
([chunk]) => {
|
|
924
|
-
if (chunk == null) return { chunkCount: 0, charCount: 0, estimatedTokens: 0 };
|
|
925
|
-
const c = chunk;
|
|
926
|
-
const charCount = c.accumulated.length;
|
|
927
|
-
return {
|
|
928
|
-
chunkCount: c.index + 1,
|
|
929
|
-
charCount,
|
|
930
|
-
estimatedTokens: Math.ceil(charCount / charsPerToken)
|
|
931
|
-
};
|
|
932
|
-
},
|
|
933
|
-
{
|
|
934
|
-
name: opts?.name ?? "cost-meter",
|
|
935
|
-
describeKind: "derived",
|
|
936
|
-
initial: { chunkCount: 0, charCount: 0, estimatedTokens: 0 },
|
|
937
|
-
meta: aiMeta("cost_meter_extractor"),
|
|
938
|
-
equals: costMeterEqual
|
|
939
|
-
}
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
function redactor(streamTopic, patterns, replaceFn, opts) {
|
|
943
|
-
const replace = replaceFn ?? (() => "[REDACTED]");
|
|
944
|
-
function sanitize(text) {
|
|
945
|
-
let result = text;
|
|
946
|
-
for (const pat of patterns) {
|
|
947
|
-
const global = pat.global ? pat : new RegExp(pat.source, `${pat.flags}g`);
|
|
948
|
-
result = result.replace(global, (m) => replace(m, pat));
|
|
949
|
-
}
|
|
950
|
-
return result;
|
|
951
|
-
}
|
|
952
|
-
return derived(
|
|
953
|
-
[streamTopic.latest],
|
|
954
|
-
([chunk]) => {
|
|
955
|
-
if (chunk == null) {
|
|
956
|
-
return { source: "", token: "", accumulated: "", index: -1 };
|
|
957
|
-
}
|
|
958
|
-
const c = chunk;
|
|
959
|
-
const sanitizedAccumulated = sanitize(c.accumulated);
|
|
960
|
-
const sanitizedToken = sanitize(c.token);
|
|
961
|
-
return {
|
|
962
|
-
source: c.source,
|
|
963
|
-
token: sanitizedToken,
|
|
964
|
-
accumulated: sanitizedAccumulated,
|
|
965
|
-
index: c.index
|
|
966
|
-
};
|
|
967
|
-
},
|
|
968
|
-
{ name: opts?.name ?? "redactor" }
|
|
969
|
-
);
|
|
970
|
-
}
|
|
971
|
-
function contentGate(streamTopic, classifier, threshold, opts) {
|
|
972
|
-
const hardThreshold = threshold * (opts?.hardMultiplier ?? 1.5);
|
|
973
|
-
const isNodeClassifier = typeof classifier !== "function";
|
|
974
|
-
const deps = [streamTopic.latest];
|
|
975
|
-
if (isNodeClassifier) deps.push(classifier);
|
|
976
|
-
return derived(
|
|
977
|
-
deps,
|
|
978
|
-
(values) => {
|
|
979
|
-
const chunk = values[0];
|
|
980
|
-
if (chunk == null) return "allow";
|
|
981
|
-
const score = isNodeClassifier ? values[1] ?? 0 : classifier(chunk.accumulated);
|
|
982
|
-
if (score >= hardThreshold) return "block";
|
|
983
|
-
if (score >= threshold) return "review";
|
|
984
|
-
return "allow";
|
|
985
|
-
},
|
|
986
|
-
{ name: opts?.name ?? "content-gate", initial: "allow" }
|
|
987
|
-
);
|
|
988
|
-
}
|
|
989
|
-
function gatedStream(graph, name, adapter, deps, prompt, opts) {
|
|
990
|
-
const cancelSignal = state(0, { name: `${name}/cancel` });
|
|
991
|
-
let cancelCounter = 0;
|
|
992
|
-
const allDeps = [...deps, cancelSignal];
|
|
993
|
-
const sourceName = opts?.name ?? name;
|
|
994
|
-
const format = opts?.format ?? "text";
|
|
995
|
-
const streamTopic = topic(`${sourceName}/stream`);
|
|
996
|
-
const messagesNode = derived(allDeps, (values) => {
|
|
997
|
-
const depValues = values.slice(0, -1);
|
|
998
|
-
if (depValues.some((v) => v == null)) return [];
|
|
999
|
-
const text = typeof prompt === "string" ? prompt : prompt(...depValues);
|
|
1000
|
-
if (!text) return [];
|
|
1001
|
-
const msgs = [];
|
|
1002
|
-
if (opts?.systemPrompt) msgs.push({ role: "system", content: opts.systemPrompt });
|
|
1003
|
-
msgs.push({ role: "user", content: text });
|
|
1004
|
-
return msgs;
|
|
1005
|
-
});
|
|
1006
|
-
const output = switchMap(messagesNode, (msgs) => {
|
|
1007
|
-
const chatMsgs = msgs;
|
|
1008
|
-
if (!chatMsgs || chatMsgs.length === 0) {
|
|
1009
|
-
return state(null);
|
|
1010
|
-
}
|
|
1011
|
-
const ac = new AbortController();
|
|
1012
|
-
async function* pumpAndCollect() {
|
|
1013
|
-
let accumulated = "";
|
|
1014
|
-
let index = 0;
|
|
1015
|
-
try {
|
|
1016
|
-
for await (const token of adapter.stream(chatMsgs, {
|
|
1017
|
-
model: opts?.model,
|
|
1018
|
-
temperature: opts?.temperature,
|
|
1019
|
-
maxTokens: opts?.maxTokens,
|
|
1020
|
-
systemPrompt: opts?.systemPrompt,
|
|
1021
|
-
signal: ac.signal
|
|
1022
|
-
})) {
|
|
1023
|
-
accumulated += token;
|
|
1024
|
-
streamTopic.publish({
|
|
1025
|
-
source: sourceName,
|
|
1026
|
-
token,
|
|
1027
|
-
accumulated,
|
|
1028
|
-
index: index++
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
let result;
|
|
1032
|
-
if (format === "json") {
|
|
1033
|
-
try {
|
|
1034
|
-
result = JSON.parse(stripFences(accumulated));
|
|
1035
|
-
} catch {
|
|
1036
|
-
result = null;
|
|
1037
|
-
}
|
|
1038
|
-
} else {
|
|
1039
|
-
result = accumulated;
|
|
1040
|
-
}
|
|
1041
|
-
yield result;
|
|
1042
|
-
} finally {
|
|
1043
|
-
ac.abort();
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return fromAny(pumpAndCollect());
|
|
1047
|
-
});
|
|
1048
|
-
const unsub = keepalive(output);
|
|
1049
|
-
const nonNullOutput = derived(
|
|
1050
|
-
[output],
|
|
1051
|
-
([v]) => {
|
|
1052
|
-
if (v == null) return void 0;
|
|
1053
|
-
return v;
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
name: `${name}/filter`
|
|
1057
|
-
}
|
|
1058
|
-
);
|
|
1059
|
-
graph.add(`${name}/raw`, nonNullOutput);
|
|
1060
|
-
const gateCtrl = gate(graph, `${name}/gate`, `${name}/raw`, opts?.gate);
|
|
1061
|
-
const originalReject = gateCtrl.reject.bind(gateCtrl);
|
|
1062
|
-
const gateWithAbort = {
|
|
1063
|
-
...gateCtrl,
|
|
1064
|
-
reject(count = 1) {
|
|
1065
|
-
originalReject(count);
|
|
1066
|
-
cancelSignal.down([[DATA, ++cancelCounter]]);
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
return {
|
|
1070
|
-
output: gateCtrl.node,
|
|
1071
|
-
stream: streamTopic,
|
|
1072
|
-
gate: gateWithAbort,
|
|
1073
|
-
dispose: () => {
|
|
1074
|
-
unsub();
|
|
1075
|
-
streamTopic.destroy();
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
function extractContent(resp) {
|
|
1080
|
-
if (resp != null && typeof resp === "object" && "content" in resp) {
|
|
1081
|
-
return String(resp.content);
|
|
1082
|
-
}
|
|
1083
|
-
if (typeof resp === "string") return resp;
|
|
1084
|
-
return String(resp);
|
|
1085
|
-
}
|
|
1086
|
-
function promptNode(adapter, deps, prompt, opts) {
|
|
1087
|
-
const format = opts?.format ?? "text";
|
|
1088
|
-
const retries = opts?.retries ?? 0;
|
|
1089
|
-
const useCache = opts?.cache ?? false;
|
|
1090
|
-
const cache = useCache ? /* @__PURE__ */ new Map() : null;
|
|
1091
|
-
const messagesNode = derived(
|
|
1092
|
-
deps,
|
|
1093
|
-
(values) => {
|
|
1094
|
-
if (values.some((v) => v == null)) return [];
|
|
1095
|
-
const text = typeof prompt === "string" ? prompt : prompt(...values);
|
|
1096
|
-
if (!text) return [];
|
|
1097
|
-
const msgs = [];
|
|
1098
|
-
if (opts?.systemPrompt) msgs.push({ role: "system", content: opts.systemPrompt });
|
|
1099
|
-
msgs.push({ role: "user", content: text });
|
|
1100
|
-
return msgs;
|
|
1101
|
-
},
|
|
1102
|
-
{
|
|
1103
|
-
name: opts?.name ? `${opts.name}::messages` : "prompt_node::messages",
|
|
1104
|
-
meta: aiMeta("prompt_node"),
|
|
1105
|
-
initial: []
|
|
1106
|
-
}
|
|
1107
|
-
);
|
|
1108
|
-
const result = switchMap(messagesNode, (msgs) => {
|
|
1109
|
-
if (!msgs || msgs.length === 0) {
|
|
1110
|
-
return state(null);
|
|
1111
|
-
}
|
|
1112
|
-
const cacheKey = useCache ? JSON.stringify(msgs.map((m) => [m.role, m.content])) : "";
|
|
1113
|
-
if (cache?.has(cacheKey)) {
|
|
1114
|
-
return state(cache.get(cacheKey));
|
|
1115
|
-
}
|
|
1116
|
-
async function attempt(remaining) {
|
|
1117
|
-
try {
|
|
1118
|
-
const resp = await new Promise((resolve, reject) => {
|
|
1119
|
-
const input = adapter.invoke(msgs, {
|
|
1120
|
-
model: opts?.model,
|
|
1121
|
-
temperature: opts?.temperature,
|
|
1122
|
-
maxTokens: opts?.maxTokens,
|
|
1123
|
-
systemPrompt: opts?.systemPrompt
|
|
1124
|
-
});
|
|
1125
|
-
if (input && typeof input.then === "function") {
|
|
1126
|
-
input.then(resolve, reject);
|
|
1127
|
-
} else if (input && typeof input.subscribe === "function") {
|
|
1128
|
-
resolve(input.cache);
|
|
1129
|
-
} else {
|
|
1130
|
-
resolve(input);
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
const content = extractContent(resp);
|
|
1134
|
-
let parsed;
|
|
1135
|
-
if (format === "json") {
|
|
1136
|
-
parsed = JSON.parse(stripFences(content));
|
|
1137
|
-
} else {
|
|
1138
|
-
parsed = content;
|
|
1139
|
-
}
|
|
1140
|
-
cache?.set(cacheKey, parsed);
|
|
1141
|
-
return parsed;
|
|
1142
|
-
} catch (err) {
|
|
1143
|
-
if (remaining > 0) return attempt(remaining - 1);
|
|
1144
|
-
throw err;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
return attempt(retries);
|
|
1148
|
-
});
|
|
1149
|
-
return result;
|
|
1150
|
-
}
|
|
1151
|
-
var ChatStreamGraph = class extends Graph {
|
|
1152
|
-
_log;
|
|
1153
|
-
messages;
|
|
1154
|
-
latest;
|
|
1155
|
-
messageCount;
|
|
1156
|
-
constructor(name, opts = {}) {
|
|
1157
|
-
super(name, opts.graph);
|
|
1158
|
-
this._log = reactiveLog([], {
|
|
1159
|
-
name: "messages",
|
|
1160
|
-
maxSize: opts.maxMessages
|
|
1161
|
-
});
|
|
1162
|
-
this.messages = this._log.entries;
|
|
1163
|
-
this.add("messages", this.messages);
|
|
1164
|
-
this.latest = derived(
|
|
1165
|
-
[this.messages],
|
|
1166
|
-
([snapshot]) => {
|
|
1167
|
-
const entries = snapshot;
|
|
1168
|
-
return entries.length === 0 ? null : entries[entries.length - 1];
|
|
1169
|
-
},
|
|
1170
|
-
{
|
|
1171
|
-
name: "latest",
|
|
1172
|
-
describeKind: "derived",
|
|
1173
|
-
meta: aiMeta("chat_latest")
|
|
1174
|
-
}
|
|
1175
|
-
);
|
|
1176
|
-
this.add("latest", this.latest);
|
|
1177
|
-
this.addDisposer(keepalive(this.latest));
|
|
1178
|
-
this.messageCount = derived(
|
|
1179
|
-
[this.messages],
|
|
1180
|
-
([snapshot]) => snapshot.length,
|
|
1181
|
-
{
|
|
1182
|
-
name: "messageCount",
|
|
1183
|
-
describeKind: "derived",
|
|
1184
|
-
meta: aiMeta("chat_message_count"),
|
|
1185
|
-
initial: 0
|
|
1186
|
-
}
|
|
1187
|
-
);
|
|
1188
|
-
this.add("messageCount", this.messageCount);
|
|
1189
|
-
this.addDisposer(keepalive(this.messageCount));
|
|
1190
|
-
}
|
|
1191
|
-
append(role, content, extra) {
|
|
1192
|
-
this._log.append({ role, content, ...extra });
|
|
1193
|
-
}
|
|
1194
|
-
appendToolResult(callId, content) {
|
|
1195
|
-
this._log.append({ role: "tool", content, toolCallId: callId });
|
|
1196
|
-
}
|
|
1197
|
-
clear() {
|
|
1198
|
-
this._log.clear();
|
|
1199
|
-
}
|
|
1200
|
-
allMessages() {
|
|
1201
|
-
return this.messages.cache;
|
|
1202
|
-
}
|
|
1203
|
-
};
|
|
1204
|
-
function chatStream(name, opts) {
|
|
1205
|
-
return new ChatStreamGraph(name, opts);
|
|
1206
|
-
}
|
|
1207
|
-
var ToolRegistryGraph = class extends Graph {
|
|
1208
|
-
definitions;
|
|
1209
|
-
schemas;
|
|
1210
|
-
constructor(name, opts = {}) {
|
|
1211
|
-
super(name, opts.graph);
|
|
1212
|
-
this.definitions = state(/* @__PURE__ */ new Map(), {
|
|
1213
|
-
name: "definitions",
|
|
1214
|
-
describeKind: "state",
|
|
1215
|
-
meta: aiMeta("tool_definitions")
|
|
1216
|
-
});
|
|
1217
|
-
this.add("definitions", this.definitions);
|
|
1218
|
-
this.schemas = derived(
|
|
1219
|
-
[this.definitions],
|
|
1220
|
-
([defs]) => [...(defs ?? /* @__PURE__ */ new Map()).values()],
|
|
1221
|
-
{
|
|
1222
|
-
name: "schemas",
|
|
1223
|
-
describeKind: "derived",
|
|
1224
|
-
meta: aiMeta("tool_schemas"),
|
|
1225
|
-
initial: []
|
|
1226
|
-
}
|
|
1227
|
-
);
|
|
1228
|
-
this.add("schemas", this.schemas);
|
|
1229
|
-
this.addDisposer(keepalive(this.schemas));
|
|
1230
|
-
}
|
|
1231
|
-
register(tool) {
|
|
1232
|
-
const current = this.definitions.cache;
|
|
1233
|
-
const next = new Map(current);
|
|
1234
|
-
next.set(tool.name, tool);
|
|
1235
|
-
this.definitions.down([[DATA, next]]);
|
|
1236
|
-
}
|
|
1237
|
-
unregister(name) {
|
|
1238
|
-
const current = this.definitions.cache;
|
|
1239
|
-
if (!current.has(name)) return;
|
|
1240
|
-
const next = new Map(current);
|
|
1241
|
-
next.delete(name);
|
|
1242
|
-
this.definitions.down([[DATA, next]]);
|
|
1243
|
-
}
|
|
1244
|
-
async execute(name, args) {
|
|
1245
|
-
const defs = this.definitions.cache;
|
|
1246
|
-
const tool = defs.get(name);
|
|
1247
|
-
if (!tool) throw new Error(`toolRegistry: unknown tool "${name}"`);
|
|
1248
|
-
const raw = tool.handler(args);
|
|
1249
|
-
return resolveToolHandlerResult(raw);
|
|
1250
|
-
}
|
|
1251
|
-
getDefinition(name) {
|
|
1252
|
-
return this.definitions.cache?.get(name);
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
function toolRegistry(name, opts) {
|
|
1256
|
-
return new ToolRegistryGraph(name, opts);
|
|
1257
|
-
}
|
|
1258
|
-
function systemPromptBuilder(sections, opts) {
|
|
1259
|
-
const separator = opts?.separator ?? "\n\n";
|
|
1260
|
-
const sectionNodes = sections.map((s) => typeof s === "string" ? state(s) : fromAny(s));
|
|
1261
|
-
const prompt = derived(
|
|
1262
|
-
sectionNodes,
|
|
1263
|
-
(values) => values.filter((v) => v != null && v !== "").join(separator),
|
|
1264
|
-
{
|
|
1265
|
-
name: opts?.name ?? "systemPrompt",
|
|
1266
|
-
describeKind: "derived",
|
|
1267
|
-
meta: aiMeta("system_prompt"),
|
|
1268
|
-
initial: ""
|
|
1269
|
-
}
|
|
1270
|
-
);
|
|
1271
|
-
const unsub = keepalive(prompt);
|
|
1272
|
-
return Object.assign(prompt, { dispose: unsub });
|
|
1273
|
-
}
|
|
1274
|
-
function llmExtractor(systemPrompt, opts) {
|
|
1275
|
-
return (raw, existing) => {
|
|
1276
|
-
const existingKeys = [...existing.keys()].slice(0, 100);
|
|
1277
|
-
const messages = [
|
|
1278
|
-
{ role: "system", content: systemPrompt },
|
|
1279
|
-
{
|
|
1280
|
-
role: "user",
|
|
1281
|
-
content: JSON.stringify({
|
|
1282
|
-
input: raw,
|
|
1283
|
-
existingKeys
|
|
1284
|
-
})
|
|
1285
|
-
}
|
|
1286
|
-
];
|
|
1287
|
-
return producer((actions) => {
|
|
1288
|
-
let active = true;
|
|
1289
|
-
const result = opts.adapter.invoke(messages, {
|
|
1290
|
-
model: opts.model,
|
|
1291
|
-
temperature: opts.temperature ?? 0,
|
|
1292
|
-
maxTokens: opts.maxTokens
|
|
1293
|
-
});
|
|
1294
|
-
const resolved = fromAny(result);
|
|
1295
|
-
const unsub = resolved.subscribe((msgs) => {
|
|
1296
|
-
if (!active) return;
|
|
1297
|
-
let done = false;
|
|
1298
|
-
for (const msg of msgs) {
|
|
1299
|
-
if (done) break;
|
|
1300
|
-
if (msg[0] === DATA) {
|
|
1301
|
-
const response = msg[1];
|
|
1302
|
-
try {
|
|
1303
|
-
const parsed = JSON.parse(response.content);
|
|
1304
|
-
actions.emit(parsed);
|
|
1305
|
-
actions.down([[COMPLETE]]);
|
|
1306
|
-
} catch {
|
|
1307
|
-
actions.down([
|
|
1308
|
-
[ERROR, new Error("llmExtractor: failed to parse LLM response as JSON")]
|
|
1309
|
-
]);
|
|
1310
|
-
}
|
|
1311
|
-
done = true;
|
|
1312
|
-
} else if (msg[0] === ERROR) {
|
|
1313
|
-
actions.down([[ERROR, msg[1]]]);
|
|
1314
|
-
done = true;
|
|
1315
|
-
} else if (msg[0] === COMPLETE) {
|
|
1316
|
-
actions.down([[COMPLETE]]);
|
|
1317
|
-
done = true;
|
|
1318
|
-
} else {
|
|
1319
|
-
actions.down([[msg[0], msg[1]]]);
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
});
|
|
1323
|
-
return () => {
|
|
1324
|
-
unsub();
|
|
1325
|
-
active = false;
|
|
1326
|
-
};
|
|
1327
|
-
});
|
|
1328
|
-
};
|
|
1329
|
-
}
|
|
1330
|
-
function llmConsolidator(systemPrompt, opts) {
|
|
1331
|
-
return (entries) => {
|
|
1332
|
-
const entriesArray = [...entries.entries()].map(([key, value]) => ({ key, value }));
|
|
1333
|
-
const messages = [
|
|
1334
|
-
{ role: "system", content: systemPrompt },
|
|
1335
|
-
{ role: "user", content: JSON.stringify({ memories: entriesArray }) }
|
|
1336
|
-
];
|
|
1337
|
-
return producer((actions) => {
|
|
1338
|
-
let active = true;
|
|
1339
|
-
const result = opts.adapter.invoke(messages, {
|
|
1340
|
-
model: opts.model,
|
|
1341
|
-
temperature: opts.temperature ?? 0,
|
|
1342
|
-
maxTokens: opts.maxTokens
|
|
1343
|
-
});
|
|
1344
|
-
const resolved = fromAny(result);
|
|
1345
|
-
const unsub = resolved.subscribe((msgs) => {
|
|
1346
|
-
if (!active) return;
|
|
1347
|
-
let done = false;
|
|
1348
|
-
for (const msg of msgs) {
|
|
1349
|
-
if (done) break;
|
|
1350
|
-
if (msg[0] === DATA) {
|
|
1351
|
-
const response = msg[1];
|
|
1352
|
-
try {
|
|
1353
|
-
const parsed = JSON.parse(response.content);
|
|
1354
|
-
actions.emit(parsed);
|
|
1355
|
-
actions.down([[COMPLETE]]);
|
|
1356
|
-
} catch {
|
|
1357
|
-
actions.down([
|
|
1358
|
-
[ERROR, new Error("llmConsolidator: failed to parse LLM response as JSON")]
|
|
1359
|
-
]);
|
|
1360
|
-
}
|
|
1361
|
-
done = true;
|
|
1362
|
-
} else if (msg[0] === ERROR) {
|
|
1363
|
-
actions.down([[ERROR, msg[1]]]);
|
|
1364
|
-
done = true;
|
|
1365
|
-
} else if (msg[0] === COMPLETE) {
|
|
1366
|
-
actions.down([[COMPLETE]]);
|
|
1367
|
-
done = true;
|
|
1368
|
-
} else {
|
|
1369
|
-
actions.down([[msg[0], msg[1]]]);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
return () => {
|
|
1374
|
-
unsub();
|
|
1375
|
-
active = false;
|
|
1376
|
-
};
|
|
1377
|
-
});
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
function defaultAdmissionScorer(_raw) {
|
|
1381
|
-
return { persistence: 0.5, structure: 0.5, personalValue: 0.5 };
|
|
1382
|
-
}
|
|
1383
|
-
function admissionFilter3D(opts = {}) {
|
|
1384
|
-
const scoreFn = opts.scoreFn ?? defaultAdmissionScorer;
|
|
1385
|
-
const pThresh = opts.persistenceThreshold ?? 0.3;
|
|
1386
|
-
const pvThresh = opts.personalValueThreshold ?? 0.3;
|
|
1387
|
-
const reqStructured = opts.requireStructured ?? false;
|
|
1388
|
-
return (raw) => {
|
|
1389
|
-
const scores = scoreFn(raw);
|
|
1390
|
-
if (scores.persistence < pThresh) return false;
|
|
1391
|
-
if (scores.personalValue < pvThresh) return false;
|
|
1392
|
-
if (reqStructured && scores.structure <= 0) return false;
|
|
1393
|
-
return true;
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
var DEFAULT_DECAY_RATE = Math.LN2 / (7 * 86400);
|
|
1397
|
-
function extractStoreMap(snapshot) {
|
|
1398
|
-
if (snapshot instanceof Map) return snapshot;
|
|
1399
|
-
return /* @__PURE__ */ new Map();
|
|
1400
|
-
}
|
|
1401
|
-
function agentMemory(name, source, opts) {
|
|
1402
|
-
const graph = new Graph(name, opts.graph);
|
|
1403
|
-
const keepaliveSubs = [];
|
|
1404
|
-
let rawExtractFn;
|
|
1405
|
-
if (opts.extractFn) {
|
|
1406
|
-
rawExtractFn = opts.extractFn;
|
|
1407
|
-
} else if (opts.adapter && opts.extractPrompt) {
|
|
1408
|
-
rawExtractFn = llmExtractor(opts.extractPrompt, { adapter: opts.adapter });
|
|
1409
|
-
} else {
|
|
1410
|
-
throw new Error("agentMemory: provide either extractFn or adapter + extractPrompt");
|
|
1411
|
-
}
|
|
1412
|
-
const extractFn = (raw, existing) => {
|
|
1413
|
-
if (raw == null) return { upsert: [] };
|
|
1414
|
-
return rawExtractFn(raw, existing);
|
|
1415
|
-
};
|
|
1416
|
-
let filteredSource = source;
|
|
1417
|
-
if (opts.admissionFilter) {
|
|
1418
|
-
const srcNode = fromAny(source);
|
|
1419
|
-
const filter = opts.admissionFilter;
|
|
1420
|
-
filteredSource = derived(
|
|
1421
|
-
[srcNode],
|
|
1422
|
-
([raw]) => {
|
|
1423
|
-
if (filter(raw)) return raw;
|
|
1424
|
-
return void 0;
|
|
1425
|
-
},
|
|
1426
|
-
{ name: "admissionFilter", describeKind: "derived" }
|
|
1427
|
-
);
|
|
1428
|
-
}
|
|
1429
|
-
let consolidateFn;
|
|
1430
|
-
if (opts.consolidateFn) {
|
|
1431
|
-
consolidateFn = opts.consolidateFn;
|
|
1432
|
-
} else if (opts.adapter && opts.consolidatePrompt) {
|
|
1433
|
-
consolidateFn = llmConsolidator(opts.consolidatePrompt, { adapter: opts.adapter });
|
|
1434
|
-
}
|
|
1435
|
-
let consolidateTrigger = opts.consolidateTrigger;
|
|
1436
|
-
if (!consolidateTrigger && consolidateFn && opts.reflection?.enabled !== false) {
|
|
1437
|
-
const interval = opts.reflection?.interval ?? 3e5;
|
|
1438
|
-
consolidateTrigger = fromTimer(interval, { period: interval });
|
|
1439
|
-
}
|
|
1440
|
-
const distillOpts = {
|
|
1441
|
-
score: opts.score,
|
|
1442
|
-
cost: opts.cost,
|
|
1443
|
-
budget: opts.budget ?? 2e3,
|
|
1444
|
-
context: opts.context,
|
|
1445
|
-
consolidate: consolidateFn,
|
|
1446
|
-
consolidateTrigger
|
|
1447
|
-
};
|
|
1448
|
-
const distillBundle = distill(filteredSource, extractFn, distillOpts);
|
|
1449
|
-
graph.add("store", distillBundle.store.entries);
|
|
1450
|
-
graph.add("compact", distillBundle.compact);
|
|
1451
|
-
graph.add("size", distillBundle.size);
|
|
1452
|
-
let vectors = null;
|
|
1453
|
-
if (opts.vectorDimensions && opts.vectorDimensions > 0 && opts.embedFn) {
|
|
1454
|
-
vectors = vectorIndex({ dimension: opts.vectorDimensions });
|
|
1455
|
-
graph.add("vectorIndex", vectors.entries);
|
|
1456
|
-
}
|
|
1457
|
-
let kg = null;
|
|
1458
|
-
if (opts.enableKnowledgeGraph) {
|
|
1459
|
-
kg = knowledgeGraph(`${name}-kg`);
|
|
1460
|
-
graph.mount("kg", kg);
|
|
1461
|
-
}
|
|
1462
|
-
let memoryTiersBundle = null;
|
|
1463
|
-
if (opts.tiers) {
|
|
1464
|
-
const tiersOpts = opts.tiers;
|
|
1465
|
-
const decayRate = tiersOpts.decayRate ?? DEFAULT_DECAY_RATE;
|
|
1466
|
-
const maxActive = tiersOpts.maxActive ?? 1e3;
|
|
1467
|
-
const archiveThreshold = tiersOpts.archiveThreshold ?? 0.1;
|
|
1468
|
-
const permanentFilter = tiersOpts.permanentFilter ?? (() => false);
|
|
1469
|
-
const permanent = lightCollection({ name: "permanent" });
|
|
1470
|
-
graph.add("permanent", permanent.entries);
|
|
1471
|
-
const permanentKeys = /* @__PURE__ */ new Set();
|
|
1472
|
-
const tierOf = (key) => {
|
|
1473
|
-
if (permanentKeys.has(key)) return "permanent";
|
|
1474
|
-
const storeMap = extractStoreMap(distillBundle.store.entries.cache);
|
|
1475
|
-
if (storeMap.has(key)) return "active";
|
|
1476
|
-
return "archived";
|
|
1477
|
-
};
|
|
1478
|
-
const markPermanent = (key, value) => {
|
|
1479
|
-
permanentKeys.add(key);
|
|
1480
|
-
permanent.upsert(key, value);
|
|
1481
|
-
};
|
|
1482
|
-
const entryCreatedAtNs = /* @__PURE__ */ new Map();
|
|
1483
|
-
const storeNode = distillBundle.store.entries;
|
|
1484
|
-
const contextNode = opts.context ? fromAny(opts.context) : state(null);
|
|
1485
|
-
const tierClassifier = effect([storeNode, contextNode], ([snapshot, ctx]) => {
|
|
1486
|
-
const storeMap = extractStoreMap(snapshot);
|
|
1487
|
-
const nowNs = monotonicNs();
|
|
1488
|
-
const toArchive = [];
|
|
1489
|
-
const toPermanent = [];
|
|
1490
|
-
for (const [key, mem] of storeMap) {
|
|
1491
|
-
if (!entryCreatedAtNs.has(key)) {
|
|
1492
|
-
entryCreatedAtNs.set(key, nowNs);
|
|
1493
|
-
}
|
|
1494
|
-
if (permanentFilter(key, mem)) {
|
|
1495
|
-
toPermanent.push({ key, value: mem });
|
|
1496
|
-
continue;
|
|
1497
|
-
}
|
|
1498
|
-
const baseScore = opts.score(mem, ctx);
|
|
1499
|
-
const createdNs = entryCreatedAtNs.get(key) ?? nowNs;
|
|
1500
|
-
const ageSeconds = Number(nowNs - createdNs) / 1e9;
|
|
1501
|
-
const decayed = decay(baseScore, ageSeconds, decayRate);
|
|
1502
|
-
if (decayed < archiveThreshold) {
|
|
1503
|
-
toArchive.push(key);
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
for (const key of entryCreatedAtNs.keys()) {
|
|
1507
|
-
if (!storeMap.has(key)) entryCreatedAtNs.delete(key);
|
|
1508
|
-
}
|
|
1509
|
-
for (const { key, value } of toPermanent) {
|
|
1510
|
-
if (!permanentKeys.has(key)) {
|
|
1511
|
-
markPermanent(key, value);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
const activeCount = storeMap.size - permanentKeys.size;
|
|
1515
|
-
if (activeCount > maxActive) {
|
|
1516
|
-
const scored = [...storeMap.entries()].filter(([k]) => !permanentKeys.has(k)).map(([k, m]) => ({ key: k, score: opts.score(m, ctx) })).sort((a, b) => a.score - b.score);
|
|
1517
|
-
const excess = activeCount - maxActive;
|
|
1518
|
-
for (let i = 0; i < excess && i < scored.length; i++) {
|
|
1519
|
-
const sk = scored[i].key;
|
|
1520
|
-
if (!toArchive.includes(sk)) toArchive.push(sk);
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
if (toArchive.length > 0) {
|
|
1524
|
-
batch(() => {
|
|
1525
|
-
for (const key of toArchive) {
|
|
1526
|
-
distillBundle.store.delete(key);
|
|
1527
|
-
}
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
});
|
|
1531
|
-
keepaliveSubs.push(tierClassifier.subscribe(() => void 0));
|
|
1532
|
-
let archiveHandle = null;
|
|
1533
|
-
if (tiersOpts.archiveTier) {
|
|
1534
|
-
archiveHandle = graph.attachStorage(
|
|
1535
|
-
[tiersOpts.archiveTier],
|
|
1536
|
-
tiersOpts.archiveStorageOptions ?? {}
|
|
1537
|
-
);
|
|
1538
|
-
}
|
|
1539
|
-
memoryTiersBundle = {
|
|
1540
|
-
permanent,
|
|
1541
|
-
activeEntries: storeNode,
|
|
1542
|
-
archiveHandle,
|
|
1543
|
-
tierOf,
|
|
1544
|
-
markPermanent
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
if (vectors || kg) {
|
|
1548
|
-
const embedFn = opts.embedFn;
|
|
1549
|
-
const entityFn = opts.entityFn;
|
|
1550
|
-
const storeNode = distillBundle.store.entries;
|
|
1551
|
-
const indexer = effect([storeNode], ([snapshot]) => {
|
|
1552
|
-
const storeMap = extractStoreMap(snapshot);
|
|
1553
|
-
for (const [key, mem] of storeMap) {
|
|
1554
|
-
if (vectors && embedFn) {
|
|
1555
|
-
const vec = embedFn(mem);
|
|
1556
|
-
if (vec) vectors.upsert(key, vec, mem);
|
|
1557
|
-
}
|
|
1558
|
-
if (kg && entityFn) {
|
|
1559
|
-
const extracted = entityFn(key, mem);
|
|
1560
|
-
if (extracted) {
|
|
1561
|
-
for (const ent of extracted.entities ?? []) {
|
|
1562
|
-
kg.upsertEntity(ent.id, ent.value);
|
|
1563
|
-
}
|
|
1564
|
-
for (const rel of extracted.relations ?? []) {
|
|
1565
|
-
kg.link(rel.from, rel.to, rel.relation, rel.weight);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
});
|
|
1571
|
-
keepaliveSubs.push(indexer.subscribe(() => void 0));
|
|
1572
|
-
}
|
|
1573
|
-
let retrievalNode = null;
|
|
1574
|
-
let retrievalTraceNode = null;
|
|
1575
|
-
let retrieveFn = null;
|
|
1576
|
-
if (vectors || kg) {
|
|
1577
|
-
const topK = opts.retrieval?.topK ?? 20;
|
|
1578
|
-
const graphDepth = opts.retrieval?.graphDepth ?? 1;
|
|
1579
|
-
const budget = opts.budget ?? 2e3;
|
|
1580
|
-
const costFn = opts.cost;
|
|
1581
|
-
const scoreFn = opts.score;
|
|
1582
|
-
const contextNode = opts.context ? fromAny(opts.context) : state(null);
|
|
1583
|
-
const retrievalOutput = state([], {
|
|
1584
|
-
name: "retrieval",
|
|
1585
|
-
describeKind: "state",
|
|
1586
|
-
meta: aiMeta("retrieval_pipeline")
|
|
1587
|
-
});
|
|
1588
|
-
graph.add("retrieval", retrievalOutput);
|
|
1589
|
-
retrievalNode = retrievalOutput;
|
|
1590
|
-
const traceState = state(null, {
|
|
1591
|
-
name: "retrievalTrace",
|
|
1592
|
-
describeKind: "state",
|
|
1593
|
-
meta: aiMeta("retrieval_trace")
|
|
1594
|
-
});
|
|
1595
|
-
graph.add("retrievalTrace", traceState);
|
|
1596
|
-
retrievalTraceNode = traceState;
|
|
1597
|
-
retrieveFn = (query) => {
|
|
1598
|
-
const storeMap = extractStoreMap(distillBundle.store.entries.cache);
|
|
1599
|
-
const ctx = contextNode.cache;
|
|
1600
|
-
const candidateMap = /* @__PURE__ */ new Map();
|
|
1601
|
-
let vectorCandidates = [];
|
|
1602
|
-
if (vectors && query.vector) {
|
|
1603
|
-
vectorCandidates = vectors.search(query.vector, topK);
|
|
1604
|
-
for (const vc of vectorCandidates) {
|
|
1605
|
-
const mem = storeMap.get(vc.id);
|
|
1606
|
-
if (mem) {
|
|
1607
|
-
candidateMap.set(vc.id, { value: mem, sources: /* @__PURE__ */ new Set(["vector"]) });
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
const graphExpanded = [];
|
|
1612
|
-
if (kg) {
|
|
1613
|
-
const seedIds = [...query.entityIds ?? [], ...[...candidateMap.keys()]];
|
|
1614
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1615
|
-
let frontier = seedIds;
|
|
1616
|
-
for (let depth = 0; depth < graphDepth; depth++) {
|
|
1617
|
-
const nextFrontier = [];
|
|
1618
|
-
for (const id of frontier) {
|
|
1619
|
-
if (visited.has(id)) continue;
|
|
1620
|
-
visited.add(id);
|
|
1621
|
-
const related = kg.related(id);
|
|
1622
|
-
for (const edge of related) {
|
|
1623
|
-
const targetId = edge.to;
|
|
1624
|
-
if (!visited.has(targetId)) {
|
|
1625
|
-
nextFrontier.push(targetId);
|
|
1626
|
-
const mem = storeMap.get(targetId);
|
|
1627
|
-
if (mem) {
|
|
1628
|
-
const existing = candidateMap.get(targetId);
|
|
1629
|
-
if (existing) {
|
|
1630
|
-
existing.sources.add("graph");
|
|
1631
|
-
} else {
|
|
1632
|
-
candidateMap.set(targetId, { value: mem, sources: /* @__PURE__ */ new Set(["graph"]) });
|
|
1633
|
-
}
|
|
1634
|
-
graphExpanded.push(targetId);
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
frontier = nextFrontier;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
for (const [key, mem] of storeMap) {
|
|
1643
|
-
if (!candidateMap.has(key)) {
|
|
1644
|
-
candidateMap.set(key, { value: mem, sources: /* @__PURE__ */ new Set(["store"]) });
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
const ranked = [];
|
|
1648
|
-
for (const [key, { value, sources }] of candidateMap) {
|
|
1649
|
-
const score = scoreFn(value, ctx);
|
|
1650
|
-
ranked.push({ key, value, score, sources: [...sources] });
|
|
1651
|
-
}
|
|
1652
|
-
ranked.sort((a, b) => b.score - a.score);
|
|
1653
|
-
const packed = [];
|
|
1654
|
-
let usedBudget = 0;
|
|
1655
|
-
for (const entry of ranked) {
|
|
1656
|
-
const c = costFn(entry.value);
|
|
1657
|
-
if (usedBudget + c > budget && packed.length > 0) break;
|
|
1658
|
-
packed.push(entry);
|
|
1659
|
-
usedBudget += c;
|
|
1660
|
-
}
|
|
1661
|
-
const trace = {
|
|
1662
|
-
vectorCandidates,
|
|
1663
|
-
graphExpanded,
|
|
1664
|
-
ranked,
|
|
1665
|
-
packed
|
|
1666
|
-
};
|
|
1667
|
-
batch(() => {
|
|
1668
|
-
retrievalOutput.down([[DATA, packed]]);
|
|
1669
|
-
traceState.down([[DATA, trace]]);
|
|
1670
|
-
});
|
|
1671
|
-
return packed;
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
graph.addDisposer(() => {
|
|
1675
|
-
for (const unsub of keepaliveSubs) unsub();
|
|
1676
|
-
keepaliveSubs.length = 0;
|
|
1677
|
-
});
|
|
1678
|
-
return Object.assign(graph, {
|
|
1679
|
-
distillBundle,
|
|
1680
|
-
compact: distillBundle.compact,
|
|
1681
|
-
size: distillBundle.size,
|
|
1682
|
-
vectors,
|
|
1683
|
-
kg,
|
|
1684
|
-
memoryTiers: memoryTiersBundle,
|
|
1685
|
-
retrieval: retrievalNode,
|
|
1686
|
-
retrievalTrace: retrievalTraceNode,
|
|
1687
|
-
retrieve: retrieveFn
|
|
1688
|
-
});
|
|
1689
|
-
}
|
|
1690
|
-
var AgentLoopGraph = class extends Graph {
|
|
1691
|
-
chat;
|
|
1692
|
-
tools;
|
|
1693
|
-
status;
|
|
1694
|
-
turnCount;
|
|
1695
|
-
lastResponse;
|
|
1696
|
-
_statusState;
|
|
1697
|
-
_turnCountState;
|
|
1698
|
-
_adapter;
|
|
1699
|
-
_maxTurns;
|
|
1700
|
-
_stopWhen;
|
|
1701
|
-
_onToolCall;
|
|
1702
|
-
_systemPrompt;
|
|
1703
|
-
_model;
|
|
1704
|
-
_temperature;
|
|
1705
|
-
_maxTokens;
|
|
1706
|
-
_running = false;
|
|
1707
|
-
_abortController = null;
|
|
1708
|
-
constructor(name, opts) {
|
|
1709
|
-
super(name, opts.graph);
|
|
1710
|
-
this._adapter = opts.adapter;
|
|
1711
|
-
this._maxTurns = opts.maxTurns ?? 10;
|
|
1712
|
-
this._stopWhen = opts.stopWhen;
|
|
1713
|
-
this._onToolCall = opts.onToolCall;
|
|
1714
|
-
this._systemPrompt = opts.systemPrompt;
|
|
1715
|
-
this._model = opts.model;
|
|
1716
|
-
this._temperature = opts.temperature;
|
|
1717
|
-
this._maxTokens = opts.maxTokens;
|
|
1718
|
-
this.chat = chatStream(`${name}-chat`, { maxMessages: opts.maxMessages });
|
|
1719
|
-
this.mount("chat", this.chat);
|
|
1720
|
-
this.tools = toolRegistry(`${name}-tools`);
|
|
1721
|
-
this.mount("tools", this.tools);
|
|
1722
|
-
if (opts.tools) {
|
|
1723
|
-
for (const tool of opts.tools) {
|
|
1724
|
-
this.tools.register(tool);
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
this._statusState = state("idle", {
|
|
1728
|
-
name: "status",
|
|
1729
|
-
describeKind: "state",
|
|
1730
|
-
meta: aiMeta("agent_status")
|
|
1731
|
-
});
|
|
1732
|
-
this.status = this._statusState;
|
|
1733
|
-
this.add("status", this.status);
|
|
1734
|
-
this._turnCountState = state(0, {
|
|
1735
|
-
name: "turnCount",
|
|
1736
|
-
describeKind: "state",
|
|
1737
|
-
meta: aiMeta("agent_turn_count")
|
|
1738
|
-
});
|
|
1739
|
-
this.turnCount = this._turnCountState;
|
|
1740
|
-
this.add("turnCount", this.turnCount);
|
|
1741
|
-
this.lastResponse = state(null, {
|
|
1742
|
-
name: "lastResponse",
|
|
1743
|
-
describeKind: "state",
|
|
1744
|
-
meta: aiMeta("agent_last_response")
|
|
1745
|
-
});
|
|
1746
|
-
this.add("lastResponse", this.lastResponse);
|
|
1747
|
-
}
|
|
1748
|
-
/**
|
|
1749
|
-
* Start the agent loop with a user message. The loop runs reactively:
|
|
1750
|
-
* think (LLM call) → act (tool execution) → repeat until done.
|
|
1751
|
-
*
|
|
1752
|
-
* Messages accumulate across calls. Call `chat.clear()` before `run()`
|
|
1753
|
-
* to reset conversation history.
|
|
1754
|
-
*/
|
|
1755
|
-
async run(userMessage) {
|
|
1756
|
-
if (this._running) throw new Error("agentLoop: already running");
|
|
1757
|
-
this._running = true;
|
|
1758
|
-
this._abortController = new AbortController();
|
|
1759
|
-
const { signal } = this._abortController;
|
|
1760
|
-
batch(() => {
|
|
1761
|
-
this._statusState.down([[DATA, "idle"]]);
|
|
1762
|
-
this._turnCountState.down([[DATA, 0]]);
|
|
1763
|
-
});
|
|
1764
|
-
this.chat.append("user", userMessage);
|
|
1765
|
-
try {
|
|
1766
|
-
let turns = 0;
|
|
1767
|
-
while (turns < this._maxTurns) {
|
|
1768
|
-
if (signal.aborted) throw new Error("agentLoop: aborted");
|
|
1769
|
-
turns++;
|
|
1770
|
-
batch(() => {
|
|
1771
|
-
this._turnCountState.down([[DATA, turns]]);
|
|
1772
|
-
this._statusState.down([[DATA, "thinking"]]);
|
|
1773
|
-
});
|
|
1774
|
-
const msgs = this.chat.allMessages();
|
|
1775
|
-
const toolSchemas = this.tools.schemas.cache ?? [];
|
|
1776
|
-
const response = await this._invokeLLM(msgs, toolSchemas, signal);
|
|
1777
|
-
if (signal.aborted) throw new Error("agentLoop: aborted");
|
|
1778
|
-
this.lastResponse.down([[DATA, response]]);
|
|
1779
|
-
this.chat.append("assistant", response.content, {
|
|
1780
|
-
toolCalls: response.toolCalls
|
|
1781
|
-
});
|
|
1782
|
-
if (this._shouldStop(response)) {
|
|
1783
|
-
this._statusState.down([[DATA, "done"]]);
|
|
1784
|
-
this._running = false;
|
|
1785
|
-
this._abortController = null;
|
|
1786
|
-
return response;
|
|
1787
|
-
}
|
|
1788
|
-
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
1789
|
-
this._statusState.down([[DATA, "acting"]]);
|
|
1790
|
-
for (const call of response.toolCalls) {
|
|
1791
|
-
if (signal.aborted) throw new Error("agentLoop: aborted");
|
|
1792
|
-
this._onToolCall?.(call);
|
|
1793
|
-
try {
|
|
1794
|
-
const result = await this.tools.execute(call.name, call.arguments);
|
|
1795
|
-
this.chat.appendToolResult(call.id, JSON.stringify(result));
|
|
1796
|
-
} catch (err) {
|
|
1797
|
-
this.chat.appendToolResult(call.id, JSON.stringify({ error: String(err) }));
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
} else {
|
|
1801
|
-
this._statusState.down([[DATA, "done"]]);
|
|
1802
|
-
this._running = false;
|
|
1803
|
-
this._abortController = null;
|
|
1804
|
-
return response;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
this._statusState.down([[DATA, "done"]]);
|
|
1808
|
-
this._running = false;
|
|
1809
|
-
this._abortController = null;
|
|
1810
|
-
return this.lastResponse.cache;
|
|
1811
|
-
} catch (err) {
|
|
1812
|
-
this._statusState.down([[DATA, "error"]]);
|
|
1813
|
-
this._running = false;
|
|
1814
|
-
this._abortController = null;
|
|
1815
|
-
throw err;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
async _invokeLLM(msgs, tools, signal) {
|
|
1819
|
-
const result = this._adapter.invoke(msgs, {
|
|
1820
|
-
tools: tools.length > 0 ? tools : void 0,
|
|
1821
|
-
systemPrompt: this._systemPrompt,
|
|
1822
|
-
model: this._model,
|
|
1823
|
-
temperature: this._temperature,
|
|
1824
|
-
maxTokens: this._maxTokens,
|
|
1825
|
-
signal
|
|
1826
|
-
});
|
|
1827
|
-
if (result == null) {
|
|
1828
|
-
throw new Error("_invokeLLM: adapter.invoke() returned null or undefined");
|
|
1829
|
-
}
|
|
1830
|
-
if (typeof result === "string") {
|
|
1831
|
-
throw new Error("_invokeLLM: adapter.invoke() returned a string, expected LLMResponse");
|
|
1832
|
-
}
|
|
1833
|
-
if (typeof result === "object" && "content" in result && !("subscribe" in result) && !("then" in result)) {
|
|
1834
|
-
return result;
|
|
1835
|
-
}
|
|
1836
|
-
if (isPromiseLike(result)) {
|
|
1837
|
-
const awaited = await result;
|
|
1838
|
-
if (typeof awaited === "object" && awaited !== null && "content" in awaited && !("subscribe" in awaited)) {
|
|
1839
|
-
return awaited;
|
|
1840
|
-
}
|
|
1841
|
-
return firstDataFromNode(fromAny(awaited));
|
|
1842
|
-
}
|
|
1843
|
-
return firstDataFromNode(fromAny(result));
|
|
1844
|
-
}
|
|
1845
|
-
_shouldStop(response) {
|
|
1846
|
-
if (response.finishReason === "end_turn" && (!response.toolCalls || response.toolCalls.length === 0))
|
|
1847
|
-
return true;
|
|
1848
|
-
if (this._stopWhen?.(response)) return true;
|
|
1849
|
-
return false;
|
|
1850
|
-
}
|
|
1851
|
-
destroy() {
|
|
1852
|
-
if (this._abortController) {
|
|
1853
|
-
this._abortController.abort();
|
|
1854
|
-
this._abortController = null;
|
|
1855
|
-
}
|
|
1856
|
-
this._running = false;
|
|
1857
|
-
super.destroy();
|
|
1858
|
-
}
|
|
1859
|
-
};
|
|
1860
|
-
function agentLoop(name, opts) {
|
|
1861
|
-
return new AgentLoopGraph(name, opts);
|
|
1862
|
-
}
|
|
1863
|
-
function metaToJsonSchema(meta) {
|
|
1864
|
-
const schema = {};
|
|
1865
|
-
const metaType = meta.type;
|
|
1866
|
-
if (metaType === "enum" && Array.isArray(meta.values)) {
|
|
1867
|
-
schema.type = "string";
|
|
1868
|
-
schema.enum = meta.values;
|
|
1869
|
-
} else if (metaType === "integer") {
|
|
1870
|
-
schema.type = "integer";
|
|
1871
|
-
} else if (metaType === "number") {
|
|
1872
|
-
schema.type = "number";
|
|
1873
|
-
} else if (metaType === "boolean") {
|
|
1874
|
-
schema.type = "boolean";
|
|
1875
|
-
} else if (metaType === "string") {
|
|
1876
|
-
schema.type = "string";
|
|
1877
|
-
} else {
|
|
1878
|
-
schema.type = ["string", "number", "boolean"];
|
|
1879
|
-
}
|
|
1880
|
-
if (Array.isArray(meta.range) && meta.range.length === 2) {
|
|
1881
|
-
schema.minimum = meta.range[0];
|
|
1882
|
-
schema.maximum = meta.range[1];
|
|
1883
|
-
}
|
|
1884
|
-
if (typeof meta.format === "string") {
|
|
1885
|
-
schema.description = `Format: ${meta.format}`;
|
|
1886
|
-
}
|
|
1887
|
-
if (typeof meta.unit === "string") {
|
|
1888
|
-
if (schema.description) {
|
|
1889
|
-
schema.description += ` (${meta.unit})`;
|
|
1890
|
-
} else {
|
|
1891
|
-
schema.description = `Unit: ${meta.unit}`;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
return schema;
|
|
1895
|
-
}
|
|
1896
|
-
function knobsAsTools(graph, actor) {
|
|
1897
|
-
const described = graph.describe({ actor, detail: "full" });
|
|
1898
|
-
const openai = [];
|
|
1899
|
-
const mcp = [];
|
|
1900
|
-
const definitions = [];
|
|
1901
|
-
for (const [path, node2] of Object.entries(described.nodes)) {
|
|
1902
|
-
if (node2.type !== "state") continue;
|
|
1903
|
-
if (path.includes("::__meta__::")) continue;
|
|
1904
|
-
if (node2.status === "completed" || node2.status === "errored") continue;
|
|
1905
|
-
const meta = node2.meta ?? {};
|
|
1906
|
-
const access = meta.access;
|
|
1907
|
-
if (access === "human" || access === "system") continue;
|
|
1908
|
-
const description = meta.description ?? `Set the value of ${path}`;
|
|
1909
|
-
const valueSchema = metaToJsonSchema(meta);
|
|
1910
|
-
const parameterSchema = {
|
|
1911
|
-
type: "object",
|
|
1912
|
-
required: ["value"],
|
|
1913
|
-
properties: {
|
|
1914
|
-
value: valueSchema
|
|
1915
|
-
},
|
|
1916
|
-
additionalProperties: false
|
|
1917
|
-
};
|
|
1918
|
-
const sanitizedName = path.replace(/::/g, "__");
|
|
1919
|
-
openai.push({
|
|
1920
|
-
type: "function",
|
|
1921
|
-
function: {
|
|
1922
|
-
name: sanitizedName,
|
|
1923
|
-
description,
|
|
1924
|
-
parameters: parameterSchema
|
|
1925
|
-
}
|
|
1926
|
-
});
|
|
1927
|
-
mcp.push({
|
|
1928
|
-
name: path,
|
|
1929
|
-
description,
|
|
1930
|
-
inputSchema: parameterSchema
|
|
1931
|
-
});
|
|
1932
|
-
const graphRef = graph;
|
|
1933
|
-
const actorRef = actor;
|
|
1934
|
-
const nv = node2.v;
|
|
1935
|
-
definitions.push({
|
|
1936
|
-
name: path,
|
|
1937
|
-
description,
|
|
1938
|
-
parameters: parameterSchema,
|
|
1939
|
-
handler(args) {
|
|
1940
|
-
graphRef.set(path, args.value, actorRef ? { actor: actorRef } : void 0);
|
|
1941
|
-
return args.value;
|
|
1942
|
-
},
|
|
1943
|
-
...nv != null ? { version: { id: nv.id, version: nv.version } } : {}
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
return { openai, mcp, definitions };
|
|
1947
|
-
}
|
|
1948
|
-
function gaugesAsContext(graph, actor, options) {
|
|
1949
|
-
const described = graph.describe({ actor, detail: "full" });
|
|
1950
|
-
const groupByTags = options?.groupByTags ?? true;
|
|
1951
|
-
const separator = options?.separator ?? "\n";
|
|
1952
|
-
const entries = [];
|
|
1953
|
-
const sinceVersion = options?.sinceVersion;
|
|
1954
|
-
for (const [path, node2] of Object.entries(described.nodes)) {
|
|
1955
|
-
const meta = node2.meta ?? {};
|
|
1956
|
-
const desc = meta.description;
|
|
1957
|
-
const format = meta.format;
|
|
1958
|
-
if (!desc && !format) continue;
|
|
1959
|
-
if (sinceVersion != null && node2.v != null) {
|
|
1960
|
-
const lastSeen = sinceVersion.get(path);
|
|
1961
|
-
if (lastSeen != null && lastSeen.id === node2.v.id && node2.v.version <= lastSeen.version)
|
|
1962
|
-
continue;
|
|
1963
|
-
}
|
|
1964
|
-
const label = desc ?? path;
|
|
1965
|
-
const value = node2.value;
|
|
1966
|
-
const unit = meta.unit;
|
|
1967
|
-
let formatted;
|
|
1968
|
-
if (format === "currency" && typeof value === "number") {
|
|
1969
|
-
formatted = `$${value.toFixed(2)}`;
|
|
1970
|
-
} else if (format === "percentage" && typeof value === "number") {
|
|
1971
|
-
formatted = `${(value * 100).toFixed(1)}%`;
|
|
1972
|
-
} else if (value === void 0 || value === null) {
|
|
1973
|
-
formatted = "(no value)";
|
|
1974
|
-
} else {
|
|
1975
|
-
formatted = String(value);
|
|
1976
|
-
}
|
|
1977
|
-
if (unit && format !== "currency" && format !== "percentage") {
|
|
1978
|
-
formatted = `${formatted} ${unit}`;
|
|
1979
|
-
}
|
|
1980
|
-
entries.push({ path, description: label, formatted });
|
|
1981
|
-
}
|
|
1982
|
-
if (entries.length === 0) return "";
|
|
1983
|
-
if (groupByTags) {
|
|
1984
|
-
const tagGroups = /* @__PURE__ */ new Map();
|
|
1985
|
-
const ungrouped = [];
|
|
1986
|
-
for (const entry of entries) {
|
|
1987
|
-
const node2 = described.nodes[entry.path];
|
|
1988
|
-
const tags = node2.meta?.tags;
|
|
1989
|
-
if (tags && tags.length > 0) {
|
|
1990
|
-
const tag = tags[0];
|
|
1991
|
-
let group = tagGroups.get(tag);
|
|
1992
|
-
if (!group) {
|
|
1993
|
-
group = [];
|
|
1994
|
-
tagGroups.set(tag, group);
|
|
1995
|
-
}
|
|
1996
|
-
group.push(entry);
|
|
1997
|
-
} else {
|
|
1998
|
-
ungrouped.push(entry);
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
if (tagGroups.size === 0) {
|
|
2002
|
-
return entries.map((e) => `- ${e.description}: ${e.formatted}`).join(separator);
|
|
2003
|
-
}
|
|
2004
|
-
const sections = [];
|
|
2005
|
-
for (const [tag, group] of [...tagGroups.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
2006
|
-
sections.push(
|
|
2007
|
-
`[${tag}]${separator}${group.map((e) => `- ${e.description}: ${e.formatted}`).join(separator)}`
|
|
2008
|
-
);
|
|
2009
|
-
}
|
|
2010
|
-
if (ungrouped.length > 0) {
|
|
2011
|
-
sections.push(ungrouped.map((e) => `- ${e.description}: ${e.formatted}`).join(separator));
|
|
2012
|
-
}
|
|
2013
|
-
return sections.join(separator + separator);
|
|
2014
|
-
}
|
|
2015
|
-
return entries.map((e) => `- ${e.description}: ${e.formatted}`).join(separator);
|
|
2016
|
-
}
|
|
2017
|
-
var VALID_NODE_TYPES = /* @__PURE__ */ new Set(["state", "derived", "producer", "operator", "effect"]);
|
|
2018
|
-
function validateGraphDef(def) {
|
|
2019
|
-
const errors = [];
|
|
2020
|
-
if (def == null || typeof def !== "object") {
|
|
2021
|
-
return { valid: false, errors: ["Definition must be a non-null object"] };
|
|
2022
|
-
}
|
|
2023
|
-
const d = def;
|
|
2024
|
-
if (typeof d.name !== "string" || d.name.length === 0) {
|
|
2025
|
-
errors.push("Missing or empty 'name' field");
|
|
2026
|
-
}
|
|
2027
|
-
if (d.nodes == null || typeof d.nodes !== "object" || Array.isArray(d.nodes)) {
|
|
2028
|
-
errors.push("Missing or invalid 'nodes' field (must be an object)");
|
|
2029
|
-
return { valid: false, errors };
|
|
2030
|
-
}
|
|
2031
|
-
const nodeNames = new Set(Object.keys(d.nodes));
|
|
2032
|
-
for (const [name, raw] of Object.entries(d.nodes)) {
|
|
2033
|
-
if (raw == null || typeof raw !== "object") {
|
|
2034
|
-
errors.push(`Node "${name}": must be an object`);
|
|
2035
|
-
continue;
|
|
2036
|
-
}
|
|
2037
|
-
const node2 = raw;
|
|
2038
|
-
if (typeof node2.type !== "string" || !VALID_NODE_TYPES.has(node2.type)) {
|
|
2039
|
-
errors.push(
|
|
2040
|
-
`Node "${name}": invalid type "${String(node2.type)}" (expected: ${[...VALID_NODE_TYPES].join(", ")})`
|
|
2041
|
-
);
|
|
2042
|
-
}
|
|
2043
|
-
if (Array.isArray(node2.deps)) {
|
|
2044
|
-
for (const dep of node2.deps) {
|
|
2045
|
-
if (typeof dep === "string" && !nodeNames.has(dep)) {
|
|
2046
|
-
errors.push(`Node "${name}": dep "${dep}" does not reference an existing node`);
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
if (!Array.isArray(d.edges)) {
|
|
2052
|
-
if (d.edges !== void 0) {
|
|
2053
|
-
errors.push("'edges' must be an array");
|
|
2054
|
-
}
|
|
2055
|
-
} else {
|
|
2056
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2057
|
-
for (let i = 0; i < d.edges.length; i++) {
|
|
2058
|
-
const edge = d.edges[i];
|
|
2059
|
-
if (edge == null || typeof edge !== "object") {
|
|
2060
|
-
errors.push(`Edge [${i}]: must be an object`);
|
|
2061
|
-
continue;
|
|
2062
|
-
}
|
|
2063
|
-
const e = edge;
|
|
2064
|
-
if (typeof e.from !== "string" || !nodeNames.has(e.from)) {
|
|
2065
|
-
errors.push(`Edge [${i}]: 'from' "${String(e.from)}" does not reference an existing node`);
|
|
2066
|
-
}
|
|
2067
|
-
if (typeof e.to !== "string" || !nodeNames.has(e.to)) {
|
|
2068
|
-
errors.push(`Edge [${i}]: 'to' "${String(e.to)}" does not reference an existing node`);
|
|
2069
|
-
}
|
|
2070
|
-
const key = `${e.from}->${e.to}`;
|
|
2071
|
-
if (seen.has(key)) {
|
|
2072
|
-
errors.push(`Edge [${i}]: duplicate edge ${key}`);
|
|
2073
|
-
}
|
|
2074
|
-
seen.add(key);
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
return { valid: errors.length === 0, errors };
|
|
2078
|
-
}
|
|
2079
|
-
function stripFences(text) {
|
|
2080
|
-
const match = text.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);
|
|
2081
|
-
return match ? match[1] : text;
|
|
2082
|
-
}
|
|
2083
|
-
var GRAPH_FROM_SPEC_SYSTEM_PROMPT = `You are a graph architect for GraphReFly, a reactive graph protocol.
|
|
2084
|
-
|
|
2085
|
-
Given a natural-language description, produce a JSON graph definition with this structure:
|
|
2086
|
-
|
|
2087
|
-
{
|
|
2088
|
-
"name": "<graph_name>",
|
|
2089
|
-
"nodes": {
|
|
2090
|
-
"<node_name>": {
|
|
2091
|
-
"type": "state" | "derived" | "producer" | "operator" | "effect",
|
|
2092
|
-
"value": <initial_value_or_null>,
|
|
2093
|
-
"deps": ["<dep_node_name>", ...],
|
|
2094
|
-
"meta": {
|
|
2095
|
-
"description": "<human-readable purpose>",
|
|
2096
|
-
"type": "string" | "number" | "boolean" | "integer" | "enum",
|
|
2097
|
-
"range": [min, max],
|
|
2098
|
-
"values": ["a", "b"],
|
|
2099
|
-
"format": "currency" | "percentage" | "status",
|
|
2100
|
-
"access": "human" | "llm" | "both" | "system",
|
|
2101
|
-
"unit": "<unit>",
|
|
2102
|
-
"tags": ["<tag>"]
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
},
|
|
2106
|
-
"edges": [
|
|
2107
|
-
{ "from": "<source_node>", "to": "<target_node>" }
|
|
2108
|
-
]
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
Rules:
|
|
2112
|
-
- "state" nodes have no deps and hold user/LLM-writable values (knobs).
|
|
2113
|
-
- "derived" nodes have deps and compute from them.
|
|
2114
|
-
- "effect" nodes have deps but produce side effects (no return value).
|
|
2115
|
-
- "producer" nodes have no deps but generate values asynchronously.
|
|
2116
|
-
- Edges wire output of one node as input to another. They must match deps.
|
|
2117
|
-
- meta.description is required for every node.
|
|
2118
|
-
- Return ONLY valid JSON, no markdown fences or commentary.`;
|
|
2119
|
-
async function graphFromSpec(naturalLanguage, adapter, opts) {
|
|
2120
|
-
const systemPrompt = opts?.systemPromptExtra ? `${GRAPH_FROM_SPEC_SYSTEM_PROMPT}
|
|
2121
|
-
|
|
2122
|
-
${opts.systemPromptExtra}` : GRAPH_FROM_SPEC_SYSTEM_PROMPT;
|
|
2123
|
-
const messages = [
|
|
2124
|
-
{ role: "system", content: systemPrompt },
|
|
2125
|
-
{ role: "user", content: naturalLanguage }
|
|
2126
|
-
];
|
|
2127
|
-
const rawResult = adapter.invoke(messages, {
|
|
2128
|
-
model: opts?.model,
|
|
2129
|
-
temperature: opts?.temperature ?? 0,
|
|
2130
|
-
maxTokens: opts?.maxTokens
|
|
2131
|
-
});
|
|
2132
|
-
const response = await resolveToolHandlerResult(rawResult);
|
|
2133
|
-
let content = response.content.trim();
|
|
2134
|
-
if (content.startsWith("```")) {
|
|
2135
|
-
content = stripFences(content);
|
|
2136
|
-
}
|
|
2137
|
-
let parsed;
|
|
2138
|
-
try {
|
|
2139
|
-
parsed = JSON.parse(content);
|
|
2140
|
-
} catch {
|
|
2141
|
-
throw new Error(`graphFromSpec: LLM response is not valid JSON: ${content.slice(0, 200)}`);
|
|
2142
|
-
}
|
|
2143
|
-
const validation = validateGraphDef(parsed);
|
|
2144
|
-
if (!validation.valid) {
|
|
2145
|
-
throw new Error(`graphFromSpec: invalid graph definition:
|
|
2146
|
-
${validation.errors.join("\n")}`);
|
|
2147
|
-
}
|
|
2148
|
-
const def = parsed;
|
|
2149
|
-
if (def.version === void 0) def.version = 1;
|
|
2150
|
-
if (!Array.isArray(def.subgraphs)) def.subgraphs = [];
|
|
2151
|
-
return Graph.fromSnapshot(def, opts?.build);
|
|
2152
|
-
}
|
|
2153
|
-
var SUGGEST_STRATEGY_SYSTEM_PROMPT = `You are a reactive graph optimizer for GraphReFly.
|
|
2154
|
-
|
|
2155
|
-
Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
|
|
2156
|
-
|
|
2157
|
-
Return ONLY valid JSON with this structure:
|
|
2158
|
-
{
|
|
2159
|
-
"summary": "<one-line summary of the strategy>",
|
|
2160
|
-
"reasoning": "<explanation of why these changes help>",
|
|
2161
|
-
"operations": [
|
|
2162
|
-
{ "type": "add_node", "name": "<name>", "nodeType": "state|derived|effect|producer|operator", "meta": {...}, "initial": <value> },
|
|
2163
|
-
{ "type": "remove_node", "name": "<name>" },
|
|
2164
|
-
{ "type": "connect", "from": "<source>", "to": "<target>" },
|
|
2165
|
-
{ "type": "disconnect", "from": "<source>", "to": "<target>" },
|
|
2166
|
-
{ "type": "set_value", "name": "<name>", "value": <new_value> },
|
|
2167
|
-
{ "type": "update_meta", "name": "<name>", "key": "<meta_key>", "value": <new_value> }
|
|
2168
|
-
]
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
Rules:
|
|
2172
|
-
- Only suggest operations that reference existing nodes (for remove/disconnect/set_value/update_meta) or new nodes you define (for add_node).
|
|
2173
|
-
- Keep changes minimal \u2014 prefer the smallest set of operations that solves the problem.
|
|
2174
|
-
- Return ONLY valid JSON, no markdown fences or commentary.`;
|
|
2175
|
-
async function suggestStrategy(graph, problem, adapter, opts) {
|
|
2176
|
-
const { expand: _, ...described } = graph.describe({ actor: opts?.actor, detail: "standard" });
|
|
2177
|
-
const messages = [
|
|
2178
|
-
{ role: "system", content: SUGGEST_STRATEGY_SYSTEM_PROMPT },
|
|
2179
|
-
{
|
|
2180
|
-
role: "user",
|
|
2181
|
-
content: JSON.stringify({
|
|
2182
|
-
graph: described,
|
|
2183
|
-
problem
|
|
2184
|
-
})
|
|
2185
|
-
}
|
|
2186
|
-
];
|
|
2187
|
-
const rawResult = adapter.invoke(messages, {
|
|
2188
|
-
model: opts?.model,
|
|
2189
|
-
temperature: opts?.temperature ?? 0,
|
|
2190
|
-
maxTokens: opts?.maxTokens
|
|
2191
|
-
});
|
|
2192
|
-
const response = await resolveToolHandlerResult(rawResult);
|
|
2193
|
-
let content = response.content.trim();
|
|
2194
|
-
if (content.startsWith("```")) {
|
|
2195
|
-
content = content.replace(/^```(?:json)?\s*/, "").replace(/\s*```$/, "");
|
|
2196
|
-
}
|
|
2197
|
-
let parsed;
|
|
2198
|
-
try {
|
|
2199
|
-
parsed = JSON.parse(content);
|
|
2200
|
-
} catch {
|
|
2201
|
-
throw new Error(`suggestStrategy: LLM response is not valid JSON: ${content.slice(0, 200)}`);
|
|
2202
|
-
}
|
|
2203
|
-
const plan = parsed;
|
|
2204
|
-
if (typeof plan.summary !== "string") {
|
|
2205
|
-
throw new Error("suggestStrategy: missing 'summary' in response");
|
|
2206
|
-
}
|
|
2207
|
-
if (typeof plan.reasoning !== "string") {
|
|
2208
|
-
throw new Error("suggestStrategy: missing 'reasoning' in response");
|
|
2209
|
-
}
|
|
2210
|
-
if (!Array.isArray(plan.operations)) {
|
|
2211
|
-
throw new Error("suggestStrategy: missing 'operations' array in response");
|
|
2212
|
-
}
|
|
2213
|
-
return {
|
|
2214
|
-
summary: plan.summary,
|
|
2215
|
-
reasoning: plan.reasoning,
|
|
2216
|
-
operations: plan.operations
|
|
2217
|
-
};
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
export {
|
|
2221
|
-
gate,
|
|
2222
|
-
orchestration_exports,
|
|
2223
|
-
fromLLM,
|
|
2224
|
-
streamingPromptNode,
|
|
2225
|
-
streamExtractor,
|
|
2226
|
-
keywordFlagExtractor,
|
|
2227
|
-
toolCallExtractor,
|
|
2228
|
-
costMeterExtractor,
|
|
2229
|
-
redactor,
|
|
2230
|
-
contentGate,
|
|
2231
|
-
gatedStream,
|
|
2232
|
-
promptNode,
|
|
2233
|
-
ChatStreamGraph,
|
|
2234
|
-
chatStream,
|
|
2235
|
-
ToolRegistryGraph,
|
|
2236
|
-
toolRegistry,
|
|
2237
|
-
systemPromptBuilder,
|
|
2238
|
-
llmExtractor,
|
|
2239
|
-
llmConsolidator,
|
|
2240
|
-
admissionFilter3D,
|
|
2241
|
-
agentMemory,
|
|
2242
|
-
AgentLoopGraph,
|
|
2243
|
-
agentLoop,
|
|
2244
|
-
knobsAsTools,
|
|
2245
|
-
gaugesAsContext,
|
|
2246
|
-
validateGraphDef,
|
|
2247
|
-
graphFromSpec,
|
|
2248
|
-
suggestStrategy,
|
|
2249
|
-
ai_exports
|
|
2250
|
-
};
|
|
2251
|
-
//# sourceMappingURL=chunk-K2AUJHVP.js.map
|