@agimon-ai/po-cloudflare 0.0.2-alpha.2 → 0.0.2-alpha.21
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 +4 -3
- package/dist/abort-signals-2GUraIGq.js +34 -0
- package/dist/agent-DZ-OKOHn.js +6850 -0
- package/dist/anthropic-messages-5ODquUB-.js +14317 -0
- package/dist/{apiContracts-CHOiCbS_.js → apiContracts-b33nSAAI.js} +18 -81
- package/dist/{approval-BMXqnTYd.js → approval-r3NnI1VC.js} +19 -3
- package/dist/{approvalPrompt-Bg1JrEEY.js → approvalPrompt-DWoXxu3S.js} +2 -2
- package/dist/artifactFiles-DLCReI0-.js +1 -0
- package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-XeNS0L9M.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-B6ZW0nkR.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-bVR64sHO.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53-D7tZz3io.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-DdwScfiX.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-DgSxZJCV.js} +2 -2
- package/dist/assets/assets/channel-TPcVvp_3.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-D5TXC2SM.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T-BWhOSvo1.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-HkkBzLtZ.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-CBnjycLU.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-75lIIq8T.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-D8PpnXMk.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-CXRS2NIN.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-BocUqS94.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-CHf_ogYT.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-DrW1PaIv.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-CLoA7bFm.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-BmBsrj9I.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-iFE4Tl8c.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-DShE_cgv.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-B3oLvSXy.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-B14vKK7C.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-Da8elIW2.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-Du4tGtiJ.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-Cyj6i_WI.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-DFWXwO7A.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-C1wB_cf-.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-MYCOBYl6.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-BFYbKUFf.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-6siqTpv_.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-CaBr9CoB.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-DAvmuDpc.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-CJnhgCpo.js} +2 -2
- package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-BQ4W1R18.js} +2 -2
- package/dist/assets/assets/{dist-DvgCCshF.js → dist-BnzFckPF.js} +2 -2
- package/dist/assets/assets/{dist-gfbb4ygy.js → dist-CFtBpcYL.js} +2 -2
- package/dist/assets/assets/{dist-BabjcJ3j.js → dist-CIQX1z4W.js} +2 -2
- package/dist/assets/assets/{dist-XIZum9n5.js → dist-ChHYoe9_.js} +2 -2
- package/dist/assets/assets/{dist-1-mhYUBH.js → dist-DKxZO8d9.js} +2 -2
- package/dist/assets/assets/{dist-h6SOnP8-.js → dist-DL6z28wl.js} +2 -2
- package/dist/assets/assets/{dist-B3JXhDWV.js → dist-DNyn1p9Z.js} +2 -2
- package/dist/assets/assets/{dist-Izr2SB3q.js → dist-qYlLXIa8.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-AUcqDTM3.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-aA10PEHJ.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-hhYiqA-x.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-BQZqbRo5.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BuyysPYC.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-CLON1GpW.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-DbmvNwR2.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-DJVO0WlL.js} +2 -2
- package/dist/assets/assets/index-BiTVAj5E.js +155 -0
- package/dist/assets/assets/index-CBNQEGK3.css +1 -0
- package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-CAt3Nt3g.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-DTuqH-Zb.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-BnWvdonT.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-Btxtcgvl.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-q7ek9o_H.js} +2 -2
- package/dist/assets/assets/{line-BsXJZn93.js → line-B7yLilmC.js} +2 -2
- package/dist/assets/assets/{linear-BHYaD5T0.js → linear-y8aSKEli.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-B4rH50nD.js} +4 -4
- package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-DnRVHTjE.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-DT9Afs2v.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-CnqNbu4p.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-cvxdBBFq.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-etXMNsaL.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-CBN-R3_j.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-C5jjVPIH.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-CAMd_mrV.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-DIs3auoe.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-CJXr1qWy.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-DfwtykqI.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-B8beAhTs.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-BDcQE-EL.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-KJ4-QjZM.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-VjIB-Ybr.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-MfMuWq1M.js} +2 -2
- package/dist/assets/assets/{src-gihY33R9.js → src-BAxIj8GJ.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-mHwLRRCY.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-PArlYoqV.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-The09-5S.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-B2nKiNFU.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-gU23_RuI.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-CiqoMvZa.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-DpeoWpMK.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-C31iGKvM.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-CIzHhzNw.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-DIIkoezc.js} +2 -2
- package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-RFseiMZW.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-QiHL91kC.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +2 -2
- package/dist/assets/plugins/assets/base-CKKRZ7-h.css +2 -0
- package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
- package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
- package/dist/assets/plugins/chunks/po-web-runtime-BJDT6Lbw.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -0
- package/dist/assets/plugins/slots/approval.293d9a00-BXIhaPlQ.js +2 -0
- package/dist/assets/plugins/slots/artifacts.24567664-ZzR0gbvy.js +1 -0
- package/dist/assets/plugins/slots/author.0998a880-DAbA-7rb.js +93 -0
- package/dist/assets/plugins/slots/autocompact.dd97d013-IVq4Z6qm.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.36d7400b-CpCLjRRN.js +7 -0
- package/dist/assets/plugins/slots/codemode.8eaee717-VWt9PqsU.js +10 -0
- package/dist/assets/plugins/slots/domain.5e95fc37-5PIUBqDe.js +1 -0
- package/dist/assets/plugins/slots/edit.385c9aa9-DNAjPNG5.js +7 -0
- package/dist/assets/plugins/slots/files.daf34ed8-CQaTz0i1.js +2 -0
- package/dist/assets/plugins/slots/goal.77ec9930-B8EkarBq.js +1 -0
- package/dist/assets/plugins/slots/grep.02052cdc-CIRhO2gY.js +1 -0
- package/dist/assets/plugins/slots/help.ecd4c0f9-naMF9NN1.js +3 -0
- package/dist/assets/plugins/slots/log.a86eb6d0-D5__rAZJ.js +4 -0
- package/dist/assets/plugins/slots/mcp.974af249-DPNHn9XH.js +109 -0
- package/dist/assets/plugins/slots/plan.bafb8f68-C5GEpybF.js +3 -0
- package/dist/assets/plugins/slots/profile.48851a1d-yX6tzV3x.js +1 -0
- package/dist/assets/plugins/slots/prompts.723d7748-B7zpPeoF.js +3 -0
- package/dist/assets/plugins/slots/read.46bf6536-Cw5Z5z5T.js +1 -0
- package/dist/assets/plugins/slots/runner.53e9bd76-CiQR_FPX.js +8 -0
- package/dist/assets/plugins/slots/skill.086701a4-CL6h_F-x.js +4 -0
- package/dist/assets/plugins/slots/vault.ac9935c8-DKERQYg4.js +1 -0
- package/dist/assets/plugins/slots/voice.e85ca7f9-DEgb-U9m.js +1 -0
- package/dist/assets/pwa/pwa.js +12 -12
- package/dist/assets/pwa/sw.js +4 -4
- package/dist/{atomicJson-BJfPFSYF.js → atomicJson-C_7F2zD1.js} +2 -3
- package/dist/azure-openai-config-COZUaRzM.js +55 -0
- package/dist/azure-openai-responses-Cs4k2HOd.js +183 -0
- package/dist/{backgroundWork-CeFrbRnj.js → backgroundWork-B1mPDYlf.js} +1 -1
- package/dist/browser-BWf8OMfl.js +3 -0
- package/dist/childSession-Cf2-kH4O.js +22 -0
- package/dist/classifier-shared-IhSH9hhh.js +106 -0
- package/dist/cloudflare-workers-ai-system-one-BNnc8MuH.js +52 -0
- package/dist/{codemode-DbPu0yJN.js → codemode-DQFmrosw.js} +5 -2
- package/dist/contracts-DD3f1Lpn.js +19 -0
- package/dist/diagnostics-1lYFeSJe.js +131 -0
- package/dist/{server-D3PQk1Gt.js → dist-B-vqs6tA.js} +1 -546
- package/dist/dist-Dvx5mlIR.js +50 -0
- package/dist/env-api-keys-Bow6MJe2.js +32 -0
- package/dist/error-body-CJk7jMUh.js +102 -0
- package/dist/esm-BKJy3O9-.js +1553 -0
- package/dist/exports-B0WMEXCP.js +34 -0
- package/dist/{remoteMcp-CMqZldeA.js → exports-D09VsUk-.js} +1153 -175
- package/dist/{exports-BNZz2DNU.js → exports-nV43ShA7.js} +25 -9
- package/dist/{extensionFile-CXOa5G4C.js → extensionFile-DNM4xsje.js} +26 -2
- package/dist/github-copilot-headers-D1RedfLn.js +22 -0
- package/dist/google-generative-ai-DXTILNT0.js +328 -0
- package/dist/google-shared-e4JDCTVP.js +19588 -0
- package/dist/google-vertex-a1lzvJfq.js +374 -0
- package/dist/{domains-BNjGTOPj.js → harnessState-Dwrk3lfv.js} +175 -16
- package/dist/{harnessStore-BT706Ly6.js → harnessStore-Z7yDLO45.js} +4 -5
- package/dist/hash-Dt6RIbkn.js +16 -0
- package/dist/headers-CwtEVQvr.js +17 -0
- package/dist/help-w6vVEZGL.js +101 -0
- package/dist/hubChannel-Cm-sxOvU.js +21 -0
- package/dist/hubRevisions-58pU2dW5.js +363 -0
- package/dist/identity-BgfHobJH.js +165 -0
- package/dist/index.edge-COJJ_Dv2.js +937 -0
- package/dist/index.edge-ChYa2LU4.js +14 -0
- package/dist/index.edge-ClLTmPFz.js +191 -0
- package/dist/index.edge-DyYmurS7.js +62 -0
- package/dist/index.edge-K0w5auwG.js +56 -0
- package/dist/index.edge-Xa5LLtxz.js +67 -0
- package/dist/iso-BPQViXM8.js +10 -0
- package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-CUkYUs1f.js} +193 -15
- package/dist/{majorModes-DbCfLZH3.js → majorModes-BB0PXgFn.js} +4 -14
- package/dist/majorModes-C7vtBs4D.js +1 -0
- package/dist/{mcpProjection-BsP0IEnb.js → mcpProjection-BtKzB6oK.js} +2 -2
- package/dist/migrations-5gbLIQIc.js +32 -0
- package/dist/mistral-conversations-CLwhVDjA.js +689 -0
- package/dist/modeDefinition-C3Zbrw48.js +44 -0
- package/dist/models-Chzm15vC.js +1511 -0
- package/dist/narration-CpRurWLO.js +127 -0
- package/dist/node-BT4GsJQp.js +2479 -0
- package/dist/node-DytJOfYf.js +23 -0
- package/dist/notification-kckG3leF.js +102 -0
- package/dist/openai-codex-responses-DRMONxDE.js +1210 -0
- package/dist/openai-completions-CcNhAv8l.js +984 -0
- package/dist/openai-decisions-BsFjaAGw.js +142 -0
- package/dist/openai-kPrtlgjl.js +17357 -0
- package/dist/openai-prompt-cache-Bc6qNWt0.js +8 -0
- package/dist/openai-responses-C5Gp2UOV.js +281 -0
- package/dist/openai-responses-shared-BbSi-wBR.js +661 -0
- package/dist/openrouter-cost-CvC52g3b.js +30 -0
- package/dist/openrouter-images-BoHl8g8p.js +124 -0
- package/dist/{hubChannel-BHQyzcOo.js → packageApi-t1oCjNDU.js} +4 -41
- package/dist/photon_rs_bg.wasm +0 -0
- package/dist/pi-messages-BXfrZLC7.js +312 -0
- package/dist/piConfig-DQzlbPY4.js +126 -0
- package/dist/piSettings-Cf1QofNe.js +1 -0
- package/dist/platform-BIEiM4TG.js +113 -0
- package/dist/pluginContributions-Be9EnCAW.js +16 -0
- package/dist/pluginProtocol-BqXXyI4z.js +80 -0
- package/dist/{protocol-Xpm_mCNN.js → protocol-DDL8geoS.js} +2 -2
- package/dist/provider-env-CxhHUFiF.js +38 -0
- package/dist/provider-retry-BUoezuw8.js +79 -0
- package/dist/sanitize-unicode-C3Ec8oL6.js +26 -0
- package/dist/sealedChannel-BeWNTWys.js +27 -0
- package/dist/server-AbXyhXlY.js +217 -0
- package/dist/server-B6dqQoh2.js +1518 -0
- package/dist/server-BIHo9TFu.js +505 -0
- package/dist/{server-BZh1ZXz_.js → server-BJ7DNzCp.js} +8 -19
- package/dist/server-BO-j_GbD.js +15106 -0
- package/dist/{server-D4W7EdJY.js → server-BQzAiMns.js} +16 -16
- package/dist/server-BR7SZtj7.js +3125 -0
- package/dist/{server-BE6VqEiA.js → server-BT2ORK83.js} +20 -12
- package/dist/server-BbSHYRnY.js +295 -0
- package/dist/server-BqoKlEGk.js +1806 -0
- package/dist/{server-tvgQ99rv.js → server-Busl0pQI.js} +370 -120
- package/dist/server-CIHM4jqu.js +1116 -0
- package/dist/server-CgWSSdvd.js +576 -0
- package/dist/{server-Dpgh8PDh.js → server-Co_UWKrR.js} +14 -5
- package/dist/{server-BAAL9-NA.js → server-CuEPb7u-.js} +3 -10
- package/dist/{server-Dt4y1rZD.js → server-D40q2Jpx.js} +47 -27
- package/dist/server-DCyf2Asb.js +679 -0
- package/dist/server-DH7PfLln.js +148 -0
- package/dist/server-DJ8bc89M.js +934 -0
- package/dist/server-DYdp0W9v.js +489 -0
- package/dist/server-DsdPEYGu.js +639 -0
- package/dist/server-DymH4Ucq.js +189 -0
- package/dist/server-IqECnUrb.js +834 -0
- package/dist/{server-36iuA3MI.js → server-KBgW77zh.js} +3 -3
- package/dist/server-RW_9R3R3.js +1522 -0
- package/dist/server-aUit8j6r.js +1028 -0
- package/dist/{server-DJAanjoI.js → server-gifRriZK.js} +491 -103
- package/dist/server-nkUlqnAL.js +2658 -0
- package/dist/server-oxyEbv1a.js +1256 -0
- package/dist/{server-D8ndq0wL.js → server-ub3s16Mc.js} +11 -9
- package/dist/{build-2gFaVEfG.js → serverPlugin-CELT6P0Q.js} +3946 -3
- package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-RQGvfm6E.js} +550 -760
- package/dist/simple-options-CFzI5Pd_.js +156 -0
- package/dist/streaming-json-BWTHTwz-.js +858 -0
- package/dist/system-one-shared-CiIrx29d.js +132 -0
- package/dist/{notification-D76PSL7r.js → telemetry-Csv1ZxAn.js} +1 -92
- package/dist/transform-messages-D77af7Bx.js +356 -0
- package/dist/truncate-M3KbFyVj.js +89 -0
- package/dist/{server-A-_GFpPr.js → type-ASYnCGVW.js} +10 -1031
- package/dist/typesafe-system-one-DGxeggJh.js +37 -0
- package/dist/uuid-B0QJx6Kr.js +31 -0
- package/dist/{validation-D77NZBrx.js → validation-BJxVSAwx.js} +8 -3
- package/dist/{value-Djvc2foV.js → value-_W31So3B.js} +1 -1
- package/dist/vaultSettings-Di3n5YIg.js +328 -0
- package/dist/voiceTools-RMn4HvWo.js +246 -0
- package/dist/web-DCP7ELJj.js +3 -0
- package/dist/worker.js +95288 -49863
- package/dist/workflow-B7qx0Vv9.js +79 -0
- package/package.json +37 -22
- package/wrangler.jsonc +4 -2
- package/dist/assets/assets/channel-CMrEzemr.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-CFf0S6bN.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BhGbWVf0.js +0 -1
- package/dist/assets/assets/index-Bx_K4Joy.js +0 -155
- package/dist/assets/assets/index-DZM68mTk.css +0 -1
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-q91tR8ri.js +0 -9
- package/dist/contextProjection-DVP2Vc5j.js +0 -188
- package/dist/harnessState-gmzJcPGt.js +0 -88
- package/dist/harnessStore-BiH9vSuD.js +0 -1
- package/dist/index.edge-BgSx_gRO.js +0 -45
- package/dist/majorModes-BvWNqoHt.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- package/dist/platform-B4AAgwJ0.js +0 -16
- package/dist/platformFiles-C_bXo4Ig.js +0 -39
- package/dist/server-BZaPPoQp.js +0 -592
- package/dist/server-D75MWDhB.js +0 -118
- package/dist/server-r358hzQg.js +0 -280
- package/dist/serverPlugin-BOI6c6s5.js +0 -3393
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
import { m as getCurrentTools, n as clampThinkingLevel, t as calculateCost, v as resolveTranscript } from "./models-Chzm15vC.js";
|
|
2
|
+
import { l as renderSystemMessageUpdate, n as getIdentityHeaders, s as getSystemMessageText } from "./identity-BgfHobJH.js";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-CFzI5Pd_.js";
|
|
4
|
+
import { n as ToolCallArgumentsStream } from "./streaming-json-BWTHTwz-.js";
|
|
5
|
+
import { i as AssistantMessageEventStream } from "./diagnostics-1lYFeSJe.js";
|
|
6
|
+
import { t as headersToRecord } from "./headers-CwtEVQvr.js";
|
|
7
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-C3Ec8oL6.js";
|
|
8
|
+
import { d as resolveJsonSchemaStrictSampling, n as transformMessages, s as getJsonSchemaToolParameters } from "./transform-messages-D77af7Bx.js";
|
|
9
|
+
import { r as truncateErrorText } from "./error-body-CJk7jMUh.js";
|
|
10
|
+
import { t as shortHash } from "./hash-Dt6RIbkn.js";
|
|
11
|
+
import { t as combineAbortSignals } from "./abort-signals-2GUraIGq.js";
|
|
12
|
+
//#region ../../../node_modules/.pnpm/@earendil-works+pi-ai@1.5.0_@aws-sdk+credential-provider-node@3.972.86_@modelcontextpro_018b33d3c6d4455b3921fdf11f2d0b63/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js
|
|
13
|
+
const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
14
|
+
const MAX_MISTRAL_ERROR_BODY_CHARS = 4e3;
|
|
15
|
+
/**
|
|
16
|
+
* Stream responses from the native Mistral Chat Completions endpoint.
|
|
17
|
+
*/
|
|
18
|
+
const stream = (model, context, options) => {
|
|
19
|
+
const stream = new AssistantMessageEventStream();
|
|
20
|
+
const normalizedContext = resolveTranscript(context, model.compat?.supportsMidConvoSystemMessages);
|
|
21
|
+
(async () => {
|
|
22
|
+
const output = createOutput(model);
|
|
23
|
+
try {
|
|
24
|
+
const apiKey = options?.apiKey;
|
|
25
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
26
|
+
const normalizeMistralToolCallId = createMistralToolCallIdNormalizer();
|
|
27
|
+
const transformedMessages = transformMessages(normalizedContext.messages, model, (id) => normalizeMistralToolCallId(id));
|
|
28
|
+
let payload = buildChatPayload(model, normalizedContext, transformedMessages, options);
|
|
29
|
+
const nextPayload = await options?.onPayload?.(payload, model);
|
|
30
|
+
if (nextPayload !== void 0) payload = nextPayload;
|
|
31
|
+
const mistralStream = await requestMistralStream(model, payload, apiKey, options);
|
|
32
|
+
stream.push({
|
|
33
|
+
type: "start",
|
|
34
|
+
partial: output
|
|
35
|
+
});
|
|
36
|
+
await consumeChatStream(model, output, stream, mistralStream, options?.onProviderStreamEvent);
|
|
37
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
38
|
+
if (output.stopReason === "pending") throw new Error("Mistral stream ended without a finish reason");
|
|
39
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage || "An unknown error occurred");
|
|
40
|
+
stream.push({
|
|
41
|
+
type: "done",
|
|
42
|
+
reason: output.stopReason,
|
|
43
|
+
message: output
|
|
44
|
+
});
|
|
45
|
+
stream.end();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
48
|
+
output.errorMessage = formatMistralError(error);
|
|
49
|
+
stream.push({
|
|
50
|
+
type: "error",
|
|
51
|
+
reason: output.stopReason,
|
|
52
|
+
error: output
|
|
53
|
+
});
|
|
54
|
+
stream.end();
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
return stream;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Maps provider-agnostic `SimpleStreamOptions` to Mistral options.
|
|
61
|
+
*/
|
|
62
|
+
const streamSimple = (model, context, options) => {
|
|
63
|
+
const apiKey = options?.apiKey;
|
|
64
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
65
|
+
const base = {
|
|
66
|
+
...buildBaseOptions(model, context, options, apiKey),
|
|
67
|
+
toolChoice: options?.toolChoice
|
|
68
|
+
};
|
|
69
|
+
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
|
|
70
|
+
const reasoning = clampedReasoning === "off" ? void 0 : clampedReasoning;
|
|
71
|
+
const effortMap = model.reasoning ? model.thinkingLevelMap : void 0;
|
|
72
|
+
const reasoningEffort = effortMap ? reasoning ? effortMap[reasoning] ?? "high" : effortMap.off ?? void 0 : void 0;
|
|
73
|
+
return stream(model, context, {
|
|
74
|
+
...base,
|
|
75
|
+
promptMode: model.reasoning && !effortMap && reasoning ? "reasoning" : void 0,
|
|
76
|
+
reasoningEffort
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
function createOutput(model) {
|
|
80
|
+
return {
|
|
81
|
+
role: "assistant",
|
|
82
|
+
content: [],
|
|
83
|
+
api: model.api,
|
|
84
|
+
provider: model.provider,
|
|
85
|
+
model: model.id,
|
|
86
|
+
usage: {
|
|
87
|
+
input: 0,
|
|
88
|
+
output: 0,
|
|
89
|
+
cacheRead: 0,
|
|
90
|
+
cacheWrite: 0,
|
|
91
|
+
totalTokens: 0,
|
|
92
|
+
cost: {
|
|
93
|
+
input: 0,
|
|
94
|
+
output: 0,
|
|
95
|
+
cacheRead: 0,
|
|
96
|
+
cacheWrite: 0,
|
|
97
|
+
total: 0
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
stopReason: "pending",
|
|
101
|
+
timestamp: Date.now()
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function createMistralToolCallIdNormalizer() {
|
|
105
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
106
|
+
const reverseMap = /* @__PURE__ */ new Map();
|
|
107
|
+
return (id) => {
|
|
108
|
+
const existing = idMap.get(id);
|
|
109
|
+
if (existing) return existing;
|
|
110
|
+
let attempt = 0;
|
|
111
|
+
while (true) {
|
|
112
|
+
const candidate = deriveMistralToolCallId(id, attempt);
|
|
113
|
+
const owner = reverseMap.get(candidate);
|
|
114
|
+
if (!owner || owner === id) {
|
|
115
|
+
idMap.set(id, candidate);
|
|
116
|
+
reverseMap.set(candidate, id);
|
|
117
|
+
return candidate;
|
|
118
|
+
}
|
|
119
|
+
attempt++;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function deriveMistralToolCallId(id, attempt) {
|
|
124
|
+
const normalized = id.replace(/[^a-zA-Z0-9]/g, "");
|
|
125
|
+
if (attempt === 0 && normalized.length === MISTRAL_TOOL_CALL_ID_LENGTH) return normalized;
|
|
126
|
+
const seedBase = normalized || id;
|
|
127
|
+
const seed = attempt === 0 ? seedBase : `${seedBase}:${attempt}`;
|
|
128
|
+
return shortHash(seed).replace(/[^a-zA-Z0-9]/g, "").slice(0, MISTRAL_TOOL_CALL_ID_LENGTH);
|
|
129
|
+
}
|
|
130
|
+
function formatMistralError(error) {
|
|
131
|
+
if (error instanceof Error) {
|
|
132
|
+
const httpError = error;
|
|
133
|
+
const statusCode = typeof httpError.statusCode === "number" ? httpError.statusCode : void 0;
|
|
134
|
+
const bodyText = typeof httpError.body === "string" ? httpError.body.trim() : void 0;
|
|
135
|
+
if (statusCode !== void 0 && bodyText) return `Mistral API error (${statusCode}): ${truncateErrorText(bodyText, MAX_MISTRAL_ERROR_BODY_CHARS)}`;
|
|
136
|
+
if (statusCode !== void 0) return `Mistral API error (${statusCode}): ${error.message}`;
|
|
137
|
+
return error.message;
|
|
138
|
+
}
|
|
139
|
+
return safeJsonStringify(error);
|
|
140
|
+
}
|
|
141
|
+
function safeJsonStringify(value) {
|
|
142
|
+
try {
|
|
143
|
+
const serialized = JSON.stringify(value);
|
|
144
|
+
return serialized === void 0 ? String(value) : serialized;
|
|
145
|
+
} catch {
|
|
146
|
+
return String(value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function requestMistralStream(model, payload, apiKey, options) {
|
|
150
|
+
const baseUrl = new URL(model.baseUrl);
|
|
151
|
+
baseUrl.pathname = `${baseUrl.pathname.replace(/\/+$/u, "")}/`;
|
|
152
|
+
const url = new URL("v1/chat/completions", baseUrl);
|
|
153
|
+
const headers = buildMistralHeaders(model, apiKey, options);
|
|
154
|
+
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
155
|
+
const headerTimeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
156
|
+
const combinedSignal = combineAbortSignals([options?.signal, headerTimeoutSignal]);
|
|
157
|
+
let response;
|
|
158
|
+
try {
|
|
159
|
+
response = await (options?.fetch ?? globalThis.fetch)(url, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers,
|
|
162
|
+
body: JSON.stringify(toMistralWirePayload(payload)),
|
|
163
|
+
signal: combinedSignal.signal
|
|
164
|
+
});
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (headerTimeoutSignal.aborted && !options?.signal?.aborted) throw new Error(`Mistral response headers timed out after ${timeoutMs}ms`);
|
|
167
|
+
throw error;
|
|
168
|
+
} finally {
|
|
169
|
+
combinedSignal.cleanup();
|
|
170
|
+
}
|
|
171
|
+
await options?.onResponse?.({
|
|
172
|
+
status: response.status,
|
|
173
|
+
headers: headersToRecord(response.headers)
|
|
174
|
+
}, model);
|
|
175
|
+
if (!response.ok) {
|
|
176
|
+
const body = await response.text();
|
|
177
|
+
throw new MistralHttpError(response.status, body, response.statusText);
|
|
178
|
+
}
|
|
179
|
+
if (!response.body) throw new Error("Mistral response has no body");
|
|
180
|
+
return readMistralEvents(response.body, options?.signal);
|
|
181
|
+
}
|
|
182
|
+
var MistralHttpError = class extends Error {
|
|
183
|
+
statusCode;
|
|
184
|
+
body;
|
|
185
|
+
constructor(statusCode, body, statusText) {
|
|
186
|
+
super(statusText || `Request failed with status ${statusCode}`);
|
|
187
|
+
this.name = "MistralHttpError";
|
|
188
|
+
this.statusCode = statusCode;
|
|
189
|
+
this.body = body;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
function buildMistralHeaders(model, apiKey, options) {
|
|
193
|
+
const headers = new Headers({
|
|
194
|
+
...getIdentityHeaders(model, options?.identity),
|
|
195
|
+
accept: "text/event-stream",
|
|
196
|
+
authorization: `Bearer ${apiKey}`,
|
|
197
|
+
"content-type": "application/json"
|
|
198
|
+
});
|
|
199
|
+
applyMistralHeaderOverrides(headers, model.headers);
|
|
200
|
+
applyMistralHeaderOverrides(headers, options?.headers);
|
|
201
|
+
const hasExplicitAffinity = hasMistralHeaderOverride(model.headers, "x-affinity") || hasMistralHeaderOverride(options?.headers, "x-affinity");
|
|
202
|
+
if (shouldUsePromptCaching(options) && !hasExplicitAffinity) headers.set("x-affinity", options.sessionId);
|
|
203
|
+
return headers;
|
|
204
|
+
}
|
|
205
|
+
function applyMistralHeaderOverrides(headers, overrides) {
|
|
206
|
+
if (!overrides) return;
|
|
207
|
+
for (const [name, value] of Object.entries(overrides)) if (value === null) headers.delete(name);
|
|
208
|
+
else headers.set(name, value);
|
|
209
|
+
}
|
|
210
|
+
function hasMistralHeaderOverride(overrides, target) {
|
|
211
|
+
return !!overrides && Object.keys(overrides).some((name) => name.toLowerCase() === target);
|
|
212
|
+
}
|
|
213
|
+
function toMistralWirePayload(payload) {
|
|
214
|
+
const wirePayload = { ...payload };
|
|
215
|
+
for (const [source, target] of [
|
|
216
|
+
["topP", "top_p"],
|
|
217
|
+
["maxTokens", "max_tokens"],
|
|
218
|
+
["randomSeed", "random_seed"],
|
|
219
|
+
["responseFormat", "response_format"],
|
|
220
|
+
["toolChoice", "tool_choice"],
|
|
221
|
+
["presencePenalty", "presence_penalty"],
|
|
222
|
+
["frequencyPenalty", "frequency_penalty"],
|
|
223
|
+
["parallelToolCalls", "parallel_tool_calls"],
|
|
224
|
+
["reasoningEffort", "reasoning_effort"],
|
|
225
|
+
["promptMode", "prompt_mode"],
|
|
226
|
+
["promptCacheKey", "prompt_cache_key"],
|
|
227
|
+
["safePrompt", "safe_prompt"]
|
|
228
|
+
]) remapMistralProperty(wirePayload, source, target);
|
|
229
|
+
wirePayload.messages = payload.messages.map((message) => toMistralWireMessage(message));
|
|
230
|
+
const responseFormat = wirePayload.response_format;
|
|
231
|
+
if (isMistralRecord(responseFormat)) {
|
|
232
|
+
const wireResponseFormat = { ...responseFormat };
|
|
233
|
+
remapMistralProperty(wireResponseFormat, "jsonSchema", "json_schema");
|
|
234
|
+
const jsonSchema = wireResponseFormat.json_schema;
|
|
235
|
+
if (isMistralRecord(jsonSchema)) {
|
|
236
|
+
const wireJsonSchema = { ...jsonSchema };
|
|
237
|
+
remapMistralProperty(wireJsonSchema, "schemaDefinition", "schema");
|
|
238
|
+
wireResponseFormat.json_schema = wireJsonSchema;
|
|
239
|
+
}
|
|
240
|
+
wirePayload.response_format = wireResponseFormat;
|
|
241
|
+
}
|
|
242
|
+
return wirePayload;
|
|
243
|
+
}
|
|
244
|
+
function toMistralWireMessage(message) {
|
|
245
|
+
const wireMessage = { ...message };
|
|
246
|
+
remapMistralProperty(wireMessage, "toolCalls", "tool_calls");
|
|
247
|
+
remapMistralProperty(wireMessage, "toolCallId", "tool_call_id");
|
|
248
|
+
if (Array.isArray(message.content)) wireMessage.content = message.content.map((chunk) => toMistralWireContentChunk(chunk));
|
|
249
|
+
return wireMessage;
|
|
250
|
+
}
|
|
251
|
+
function toMistralWireContentChunk(chunk) {
|
|
252
|
+
const wireChunk = { ...chunk };
|
|
253
|
+
for (const [source, target] of [
|
|
254
|
+
["imageUrl", "image_url"],
|
|
255
|
+
["documentUrl", "document_url"],
|
|
256
|
+
["documentName", "document_name"],
|
|
257
|
+
["fileId", "file_id"],
|
|
258
|
+
["referenceIds", "reference_ids"],
|
|
259
|
+
["inputAudio", "input_audio"]
|
|
260
|
+
]) remapMistralProperty(wireChunk, source, target);
|
|
261
|
+
return wireChunk;
|
|
262
|
+
}
|
|
263
|
+
function remapMistralProperty(record, source, target) {
|
|
264
|
+
if (!(source in record)) return;
|
|
265
|
+
record[target] = record[source];
|
|
266
|
+
delete record[source];
|
|
267
|
+
}
|
|
268
|
+
function isMistralRecord(value) {
|
|
269
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
270
|
+
}
|
|
271
|
+
const MISTRAL_STREAM_DONE = Symbol("mistral-stream-done");
|
|
272
|
+
async function* readMistralEvents(body, signal) {
|
|
273
|
+
const reader = body.getReader();
|
|
274
|
+
const decoder = new TextDecoder();
|
|
275
|
+
let buffer = "";
|
|
276
|
+
const onAbort = () => {
|
|
277
|
+
reader.cancel().catch(() => {});
|
|
278
|
+
};
|
|
279
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
280
|
+
try {
|
|
281
|
+
while (true) {
|
|
282
|
+
if (signal?.aborted) throw signal.reason;
|
|
283
|
+
const { done, value } = await reader.read();
|
|
284
|
+
if (signal?.aborted) throw signal.reason;
|
|
285
|
+
buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });
|
|
286
|
+
let boundary = findMistralEventBoundary(buffer);
|
|
287
|
+
while (boundary) {
|
|
288
|
+
const event = parseMistralEvent(buffer.slice(0, boundary.index));
|
|
289
|
+
buffer = buffer.slice(boundary.index + boundary.length);
|
|
290
|
+
if (event === MISTRAL_STREAM_DONE) return;
|
|
291
|
+
if (event) yield event;
|
|
292
|
+
boundary = findMistralEventBoundary(buffer);
|
|
293
|
+
}
|
|
294
|
+
if (done) break;
|
|
295
|
+
}
|
|
296
|
+
if (buffer.trim()) {
|
|
297
|
+
const event = parseMistralEvent(buffer);
|
|
298
|
+
if (event !== MISTRAL_STREAM_DONE && event) yield event;
|
|
299
|
+
}
|
|
300
|
+
} finally {
|
|
301
|
+
signal?.removeEventListener("abort", onAbort);
|
|
302
|
+
try {
|
|
303
|
+
await reader.cancel();
|
|
304
|
+
} catch {}
|
|
305
|
+
try {
|
|
306
|
+
reader.releaseLock();
|
|
307
|
+
} catch {}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function findMistralEventBoundary(buffer) {
|
|
311
|
+
const match = /\r\n\r\n|\r\n\r|\r\n\n|\r\r\n|\n\r\n|\r\r|\n\r|\n\n/u.exec(buffer);
|
|
312
|
+
return match?.index === void 0 ? void 0 : {
|
|
313
|
+
index: match.index,
|
|
314
|
+
length: match[0].length
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function parseMistralEvent(raw) {
|
|
318
|
+
const data = raw.split(/\r\n|\r|\n/u).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n").trim();
|
|
319
|
+
if (!data) return void 0;
|
|
320
|
+
if (data === "[DONE]") return MISTRAL_STREAM_DONE;
|
|
321
|
+
const parsed = JSON.parse(data);
|
|
322
|
+
if (!isMistralRecord(parsed) || !Array.isArray(parsed.choices)) throw new Error("Invalid Mistral streaming event");
|
|
323
|
+
return { data: parsed };
|
|
324
|
+
}
|
|
325
|
+
function buildChatPayload(model, context, messages, options) {
|
|
326
|
+
const payload = {
|
|
327
|
+
model: model.id,
|
|
328
|
+
stream: true,
|
|
329
|
+
messages: toChatMessages(messages, model.input.includes("image"))
|
|
330
|
+
};
|
|
331
|
+
const currentTools = getCurrentTools(context.messages);
|
|
332
|
+
if (currentTools.length > 0) payload.tools = toFunctionTools(currentTools);
|
|
333
|
+
if (options?.temperature !== void 0) payload.temperature = options.temperature;
|
|
334
|
+
if (options?.maxTokens !== void 0) payload.maxTokens = options.maxTokens;
|
|
335
|
+
if (options?.toolChoice) payload.toolChoice = mapToolChoice(options.toolChoice);
|
|
336
|
+
if (options?.promptMode) payload.promptMode = options.promptMode;
|
|
337
|
+
if (options?.reasoningEffort) payload.reasoningEffort = options.reasoningEffort;
|
|
338
|
+
if (shouldUsePromptCaching(options)) payload.promptCacheKey = options.sessionId;
|
|
339
|
+
return payload;
|
|
340
|
+
}
|
|
341
|
+
function shouldUsePromptCaching(options) {
|
|
342
|
+
return options?.cacheRetention !== "none" && !!options?.sessionId;
|
|
343
|
+
}
|
|
344
|
+
function getMistralCachedPromptTokens(usage, promptTokens) {
|
|
345
|
+
const rawUsage = usage;
|
|
346
|
+
const rawCachedTokens = rawUsage.promptTokensDetails?.cachedTokens ?? rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.promptTokenDetails?.cachedTokens ?? rawUsage.prompt_token_details?.cached_tokens ?? rawUsage.numCachedTokens ?? rawUsage.num_cached_tokens ?? 0;
|
|
347
|
+
return Math.min(promptTokens, Math.max(0, typeof rawCachedTokens === "number" && Number.isFinite(rawCachedTokens) ? rawCachedTokens : 0));
|
|
348
|
+
}
|
|
349
|
+
async function consumeChatStream(model, output, stream, mistralStream, onProviderStreamEvent) {
|
|
350
|
+
let currentBlock = null;
|
|
351
|
+
const blocks = output.content;
|
|
352
|
+
const blockIndex = () => blocks.length - 1;
|
|
353
|
+
const toolCallsByKey = /* @__PURE__ */ new Map();
|
|
354
|
+
const finishCurrentBlock = (block) => {
|
|
355
|
+
if (!block) return;
|
|
356
|
+
if (block.type === "text") {
|
|
357
|
+
stream.push({
|
|
358
|
+
type: "text_end",
|
|
359
|
+
contentIndex: blockIndex(),
|
|
360
|
+
content: block.text,
|
|
361
|
+
partial: output
|
|
362
|
+
});
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (block.type === "thinking") stream.push({
|
|
366
|
+
type: "thinking_end",
|
|
367
|
+
contentIndex: blockIndex(),
|
|
368
|
+
content: block.thinking,
|
|
369
|
+
partial: output
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
for await (const event of mistralStream) {
|
|
373
|
+
const chunk = event.data;
|
|
374
|
+
await onProviderStreamEvent?.(chunk, model);
|
|
375
|
+
output.responseId ||= chunk.id;
|
|
376
|
+
if (chunk.usage) {
|
|
377
|
+
const promptTokens = chunk.usage.prompt_tokens || 0;
|
|
378
|
+
const cachedPromptTokens = getMistralCachedPromptTokens(chunk.usage, promptTokens);
|
|
379
|
+
output.usage.input = Math.max(0, promptTokens - cachedPromptTokens);
|
|
380
|
+
output.usage.output = chunk.usage.completion_tokens || 0;
|
|
381
|
+
output.usage.cacheRead = cachedPromptTokens;
|
|
382
|
+
output.usage.cacheWrite = 0;
|
|
383
|
+
output.usage.totalTokens = chunk.usage.total_tokens || output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
384
|
+
calculateCost(model, output.usage);
|
|
385
|
+
}
|
|
386
|
+
const choice = chunk.choices[0];
|
|
387
|
+
if (!choice) continue;
|
|
388
|
+
if (choice.finish_reason) {
|
|
389
|
+
output.rawStopReason = choice.finish_reason;
|
|
390
|
+
const stopReasonResult = mapChatStopReason(choice.finish_reason);
|
|
391
|
+
output.stopReason = stopReasonResult.stopReason;
|
|
392
|
+
if (stopReasonResult.errorMessage) output.errorMessage = stopReasonResult.errorMessage;
|
|
393
|
+
}
|
|
394
|
+
const delta = choice.delta;
|
|
395
|
+
if (delta.content !== null && delta.content !== void 0) {
|
|
396
|
+
const contentItems = typeof delta.content === "string" ? [delta.content] : delta.content;
|
|
397
|
+
for (const item of contentItems) {
|
|
398
|
+
if (typeof item === "string") {
|
|
399
|
+
const textDelta = sanitizeSurrogates(item);
|
|
400
|
+
if (!textDelta) continue;
|
|
401
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
402
|
+
finishCurrentBlock(currentBlock);
|
|
403
|
+
currentBlock = {
|
|
404
|
+
type: "text",
|
|
405
|
+
text: ""
|
|
406
|
+
};
|
|
407
|
+
output.content.push(currentBlock);
|
|
408
|
+
stream.push({
|
|
409
|
+
type: "text_start",
|
|
410
|
+
contentIndex: blockIndex(),
|
|
411
|
+
partial: output
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
currentBlock.text += textDelta;
|
|
415
|
+
stream.push({
|
|
416
|
+
type: "text_delta",
|
|
417
|
+
contentIndex: blockIndex(),
|
|
418
|
+
delta: textDelta,
|
|
419
|
+
partial: output
|
|
420
|
+
});
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (item.type === "thinking") {
|
|
424
|
+
const deltaText = (item.thinking ?? []).map((part) => part.text ?? "").filter((text) => text.length > 0).join("");
|
|
425
|
+
const thinkingDelta = sanitizeSurrogates(deltaText);
|
|
426
|
+
if (!thinkingDelta) continue;
|
|
427
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
428
|
+
finishCurrentBlock(currentBlock);
|
|
429
|
+
currentBlock = {
|
|
430
|
+
type: "thinking",
|
|
431
|
+
thinking: ""
|
|
432
|
+
};
|
|
433
|
+
output.content.push(currentBlock);
|
|
434
|
+
stream.push({
|
|
435
|
+
type: "thinking_start",
|
|
436
|
+
contentIndex: blockIndex(),
|
|
437
|
+
partial: output
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
currentBlock.thinking += thinkingDelta;
|
|
441
|
+
stream.push({
|
|
442
|
+
type: "thinking_delta",
|
|
443
|
+
contentIndex: blockIndex(),
|
|
444
|
+
delta: thinkingDelta,
|
|
445
|
+
partial: output
|
|
446
|
+
});
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if (item.type === "text") {
|
|
450
|
+
const textDelta = sanitizeSurrogates(item.text ?? "");
|
|
451
|
+
if (!textDelta) continue;
|
|
452
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
453
|
+
finishCurrentBlock(currentBlock);
|
|
454
|
+
currentBlock = {
|
|
455
|
+
type: "text",
|
|
456
|
+
text: ""
|
|
457
|
+
};
|
|
458
|
+
output.content.push(currentBlock);
|
|
459
|
+
stream.push({
|
|
460
|
+
type: "text_start",
|
|
461
|
+
contentIndex: blockIndex(),
|
|
462
|
+
partial: output
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
currentBlock.text += textDelta;
|
|
466
|
+
stream.push({
|
|
467
|
+
type: "text_delta",
|
|
468
|
+
contentIndex: blockIndex(),
|
|
469
|
+
delta: textDelta,
|
|
470
|
+
partial: output
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const toolCalls = delta.tool_calls || [];
|
|
476
|
+
for (const toolCall of toolCalls) {
|
|
477
|
+
if (currentBlock) {
|
|
478
|
+
finishCurrentBlock(currentBlock);
|
|
479
|
+
currentBlock = null;
|
|
480
|
+
}
|
|
481
|
+
const callId = toolCall.id && toolCall.id !== "null" ? toolCall.id : deriveMistralToolCallId(`toolcall:${toolCall.index ?? 0}`, 0);
|
|
482
|
+
const key = toolCall.index ?? callId;
|
|
483
|
+
let open = toolCallsByKey.get(key);
|
|
484
|
+
if (!open) {
|
|
485
|
+
output.content.push({
|
|
486
|
+
type: "toolCall",
|
|
487
|
+
id: callId,
|
|
488
|
+
name: toolCall.function.name,
|
|
489
|
+
arguments: {}
|
|
490
|
+
});
|
|
491
|
+
open = {
|
|
492
|
+
contentIndex: output.content.length - 1,
|
|
493
|
+
arguments: new ToolCallArgumentsStream()
|
|
494
|
+
};
|
|
495
|
+
toolCallsByKey.set(key, open);
|
|
496
|
+
stream.push({
|
|
497
|
+
type: "toolcall_start",
|
|
498
|
+
contentIndex: open.contentIndex,
|
|
499
|
+
partial: output
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const argsDelta = typeof toolCall.function.arguments === "string" ? toolCall.function.arguments : JSON.stringify(toolCall.function.arguments || {});
|
|
503
|
+
output.content[open.contentIndex].arguments = open.arguments.append(argsDelta);
|
|
504
|
+
stream.push({
|
|
505
|
+
type: "toolcall_delta",
|
|
506
|
+
contentIndex: open.contentIndex,
|
|
507
|
+
delta: argsDelta,
|
|
508
|
+
partial: output
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
finishCurrentBlock(currentBlock);
|
|
513
|
+
for (const open of toolCallsByKey.values()) {
|
|
514
|
+
const block = output.content[open.contentIndex];
|
|
515
|
+
Object.assign(block, open.arguments.finish());
|
|
516
|
+
stream.push({
|
|
517
|
+
type: "toolcall_end",
|
|
518
|
+
contentIndex: open.contentIndex,
|
|
519
|
+
toolCall: block,
|
|
520
|
+
partial: output
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function toFunctionTools(tools) {
|
|
525
|
+
return tools.map((tool) => {
|
|
526
|
+
const strict = resolveJsonSchemaStrictSampling(tool, true);
|
|
527
|
+
return {
|
|
528
|
+
type: "function",
|
|
529
|
+
function: {
|
|
530
|
+
name: tool.name,
|
|
531
|
+
description: tool.description,
|
|
532
|
+
parameters: stripSymbolKeys(getJsonSchemaToolParameters(tool, strict)),
|
|
533
|
+
strict: strict ?? false
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
function stripSymbolKeys(value) {
|
|
539
|
+
if (Array.isArray(value)) return value.map((item) => stripSymbolKeys(item));
|
|
540
|
+
if (value && typeof value === "object") {
|
|
541
|
+
const result = {};
|
|
542
|
+
for (const [key, entry] of Object.entries(value)) result[key] = stripSymbolKeys(entry);
|
|
543
|
+
return result;
|
|
544
|
+
}
|
|
545
|
+
return value;
|
|
546
|
+
}
|
|
547
|
+
function toChatMessages(messages, supportsImages) {
|
|
548
|
+
const result = [];
|
|
549
|
+
for (const [index, msg] of messages.entries()) {
|
|
550
|
+
if (msg.role === "system") {
|
|
551
|
+
const text = index === 0 ? getSystemMessageText(msg) : renderSystemMessageUpdate(msg);
|
|
552
|
+
if (text.length > 0) result.push({
|
|
553
|
+
role: "system",
|
|
554
|
+
content: sanitizeSurrogates(text)
|
|
555
|
+
});
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (msg.role === "user") {
|
|
559
|
+
if (typeof msg.content === "string") {
|
|
560
|
+
result.push({
|
|
561
|
+
role: "user",
|
|
562
|
+
content: sanitizeSurrogates(msg.content)
|
|
563
|
+
});
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const hadImages = msg.content.some((item) => item.type === "image");
|
|
567
|
+
const content = msg.content.filter((item) => item.type === "text" || supportsImages).map((item) => {
|
|
568
|
+
if (item.type === "text") return {
|
|
569
|
+
type: "text",
|
|
570
|
+
text: sanitizeSurrogates(item.text)
|
|
571
|
+
};
|
|
572
|
+
return {
|
|
573
|
+
type: "image_url",
|
|
574
|
+
imageUrl: `data:${item.mimeType};base64,${item.data}`
|
|
575
|
+
};
|
|
576
|
+
});
|
|
577
|
+
if (content.length > 0) {
|
|
578
|
+
result.push({
|
|
579
|
+
role: "user",
|
|
580
|
+
content
|
|
581
|
+
});
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (hadImages && !supportsImages) result.push({
|
|
585
|
+
role: "user",
|
|
586
|
+
content: "(image omitted: model does not support images)"
|
|
587
|
+
});
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
if (msg.role === "assistant") {
|
|
591
|
+
const contentParts = [];
|
|
592
|
+
const toolCalls = [];
|
|
593
|
+
for (const block of msg.content) {
|
|
594
|
+
if (block.type === "text") {
|
|
595
|
+
if (block.text.trim().length > 0) contentParts.push({
|
|
596
|
+
type: "text",
|
|
597
|
+
text: sanitizeSurrogates(block.text)
|
|
598
|
+
});
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (block.type === "thinking") {
|
|
602
|
+
if (block.thinking.trim().length > 0) contentParts.push({
|
|
603
|
+
type: "thinking",
|
|
604
|
+
thinking: [{
|
|
605
|
+
type: "text",
|
|
606
|
+
text: sanitizeSurrogates(block.thinking)
|
|
607
|
+
}]
|
|
608
|
+
});
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
toolCalls.push({
|
|
612
|
+
id: block.id,
|
|
613
|
+
type: "function",
|
|
614
|
+
function: {
|
|
615
|
+
name: block.name,
|
|
616
|
+
arguments: JSON.stringify(block.arguments || {})
|
|
617
|
+
},
|
|
618
|
+
index: 0
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
const assistantMessage = {
|
|
622
|
+
role: "assistant",
|
|
623
|
+
prefix: false
|
|
624
|
+
};
|
|
625
|
+
if (contentParts.length > 0) assistantMessage.content = contentParts;
|
|
626
|
+
if (toolCalls.length > 0) assistantMessage.toolCalls = toolCalls;
|
|
627
|
+
if (contentParts.length > 0 || toolCalls.length > 0) result.push(assistantMessage);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const toolContent = [];
|
|
631
|
+
const toolText = buildToolResultText(msg.content.filter((part) => part.type === "text").map((part) => part.type === "text" ? sanitizeSurrogates(part.text) : "").join("\n"), msg.content.some((part) => part.type === "image"), supportsImages, msg.isError);
|
|
632
|
+
toolContent.push({
|
|
633
|
+
type: "text",
|
|
634
|
+
text: toolText
|
|
635
|
+
});
|
|
636
|
+
for (const part of msg.content) {
|
|
637
|
+
if (!supportsImages) continue;
|
|
638
|
+
if (part.type !== "image") continue;
|
|
639
|
+
toolContent.push({
|
|
640
|
+
type: "image_url",
|
|
641
|
+
imageUrl: `data:${part.mimeType};base64,${part.data}`
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
result.push({
|
|
645
|
+
role: "tool",
|
|
646
|
+
toolCallId: msg.toolCallId,
|
|
647
|
+
name: msg.toolName,
|
|
648
|
+
content: toolContent
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return result;
|
|
652
|
+
}
|
|
653
|
+
function buildToolResultText(text, hasImages, supportsImages, isError) {
|
|
654
|
+
const trimmed = text.trim();
|
|
655
|
+
const errorPrefix = isError ? "[tool error] " : "";
|
|
656
|
+
if (trimmed.length > 0) return `${errorPrefix}${trimmed}${hasImages && !supportsImages ? "\n[tool image omitted: model does not support images]" : ""}`;
|
|
657
|
+
if (hasImages) {
|
|
658
|
+
if (supportsImages) return isError ? "[tool error] (see attached image)" : "(see attached image)";
|
|
659
|
+
return isError ? "[tool error] (image omitted: model does not support images)" : "(image omitted: model does not support images)";
|
|
660
|
+
}
|
|
661
|
+
return isError ? "[tool error] (no tool output)" : "(no tool output)";
|
|
662
|
+
}
|
|
663
|
+
function mapToolChoice(choice) {
|
|
664
|
+
if (!choice) return void 0;
|
|
665
|
+
if (choice === "auto" || choice === "none" || choice === "any" || choice === "required") return choice;
|
|
666
|
+
return {
|
|
667
|
+
type: "function",
|
|
668
|
+
function: { name: choice.function.name }
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function mapChatStopReason(reason) {
|
|
672
|
+
if (reason === null) return { stopReason: "stop" };
|
|
673
|
+
switch (reason) {
|
|
674
|
+
case "stop": return { stopReason: "stop" };
|
|
675
|
+
case "length":
|
|
676
|
+
case "model_length": return { stopReason: "length" };
|
|
677
|
+
case "tool_calls": return { stopReason: "toolUse" };
|
|
678
|
+
case "error": return {
|
|
679
|
+
stopReason: "error",
|
|
680
|
+
errorMessage: "Provider stopped with: error (server error)"
|
|
681
|
+
};
|
|
682
|
+
default: return {
|
|
683
|
+
stopReason: "error",
|
|
684
|
+
errorMessage: `Provider stopped with: ${reason}`
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
//#endregion
|
|
689
|
+
export { stream, streamSimple };
|