@anvia/core 1.1.2 → 1.2.1
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 +226 -0
- package/dist/agent/agent-stream.js +7 -0
- package/dist/agent/agent-stream.js.map +1 -0
- package/dist/agent/agent-tool.js +24 -0
- package/dist/agent/agent-tool.js.map +1 -0
- package/dist/agent/agent.js +89 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/errors.js +17 -0
- package/dist/agent/errors.js.map +1 -0
- package/dist/agent/ids.js +7 -0
- package/dist/agent/ids.js.map +1 -0
- package/dist/agent/index.d.ts +127 -9
- package/dist/agent/index.js +103 -21
- package/dist/agent/interactions/index.js +2 -2
- package/dist/agent/interactions.js +22 -0
- package/dist/agent/interactions.js.map +1 -0
- package/dist/agent/lifecycle.js +9 -0
- package/dist/agent/lifecycle.js.map +1 -0
- package/dist/agent/output-schema.js +10 -0
- package/dist/agent/output-schema.js.map +1 -0
- package/dist/agent/resolve-options.js +46 -0
- package/dist/agent/resolve-options.js.map +1 -0
- package/dist/agent/resolved-agent.js +92 -0
- package/dist/agent/resolved-agent.js.map +1 -0
- package/dist/agent/run-types.js +1 -0
- package/dist/agent/run-types.js.map +1 -0
- package/dist/agent/snapshot.js +17 -0
- package/dist/agent/snapshot.js.map +1 -0
- package/dist/agent/team/agent-team.js +98 -0
- package/dist/agent/team/agent-team.js.map +1 -0
- package/dist/agent/team/errors.js +9 -0
- package/dist/agent/team/errors.js.map +1 -0
- package/dist/agent/team/index.js +104 -0
- package/dist/agent/team/index.js.map +1 -0
- package/dist/agent/team/types.js +1 -0
- package/dist/agent/team/types.js.map +1 -0
- package/dist/agent/tool-catalog.js +37 -0
- package/dist/agent/tool-catalog.js.map +1 -0
- package/dist/agent/tool-state.js +11 -0
- package/dist/agent/tool-state.js.map +1 -0
- package/dist/agent/types.js +1 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent/vector-context.js +10 -0
- package/dist/agent/vector-context.js.map +1 -0
- package/dist/{agent-DTmzs1Qr.d.ts → agent-C9VhENdj.d.ts} +2 -3
- package/dist/{chunk-I3Q7XSBB.js → chunk-23LRXKQX.js} +6 -4
- package/dist/{chunk-I3Q7XSBB.js.map → chunk-23LRXKQX.js.map} +1 -1
- package/dist/{chunk-YK4WAAS4.js → chunk-2NLINXRF.js} +1 -1
- package/dist/{chunk-SPD4XVR7.js → chunk-2XSMGVBG.js} +1 -1
- package/dist/chunk-3J2CSVPR.js +1 -0
- package/dist/chunk-3J2CSVPR.js.map +1 -0
- package/dist/chunk-3P3YVJ7V.js +1 -0
- package/dist/chunk-3P3YVJ7V.js.map +1 -0
- package/dist/chunk-3TAQXJBC.js +107 -0
- package/dist/chunk-3TAQXJBC.js.map +1 -0
- package/dist/chunk-47NTHIVB.js +76 -0
- package/dist/chunk-47NTHIVB.js.map +1 -0
- package/dist/chunk-4AW2633B.js +9 -0
- package/dist/chunk-4AW2633B.js.map +1 -0
- package/dist/{chunk-3XQGVDU5.js → chunk-4C7AXYOM.js} +1 -1
- package/dist/{chunk-IZNOP6JG.js → chunk-4FIVU53H.js} +1 -1
- package/dist/chunk-4ITAV7YA.js +1 -0
- package/dist/chunk-4ITAV7YA.js.map +1 -0
- package/dist/{chunk-7JLAIN6E.js → chunk-4ONUNWGC.js} +2 -2
- package/dist/chunk-4S4OECPW.js +158 -0
- package/dist/chunk-4S4OECPW.js.map +1 -0
- package/dist/chunk-4UUIGAIX.js +1 -0
- package/dist/chunk-4UUIGAIX.js.map +1 -0
- package/dist/chunk-53TPAXYR.js +1 -0
- package/dist/chunk-53TPAXYR.js.map +1 -0
- package/dist/chunk-54ZZJRP2.js +57 -0
- package/dist/chunk-54ZZJRP2.js.map +1 -0
- package/dist/chunk-5FCZ64HM.js +112 -0
- package/dist/chunk-5FCZ64HM.js.map +1 -0
- package/dist/chunk-5I2NVRHC.js +146 -0
- package/dist/chunk-5I2NVRHC.js.map +1 -0
- package/dist/chunk-5IURMWFN.js +53 -0
- package/dist/chunk-5IURMWFN.js.map +1 -0
- package/dist/chunk-5M6GTA3T.js +1 -0
- package/dist/chunk-5M6GTA3T.js.map +1 -0
- package/dist/chunk-5N5W7CX7.js +18 -0
- package/dist/chunk-5N5W7CX7.js.map +1 -0
- package/dist/chunk-5S7T2URX.js +1 -0
- package/dist/chunk-5S7T2URX.js.map +1 -0
- package/dist/chunk-5V533R7F.js +19 -0
- package/dist/chunk-5V533R7F.js.map +1 -0
- package/dist/chunk-5WLIHNNJ.js +56 -0
- package/dist/chunk-5WLIHNNJ.js.map +1 -0
- package/dist/chunk-6BTJC3ES.js +37 -0
- package/dist/chunk-6BTJC3ES.js.map +1 -0
- package/dist/chunk-6N4ENZO4.js +24 -0
- package/dist/chunk-6N4ENZO4.js.map +1 -0
- package/dist/{chunk-4UQALF5Y.js → chunk-6RQYWZI3.js} +2 -36
- package/dist/chunk-6RQYWZI3.js.map +1 -0
- package/dist/chunk-6TAWRKFK.js +86 -0
- package/dist/chunk-6TAWRKFK.js.map +1 -0
- package/dist/chunk-72LBHKYP.js +236 -0
- package/dist/chunk-72LBHKYP.js.map +1 -0
- package/dist/chunk-7F53DOML.js +53 -0
- package/dist/chunk-7F53DOML.js.map +1 -0
- package/dist/chunk-7LBPRXZP.js +1 -0
- package/dist/chunk-7LBPRXZP.js.map +1 -0
- package/dist/chunk-A7BXVZXZ.js +25 -0
- package/dist/chunk-A7BXVZXZ.js.map +1 -0
- package/dist/chunk-AOG6KSV4.js +107 -0
- package/dist/chunk-AOG6KSV4.js.map +1 -0
- package/dist/chunk-B47EXUHL.js +67 -0
- package/dist/chunk-B47EXUHL.js.map +1 -0
- package/dist/chunk-B5JQDR33.js +14 -0
- package/dist/chunk-B5JQDR33.js.map +1 -0
- package/dist/chunk-BDDC72GF.js +189 -0
- package/dist/chunk-BDDC72GF.js.map +1 -0
- package/dist/chunk-BDKFFFVX.js +342 -0
- package/dist/chunk-BDKFFFVX.js.map +1 -0
- package/dist/{chunk-QGX73TSQ.js → chunk-BONQTXRQ.js} +3 -12
- package/dist/chunk-BONQTXRQ.js.map +1 -0
- package/dist/chunk-BUPC72Y2.js +1007 -0
- package/dist/chunk-BUPC72Y2.js.map +1 -0
- package/dist/chunk-CKKNO4XB.js +70 -0
- package/dist/chunk-CKKNO4XB.js.map +1 -0
- package/dist/chunk-CX7ZVTO5.js +22 -0
- package/dist/chunk-CX7ZVTO5.js.map +1 -0
- package/dist/chunk-DU4WA6LQ.js +1 -0
- package/dist/chunk-DU4WA6LQ.js.map +1 -0
- package/dist/chunk-EJR6VVB3.js +63 -0
- package/dist/chunk-EJR6VVB3.js.map +1 -0
- package/dist/chunk-EKZRAWBP.js +110 -0
- package/dist/chunk-EKZRAWBP.js.map +1 -0
- package/dist/chunk-ENZ2XX27.js +26 -0
- package/dist/chunk-ENZ2XX27.js.map +1 -0
- package/dist/chunk-EOAJBBII.js +1 -0
- package/dist/chunk-EOAJBBII.js.map +1 -0
- package/dist/chunk-ERN7P6Q4.js +1 -0
- package/dist/chunk-ERN7P6Q4.js.map +1 -0
- package/dist/chunk-ESOFEAYK.js +57 -0
- package/dist/chunk-ESOFEAYK.js.map +1 -0
- package/dist/chunk-ETYB5JO6.js +175 -0
- package/dist/chunk-ETYB5JO6.js.map +1 -0
- package/dist/chunk-EZR5AV3J.js +74 -0
- package/dist/chunk-EZR5AV3J.js.map +1 -0
- package/dist/chunk-F2OKLHGB.js +9 -0
- package/dist/chunk-F2OKLHGB.js.map +1 -0
- package/dist/chunk-F3E2RLC7.js +342 -0
- package/dist/chunk-F3E2RLC7.js.map +1 -0
- package/dist/chunk-FAPIZJS2.js +54 -0
- package/dist/chunk-FAPIZJS2.js.map +1 -0
- package/dist/{chunk-2QZJTG2E.js → chunk-G336L2IE.js} +11 -71
- package/dist/chunk-G336L2IE.js.map +1 -0
- package/dist/chunk-GDJNOZ47.js +1 -0
- package/dist/chunk-GDJNOZ47.js.map +1 -0
- package/dist/chunk-GDY2Z2SZ.js +83 -0
- package/dist/chunk-GDY2Z2SZ.js.map +1 -0
- package/dist/chunk-GLMYZ6OA.js +20 -0
- package/dist/chunk-GLMYZ6OA.js.map +1 -0
- package/dist/{chunk-XEVOC433.js → chunk-GPVXCY5I.js} +2 -73
- package/dist/chunk-GPVXCY5I.js.map +1 -0
- package/dist/{chunk-KSKST3KP.js → chunk-H3H74RWJ.js} +1 -1
- package/dist/chunk-HAAGSIZH.js +89 -0
- package/dist/chunk-HAAGSIZH.js.map +1 -0
- package/dist/{chunk-K5L7R7XM.js → chunk-HHMLE3TZ.js} +6 -54
- package/dist/chunk-HHMLE3TZ.js.map +1 -0
- package/dist/{chunk-JLJMVRRE.js → chunk-HP34GRQX.js} +10 -83
- package/dist/chunk-HP34GRQX.js.map +1 -0
- package/dist/chunk-HTI343NP.js +1 -0
- package/dist/chunk-HTI343NP.js.map +1 -0
- package/dist/{chunk-T2C3CGDQ.js → chunk-HTI7DZJM.js} +6 -4
- package/dist/{chunk-T2C3CGDQ.js.map → chunk-HTI7DZJM.js.map} +1 -1
- package/dist/chunk-IDNL6IH4.js +294 -0
- package/dist/chunk-IDNL6IH4.js.map +1 -0
- package/dist/chunk-IV6YQTY2.js +47 -0
- package/dist/chunk-IV6YQTY2.js.map +1 -0
- package/dist/chunk-J4SINPUA.js +939 -0
- package/dist/chunk-J4SINPUA.js.map +1 -0
- package/dist/chunk-J6S6MT7O.js +32 -0
- package/dist/chunk-J6S6MT7O.js.map +1 -0
- package/dist/chunk-JBQNCUXA.js +34 -0
- package/dist/chunk-JBQNCUXA.js.map +1 -0
- package/dist/chunk-JMJFK3A4.js +1 -0
- package/dist/chunk-JMJFK3A4.js.map +1 -0
- package/dist/chunk-JMMZICU7.js +74 -0
- package/dist/chunk-JMMZICU7.js.map +1 -0
- package/dist/chunk-K4IBS7VB.js +55 -0
- package/dist/chunk-K4IBS7VB.js.map +1 -0
- package/dist/chunk-KBBQSP4M.js +16 -0
- package/dist/chunk-KBBQSP4M.js.map +1 -0
- package/dist/chunk-KFAVEL5F.js +68 -0
- package/dist/chunk-KFAVEL5F.js.map +1 -0
- package/dist/chunk-KITX3HDN.js +17 -0
- package/dist/chunk-KITX3HDN.js.map +1 -0
- package/dist/chunk-KO5NMTAM.js +1 -0
- package/dist/chunk-KO5NMTAM.js.map +1 -0
- package/dist/chunk-KY4VXIN2.js +118 -0
- package/dist/chunk-KY4VXIN2.js.map +1 -0
- package/dist/chunk-KZGSXJKU.js +29 -0
- package/dist/chunk-KZGSXJKU.js.map +1 -0
- package/dist/chunk-LAIATEUB.js +24 -0
- package/dist/chunk-LAIATEUB.js.map +1 -0
- package/dist/{chunk-OJBFDBLG.js → chunk-LBYJPMHC.js} +2 -2
- package/dist/chunk-LKIABZNR.js +49 -0
- package/dist/chunk-LKIABZNR.js.map +1 -0
- package/dist/chunk-LQJ4KHMY.js +23 -0
- package/dist/chunk-LQJ4KHMY.js.map +1 -0
- package/dist/chunk-MEN4AFDZ.js +1 -0
- package/dist/chunk-MEN4AFDZ.js.map +1 -0
- package/dist/chunk-MHOJJYDK.js +93 -0
- package/dist/chunk-MHOJJYDK.js.map +1 -0
- package/dist/chunk-MJCMKZFP.js +30 -0
- package/dist/chunk-MJCMKZFP.js.map +1 -0
- package/dist/chunk-MNYMLWWA.js +168 -0
- package/dist/chunk-MNYMLWWA.js.map +1 -0
- package/dist/chunk-MT3BLVYN.js +31 -0
- package/dist/chunk-MT3BLVYN.js.map +1 -0
- package/dist/chunk-NF6WBPFG.js +37 -0
- package/dist/chunk-NF6WBPFG.js.map +1 -0
- package/dist/chunk-NNEKBZSM.js +66 -0
- package/dist/chunk-NNEKBZSM.js.map +1 -0
- package/dist/chunk-NPJ2T3L5.js +19 -0
- package/dist/chunk-NPJ2T3L5.js.map +1 -0
- package/dist/chunk-NVALGVQG.js +150 -0
- package/dist/chunk-NVALGVQG.js.map +1 -0
- package/dist/chunk-O6DTOCBM.js +355 -0
- package/dist/chunk-O6DTOCBM.js.map +1 -0
- package/dist/chunk-OJF67RNM.js +1 -0
- package/dist/chunk-OJF67RNM.js.map +1 -0
- package/dist/chunk-PHLGGRHC.js +89 -0
- package/dist/chunk-PHLGGRHC.js.map +1 -0
- package/dist/chunk-PIMD4DYG.js +104 -0
- package/dist/chunk-PIMD4DYG.js.map +1 -0
- package/dist/chunk-PJNE75WC.js +1 -0
- package/dist/chunk-PJNE75WC.js.map +1 -0
- package/dist/{chunk-J6LVLV6P.js → chunk-PLDJCCVL.js} +1 -1
- package/dist/{chunk-3RWESPUG.js → chunk-POXHJF3H.js} +6 -51
- package/dist/chunk-POXHJF3H.js.map +1 -0
- package/dist/chunk-PPJ7SYQL.js +81 -0
- package/dist/chunk-PPJ7SYQL.js.map +1 -0
- package/dist/chunk-QHGYCYV6.js +91 -0
- package/dist/chunk-QHGYCYV6.js.map +1 -0
- package/dist/chunk-QUS6S2NB.js +663 -0
- package/dist/chunk-QUS6S2NB.js.map +1 -0
- package/dist/chunk-R6722CIU.js +28 -0
- package/dist/chunk-R6722CIU.js.map +1 -0
- package/dist/chunk-RA4YVN43.js +1 -0
- package/dist/chunk-RA4YVN43.js.map +1 -0
- package/dist/chunk-RT5LUEO3.js +2339 -0
- package/dist/chunk-RT5LUEO3.js.map +1 -0
- package/dist/chunk-SC4SUIEY.js +1 -0
- package/dist/chunk-SC4SUIEY.js.map +1 -0
- package/dist/chunk-SIYZDPVH.js +613 -0
- package/dist/chunk-SIYZDPVH.js.map +1 -0
- package/dist/chunk-SQAAVYJG.js +12 -0
- package/dist/chunk-SQAAVYJG.js.map +1 -0
- package/dist/chunk-SXE4J43E.js +59 -0
- package/dist/chunk-SXE4J43E.js.map +1 -0
- package/dist/{chunk-EFLT7XZD.js → chunk-SYULMZGL.js} +6 -4
- package/dist/{chunk-EFLT7XZD.js.map → chunk-SYULMZGL.js.map} +1 -1
- package/dist/chunk-T4IAJJUU.js +48 -0
- package/dist/chunk-T4IAJJUU.js.map +1 -0
- package/dist/chunk-T4KS577P.js +58 -0
- package/dist/chunk-T4KS577P.js.map +1 -0
- package/dist/chunk-TFIOU6UR.js +78 -0
- package/dist/chunk-TFIOU6UR.js.map +1 -0
- package/dist/chunk-TIZGADU4.js +375 -0
- package/dist/chunk-TIZGADU4.js.map +1 -0
- package/dist/chunk-TP3MCUXS.js +1 -0
- package/dist/chunk-TP3MCUXS.js.map +1 -0
- package/dist/{chunk-JTJU56ZV.js → chunk-UOGM62JL.js} +11 -7
- package/dist/{chunk-JTJU56ZV.js.map → chunk-UOGM62JL.js.map} +1 -1
- package/dist/chunk-USRKPEQN.js +55 -0
- package/dist/chunk-USRKPEQN.js.map +1 -0
- package/dist/chunk-UTAB3XQI.js +667 -0
- package/dist/chunk-UTAB3XQI.js.map +1 -0
- package/dist/chunk-V3FFZWF3.js +182 -0
- package/dist/chunk-V3FFZWF3.js.map +1 -0
- package/dist/chunk-V4OZ7ISA.js +9 -0
- package/dist/chunk-V4OZ7ISA.js.map +1 -0
- package/dist/chunk-VZ5ZZBNX.js +139 -0
- package/dist/chunk-VZ5ZZBNX.js.map +1 -0
- package/dist/{chunk-AHLKV6KP.js → chunk-WN6AVBO4.js} +1 -1
- package/dist/chunk-WXR5CWSC.js +1 -0
- package/dist/chunk-WXR5CWSC.js.map +1 -0
- package/dist/chunk-X6WS3XWL.js +36 -0
- package/dist/chunk-X6WS3XWL.js.map +1 -0
- package/dist/{chunk-Q5BCNYED.js → chunk-XJRNBTIV.js} +7 -4
- package/dist/chunk-XQV3XNVT.js +225 -0
- package/dist/chunk-XQV3XNVT.js.map +1 -0
- package/dist/chunk-XV3DH5GC.js +58 -0
- package/dist/chunk-XV3DH5GC.js.map +1 -0
- package/dist/chunk-Y7JTHNCU.js +318 -0
- package/dist/chunk-Y7JTHNCU.js.map +1 -0
- package/dist/chunk-YWRXOPHC.js +43 -0
- package/dist/chunk-YWRXOPHC.js.map +1 -0
- package/dist/chunk-YZVFIW5D.js +27 -0
- package/dist/chunk-YZVFIW5D.js.map +1 -0
- package/dist/chunk-ZHC5CD6J.js +33 -0
- package/dist/chunk-ZHC5CD6J.js.map +1 -0
- package/dist/chunk-ZPJFXRQZ.js +23 -0
- package/dist/chunk-ZPJFXRQZ.js.map +1 -0
- package/dist/chunk-ZPXOBQDS.js +57 -0
- package/dist/chunk-ZPXOBQDS.js.map +1 -0
- package/dist/chunk-ZUFS6R7L.js +155 -0
- package/dist/chunk-ZUFS6R7L.js.map +1 -0
- package/dist/chunk-ZXLCTQUX.js +62 -0
- package/dist/chunk-ZXLCTQUX.js.map +1 -0
- package/dist/chunk-ZYXMWEL4.js +59 -0
- package/dist/chunk-ZYXMWEL4.js.map +1 -0
- package/dist/completion/controls.js +11 -0
- package/dist/completion/controls.js.map +1 -0
- package/dist/completion/documents.js +9 -0
- package/dist/completion/documents.js.map +1 -0
- package/dist/completion/generate-completion.js +23 -0
- package/dist/completion/generate-completion.js.map +1 -0
- package/dist/completion/index.js +23 -12
- package/dist/completion/json.js +7 -0
- package/dist/completion/json.js.map +1 -0
- package/dist/completion/message-schema.js +18 -0
- package/dist/completion/message-schema.js.map +1 -0
- package/dist/completion/provider-output-error.js +12 -0
- package/dist/completion/provider-output-error.js.map +1 -0
- package/dist/completion/stream-accumulator.js +10 -0
- package/dist/completion/stream-accumulator.js.map +1 -0
- package/dist/completion/types.js +28 -0
- package/dist/completion/types.js.map +1 -0
- package/dist/documents/chunk-text.js +7 -0
- package/dist/documents/chunk-text.js.map +1 -0
- package/dist/documents/index.js +5 -2
- package/dist/documents/text-document.js +8 -0
- package/dist/documents/text-document.js.map +1 -0
- package/dist/embeddings/distance.js +17 -0
- package/dist/embeddings/distance.js.map +1 -0
- package/dist/embeddings/embed.js +18 -0
- package/dist/embeddings/embed.js.map +1 -0
- package/dist/embeddings/index.js +11 -6
- package/dist/embeddings/types.js +2 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/evals/advanced-metrics.js +46 -0
- package/dist/evals/advanced-metrics.js.map +1 -0
- package/dist/evals/agent-target.js +10 -0
- package/dist/evals/agent-target.js.map +1 -0
- package/dist/evals/cli.js +40 -0
- package/dist/evals/cli.js.map +1 -0
- package/dist/evals/execution.js +15 -0
- package/dist/evals/execution.js.map +1 -0
- package/dist/evals/format.js +13 -0
- package/dist/evals/format.js.map +1 -0
- package/dist/evals/index.d.ts +4 -4
- package/dist/evals/index.js +87 -2660
- package/dist/evals/index.js.map +1 -1
- package/dist/evals/judge.js +27 -0
- package/dist/evals/judge.js.map +1 -0
- package/dist/evals/metric.js +7 -0
- package/dist/evals/metric.js.map +1 -0
- package/dist/evals/metrics.js +53 -0
- package/dist/evals/metrics.js.map +1 -0
- package/dist/evals/outcome.js +7 -0
- package/dist/evals/outcome.js.map +1 -0
- package/dist/evals/reporting.js +11 -0
- package/dist/evals/reporting.js.map +1 -0
- package/dist/evals/runner.js +29 -0
- package/dist/evals/runner.js.map +1 -0
- package/dist/evals/selectors.js +18 -0
- package/dist/evals/selectors.js.map +1 -0
- package/dist/evals/suite.js +11 -0
- package/dist/evals/suite.js.map +1 -0
- package/dist/evals/types.js +1 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/extractor/extractor.js +23 -0
- package/dist/extractor/extractor.js.map +1 -0
- package/dist/extractor/index.js +16 -7
- package/dist/guardrails/actions.js +13 -0
- package/dist/guardrails/actions.js.map +1 -0
- package/dist/guardrails/index.d.ts +3 -4
- package/dist/guardrails/index.js +15 -7
- package/dist/guardrails/message.js +9 -0
- package/dist/guardrails/message.js.map +1 -0
- package/dist/guardrails/policy.js +17 -0
- package/dist/guardrails/policy.js.map +1 -0
- package/dist/guardrails/runtime.js +11 -0
- package/dist/guardrails/runtime.js.map +1 -0
- package/dist/guardrails/text.js +9 -0
- package/dist/guardrails/text.js.map +1 -0
- package/dist/guardrails/types.js +1 -0
- package/dist/guardrails/types.js.map +1 -0
- package/dist/hooks/control.js +17 -0
- package/dist/hooks/control.js.map +1 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.js +2 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/image-generation/generate-image.js +11 -0
- package/dist/image-generation/generate-image.js.map +1 -0
- package/dist/image-generation/index.js +7 -4
- package/dist/image-generation/types.js +2 -0
- package/dist/image-generation/types.js.map +1 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +163 -57
- package/dist/internal/abort.js +13 -0
- package/dist/internal/abort.js.map +1 -0
- package/dist/internal/agent-runtime/agent-run.js +81 -0
- package/dist/internal/agent-runtime/agent-run.js.map +1 -0
- package/dist/internal/agent-runtime/approval-request.js +1 -0
- package/dist/internal/agent-runtime/approval-request.js.map +1 -0
- package/dist/internal/agent-runtime/approval-requirement.js +9 -0
- package/dist/internal/agent-runtime/approval-requirement.js.map +1 -0
- package/dist/internal/agent-runtime/continuation-state.js +26 -0
- package/dist/internal/agent-runtime/continuation-state.js.map +1 -0
- package/dist/internal/agent-runtime/interaction-suspension.js +25 -0
- package/dist/internal/agent-runtime/interaction-suspension.js.map +1 -0
- package/dist/internal/agent-runtime/memory-scope.js +8 -0
- package/dist/internal/agent-runtime/memory-scope.js.map +1 -0
- package/dist/internal/agent-runtime/memory.js +24 -0
- package/dist/internal/agent-runtime/memory.js.map +1 -0
- package/dist/internal/agent-runtime/prepared-tool-call.js +19 -0
- package/dist/internal/agent-runtime/prepared-tool-call.js.map +1 -0
- package/dist/internal/agent-runtime/retrieval.js +35 -0
- package/dist/internal/agent-runtime/retrieval.js.map +1 -0
- package/dist/internal/agent-runtime/run-options.js +9 -0
- package/dist/internal/agent-runtime/run-options.js.map +1 -0
- package/dist/internal/agent-runtime/run-validation.js +9 -0
- package/dist/internal/agent-runtime/run-validation.js.map +1 -0
- package/dist/internal/agent-runtime/stream-events.js +11 -0
- package/dist/internal/agent-runtime/stream-events.js.map +1 -0
- package/dist/internal/agent-runtime/structured-output.js +13 -0
- package/dist/internal/agent-runtime/structured-output.js.map +1 -0
- package/dist/internal/agent-runtime/tool-execution.js +55 -0
- package/dist/internal/agent-runtime/tool-execution.js.map +1 -0
- package/dist/internal/agent.d.ts +5 -5
- package/dist/internal/agent.js +93 -57
- package/dist/internal/agent.js.map +1 -1
- package/dist/internal/async-queue.js +7 -0
- package/dist/internal/async-queue.js.map +1 -0
- package/dist/internal/completion-request.js +11 -0
- package/dist/internal/completion-request.js.map +1 -0
- package/dist/internal/concurrency.js +7 -0
- package/dist/internal/concurrency.js.map +1 -0
- package/dist/internal/json-object.js +8 -0
- package/dist/internal/json-object.js.map +1 -0
- package/dist/internal/rag-text.js +7 -0
- package/dist/internal/rag-text.js.map +1 -0
- package/dist/internal/record.js +7 -0
- package/dist/internal/record.js.map +1 -0
- package/dist/internal/team-runtime/coordination.js +12 -0
- package/dist/internal/team-runtime/coordination.js.map +1 -0
- package/dist/internal/team-runtime/member.js +26 -0
- package/dist/internal/team-runtime/member.js.map +1 -0
- package/dist/internal/team-runtime/policy.js +7 -0
- package/dist/internal/team-runtime/policy.js.map +1 -0
- package/dist/internal/team-runtime/run.js +95 -0
- package/dist/internal/team-runtime/run.js.map +1 -0
- package/dist/internal/team-runtime/stream.js +9 -0
- package/dist/internal/team-runtime/stream.js.map +1 -0
- package/dist/internal/team-runtime/tools.js +17 -0
- package/dist/internal/team-runtime/tools.js.map +1 -0
- package/dist/internal/type-utils.js +1 -0
- package/dist/internal/type-utils.js.map +1 -0
- package/dist/internal/vector-search-options.js +9 -0
- package/dist/internal/vector-search-options.js.map +1 -0
- package/dist/mcp/index.js +3 -1
- package/dist/mcp/tool.js +7 -0
- package/dist/mcp/tool.js.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/memory/assert.js +11 -0
- package/dist/memory/assert.js.map +1 -0
- package/dist/memory/compaction.js +26 -0
- package/dist/memory/compaction.js.map +1 -0
- package/dist/memory/errors.js +9 -0
- package/dist/memory/errors.js.map +1 -0
- package/dist/memory/index.js +23 -10
- package/dist/memory/options.js +10 -0
- package/dist/memory/options.js.map +1 -0
- package/dist/memory/scope-key.js +7 -0
- package/dist/memory/scope-key.js.map +1 -0
- package/dist/memory/types.js +2 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/{types-CRda8x7p.d.ts → middleware-CWjnMbiH.d.ts} +64 -5
- package/dist/model-call-options.js +1 -0
- package/dist/model-call-options.js.map +1 -0
- package/dist/model-listing/errors.js +7 -0
- package/dist/model-listing/errors.js.map +1 -0
- package/dist/model-listing/index.js +4 -13
- package/dist/model-listing/index.js.map +1 -1
- package/dist/model-listing/types.js +2 -0
- package/dist/model-listing/types.js.map +1 -0
- package/dist/observability/group.js +30 -0
- package/dist/observability/group.js.map +1 -0
- package/dist/observability/index.d.ts +4 -6
- package/dist/observability/index.js +16 -8
- package/dist/observability/snapshot.js +7 -0
- package/dist/observability/snapshot.js.map +1 -0
- package/dist/observability/types.js +1 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pipeline/errors.js +9 -0
- package/dist/pipeline/errors.js.map +1 -0
- package/dist/pipeline/graph.js +21 -0
- package/dist/pipeline/graph.js.map +1 -0
- package/dist/pipeline/index.d.ts +4 -6
- package/dist/pipeline/index.js +27 -805
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/observability.js +15 -0
- package/dist/pipeline/observability.js.map +1 -0
- package/dist/pipeline/pipeline.js +30 -0
- package/dist/pipeline/pipeline.js.map +1 -0
- package/dist/pipeline/runtime.js +17 -0
- package/dist/pipeline/runtime.js.map +1 -0
- package/dist/pipeline/types.js +1 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/retry.js +20 -0
- package/dist/retry.js.map +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/zod-schema.js +7 -0
- package/dist/schema/zod-schema.js.map +1 -0
- package/dist/skills/index.js +41 -12
- package/dist/skills/instructions.js +7 -0
- package/dist/skills/instructions.js.map +1 -0
- package/dist/skills/load.js +39 -0
- package/dist/skills/load.js.map +1 -0
- package/dist/skills/local.js +9 -0
- package/dist/skills/local.js.map +1 -0
- package/dist/skills/tools.js +37 -0
- package/dist/skills/tools.js.map +1 -0
- package/dist/skills/types.js +7 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/speech-generation/generate-speech.js +11 -0
- package/dist/speech-generation/generate-speech.js.map +1 -0
- package/dist/speech-generation/index.js +7 -4
- package/dist/speech-generation/types.js +2 -0
- package/dist/speech-generation/types.js.map +1 -0
- package/dist/streaming/index.js +4 -37
- package/dist/streaming/index.js.map +1 -1
- package/dist/streaming/readable-stream.js +8 -0
- package/dist/streaming/readable-stream.js.map +1 -0
- package/dist/{text-CmjXxakS.d.ts → text-GbW4WYMg.d.ts} +1 -1
- package/dist/tool/create-tool.js +14 -0
- package/dist/tool/create-tool.js.map +1 -0
- package/dist/tool/dynamic-tools.js +35 -0
- package/dist/tool/dynamic-tools.js.map +1 -0
- package/dist/tool/errors.js +11 -0
- package/dist/tool/errors.js.map +1 -0
- package/dist/tool/index.d.ts +3 -2
- package/dist/tool/index.js +41 -15
- package/dist/tool/middleware.js +7 -0
- package/dist/tool/middleware.js.map +1 -0
- package/dist/tool/question-tool.js +17 -0
- package/dist/tool/question-tool.js.map +1 -0
- package/dist/tool/skill-tool-marker.js +9 -0
- package/dist/tool/skill-tool-marker.js.map +1 -0
- package/dist/tool/think-tool.js +15 -0
- package/dist/tool/think-tool.js.map +1 -0
- package/dist/tool/tool.js +17 -0
- package/dist/tool/tool.js.map +1 -0
- package/dist/transcription/index.js +7 -4
- package/dist/transcription/transcribe.js +11 -0
- package/dist/transcription/transcribe.js.map +1 -0
- package/dist/transcription/types.js +2 -0
- package/dist/transcription/types.js.map +1 -0
- package/dist/{types-h0EL6Xn0.d.ts → types-Bqw0AuFl.d.ts} +6 -2
- package/dist/vector-store/filter.js +9 -0
- package/dist/vector-store/filter.js.map +1 -0
- package/dist/vector-store/index.js +31 -11
- package/dist/vector-store/ingest.js +19 -0
- package/dist/vector-store/ingest.js.map +1 -0
- package/dist/vector-store/lsh.js +7 -0
- package/dist/vector-store/lsh.js.map +1 -0
- package/dist/vector-store/retrieve.js +15 -0
- package/dist/vector-store/retrieve.js.map +1 -0
- package/dist/vector-store/types.js +1 -0
- package/dist/vector-store/types.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-2QZJTG2E.js.map +0 -1
- package/dist/chunk-3RWESPUG.js.map +0 -1
- package/dist/chunk-4UQALF5Y.js.map +0 -1
- package/dist/chunk-AZB6N7P4.js +0 -320
- package/dist/chunk-AZB6N7P4.js.map +0 -1
- package/dist/chunk-JLJMVRRE.js.map +0 -1
- package/dist/chunk-K5L7R7XM.js.map +0 -1
- package/dist/chunk-OI3LSMJG.js +0 -1545
- package/dist/chunk-OI3LSMJG.js.map +0 -1
- package/dist/chunk-QGX73TSQ.js.map +0 -1
- package/dist/chunk-XC3LVC4K.js +0 -753
- package/dist/chunk-XC3LVC4K.js.map +0 -1
- package/dist/chunk-XEVOC433.js.map +0 -1
- package/dist/chunk-XSV5C4R5.js +0 -400
- package/dist/chunk-XSV5C4R5.js.map +0 -1
- package/dist/chunk-XU54PLSD.js +0 -4786
- package/dist/chunk-XU54PLSD.js.map +0 -1
- package/dist/middleware-mY_lpjDp.d.ts +0 -59
- package/dist/type-utils-CtHVDRn_.d.ts +0 -6
- /package/dist/{chunk-YK4WAAS4.js.map → chunk-2NLINXRF.js.map} +0 -0
- /package/dist/{chunk-SPD4XVR7.js.map → chunk-2XSMGVBG.js.map} +0 -0
- /package/dist/{chunk-3XQGVDU5.js.map → chunk-4C7AXYOM.js.map} +0 -0
- /package/dist/{chunk-IZNOP6JG.js.map → chunk-4FIVU53H.js.map} +0 -0
- /package/dist/{chunk-7JLAIN6E.js.map → chunk-4ONUNWGC.js.map} +0 -0
- /package/dist/{chunk-KSKST3KP.js.map → chunk-H3H74RWJ.js.map} +0 -0
- /package/dist/{chunk-OJBFDBLG.js.map → chunk-LBYJPMHC.js.map} +0 -0
- /package/dist/{chunk-J6LVLV6P.js.map → chunk-PLDJCCVL.js.map} +0 -0
- /package/dist/{chunk-AHLKV6KP.js.map → chunk-WN6AVBO4.js.map} +0 -0
- /package/dist/{chunk-Q5BCNYED.js.map → chunk-XJRNBTIV.js.map} +0 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TEAM_INSTRUCTIONS,
|
|
3
|
+
teamTools
|
|
4
|
+
} from "./chunk-B47EXUHL.js";
|
|
5
|
+
import {
|
|
6
|
+
TeamChanges,
|
|
7
|
+
TeamSlots,
|
|
8
|
+
abortable
|
|
9
|
+
} from "./chunk-PIMD4DYG.js";
|
|
10
|
+
import {
|
|
11
|
+
agentMessageInput,
|
|
12
|
+
memberSummary,
|
|
13
|
+
steeringMessages
|
|
14
|
+
} from "./chunk-T4KS577P.js";
|
|
15
|
+
import {
|
|
16
|
+
AgentTeamInteractionError,
|
|
17
|
+
AgentTeamLimitError
|
|
18
|
+
} from "./chunk-ENZ2XX27.js";
|
|
19
|
+
import {
|
|
20
|
+
createResolvedAgent,
|
|
21
|
+
getResolvedAgentOptions
|
|
22
|
+
} from "./chunk-T4IAJJUU.js";
|
|
23
|
+
import {
|
|
24
|
+
AgentRun
|
|
25
|
+
} from "./chunk-RT5LUEO3.js";
|
|
26
|
+
import {
|
|
27
|
+
withInternalAgentRunOptions
|
|
28
|
+
} from "./chunk-KITX3HDN.js";
|
|
29
|
+
import {
|
|
30
|
+
assertAgentInteractionResponse,
|
|
31
|
+
parseAgentInteractionResponse
|
|
32
|
+
} from "./chunk-LBYJPMHC.js";
|
|
33
|
+
import {
|
|
34
|
+
composeAgentLifecycle,
|
|
35
|
+
lifecycleSnapshot
|
|
36
|
+
} from "./chunk-KFAVEL5F.js";
|
|
37
|
+
import {
|
|
38
|
+
isStreamingCompletionModel
|
|
39
|
+
} from "./chunk-BDKFFFVX.js";
|
|
40
|
+
import {
|
|
41
|
+
Usage
|
|
42
|
+
} from "./chunk-IDNL6IH4.js";
|
|
43
|
+
import {
|
|
44
|
+
parseMessages
|
|
45
|
+
} from "./chunk-BONQTXRQ.js";
|
|
46
|
+
import {
|
|
47
|
+
throwIfAborted
|
|
48
|
+
} from "./chunk-USRKPEQN.js";
|
|
49
|
+
import {
|
|
50
|
+
AgentRunCancelledError,
|
|
51
|
+
AgentStreamClosedError
|
|
52
|
+
} from "./chunk-WN6AVBO4.js";
|
|
53
|
+
|
|
54
|
+
// src/internal/team-runtime/run.ts
|
|
55
|
+
var TeamRun = class {
|
|
56
|
+
constructor(leader, policy, limits, options, streaming, emit) {
|
|
57
|
+
this.policy = policy;
|
|
58
|
+
this.limits = limits;
|
|
59
|
+
this.options = options;
|
|
60
|
+
this.streaming = streaming;
|
|
61
|
+
this.emit = emit;
|
|
62
|
+
this.slots = new TeamSlots(limits.maxConcurrentAgents);
|
|
63
|
+
this.leader = this.createMember(leader, leader.name ?? leader.id);
|
|
64
|
+
const messages = options.messages === void 0 ? steeringMessages({ prompt: options.prompt }) : parseMessages(options.messages);
|
|
65
|
+
const last = messages.at(-1);
|
|
66
|
+
if (last?.role !== "user")
|
|
67
|
+
throw new TypeError("Agent team input must end with a user message.");
|
|
68
|
+
this.leader.history = messages.slice(0, -1);
|
|
69
|
+
this.leader.inputs.push({
|
|
70
|
+
id: globalThis.crypto.randomUUID(),
|
|
71
|
+
messages: [last],
|
|
72
|
+
submitted: false
|
|
73
|
+
});
|
|
74
|
+
if (options.abortSignal !== void 0) {
|
|
75
|
+
const signal = options.abortSignal;
|
|
76
|
+
const abort = () => this.cancel("Agent team aborted.");
|
|
77
|
+
if (signal.aborted) abort();
|
|
78
|
+
else {
|
|
79
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
80
|
+
this.removeAbortListener = () => signal.removeEventListener("abort", abort);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
policy;
|
|
85
|
+
limits;
|
|
86
|
+
options;
|
|
87
|
+
streaming;
|
|
88
|
+
emit;
|
|
89
|
+
id = globalThis.crypto.randomUUID();
|
|
90
|
+
controller = new AbortController();
|
|
91
|
+
changes = new TeamChanges();
|
|
92
|
+
slots;
|
|
93
|
+
instances = /* @__PURE__ */ new Map();
|
|
94
|
+
leader;
|
|
95
|
+
closed = false;
|
|
96
|
+
started = false;
|
|
97
|
+
turns = 0;
|
|
98
|
+
fatal;
|
|
99
|
+
removeAbortListener;
|
|
100
|
+
async execute() {
|
|
101
|
+
if (this.started) throw new Error("Agent team execution has already started.");
|
|
102
|
+
this.started = true;
|
|
103
|
+
try {
|
|
104
|
+
this.assertOpen();
|
|
105
|
+
this.launch(this.leader);
|
|
106
|
+
while (true) {
|
|
107
|
+
this.assertOpen();
|
|
108
|
+
const version = this.changes.version;
|
|
109
|
+
if (this.leader.status === "failed" && this.leader.outcome?.type !== "blocked")
|
|
110
|
+
throw this.leader.error;
|
|
111
|
+
const outcome = this.leader.outcome;
|
|
112
|
+
if (outcome !== void 0 && (outcome.type === "blocked" || this.leader.status === "idle" && this.leader.task === void 0 && this.leader.inputs.length === 0 && !this.childrenBusy())) {
|
|
113
|
+
this.closed = true;
|
|
114
|
+
this.stopMembers();
|
|
115
|
+
await this.settleMembers();
|
|
116
|
+
const result = {
|
|
117
|
+
...outcome,
|
|
118
|
+
teamRunId: this.id,
|
|
119
|
+
usage: [...this.instances.values()].reduce(
|
|
120
|
+
(usage, member) => Usage.add(usage, member.usage),
|
|
121
|
+
Usage.empty()
|
|
122
|
+
),
|
|
123
|
+
members: [...this.instances.values()].filter((member) => member !== this.leader).map(memberSummary)
|
|
124
|
+
};
|
|
125
|
+
this.emit(result);
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
await this.changes.wait(version, this.controller.signal);
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
this.closed = true;
|
|
132
|
+
this.stopMembers();
|
|
133
|
+
await this.settleMembers();
|
|
134
|
+
throw this.fatal ?? error;
|
|
135
|
+
} finally {
|
|
136
|
+
this.removeAbortListener?.();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
steer(input) {
|
|
140
|
+
this.assertOpen();
|
|
141
|
+
const entry = {
|
|
142
|
+
id: globalThis.crypto.randomUUID(),
|
|
143
|
+
messages: steeringMessages(input),
|
|
144
|
+
submitted: false
|
|
145
|
+
};
|
|
146
|
+
this.enqueue(this.leader, entry);
|
|
147
|
+
return { id: entry.id, status: "queued" };
|
|
148
|
+
}
|
|
149
|
+
cancel(reason = "Agent team cancelled.") {
|
|
150
|
+
if (this.closed || this.controller.signal.aborted) return;
|
|
151
|
+
this.fail(new AgentRunCancelledError([], reason));
|
|
152
|
+
}
|
|
153
|
+
spawn(parent, definition, prompt, name) {
|
|
154
|
+
this.assertOpen();
|
|
155
|
+
throwIfAborted(parent.controller.signal);
|
|
156
|
+
if (!this.policy.spawnTargets(parent).includes(definition))
|
|
157
|
+
throw new Error(`Agent "${parent.definition.id}" cannot spawn "${definition.id}".`);
|
|
158
|
+
if (parent.depth >= this.limits.maxDepth) throw new AgentTeamLimitError("maxDepth");
|
|
159
|
+
if (this.instances.size >= this.limits.maxAgentInstances)
|
|
160
|
+
throw new AgentTeamLimitError("maxAgentInstances");
|
|
161
|
+
const member = this.createMember(definition, name ?? definition.name ?? definition.id, parent);
|
|
162
|
+
member.inputs.push({
|
|
163
|
+
id: globalThis.crypto.randomUUID(),
|
|
164
|
+
messages: [{ role: "user", content: prompt }],
|
|
165
|
+
submitted: false
|
|
166
|
+
});
|
|
167
|
+
this.memberEvent(member, "agent_queued");
|
|
168
|
+
this.launch(member);
|
|
169
|
+
return { instanceId: member.instanceId, status: "queued" };
|
|
170
|
+
}
|
|
171
|
+
send(sender, input) {
|
|
172
|
+
this.assertOpen();
|
|
173
|
+
throwIfAborted(sender.controller.signal);
|
|
174
|
+
const recipient = this.recipient(sender, input.to);
|
|
175
|
+
if (recipient.status === "failed" || recipient.status === "cancelled") {
|
|
176
|
+
throw new Error(`Agent instance "${recipient.instanceId}" is ${recipient.status}.`);
|
|
177
|
+
}
|
|
178
|
+
return this.queueMessage(sender, recipient, input);
|
|
179
|
+
}
|
|
180
|
+
queueMessage(sender, recipient, input, notificationType = "message") {
|
|
181
|
+
const message = {
|
|
182
|
+
id: globalThis.crypto.randomUUID(),
|
|
183
|
+
teamRunId: this.id,
|
|
184
|
+
fromInstanceId: sender.instanceId,
|
|
185
|
+
toInstanceId: recipient.instanceId,
|
|
186
|
+
content: input.content,
|
|
187
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
188
|
+
...input.replyTo === void 0 ? {} : { replyTo: input.replyTo }
|
|
189
|
+
};
|
|
190
|
+
this.enqueue(recipient, agentMessageInput(message), notificationType);
|
|
191
|
+
return { messageId: message.id, status: "queued" };
|
|
192
|
+
}
|
|
193
|
+
visibleMembers(caller) {
|
|
194
|
+
return [...this.instances.values()].filter((member) => this.policy.canAccess(caller, member)).map((member) => ({
|
|
195
|
+
instanceId: member.instanceId,
|
|
196
|
+
agentId: member.agent.id,
|
|
197
|
+
name: member.name,
|
|
198
|
+
status: member.status,
|
|
199
|
+
depth: member.depth,
|
|
200
|
+
...member.parentInstanceId === void 0 ? {} : { parentInstanceId: member.parentInstanceId }
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
cancelMember(caller, instanceId, reason = "Cancelled by parent.") {
|
|
204
|
+
this.assertOpen();
|
|
205
|
+
throwIfAborted(caller.controller.signal);
|
|
206
|
+
const member = this.recipient(caller, instanceId);
|
|
207
|
+
if (member.parentInstanceId !== caller.instanceId)
|
|
208
|
+
throw new Error("Only a parent can cancel its child.");
|
|
209
|
+
if (member.status === "cancelled") return { instanceId, status: "cancelled" };
|
|
210
|
+
this.stopMember(member, reason);
|
|
211
|
+
this.stopDescendants(member, reason);
|
|
212
|
+
if (member.task === void 0) this.reportOutcome(member);
|
|
213
|
+
return { instanceId, status: "cancelled" };
|
|
214
|
+
}
|
|
215
|
+
async wait(member, instanceId, timeoutMs) {
|
|
216
|
+
this.assertOpen();
|
|
217
|
+
const target = instanceId === void 0 ? void 0 : this.recipient(member, instanceId);
|
|
218
|
+
const deadline = Date.now() + timeoutMs;
|
|
219
|
+
return this.yieldSlot(member, "waiting", async () => {
|
|
220
|
+
while (true) {
|
|
221
|
+
const version = this.changes.version;
|
|
222
|
+
const index = member.notifications.findIndex(
|
|
223
|
+
(notification) => target === void 0 || notification.from === target.instanceId
|
|
224
|
+
);
|
|
225
|
+
if (index !== -1) {
|
|
226
|
+
const notification = member.notifications.splice(index, 1)[0];
|
|
227
|
+
return {
|
|
228
|
+
reason: notification.type,
|
|
229
|
+
instanceId: notification.from,
|
|
230
|
+
messageId: notification.id
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
if (target !== void 0 && ["idle", "failed", "cancelled"].includes(target.status)) {
|
|
234
|
+
return { reason: "outcome", instanceId: target.instanceId, status: target.status };
|
|
235
|
+
}
|
|
236
|
+
const remaining = deadline - Date.now();
|
|
237
|
+
if (remaining <= 0) return { reason: "timeout" };
|
|
238
|
+
await this.changes.wait(version, member.controller.signal, remaining);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
createMember(agent, name, parent) {
|
|
243
|
+
const parentInstanceId = parent?.instanceId;
|
|
244
|
+
const member = {
|
|
245
|
+
instanceId: globalThis.crypto.randomUUID(),
|
|
246
|
+
agent,
|
|
247
|
+
definition: agent,
|
|
248
|
+
depth: parent === void 0 ? 0 : parent.depth + 1,
|
|
249
|
+
name,
|
|
250
|
+
...parentInstanceId === void 0 ? {} : { parentInstanceId },
|
|
251
|
+
status: "queued",
|
|
252
|
+
history: [],
|
|
253
|
+
inputs: [],
|
|
254
|
+
receipts: /* @__PURE__ */ new Map(),
|
|
255
|
+
controller: new AbortController(),
|
|
256
|
+
usage: Usage.empty(),
|
|
257
|
+
notifications: []
|
|
258
|
+
};
|
|
259
|
+
const resolved = getResolvedAgentOptions(member.agent);
|
|
260
|
+
member.agent = createResolvedAgent({
|
|
261
|
+
...resolved,
|
|
262
|
+
instructions: [
|
|
263
|
+
resolved.instructions,
|
|
264
|
+
TEAM_INSTRUCTIONS,
|
|
265
|
+
`Your instance ID is ${member.instanceId}. ${parentInstanceId === void 0 ? "You are the coordinator. Spawn tools create independent members; their outcomes are delivered automatically." : `Your parent instance is ${parentInstanceId}.`}`
|
|
266
|
+
].filter(Boolean).join("\n\n"),
|
|
267
|
+
tools: [
|
|
268
|
+
...resolved.tools ?? [],
|
|
269
|
+
...teamTools(this, member, this.policy.spawnTargets(member))
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
this.instances.set(member.instanceId, member);
|
|
273
|
+
return member;
|
|
274
|
+
}
|
|
275
|
+
recipient(sender, to) {
|
|
276
|
+
const id = to === "parent" ? sender.parentInstanceId : to;
|
|
277
|
+
const recipient = id === void 0 ? void 0 : this.instances.get(id);
|
|
278
|
+
if (recipient === void 0 || recipient === sender || !this.policy.canAccess(sender, recipient)) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
`Agent instance "${to}" is not an accessible parent or child, or enabled sibling.`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return recipient;
|
|
284
|
+
}
|
|
285
|
+
enqueue(member, input, notificationType = "message") {
|
|
286
|
+
if (member.inputs.length >= 128)
|
|
287
|
+
throw new AgentTeamLimitError("pending messages per instance (128)");
|
|
288
|
+
member.inputs.push(input);
|
|
289
|
+
if (input.message !== void 0) {
|
|
290
|
+
this.emit({ type: "message_queued", ...this.identity(member), message: input.message });
|
|
291
|
+
member.notifications.push({
|
|
292
|
+
type: notificationType,
|
|
293
|
+
from: input.message.fromInstanceId,
|
|
294
|
+
id: input.id
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
this.submitInputs(member);
|
|
298
|
+
if (this.started && member.task === void 0) this.launch(member);
|
|
299
|
+
this.changes.notify();
|
|
300
|
+
}
|
|
301
|
+
submitInputs(member) {
|
|
302
|
+
if (member.activeRun === void 0) return;
|
|
303
|
+
for (const input of member.inputs) {
|
|
304
|
+
if (input.submitted) continue;
|
|
305
|
+
try {
|
|
306
|
+
const receipt = member.activeRun.steer({ messages: input.messages });
|
|
307
|
+
member.receipts.set(receipt.id, input);
|
|
308
|
+
input.submitted = true;
|
|
309
|
+
} catch (error) {
|
|
310
|
+
if (error instanceof AgentStreamClosedError) return;
|
|
311
|
+
throw error;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
delivered(member, input) {
|
|
316
|
+
const index = member.inputs.indexOf(input);
|
|
317
|
+
if (index !== -1) member.inputs.splice(index, 1);
|
|
318
|
+
member.notifications = member.notifications.filter(
|
|
319
|
+
(notification) => notification.id !== input.id
|
|
320
|
+
);
|
|
321
|
+
if (input.message !== void 0)
|
|
322
|
+
this.emit({ type: "message_delivered", ...this.identity(member), message: input.message });
|
|
323
|
+
}
|
|
324
|
+
launch(member) {
|
|
325
|
+
if (member.task !== void 0 || this.closed || member.controller.signal.aborted) return;
|
|
326
|
+
member.status = "queued";
|
|
327
|
+
member.task = Promise.resolve().then(() => this.runMember(member)).catch((error) => {
|
|
328
|
+
member.error = error;
|
|
329
|
+
member.inputs.length = 0;
|
|
330
|
+
if (member.controller.signal.aborted) member.status = "cancelled";
|
|
331
|
+
else {
|
|
332
|
+
member.status = "failed";
|
|
333
|
+
this.memberEvent(member, "agent_failed");
|
|
334
|
+
}
|
|
335
|
+
this.stopDescendants(member, "Parent failed or was cancelled.");
|
|
336
|
+
if (!this.closed && !this.controller.signal.aborted && member !== this.leader) {
|
|
337
|
+
try {
|
|
338
|
+
this.reportOutcome(member);
|
|
339
|
+
} catch (reportError) {
|
|
340
|
+
this.fail(reportError);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}).finally(() => {
|
|
344
|
+
member.release?.();
|
|
345
|
+
member.release = void 0;
|
|
346
|
+
member.activeRun = void 0;
|
|
347
|
+
member.task = void 0;
|
|
348
|
+
if (member.status === "idle" && member.inputs.length > 0) this.launch(member);
|
|
349
|
+
this.changes.notify();
|
|
350
|
+
});
|
|
351
|
+
this.changes.notify();
|
|
352
|
+
}
|
|
353
|
+
async runMember(member) {
|
|
354
|
+
const signal = member.controller.signal;
|
|
355
|
+
member.release = await this.slots.acquire(signal);
|
|
356
|
+
let nextInput;
|
|
357
|
+
let firstInputs = [];
|
|
358
|
+
while (true) {
|
|
359
|
+
throwIfAborted(signal);
|
|
360
|
+
member.status = "running";
|
|
361
|
+
member.runId = globalThis.crypto.randomUUID();
|
|
362
|
+
if (nextInput === void 0) {
|
|
363
|
+
firstInputs = member.inputs.filter((input) => !input.submitted);
|
|
364
|
+
const incoming = firstInputs.flatMap((input) => input.messages);
|
|
365
|
+
if (incoming.length === 0) throw new Error("Agent team member has no input.");
|
|
366
|
+
nextInput = { messages: [...member.history, ...incoming] };
|
|
367
|
+
member.history.push(...incoming.slice(0, -1));
|
|
368
|
+
for (const input of firstInputs) input.submitted = true;
|
|
369
|
+
}
|
|
370
|
+
const streaming = this.streaming && member.agent.model.capabilities.streaming && isStreamingCompletionModel(member.agent.model);
|
|
371
|
+
const baseSettings = member === this.leader ? {
|
|
372
|
+
maxTurns: this.options.maxTurns,
|
|
373
|
+
retries: this.options.retries,
|
|
374
|
+
lifecycle: this.options.lifecycle,
|
|
375
|
+
guardrails: this.options.guardrails,
|
|
376
|
+
middlewares: this.options.middlewares,
|
|
377
|
+
trace: this.options.trace,
|
|
378
|
+
controls: this.options.controls
|
|
379
|
+
} : {};
|
|
380
|
+
const run = AgentRun.fromAgent(
|
|
381
|
+
member.agent,
|
|
382
|
+
withInternalAgentRunOptions(
|
|
383
|
+
{
|
|
384
|
+
...baseSettings,
|
|
385
|
+
...nextInput,
|
|
386
|
+
abortSignal: signal,
|
|
387
|
+
// Collaboration tools mutate one inbox/permit at a time; provider tools may still run independently across agents.
|
|
388
|
+
toolConcurrency: 1,
|
|
389
|
+
lifecycle: composeAgentLifecycle(baseSettings.lifecycle, {
|
|
390
|
+
onStepFinish: (event) => {
|
|
391
|
+
if (!streaming)
|
|
392
|
+
this.agentEvent(member, {
|
|
393
|
+
type: "turn_end",
|
|
394
|
+
turn: event.step,
|
|
395
|
+
response: lifecycleSnapshot(event.response)
|
|
396
|
+
});
|
|
397
|
+
},
|
|
398
|
+
onError: (event) => {
|
|
399
|
+
member.usage = Usage.add(member.usage, event.usage);
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
runId: member.runId,
|
|
405
|
+
hook: {
|
|
406
|
+
onCompletionCall: () => {
|
|
407
|
+
this.assertOpen();
|
|
408
|
+
if (this.turns >= this.limits.maxTotalTurns) {
|
|
409
|
+
const error = new AgentTeamLimitError("maxTotalTurns");
|
|
410
|
+
this.fail(error);
|
|
411
|
+
throw error;
|
|
412
|
+
}
|
|
413
|
+
this.turns += 1;
|
|
414
|
+
for (const input of firstInputs) this.delivered(member, input);
|
|
415
|
+
firstInputs = [];
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
beforeFinish: () => this.waitForChildren(member),
|
|
419
|
+
onSteeringApplied: (id) => {
|
|
420
|
+
const input = member.receipts.get(id);
|
|
421
|
+
if (input !== void 0) {
|
|
422
|
+
member.receipts.delete(id);
|
|
423
|
+
this.delivered(member, input);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
member.activeRun = run;
|
|
430
|
+
this.submitInputs(member);
|
|
431
|
+
this.memberEvent(member, "agent_started");
|
|
432
|
+
const outcome = await abortable(this.consumeRun(member, run, streaming), signal);
|
|
433
|
+
member.activeRun = void 0;
|
|
434
|
+
member.usage = Usage.add(member.usage, outcome.usage);
|
|
435
|
+
member.history.push(...outcome.messages);
|
|
436
|
+
if (outcome.type === "interaction") {
|
|
437
|
+
const resolver = this.options.resolveInteraction;
|
|
438
|
+
this.emit({
|
|
439
|
+
type: "interaction",
|
|
440
|
+
...this.identity(member),
|
|
441
|
+
interaction: lifecycleSnapshot(outcome.interaction)
|
|
442
|
+
});
|
|
443
|
+
if (resolver === void 0) {
|
|
444
|
+
const error = new AgentTeamInteractionError(member.instanceId);
|
|
445
|
+
this.fail(error);
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
try {
|
|
449
|
+
const response = await this.yieldSlot(
|
|
450
|
+
member,
|
|
451
|
+
"awaiting_interaction",
|
|
452
|
+
() => abortable(
|
|
453
|
+
Promise.resolve().then(
|
|
454
|
+
() => resolver({
|
|
455
|
+
teamRunId: this.id,
|
|
456
|
+
instanceId: member.instanceId,
|
|
457
|
+
runId: outcome.runId,
|
|
458
|
+
interaction: lifecycleSnapshot(outcome.interaction),
|
|
459
|
+
abortSignal: signal
|
|
460
|
+
})
|
|
461
|
+
),
|
|
462
|
+
signal
|
|
463
|
+
)
|
|
464
|
+
);
|
|
465
|
+
const parsed = parseAgentInteractionResponse(response);
|
|
466
|
+
assertAgentInteractionResponse(outcome.interaction, parsed);
|
|
467
|
+
nextInput = { continuation: outcome.continuation, response: parsed };
|
|
468
|
+
} catch (cause) {
|
|
469
|
+
if (signal.aborted) throw cause;
|
|
470
|
+
const error = new AgentTeamInteractionError(member.instanceId, { cause });
|
|
471
|
+
this.fail(error);
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
member.outcome = outcome;
|
|
477
|
+
member.status = outcome.type === "blocked" ? "failed" : "idle";
|
|
478
|
+
if (outcome.type === "blocked") {
|
|
479
|
+
member.inputs.length = 0;
|
|
480
|
+
this.stopDescendants(member, "Parent was blocked.");
|
|
481
|
+
}
|
|
482
|
+
this.memberEvent(member, outcome.type === "blocked" ? "agent_failed" : "agent_idle");
|
|
483
|
+
if (member !== this.leader) this.reportOutcome(member);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async consumeRun(member, run, streaming) {
|
|
488
|
+
if (!streaming) {
|
|
489
|
+
const outcome = await run.generate();
|
|
490
|
+
if (outcome.type === "response")
|
|
491
|
+
this.agentEvent(member, { type: "text_delta", turn: 0, delta: outcome.text });
|
|
492
|
+
this.agentEvent(member, outcome);
|
|
493
|
+
return outcome;
|
|
494
|
+
}
|
|
495
|
+
for await (const event of run.events()) {
|
|
496
|
+
this.agentEvent(member, event);
|
|
497
|
+
if (event.type === "error") throw event.error;
|
|
498
|
+
if (event.type === "response" || event.type === "blocked" || event.type === "interaction")
|
|
499
|
+
return event;
|
|
500
|
+
}
|
|
501
|
+
throw new Error("Agent team member stream ended without an outcome.");
|
|
502
|
+
}
|
|
503
|
+
reportOutcome(member) {
|
|
504
|
+
const parent = this.instances.get(member.parentInstanceId);
|
|
505
|
+
if (parent === void 0 || parent.status === "failed" || parent.status === "cancelled") return;
|
|
506
|
+
const content = JSON.stringify({
|
|
507
|
+
type: "agent-outcome",
|
|
508
|
+
instanceId: member.instanceId,
|
|
509
|
+
status: member.status,
|
|
510
|
+
...member.outcome?.type === "response" ? { output: member.outcome.output } : {},
|
|
511
|
+
...member.outcome?.type === "blocked" ? { reason: member.outcome.reason } : {},
|
|
512
|
+
...member.error === void 0 ? {} : { error: member.error instanceof Error ? member.error.message : String(member.error) }
|
|
513
|
+
});
|
|
514
|
+
this.queueMessage(member, parent, { content }, "outcome");
|
|
515
|
+
}
|
|
516
|
+
async waitForChildren(member) {
|
|
517
|
+
if (!this.childrenBusy(member) || member.inputs.length > 0) return;
|
|
518
|
+
await this.yieldSlot(member, "waiting", async () => {
|
|
519
|
+
while (this.childrenBusy(member) && member.inputs.length === 0) {
|
|
520
|
+
const version = this.changes.version;
|
|
521
|
+
await this.changes.wait(version, member.controller.signal);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
// Without a parent, final team settlement checks all descendants, including revived assignments.
|
|
526
|
+
childrenBusy(parent) {
|
|
527
|
+
return [...this.instances.values()].some(
|
|
528
|
+
(member) => member !== this.leader && (parent === void 0 || member.parentInstanceId === parent.instanceId) && (["queued", "running", "waiting", "awaiting_interaction"].includes(member.status) || member.inputs.length > 0)
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
async yieldSlot(member, status, work) {
|
|
532
|
+
member.release?.();
|
|
533
|
+
member.release = void 0;
|
|
534
|
+
member.status = status;
|
|
535
|
+
this.memberEvent(member, "agent_waiting");
|
|
536
|
+
this.changes.notify();
|
|
537
|
+
try {
|
|
538
|
+
return await work();
|
|
539
|
+
} finally {
|
|
540
|
+
if (!member.controller.signal.aborted && !this.closed) {
|
|
541
|
+
member.release = await this.slots.acquire(member.controller.signal);
|
|
542
|
+
member.status = "running";
|
|
543
|
+
this.changes.notify();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
identity(member) {
|
|
548
|
+
return {
|
|
549
|
+
teamRunId: this.id,
|
|
550
|
+
instanceId: member.instanceId,
|
|
551
|
+
...member.runId === void 0 ? {} : { runId: member.runId }
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
memberEvent(member, type) {
|
|
555
|
+
this.emit({ type, ...this.identity(member), member: memberSummary(member) });
|
|
556
|
+
}
|
|
557
|
+
agentEvent(member, event) {
|
|
558
|
+
if (this.closed || member.controller.signal.aborted) return;
|
|
559
|
+
this.emit({
|
|
560
|
+
type: "agent_event",
|
|
561
|
+
...this.identity(member),
|
|
562
|
+
coordinator: member === this.leader,
|
|
563
|
+
event: lifecycleSnapshot(event)
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
assertOpen() {
|
|
567
|
+
if (this.fatal !== void 0) throw this.fatal;
|
|
568
|
+
if (this.closed) throw new AgentStreamClosedError();
|
|
569
|
+
throwIfAborted(this.controller.signal);
|
|
570
|
+
}
|
|
571
|
+
fail(error) {
|
|
572
|
+
this.fatal ??= error;
|
|
573
|
+
this.controller.abort(error);
|
|
574
|
+
this.stopMembers();
|
|
575
|
+
this.changes.notify();
|
|
576
|
+
}
|
|
577
|
+
stopMember(member, reason) {
|
|
578
|
+
if (member.status === "cancelled") return;
|
|
579
|
+
member.status = "cancelled";
|
|
580
|
+
member.inputs.length = 0;
|
|
581
|
+
member.controller.abort(reason);
|
|
582
|
+
member.activeRun?.cancel(reason);
|
|
583
|
+
this.memberEvent(member, "agent_cancelled");
|
|
584
|
+
this.changes.notify();
|
|
585
|
+
}
|
|
586
|
+
stopMembers() {
|
|
587
|
+
for (const member of this.instances.values()) {
|
|
588
|
+
if (["queued", "running", "waiting", "awaiting_interaction"].includes(member.status))
|
|
589
|
+
this.stopMember(member, "Agent team closed.");
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
stopDescendants(parent, reason) {
|
|
593
|
+
const stopped = /* @__PURE__ */ new Set([parent.instanceId]);
|
|
594
|
+
for (const member of this.instances.values()) {
|
|
595
|
+
if (member.parentInstanceId !== void 0 && stopped.has(member.parentInstanceId)) {
|
|
596
|
+
stopped.add(member.instanceId);
|
|
597
|
+
this.stopMember(member, reason);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async settleMembers() {
|
|
602
|
+
await Promise.allSettled(
|
|
603
|
+
[...this.instances.values()].flatMap(
|
|
604
|
+
(member) => member.task === void 0 ? [] : [member.task]
|
|
605
|
+
)
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
export {
|
|
611
|
+
TeamRun
|
|
612
|
+
};
|
|
613
|
+
//# sourceMappingURL=chunk-SIYZDPVH.js.map
|