@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,374 @@
|
|
|
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 { t as getProviderEnvValue } from "./provider-env-DgfpjgTa.js";
|
|
6
|
+
import { n as providerHeadersToRecord } from "./headers-BEuxFxDI.js";
|
|
7
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Dl4ROF7y.js";
|
|
8
|
+
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-DQZRsyL5.js";
|
|
9
|
+
import { a as mapStopReason, c as retainThoughtSignature, d as toGoogleSdkThinkingLevel, f as toGoogleThinkingLevel, h as ResourceScope, 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";
|
|
10
|
+
//#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-vertex.js
|
|
11
|
+
const API_VERSION = "v1";
|
|
12
|
+
const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
|
|
13
|
+
let toolCallCounter = 0;
|
|
14
|
+
const stream = (model, context, options) => {
|
|
15
|
+
const stream = new AssistantMessageEventStream();
|
|
16
|
+
const normalizedContext = collapseSystemMessages(context);
|
|
17
|
+
(async () => {
|
|
18
|
+
const output = {
|
|
19
|
+
role: "assistant",
|
|
20
|
+
content: [],
|
|
21
|
+
api: "google-vertex",
|
|
22
|
+
provider: model.provider,
|
|
23
|
+
model: model.id,
|
|
24
|
+
usage: {
|
|
25
|
+
input: 0,
|
|
26
|
+
output: 0,
|
|
27
|
+
cacheRead: 0,
|
|
28
|
+
cacheWrite: 0,
|
|
29
|
+
totalTokens: 0,
|
|
30
|
+
cost: {
|
|
31
|
+
input: 0,
|
|
32
|
+
output: 0,
|
|
33
|
+
cacheRead: 0,
|
|
34
|
+
cacheWrite: 0,
|
|
35
|
+
total: 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
stopReason: "pending",
|
|
39
|
+
timestamp: Date.now()
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
if (options?.fetch && options.fetch !== globalThis.fetch) throw new Error("Custom fetch is not supported by the Google Vertex adapter");
|
|
43
|
+
const apiKey = resolveApiKey(options);
|
|
44
|
+
const client = apiKey ? createClientWithApiKey(model, apiKey, options?.headers, options?.identity) : createClient(model, resolveProject(options), resolveLocation(options), options?.headers, options?.env, options?.identity);
|
|
45
|
+
let params = buildParams(model, normalizedContext, options);
|
|
46
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
47
|
+
if (nextParams !== void 0) params = nextParams;
|
|
48
|
+
const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);
|
|
49
|
+
stream.push({
|
|
50
|
+
type: "start",
|
|
51
|
+
partial: output
|
|
52
|
+
});
|
|
53
|
+
let currentBlock = null;
|
|
54
|
+
const blocks = output.content;
|
|
55
|
+
const blockIndex = () => blocks.length - 1;
|
|
56
|
+
for await (const chunk of googleStream) {
|
|
57
|
+
await options?.onProviderStreamEvent?.(chunk, model);
|
|
58
|
+
output.responseId ||= chunk.responseId;
|
|
59
|
+
const candidate = chunk.candidates?.[0];
|
|
60
|
+
if (candidate?.content?.parts) for (const part of candidate.content.parts) {
|
|
61
|
+
if (part.text !== void 0) {
|
|
62
|
+
const isThinking = isThinkingPart(part);
|
|
63
|
+
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
64
|
+
if (currentBlock) {
|
|
65
|
+
if (currentBlock.type === "text") stream.push({
|
|
66
|
+
type: "text_end",
|
|
67
|
+
contentIndex: blocks.length - 1,
|
|
68
|
+
content: currentBlock.text,
|
|
69
|
+
partial: output
|
|
70
|
+
});
|
|
71
|
+
else stream.push({
|
|
72
|
+
type: "thinking_end",
|
|
73
|
+
contentIndex: blockIndex(),
|
|
74
|
+
content: currentBlock.thinking,
|
|
75
|
+
partial: output
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (isThinking) {
|
|
79
|
+
currentBlock = {
|
|
80
|
+
type: "thinking",
|
|
81
|
+
thinking: "",
|
|
82
|
+
thinkingSignature: void 0
|
|
83
|
+
};
|
|
84
|
+
output.content.push(currentBlock);
|
|
85
|
+
stream.push({
|
|
86
|
+
type: "thinking_start",
|
|
87
|
+
contentIndex: blockIndex(),
|
|
88
|
+
partial: output
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
currentBlock = {
|
|
92
|
+
type: "text",
|
|
93
|
+
text: ""
|
|
94
|
+
};
|
|
95
|
+
output.content.push(currentBlock);
|
|
96
|
+
stream.push({
|
|
97
|
+
type: "text_start",
|
|
98
|
+
contentIndex: blockIndex(),
|
|
99
|
+
partial: output
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (currentBlock.type === "thinking") {
|
|
104
|
+
currentBlock.thinking += part.text;
|
|
105
|
+
currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
|
|
106
|
+
stream.push({
|
|
107
|
+
type: "thinking_delta",
|
|
108
|
+
contentIndex: blockIndex(),
|
|
109
|
+
delta: part.text,
|
|
110
|
+
partial: output
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
currentBlock.text += part.text;
|
|
114
|
+
currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
|
|
115
|
+
stream.push({
|
|
116
|
+
type: "text_delta",
|
|
117
|
+
contentIndex: blockIndex(),
|
|
118
|
+
delta: part.text,
|
|
119
|
+
partial: output
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (part.functionCall) {
|
|
124
|
+
if (currentBlock) {
|
|
125
|
+
if (currentBlock.type === "text") stream.push({
|
|
126
|
+
type: "text_end",
|
|
127
|
+
contentIndex: blockIndex(),
|
|
128
|
+
content: currentBlock.text,
|
|
129
|
+
partial: output
|
|
130
|
+
});
|
|
131
|
+
else stream.push({
|
|
132
|
+
type: "thinking_end",
|
|
133
|
+
contentIndex: blockIndex(),
|
|
134
|
+
content: currentBlock.thinking,
|
|
135
|
+
partial: output
|
|
136
|
+
});
|
|
137
|
+
currentBlock = null;
|
|
138
|
+
}
|
|
139
|
+
const providedId = part.functionCall.id;
|
|
140
|
+
const toolCall = {
|
|
141
|
+
type: "toolCall",
|
|
142
|
+
id: !providedId || output.content.some((b) => b.type === "toolCall" && b.id === providedId) ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}` : providedId,
|
|
143
|
+
name: part.functionCall.name || "",
|
|
144
|
+
arguments: part.functionCall.args ?? {},
|
|
145
|
+
...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
|
|
146
|
+
};
|
|
147
|
+
output.content.push(toolCall);
|
|
148
|
+
stream.push({
|
|
149
|
+
type: "toolcall_start",
|
|
150
|
+
contentIndex: blockIndex(),
|
|
151
|
+
partial: output
|
|
152
|
+
});
|
|
153
|
+
stream.push({
|
|
154
|
+
type: "toolcall_delta",
|
|
155
|
+
contentIndex: blockIndex(),
|
|
156
|
+
delta: JSON.stringify(toolCall.arguments),
|
|
157
|
+
partial: output
|
|
158
|
+
});
|
|
159
|
+
stream.push({
|
|
160
|
+
type: "toolcall_end",
|
|
161
|
+
contentIndex: blockIndex(),
|
|
162
|
+
toolCall,
|
|
163
|
+
partial: output
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (candidate?.finishReason) {
|
|
168
|
+
output.rawStopReason = candidate.finishReason;
|
|
169
|
+
output.stopReason = mapStopReason(candidate.finishReason);
|
|
170
|
+
if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") output.stopReason = "toolUse";
|
|
171
|
+
}
|
|
172
|
+
if (chunk.usageMetadata) {
|
|
173
|
+
output.usage = {
|
|
174
|
+
input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),
|
|
175
|
+
output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),
|
|
176
|
+
cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,
|
|
177
|
+
cacheWrite: 0,
|
|
178
|
+
reasoning: chunk.usageMetadata.thoughtsTokenCount || 0,
|
|
179
|
+
totalTokens: chunk.usageMetadata.totalTokenCount || 0,
|
|
180
|
+
cost: {
|
|
181
|
+
input: 0,
|
|
182
|
+
output: 0,
|
|
183
|
+
cacheRead: 0,
|
|
184
|
+
cacheWrite: 0,
|
|
185
|
+
total: 0
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
calculateCost(model, output.usage);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (currentBlock) {
|
|
192
|
+
if (currentBlock.type === "text") stream.push({
|
|
193
|
+
type: "text_end",
|
|
194
|
+
contentIndex: blockIndex(),
|
|
195
|
+
content: currentBlock.text,
|
|
196
|
+
partial: output
|
|
197
|
+
});
|
|
198
|
+
else stream.push({
|
|
199
|
+
type: "thinking_end",
|
|
200
|
+
contentIndex: blockIndex(),
|
|
201
|
+
content: currentBlock.thinking,
|
|
202
|
+
partial: output
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (options?.signal?.aborted) throw new Error("Request was aborted");
|
|
206
|
+
if (output.stopReason === "pending") throw new Error("Google Vertex stream ended without a finish reason");
|
|
207
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
208
|
+
const errorMessage = output.rawStopReason ? `Provider stopped with: ${output.rawStopReason}` : "An unknown error occurred";
|
|
209
|
+
throw new Error(errorMessage);
|
|
210
|
+
}
|
|
211
|
+
stream.push({
|
|
212
|
+
type: "done",
|
|
213
|
+
reason: output.stopReason,
|
|
214
|
+
message: output
|
|
215
|
+
});
|
|
216
|
+
stream.end();
|
|
217
|
+
} catch (error) {
|
|
218
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
219
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
220
|
+
stream.push({
|
|
221
|
+
type: "error",
|
|
222
|
+
reason: output.stopReason,
|
|
223
|
+
error: output
|
|
224
|
+
});
|
|
225
|
+
stream.end();
|
|
226
|
+
}
|
|
227
|
+
})();
|
|
228
|
+
return stream;
|
|
229
|
+
};
|
|
230
|
+
const streamSimple = (model, context, options) => {
|
|
231
|
+
const base = {
|
|
232
|
+
...buildBaseOptions(model, context, options, void 0),
|
|
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, project, location, optionsHeaders, env, identity) {
|
|
261
|
+
const googleAuthOptions = buildGoogleAuthOptions(env);
|
|
262
|
+
return new GoogleGenAI({
|
|
263
|
+
vertexai: true,
|
|
264
|
+
project,
|
|
265
|
+
location,
|
|
266
|
+
apiVersion: API_VERSION,
|
|
267
|
+
...googleAuthOptions ? { googleAuthOptions } : {},
|
|
268
|
+
httpOptions: buildHttpOptions(model, optionsHeaders, identity)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function createClientWithApiKey(model, apiKey, optionsHeaders, identity) {
|
|
272
|
+
return new GoogleGenAI({
|
|
273
|
+
vertexai: true,
|
|
274
|
+
apiKey,
|
|
275
|
+
apiVersion: API_VERSION,
|
|
276
|
+
httpOptions: buildHttpOptions(model, optionsHeaders, identity)
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function buildHttpOptions(model, optionsHeaders, identity) {
|
|
280
|
+
const httpOptions = {};
|
|
281
|
+
const baseUrl = resolveCustomBaseUrl(model.baseUrl);
|
|
282
|
+
if (baseUrl) {
|
|
283
|
+
httpOptions.baseUrl = baseUrl;
|
|
284
|
+
httpOptions.baseUrlResourceScope = ResourceScope.COLLECTION;
|
|
285
|
+
if (baseUrlIncludesApiVersion(baseUrl)) httpOptions.apiVersion = "";
|
|
286
|
+
}
|
|
287
|
+
const headers = providerHeadersToRecord(getIdentityHeaders(model, identity), model.headers, optionsHeaders);
|
|
288
|
+
if (headers) httpOptions.headers = headers;
|
|
289
|
+
return Object.keys(httpOptions).length > 0 ? httpOptions : void 0;
|
|
290
|
+
}
|
|
291
|
+
function resolveCustomBaseUrl(baseUrl) {
|
|
292
|
+
const trimmed = baseUrl.trim();
|
|
293
|
+
if (!trimmed || trimmed.includes("{location}")) return;
|
|
294
|
+
return trimmed;
|
|
295
|
+
}
|
|
296
|
+
function baseUrlIncludesApiVersion(baseUrl) {
|
|
297
|
+
try {
|
|
298
|
+
return new URL(baseUrl).pathname.split("/").some((part) => /^v\d+(?:beta\d*)?$/.test(part));
|
|
299
|
+
} catch {
|
|
300
|
+
return /(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(baseUrl);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function buildGoogleAuthOptions(env) {
|
|
304
|
+
const keyFilename = getProviderEnvValue("GOOGLE_APPLICATION_CREDENTIALS", env);
|
|
305
|
+
return keyFilename ? { keyFilename } : void 0;
|
|
306
|
+
}
|
|
307
|
+
function resolveApiKey(options) {
|
|
308
|
+
const apiKey = options?.apiKey?.trim();
|
|
309
|
+
if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER || isPlaceholderApiKey(apiKey)) return;
|
|
310
|
+
return apiKey;
|
|
311
|
+
}
|
|
312
|
+
function isPlaceholderApiKey(apiKey) {
|
|
313
|
+
return /^<[^>]+>$/.test(apiKey);
|
|
314
|
+
}
|
|
315
|
+
function resolveProject(options) {
|
|
316
|
+
const project = options?.project || getProviderEnvValue("GOOGLE_CLOUD_PROJECT", options?.env) || getProviderEnvValue("GCLOUD_PROJECT", options?.env);
|
|
317
|
+
if (!project) throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
318
|
+
return project;
|
|
319
|
+
}
|
|
320
|
+
function resolveLocation(options) {
|
|
321
|
+
const location = options?.location || getProviderEnvValue("GOOGLE_CLOUD_LOCATION", options?.env);
|
|
322
|
+
if (!location) throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
|
|
323
|
+
return location;
|
|
324
|
+
}
|
|
325
|
+
function buildParams(model, context, options = {}) {
|
|
326
|
+
const contents = convertMessages(model, context);
|
|
327
|
+
const initialSystemMessage = getInitialSystemMessage(context.messages);
|
|
328
|
+
const currentTools = getCurrentTools(context.messages);
|
|
329
|
+
const generationConfig = {};
|
|
330
|
+
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
331
|
+
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
332
|
+
const supportsStrictMode = supportsGoogleStrictToolSampling(model.id);
|
|
333
|
+
const functionCallingMode = currentTools.length > 0 ? resolveGoogleFunctionCallingMode(currentTools, options.toolChoice, supportsStrictMode) : void 0;
|
|
334
|
+
const systemInstruction = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : "";
|
|
335
|
+
const config = {
|
|
336
|
+
...Object.keys(generationConfig).length > 0 && generationConfig,
|
|
337
|
+
...systemInstruction && { systemInstruction: sanitizeSurrogates(systemInstruction) },
|
|
338
|
+
...currentTools.length > 0 && { tools: convertTools(currentTools, false, supportsStrictMode) },
|
|
339
|
+
...functionCallingMode !== void 0 && { toolConfig: { functionCallingConfig: { mode: functionCallingMode } } }
|
|
340
|
+
};
|
|
341
|
+
if (options.thinking?.enabled && model.reasoning) {
|
|
342
|
+
const thinkingConfig = { includeThoughts: true };
|
|
343
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = toGoogleSdkThinkingLevel(options.thinking.level);
|
|
344
|
+
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
345
|
+
config.thinkingConfig = thinkingConfig;
|
|
346
|
+
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = getDisabledGoogleThinkingConfig(model);
|
|
347
|
+
if (options.signal) {
|
|
348
|
+
if (options.signal.aborted) throw new Error("Request aborted");
|
|
349
|
+
config.abortSignal = options.signal;
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
model: model.id,
|
|
353
|
+
contents,
|
|
354
|
+
config
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function getGoogleBudget(model, level, customBudgets) {
|
|
358
|
+
if (customBudgets?.[level] !== void 0) return customBudgets[level];
|
|
359
|
+
if (model.id.includes("2.5-pro")) return {
|
|
360
|
+
minimal: 128,
|
|
361
|
+
low: 2048,
|
|
362
|
+
medium: 8192,
|
|
363
|
+
high: 32768
|
|
364
|
+
}[level];
|
|
365
|
+
if (model.id.includes("2.5-flash")) return {
|
|
366
|
+
minimal: 128,
|
|
367
|
+
low: 2048,
|
|
368
|
+
medium: 8192,
|
|
369
|
+
high: 24576
|
|
370
|
+
}[level];
|
|
371
|
+
return -1;
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { stream, streamSimple };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as nodeHost, s as createSerialRunner } from "./serverPlugin-
|
|
2
|
-
import { t as readTextIfExists } from "./platformFiles-
|
|
3
|
-
import "./platform-
|
|
4
|
-
import "./atomicJson-
|
|
1
|
+
import { c as nodeHost, s as createSerialRunner } from "./serverPlugin-H4T49sac.js";
|
|
2
|
+
import { t as readTextIfExists } from "./platformFiles-3rzOh9cg.js";
|
|
3
|
+
import "./platform-CNhm9zLi.js";
|
|
4
|
+
import "./atomicJson-DwSqByUJ.js";
|
|
5
5
|
import { t as readHarnessState } from "./harnessState-gmzJcPGt.js";
|
|
6
6
|
import "node:path";
|
|
7
7
|
//#region ../../foundations/po-config/src/services/harnessStore/core.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./harnessStore-CRtlTdbI.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
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/utils/hash.js
|
|
2
|
+
/** Fast deterministic hash to shorten long strings */
|
|
3
|
+
function shortHash(str) {
|
|
4
|
+
let h1 = 3735928559;
|
|
5
|
+
let h2 = 1103547991;
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
const ch = str.charCodeAt(i);
|
|
8
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
9
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
10
|
+
}
|
|
11
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
12
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
13
|
+
return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { shortHash as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
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/utils/headers.js
|
|
2
|
+
function headersToRecord(headers) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const [key, value] of headers.entries()) result[key] = value;
|
|
5
|
+
return result;
|
|
6
|
+
}
|
|
7
|
+
function providerHeadersToRecord(...headerSources) {
|
|
8
|
+
const merged = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const source of headerSources) for (const [name, value] of Object.entries(source ?? {})) {
|
|
10
|
+
const normalizedName = name.toLowerCase();
|
|
11
|
+
merged.delete(normalizedName);
|
|
12
|
+
if (value !== null) merged.set(normalizedName, [name, value]);
|
|
13
|
+
}
|
|
14
|
+
return merged.size > 0 ? Object.fromEntries(merged.values()) : void 0;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { providerHeadersToRecord as n, headersToRecord as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pt as defineServiceContract } from "./serverPlugin-H4T49sac.js";
|
|
2
2
|
//#region ../../core/po-core/src/schemas/packageApi.ts
|
|
3
3
|
/** Only canonical resource paths may select a protocol listener. */
|
|
4
4
|
function parsePoSocketPath(pathname) {
|
|
@@ -0,0 +1,165 @@
|
|
|
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/utils/text.js
|
|
2
|
+
/** Extract and join text from message content. */
|
|
3
|
+
function contentText(content, separator = "\n") {
|
|
4
|
+
if (typeof content === "string") return content;
|
|
5
|
+
return content.filter((block) => block.type === "text").map((block) => block.text).join(separator);
|
|
6
|
+
}
|
|
7
|
+
/** Render a system message as a complete prompt: its content followed by its sections. */
|
|
8
|
+
function getSystemMessageText(message) {
|
|
9
|
+
const parts = [contentText(message.content)];
|
|
10
|
+
for (const text of Object.values(message.sections ?? {})) if (text !== null) parts.push(text);
|
|
11
|
+
return parts.filter((part) => part.length > 0).join("\n\n");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Render a later system message for APIs that accept system messages mid-conversation.
|
|
15
|
+
* Section changes are framed by name so the model can relate them to the leading prompt.
|
|
16
|
+
* This framing is request-time only and may change between versions.
|
|
17
|
+
*/
|
|
18
|
+
function renderSystemMessageUpdate(message) {
|
|
19
|
+
const parts = [];
|
|
20
|
+
const text = contentText(message.content);
|
|
21
|
+
if (text.length > 0) parts.push(text);
|
|
22
|
+
for (const [name, value] of Object.entries(message.sections ?? {})) parts.push(value === null ? `Removed system prompt section "${name}".` : `Updated system prompt section "${name}":\n\n${value}`);
|
|
23
|
+
return parts.join("\n\n");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `text.slice(start, end)` as a string of its own. V8 represents a slice of 13 or more characters as a view that keeps
|
|
27
|
+
* all of `text` alive, so a short excerpt kept from a large text (a 500-character error message cut from a megabyte
|
|
28
|
+
* response body) would keep the whole text alive as long as the excerpt lives. Appending a character and slicing it off
|
|
29
|
+
* again makes V8 copy just the slice.
|
|
30
|
+
*/
|
|
31
|
+
function ownedSlice(text, start, end = text.length) {
|
|
32
|
+
return `${text.slice(start, end)} `.slice(0, -1);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#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/identity.js
|
|
36
|
+
/** pi's attribution, used by pi-agent-core, pi-durable, and the coding agent. */
|
|
37
|
+
const PI_ATTRIBUTION = {
|
|
38
|
+
name: "pi",
|
|
39
|
+
url: "https://pi.dev",
|
|
40
|
+
categories: ["cli-agent"]
|
|
41
|
+
};
|
|
42
|
+
const NVIDIA_NIM_HOST = "integrate.api.nvidia.com";
|
|
43
|
+
const OPENCODE_HOST = "opencode.ai";
|
|
44
|
+
/** Merge identities field by field; later sources win and undefined fields are skipped. */
|
|
45
|
+
function mergeClientIdentity(...sources) {
|
|
46
|
+
let merged;
|
|
47
|
+
for (const source of sources) {
|
|
48
|
+
if (!source) continue;
|
|
49
|
+
merged = { ...merged };
|
|
50
|
+
if (source.userAgent !== void 0) merged.userAgent = source.userAgent;
|
|
51
|
+
if (source.attribution !== void 0) merged.attribution = source.attribution;
|
|
52
|
+
if (source.version !== void 0) merged.version = source.version;
|
|
53
|
+
}
|
|
54
|
+
return merged;
|
|
55
|
+
}
|
|
56
|
+
/** The version in the detailed `User-Agent`. */
|
|
57
|
+
function getClientVersion(identity) {
|
|
58
|
+
return identity?.version ?? "1.5.0";
|
|
59
|
+
}
|
|
60
|
+
function runtimeDescription() {
|
|
61
|
+
if (typeof process === "undefined") return void 0;
|
|
62
|
+
const versions = process.versions;
|
|
63
|
+
if (versions?.bun) return `bun/${versions.bun}`;
|
|
64
|
+
if (versions?.node) return `node/${process.version}`;
|
|
65
|
+
}
|
|
66
|
+
/** The `User-Agent` value of an identity. */
|
|
67
|
+
function formatUserAgent(identity) {
|
|
68
|
+
const mode = identity?.userAgent ?? "detailed";
|
|
69
|
+
if (typeof mode === "object") return mode.custom;
|
|
70
|
+
if (mode === "short") return "pi";
|
|
71
|
+
const product = `pi/${getClientVersion(identity)}`;
|
|
72
|
+
const runtime = runtimeDescription();
|
|
73
|
+
return runtime ? `${product} (${process.platform}; ${runtime}; ${process.arch})` : `${product} (browser)`;
|
|
74
|
+
}
|
|
75
|
+
function matchesHost(baseUrl, expectedHost) {
|
|
76
|
+
try {
|
|
77
|
+
return new URL(baseUrl).hostname === expectedHost;
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function isOpenRouter(target) {
|
|
83
|
+
return target.provider === "openrouter" || target.baseUrl.includes("openrouter.ai");
|
|
84
|
+
}
|
|
85
|
+
function isNvidiaNim(target) {
|
|
86
|
+
return target.provider === "nvidia" || matchesHost(target.baseUrl, NVIDIA_NIM_HOST);
|
|
87
|
+
}
|
|
88
|
+
function isOpenCode(target) {
|
|
89
|
+
return target.provider === "opencode" || target.provider === "opencode-go" || matchesHost(target.baseUrl, OPENCODE_HOST);
|
|
90
|
+
}
|
|
91
|
+
/** Provider attribution headers of an identity for a request target. Empty when attribution is off. */
|
|
92
|
+
function getAttributionHeaders(target, identity) {
|
|
93
|
+
const attribution = identity?.attribution;
|
|
94
|
+
if (!attribution) return {};
|
|
95
|
+
const { name, url, categories } = attribution;
|
|
96
|
+
if (isOpenRouter(target)) return {
|
|
97
|
+
"HTTP-Referer": url,
|
|
98
|
+
"X-OpenRouter-Title": name,
|
|
99
|
+
...categories === void 0 || categories.length === 0 ? {} : { "X-OpenRouter-Categories": categories.join(",") }
|
|
100
|
+
};
|
|
101
|
+
if (isNvidiaNim(target)) return { "X-BILLING-INVOKE-ORIGIN": name.charAt(0).toUpperCase() + name.slice(1) };
|
|
102
|
+
if (isOpenCode(target)) return { "x-opencode-client": name };
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* OpenCode's per-conversation routing header for requests to OpenCode, including custom providers pointing at it.
|
|
107
|
+
* Undefined without a session or for other targets.
|
|
108
|
+
*/
|
|
109
|
+
function getOpenCodeSessionHeaders(target, sessionId) {
|
|
110
|
+
return sessionId && isOpenCode(target) ? { "x-opencode-session": sessionId } : void 0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Default headers an identity adds to a request: `User-Agent` and provider attribution. APIs apply them below model,
|
|
114
|
+
* provider, and request headers, so configured headers override them and `null` request headers remove them.
|
|
115
|
+
*/
|
|
116
|
+
function getIdentityHeaders(target, identity) {
|
|
117
|
+
return {
|
|
118
|
+
"User-Agent": formatUserAgent(identity),
|
|
119
|
+
...getAttributionHeaders(target, identity)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function isMutableModels(models) {
|
|
123
|
+
return "setProvider" in models && "deleteProvider" in models && "clearProviders" in models;
|
|
124
|
+
}
|
|
125
|
+
function withClientIdentity(models, identity) {
|
|
126
|
+
const withIdentity = (options) => ({
|
|
127
|
+
...options,
|
|
128
|
+
identity: mergeClientIdentity(identity, options?.identity)
|
|
129
|
+
});
|
|
130
|
+
const wrapped = {
|
|
131
|
+
getProviders: () => models.getProviders(),
|
|
132
|
+
getProvider: (id) => models.getProvider(id),
|
|
133
|
+
getModels: (provider) => models.getModels(provider),
|
|
134
|
+
getModel: (provider, id) => models.getModel(provider, id),
|
|
135
|
+
getModelsOfType: (type, provider) => models.getModelsOfType(type, provider),
|
|
136
|
+
getModelOfType: (type, provider, id) => models.getModelOfType(type, provider, id),
|
|
137
|
+
getAllModels: (provider) => models.getAllModels(provider),
|
|
138
|
+
refresh: (options) => models.refresh(options),
|
|
139
|
+
checkAuth: (providerId, options) => models.checkAuth(providerId, options),
|
|
140
|
+
getAvailable: (providerId, options) => models.getAvailable(providerId, options),
|
|
141
|
+
getAvailableOfType: (type, providerId, options) => models.getAvailableOfType(type, providerId, options),
|
|
142
|
+
getAllAvailable: (providerId, options) => models.getAllAvailable(providerId, options),
|
|
143
|
+
getAuth: models.getAuth.bind(models),
|
|
144
|
+
login: (providerId, type, interaction, options) => models.login(providerId, type, interaction, options),
|
|
145
|
+
logout: (providerId, options) => models.logout(providerId, options),
|
|
146
|
+
stream: (model, context, options) => models.stream(model, context, withIdentity(options)),
|
|
147
|
+
complete: (model, context, options) => models.complete(model, context, withIdentity(options)),
|
|
148
|
+
streamSimple: (model, context, options) => models.streamSimple(model, context, withIdentity(options)),
|
|
149
|
+
completeSimple: (model, context, options) => models.completeSimple(model, context, withIdentity(options)),
|
|
150
|
+
streamDeferred: (model, handle, options) => models.streamDeferred(model, handle, withIdentity(options)),
|
|
151
|
+
fetchDeferred: (model, handle, options) => models.fetchDeferred(model, handle, withIdentity(options)),
|
|
152
|
+
cancelDeferred: (model, handle, options) => models.cancelDeferred(model, handle, withIdentity(options)),
|
|
153
|
+
generateImages: (model, context, options) => models.generateImages(model, context, withIdentity(options)),
|
|
154
|
+
classify: (model, context, options) => models.classify(model, context, withIdentity(options))
|
|
155
|
+
};
|
|
156
|
+
if (!isMutableModels(models)) return wrapped;
|
|
157
|
+
return {
|
|
158
|
+
...wrapped,
|
|
159
|
+
setProvider: (provider) => models.setProvider(provider),
|
|
160
|
+
deleteProvider: (id) => models.deleteProvider(id),
|
|
161
|
+
clearProviders: () => models.clearProviders()
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { withClientIdentity as a, ownedSlice as c, mergeClientIdentity as i, renderSystemMessageUpdate as l, getIdentityHeaders as n, contentText as o, getOpenCodeSessionHeaders as r, getSystemMessageText as s, PI_ATTRIBUTION as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as nodeHost, o as poHomeDirectory } from "./serverPlugin-
|
|
2
|
-
import { t as readTextIfExists } from "./platformFiles-
|
|
3
|
-
import "./platform-
|
|
1
|
+
import { c as nodeHost, o as poHomeDirectory } from "./serverPlugin-H4T49sac.js";
|
|
2
|
+
import { t as readTextIfExists } from "./platformFiles-3rzOh9cg.js";
|
|
3
|
+
import "./platform-CNhm9zLi.js";
|
|
4
4
|
import "./piSettings-B6fsgIBA.js";
|
|
5
5
|
import "node:crypto";
|
|
6
6
|
import path from "node:path";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./majorModes-C-OD4PBc.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as nodeHost, f as getOrThrow } from "./serverPlugin-
|
|
2
|
-
import { t as readTextIfExists } from "./platformFiles-
|
|
3
|
-
import "./platform-
|
|
4
|
-
import { t as readPoConfigSourcesAsync } from "./layeredConfig-
|
|
1
|
+
import { c as nodeHost, f as getOrThrow } from "./serverPlugin-H4T49sac.js";
|
|
2
|
+
import { t as readTextIfExists } from "./platformFiles-3rzOh9cg.js";
|
|
3
|
+
import "./platform-CNhm9zLi.js";
|
|
4
|
+
import { t as readPoConfigSourcesAsync } from "./layeredConfig-BqIwPJ-I.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region ../../foundations/po-config/src/services/majorModes/core.ts
|
|
7
7
|
const MODES_FILE = "modes.yaml";
|