@agimon-ai/po-cloudflare 0.0.2-alpha.2 → 0.0.2-alpha.4
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-Bkmp_euQ.js +34 -0
- package/dist/anthropic-messages-CkYm8M3V.js +14317 -0
- package/dist/{approval-BMXqnTYd.js → approval-Eu7UgGL-.js} +1 -1
- package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-rEfljuRK.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-J6Iu5p17.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-DKj_xMR1.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53--D1MzuBo.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-CrWO0t-Q.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-CBMOJREz.js} +2 -2
- package/dist/assets/assets/channel-CNegK3Rr.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-CR9NMk46.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T-B4D0falO.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-CKrttFen.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-BPNrdjSb.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-Ddx2gPU_.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-iQg3RbZ_.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-CGlDRwnk.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-CN7VMEsn.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-DQKmIS4j.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-BKSG_d1a.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-AbFHiDOg.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-C5a4DmCb.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-BbVKQGnw.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-UbKezTdY.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-BShGGpRc.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-BmV-PDP0.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-DB-cfBNq.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-Dprqh48h.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-Bz4CND4n.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-Cv0Tq-0q.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-H4d8oeNm.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-D75OthTM.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-CB_W2jXU.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-DPO0lYZ-.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-DJ9olXAC.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-DL3974PI.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-ZuYESp4p.js} +2 -2
- package/dist/assets/assets/{dist-B3JXhDWV.js → dist-BnkGKHOV.js} +2 -2
- package/dist/assets/assets/{dist-1-mhYUBH.js → dist-C8iSs-hT.js} +2 -2
- package/dist/assets/assets/{dist-XIZum9n5.js → dist-CXqaT1wB.js} +2 -2
- package/dist/assets/assets/{dist-gfbb4ygy.js → dist-CdrEbsAL.js} +2 -2
- package/dist/assets/assets/{dist-h6SOnP8-.js → dist-CeotBqYt.js} +2 -2
- package/dist/assets/assets/{dist-DvgCCshF.js → dist-D2iSi_lg.js} +2 -2
- package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-DvCNYjgK.js} +2 -2
- package/dist/assets/assets/{dist-BabjcJ3j.js → dist-G3vL_xw7.js} +2 -2
- package/dist/assets/assets/{dist-Izr2SB3q.js → dist-zXhaMKmO.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-DNfHKEsm.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-C0FX9D60.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-BI1O9lW0.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-BmWt-aOv.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-DQj3H5a6.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-pM7PmQ6B.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-D0QXMQxv.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-BsMltgt3.js} +2 -2
- package/dist/assets/assets/index-BTHzc8EN.js +155 -0
- package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-Dp5Eu5PX.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-TgXRfZiq.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-Qzrmih4p.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-BksI3QOT.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-l_IuN5_k.js} +2 -2
- package/dist/assets/assets/{line-BsXJZn93.js → line-BDKssGoM.js} +2 -2
- package/dist/assets/assets/{linear-BHYaD5T0.js → linear-C9vmtzBC.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-O1yFX7K_.js} +4 -4
- package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-CIq57361.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-BkVuZ010.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-PPNcSWeV.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-ClwrHXhM.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-BAE4Cy9j.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-CvQ62Knb.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-CzAyT5ZB.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-CoEe8B7b.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-BbK5J8H5.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-DlGngfop.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-BRk4ifMx.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-Rz-3vbj2.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-DQISBRHH.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-DcK4FnTB.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-N2EXBOYb.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-CMJ2EqC_.js} +2 -2
- package/dist/assets/assets/{src-gihY33R9.js → src-Df9VBjd7.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-D6Cxm8wj.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-BybuzSPd.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-CXJkO6sc.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-BzjkWUdz.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-DIDWwDtU.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-SWP4JszI.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-ZfCxSJdE.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-o44wkgGH.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-0zKRsI4Z.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-CyBVyB40.js} +2 -2
- package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-C4nkEwJD.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-BMvRihYC.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +1 -1
- package/dist/assets/plugins/assets/base-B5jpmLBl.css +2 -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/chunks/po-web-runtime-D4qQFtJO.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -0
- package/dist/assets/plugins/slots/approval.09e72f36-Cck_K9ex.js +2 -0
- package/dist/assets/plugins/slots/artifacts.50b639bb-BZM7uEbe.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.75108f21-EWWGTveL.js +7 -0
- package/dist/assets/plugins/slots/codemode.c58fb583-CgfTL6kt.js +9 -0
- package/dist/assets/plugins/slots/domain.753f9f92-BU0ilfwM.js +1 -0
- package/dist/assets/plugins/slots/mcp.82cc1ff5-BaCD2xZB.js +109 -0
- package/dist/assets/plugins/slots/profile.ab16dcec-Cu6ev2uW.js +1 -0
- package/dist/assets/plugins/slots/skill.62a0a1b3-Bz20F1eA.js +4 -0
- package/dist/{atomicJson-BJfPFSYF.js → atomicJson-DwSqByUJ.js} +3 -3
- package/dist/azure-openai-config-DHMgdIa-.js +55 -0
- package/dist/azure-openai-responses-CTgRdQ4m.js +183 -0
- package/dist/backgroundWork-bE3pc-R9.js +25 -0
- package/dist/classifier-shared-jXm-plIK.js +106 -0
- package/dist/cloudflare-workers-ai-system-one-B0wH6HU5.js +52 -0
- package/dist/{codemode-DbPu0yJN.js → codemode-yHAHBZO-.js} +1 -1
- package/dist/diagnostics-DPTP-yrt.js +131 -0
- package/dist/dist-Dvx5mlIR.js +50 -0
- package/dist/{domains-BNjGTOPj.js → domains-dHfk2U8X.js} +4 -4
- package/dist/env-api-keys-CAnjjnsR.js +32 -0
- package/dist/error-body-DQZRsyL5.js +102 -0
- package/dist/{exports-BNZz2DNU.js → exports-CrJqsTU6.js} +8 -8
- package/dist/{extensionFile-CXOa5G4C.js → extensionFile-CY4EFNHQ.js} +1 -1
- package/dist/github-copilot-headers-DpQQAh-s.js +22 -0
- package/dist/google-generative-ai-BTTOo5RQ.js +328 -0
- package/dist/google-shared-S7bqOccz.js +19588 -0
- package/dist/google-vertex-BcMU_DMb.js +374 -0
- package/dist/{harnessStore-BT706Ly6.js → harnessStore-CRtlTdbI.js} +4 -4
- package/dist/harnessStore-DZ4lDIq6.js +1 -0
- package/dist/hash-B3RRpLS2.js +16 -0
- package/dist/headers-BEuxFxDI.js +17 -0
- package/dist/{hubChannel-BHQyzcOo.js → hubChannel-Cj1iF847.js} +1 -1
- package/dist/identity-BIeAyilV.js +165 -0
- package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-BqIwPJ-I.js} +3 -3
- package/dist/majorModes-AYZvnOpU.js +1 -0
- package/dist/{majorModes-DbCfLZH3.js → majorModes-C-OD4PBc.js} +4 -4
- package/dist/mistral-conversations-DN8VSERk.js +689 -0
- package/dist/models-D6d73jcW.js +1511 -0
- package/dist/node-DytJOfYf.js +23 -0
- package/dist/node-UuMT2C3q.js +2479 -0
- package/dist/openai-bt3ZRBZv.js +17357 -0
- package/dist/openai-codex-responses-cL36x0ml.js +1210 -0
- package/dist/openai-completions-BWsTNYyT.js +984 -0
- package/dist/openai-decisions-Dfn_KgQd.js +142 -0
- package/dist/openai-prompt-cache-Bc6qNWt0.js +8 -0
- package/dist/openai-responses-aa0LoyCJ.js +281 -0
- package/dist/openai-responses-shared-H-jH5SlM.js +661 -0
- package/dist/openrouter-cost-D99Qqcs6.js +30 -0
- package/dist/openrouter-images-BpwVpALC.js +124 -0
- package/dist/pi-messages-BHAIkYBj.js +312 -0
- package/dist/{platform-B4AAgwJ0.js → platform-CNhm9zLi.js} +1 -1
- package/dist/{platformFiles-C_bXo4Ig.js → platformFiles-3rzOh9cg.js} +1 -1
- package/dist/provider-env-DgfpjgTa.js +38 -0
- package/dist/provider-retry-ChD-K2Gv.js +79 -0
- package/dist/{remoteMcp-CMqZldeA.js → remoteMcp-Ci8crSU9.js} +1 -1
- package/dist/sanitize-unicode-Dl4ROF7y.js +26 -0
- package/dist/{server-BZh1ZXz_.js → server-B2xd7WTP.js} +4 -4
- package/dist/{server-DJAanjoI.js → server-BPvd3Ya5.js} +6 -6
- package/dist/{server-D4W7EdJY.js → server-BccTx_r6.js} +11 -10
- package/dist/{server-BZaPPoQp.js → server-Bf3_VTkt.js} +9 -9
- package/dist/{server-tvgQ99rv.js → server-BmAziQml.js} +4 -4
- package/dist/{server-r358hzQg.js → server-BvV-GqDO.js} +3 -3
- package/dist/{server-BAAL9-NA.js → server-C1ijZQp4.js} +2 -2
- package/dist/{server-BE6VqEiA.js → server-CUvohcAm.js} +4 -4
- package/dist/{server-D8ndq0wL.js → server-CYQHzqaQ.js} +2 -2
- package/dist/{server-Dt4y1rZD.js → server-De_PIOty.js} +5 -5
- package/dist/{server-A-_GFpPr.js → server-DrZBZ17y.js} +7 -7
- package/dist/{server-Dpgh8PDh.js → server-DwWTQg1J.js} +4 -4
- package/dist/{server-D75MWDhB.js → server-xiuzwJ1C.js} +2 -2
- package/dist/{server-D3PQk1Gt.js → server-y9pjeHJM.js} +3 -3
- package/dist/{serverPlugin-BOI6c6s5.js → serverPlugin-H4T49sac.js} +4 -50
- package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-2a4LWInR.js} +8 -8
- package/dist/simple-options-DWrW31_K.js +156 -0
- package/dist/streaming-json-t4rzNHEp.js +858 -0
- package/dist/system-one-shared-DLVLdzYL.js +132 -0
- package/dist/transform-messages-CjTSwW9q.js +356 -0
- package/dist/typesafe-system-one-DBVcjcUQ.js +37 -0
- package/dist/uuid-mkNGilLv.js +31 -0
- package/dist/worker.js +56113 -21793
- package/package.json +22 -22
- 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/swimlanesDiagram-AYQRV4AK-q91tR8ri.js +0 -9
- package/dist/backgroundWork-CeFrbRnj.js +0 -43
- package/dist/harnessStore-BiH9vSuD.js +0 -1
- package/dist/majorModes-BvWNqoHt.js +0 -1
- package/dist/server-36iuA3MI.js +0 -343
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@earendil-works+pi-ai@1.5.0_@aws-sdk+credential-provider-node@3.972.86_@modelcontextpro_cbd356c737d8e30c7d704b4728fb9233/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js
|
|
2
|
+
var __rewriteRelativeImportExtension = function(path, preserveJsx) {
|
|
3
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
5
|
+
});
|
|
6
|
+
return path;
|
|
7
|
+
};
|
|
8
|
+
const dynamicImport = (specifier) => import(__rewriteRelativeImportExtension(specifier));
|
|
9
|
+
const NODE_FS_SPECIFIER = "node:fs";
|
|
10
|
+
const NODE_OS_SPECIFIER = "node:os";
|
|
11
|
+
const NODE_PATH_SPECIFIER = "node:path";
|
|
12
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
|
13
|
+
dynamicImport(NODE_FS_SPECIFIER).then((m) => {
|
|
14
|
+
m.existsSync;
|
|
15
|
+
});
|
|
16
|
+
dynamicImport(NODE_OS_SPECIFIER).then((m) => {
|
|
17
|
+
m.homedir;
|
|
18
|
+
});
|
|
19
|
+
dynamicImport(NODE_PATH_SPECIFIER).then((m) => {
|
|
20
|
+
m.join;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const ANTHROPIC_AUTH_TOKEN_ENV = "ANTHROPIC_AUTH_TOKEN";
|
|
24
|
+
const ANTHROPIC_OAUTH_TOKEN_ENV = "ANTHROPIC_OAUTH_TOKEN";
|
|
25
|
+
const ANTHROPIC_API_KEY_ENV = "ANTHROPIC_API_KEY";
|
|
26
|
+
const ANTHROPIC_FEDERATION_RULE_ID_ENV = "ANTHROPIC_FEDERATION_RULE_ID";
|
|
27
|
+
const ANTHROPIC_ORGANIZATION_ID_ENV = "ANTHROPIC_ORGANIZATION_ID";
|
|
28
|
+
const ANTHROPIC_SERVICE_ACCOUNT_ID_ENV = "ANTHROPIC_SERVICE_ACCOUNT_ID";
|
|
29
|
+
const ANTHROPIC_IDENTITY_TOKEN_FILE_ENV = "ANTHROPIC_IDENTITY_TOKEN_FILE";
|
|
30
|
+
const ANTHROPIC_WORKSPACE_ID_ENV = "ANTHROPIC_WORKSPACE_ID";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ANTHROPIC_OAUTH_TOKEN_ENV as a, ANTHROPIC_WORKSPACE_ID_ENV as c, ANTHROPIC_IDENTITY_TOKEN_FILE_ENV as i, ANTHROPIC_AUTH_TOKEN_ENV as n, ANTHROPIC_ORGANIZATION_ID_ENV as o, ANTHROPIC_FEDERATION_RULE_ID_ENV as r, ANTHROPIC_SERVICE_ACCOUNT_ID_ENV as s, ANTHROPIC_API_KEY_ENV as t };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { c as ownedSlice } from "./identity-BIeAyilV.js";
|
|
2
|
+
//#region ../../../node_modules/.pnpm/@earendil-works+pi-ai@1.5.0_@aws-sdk+credential-provider-node@3.972.86_@modelcontextpro_cbd356c737d8e30c7d704b4728fb9233/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js
|
|
3
|
+
const MAX_PROVIDER_ERROR_BODY_CHARS = 4e3;
|
|
4
|
+
function normalizeProviderError(error) {
|
|
5
|
+
if (!(error instanceof Error)) return {
|
|
6
|
+
message: safeJsonStringify(error),
|
|
7
|
+
messageCarriesBody: false
|
|
8
|
+
};
|
|
9
|
+
const sdkError = error;
|
|
10
|
+
const status = extractStatus(sdkError);
|
|
11
|
+
const body = extractBody(sdkError);
|
|
12
|
+
const messageCarriesBody = body === void 0 || error.message.includes(body);
|
|
13
|
+
return {
|
|
14
|
+
status,
|
|
15
|
+
body,
|
|
16
|
+
message: error.message,
|
|
17
|
+
messageCarriesBody
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Probe the HTTP status, first numeric hit wins, in SDK-field order:
|
|
22
|
+
* `statusCode` (Mistral) → `status` (`openai`, `@google/genai`) →
|
|
23
|
+
* `$metadata.httpStatusCode` (Bedrock) → `$response.statusCode` (Bedrock).
|
|
24
|
+
*/
|
|
25
|
+
function extractStatus(error) {
|
|
26
|
+
if (typeof error.statusCode === "number") return error.statusCode;
|
|
27
|
+
if (typeof error.status === "number") return error.status;
|
|
28
|
+
if (typeof error.$metadata?.httpStatusCode === "number") return error.$metadata.httpStatusCode;
|
|
29
|
+
if (typeof error.$response?.statusCode === "number") return error.$response.statusCode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Probe the raw body reason, first usable hit wins, in SDK-field order:
|
|
33
|
+
* `body` string (Mistral) → `error` parsed JSON body object (`openai` SDK's
|
|
34
|
+
* `this.error`) → `$response.body` (Bedrock). Empty objects and unread response
|
|
35
|
+
* streams are treated as no body so they do not surface as `"{}"` or serialized
|
|
36
|
+
* stream internals. The chosen body is truncated to the cap.
|
|
37
|
+
*/
|
|
38
|
+
function extractBody(error) {
|
|
39
|
+
const bodyText = pickBodyText(error);
|
|
40
|
+
if (bodyText === void 0) return void 0;
|
|
41
|
+
const trimmed = bodyText.trim();
|
|
42
|
+
if (trimmed.length === 0) return void 0;
|
|
43
|
+
return truncateErrorText(trimmed, MAX_PROVIDER_ERROR_BODY_CHARS);
|
|
44
|
+
}
|
|
45
|
+
function pickBodyText(error) {
|
|
46
|
+
if (typeof error.body === "string") return error.body;
|
|
47
|
+
if (isPlainNonEmptyObject(error.error)) return safeJsonStringify(error.error);
|
|
48
|
+
const responseBody = error.$response?.body;
|
|
49
|
+
if (typeof responseBody === "string") return responseBody;
|
|
50
|
+
if (isReadableStreamLike(responseBody)) return void 0;
|
|
51
|
+
if (isPlainNonEmptyObject(responseBody)) return safeJsonStringify(responseBody);
|
|
52
|
+
}
|
|
53
|
+
function isReadableStreamLike(value) {
|
|
54
|
+
return typeof value === "object" && value !== null && "pipe" in value && typeof value.pipe === "function";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Only a PLAIN object counts as an HTTP body. SDK error fields can hold class
|
|
58
|
+
* instances instead of parsed bodies — AWS SDK v3's `$response.body` is an
|
|
59
|
+
* HTTP stream/response wrapper object, and stringifying one produced garbage
|
|
60
|
+
* like `{"_events":...}` as the "body", which then REPLACED `error.message`
|
|
61
|
+
* in the composed display string. `error.message` is where the SDK puts the
|
|
62
|
+
* real deserialized exception text ("Input is too long...", schema validation
|
|
63
|
+
* details, ...), so the one useful string was discarded for noise. A class
|
|
64
|
+
* instance yields no body, `messageCarriesBody` stays true, and the real
|
|
65
|
+
* message survives. Complements the `pipe` sniffing above: web
|
|
66
|
+
* ReadableStreams (pipeTo/pipeThrough, no `pipe`) and non-stream SDK wrapper
|
|
67
|
+
* classes fail the prototype check, while parsed JSON bodies (plain objects
|
|
68
|
+
* by construction) still pass.
|
|
69
|
+
*/
|
|
70
|
+
function isPlainNonEmptyObject(value) {
|
|
71
|
+
if (typeof value !== "object" || value === null) return false;
|
|
72
|
+
const proto = Object.getPrototypeOf(value);
|
|
73
|
+
if (proto !== Object.prototype && proto !== null) return false;
|
|
74
|
+
return Object.keys(value).length > 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compose a display string from a normalized error. When the message already
|
|
78
|
+
* carries the body (Anthropic / `@google/genai` happy path) or no body/status
|
|
79
|
+
* was extracted, the message is returned unchanged. Otherwise the status and
|
|
80
|
+
* body are surfaced, with an optional provider prefix.
|
|
81
|
+
*
|
|
82
|
+
* - no prefix: `"<status>: <body>"`
|
|
83
|
+
* - prefix: `"<prefix> (<status>): <body>"`
|
|
84
|
+
*/
|
|
85
|
+
function formatProviderError(norm, prefix) {
|
|
86
|
+
if (norm.messageCarriesBody || norm.status === void 0 || norm.body === void 0) return prefix !== void 0 && norm.status !== void 0 ? `${prefix} (${norm.status}): ${norm.message}` : norm.message;
|
|
87
|
+
return prefix !== void 0 ? `${prefix} (${norm.status}): ${norm.body}` : `${norm.status}: ${norm.body}`;
|
|
88
|
+
}
|
|
89
|
+
function truncateErrorText(text, maxChars) {
|
|
90
|
+
if (text.length <= maxChars) return text;
|
|
91
|
+
return `${ownedSlice(text, 0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
92
|
+
}
|
|
93
|
+
function safeJsonStringify(value) {
|
|
94
|
+
try {
|
|
95
|
+
const serialized = JSON.stringify(value);
|
|
96
|
+
return serialized === void 0 ? String(value) : serialized;
|
|
97
|
+
} catch {
|
|
98
|
+
return String(value);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { normalizeProviderError as n, truncateErrorText as r, formatProviderError as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { s as createSerialRunner } from "./serverPlugin-
|
|
2
|
-
import "./platform-
|
|
3
|
-
import "./atomicJson-
|
|
4
|
-
import "./layeredConfig-
|
|
5
|
-
import "./sessionConfig-
|
|
6
|
-
import "./domains-
|
|
7
|
-
import "./majorModes-
|
|
8
|
-
import "./harnessStore-
|
|
1
|
+
import { s as createSerialRunner } from "./serverPlugin-H4T49sac.js";
|
|
2
|
+
import "./platform-CNhm9zLi.js";
|
|
3
|
+
import "./atomicJson-DwSqByUJ.js";
|
|
4
|
+
import "./layeredConfig-BqIwPJ-I.js";
|
|
5
|
+
import "./sessionConfig-2a4LWInR.js";
|
|
6
|
+
import "./domains-dHfk2U8X.js";
|
|
7
|
+
import "./majorModes-C-OD4PBc.js";
|
|
8
|
+
import "./harnessStore-CRtlTdbI.js";
|
|
9
9
|
import "node:path";
|
|
10
10
|
({
|
|
11
11
|
"config.yaml": `projectTrust: ask
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as readPoHeadlessHost, at as requirePoServerHost,
|
|
1
|
+
import { Q as readPoHeadlessHost, at as requirePoServerHost, dt as PO_SERVER_SCOPE_LEVELS, ft as PO_SERVER_SCOPE_SERVICE, mt as requirePoServerScope, nt as PO_SERVER_HOST_SERVICE } from "./serverPlugin-H4T49sac.js";
|
|
2
2
|
//#region ../../core/po-core/src/services/pluginLifecycle/index.ts
|
|
3
3
|
/** Runs ordered cleanup steps to completion before reporting their failures. */
|
|
4
4
|
async function runCleanups(steps, message) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@earendil-works+pi-ai@1.5.0_@aws-sdk+credential-provider-node@3.972.86_@modelcontextpro_cbd356c737d8e30c7d704b4728fb9233/node_modules/@earendil-works/pi-ai/dist/api/github-copilot-headers.js
|
|
2
|
+
function inferCopilotInitiator(messages) {
|
|
3
|
+
const last = messages[messages.length - 1];
|
|
4
|
+
return last && last.role !== "user" ? "agent" : "user";
|
|
5
|
+
}
|
|
6
|
+
function hasCopilotVisionInput(messages) {
|
|
7
|
+
return messages.some((msg) => {
|
|
8
|
+
if (msg.role === "user" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
9
|
+
if (msg.role === "toolResult" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
10
|
+
return false;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function buildCopilotDynamicHeaders(params) {
|
|
14
|
+
const headers = {
|
|
15
|
+
"X-Initiator": inferCopilotInitiator(params.messages),
|
|
16
|
+
"Openai-Intent": "conversation-edits"
|
|
17
|
+
};
|
|
18
|
+
if (params.hasImages) headers["Copilot-Vision-Request"] = "true";
|
|
19
|
+
return headers;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { hasCopilotVisionInput as n, buildCopilotDynamicHeaders as t };
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { d as collapseSystemMessages, g as getInitialSystemMessage, m as getCurrentTools, n as clampThinkingLevel, t as calculateCost } from "./models-D6d73jcW.js";
|
|
2
|
+
import { n as getIdentityHeaders, s as getSystemMessageText } from "./identity-BIeAyilV.js";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-DWrW31_K.js";
|
|
4
|
+
import { i as AssistantMessageEventStream } from "./diagnostics-DPTP-yrt.js";
|
|
5
|
+
import { n as providerHeadersToRecord } from "./headers-BEuxFxDI.js";
|
|
6
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Dl4ROF7y.js";
|
|
7
|
+
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DQZRsyL5.js";
|
|
8
|
+
import { a as mapStopReason, c as retainThoughtSignature, d as toGoogleSdkThinkingLevel, f as toGoogleThinkingLevel, i as isThinkingPart, l as retryGoogleRequest, m as GoogleGenAI, n as convertTools, o as resolveGoogleFunctionCallingMode, p as usesGoogleThinkingLevel, r as getDisabledGoogleThinkingConfig, s as resolveGoogleThinkingLevel, t as convertMessages, u as supportsGoogleStrictToolSampling } from "./google-shared-S7bqOccz.js";
|
|
9
|
+
//#region ../../../node_modules/.pnpm/@earendil-works+pi-ai@1.5.0_@aws-sdk+credential-provider-node@3.972.86_@modelcontextpro_cbd356c737d8e30c7d704b4728fb9233/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
|
|
10
|
+
let toolCallCounter = 0;
|
|
11
|
+
const stream = (model, context, options) => {
|
|
12
|
+
const stream = new AssistantMessageEventStream();
|
|
13
|
+
const normalizedContext = collapseSystemMessages(context);
|
|
14
|
+
(async () => {
|
|
15
|
+
const output = {
|
|
16
|
+
role: "assistant",
|
|
17
|
+
content: [],
|
|
18
|
+
api: "google-generative-ai",
|
|
19
|
+
provider: model.provider,
|
|
20
|
+
model: model.id,
|
|
21
|
+
usage: {
|
|
22
|
+
input: 0,
|
|
23
|
+
output: 0,
|
|
24
|
+
cacheRead: 0,
|
|
25
|
+
cacheWrite: 0,
|
|
26
|
+
totalTokens: 0,
|
|
27
|
+
cost: {
|
|
28
|
+
input: 0,
|
|
29
|
+
output: 0,
|
|
30
|
+
cacheRead: 0,
|
|
31
|
+
cacheWrite: 0,
|
|
32
|
+
total: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
stopReason: "pending",
|
|
36
|
+
timestamp: Date.now()
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
if (options?.fetch && options.fetch !== globalThis.fetch) throw new Error("Custom fetch is not supported by the Google Generative AI adapter");
|
|
40
|
+
const apiKey = options?.apiKey;
|
|
41
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
42
|
+
const client = createClient(model, apiKey, options?.headers, options?.identity);
|
|
43
|
+
let params = buildParams(model, normalizedContext, options);
|
|
44
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
45
|
+
if (nextParams !== void 0) params = nextParams;
|
|
46
|
+
const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);
|
|
47
|
+
stream.push({
|
|
48
|
+
type: "start",
|
|
49
|
+
partial: output
|
|
50
|
+
});
|
|
51
|
+
let currentBlock = null;
|
|
52
|
+
const blocks = output.content;
|
|
53
|
+
const blockIndex = () => blocks.length - 1;
|
|
54
|
+
for await (const chunk of googleStream) {
|
|
55
|
+
await options?.onProviderStreamEvent?.(chunk, model);
|
|
56
|
+
output.responseId ||= chunk.responseId;
|
|
57
|
+
const candidate = chunk.candidates?.[0];
|
|
58
|
+
if (candidate?.content?.parts) for (const part of candidate.content.parts) {
|
|
59
|
+
if (part.text !== void 0) {
|
|
60
|
+
const isThinking = isThinkingPart(part);
|
|
61
|
+
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
62
|
+
if (currentBlock) {
|
|
63
|
+
if (currentBlock.type === "text") stream.push({
|
|
64
|
+
type: "text_end",
|
|
65
|
+
contentIndex: blocks.length - 1,
|
|
66
|
+
content: currentBlock.text,
|
|
67
|
+
partial: output
|
|
68
|
+
});
|
|
69
|
+
else stream.push({
|
|
70
|
+
type: "thinking_end",
|
|
71
|
+
contentIndex: blockIndex(),
|
|
72
|
+
content: currentBlock.thinking,
|
|
73
|
+
partial: output
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (isThinking) {
|
|
77
|
+
currentBlock = {
|
|
78
|
+
type: "thinking",
|
|
79
|
+
thinking: "",
|
|
80
|
+
thinkingSignature: void 0
|
|
81
|
+
};
|
|
82
|
+
output.content.push(currentBlock);
|
|
83
|
+
stream.push({
|
|
84
|
+
type: "thinking_start",
|
|
85
|
+
contentIndex: blockIndex(),
|
|
86
|
+
partial: output
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
currentBlock = {
|
|
90
|
+
type: "text",
|
|
91
|
+
text: ""
|
|
92
|
+
};
|
|
93
|
+
output.content.push(currentBlock);
|
|
94
|
+
stream.push({
|
|
95
|
+
type: "text_start",
|
|
96
|
+
contentIndex: blockIndex(),
|
|
97
|
+
partial: output
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (currentBlock.type === "thinking") {
|
|
102
|
+
currentBlock.thinking += part.text;
|
|
103
|
+
currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
|
|
104
|
+
stream.push({
|
|
105
|
+
type: "thinking_delta",
|
|
106
|
+
contentIndex: blockIndex(),
|
|
107
|
+
delta: part.text,
|
|
108
|
+
partial: output
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
currentBlock.text += part.text;
|
|
112
|
+
currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
|
|
113
|
+
stream.push({
|
|
114
|
+
type: "text_delta",
|
|
115
|
+
contentIndex: blockIndex(),
|
|
116
|
+
delta: part.text,
|
|
117
|
+
partial: output
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (part.functionCall) {
|
|
122
|
+
if (currentBlock) {
|
|
123
|
+
if (currentBlock.type === "text") stream.push({
|
|
124
|
+
type: "text_end",
|
|
125
|
+
contentIndex: blockIndex(),
|
|
126
|
+
content: currentBlock.text,
|
|
127
|
+
partial: output
|
|
128
|
+
});
|
|
129
|
+
else stream.push({
|
|
130
|
+
type: "thinking_end",
|
|
131
|
+
contentIndex: blockIndex(),
|
|
132
|
+
content: currentBlock.thinking,
|
|
133
|
+
partial: output
|
|
134
|
+
});
|
|
135
|
+
currentBlock = null;
|
|
136
|
+
}
|
|
137
|
+
const providedId = part.functionCall.id;
|
|
138
|
+
const toolCall = {
|
|
139
|
+
type: "toolCall",
|
|
140
|
+
id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
|
|
141
|
+
name: part.functionCall.name || "",
|
|
142
|
+
arguments: part.functionCall.args ?? {},
|
|
143
|
+
...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
|
|
144
|
+
};
|
|
145
|
+
output.content.push(toolCall);
|
|
146
|
+
stream.push({
|
|
147
|
+
type: "toolcall_start",
|
|
148
|
+
contentIndex: blockIndex(),
|
|
149
|
+
partial: output
|
|
150
|
+
});
|
|
151
|
+
stream.push({
|
|
152
|
+
type: "toolcall_delta",
|
|
153
|
+
contentIndex: blockIndex(),
|
|
154
|
+
delta: JSON.stringify(toolCall.arguments),
|
|
155
|
+
partial: output
|
|
156
|
+
});
|
|
157
|
+
stream.push({
|
|
158
|
+
type: "toolcall_end",
|
|
159
|
+
contentIndex: blockIndex(),
|
|
160
|
+
toolCall,
|
|
161
|
+
partial: output
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (candidate?.finishReason) {
|
|
166
|
+
output.rawStopReason = candidate.finishReason;
|
|
167
|
+
output.stopReason = mapStopReason(candidate.finishReason);
|
|
168
|
+
if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") output.stopReason = "toolUse";
|
|
169
|
+
}
|
|
170
|
+
if (chunk.usageMetadata) {
|
|
171
|
+
output.usage = {
|
|
172
|
+
input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
|
|
173
|
+
output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
|
|
174
|
+
cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
|
|
175
|
+
cacheWrite: 0,
|
|
176
|
+
reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
|
|
177
|
+
totalTokens: chunk.usageMetadata.totalTokenCount || 0,
|
|
178
|
+
cost: {
|
|
179
|
+
input: 0,
|
|
180
|
+
output: 0,
|
|
181
|
+
cacheRead: 0,
|
|
182
|
+
cacheWrite: 0,
|
|
183
|
+
total: 0
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
calculateCost(model, output.usage);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (currentBlock) {
|
|
190
|
+
if (currentBlock.type === "text") stream.push({
|
|
191
|
+
type: "text_end",
|
|
192
|
+
contentIndex: blockIndex(),
|
|
193
|
+
content: currentBlock.text,
|
|
194
|
+
partial: output
|
|
195
|
+
});
|
|
196
|
+
else stream.push({
|
|
197
|
+
type: "thinking_end",
|
|
198
|
+
contentIndex: blockIndex(),
|
|
199
|
+
content: currentBlock.thinking,
|
|
200
|
+
partial: output
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
204
|
+
if (output.stopReason === "pending") throw new Error("Google stream ended without a finish reason");
|
|
205
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
206
|
+
const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
|
|
207
|
+
throw new Error(errorMessage);
|
|
208
|
+
}
|
|
209
|
+
stream.push({
|
|
210
|
+
type: "done",
|
|
211
|
+
reason: output.stopReason,
|
|
212
|
+
message: output
|
|
213
|
+
});
|
|
214
|
+
stream.end();
|
|
215
|
+
} catch (error) {
|
|
216
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
217
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
218
|
+
stream.push({
|
|
219
|
+
type: "error",
|
|
220
|
+
reason: output.stopReason,
|
|
221
|
+
error: output
|
|
222
|
+
});
|
|
223
|
+
stream.end();
|
|
224
|
+
}
|
|
225
|
+
})();
|
|
226
|
+
return stream;
|
|
227
|
+
};
|
|
228
|
+
const streamSimple = (model, context, options) => {
|
|
229
|
+
const apiKey = options?.apiKey;
|
|
230
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
231
|
+
const base = {
|
|
232
|
+
...buildBaseOptions(model, context, options, apiKey),
|
|
233
|
+
toolChoice: options?.toolChoice
|
|
234
|
+
};
|
|
235
|
+
if (!options?.reasoning) return stream(model, context, {
|
|
236
|
+
...base,
|
|
237
|
+
thinking: { enabled: false }
|
|
238
|
+
});
|
|
239
|
+
const clampedReasoning = clampThinkingLevel(model, options.reasoning);
|
|
240
|
+
if (clampedReasoning === "off") return stream(model, context, {
|
|
241
|
+
...base,
|
|
242
|
+
thinking: { enabled: false }
|
|
243
|
+
});
|
|
244
|
+
const resolvedLevel = resolveGoogleThinkingLevel(model, clampedReasoning);
|
|
245
|
+
if (usesGoogleThinkingLevel(model)) return stream(model, context, {
|
|
246
|
+
...base,
|
|
247
|
+
thinking: {
|
|
248
|
+
enabled: true,
|
|
249
|
+
level: toGoogleThinkingLevel(resolvedLevel)
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return stream(model, context, {
|
|
253
|
+
...base,
|
|
254
|
+
thinking: {
|
|
255
|
+
enabled: true,
|
|
256
|
+
budgetTokens: getGoogleBudget(model, resolvedLevel, options.thinkingBudgets)
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
function createClient(model, apiKey, optionsHeaders, identity) {
|
|
261
|
+
const httpOptions = {};
|
|
262
|
+
if (model.baseUrl) {
|
|
263
|
+
httpOptions.baseUrl = model.baseUrl;
|
|
264
|
+
httpOptions.apiVersion = "";
|
|
265
|
+
}
|
|
266
|
+
const headers = providerHeadersToRecord(getIdentityHeaders(model, identity), model.headers, optionsHeaders);
|
|
267
|
+
if (headers) httpOptions.headers = headers;
|
|
268
|
+
return new GoogleGenAI({
|
|
269
|
+
apiKey,
|
|
270
|
+
httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function buildParams(model, context, options = {}) {
|
|
274
|
+
const contents = convertMessages(model, context);
|
|
275
|
+
const initialSystemMessage = getInitialSystemMessage(context.messages);
|
|
276
|
+
const currentTools = getCurrentTools(context.messages);
|
|
277
|
+
const generationConfig = {};
|
|
278
|
+
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
279
|
+
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
280
|
+
const supportsStrictMode = supportsGoogleStrictToolSampling(model.id);
|
|
281
|
+
const functionCallingMode = currentTools.length > 0 ? resolveGoogleFunctionCallingMode(currentTools, options.toolChoice, supportsStrictMode) : void 0;
|
|
282
|
+
const systemInstruction = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : "";
|
|
283
|
+
const config = {
|
|
284
|
+
...Object.keys(generationConfig).length > 0 && generationConfig,
|
|
285
|
+
...systemInstruction && { systemInstruction: sanitizeSurrogates(systemInstruction) },
|
|
286
|
+
...currentTools.length > 0 && { tools: convertTools(currentTools, false, supportsStrictMode) },
|
|
287
|
+
...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
|
|
288
|
+
};
|
|
289
|
+
if (options.thinking?.enabled && model.reasoning) {
|
|
290
|
+
const thinkingConfig = { includeThoughts: true };
|
|
291
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = toGoogleSdkThinkingLevel(options.thinking.level);
|
|
292
|
+
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
293
|
+
config.thinkingConfig = thinkingConfig;
|
|
294
|
+
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledGoogleThinkingConfig(model);
|
|
295
|
+
if (options.signal) {
|
|
296
|
+
if (options.signal.aborted) throw new Error("Request aborted");
|
|
297
|
+
config.abortSignal = options.signal;
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
model: model.id,
|
|
301
|
+
contents,
|
|
302
|
+
config
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function getGoogleBudget(model, level, customBudgets) {
|
|
306
|
+
if (customBudgets?.[level] !== void 0) return customBudgets[level];
|
|
307
|
+
if (model.id.includes("2.5-pro")) return {
|
|
308
|
+
minimal: 128,
|
|
309
|
+
low: 2048,
|
|
310
|
+
medium: 8192,
|
|
311
|
+
high: 32768
|
|
312
|
+
}[level];
|
|
313
|
+
if (model.id.includes("2.5-flash-lite")) return {
|
|
314
|
+
minimal: 512,
|
|
315
|
+
low: 2048,
|
|
316
|
+
medium: 8192,
|
|
317
|
+
high: 24576
|
|
318
|
+
}[level];
|
|
319
|
+
if (model.id.includes("2.5-flash")) return {
|
|
320
|
+
minimal: 128,
|
|
321
|
+
low: 2048,
|
|
322
|
+
medium: 8192,
|
|
323
|
+
high: 24576
|
|
324
|
+
}[level];
|
|
325
|
+
return -1;
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
export { stream, streamSimple };
|