@anvia/core 1.1.1 → 1.2.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 +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-2QZJTG2E.js → chunk-23GEYG2X.js} +11 -71
- package/dist/chunk-23GEYG2X.js.map +1 -0
- 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-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-5AETKC4L.js +107 -0
- package/dist/chunk-5AETKC4L.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-5P2YOQSA.js +355 -0
- package/dist/chunk-5P2YOQSA.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-7F53DOML.js +53 -0
- package/dist/chunk-7F53DOML.js.map +1 -0
- package/dist/chunk-7KAGWJ5M.js +112 -0
- package/dist/chunk-7KAGWJ5M.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-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-B5YTCKUJ.js +158 -0
- package/dist/chunk-B5YTCKUJ.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-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-JB3RFK6K.js +168 -0
- package/dist/chunk-JB3RFK6K.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-JOQ2T3QP.js +663 -0
- package/dist/chunk-JOQ2T3QP.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-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-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-PT777EQ3.js +48 -0
- package/dist/chunk-PT777EQ3.js.map +1 -0
- package/dist/chunk-PYLPLFJZ.js +318 -0
- package/dist/chunk-PYLPLFJZ.js.map +1 -0
- package/dist/chunk-QEPBHHAP.js +41 -0
- package/dist/chunk-QEPBHHAP.js.map +1 -0
- package/dist/chunk-QHGYCYV6.js +91 -0
- package/dist/chunk-QHGYCYV6.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-RXKUIJ77.js +236 -0
- package/dist/chunk-RXKUIJ77.js.map +1 -0
- package/dist/chunk-SC4SUIEY.js +1 -0
- package/dist/chunk-SC4SUIEY.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-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-TSPQD5HW.js +613 -0
- package/dist/chunk-TSPQD5HW.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-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 +3 -37
- package/dist/streaming/index.js.map +1 -1
- package/dist/streaming/readable-stream.js +7 -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 +8 -5
- 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,667 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompletionProviderOutputError
|
|
3
|
+
} from "./chunk-XQV3XNVT.js";
|
|
4
|
+
import {
|
|
5
|
+
Usage
|
|
6
|
+
} from "./chunk-IDNL6IH4.js";
|
|
7
|
+
import {
|
|
8
|
+
isJsonValue
|
|
9
|
+
} from "./chunk-4C7AXYOM.js";
|
|
10
|
+
|
|
11
|
+
// src/completion/stream-accumulator.ts
|
|
12
|
+
var CompletionStreamAccumulator = class {
|
|
13
|
+
orderedParts = [];
|
|
14
|
+
textParts = /* @__PURE__ */ new Map();
|
|
15
|
+
reasoningByKey = /* @__PURE__ */ new Map();
|
|
16
|
+
reasoningKeyById = /* @__PURE__ */ new Map();
|
|
17
|
+
toolCalls = /* @__PURE__ */ new Map();
|
|
18
|
+
sources = /* @__PURE__ */ new Map();
|
|
19
|
+
providerToolCalls = /* @__PURE__ */ new Map();
|
|
20
|
+
finalResponse;
|
|
21
|
+
messageId;
|
|
22
|
+
nextTextKey = 0;
|
|
23
|
+
nextReasoningKey = 0;
|
|
24
|
+
accept(event) {
|
|
25
|
+
if (event.type === "text_delta") {
|
|
26
|
+
if (typeof event.delta !== "string") {
|
|
27
|
+
throw new CompletionProviderOutputError({ kind: "invalid-stream-event" });
|
|
28
|
+
}
|
|
29
|
+
this.appendText(event.delta);
|
|
30
|
+
return { type: "text_delta", delta: event.delta };
|
|
31
|
+
}
|
|
32
|
+
if (event.type === "reasoning_delta") {
|
|
33
|
+
if (typeof event.delta !== "string" || event.id !== void 0 && !isNonblankString(event.id) || event.signature !== void 0 && !isNonblankString(event.signature) || event.contentType !== void 0 && !isReasoningContentType(event.contentType)) {
|
|
34
|
+
throw new CompletionProviderOutputError({ kind: "invalid-stream-event" });
|
|
35
|
+
}
|
|
36
|
+
const reasoning = this.reasoningStateForEvent(event);
|
|
37
|
+
this.appendReasoning(reasoning, event);
|
|
38
|
+
return reasoningDeltaEvent(event);
|
|
39
|
+
}
|
|
40
|
+
if (event.type === "tool_call_delta") {
|
|
41
|
+
if (!isNonblankString(event.id)) {
|
|
42
|
+
throw new CompletionProviderOutputError({ kind: "invalid-tool-call" });
|
|
43
|
+
}
|
|
44
|
+
const toolCall = this.toolCallStateForId(event.id);
|
|
45
|
+
if (toolCall.fullCallSeen) {
|
|
46
|
+
throw new CompletionProviderOutputError({
|
|
47
|
+
kind: "invalid-tool-call",
|
|
48
|
+
toolCallId: toolCall.id
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (event.callId !== void 0) {
|
|
52
|
+
if (!isNonblankString(event.callId)) {
|
|
53
|
+
throw new CompletionProviderOutputError({
|
|
54
|
+
kind: "invalid-tool-call",
|
|
55
|
+
toolCallId: toolCall.id
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (toolCall.callId !== void 0 && toolCall.callId !== event.callId) {
|
|
59
|
+
throw new CompletionProviderOutputError({
|
|
60
|
+
kind: "invalid-tool-call",
|
|
61
|
+
toolCallId: toolCall.id
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
toolCall.callId = event.callId;
|
|
65
|
+
}
|
|
66
|
+
if (event.name !== void 0) {
|
|
67
|
+
if (!isNonblankString(event.name)) {
|
|
68
|
+
throw new CompletionProviderOutputError({
|
|
69
|
+
kind: "invalid-tool-call",
|
|
70
|
+
toolCallId: toolCall.id
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (toolCall.name.length > 0 && toolCall.name !== event.name) {
|
|
74
|
+
throw new CompletionProviderOutputError({
|
|
75
|
+
kind: "invalid-tool-call",
|
|
76
|
+
toolCallId: toolCall.id
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
toolCall.name = event.name;
|
|
80
|
+
}
|
|
81
|
+
if (event.signature !== void 0) {
|
|
82
|
+
if (!isNonblankString(event.signature) || toolCall.signature !== void 0 && toolCall.signature !== event.signature) {
|
|
83
|
+
throw new CompletionProviderOutputError({
|
|
84
|
+
kind: "invalid-tool-call",
|
|
85
|
+
toolCallId: toolCall.id
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
toolCall.signature = event.signature;
|
|
89
|
+
}
|
|
90
|
+
if (event.argumentsMode !== void 0 && event.argumentsMode !== "append" && event.argumentsMode !== "replace") {
|
|
91
|
+
throw new CompletionProviderOutputError({
|
|
92
|
+
kind: "invalid-stream-event",
|
|
93
|
+
toolCallId: toolCall.id
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (event.argumentsMode !== void 0 && event.argumentsDelta === void 0) {
|
|
97
|
+
throw new CompletionProviderOutputError({
|
|
98
|
+
kind: "invalid-stream-event",
|
|
99
|
+
toolCallId: toolCall.id
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (event.argumentsDelta !== void 0) {
|
|
103
|
+
if (typeof event.argumentsDelta !== "string") {
|
|
104
|
+
throw new CompletionProviderOutputError({
|
|
105
|
+
kind: "invalid-tool-arguments",
|
|
106
|
+
toolCallId: toolCall.id
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (event.argumentsMode === "replace") {
|
|
110
|
+
if (toolCall.argumentsText.length > 0 && toolCall.argumentsText !== event.argumentsDelta && (toolCall.argumentsSnapshotSeen || !event.argumentsDelta.startsWith(toolCall.argumentsText))) {
|
|
111
|
+
throw new CompletionProviderOutputError({
|
|
112
|
+
kind: "invalid-tool-call",
|
|
113
|
+
toolCallId: toolCall.id
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
toolCall.argumentsText = event.argumentsDelta;
|
|
117
|
+
toolCall.argumentsSnapshotSeen = true;
|
|
118
|
+
} else {
|
|
119
|
+
if (toolCall.argumentsSnapshotSeen) {
|
|
120
|
+
throw new CompletionProviderOutputError({
|
|
121
|
+
kind: "invalid-tool-call",
|
|
122
|
+
toolCallId: toolCall.id
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
toolCall.argumentsText += event.argumentsDelta;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
if (event.type === "tool_call") {
|
|
131
|
+
this.upsertToolCall(event.toolCall);
|
|
132
|
+
return { type: "tool_call", toolCall: event.toolCall };
|
|
133
|
+
}
|
|
134
|
+
if (event.type === "source") {
|
|
135
|
+
this.sources.set(sourceKey(event.source), event.source);
|
|
136
|
+
return { type: "source", source: event.source };
|
|
137
|
+
}
|
|
138
|
+
if (event.type === "provider_tool_call") {
|
|
139
|
+
this.providerToolCalls.set(event.toolCall.id, event.toolCall);
|
|
140
|
+
return { type: "provider_tool_call", toolCall: event.toolCall };
|
|
141
|
+
}
|
|
142
|
+
if (event.type === "message_id") {
|
|
143
|
+
if (!isNonblankString(event.id)) {
|
|
144
|
+
throw new CompletionProviderOutputError({ kind: "invalid-stream-event" });
|
|
145
|
+
}
|
|
146
|
+
this.messageId = event.id;
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
if (event.type === "final") {
|
|
150
|
+
this.finalResponse = event.response;
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
return void 0;
|
|
154
|
+
}
|
|
155
|
+
response() {
|
|
156
|
+
this.assertAccumulatedFinishReason();
|
|
157
|
+
let accumulatedResponse;
|
|
158
|
+
try {
|
|
159
|
+
accumulatedResponse = this.buildAccumulatedResponse();
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (error instanceof CompletionProviderOutputError && this.finalResponse !== void 0) {
|
|
162
|
+
throw providerOutputErrorWithUsage(error, this.finalResponse.usage);
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
if (this.finalResponse !== void 0) {
|
|
167
|
+
if (accumulatedResponse.choice.length === 0) {
|
|
168
|
+
return this.withAccumulatedArtifacts(this.finalResponse, accumulatedResponse);
|
|
169
|
+
}
|
|
170
|
+
return this.mergeFinalResponse(accumulatedResponse, this.finalResponse);
|
|
171
|
+
}
|
|
172
|
+
return accumulatedResponse;
|
|
173
|
+
}
|
|
174
|
+
assertAccumulatedFinishReason() {
|
|
175
|
+
if (this.finalResponse === void 0) {
|
|
176
|
+
if (this.toolCalls.size === 0) {
|
|
177
|
+
throw new CompletionProviderOutputError({ kind: "incomplete-stream" });
|
|
178
|
+
}
|
|
179
|
+
const toolCallId = this.toolCalls.size === 1 ? this.toolCalls.keys().next().value : void 0;
|
|
180
|
+
throw new CompletionProviderOutputError({
|
|
181
|
+
kind: "incomplete-tool-call",
|
|
182
|
+
toolCallId
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (this.toolCalls.size === 0) return;
|
|
186
|
+
const finishReason = this.finalResponse.finishReason;
|
|
187
|
+
if (finishReason === "length") {
|
|
188
|
+
throw new CompletionProviderOutputError({
|
|
189
|
+
kind: "truncated-tool-call",
|
|
190
|
+
finishReason,
|
|
191
|
+
usage: this.finalResponse.usage
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (finishReason === "content-filter") {
|
|
195
|
+
throw new CompletionProviderOutputError({
|
|
196
|
+
kind: "filtered-tool-call",
|
|
197
|
+
finishReason,
|
|
198
|
+
usage: this.finalResponse.usage
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (finishReason !== void 0 && finishReason !== "stop" && finishReason !== "tool-calls") {
|
|
202
|
+
throw new CompletionProviderOutputError({
|
|
203
|
+
kind: "invalid-tool-call",
|
|
204
|
+
usage: this.finalResponse.usage
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
buildAccumulatedResponse() {
|
|
209
|
+
const choice = [];
|
|
210
|
+
for (const part of this.orderedParts) {
|
|
211
|
+
if (part.type === "text") {
|
|
212
|
+
const text = this.textParts.get(part.key) ?? "";
|
|
213
|
+
if (text.length > 0) {
|
|
214
|
+
choice.push({ type: "text", text });
|
|
215
|
+
}
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (part.type === "reasoning") {
|
|
219
|
+
const reasoning = this.reasoningByKey.get(part.key);
|
|
220
|
+
if (reasoning !== void 0) {
|
|
221
|
+
choice.push(reasoningContent(reasoning));
|
|
222
|
+
}
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const toolCall = this.toolCalls.get(part.key);
|
|
226
|
+
if (toolCall !== void 0) {
|
|
227
|
+
choice.push(toolCallContent(toolCall));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const response = {
|
|
231
|
+
choice,
|
|
232
|
+
usage: Usage.empty(),
|
|
233
|
+
rawResponse: void 0
|
|
234
|
+
};
|
|
235
|
+
if (this.messageId !== void 0) {
|
|
236
|
+
response.messageId = this.messageId;
|
|
237
|
+
}
|
|
238
|
+
const sources = [...this.sources.values()];
|
|
239
|
+
if (sources.length > 0) {
|
|
240
|
+
response.sources = sources;
|
|
241
|
+
}
|
|
242
|
+
const providerToolCalls = [...this.providerToolCalls.values()];
|
|
243
|
+
if (providerToolCalls.length > 0) {
|
|
244
|
+
response.providerToolCalls = providerToolCalls;
|
|
245
|
+
}
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
248
|
+
upsertToolCall(toolCall) {
|
|
249
|
+
if (!isNonblankString(toolCall.toolCallId) || !isNonblankString(toolCall.toolName) || toolCall.callId !== void 0 && !isNonblankString(toolCall.callId) || toolCall.signature !== void 0 && !isNonblankString(toolCall.signature)) {
|
|
250
|
+
throw new CompletionProviderOutputError({
|
|
251
|
+
kind: "invalid-tool-call",
|
|
252
|
+
toolCallId: isNonblankString(toolCall.toolCallId) ? toolCall.toolCallId : void 0
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (!isJsonValue(toolCall.input)) {
|
|
256
|
+
throw new CompletionProviderOutputError({
|
|
257
|
+
kind: "invalid-tool-arguments",
|
|
258
|
+
toolCallId: toolCall.toolCallId
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const existing = this.toolCalls.get(toolCall.toolCallId);
|
|
262
|
+
if (existing !== void 0) {
|
|
263
|
+
if (existing.fullCallSeen) {
|
|
264
|
+
throw new CompletionProviderOutputError({
|
|
265
|
+
kind: "invalid-tool-call",
|
|
266
|
+
toolCallId: toolCall.toolCallId
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (existing.name.length > 0 && existing.name !== toolCall.toolName || existing.callId !== void 0 && existing.callId !== toolCall.callId || existing.signature !== void 0 && toolCall.signature !== void 0 && existing.signature !== toolCall.signature) {
|
|
270
|
+
throw new CompletionProviderOutputError({
|
|
271
|
+
kind: "invalid-tool-call",
|
|
272
|
+
toolCallId: toolCall.toolCallId
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (existing.argumentsText.length > 0) {
|
|
276
|
+
const accumulatedInput = parseToolArguments(existing.id, existing.argumentsText);
|
|
277
|
+
if (!jsonValuesEqual(accumulatedInput, toolCall.input)) {
|
|
278
|
+
throw new CompletionProviderOutputError({
|
|
279
|
+
kind: "invalid-tool-call",
|
|
280
|
+
toolCallId: toolCall.toolCallId
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!this.toolCalls.has(toolCall.toolCallId)) {
|
|
286
|
+
this.orderedParts.push({ type: "tool_call", key: toolCall.toolCallId });
|
|
287
|
+
}
|
|
288
|
+
const partial = {
|
|
289
|
+
id: toolCall.toolCallId,
|
|
290
|
+
name: toolCall.toolName,
|
|
291
|
+
argumentsText: JSON.stringify(toolCall.input),
|
|
292
|
+
argumentsSnapshotSeen: true,
|
|
293
|
+
fullCallSeen: true
|
|
294
|
+
};
|
|
295
|
+
if (toolCall.callId !== void 0) {
|
|
296
|
+
partial.callId = toolCall.callId;
|
|
297
|
+
}
|
|
298
|
+
const signature = toolCall.signature ?? existing?.signature;
|
|
299
|
+
if (signature !== void 0) {
|
|
300
|
+
partial.signature = signature;
|
|
301
|
+
}
|
|
302
|
+
this.toolCalls.set(toolCall.toolCallId, partial);
|
|
303
|
+
}
|
|
304
|
+
mergeFinalResponse(accumulatedResponse, finalResponse) {
|
|
305
|
+
if (finalResponse.choice.length === 0) {
|
|
306
|
+
const mergedResponse = {
|
|
307
|
+
...accumulatedResponse,
|
|
308
|
+
usage: finalResponse.usage,
|
|
309
|
+
rawResponse: finalResponse.rawResponse
|
|
310
|
+
};
|
|
311
|
+
if (finalResponse.finishReason !== void 0) {
|
|
312
|
+
mergedResponse.finishReason = finalResponse.finishReason;
|
|
313
|
+
}
|
|
314
|
+
if (finalResponse.providerFinishReason !== void 0) {
|
|
315
|
+
mergedResponse.providerFinishReason = finalResponse.providerFinishReason;
|
|
316
|
+
}
|
|
317
|
+
if (finalResponse.messageId !== void 0) {
|
|
318
|
+
mergedResponse.messageId = finalResponse.messageId;
|
|
319
|
+
}
|
|
320
|
+
return this.withAccumulatedArtifacts(mergedResponse, accumulatedResponse);
|
|
321
|
+
}
|
|
322
|
+
const accumulatedNonTool = accumulatedResponse.choice.filter(
|
|
323
|
+
(content) => content.type !== "tool-call"
|
|
324
|
+
);
|
|
325
|
+
const finalNonTool = finalResponse.choice.filter((content) => content.type !== "tool-call");
|
|
326
|
+
if (accumulatedNonTool.length > 0 && !nonToolPartsEqual(accumulatedNonTool, finalNonTool)) {
|
|
327
|
+
throw new CompletionProviderOutputError({
|
|
328
|
+
kind: "invalid-stream-event",
|
|
329
|
+
usage: finalResponse.usage
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
const accumulatedById = /* @__PURE__ */ new Map();
|
|
333
|
+
const accumulatedByCallId = /* @__PURE__ */ new Map();
|
|
334
|
+
for (const content of accumulatedResponse.choice) {
|
|
335
|
+
if (content.type !== "tool-call") continue;
|
|
336
|
+
accumulatedById.set(content.toolCallId, content);
|
|
337
|
+
if (content.callId !== void 0) accumulatedByCallId.set(content.callId, content);
|
|
338
|
+
}
|
|
339
|
+
const matchedAccumulatedToolCalls = /* @__PURE__ */ new Set();
|
|
340
|
+
const choice = finalResponse.choice.map((content) => {
|
|
341
|
+
if (content.type !== "tool-call") return content;
|
|
342
|
+
const accumulated = accumulatedById.get(content.toolCallId);
|
|
343
|
+
if (accumulated === void 0) {
|
|
344
|
+
const changedIdentity = content.callId === void 0 ? void 0 : accumulatedByCallId.get(content.callId);
|
|
345
|
+
if (changedIdentity !== void 0) {
|
|
346
|
+
throw new CompletionProviderOutputError({
|
|
347
|
+
kind: "invalid-tool-call",
|
|
348
|
+
toolCallId: changedIdentity.toolCallId,
|
|
349
|
+
usage: finalResponse.usage
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
return content;
|
|
353
|
+
}
|
|
354
|
+
matchedAccumulatedToolCalls.add(accumulated);
|
|
355
|
+
return mergeFinalToolCall(accumulated, content, finalResponse.usage);
|
|
356
|
+
});
|
|
357
|
+
for (const accumulated of accumulatedById.values()) {
|
|
358
|
+
if (!matchedAccumulatedToolCalls.has(accumulated)) {
|
|
359
|
+
throw new CompletionProviderOutputError({
|
|
360
|
+
kind: "invalid-tool-call",
|
|
361
|
+
toolCallId: accumulated.toolCallId,
|
|
362
|
+
usage: finalResponse.usage
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return this.withAccumulatedArtifacts({ ...finalResponse, choice }, accumulatedResponse);
|
|
367
|
+
}
|
|
368
|
+
appendText(delta) {
|
|
369
|
+
const lastPart = this.orderedParts.at(-1);
|
|
370
|
+
const key = lastPart?.type === "text" ? lastPart.key : this.createTextKey();
|
|
371
|
+
if (lastPart?.type !== "text") {
|
|
372
|
+
this.orderedParts.push({ type: "text", key });
|
|
373
|
+
}
|
|
374
|
+
this.textParts.set(key, `${this.textParts.get(key) ?? ""}${delta}`);
|
|
375
|
+
}
|
|
376
|
+
reasoningStateForEvent(event) {
|
|
377
|
+
if (event.id !== void 0) {
|
|
378
|
+
const existingKey = this.reasoningKeyById.get(event.id);
|
|
379
|
+
if (existingKey !== void 0) {
|
|
380
|
+
const existing = this.reasoningByKey.get(existingKey);
|
|
381
|
+
if (existing !== void 0) {
|
|
382
|
+
return existing;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const key2 = this.createReasoningKey();
|
|
386
|
+
const reasoning2 = { id: event.id, text: "" };
|
|
387
|
+
this.reasoningKeyById.set(event.id, key2);
|
|
388
|
+
this.reasoningByKey.set(key2, reasoning2);
|
|
389
|
+
this.orderedParts.push({ type: "reasoning", key: key2 });
|
|
390
|
+
return reasoning2;
|
|
391
|
+
}
|
|
392
|
+
const lastPart = this.orderedParts.at(-1);
|
|
393
|
+
if (lastPart?.type === "reasoning") {
|
|
394
|
+
const lastReasoning = this.reasoningByKey.get(lastPart.key);
|
|
395
|
+
if (lastReasoning !== void 0 && lastReasoning.id === void 0) {
|
|
396
|
+
return lastReasoning;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const key = this.createReasoningKey();
|
|
400
|
+
const reasoning = { text: "" };
|
|
401
|
+
this.reasoningByKey.set(key, reasoning);
|
|
402
|
+
this.orderedParts.push({ type: "reasoning", key });
|
|
403
|
+
return reasoning;
|
|
404
|
+
}
|
|
405
|
+
toolCallStateForId(id) {
|
|
406
|
+
const existing = this.toolCalls.get(id);
|
|
407
|
+
if (existing !== void 0) {
|
|
408
|
+
return existing;
|
|
409
|
+
}
|
|
410
|
+
const toolCall = {
|
|
411
|
+
id,
|
|
412
|
+
name: "",
|
|
413
|
+
argumentsText: "",
|
|
414
|
+
argumentsSnapshotSeen: false,
|
|
415
|
+
fullCallSeen: false
|
|
416
|
+
};
|
|
417
|
+
this.toolCalls.set(id, toolCall);
|
|
418
|
+
this.orderedParts.push({ type: "tool_call", key: id });
|
|
419
|
+
return toolCall;
|
|
420
|
+
}
|
|
421
|
+
withMessageIdFallback(response, accumulatedResponse) {
|
|
422
|
+
if (response.messageId !== void 0 || accumulatedResponse.messageId === void 0) {
|
|
423
|
+
return response;
|
|
424
|
+
}
|
|
425
|
+
return { ...response, messageId: accumulatedResponse.messageId };
|
|
426
|
+
}
|
|
427
|
+
withAccumulatedArtifacts(response, accumulatedResponse) {
|
|
428
|
+
const withMessageId = this.withMessageIdFallback(response, accumulatedResponse);
|
|
429
|
+
const sources = mergeSources(accumulatedResponse.sources, response.sources);
|
|
430
|
+
const providerToolCalls = mergeProviderToolCalls(
|
|
431
|
+
accumulatedResponse.providerToolCalls,
|
|
432
|
+
response.providerToolCalls
|
|
433
|
+
);
|
|
434
|
+
let accumulated = { ...withMessageId };
|
|
435
|
+
if (sources.length > 0) accumulated = { ...accumulated, sources };
|
|
436
|
+
if (providerToolCalls.length > 0) {
|
|
437
|
+
accumulated = { ...accumulated, providerToolCalls };
|
|
438
|
+
}
|
|
439
|
+
return accumulated;
|
|
440
|
+
}
|
|
441
|
+
createTextKey() {
|
|
442
|
+
this.nextTextKey += 1;
|
|
443
|
+
return `text_${this.nextTextKey.toString()}`;
|
|
444
|
+
}
|
|
445
|
+
createReasoningKey() {
|
|
446
|
+
this.nextReasoningKey += 1;
|
|
447
|
+
return `reasoning_${this.nextReasoningKey.toString()}`;
|
|
448
|
+
}
|
|
449
|
+
appendReasoning(reasoning, event) {
|
|
450
|
+
const contentType = event.contentType ?? "text";
|
|
451
|
+
if (contentType === "text" || contentType === "summary") {
|
|
452
|
+
reasoning.text += event.delta;
|
|
453
|
+
}
|
|
454
|
+
if (event.contentType === void 0 && event.signature === void 0) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
reasoning.details ??= [];
|
|
458
|
+
const last = reasoning.details.at(-1);
|
|
459
|
+
if (contentType === "text") {
|
|
460
|
+
if (last?.type === "text") {
|
|
461
|
+
let detail = {
|
|
462
|
+
...last,
|
|
463
|
+
text: `${last.text}${event.delta}`
|
|
464
|
+
};
|
|
465
|
+
if (event.signature !== void 0) detail = { ...detail, signature: event.signature };
|
|
466
|
+
reasoning.details[reasoning.details.length - 1] = detail;
|
|
467
|
+
} else {
|
|
468
|
+
reasoning.details.push(
|
|
469
|
+
event.signature === void 0 ? { type: "text", text: event.delta } : { type: "text", text: event.delta, signature: event.signature }
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (contentType === "summary") {
|
|
475
|
+
if (last?.type === "summary") {
|
|
476
|
+
reasoning.details[reasoning.details.length - 1] = {
|
|
477
|
+
...last,
|
|
478
|
+
text: `${last.text}${event.delta}`
|
|
479
|
+
};
|
|
480
|
+
} else {
|
|
481
|
+
reasoning.details.push({ type: "summary", text: event.delta });
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (contentType === "encrypted") {
|
|
486
|
+
reasoning.details.push({ type: "encrypted", data: event.delta });
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
reasoning.details.push({ type: "redacted", data: event.delta });
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
function sourceKey(source) {
|
|
493
|
+
return `${source.url}\0${source.startIndex ?? ""}\0${source.endIndex ?? ""}`;
|
|
494
|
+
}
|
|
495
|
+
function mergeSources(accumulated, final) {
|
|
496
|
+
const sources = /* @__PURE__ */ new Map();
|
|
497
|
+
for (const source of [...accumulated ?? [], ...final ?? []]) {
|
|
498
|
+
sources.set(sourceKey(source), source);
|
|
499
|
+
}
|
|
500
|
+
return [...sources.values()];
|
|
501
|
+
}
|
|
502
|
+
function mergeProviderToolCalls(accumulated, final) {
|
|
503
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
504
|
+
for (const toolCall of [...accumulated ?? [], ...final ?? []]) {
|
|
505
|
+
toolCalls.set(toolCall.id, toolCall);
|
|
506
|
+
}
|
|
507
|
+
return [...toolCalls.values()];
|
|
508
|
+
}
|
|
509
|
+
function reasoningContent(reasoning) {
|
|
510
|
+
const content = reasoning.details === void 0 ? { type: "reasoning", text: reasoning.text } : { type: "reasoning", text: reasoning.text, details: reasoning.details };
|
|
511
|
+
return reasoning.id === void 0 ? content : { ...content, id: reasoning.id };
|
|
512
|
+
}
|
|
513
|
+
function toolCallContent(toolCall) {
|
|
514
|
+
const argumentsValue = parseToolArguments(toolCall.id, toolCall.argumentsText);
|
|
515
|
+
let content = {
|
|
516
|
+
type: "tool-call",
|
|
517
|
+
toolCallId: toolCall.id,
|
|
518
|
+
toolName: toolCall.name,
|
|
519
|
+
input: argumentsValue
|
|
520
|
+
};
|
|
521
|
+
if (toolCall.callId !== void 0) content = { ...content, callId: toolCall.callId };
|
|
522
|
+
if (toolCall.signature !== void 0) content = { ...content, signature: toolCall.signature };
|
|
523
|
+
return content;
|
|
524
|
+
}
|
|
525
|
+
function mergeFinalToolCall(accumulated, finalToolCall, usage) {
|
|
526
|
+
if (finalToolCall.toolCallId !== accumulated.toolCallId || finalToolCall.toolName !== accumulated.toolName || accumulated.callId !== void 0 && finalToolCall.callId !== accumulated.callId || accumulated.signature !== void 0 && finalToolCall.signature !== void 0 && finalToolCall.signature !== accumulated.signature) {
|
|
527
|
+
throw new CompletionProviderOutputError({
|
|
528
|
+
kind: "invalid-tool-call",
|
|
529
|
+
toolCallId: accumulated.toolCallId,
|
|
530
|
+
usage
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
if (!isJsonValue(finalToolCall.input)) {
|
|
534
|
+
throw new CompletionProviderOutputError({
|
|
535
|
+
kind: "invalid-tool-arguments",
|
|
536
|
+
toolCallId: accumulated.toolCallId,
|
|
537
|
+
usage
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if (!jsonValuesEqual(accumulated.input, finalToolCall.input)) {
|
|
541
|
+
throw new CompletionProviderOutputError({
|
|
542
|
+
kind: "invalid-tool-call",
|
|
543
|
+
toolCallId: accumulated.toolCallId,
|
|
544
|
+
usage
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
let merged = {
|
|
548
|
+
type: "tool-call",
|
|
549
|
+
toolCallId: finalToolCall.toolCallId,
|
|
550
|
+
toolName: finalToolCall.toolName,
|
|
551
|
+
input: accumulated.input
|
|
552
|
+
};
|
|
553
|
+
const callId = finalToolCall.callId ?? accumulated.callId;
|
|
554
|
+
if (callId !== void 0) merged = { ...merged, callId };
|
|
555
|
+
const signature = finalToolCall.signature ?? accumulated.signature;
|
|
556
|
+
if (signature !== void 0) merged = { ...merged, signature };
|
|
557
|
+
return merged;
|
|
558
|
+
}
|
|
559
|
+
function reasoningDeltaEvent(event) {
|
|
560
|
+
const mapped = { type: "reasoning_delta", delta: event.delta };
|
|
561
|
+
if (event.id !== void 0) mapped.id = event.id;
|
|
562
|
+
if (event.contentType !== void 0) mapped.contentType = event.contentType;
|
|
563
|
+
if (event.signature !== void 0) mapped.signature = event.signature;
|
|
564
|
+
return mapped;
|
|
565
|
+
}
|
|
566
|
+
function parseToolArguments(toolCallId, text) {
|
|
567
|
+
let value;
|
|
568
|
+
try {
|
|
569
|
+
value = JSON.parse(text);
|
|
570
|
+
} catch {
|
|
571
|
+
throw new CompletionProviderOutputError({
|
|
572
|
+
kind: "malformed-tool-arguments",
|
|
573
|
+
toolCallId
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if (!isJsonValue(value)) {
|
|
577
|
+
throw new CompletionProviderOutputError({
|
|
578
|
+
kind: "invalid-tool-arguments",
|
|
579
|
+
toolCallId
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
return value;
|
|
583
|
+
}
|
|
584
|
+
function jsonValuesEqual(left, right) {
|
|
585
|
+
if (left === right) {
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
if (left === null || right === null || typeof left !== "object" || typeof right !== "object") {
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
if (isJsonArray(left) || isJsonArray(right)) {
|
|
592
|
+
if (!isJsonArray(left) || !isJsonArray(right) || left.length !== right.length) {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
return left.every((value, index) => {
|
|
596
|
+
const rightValue = right[index];
|
|
597
|
+
return rightValue !== void 0 && jsonValuesEqual(value, rightValue);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
const leftKeys = Object.keys(left);
|
|
601
|
+
const rightKeys = Object.keys(right);
|
|
602
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
for (const key of leftKeys) {
|
|
606
|
+
if (!Object.hasOwn(right, key)) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
const leftValue = left[key];
|
|
610
|
+
const rightValue = right[key];
|
|
611
|
+
if (leftValue === void 0 || rightValue === void 0 || !jsonValuesEqual(leftValue, rightValue)) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return true;
|
|
616
|
+
}
|
|
617
|
+
function nonToolPartsEqual(accumulated, final) {
|
|
618
|
+
if (accumulated.length !== final.length) return false;
|
|
619
|
+
if (!isJsonValue(accumulated) || !isJsonValue(final)) return false;
|
|
620
|
+
const unmatched = [...final];
|
|
621
|
+
for (const part of accumulated) {
|
|
622
|
+
const index = unmatched.findIndex((candidate) => jsonValuesEqual(part, candidate));
|
|
623
|
+
if (index < 0) return false;
|
|
624
|
+
unmatched.splice(index, 1);
|
|
625
|
+
}
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
function isJsonArray(value) {
|
|
629
|
+
return Array.isArray(value);
|
|
630
|
+
}
|
|
631
|
+
function providerOutputErrorWithUsage(error, usage) {
|
|
632
|
+
const shared = { usage };
|
|
633
|
+
if (error.toolCallId !== void 0) shared.toolCallId = error.toolCallId;
|
|
634
|
+
if (error.kind === "truncated-tool-call") {
|
|
635
|
+
return new CompletionProviderOutputError({
|
|
636
|
+
...shared,
|
|
637
|
+
kind: error.kind,
|
|
638
|
+
finishReason: "length"
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
if (error.kind === "filtered-tool-call") {
|
|
642
|
+
return new CompletionProviderOutputError({
|
|
643
|
+
...shared,
|
|
644
|
+
kind: error.kind,
|
|
645
|
+
finishReason: "content-filter"
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
if (error.finishReason === "length" || error.finishReason === "content-filter") {
|
|
649
|
+
throw error;
|
|
650
|
+
}
|
|
651
|
+
return new CompletionProviderOutputError({
|
|
652
|
+
...shared,
|
|
653
|
+
kind: error.kind,
|
|
654
|
+
finishReason: error.finishReason
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function isNonblankString(value) {
|
|
658
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
659
|
+
}
|
|
660
|
+
function isReasoningContentType(value) {
|
|
661
|
+
return value === "text" || value === "summary" || value === "encrypted" || value === "redacted";
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
export {
|
|
665
|
+
CompletionStreamAccumulator
|
|
666
|
+
};
|
|
667
|
+
//# sourceMappingURL=chunk-UTAB3XQI.js.map
|