@graphrefly/graphrefly 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -19
- package/dist/_internal-B23BagFd.d.cts +33 -0
- package/dist/_internal-B23BagFd.d.ts +33 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
- package/dist/agents-C0Ji9ldU.d.cts +629 -0
- package/dist/agents-C9zexT7I.d.ts +629 -0
- package/dist/audit-BAXb3VOg.d.ts +246 -0
- package/dist/audit-C_bPfkqS.d.cts +246 -0
- package/dist/backoff-7KIK3WQW.js +24 -0
- package/dist/backoff-7KIK3WQW.js.map +1 -0
- package/dist/backoff-Bnb9OoPh.d.cts +6 -0
- package/dist/backoff-Bnb9OoPh.d.ts +6 -0
- package/dist/base/composition/index.cjs +811 -0
- package/dist/base/composition/index.cjs.map +1 -0
- package/dist/base/composition/index.d.cts +469 -0
- package/dist/base/composition/index.d.ts +469 -0
- package/dist/base/composition/index.js +40 -0
- package/dist/base/composition/index.js.map +1 -0
- package/dist/base/index.cjs +6336 -0
- package/dist/base/index.cjs.map +1 -0
- package/dist/base/index.d.cts +22 -0
- package/dist/base/index.d.ts +22 -0
- package/dist/base/index.js +259 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/io/index.cjs +3270 -0
- package/dist/base/io/index.cjs.map +1 -0
- package/dist/base/io/index.d.cts +2245 -0
- package/dist/base/io/index.d.ts +2245 -0
- package/dist/base/io/index.js +117 -0
- package/dist/base/io/index.js.map +1 -0
- package/dist/base/meta/index.cjs +43 -0
- package/dist/base/meta/index.cjs.map +1 -0
- package/dist/base/meta/index.d.cts +45 -0
- package/dist/base/meta/index.d.ts +45 -0
- package/dist/base/meta/index.js +13 -0
- package/dist/base/meta/index.js.map +1 -0
- package/dist/base/mutation/index.cjs +200 -0
- package/dist/base/mutation/index.cjs.map +1 -0
- package/dist/base/mutation/index.d.cts +177 -0
- package/dist/base/mutation/index.d.ts +177 -0
- package/dist/base/mutation/index.js +22 -0
- package/dist/base/mutation/index.js.map +1 -0
- package/dist/base/render/index.cjs +1120 -0
- package/dist/base/render/index.cjs.map +1 -0
- package/dist/{extra/render/index.d.ts → base/render/index.d.cts} +75 -31
- package/dist/{extra/render/index.d.cts → base/render/index.d.ts} +75 -31
- package/dist/base/render/index.js +24 -0
- package/dist/base/render/index.js.map +1 -0
- package/dist/base/sources/browser/index.cjs +172 -0
- package/dist/base/sources/browser/index.cjs.map +1 -0
- package/dist/base/sources/browser/index.d.cts +84 -0
- package/dist/base/sources/browser/index.d.ts +84 -0
- package/dist/base/sources/browser/index.js +151 -0
- package/dist/base/sources/browser/index.js.map +1 -0
- package/dist/base/sources/event/index.cjs +98 -0
- package/dist/base/sources/event/index.cjs.map +1 -0
- package/dist/base/sources/event/index.d.cts +91 -0
- package/dist/base/sources/event/index.d.ts +91 -0
- package/dist/base/sources/event/index.js +13 -0
- package/dist/base/sources/event/index.js.map +1 -0
- package/dist/base/sources/index.cjs +755 -0
- package/dist/base/sources/index.cjs.map +1 -0
- package/dist/{extra/sources.d.ts → base/sources/index.d.cts} +74 -301
- package/dist/{extra/sources.d.cts → base/sources/index.d.ts} +74 -301
- package/dist/base/sources/index.js +42 -0
- package/dist/base/sources/index.js.map +1 -0
- package/dist/base/sources/node/index.cjs +320 -0
- package/dist/base/sources/node/index.cjs.map +1 -0
- package/dist/{extra/node.d.ts → base/sources/node/index.d.cts} +35 -37
- package/dist/{extra/node.d.cts → base/sources/node/index.d.ts} +35 -37
- package/dist/base/sources/node/index.js +306 -0
- package/dist/base/sources/node/index.js.map +1 -0
- package/dist/base/utils/index.cjs +37 -0
- package/dist/base/utils/index.cjs.map +1 -0
- package/dist/base/utils/index.d.cts +37 -0
- package/dist/base/utils/index.d.ts +37 -0
- package/dist/base/utils/index.js +11 -0
- package/dist/base/utils/index.js.map +1 -0
- package/dist/base/worker/index.cjs +548 -0
- package/dist/base/worker/index.cjs.map +1 -0
- package/dist/base/worker/index.d.cts +207 -0
- package/dist/base/worker/index.d.ts +207 -0
- package/dist/base/worker/index.js +20 -0
- package/dist/base/worker/index.js.map +1 -0
- package/dist/breaker-C9skL3d8.d.ts +175 -0
- package/dist/breaker-ugSdq54q.d.cts +175 -0
- package/dist/{cascading-BglDkMdX.d.cts → cascading-CSSbKGrJ.d.ts} +3 -3
- package/dist/{cascading-MFgxu7Yo.d.ts → cascading-baGkiihI.d.cts} +3 -3
- package/dist/chunk-255UCBG4.js +58 -0
- package/dist/chunk-255UCBG4.js.map +1 -0
- package/dist/chunk-2LO3EL4W.js +1 -0
- package/dist/chunk-2LO3EL4W.js.map +1 -0
- package/dist/chunk-2OB3CEJS.js +1065 -0
- package/dist/chunk-2OB3CEJS.js.map +1 -0
- package/dist/chunk-36NMM65U.js +144 -0
- package/dist/chunk-36NMM65U.js.map +1 -0
- package/dist/chunk-3CEXCBN6.js +1 -0
- package/dist/chunk-3CEXCBN6.js.map +1 -0
- package/dist/chunk-3MUSLI6E.js +105 -0
- package/dist/chunk-3MUSLI6E.js.map +1 -0
- package/dist/chunk-3PSLNJDU.js +884 -0
- package/dist/chunk-3PSLNJDU.js.map +1 -0
- package/dist/chunk-3QZY5BI7.js +92 -0
- package/dist/chunk-3QZY5BI7.js.map +1 -0
- package/dist/chunk-42FQ27MQ.js +594 -0
- package/dist/chunk-42FQ27MQ.js.map +1 -0
- package/dist/chunk-4GYMCUDZ.js +1085 -0
- package/dist/chunk-4GYMCUDZ.js.map +1 -0
- package/dist/chunk-4S53H2KR.js +382 -0
- package/dist/chunk-4S53H2KR.js.map +1 -0
- package/dist/chunk-4XCHZRUJ.js +128 -0
- package/dist/chunk-4XCHZRUJ.js.map +1 -0
- package/dist/chunk-5THCXDWY.js +725 -0
- package/dist/chunk-5THCXDWY.js.map +1 -0
- package/dist/chunk-6XZYT4SW.js +256 -0
- package/dist/chunk-6XZYT4SW.js.map +1 -0
- package/dist/chunk-7EGRP2VX.js +76 -0
- package/dist/chunk-7EGRP2VX.js.map +1 -0
- package/dist/chunk-A7KV5UK4.js +150 -0
- package/dist/chunk-A7KV5UK4.js.map +1 -0
- package/dist/chunk-APY2SS5X.js +156 -0
- package/dist/chunk-APY2SS5X.js.map +1 -0
- package/dist/chunk-AZDQPQ3V.js +66 -0
- package/dist/chunk-AZDQPQ3V.js.map +1 -0
- package/dist/chunk-BU3SEFA5.js +90 -0
- package/dist/chunk-BU3SEFA5.js.map +1 -0
- package/dist/chunk-BXGZFGZ4.js +189 -0
- package/dist/chunk-BXGZFGZ4.js.map +1 -0
- package/dist/chunk-CGHORL6G.js +579 -0
- package/dist/chunk-CGHORL6G.js.map +1 -0
- package/dist/chunk-CXANAIZU.js +530 -0
- package/dist/chunk-CXANAIZU.js.map +1 -0
- package/dist/chunk-CZQHCKKG.js +1 -0
- package/dist/chunk-CZQHCKKG.js.map +1 -0
- package/dist/chunk-DKNHAICT.js +133 -0
- package/dist/chunk-DKNHAICT.js.map +1 -0
- package/dist/chunk-DM4OMPWK.js +584 -0
- package/dist/chunk-DM4OMPWK.js.map +1 -0
- package/dist/chunk-DMSNO6ZB.js +452 -0
- package/dist/chunk-DMSNO6ZB.js.map +1 -0
- package/dist/chunk-E5OZPDIW.js +229 -0
- package/dist/chunk-E5OZPDIW.js.map +1 -0
- package/dist/chunk-EVYY4X5A.js +509 -0
- package/dist/chunk-EVYY4X5A.js.map +1 -0
- package/dist/chunk-FDFD67UO.js +1 -0
- package/dist/chunk-FDFD67UO.js.map +1 -0
- package/dist/chunk-FMPF42Q4.js +13 -0
- package/dist/chunk-FMPF42Q4.js.map +1 -0
- package/dist/chunk-FR6RGA3B.js +1277 -0
- package/dist/chunk-FR6RGA3B.js.map +1 -0
- package/dist/chunk-FW23JYNQ.js +454 -0
- package/dist/chunk-FW23JYNQ.js.map +1 -0
- package/dist/chunk-GBCENOLN.js +1575 -0
- package/dist/chunk-GBCENOLN.js.map +1 -0
- package/dist/chunk-HL7HUJIX.js +1 -0
- package/dist/chunk-HL7HUJIX.js.map +1 -0
- package/dist/chunk-HULCUY35.js +2508 -0
- package/dist/chunk-HULCUY35.js.map +1 -0
- package/dist/chunk-IHTWQEDR.js +169 -0
- package/dist/chunk-IHTWQEDR.js.map +1 -0
- package/dist/chunk-IJRR6YAI.js +128 -0
- package/dist/chunk-IJRR6YAI.js.map +1 -0
- package/dist/chunk-JGFRAFDL.js +221 -0
- package/dist/chunk-JGFRAFDL.js.map +1 -0
- package/dist/chunk-KIIXR252.js +211 -0
- package/dist/chunk-KIIXR252.js.map +1 -0
- package/dist/chunk-KN3H5CNT.js +11 -0
- package/dist/chunk-KN3H5CNT.js.map +1 -0
- package/dist/chunk-KPG3DGLA.js +1 -0
- package/dist/chunk-KPG3DGLA.js.map +1 -0
- package/dist/chunk-KRNQ6RGQ.js +1 -0
- package/dist/chunk-KRNQ6RGQ.js.map +1 -0
- package/dist/chunk-LBAJK24K.js +1071 -0
- package/dist/chunk-LBAJK24K.js.map +1 -0
- package/dist/chunk-MLTPJMH6.js +417 -0
- package/dist/chunk-MLTPJMH6.js.map +1 -0
- package/dist/chunk-N3SZ7BMH.js +95 -0
- package/dist/chunk-N3SZ7BMH.js.map +1 -0
- package/dist/chunk-NDUD3IMO.js +540 -0
- package/dist/chunk-NDUD3IMO.js.map +1 -0
- package/dist/chunk-NY2PYHNC.js +873 -0
- package/dist/chunk-NY2PYHNC.js.map +1 -0
- package/dist/chunk-O3MT7DYI.js +225 -0
- package/dist/chunk-O3MT7DYI.js.map +1 -0
- package/dist/chunk-OCUDSN63.js +2386 -0
- package/dist/chunk-OCUDSN63.js.map +1 -0
- package/dist/chunk-OIWU3NYV.js +199 -0
- package/dist/chunk-OIWU3NYV.js.map +1 -0
- package/dist/chunk-OO5BM6CJ.js +1153 -0
- package/dist/chunk-OO5BM6CJ.js.map +1 -0
- package/dist/chunk-OQUIJT7A.js +1 -0
- package/dist/chunk-OQUIJT7A.js.map +1 -0
- package/dist/chunk-P5LBT622.js +105 -0
- package/dist/chunk-P5LBT622.js.map +1 -0
- package/dist/chunk-PKGQG5QQ.js +519 -0
- package/dist/chunk-PKGQG5QQ.js.map +1 -0
- package/dist/chunk-PKPO3JTZ.js +561 -0
- package/dist/chunk-PKPO3JTZ.js.map +1 -0
- package/dist/chunk-PL5UDIQ5.js +118 -0
- package/dist/chunk-PL5UDIQ5.js.map +1 -0
- package/dist/chunk-PZWISPIQ.js +432 -0
- package/dist/chunk-PZWISPIQ.js.map +1 -0
- package/dist/chunk-Q3EYOCZB.js +510 -0
- package/dist/chunk-Q3EYOCZB.js.map +1 -0
- package/dist/chunk-QMBYUVRL.js +15 -0
- package/dist/chunk-QMBYUVRL.js.map +1 -0
- package/dist/chunk-RAGGHLCV.js +200 -0
- package/dist/chunk-RAGGHLCV.js.map +1 -0
- package/dist/chunk-RGL53X5G.js +574 -0
- package/dist/chunk-RGL53X5G.js.map +1 -0
- package/dist/chunk-RJOG4IJU.js +1039 -0
- package/dist/chunk-RJOG4IJU.js.map +1 -0
- package/dist/chunk-SOOKUYVM.js +403 -0
- package/dist/chunk-SOOKUYVM.js.map +1 -0
- package/dist/chunk-T5BN5KG7.js +1 -0
- package/dist/chunk-T5BN5KG7.js.map +1 -0
- package/dist/chunk-TP7244Y6.js +207 -0
- package/dist/chunk-TP7244Y6.js.map +1 -0
- package/dist/chunk-TSBFTJKM.js +57 -0
- package/dist/chunk-TSBFTJKM.js.map +1 -0
- package/dist/chunk-URQ2CBBF.js +143 -0
- package/dist/chunk-URQ2CBBF.js.map +1 -0
- package/dist/chunk-W2BOPXTI.js +1 -0
- package/dist/chunk-W2BOPXTI.js.map +1 -0
- package/dist/chunk-WKSWLSCX.js +207 -0
- package/dist/chunk-WKSWLSCX.js.map +1 -0
- package/dist/chunk-Y52CS6YA.js +88 -0
- package/dist/chunk-Y52CS6YA.js.map +1 -0
- package/dist/chunk-YCBUWK77.js +92 -0
- package/dist/chunk-YCBUWK77.js.map +1 -0
- package/dist/chunk-YJ4U2D2C.js +314 -0
- package/dist/chunk-YJ4U2D2C.js.map +1 -0
- package/dist/chunk-Z4YXAUDN.js +239 -0
- package/dist/chunk-Z4YXAUDN.js.map +1 -0
- package/dist/chunk-Z6EGP5D7.js +92 -0
- package/dist/chunk-Z6EGP5D7.js.map +1 -0
- package/dist/compat/index.cjs +3100 -9
- package/dist/compat/index.cjs.map +1 -0
- package/dist/compat/index.d.cts +112 -18
- package/dist/compat/index.d.ts +112 -18
- package/dist/compat/index.js +176 -1
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/jotai/index.cjs +149 -1
- package/dist/compat/jotai/index.cjs.map +1 -0
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +8 -1
- package/dist/compat/jotai/index.js.map +1 -0
- package/dist/compat/nanostores/index.cjs +205 -1
- package/dist/compat/nanostores/index.cjs.map +1 -0
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +22 -1
- package/dist/compat/nanostores/index.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +2241 -9
- package/dist/compat/nestjs/index.cjs.map +1 -0
- package/dist/compat/nestjs/index.d.cts +7 -10
- package/dist/compat/nestjs/index.d.ts +7 -10
- package/dist/compat/nestjs/index.js +78 -1
- package/dist/compat/nestjs/index.js.map +1 -0
- package/dist/compat/react/index.cjs +114 -1
- package/dist/compat/react/index.cjs.map +1 -0
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/react/index.js +12 -1
- package/dist/compat/react/index.js.map +1 -0
- package/dist/compat/solid/index.cjs +101 -1
- package/dist/compat/solid/index.cjs.map +1 -0
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/solid/index.js +12 -1
- package/dist/compat/solid/index.js.map +1 -0
- package/dist/compat/svelte/index.cjs +104 -1
- package/dist/compat/svelte/index.cjs.map +1 -0
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/svelte/index.js +12 -1
- package/dist/compat/svelte/index.js.map +1 -0
- package/dist/compat/vue/index.cjs +119 -1
- package/dist/compat/vue/index.cjs.map +1 -0
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/vue/index.js +12 -1
- package/dist/compat/vue/index.js.map +1 -0
- package/dist/compat/zustand/index.cjs +69 -3
- package/dist/compat/zustand/index.cjs.map +1 -0
- package/dist/compat/zustand/index.d.cts +2 -6
- package/dist/compat/zustand/index.d.ts +2 -6
- package/dist/compat/zustand/index.js +8 -1
- package/dist/compat/zustand/index.js.map +1 -0
- package/dist/distill-De6Rnn15.d.cts +48 -0
- package/dist/distill-De6Rnn15.d.ts +48 -0
- package/dist/external-register-CWyroXb_.d.cts +138 -0
- package/dist/external-register-CWyroXb_.d.ts +138 -0
- package/dist/{fallback-74oxi34l.d.cts → fallback-Bx46zqky.d.cts} +3 -10
- package/dist/{fallback-DUyyBTBK.d.ts → fallback-pIWW8A2d.d.ts} +3 -10
- package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
- package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
- package/dist/{index-CBGUK09R.d.ts → index-5SU_O78r.d.cts} +5 -5
- package/dist/{index-BmZXHqkE.d.ts → index-B6pxYJzO.d.cts} +1 -1
- package/dist/{index-hcDJ8PSI.d.cts → index-B6pxYJzO.d.ts} +1 -1
- package/dist/{index-C5stwKcw.d.cts → index-BFsng6v1.d.cts} +1 -1
- package/dist/{index-CdAlHFEt.d.ts → index-BFsng6v1.d.ts} +1 -1
- package/dist/{index-_6ODbuOu.d.cts → index-Bg-LwEt-.d.cts} +1 -1
- package/dist/{index-CviRnE4K.d.ts → index-Bg-LwEt-.d.ts} +1 -1
- package/dist/{index-CBBLl_rc.d.ts → index-Brp888t0.d.cts} +1 -1
- package/dist/{index-BQSKmbuG.d.cts → index-Brp888t0.d.ts} +1 -1
- package/dist/{index-sqkqlb1p.d.ts → index-CDfk6jHN.d.cts} +1 -1
- package/dist/{index-ZVQhLa2i.d.cts → index-CDfk6jHN.d.ts} +1 -1
- package/dist/{index-Climxqsu.d.cts → index-CEXCtYYJ.d.ts} +5 -5
- package/dist/index-DLAxYaN5.d.cts +169 -0
- package/dist/index-DLAxYaN5.d.ts +169 -0
- package/dist/{index-CK29LV56.d.cts → index-DeWbQzMe.d.cts} +1 -1
- package/dist/{index-CPQlGA29.d.ts → index-DeWbQzMe.d.ts} +1 -1
- package/dist/{index-BrPrLl4e.d.cts → index-dX9IzPqj.d.cts} +1 -1
- package/dist/{index-Dgl1HpPn.d.ts → index-dX9IzPqj.d.ts} +1 -1
- package/dist/index.cjs +25934 -191
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +58 -94
- package/dist/index.d.ts +58 -94
- package/dist/index.js +852 -1
- package/dist/index.js.map +1 -0
- package/dist/layout-types-B5aiHYgk.d.cts +72 -0
- package/dist/layout-types-B5aiHYgk.d.ts +72 -0
- package/dist/memory-composers-BryDrRBX.d.cts +529 -0
- package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
- package/dist/{observable-DWjNfLvC.d.ts → observable-BXQoW1P-.d.cts} +1 -1
- package/dist/{observable-e3eiPPFy.d.cts → observable-BXQoW1P-.d.ts} +1 -1
- package/dist/{pipeline-graph-Sgj0gCwn.d.ts → pipeline-graph-Ce47CB6Y.d.cts} +13 -10
- package/dist/{pipeline-graph-CIKhynsF.d.cts → pipeline-graph-DXCwY9vG.d.ts} +13 -10
- package/dist/presets/ai/index.cjs +4377 -0
- package/dist/presets/ai/index.cjs.map +1 -0
- package/dist/presets/ai/index.d.cts +98 -0
- package/dist/presets/ai/index.d.ts +98 -0
- package/dist/presets/ai/index.js +54 -0
- package/dist/presets/ai/index.js.map +1 -0
- package/dist/presets/harness/index.cjs +5929 -0
- package/dist/presets/harness/index.cjs.map +1 -0
- package/dist/presets/harness/index.d.cts +566 -0
- package/dist/presets/harness/index.d.ts +566 -0
- package/dist/presets/harness/index.js +71 -0
- package/dist/presets/harness/index.js.map +1 -0
- package/dist/presets/index.cjs +9782 -0
- package/dist/presets/index.cjs.map +1 -0
- package/dist/presets/index.d.cts +28 -0
- package/dist/presets/index.d.ts +28 -0
- package/dist/presets/index.js +129 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/inspect/index.cjs +1087 -0
- package/dist/presets/inspect/index.cjs.map +1 -0
- package/dist/presets/inspect/index.d.cts +172 -0
- package/dist/presets/inspect/index.d.ts +172 -0
- package/dist/presets/inspect/index.js +21 -0
- package/dist/presets/inspect/index.js.map +1 -0
- package/dist/presets/resilience/index.cjs +1593 -0
- package/dist/presets/resilience/index.cjs.map +1 -0
- package/dist/presets/resilience/index.d.cts +205 -0
- package/dist/presets/resilience/index.d.ts +205 -0
- package/dist/presets/resilience/index.js +18 -0
- package/dist/presets/resilience/index.js.map +1 -0
- package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
- package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
- package/dist/{reactive-layout-DOTs9P3X.d.ts → reactive-layout-fswlBUvX.d.cts} +19 -7
- package/dist/{reactive-layout-DgctbqZo.d.cts → reactive-layout-fswlBUvX.d.ts} +19 -7
- package/dist/retry-BDbRZ_gx.d.ts +125 -0
- package/dist/retry-DWuhjvsA.d.cts +125 -0
- package/dist/solutions/index.cjs +8200 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +23 -0
- package/dist/solutions/index.d.ts +23 -0
- package/dist/solutions/index.js +55 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/spawnable-5mDY501F.d.cts +746 -0
- package/dist/spawnable-D3lR0oQu.d.ts +746 -0
- package/dist/status-U-rUI79b.d.cts +84 -0
- package/dist/status-U-rUI79b.d.ts +84 -0
- package/dist/timeout-U5O4ESK3.js +12 -0
- package/dist/timeout-U5O4ESK3.js.map +1 -0
- package/dist/{types-CWFysE9E.d.ts → types-BB5Lw-pB.d.cts} +3 -3
- package/dist/{types-C0_yquda.d.cts → types-BB5Lw-pB.d.ts} +3 -3
- package/dist/types-CJWIMJiZ.d.ts +548 -0
- package/dist/types-vCq7ShIm.d.cts +548 -0
- package/dist/utils/ai/browser.cjs +2169 -0
- package/dist/utils/ai/browser.cjs.map +1 -0
- package/dist/{patterns → utils}/ai/browser.d.cts +7 -5
- package/dist/{patterns → utils}/ai/browser.d.ts +7 -5
- package/dist/utils/ai/browser.js +255 -0
- package/dist/utils/ai/browser.js.map +1 -0
- package/dist/utils/ai/index.cjs +8468 -0
- package/dist/utils/ai/index.cjs.map +1 -0
- package/dist/{index-CR8QpwX8.d.ts → utils/ai/index.d.cts} +73 -976
- package/dist/{index-UPSiS-X7.d.cts → utils/ai/index.d.ts} +73 -976
- package/dist/utils/ai/index.js +173 -0
- package/dist/utils/ai/index.js.map +1 -0
- package/dist/utils/ai/node.cjs +648 -0
- package/dist/utils/ai/node.cjs.map +1 -0
- package/dist/{patterns → utils}/ai/node.d.cts +5 -7
- package/dist/{patterns → utils}/ai/node.d.ts +5 -7
- package/dist/utils/ai/node.js +84 -0
- package/dist/utils/ai/node.js.map +1 -0
- package/dist/utils/cqrs/index.cjs +1036 -0
- package/dist/utils/cqrs/index.cjs.map +1 -0
- package/dist/{index-CeFiHtAg.d.ts → utils/cqrs/index.d.cts} +7 -37
- package/dist/{index-B-_tFaqV.d.cts → utils/cqrs/index.d.ts} +7 -37
- package/dist/utils/cqrs/index.js +18 -0
- package/dist/utils/cqrs/index.js.map +1 -0
- package/dist/utils/demo-shell/index.cjs +865 -0
- package/dist/utils/demo-shell/index.cjs.map +1 -0
- package/dist/{index-B8YnZpIR.d.ts → utils/demo-shell/index.d.cts} +4 -16
- package/dist/{index-Cwv0KWcU.d.cts → utils/demo-shell/index.d.ts} +4 -16
- package/dist/utils/demo-shell/index.js +13 -0
- package/dist/utils/demo-shell/index.js.map +1 -0
- package/dist/utils/domain-templates/index.cjs +732 -0
- package/dist/utils/domain-templates/index.cjs.map +1 -0
- package/dist/{index-CzLVrjxn.d.ts → utils/domain-templates/index.d.cts} +3 -20
- package/dist/{index-BaQaY_IQ.d.cts → utils/domain-templates/index.d.ts} +3 -20
- package/dist/utils/domain-templates/index.js +17 -0
- package/dist/utils/domain-templates/index.js.map +1 -0
- package/dist/utils/graphspec/index.cjs +1174 -0
- package/dist/utils/graphspec/index.cjs.map +1 -0
- package/dist/{index-CMh5Rz1y.d.ts → utils/graphspec/index.d.cts} +106 -42
- package/dist/{index-CS0LTlB8.d.cts → utils/graphspec/index.d.ts} +106 -42
- package/dist/utils/graphspec/index.js +35 -0
- package/dist/utils/graphspec/index.js.map +1 -0
- package/dist/utils/harness/index.cjs +656 -0
- package/dist/utils/harness/index.cjs.map +1 -0
- package/dist/utils/harness/index.d.cts +542 -0
- package/dist/utils/harness/index.d.ts +542 -0
- package/dist/utils/harness/index.js +56 -0
- package/dist/utils/harness/index.js.map +1 -0
- package/dist/utils/index.cjs +17609 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +96 -0
- package/dist/utils/index.d.ts +96 -0
- package/dist/utils/index.js +514 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inspect/index.cjs +807 -0
- package/dist/utils/inspect/index.cjs.map +1 -0
- package/dist/utils/inspect/index.d.cts +123 -0
- package/dist/utils/inspect/index.d.ts +123 -0
- package/dist/utils/inspect/index.js +30 -0
- package/dist/utils/inspect/index.js.map +1 -0
- package/dist/utils/job-queue/index.cjs +717 -0
- package/dist/utils/job-queue/index.cjs.map +1 -0
- package/dist/{index-DisjX8a-.d.ts → utils/job-queue/index.d.cts} +5 -26
- package/dist/{index-DV_1YuVk.d.cts → utils/job-queue/index.d.ts} +5 -26
- package/dist/utils/job-queue/index.js +18 -0
- package/dist/utils/job-queue/index.js.map +1 -0
- package/dist/utils/memory/index.cjs +1451 -0
- package/dist/utils/memory/index.cjs.map +1 -0
- package/dist/{index-CZ3r5Rxp.d.ts → utils/memory/index.d.cts} +242 -34
- package/dist/{index-B17QddL1.d.cts → utils/memory/index.d.ts} +242 -34
- package/dist/utils/memory/index.js +19 -0
- package/dist/utils/memory/index.js.map +1 -0
- package/dist/utils/messaging/index.cjs +666 -0
- package/dist/utils/messaging/index.cjs.map +1 -0
- package/dist/utils/messaging/index.d.cts +562 -0
- package/dist/utils/messaging/index.d.ts +562 -0
- package/dist/utils/messaging/index.js +50 -0
- package/dist/utils/messaging/index.js.map +1 -0
- package/dist/utils/orchestration/index.cjs +876 -0
- package/dist/utils/orchestration/index.cjs.map +1 -0
- package/dist/utils/orchestration/index.d.cts +233 -0
- package/dist/utils/orchestration/index.d.ts +233 -0
- package/dist/utils/orchestration/index.js +19 -0
- package/dist/utils/orchestration/index.js.map +1 -0
- package/dist/utils/process/index.cjs +743 -0
- package/dist/utils/process/index.cjs.map +1 -0
- package/dist/{index-p09KSrTN.d.ts → utils/process/index.d.cts} +97 -44
- package/dist/{index-CasX6Pfq.d.cts → utils/process/index.d.ts} +97 -44
- package/dist/utils/process/index.js +14 -0
- package/dist/utils/process/index.js.map +1 -0
- package/dist/utils/reactive-layout/index.cjs +1607 -0
- package/dist/utils/reactive-layout/index.cjs.map +1 -0
- package/dist/{index-B5S8ULbU.d.ts → utils/reactive-layout/index.d.cts} +58 -81
- package/dist/{index-Dc4AYqrJ.d.cts → utils/reactive-layout/index.d.ts} +58 -81
- package/dist/utils/reactive-layout/index.js +52 -0
- package/dist/utils/reactive-layout/index.js.map +1 -0
- package/dist/utils/reduction/index.cjs +203 -0
- package/dist/utils/reduction/index.cjs.map +1 -0
- package/dist/{index-Byu-OpX_.d.ts → utils/reduction/index.d.cts} +6 -17
- package/dist/{index-tRCxuAXF.d.cts → utils/reduction/index.d.ts} +6 -17
- package/dist/utils/reduction/index.js +14 -0
- package/dist/utils/reduction/index.js.map +1 -0
- package/dist/utils/resilience/index.cjs +1617 -0
- package/dist/utils/resilience/index.cjs.map +1 -0
- package/dist/utils/resilience/index.d.cts +9 -0
- package/dist/utils/resilience/index.d.ts +9 -0
- package/dist/utils/resilience/index.js +44 -0
- package/dist/utils/resilience/index.js.map +1 -0
- package/dist/utils/surface/index.cjs +1070 -0
- package/dist/utils/surface/index.cjs.map +1 -0
- package/dist/{index-CYq8vAyV.d.ts → utils/surface/index.d.cts} +7 -58
- package/dist/{index-CSOmP7xT.d.cts → utils/surface/index.d.ts} +7 -58
- package/dist/utils/surface/index.js +30 -0
- package/dist/utils/surface/index.js.map +1 -0
- package/dist/utils/topology-view/index.cjs +620 -0
- package/dist/utils/topology-view/index.cjs.map +1 -0
- package/dist/utils/topology-view/index.d.cts +68 -0
- package/dist/utils/topology-view/index.d.ts +68 -0
- package/dist/utils/topology-view/index.js +11 -0
- package/dist/utils/topology-view/index.js.map +1 -0
- package/package.json +664 -584
- package/dist/backoff-HPZMEZNF.js +0 -1
- package/dist/chunk-2T7U5EU6.js +0 -1
- package/dist/chunk-3G5U5QNE.js +0 -5
- package/dist/chunk-4VVTGLXJ.js +0 -1
- package/dist/chunk-5M4CCMMD.js +0 -45
- package/dist/chunk-5QDBSZBV.js +0 -1
- package/dist/chunk-5XJ6B66J.js +0 -1
- package/dist/chunk-6QZNQS5B.js +0 -1
- package/dist/chunk-6X7AFUJV.js +0 -9
- package/dist/chunk-7K6PWTDQ.js +0 -1
- package/dist/chunk-7LIAPXJB.js +0 -1
- package/dist/chunk-7WPU3UHQ.js +0 -1
- package/dist/chunk-A5WCQ5NO.js +0 -1
- package/dist/chunk-APPIWSGD.js +0 -84
- package/dist/chunk-BEZWM2SY.js +0 -1
- package/dist/chunk-C72GO4IZ.js +0 -1
- package/dist/chunk-CB676TKJ.js +0 -1
- package/dist/chunk-CE6TI2TL.js +0 -1
- package/dist/chunk-CE72X3WO.js +0 -1
- package/dist/chunk-CK2E7BTU.js +0 -1
- package/dist/chunk-CLVB32RD.js +0 -1
- package/dist/chunk-CRVT7D2P.js +0 -1
- package/dist/chunk-D5RFJOZ2.js +0 -1
- package/dist/chunk-D7GPHKFH.js +0 -1
- package/dist/chunk-DHRX7JX4.js +0 -2
- package/dist/chunk-ESMPEKEV.js +0 -1
- package/dist/chunk-F672GV32.js +0 -1
- package/dist/chunk-FZMYDOWV.js +0 -1
- package/dist/chunk-GHBWHMRZ.js +0 -1
- package/dist/chunk-GLERH466.js +0 -1
- package/dist/chunk-GPW2V3RE.js +0 -1
- package/dist/chunk-HIDYF36O.js +0 -1
- package/dist/chunk-HITNVN6B.js +0 -3
- package/dist/chunk-HY4DJBA7.js +0 -5
- package/dist/chunk-KZIEYVXN.js +0 -1
- package/dist/chunk-L6NSJVJZ.js +0 -1
- package/dist/chunk-N4MQX6JU.js +0 -18
- package/dist/chunk-N7FHEL4D.js +0 -1
- package/dist/chunk-NTEURFZH.js +0 -1
- package/dist/chunk-OIVP6KFV.js +0 -1
- package/dist/chunk-OPHBU3LG.js +0 -1
- package/dist/chunk-OYQOZP2F.js +0 -5
- package/dist/chunk-PTZK576G.js +0 -1
- package/dist/chunk-QYADASLV.js +0 -1
- package/dist/chunk-ST7UXLWR.js +0 -1
- package/dist/chunk-SVY7VUYU.js +0 -1
- package/dist/chunk-TK3NWWD4.js +0 -1
- package/dist/chunk-TSOYJ743.js +0 -1
- package/dist/chunk-UNGSTR4X.js +0 -61
- package/dist/chunk-VIMF6LGM.js +0 -1
- package/dist/chunk-VJLMUKOI.js +0 -1
- package/dist/chunk-VN6RDSK2.js +0 -1
- package/dist/chunk-VV4N5P64.js +0 -1
- package/dist/chunk-W3I423PS.js +0 -1
- package/dist/chunk-WJR24TAG.js +0 -1
- package/dist/chunk-XTGKMHSW.js +0 -1
- package/dist/chunk-YBB7ZGTY.js +0 -1
- package/dist/chunk-Z4NPUARF.js +0 -1
- package/dist/chunk-ZGNQRPDT.js +0 -1
- package/dist/chunk-ZKPSFFKU.js +0 -1
- package/dist/chunk-ZLV5SQSX.js +0 -1
- package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
- package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
- package/dist/core/index.cjs +0 -1
- package/dist/core/index.d.cts +0 -3
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -1
- package/dist/decay-BvOWTZ00.d.ts +0 -112
- package/dist/decay-CFlLvXUT.d.cts +0 -112
- package/dist/extra/browser.cjs +0 -1
- package/dist/extra/browser.d.cts +0 -4
- package/dist/extra/browser.d.ts +0 -4
- package/dist/extra/browser.js +0 -1
- package/dist/extra/index.cjs +0 -20
- package/dist/extra/index.d.cts +0 -17
- package/dist/extra/index.d.ts +0 -17
- package/dist/extra/index.js +0 -1
- package/dist/extra/node.cjs +0 -2
- package/dist/extra/node.js +0 -2
- package/dist/extra/operators.cjs +0 -1
- package/dist/extra/operators.d.cts +0 -958
- package/dist/extra/operators.d.ts +0 -958
- package/dist/extra/operators.js +0 -1
- package/dist/extra/reactive.cjs +0 -1
- package/dist/extra/reactive.d.cts +0 -353
- package/dist/extra/reactive.d.ts +0 -353
- package/dist/extra/reactive.js +0 -1
- package/dist/extra/render/index.cjs +0 -5
- package/dist/extra/render/index.js +0 -1
- package/dist/extra/sources.cjs +0 -3
- package/dist/extra/sources.js +0 -1
- package/dist/extra/storage-browser.cjs +0 -1
- package/dist/extra/storage-browser.d.cts +0 -37
- package/dist/extra/storage-browser.d.ts +0 -37
- package/dist/extra/storage-browser.js +0 -1
- package/dist/extra/storage-core.cjs +0 -1
- package/dist/extra/storage-core.d.cts +0 -28
- package/dist/extra/storage-core.d.ts +0 -28
- package/dist/extra/storage-core.js +0 -1
- package/dist/extra/storage-node.cjs +0 -1
- package/dist/extra/storage-node.d.cts +0 -2
- package/dist/extra/storage-node.d.ts +0 -2
- package/dist/extra/storage-node.js +0 -0
- package/dist/extra/storage-tiers-browser.cjs +0 -1
- package/dist/extra/storage-tiers-browser.d.cts +0 -120
- package/dist/extra/storage-tiers-browser.d.ts +0 -120
- package/dist/extra/storage-tiers-browser.js +0 -1
- package/dist/extra/storage-tiers-node.cjs +0 -1
- package/dist/extra/storage-tiers-node.d.cts +0 -210
- package/dist/extra/storage-tiers-node.d.ts +0 -210
- package/dist/extra/storage-tiers-node.js +0 -1
- package/dist/extra/storage-tiers.cjs +0 -1
- package/dist/extra/storage-tiers.d.cts +0 -412
- package/dist/extra/storage-tiers.d.ts +0 -412
- package/dist/extra/storage-tiers.js +0 -1
- package/dist/graph/index.cjs +0 -7
- package/dist/graph/index.d.cts +0 -7
- package/dist/graph/index.d.ts +0 -7
- package/dist/graph/index.js +0 -1
- package/dist/graph-CWvEUQAq.d.cts +0 -1861
- package/dist/graph-D9LFnda9.d.ts +0 -1861
- package/dist/index-5k1T6jl0.d.cts +0 -121
- package/dist/index-9770hRuQ.d.cts +0 -779
- package/dist/index-B1F8Enjf.d.ts +0 -704
- package/dist/index-BHskSB8v.d.ts +0 -3413
- package/dist/index-BIYAkbAi.d.cts +0 -26
- package/dist/index-BoJ5JHxI.d.ts +0 -557
- package/dist/index-BocU7pqs.d.ts +0 -779
- package/dist/index-BxNs2HB9.d.cts +0 -1858
- package/dist/index-C1T3d7V-.d.cts +0 -704
- package/dist/index-C5ri2Axc.d.cts +0 -301
- package/dist/index-C9l6OEBL.d.ts +0 -26
- package/dist/index-CC-AvFTy.d.cts +0 -557
- package/dist/index-CJF1URuX.d.ts +0 -121
- package/dist/index-CdTelp1M.d.ts +0 -202
- package/dist/index-Cj3WohTd.d.cts +0 -202
- package/dist/index-Co7uli2l.d.cts +0 -3413
- package/dist/index-D0aciIex.d.cts +0 -209
- package/dist/index-DHen9Klo.d.ts +0 -1858
- package/dist/index-Yq60JP3s.d.ts +0 -209
- package/dist/index-nozs3fFC.d.ts +0 -301
- package/dist/node-kK3CvTrR.d.cts +0 -1347
- package/dist/node-kK3CvTrR.d.ts +0 -1347
- package/dist/patterns/ai/browser.cjs +0 -8
- package/dist/patterns/ai/browser.js +0 -3
- package/dist/patterns/ai/index.cjs +0 -74
- package/dist/patterns/ai/index.d.cts +0 -20
- package/dist/patterns/ai/index.d.ts +0 -20
- package/dist/patterns/ai/index.js +0 -1
- package/dist/patterns/ai/node.cjs +0 -1
- package/dist/patterns/ai/node.js +0 -1
- package/dist/patterns/cqrs/index.cjs +0 -3
- package/dist/patterns/cqrs/index.d.cts +0 -8
- package/dist/patterns/cqrs/index.d.ts +0 -8
- package/dist/patterns/cqrs/index.js +0 -1
- package/dist/patterns/demo-shell/index.cjs +0 -5
- package/dist/patterns/demo-shell/index.d.cts +0 -7
- package/dist/patterns/demo-shell/index.d.ts +0 -7
- package/dist/patterns/demo-shell/index.js +0 -1
- package/dist/patterns/domain-templates/index.cjs +0 -3
- package/dist/patterns/domain-templates/index.d.cts +0 -6
- package/dist/patterns/domain-templates/index.d.ts +0 -6
- package/dist/patterns/domain-templates/index.js +0 -1
- package/dist/patterns/graphspec/index.cjs +0 -86
- package/dist/patterns/graphspec/index.d.cts +0 -8
- package/dist/patterns/graphspec/index.d.ts +0 -8
- package/dist/patterns/graphspec/index.js +0 -1
- package/dist/patterns/harness/index.cjs +0 -48
- package/dist/patterns/harness/index.d.cts +0 -13
- package/dist/patterns/harness/index.d.ts +0 -13
- package/dist/patterns/harness/index.js +0 -1
- package/dist/patterns/inspect/index.cjs +0 -3
- package/dist/patterns/inspect/index.d.cts +0 -9
- package/dist/patterns/inspect/index.d.ts +0 -9
- package/dist/patterns/inspect/index.js +0 -1
- package/dist/patterns/job-queue/index.cjs +0 -3
- package/dist/patterns/job-queue/index.d.cts +0 -9
- package/dist/patterns/job-queue/index.d.ts +0 -9
- package/dist/patterns/job-queue/index.js +0 -1
- package/dist/patterns/memory/index.cjs +0 -3
- package/dist/patterns/memory/index.d.cts +0 -8
- package/dist/patterns/memory/index.d.ts +0 -8
- package/dist/patterns/memory/index.js +0 -1
- package/dist/patterns/messaging/index.cjs +0 -3
- package/dist/patterns/messaging/index.d.cts +0 -7
- package/dist/patterns/messaging/index.d.ts +0 -7
- package/dist/patterns/messaging/index.js +0 -1
- package/dist/patterns/orchestration/index.cjs +0 -3
- package/dist/patterns/orchestration/index.d.cts +0 -8
- package/dist/patterns/orchestration/index.d.ts +0 -8
- package/dist/patterns/orchestration/index.js +0 -1
- package/dist/patterns/process/index.cjs +0 -3
- package/dist/patterns/process/index.d.cts +0 -10
- package/dist/patterns/process/index.d.ts +0 -10
- package/dist/patterns/process/index.js +0 -1
- package/dist/patterns/reactive-layout/index.cjs +0 -4
- package/dist/patterns/reactive-layout/index.d.cts +0 -7
- package/dist/patterns/reactive-layout/index.d.ts +0 -7
- package/dist/patterns/reactive-layout/index.js +0 -1
- package/dist/patterns/reduction/index.cjs +0 -3
- package/dist/patterns/reduction/index.d.cts +0 -6
- package/dist/patterns/reduction/index.d.ts +0 -6
- package/dist/patterns/reduction/index.js +0 -1
- package/dist/patterns/surface/index.cjs +0 -13
- package/dist/patterns/surface/index.d.cts +0 -9
- package/dist/patterns/surface/index.d.ts +0 -9
- package/dist/patterns/surface/index.js +0 -1
- package/dist/reactive-log-BKALbfal.d.ts +0 -223
- package/dist/reactive-log-DIGdYqQ6.d.cts +0 -223
- package/dist/reactive-map-CEFGp8TK.d.cts +0 -296
- package/dist/reactive-map-DS_SIAxv.d.ts +0 -296
- package/dist/resilience-6LYQJAC5.js +0 -1
- package/dist/sugar-DQjFmVqb.d.cts +0 -399
- package/dist/sugar-fhLIE7TT.d.ts +0 -399
- package/dist/topology-tree-Bcz27hpF.d.cts +0 -25
- package/dist/topology-tree-xvaD0fOX.d.ts +0 -25
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import {
|
|
2
|
+
aiMeta,
|
|
3
|
+
chatStream,
|
|
4
|
+
toolExecution,
|
|
5
|
+
toolRegistry
|
|
6
|
+
} from "./chunk-OO5BM6CJ.js";
|
|
7
|
+
import {
|
|
8
|
+
subscription,
|
|
9
|
+
topic
|
|
10
|
+
} from "./chunk-Q3EYOCZB.js";
|
|
11
|
+
import {
|
|
12
|
+
awaitSettled
|
|
13
|
+
} from "./chunk-O3MT7DYI.js";
|
|
14
|
+
|
|
15
|
+
// src/presets/ai/agent-loop.ts
|
|
16
|
+
import {
|
|
17
|
+
batch,
|
|
18
|
+
DATA,
|
|
19
|
+
ERROR,
|
|
20
|
+
INVALIDATE,
|
|
21
|
+
node,
|
|
22
|
+
node as nodeFactory,
|
|
23
|
+
placeholderArgs,
|
|
24
|
+
RESOLVED
|
|
25
|
+
} from "@graphrefly/pure-ts/core";
|
|
26
|
+
import { fromAny, keepalive, switchMap } from "@graphrefly/pure-ts/extra";
|
|
27
|
+
import { Graph } from "@graphrefly/pure-ts/graph";
|
|
28
|
+
var AgentLoopGraph = class extends Graph {
|
|
29
|
+
chat;
|
|
30
|
+
tools;
|
|
31
|
+
/** Current agent status. `initial: "idle"` — always has a real value. */
|
|
32
|
+
status;
|
|
33
|
+
/** Turn count (completed LLM invocations this run). `initial: 0`. */
|
|
34
|
+
turn;
|
|
35
|
+
/** Aborted flag; flipped by `abort()` or external `AbortSignal`. `initial: false`. */
|
|
36
|
+
aborted;
|
|
37
|
+
/**
|
|
38
|
+
* Most recent LLM response. State-backed mirror driven by the response
|
|
39
|
+
* effect. **Stays SENTINEL** (`cache === undefined`, no DATA emitted)
|
|
40
|
+
* until the first real response — bridge subscribers see no spurious
|
|
41
|
+
* push-on-subscribe DATA. After a real response, holds the latest
|
|
42
|
+
* `LLMResponse`. Reset between `run()` calls via `[[INVALIDATE]]` (clears
|
|
43
|
+
* cache back to SENTINEL) so a second run with a pre-aborted signal
|
|
44
|
+
* cannot leak the prior run's response. Bridge with
|
|
45
|
+
* `awaitSettled(lastResponse)` for the first DATA as a Promise; consumers
|
|
46
|
+
* inside reactive fns gate on `ctx.prevData[i] === undefined`.
|
|
47
|
+
*/
|
|
48
|
+
lastResponse;
|
|
49
|
+
/** Tool-call batch emitted by the most recent LLM response. SENTINEL. */
|
|
50
|
+
toolCalls;
|
|
51
|
+
/** Tool-result batch (one entry per call) after reactive execution. SENTINEL. */
|
|
52
|
+
toolResults;
|
|
53
|
+
_terminalResult;
|
|
54
|
+
_disposeRunWiring;
|
|
55
|
+
/** Guards against overlapping `run()` calls. */
|
|
56
|
+
_running = false;
|
|
57
|
+
/**
|
|
58
|
+
* Abort controller for the currently-running `adapter.invoke`. Minted per
|
|
59
|
+
* switchMap project; aborted when the reactive `aborted` node flips true
|
|
60
|
+
* OR when the caller's external `AbortSignal` fires. Threaded into
|
|
61
|
+
* `adapter.invoke({ signal })` AND `fromAny(promise, { signal })`, so the
|
|
62
|
+
* reactive layer sees ERROR when the wire call is cancelled.
|
|
63
|
+
*/
|
|
64
|
+
_currentAbortController = null;
|
|
65
|
+
constructor(name, opts) {
|
|
66
|
+
super(name, opts.graph);
|
|
67
|
+
this.chat = chatStream(`${name}-chat`, { maxMessages: opts.maxMessages });
|
|
68
|
+
this.mount("chat", this.chat);
|
|
69
|
+
this.tools = toolRegistry(`${name}-tools`);
|
|
70
|
+
this.mount("tools", this.tools);
|
|
71
|
+
if (opts.tools) {
|
|
72
|
+
for (const tool of opts.tools) {
|
|
73
|
+
this.tools.register(tool);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.status = node([], {
|
|
77
|
+
...{
|
|
78
|
+
name: "status",
|
|
79
|
+
describeKind: "state",
|
|
80
|
+
meta: aiMeta("agent_status")
|
|
81
|
+
},
|
|
82
|
+
initial: "idle"
|
|
83
|
+
});
|
|
84
|
+
this.add(this.status, { name: "status" });
|
|
85
|
+
this.turn = node([], {
|
|
86
|
+
...{
|
|
87
|
+
name: "turn",
|
|
88
|
+
describeKind: "state",
|
|
89
|
+
meta: aiMeta("agent_turn_count")
|
|
90
|
+
},
|
|
91
|
+
initial: 0
|
|
92
|
+
});
|
|
93
|
+
this.add(this.turn, { name: "turn" });
|
|
94
|
+
this.aborted = node([], {
|
|
95
|
+
...{
|
|
96
|
+
name: "aborted",
|
|
97
|
+
describeKind: "state",
|
|
98
|
+
meta: aiMeta("agent_aborted")
|
|
99
|
+
},
|
|
100
|
+
initial: false
|
|
101
|
+
});
|
|
102
|
+
this.add(this.aborted, { name: "aborted" });
|
|
103
|
+
let latestTurn = 0;
|
|
104
|
+
const turnSub = this.turn.subscribe((msgs) => {
|
|
105
|
+
for (const m of msgs) if (m[0] === DATA) latestTurn = m[1];
|
|
106
|
+
});
|
|
107
|
+
let latestAborted = false;
|
|
108
|
+
const abortedSub = this.aborted.subscribe((msgs) => {
|
|
109
|
+
for (const m of msgs) if (m[0] === DATA) latestAborted = m[1];
|
|
110
|
+
});
|
|
111
|
+
const adapter = opts.adapter;
|
|
112
|
+
const systemPrompt = opts.systemPrompt;
|
|
113
|
+
const model = opts.model;
|
|
114
|
+
const temperature = opts.temperature;
|
|
115
|
+
const maxTokens = opts.maxTokens;
|
|
116
|
+
const maxTurns = opts.maxTurns ?? 10;
|
|
117
|
+
const stopWhen = opts.stopWhen;
|
|
118
|
+
const chat = this.chat;
|
|
119
|
+
const tools = this.tools;
|
|
120
|
+
const statusNode = this.status;
|
|
121
|
+
const turnNode = this.turn;
|
|
122
|
+
const abortedNode = this.aborted;
|
|
123
|
+
const promptInput = nodeFactory(
|
|
124
|
+
[statusNode],
|
|
125
|
+
(data, actions, ctx) => {
|
|
126
|
+
const stat = readLatest(data, ctx.prevData, 0, "idle");
|
|
127
|
+
if (stat !== "thinking" || latestAborted || latestTurn >= maxTurns) {
|
|
128
|
+
actions.down([[RESOLVED]]);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const messages = this.chat.messages.cache ?? [];
|
|
132
|
+
if (messages.length === 0) {
|
|
133
|
+
actions.down([[RESOLVED]]);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const schemas = this.tools.schemas.cache ?? [];
|
|
137
|
+
actions.emit({ messages, tools: schemas });
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "promptInput",
|
|
141
|
+
describeKind: "derived",
|
|
142
|
+
meta: aiMeta("agent_prompt_input", {
|
|
143
|
+
// State this fn body samples beyond its declared `statusNode`
|
|
144
|
+
// dep. `aborted` / `turn` come from §28 closure mirrors
|
|
145
|
+
// (`latestAborted` / `latestTurn`); `chat.messages` /
|
|
146
|
+
// `tools.schemas` come from sole-owner `.cache` reads
|
|
147
|
+
// (Phase 12 D1 lock + F2 fix; see comment block above).
|
|
148
|
+
// Listed here so inspection tooling can surface fold-in
|
|
149
|
+
// state without grepping source.
|
|
150
|
+
closureReads: ["aborted", "turn", "chat.messages", "tools.schemas"]
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
const llmResponse = switchMap(
|
|
155
|
+
promptInput,
|
|
156
|
+
(input) => {
|
|
157
|
+
const controller = new AbortController();
|
|
158
|
+
this._currentAbortController = controller;
|
|
159
|
+
if (latestAborted) {
|
|
160
|
+
controller.abort(new Error("agentLoop: aborted"));
|
|
161
|
+
}
|
|
162
|
+
return fromAny(
|
|
163
|
+
adapter.invoke(input.messages, {
|
|
164
|
+
tools: input.tools.length > 0 ? input.tools : void 0,
|
|
165
|
+
systemPrompt,
|
|
166
|
+
model,
|
|
167
|
+
temperature,
|
|
168
|
+
maxTokens,
|
|
169
|
+
signal: controller.signal
|
|
170
|
+
}),
|
|
171
|
+
{ signal: controller.signal }
|
|
172
|
+
);
|
|
173
|
+
},
|
|
174
|
+
{ equals: () => false }
|
|
175
|
+
);
|
|
176
|
+
const lastResponseState = node([], {
|
|
177
|
+
name: "lastResponse",
|
|
178
|
+
describeKind: "state",
|
|
179
|
+
meta: aiMeta("agent_last_response")
|
|
180
|
+
});
|
|
181
|
+
this.lastResponse = lastResponseState;
|
|
182
|
+
const toolCallsRaw = nodeFactory(
|
|
183
|
+
[lastResponseState, statusNode],
|
|
184
|
+
(data, actions, ctx) => {
|
|
185
|
+
const resp = readLatest(data, ctx.prevData, 0, void 0);
|
|
186
|
+
const stat = readLatest(data, ctx.prevData, 1, "idle");
|
|
187
|
+
if (stat !== "acting") {
|
|
188
|
+
actions.down([[RESOLVED]]);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const calls = resp?.toolCalls;
|
|
192
|
+
if (calls == null || calls.length === 0) {
|
|
193
|
+
actions.down([[RESOLVED]]);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
actions.emit(calls);
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "toolCallsRaw",
|
|
200
|
+
describeKind: "derived",
|
|
201
|
+
meta: aiMeta("agent_tool_calls_raw")
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
const gatedToolCallsNode = opts.interceptToolCalls ? opts.interceptToolCalls(toolCallsRaw) : toolCallsRaw;
|
|
205
|
+
this.toolCalls = gatedToolCallsNode;
|
|
206
|
+
const toolResultsNode = toolExecution({
|
|
207
|
+
toolCalls: gatedToolCallsNode,
|
|
208
|
+
tools,
|
|
209
|
+
retryCount: 1
|
|
210
|
+
});
|
|
211
|
+
this.toolResults = toolResultsNode;
|
|
212
|
+
const effResponse = node(
|
|
213
|
+
[llmResponse],
|
|
214
|
+
(batchData, _actions, ctx) => {
|
|
215
|
+
const data = batchData.map(
|
|
216
|
+
(batch3, i) => batch3 != null && batch3.length > 0 ? batch3.at(-1) : ctx.prevData[i]
|
|
217
|
+
);
|
|
218
|
+
if (latestAborted) return;
|
|
219
|
+
const response = data[0];
|
|
220
|
+
const next = latestTurn + 1;
|
|
221
|
+
const hasToolCalls = response.toolCalls != null && response.toolCalls.length > 0;
|
|
222
|
+
const naturalStop = response.finishReason === "end_turn" && (!response.toolCalls || response.toolCalls.length === 0);
|
|
223
|
+
const customStop = stopWhen?.(response) === true;
|
|
224
|
+
const capReached = next >= maxTurns;
|
|
225
|
+
const nextStatus = customStop || naturalStop || !hasToolCalls || capReached ? "done" : "acting";
|
|
226
|
+
batch(() => {
|
|
227
|
+
lastResponseState.emit(response);
|
|
228
|
+
statusNode.emit(nextStatus);
|
|
229
|
+
turnNode.emit(next);
|
|
230
|
+
chat.append("assistant", response.content, {
|
|
231
|
+
toolCalls: response.toolCalls
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
{ describeKind: "effect" }
|
|
236
|
+
);
|
|
237
|
+
const effResults = node(
|
|
238
|
+
[toolResultsNode],
|
|
239
|
+
(batchData, _actions, ctx) => {
|
|
240
|
+
const data = batchData.map(
|
|
241
|
+
(batch3, i) => batch3 != null && batch3.length > 0 ? batch3.at(-1) : ctx.prevData[i]
|
|
242
|
+
);
|
|
243
|
+
if (latestAborted) return;
|
|
244
|
+
const arr = data[0];
|
|
245
|
+
if (arr.length === 0) return;
|
|
246
|
+
const nextStatus = latestTurn >= maxTurns ? "done" : "thinking";
|
|
247
|
+
batch(() => {
|
|
248
|
+
statusNode.emit(nextStatus);
|
|
249
|
+
for (const r of arr) chat.appendToolResult(r.id, r.content);
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
{ describeKind: "effect" }
|
|
253
|
+
);
|
|
254
|
+
let latestStatus = statusNode.cache ?? "idle";
|
|
255
|
+
const statusSub = statusNode.subscribe((msgs) => {
|
|
256
|
+
for (const m of msgs) if (m[0] === DATA) latestStatus = m[1];
|
|
257
|
+
});
|
|
258
|
+
const effAbort = node(
|
|
259
|
+
[abortedNode],
|
|
260
|
+
(batchData, _actions, ctx) => {
|
|
261
|
+
const data = batchData.map(
|
|
262
|
+
(batch3, i) => batch3 != null && batch3.length > 0 ? batch3.at(-1) : ctx.prevData[i]
|
|
263
|
+
);
|
|
264
|
+
if (data[0] === true) {
|
|
265
|
+
this._currentAbortController?.abort(new Error("agentLoop: aborted"));
|
|
266
|
+
if (latestStatus !== "done") statusNode.emit("done");
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{ describeKind: "effect" }
|
|
270
|
+
);
|
|
271
|
+
const kaResponse = keepalive(effResponse);
|
|
272
|
+
const kaResults = keepalive(effResults);
|
|
273
|
+
const kaAbort = keepalive(effAbort);
|
|
274
|
+
this._terminalResult = nodeFactory(
|
|
275
|
+
[statusNode, lastResponseState],
|
|
276
|
+
(data, actions, ctx) => {
|
|
277
|
+
const stat = readLatest(data, ctx.prevData, 0, "idle");
|
|
278
|
+
const resp = readLatest(data, ctx.prevData, 1, void 0);
|
|
279
|
+
if (stat === "done") {
|
|
280
|
+
if (resp !== void 0) {
|
|
281
|
+
actions.emit(resp);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const err = new Error("agentLoop: aborted");
|
|
285
|
+
err.name = "AbortError";
|
|
286
|
+
actions.down([[ERROR, err]]);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (stat === "error") {
|
|
290
|
+
actions.down([[ERROR, new Error("agentLoop: errored")]]);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
actions.down([[RESOLVED]]);
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: "terminalResult",
|
|
297
|
+
describeKind: "derived",
|
|
298
|
+
meta: aiMeta("agent_terminal_result"),
|
|
299
|
+
// `lastResponseState` is SENTINEL until the first real response
|
|
300
|
+
// arrives — without `partial: true`, the spec §2.7 first-run
|
|
301
|
+
// gate would block this fn from ever firing on the abort-
|
|
302
|
+
// before-response path (`status → "done"` while `lastResponse`
|
|
303
|
+
// has never delivered DATA). The fn explicitly handles the
|
|
304
|
+
// SENTINEL case (`resp === undefined → ERROR(AbortError)`),
|
|
305
|
+
// so partial-fire is safe by design.
|
|
306
|
+
partial: true
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
this.add(promptInput, { name: "promptInput" });
|
|
310
|
+
this.add(llmResponse, { name: "llmResponse" });
|
|
311
|
+
this.add(this.lastResponse, { name: "lastResponse" });
|
|
312
|
+
if (this.toolCalls === toolCallsRaw) {
|
|
313
|
+
this.add(this.toolCalls, { name: "toolCalls" });
|
|
314
|
+
} else {
|
|
315
|
+
this.add(toolCallsRaw, { name: "toolCallsRaw" });
|
|
316
|
+
this.add(this.toolCalls, { name: "toolCalls" });
|
|
317
|
+
}
|
|
318
|
+
this.add(toolResultsNode, { name: "toolResults" });
|
|
319
|
+
this.add(this._terminalResult, { name: "terminalResult" });
|
|
320
|
+
this.addDisposer(turnSub);
|
|
321
|
+
this.addDisposer(abortedSub);
|
|
322
|
+
this.addDisposer(statusSub);
|
|
323
|
+
this.addDisposer(kaResponse);
|
|
324
|
+
this.addDisposer(kaResults);
|
|
325
|
+
this.addDisposer(kaAbort);
|
|
326
|
+
this._disposeRunWiring = () => {
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Bridge to `Promise<LLMResponse>` over the reactive pipeline.
|
|
331
|
+
*
|
|
332
|
+
* - If `userMessage` is provided, appends it as a user message and
|
|
333
|
+
* transitions status to `"thinking"` to kick the loop.
|
|
334
|
+
* - If `signal` is provided, binds it to the reactive `aborted` node
|
|
335
|
+
* AND threads into `adapter.invoke({ signal })` so the wire call can
|
|
336
|
+
* cancel mid-flight. The reactive `aborted` state + effect 3 guarantee
|
|
337
|
+
* that even an adapter that ignores `signal` will stop emitting into
|
|
338
|
+
* the agent graph.
|
|
339
|
+
* - Resolves when `status === "done"` with the final LLM response.
|
|
340
|
+
* Rejects with `AbortError` when the abort signal fires pre-response.
|
|
341
|
+
* Rejects with the stage error when `status === "error"`.
|
|
342
|
+
*
|
|
343
|
+
* **Concurrency:** `run()` refuses to overlap with a pending call on the
|
|
344
|
+
* same agent. Attempting to call `run()` while a previous `run()` is
|
|
345
|
+
* still in-flight throws a `RangeError` immediately. Stale-resolution
|
|
346
|
+
* safety is provided by `awaitSettled({skipCurrent: true})`, which
|
|
347
|
+
* ignores the cached initial DATA from any previous run and resolves
|
|
348
|
+
* only on a fresh post-subscribe emission of `_terminalResult`.
|
|
349
|
+
*/
|
|
350
|
+
async run(userMessage, signal) {
|
|
351
|
+
if (this._running) {
|
|
352
|
+
throw new RangeError(
|
|
353
|
+
`agentLoop "${this.name}": run() called while a previous run() is still pending \u2014 await the previous run before starting another, or call abort() first`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
this._running = true;
|
|
357
|
+
let offAbort;
|
|
358
|
+
try {
|
|
359
|
+
batch(() => {
|
|
360
|
+
this.lastResponse.down([[INVALIDATE]]);
|
|
361
|
+
this.turn.emit(0);
|
|
362
|
+
this.aborted.emit(false);
|
|
363
|
+
this.status.emit("idle");
|
|
364
|
+
});
|
|
365
|
+
if (userMessage != null) this.chat.append("user", userMessage);
|
|
366
|
+
const resultPromise = awaitSettled(this._terminalResult, { skipCurrent: true });
|
|
367
|
+
if (signal != null) {
|
|
368
|
+
if (signal.aborted) {
|
|
369
|
+
this.aborted.emit(true);
|
|
370
|
+
} else {
|
|
371
|
+
const listener = () => this.aborted.emit(true);
|
|
372
|
+
signal.addEventListener("abort", listener, { once: true });
|
|
373
|
+
offAbort = () => signal.removeEventListener("abort", listener);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (signal?.aborted !== true) {
|
|
377
|
+
this.status.emit("thinking");
|
|
378
|
+
}
|
|
379
|
+
return await resultPromise;
|
|
380
|
+
} finally {
|
|
381
|
+
offAbort?.();
|
|
382
|
+
this._running = false;
|
|
383
|
+
this._currentAbortController = null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Flip the reactive `aborted` state. Equivalent to setting an external
|
|
388
|
+
* `AbortSignal` — the pipeline observes and transitions to `"done"`.
|
|
389
|
+
*/
|
|
390
|
+
abort() {
|
|
391
|
+
this.aborted.emit(true);
|
|
392
|
+
}
|
|
393
|
+
destroy() {
|
|
394
|
+
try {
|
|
395
|
+
this._disposeRunWiring();
|
|
396
|
+
} catch {
|
|
397
|
+
}
|
|
398
|
+
super.destroy();
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
function readLatest(batchData, prevData, index, fallback) {
|
|
402
|
+
const batch3 = batchData[index];
|
|
403
|
+
if (batch3 != null && batch3.length > 0) return batch3[batch3.length - 1];
|
|
404
|
+
const prev = prevData[index];
|
|
405
|
+
return prev !== void 0 ? prev : fallback;
|
|
406
|
+
}
|
|
407
|
+
function agentLoop(name, opts) {
|
|
408
|
+
const g = new AgentLoopGraph(name, opts);
|
|
409
|
+
g.tagFactory("agentLoop", placeholderArgs(opts));
|
|
410
|
+
return g;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// src/presets/ai/agent.ts
|
|
414
|
+
import { batch as batch2, DATA as DATA2, INVALIDATE as INVALIDATE2, node as node2, RESOLVED as RESOLVED2 } from "@graphrefly/pure-ts/core";
|
|
415
|
+
import { keepalive as keepalive2 } from "@graphrefly/pure-ts/extra";
|
|
416
|
+
import { Graph as Graph2 } from "@graphrefly/pure-ts/graph";
|
|
417
|
+
var EMPTY_INPUT = Object.freeze({ regular: 0 });
|
|
418
|
+
var EMPTY_OUTPUT = Object.freeze({ regular: 0 });
|
|
419
|
+
var EMPTY_USAGE = Object.freeze({ input: EMPTY_INPUT, output: EMPTY_OUTPUT });
|
|
420
|
+
var ZERO_COST = Object.freeze({ usage: EMPTY_USAGE, turns: 0 });
|
|
421
|
+
function addOptional(a, b) {
|
|
422
|
+
if (a == null && b == null) return void 0;
|
|
423
|
+
return (a ?? 0) + (b ?? 0);
|
|
424
|
+
}
|
|
425
|
+
function addExtensions(a, b) {
|
|
426
|
+
if (a == null && b == null) return void 0;
|
|
427
|
+
const out = { ...a ?? {} };
|
|
428
|
+
for (const [k, v] of Object.entries(b ?? {})) {
|
|
429
|
+
out[k] = (out[k] ?? 0) + v;
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
function addUsage(a, b) {
|
|
434
|
+
const out = {
|
|
435
|
+
input: {
|
|
436
|
+
regular: a.input.regular + b.input.regular,
|
|
437
|
+
...addOptional(a.input.cacheRead, b.input.cacheRead) !== void 0 && {
|
|
438
|
+
cacheRead: addOptional(a.input.cacheRead, b.input.cacheRead)
|
|
439
|
+
},
|
|
440
|
+
...addOptional(a.input.cacheWrite5m, b.input.cacheWrite5m) !== void 0 && {
|
|
441
|
+
cacheWrite5m: addOptional(a.input.cacheWrite5m, b.input.cacheWrite5m)
|
|
442
|
+
},
|
|
443
|
+
...addOptional(a.input.cacheWrite1h, b.input.cacheWrite1h) !== void 0 && {
|
|
444
|
+
cacheWrite1h: addOptional(a.input.cacheWrite1h, b.input.cacheWrite1h)
|
|
445
|
+
},
|
|
446
|
+
...addOptional(a.input.cacheWriteOther, b.input.cacheWriteOther) !== void 0 && {
|
|
447
|
+
cacheWriteOther: addOptional(a.input.cacheWriteOther, b.input.cacheWriteOther)
|
|
448
|
+
},
|
|
449
|
+
...addOptional(a.input.audio, b.input.audio) !== void 0 && {
|
|
450
|
+
audio: addOptional(a.input.audio, b.input.audio)
|
|
451
|
+
},
|
|
452
|
+
...addOptional(a.input.image, b.input.image) !== void 0 && {
|
|
453
|
+
image: addOptional(a.input.image, b.input.image)
|
|
454
|
+
},
|
|
455
|
+
...addOptional(a.input.video, b.input.video) !== void 0 && {
|
|
456
|
+
video: addOptional(a.input.video, b.input.video)
|
|
457
|
+
},
|
|
458
|
+
...addOptional(a.input.toolUse, b.input.toolUse) !== void 0 && {
|
|
459
|
+
toolUse: addOptional(a.input.toolUse, b.input.toolUse)
|
|
460
|
+
},
|
|
461
|
+
...addExtensions(a.input.extensions, b.input.extensions) !== void 0 && {
|
|
462
|
+
extensions: addExtensions(a.input.extensions, b.input.extensions)
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
output: {
|
|
466
|
+
regular: a.output.regular + b.output.regular,
|
|
467
|
+
...addOptional(a.output.reasoning, b.output.reasoning) !== void 0 && {
|
|
468
|
+
reasoning: addOptional(a.output.reasoning, b.output.reasoning)
|
|
469
|
+
},
|
|
470
|
+
...addOptional(a.output.audio, b.output.audio) !== void 0 && {
|
|
471
|
+
audio: addOptional(a.output.audio, b.output.audio)
|
|
472
|
+
},
|
|
473
|
+
...addOptional(a.output.predictionAccepted, b.output.predictionAccepted) !== void 0 && {
|
|
474
|
+
predictionAccepted: addOptional(
|
|
475
|
+
a.output.predictionAccepted,
|
|
476
|
+
b.output.predictionAccepted
|
|
477
|
+
)
|
|
478
|
+
},
|
|
479
|
+
...addOptional(a.output.predictionRejected, b.output.predictionRejected) !== void 0 && {
|
|
480
|
+
predictionRejected: addOptional(
|
|
481
|
+
a.output.predictionRejected,
|
|
482
|
+
b.output.predictionRejected
|
|
483
|
+
)
|
|
484
|
+
},
|
|
485
|
+
...addExtensions(a.output.extensions, b.output.extensions) !== void 0 && {
|
|
486
|
+
extensions: addExtensions(a.output.extensions, b.output.extensions)
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
...addExtensions(a.auxiliary, b.auxiliary) !== void 0 && {
|
|
490
|
+
auxiliary: addExtensions(a.auxiliary, b.auxiliary)
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
495
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["done", "error"]);
|
|
496
|
+
var AgentGraph = class extends Graph2 {
|
|
497
|
+
/** The agent's typed inbox. Writable; `in.emit(value)` kicks the loop. */
|
|
498
|
+
in;
|
|
499
|
+
/** The agent's typed outbox. SENTINEL until first response. */
|
|
500
|
+
out;
|
|
501
|
+
/** Lifecycle status (translated from the underlying loop's substates). */
|
|
502
|
+
status;
|
|
503
|
+
/** Cumulative cost for the current / most-recent input. */
|
|
504
|
+
cost;
|
|
505
|
+
/** The underlying agentLoop — exposed for inspection / advanced wiring. */
|
|
506
|
+
loop;
|
|
507
|
+
/** Optional shared memory subgraph (mounted at `memory/` if provided). */
|
|
508
|
+
memory;
|
|
509
|
+
constructor(spec, opts) {
|
|
510
|
+
super(spec.name, opts);
|
|
511
|
+
const initialTools = Array.isArray(spec.tools) ? spec.tools : void 0;
|
|
512
|
+
this.loop = agentLoop(`${spec.name}-loop`, {
|
|
513
|
+
adapter: spec.adapter,
|
|
514
|
+
...spec.systemPrompt != null ? { systemPrompt: spec.systemPrompt } : {},
|
|
515
|
+
...initialTools != null ? { tools: initialTools } : {},
|
|
516
|
+
...spec.maxIterations != null ? { maxTurns: spec.maxIterations } : {}
|
|
517
|
+
});
|
|
518
|
+
this.mount("loop", this.loop);
|
|
519
|
+
if (spec.tools != null && !Array.isArray(spec.tools)) {
|
|
520
|
+
const toolsNode = spec.tools;
|
|
521
|
+
const registered = /* @__PURE__ */ new Set();
|
|
522
|
+
const unsubTools = toolsNode.subscribe((msgs) => {
|
|
523
|
+
for (const m of msgs) {
|
|
524
|
+
if (m[0] !== DATA2) continue;
|
|
525
|
+
const next = m[1];
|
|
526
|
+
const nextNames = new Set(next.map((t) => t.name));
|
|
527
|
+
for (const name of registered) {
|
|
528
|
+
if (!nextNames.has(name)) {
|
|
529
|
+
this.loop.tools.unregister(name);
|
|
530
|
+
registered.delete(name);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
for (const tool of next) {
|
|
534
|
+
if (!registered.has(tool.name)) {
|
|
535
|
+
this.loop.tools.register(tool);
|
|
536
|
+
registered.add(tool.name);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
this.addDisposer(unsubTools);
|
|
542
|
+
}
|
|
543
|
+
this.memory = spec.memory ?? null;
|
|
544
|
+
if (this.memory != null) {
|
|
545
|
+
this.mount("memory", this.memory);
|
|
546
|
+
}
|
|
547
|
+
this.in = node2([], {
|
|
548
|
+
name: "in",
|
|
549
|
+
describeKind: "state",
|
|
550
|
+
meta: aiMeta("agent_in"),
|
|
551
|
+
equals: () => false
|
|
552
|
+
});
|
|
553
|
+
this.add(this.in, { name: "in" });
|
|
554
|
+
const costNode = node2([], {
|
|
555
|
+
name: "cost",
|
|
556
|
+
describeKind: "state",
|
|
557
|
+
meta: aiMeta("agent_cost"),
|
|
558
|
+
initial: ZERO_COST
|
|
559
|
+
});
|
|
560
|
+
this.add(costNode, { name: "cost" });
|
|
561
|
+
this.cost = costNode;
|
|
562
|
+
const outMapper = spec.outMapper ?? defaultOutMapper();
|
|
563
|
+
const outNode = node2(
|
|
564
|
+
[this.loop.lastResponse],
|
|
565
|
+
(data, a, ctx) => {
|
|
566
|
+
const batch0 = data[0];
|
|
567
|
+
const resp = batch0 != null && batch0.length > 0 ? batch0.at(-1) : ctx.prevData[0];
|
|
568
|
+
if (resp === void 0) {
|
|
569
|
+
a.down([[RESOLVED2]]);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
a.emit(outMapper(resp));
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
name: "out",
|
|
576
|
+
describeKind: "derived",
|
|
577
|
+
meta: aiMeta("agent_out"),
|
|
578
|
+
// Each in.emit may produce a structurally-equal response (e.g.
|
|
579
|
+
// from a deterministic adapter) — disable framework dedup so
|
|
580
|
+
// repeat emits propagate and `awaitSettled({skipCurrent:true})`
|
|
581
|
+
// sees them. Callers can wrap with `distinctUntilChanged` if
|
|
582
|
+
// they want change-only semantics.
|
|
583
|
+
equals: () => false
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
this.add(outNode, { name: "out" });
|
|
587
|
+
this.out = outNode;
|
|
588
|
+
const statusNode = node2([], {
|
|
589
|
+
name: "status",
|
|
590
|
+
describeKind: "state",
|
|
591
|
+
meta: aiMeta("agent_status"),
|
|
592
|
+
initial: "idle"
|
|
593
|
+
});
|
|
594
|
+
this.add(statusNode, { name: "status" });
|
|
595
|
+
this.status = statusNode;
|
|
596
|
+
const statusMirrorEff = node2(
|
|
597
|
+
[this.loop.status],
|
|
598
|
+
(data, _a, ctx) => {
|
|
599
|
+
const batch0 = data[0];
|
|
600
|
+
const loopStatus = batch0 != null && batch0.length > 0 ? batch0.at(-1) : ctx.prevData[0] ?? "idle";
|
|
601
|
+
const next = loopStatus === "idle" ? "idle" : loopStatus === "thinking" || loopStatus === "acting" ? "running" : loopStatus === "done" ? "done" : loopStatus === "error" ? "error" : "idle";
|
|
602
|
+
if (statusNode.cache !== next) statusNode.emit(next);
|
|
603
|
+
},
|
|
604
|
+
{ describeKind: "effect", meta: aiMeta("agent_status_mirror") }
|
|
605
|
+
);
|
|
606
|
+
this.addDisposer(keepalive2(statusMirrorEff));
|
|
607
|
+
const costEff = node2(
|
|
608
|
+
[this.loop.lastResponse],
|
|
609
|
+
(data, _a, ctx) => {
|
|
610
|
+
const batch0 = data[0];
|
|
611
|
+
const resp = batch0 != null && batch0.length > 0 ? batch0.at(-1) : ctx.prevData[0];
|
|
612
|
+
if (resp === void 0) return;
|
|
613
|
+
const prev = costNode.cache ?? ZERO_COST;
|
|
614
|
+
const turns = this.loop.turn.cache ?? prev.turns;
|
|
615
|
+
const next = {
|
|
616
|
+
usage: resp.usage != null ? addUsage(prev.usage, resp.usage) : prev.usage,
|
|
617
|
+
turns
|
|
618
|
+
};
|
|
619
|
+
costNode.emit(next);
|
|
620
|
+
},
|
|
621
|
+
{ describeKind: "effect", meta: aiMeta("agent_cost_rollup") }
|
|
622
|
+
);
|
|
623
|
+
this.addDisposer(keepalive2(costEff));
|
|
624
|
+
const inMapper = spec.inMapper ?? defaultInMapper();
|
|
625
|
+
const inputTopic = topic("input-topic");
|
|
626
|
+
this.mount("input-topic", inputTopic);
|
|
627
|
+
const inputSub = subscription("input-sub", inputTopic, {
|
|
628
|
+
from: "now"
|
|
629
|
+
});
|
|
630
|
+
this.mount("input-sub", inputSub);
|
|
631
|
+
const inputBridge = this.in.subscribe((msgs) => {
|
|
632
|
+
for (const m of msgs) {
|
|
633
|
+
if (m[0] !== DATA2) continue;
|
|
634
|
+
const input = m[1];
|
|
635
|
+
inMapper(input);
|
|
636
|
+
inputTopic.publish(input);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
this.addDisposer(inputBridge);
|
|
640
|
+
const drainEffect = node2(
|
|
641
|
+
[inputSub.available, this.loop.status],
|
|
642
|
+
(data, _a, ctx) => {
|
|
643
|
+
const availBatch = data[0];
|
|
644
|
+
const statusBatch = data[1];
|
|
645
|
+
const avail = (availBatch != null && availBatch.length > 0 ? availBatch.at(-1) : ctx.prevData[0] ?? []) ?? [];
|
|
646
|
+
const stat = (statusBatch != null && statusBatch.length > 0 ? statusBatch.at(-1) : ctx.prevData[1] ?? "idle") ?? "idle";
|
|
647
|
+
if (avail.length === 0) return;
|
|
648
|
+
if (stat === "thinking" || stat === "acting") return;
|
|
649
|
+
const result = inputSub.pullAndAck(1);
|
|
650
|
+
if (result.items.length === 0) return;
|
|
651
|
+
const input = result.items[0];
|
|
652
|
+
const userMsg = inMapper(input);
|
|
653
|
+
batch2(() => {
|
|
654
|
+
this.loop.lastResponse.down([[INVALIDATE2]]);
|
|
655
|
+
this.loop.turn.emit(0);
|
|
656
|
+
this.loop.aborted.emit(false);
|
|
657
|
+
costNode.emit(ZERO_COST);
|
|
658
|
+
this.loop.chat.append("user", userMsg);
|
|
659
|
+
this.loop.status.emit("thinking");
|
|
660
|
+
});
|
|
661
|
+
},
|
|
662
|
+
{ describeKind: "effect", meta: aiMeta("agent_input_drain") }
|
|
663
|
+
);
|
|
664
|
+
this.addDisposer(keepalive2(drainEffect));
|
|
665
|
+
this.addDisposer(keepalive2(this.out));
|
|
666
|
+
void TERMINAL_STATUSES;
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
function defaultInMapper() {
|
|
670
|
+
return (input) => {
|
|
671
|
+
if (typeof input !== "string") {
|
|
672
|
+
throw new TypeError(
|
|
673
|
+
`agent: inMapper is required when TIn is not a string (got ${typeof input}). Pass spec.inMapper.`
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
return input;
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function defaultOutMapper() {
|
|
680
|
+
return (response) => response;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// src/presets/ai/agents.ts
|
|
684
|
+
import { reactiveMap } from "@graphrefly/pure-ts/extra";
|
|
685
|
+
function agent(parent, spec) {
|
|
686
|
+
const graph = new AgentGraph(spec);
|
|
687
|
+
parent.mount(spec.name, graph);
|
|
688
|
+
return {
|
|
689
|
+
in: graph.in,
|
|
690
|
+
out: graph.out,
|
|
691
|
+
status: graph.status,
|
|
692
|
+
cost: graph.cost,
|
|
693
|
+
graph
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function presetRegistry(initial) {
|
|
697
|
+
const registry = reactiveMap({ name: "presetRegistry" });
|
|
698
|
+
if (initial != null) {
|
|
699
|
+
for (const [id, preset] of initial) {
|
|
700
|
+
registry.set(id, preset);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return {
|
|
704
|
+
registry,
|
|
705
|
+
put(id, preset) {
|
|
706
|
+
registry.set(id, preset);
|
|
707
|
+
},
|
|
708
|
+
remove(id) {
|
|
709
|
+
if (!registry.has(id)) return false;
|
|
710
|
+
registry.delete(id);
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export {
|
|
717
|
+
AgentLoopGraph,
|
|
718
|
+
agentLoop,
|
|
719
|
+
ZERO_COST,
|
|
720
|
+
addUsage,
|
|
721
|
+
AgentGraph,
|
|
722
|
+
agent,
|
|
723
|
+
presetRegistry
|
|
724
|
+
};
|
|
725
|
+
//# sourceMappingURL=chunk-5THCXDWY.js.map
|