@agimon-ai/po-cloudflare 0.0.2-alpha.2 → 0.0.2-alpha.20
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-DTjnYFAN.js +6850 -0
- package/dist/anthropic-messages-5ODquUB-.js +14317 -0
- package/dist/{apiContracts-CHOiCbS_.js → apiContracts-DepyzMNr.js} +94 -81
- package/dist/{approval-BMXqnTYd.js → approval-Biq3NCWj.js} +19 -3
- package/dist/{approvalPrompt-Bg1JrEEY.js → approvalPrompt-DoHlIPkU.js} +2 -2
- package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-BU8DeV_G.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-BkzARjqu.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-B_dgnlXa.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53-DMGAifk0.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-DwTSK4lj.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-IRaOcC_u.js} +2 -2
- package/dist/assets/assets/channel-BXwM62E-.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-BvS46crW.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T--n96Xbj0.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-D3h_hFRi.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-Cj18feJl.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-DXsT43bg.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-Br7dX7yf.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-BcozAtPo.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-B8kgXgRq.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-Dn7UnsqE.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-BSJot0vi.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-Cpf1EfZK.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-Dnc36uZR.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-C9Ka5KSI.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-BV8_A7x3.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-C4Ne_31B.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-Dq9ModsA.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-1BWEjXP9.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-DREkvC_x.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-CWziP8nx.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-DOoYmcvz.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-OoAtEico.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-B-pl2-iR.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-uKzNJSZ2.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-CEXY_Tzu.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-MKlRQo-g.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-c2qlCEVs.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-DTdqLA6J.js} +2 -2
- package/dist/assets/assets/{dist-B3JXhDWV.js → dist-4TUOlkyl.js} +2 -2
- package/dist/assets/assets/{dist-1-mhYUBH.js → dist-BzTxJnSR.js} +2 -2
- package/dist/assets/assets/{dist-XIZum9n5.js → dist-D9lacOpq.js} +2 -2
- package/dist/assets/assets/{dist-gfbb4ygy.js → dist-DCKskbBE.js} +2 -2
- package/dist/assets/assets/{dist-h6SOnP8-.js → dist-DCc8tQ7G.js} +2 -2
- package/dist/assets/assets/{dist-Izr2SB3q.js → dist-DXlts_H5.js} +2 -2
- package/dist/assets/assets/{dist-DvgCCshF.js → dist-DvZCwSZ8.js} +2 -2
- package/dist/assets/assets/{dist-BabjcJ3j.js → dist-mQUN8X3n.js} +2 -2
- package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-qZHwVT1x.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-C89wxfCd.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-BMBgLOae.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-Bb04CRa4.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-DSyNf2MV.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-DXuTqLUd.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-sB7-pF_t.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-pWPBCmdT.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-DronDRed.js} +2 -2
- package/dist/assets/assets/index-CBNQEGK3.css +1 -0
- package/dist/assets/assets/index-DdAdCxGc.js +155 -0
- package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-B375mT1i.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-9Hw3wWP7.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-CdPAuupk.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-hqmaHM9u.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-BdOHplX4.js} +2 -2
- package/dist/assets/assets/{line-BsXJZn93.js → line-BCSC3Bu2.js} +2 -2
- package/dist/assets/assets/{linear-BHYaD5T0.js → linear-D5ddQU3r.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-BaSUi_Ph.js} +4 -4
- package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-CUUsU9Ou.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-BtVkhvIZ.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-CQ3OUDwI.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-DDnq-Kn3.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-BvOFTkQB.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-Bdwhl9jD.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-GHKoDEeT.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-Yk9rKkKW.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-Crr2QEwm.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-CLrgwBog.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-zWReI6MC.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-CnVnlaHi.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-MJ68mMla.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-BYb-mTCH.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-DzONJsqQ.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-0vav9YWV.js} +2 -2
- package/dist/assets/assets/{src-gihY33R9.js → src-DZJUnjaM.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-B0M8THPh.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-5YJZCHIB.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-aJTRXiIU.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-us1LwUHo.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-BSLlcDre.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-DZ2SwLmk.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-BrmvO_6k.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-FKXSeKp5.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-DZ_vIMp2.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-CfLYNckm.js} +2 -2
- package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-CiS_BB3R.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-DBucwhQh.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-C3j1WCCq.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-Czm_C4SJ.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -0
- package/dist/assets/plugins/slots/approval.3e4ea6e4-CqQk6XG_.js +2 -0
- package/dist/assets/plugins/slots/artifacts.84980c32-DQlO5IFk.js +1 -0
- package/dist/assets/plugins/slots/autocompact.ec8f713f-B3KTYwW1.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.16ef5e25-CZRYQVIP.js +7 -0
- package/dist/assets/plugins/slots/codemode.5f359b9c-Bzl_K_vt.js +10 -0
- package/dist/assets/plugins/slots/domain.832848c8-CvnpuKCY.js +1 -0
- package/dist/assets/plugins/slots/edit.7c802139-kaxIknZ-.js +7 -0
- package/dist/assets/plugins/slots/files.364f16c9-wuB8gcQA.js +2 -0
- package/dist/assets/plugins/slots/grep.d8bf9f57-3FnU8p-d.js +1 -0
- package/dist/assets/plugins/slots/log.07fd59a4-C0PXQ0O1.js +4 -0
- package/dist/assets/plugins/slots/mcp.ea8b6aa2-D0CkHnIw.js +109 -0
- package/dist/assets/plugins/slots/profile.63bc3ae6-BSY3iYfJ.js +1 -0
- package/dist/assets/plugins/slots/prompts.9d9b47cc-xdCkNkoA.js +3 -0
- package/dist/assets/plugins/slots/read.926c024f-qqaxVlEX.js +1 -0
- package/dist/assets/plugins/slots/runner.5393fa6c-DfO2Z9HG.js +8 -0
- package/dist/assets/plugins/slots/skill.56c1cc07-CL_n-l4h.js +4 -0
- package/dist/assets/plugins/slots/vault.587549ba-DbG3F_on.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-DCIsEywH.js} +3 -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-Bswjs1av.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-CgVosRtU.js} +5 -2
- package/dist/contracts-CylyLZC8.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/{domains-BNjGTOPj.js → domains-BqChtBLN.js} +90 -16
- 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-BNZz2DNU.js → exports-C_dclnKs.js} +24 -9
- package/dist/{remoteMcp-CMqZldeA.js → exports-DERO0cQf.js} +1154 -175
- package/dist/{extensionFile-CXOa5G4C.js → extensionFile-Ds7RCpnb.js} +12 -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/{harnessStore-BT706Ly6.js → harnessStore-BectazJQ.js} +4 -4
- package/dist/harnessStore-C0Zwvny8.js +1 -0
- package/dist/hash-Dt6RIbkn.js +16 -0
- package/dist/headers-CwtEVQvr.js +17 -0
- package/dist/help-Dpm82qDr.js +91 -0
- package/dist/{hubChannel-BHQyzcOo.js → hubChannel-COvmdWGO.js} +11 -28
- package/dist/hubRevisions-58pU2dW5.js +363 -0
- package/dist/identity-BgfHobJH.js +165 -0
- package/dist/index.edge-B0D_Lgbx.js +56 -0
- package/dist/index.edge-BLmsRNW8.js +57 -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-BgSx_gRO.js → index.edge-b0z7PQ6b.js} +10 -5
- package/dist/iso-BPQViXM8.js +10 -0
- package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-pQGjhAks.js} +124 -15
- package/dist/{majorModes-DbCfLZH3.js → majorModes-BrL4EtzH.js} +5 -14
- package/dist/majorModes-WXt22_km.js +1 -0
- package/dist/{mcpProjection-BsP0IEnb.js → mcpProjection-pbPBBuvs.js} +2 -2
- package/dist/migrations-5gbLIQIc.js +32 -0
- package/dist/mistral-conversations-CLwhVDjA.js +689 -0
- package/dist/models-Chzm15vC.js +1511 -0
- package/dist/node-BT4GsJQp.js +2479 -0
- package/dist/node-DytJOfYf.js +23 -0
- package/dist/notification-CINsJWDL.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/photon_rs_bg.wasm +0 -0
- package/dist/pi-messages-BXfrZLC7.js +312 -0
- package/dist/piConfig-BDUpA6w0.js +127 -0
- package/dist/piSettings-tdui0CZI.js +1 -0
- package/dist/{platform-B4AAgwJ0.js → platform-yhQXrrM_.js} +1 -1
- package/dist/{platformFiles-C_bXo4Ig.js → platformFiles-DB3Cw1l_.js} +27 -2
- package/dist/pluginContributions-Be9EnCAW.js +16 -0
- package/dist/{protocol-Xpm_mCNN.js → protocol-B6LbEIe6.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-BZh1ZXz_.js → server-1O3JEYO0.js} +8 -19
- package/dist/server-B2G-c0hg.js +639 -0
- package/dist/{server-Dpgh8PDh.js → server-B8P-UkxF.js} +14 -5
- package/dist/server-BR9yl54i.js +2658 -0
- package/dist/{server-tvgQ99rv.js → server-BXFDsLgm.js} +371 -120
- package/dist/{server-BAAL9-NA.js → server-Bt6Zsqo8.js} +3 -10
- package/dist/server-CCwwnpH0.js +148 -0
- package/dist/{server-D4W7EdJY.js → server-Cgym-G0a.js} +16 -16
- package/dist/{server-DJAanjoI.js → server-Ci3ls6LL.js} +492 -103
- package/dist/{server-36iuA3MI.js → server-Ci_BGVwd.js} +3 -3
- package/dist/{server-A-_GFpPr.js → server-CyYesT-G.js} +10 -9
- package/dist/server-CzJjYgVk.js +295 -0
- package/dist/server-DFCXmDed.js +1806 -0
- package/dist/{server-BE6VqEiA.js → server-DL6UyXfJ.js} +19 -12
- package/dist/{server-D8ndq0wL.js → server-DPTp6GXS.js} +11 -9
- package/dist/server-DRcCuj6P.js +217 -0
- package/dist/server-Dgn4el5K.js +190 -0
- package/dist/server-DhkR6ugd.js +577 -0
- package/dist/server-GIQIpf33.js +489 -0
- package/dist/server-OerXqXJT.js +680 -0
- package/dist/server-Re1VNk9s.js +1517 -0
- package/dist/{server-Dt4y1rZD.js → server-V8W5mcGu.js} +6 -6
- package/dist/server-_0288DYR.js +935 -0
- package/dist/server-cStfn1Yv.js +505 -0
- package/dist/server-pY027myK.js +1057 -0
- package/dist/{build-2gFaVEfG.js → serverPlugin-OOfjB8tm.js} +3937 -3
- package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-DfwcUKO2.js} +551 -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/typesafe-system-one-DGxeggJh.js +37 -0
- package/dist/uuid-B0QJx6Kr.js +31 -0
- package/dist/{validation-D77NZBrx.js → validation-DuOGOKEi.js} +2 -2
- package/dist/{value-Djvc2foV.js → value-DyVsxCwZ.js} +1 -1
- package/dist/vaultSettings-BFCRCBM3.js +328 -0
- package/dist/web-cN41ySs9.js +3 -0
- package/dist/worker.js +95189 -49865
- package/dist/workflow-BgwWq0nq.js +79 -0
- package/package.json +32 -22
- package/wrangler.jsonc +2 -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/harnessStore-BiH9vSuD.js +0 -1
- package/dist/majorModes-BvWNqoHt.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- 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,124 @@
|
|
|
1
|
+
import { n as getIdentityHeaders } from "./identity-BgfHobJH.js";
|
|
2
|
+
import { n as providerHeadersToRecord, t as headersToRecord } from "./headers-CwtEVQvr.js";
|
|
3
|
+
import { t as retryProviderRequest } from "./provider-retry-BUoezuw8.js";
|
|
4
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-C3Ec8oL6.js";
|
|
5
|
+
import { n as OpenAI } from "./openai-kPrtlgjl.js";
|
|
6
|
+
import { n as normalizeProviderError, t as formatProviderError } from "./error-body-CJk7jMUh.js";
|
|
7
|
+
//#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/openrouter-images.js
|
|
8
|
+
/** Image generation over OpenRouter's chat completions endpoint. */
|
|
9
|
+
const generateImages = async (model, context, options) => {
|
|
10
|
+
const output = {
|
|
11
|
+
api: model.api,
|
|
12
|
+
provider: model.provider,
|
|
13
|
+
model: model.id,
|
|
14
|
+
output: [],
|
|
15
|
+
stopReason: "stop",
|
|
16
|
+
timestamp: Date.now()
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
const apiKey = options?.apiKey;
|
|
20
|
+
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
21
|
+
const client = createClient(model, apiKey, options?.headers, options?.fetch, options?.identity);
|
|
22
|
+
let params = buildParams(model, context);
|
|
23
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
24
|
+
if (nextParams !== void 0) params = nextParams;
|
|
25
|
+
const requestOptions = {
|
|
26
|
+
...options?.signal ? { signal: options.signal } : {},
|
|
27
|
+
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
28
|
+
maxRetries: 0
|
|
29
|
+
};
|
|
30
|
+
const { data: response, response: rawResponse } = await retryProviderRequest(() => client.chat.completions.create(params, requestOptions).withResponse(), {
|
|
31
|
+
maxRetries: options?.maxRetries,
|
|
32
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
33
|
+
signal: options?.signal
|
|
34
|
+
});
|
|
35
|
+
await options?.onResponse?.({
|
|
36
|
+
status: rawResponse.status,
|
|
37
|
+
headers: headersToRecord(rawResponse.headers)
|
|
38
|
+
}, model);
|
|
39
|
+
const imageResponse = response;
|
|
40
|
+
output.responseId = imageResponse.id;
|
|
41
|
+
if (imageResponse.usage) output.usage = parseUsage(imageResponse.usage, model);
|
|
42
|
+
const choice = imageResponse.choices[0];
|
|
43
|
+
if (choice) {
|
|
44
|
+
const content = choice.message.content;
|
|
45
|
+
if (typeof content === "string" && content.length > 0) output.output.push({
|
|
46
|
+
type: "text",
|
|
47
|
+
text: content
|
|
48
|
+
});
|
|
49
|
+
for (const image of choice.message.images ?? []) {
|
|
50
|
+
const imageUrl = typeof image.image_url === "string" ? image.image_url : image.image_url?.url;
|
|
51
|
+
if (!imageUrl?.startsWith("data:")) continue;
|
|
52
|
+
const matches = imageUrl.match(/^data:([^;]+);base64,(.+)$/);
|
|
53
|
+
if (!matches) continue;
|
|
54
|
+
output.output.push({
|
|
55
|
+
type: "image",
|
|
56
|
+
mimeType: matches[1],
|
|
57
|
+
data: matches[2]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
64
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
65
|
+
return output;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function createClient(model, apiKey, optionsHeaders, fetch, identity) {
|
|
69
|
+
return new OpenAI({
|
|
70
|
+
apiKey,
|
|
71
|
+
baseURL: model.baseUrl,
|
|
72
|
+
dangerouslyAllowBrowser: true,
|
|
73
|
+
fetch,
|
|
74
|
+
defaultHeaders: providerHeadersToRecord(getIdentityHeaders(model, identity), model.headers, optionsHeaders)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function buildParams(model, context) {
|
|
78
|
+
const content = context.input.map((item) => {
|
|
79
|
+
if (item.type === "text") return {
|
|
80
|
+
type: "text",
|
|
81
|
+
text: sanitizeSurrogates(item.text)
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
type: "image_url",
|
|
85
|
+
image_url: { url: `data:${item.mimeType};base64,${item.data}` }
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
model: model.id,
|
|
90
|
+
messages: [{
|
|
91
|
+
role: "user",
|
|
92
|
+
content
|
|
93
|
+
}],
|
|
94
|
+
stream: false,
|
|
95
|
+
modalities: model.output.includes("text") ? ["image", "text"] : ["image"]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function parseUsage(rawUsage, model) {
|
|
99
|
+
const promptTokens = rawUsage.prompt_tokens || 0;
|
|
100
|
+
const reportedCachedTokens = rawUsage.prompt_tokens_details?.cached_tokens || 0;
|
|
101
|
+
const cacheWriteTokens = rawUsage.prompt_tokens_details?.cache_write_tokens || 0;
|
|
102
|
+
const cacheReadTokens = cacheWriteTokens > 0 ? Math.max(0, reportedCachedTokens - cacheWriteTokens) : reportedCachedTokens;
|
|
103
|
+
const input = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
|
|
104
|
+
const output = rawUsage.completion_tokens || 0;
|
|
105
|
+
const usage = {
|
|
106
|
+
input,
|
|
107
|
+
output,
|
|
108
|
+
cacheRead: cacheReadTokens,
|
|
109
|
+
cacheWrite: cacheWriteTokens,
|
|
110
|
+
totalTokens: input + output + cacheReadTokens + cacheWriteTokens,
|
|
111
|
+
cost: {
|
|
112
|
+
input: model.cost.input / 1e6 * input,
|
|
113
|
+
output: model.cost.output / 1e6 * output,
|
|
114
|
+
cacheRead: model.cost.cacheRead / 1e6 * cacheReadTokens,
|
|
115
|
+
cacheWrite: model.cost.cacheWrite / 1e6 * cacheWriteTokens,
|
|
116
|
+
total: 0,
|
|
117
|
+
totalFromProvider: false
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
121
|
+
return usage;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { generateImages };
|
|
Binary file
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { c as ownedSlice, n as getIdentityHeaders } from "./identity-BgfHobJH.js";
|
|
2
|
+
import { n as ToolCallArgumentsStream } from "./streaming-json-BWTHTwz-.js";
|
|
3
|
+
import { i as AssistantMessageEventStream, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-1lYFeSJe.js";
|
|
4
|
+
import { t as getProviderEnvValue } from "./provider-env-CxhHUFiF.js";
|
|
5
|
+
import { n as providerHeadersToRecord, t as headersToRecord } from "./headers-CwtEVQvr.js";
|
|
6
|
+
//#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/pi-messages.js
|
|
7
|
+
/**
|
|
8
|
+
* pi-messages API implementation.
|
|
9
|
+
*
|
|
10
|
+
* Streams pi's own message protocol directly to a backend: the request is a
|
|
11
|
+
* single POST of `{ model, context, options }` to `<baseUrl>/messages`, the
|
|
12
|
+
* response is an SSE stream of serialized assistant-message events plus a
|
|
13
|
+
* terminal `done`/`error` event. This is the wire protocol spoken by the
|
|
14
|
+
* Radius gateway, but any backend implementing it can be used, e.g. via a
|
|
15
|
+
* models.json custom provider with `"api": "pi-messages"`.
|
|
16
|
+
*/
|
|
17
|
+
var PiMessagesResponseError = class extends Error {
|
|
18
|
+
code;
|
|
19
|
+
diagnosticDetails;
|
|
20
|
+
constructor(message, code, diagnosticDetails) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "PiMessagesResponseError";
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function parsePiMessagesErrorBody(body) {
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(body);
|
|
30
|
+
const error = parsed?.error;
|
|
31
|
+
return parsed && typeof error === "object" && error !== null && !Array.isArray(error) ? parsed : void 0;
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function truncateDiagnosticString(value) {
|
|
37
|
+
const maxLength = 8192;
|
|
38
|
+
return value.length > maxLength ? `${ownedSlice(value, 0, maxLength)}…` : value;
|
|
39
|
+
}
|
|
40
|
+
function formatPiMessagesResponseError(response, body, errorBody) {
|
|
41
|
+
const message = typeof errorBody?.error?.message === "string" ? errorBody.error.message : void 0;
|
|
42
|
+
const code = typeof errorBody?.error?.code === "string" ? errorBody.error.code : void 0;
|
|
43
|
+
const suffix = message ?? body;
|
|
44
|
+
const codeSuffix = code ? ` (${code})` : "";
|
|
45
|
+
return `${response.status} ${response.statusText}: ${suffix}${codeSuffix}`;
|
|
46
|
+
}
|
|
47
|
+
function createPiMessagesResponseError(model, url, response, body) {
|
|
48
|
+
const errorBody = parsePiMessagesErrorBody(body);
|
|
49
|
+
const code = typeof errorBody?.error?.code === "string" ? errorBody.error.code : void 0;
|
|
50
|
+
return new PiMessagesResponseError(formatPiMessagesResponseError(response, body, errorBody), code, {
|
|
51
|
+
version: 1,
|
|
52
|
+
provider: model.provider,
|
|
53
|
+
model: model.id,
|
|
54
|
+
url: url.toString(),
|
|
55
|
+
status: response.status,
|
|
56
|
+
statusText: response.statusText,
|
|
57
|
+
...errorBody?.error === void 0 ? {} : { error: errorBody.error },
|
|
58
|
+
...errorBody ? {} : { body: truncateDiagnosticString(body) },
|
|
59
|
+
timestampMs: Date.now()
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function createEmptyUsage() {
|
|
63
|
+
return {
|
|
64
|
+
input: 0,
|
|
65
|
+
output: 0,
|
|
66
|
+
cacheRead: 0,
|
|
67
|
+
cacheWrite: 0,
|
|
68
|
+
totalTokens: 0,
|
|
69
|
+
cost: {
|
|
70
|
+
input: 0,
|
|
71
|
+
output: 0,
|
|
72
|
+
cacheRead: 0,
|
|
73
|
+
cacheWrite: 0,
|
|
74
|
+
total: 0
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function appendRewriteDiagnostic(message, rewrite) {
|
|
79
|
+
if (!rewrite) return;
|
|
80
|
+
appendAssistantMessageDiagnostic(message, {
|
|
81
|
+
type: "pi_messages_rewrite",
|
|
82
|
+
timestamp: Date.now(),
|
|
83
|
+
details: { ...rewrite }
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function createEventConverter(model) {
|
|
87
|
+
const partial = {
|
|
88
|
+
role: "assistant",
|
|
89
|
+
content: [],
|
|
90
|
+
api: model.api,
|
|
91
|
+
provider: model.provider,
|
|
92
|
+
model: model.id,
|
|
93
|
+
usage: createEmptyUsage(),
|
|
94
|
+
stopReason: "pending",
|
|
95
|
+
timestamp: Date.now()
|
|
96
|
+
};
|
|
97
|
+
const toolArguments = /* @__PURE__ */ new Map();
|
|
98
|
+
return (event) => {
|
|
99
|
+
if ("contentIndex" in event) {
|
|
100
|
+
const index = event.contentIndex;
|
|
101
|
+
const limit = event.type.endsWith("_start") ? partial.content.length : partial.content.length - 1;
|
|
102
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > limit) throw new Error(`Invalid contentIndex ${JSON.stringify(index)} in pi-messages ${event.type} event`);
|
|
103
|
+
}
|
|
104
|
+
switch (event.type) {
|
|
105
|
+
case "done":
|
|
106
|
+
Object.assign(partial, {
|
|
107
|
+
stopReason: event.reason,
|
|
108
|
+
usage: event.usage,
|
|
109
|
+
responseId: event.responseId
|
|
110
|
+
});
|
|
111
|
+
if (event.responseModel !== void 0) partial.responseModel = event.responseModel;
|
|
112
|
+
if (event.providerThinkingLevel !== void 0) partial.providerThinkingLevel = event.providerThinkingLevel;
|
|
113
|
+
appendRewriteDiagnostic(partial, event.rewrite);
|
|
114
|
+
return {
|
|
115
|
+
type: "done",
|
|
116
|
+
reason: event.reason,
|
|
117
|
+
message: partial
|
|
118
|
+
};
|
|
119
|
+
case "error":
|
|
120
|
+
Object.assign(partial, {
|
|
121
|
+
stopReason: event.reason,
|
|
122
|
+
usage: event.usage,
|
|
123
|
+
errorMessage: event.errorMessage,
|
|
124
|
+
responseId: event.responseId
|
|
125
|
+
});
|
|
126
|
+
if (event.responseModel !== void 0) partial.responseModel = event.responseModel;
|
|
127
|
+
if (event.providerThinkingLevel !== void 0) partial.providerThinkingLevel = event.providerThinkingLevel;
|
|
128
|
+
appendRewriteDiagnostic(partial, event.rewrite);
|
|
129
|
+
return {
|
|
130
|
+
type: "error",
|
|
131
|
+
reason: event.reason,
|
|
132
|
+
error: partial
|
|
133
|
+
};
|
|
134
|
+
case "start": break;
|
|
135
|
+
case "text_start":
|
|
136
|
+
partial.content[event.contentIndex] = {
|
|
137
|
+
type: "text",
|
|
138
|
+
text: ""
|
|
139
|
+
};
|
|
140
|
+
break;
|
|
141
|
+
case "text_delta":
|
|
142
|
+
partial.content[event.contentIndex].text += event.delta;
|
|
143
|
+
break;
|
|
144
|
+
case "text_end":
|
|
145
|
+
Object.assign(partial.content[event.contentIndex], {
|
|
146
|
+
text: event.content,
|
|
147
|
+
textSignature: event.contentSignature
|
|
148
|
+
});
|
|
149
|
+
break;
|
|
150
|
+
case "thinking_start":
|
|
151
|
+
partial.content[event.contentIndex] = {
|
|
152
|
+
type: "thinking",
|
|
153
|
+
thinking: ""
|
|
154
|
+
};
|
|
155
|
+
break;
|
|
156
|
+
case "thinking_delta":
|
|
157
|
+
partial.content[event.contentIndex].thinking += event.delta;
|
|
158
|
+
break;
|
|
159
|
+
case "thinking_end":
|
|
160
|
+
Object.assign(partial.content[event.contentIndex], {
|
|
161
|
+
thinking: event.content,
|
|
162
|
+
thinkingSignature: event.contentSignature,
|
|
163
|
+
redacted: event.redacted
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case "toolcall_start":
|
|
167
|
+
partial.content[event.contentIndex] = {
|
|
168
|
+
type: "toolCall",
|
|
169
|
+
id: event.id,
|
|
170
|
+
name: event.toolName,
|
|
171
|
+
arguments: {}
|
|
172
|
+
};
|
|
173
|
+
toolArguments.set(event.contentIndex, new ToolCallArgumentsStream());
|
|
174
|
+
break;
|
|
175
|
+
case "toolcall_delta": {
|
|
176
|
+
const args = toolArguments.get(event.contentIndex);
|
|
177
|
+
if (args !== void 0) partial.content[event.contentIndex].arguments = args.append(event.delta);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "toolcall_end":
|
|
181
|
+
Object.assign(partial.content[event.contentIndex], event.toolCall);
|
|
182
|
+
toolArguments.delete(event.contentIndex);
|
|
183
|
+
return {
|
|
184
|
+
type: "toolcall_end",
|
|
185
|
+
contentIndex: event.contentIndex,
|
|
186
|
+
toolCall: partial.content[event.contentIndex],
|
|
187
|
+
partial
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
...event,
|
|
192
|
+
partial
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async function* readPiMessagesEvents(stream) {
|
|
197
|
+
const decoder = new TextDecoder();
|
|
198
|
+
const reader = stream.getReader();
|
|
199
|
+
let buffer = "";
|
|
200
|
+
try {
|
|
201
|
+
while (true) {
|
|
202
|
+
const { done, value } = await reader.read();
|
|
203
|
+
buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });
|
|
204
|
+
buffer = buffer.replace(/\r\n/g, "\n");
|
|
205
|
+
let split = buffer.indexOf("\n\n");
|
|
206
|
+
while (split !== -1) {
|
|
207
|
+
const event = parsePiMessagesEvent(buffer.slice(0, split));
|
|
208
|
+
if (event) yield event;
|
|
209
|
+
buffer = buffer.slice(split + 2);
|
|
210
|
+
split = buffer.indexOf("\n\n");
|
|
211
|
+
}
|
|
212
|
+
if (done) break;
|
|
213
|
+
}
|
|
214
|
+
if (buffer.trim()) {
|
|
215
|
+
const event = parsePiMessagesEvent(buffer);
|
|
216
|
+
if (event) yield event;
|
|
217
|
+
}
|
|
218
|
+
} finally {
|
|
219
|
+
reader.releaseLock();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function parsePiMessagesEvent(raw) {
|
|
223
|
+
const data = raw.split("\n").find((line) => line.startsWith("data:"))?.slice(5).trim();
|
|
224
|
+
return data && data !== "[DONE]" ? JSON.parse(data) : void 0;
|
|
225
|
+
}
|
|
226
|
+
function createErrorEvent(model, error, aborted) {
|
|
227
|
+
const reason = aborted ? "aborted" : "error";
|
|
228
|
+
const assistantMessage = {
|
|
229
|
+
role: "assistant",
|
|
230
|
+
content: [],
|
|
231
|
+
api: model.api,
|
|
232
|
+
provider: model.provider,
|
|
233
|
+
model: model.id,
|
|
234
|
+
usage: createEmptyUsage(),
|
|
235
|
+
stopReason: reason,
|
|
236
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
237
|
+
timestamp: Date.now()
|
|
238
|
+
};
|
|
239
|
+
if (!aborted && error instanceof PiMessagesResponseError) appendAssistantMessageDiagnostic(assistantMessage, createAssistantMessageDiagnostic("pi_messages_response_failure", error, error.diagnosticDetails));
|
|
240
|
+
return {
|
|
241
|
+
type: "error",
|
|
242
|
+
reason,
|
|
243
|
+
error: assistantMessage
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function resolveCacheRetention(cacheRetention, env) {
|
|
247
|
+
if (cacheRetention) return cacheRetention;
|
|
248
|
+
return getProviderEnvValue("PI_CACHE_RETENTION", env) === "long" ? "long" : void 0;
|
|
249
|
+
}
|
|
250
|
+
const stream = (model, context, options) => {
|
|
251
|
+
const eventStream = new AssistantMessageEventStream();
|
|
252
|
+
const convertEvent = createEventConverter(model);
|
|
253
|
+
(async () => {
|
|
254
|
+
try {
|
|
255
|
+
const apiKey = options?.apiKey;
|
|
256
|
+
if (!apiKey) throw new Error(`No API key provided for provider "${model.provider}"`);
|
|
257
|
+
const url = new URL(`${model.baseUrl.replace(/\/+$/u, "")}/messages`);
|
|
258
|
+
if (options?.debug) url.searchParams.set("debug", "1");
|
|
259
|
+
let payload = {
|
|
260
|
+
model: model.id,
|
|
261
|
+
context,
|
|
262
|
+
options: {
|
|
263
|
+
temperature: options?.temperature,
|
|
264
|
+
maxTokens: options?.maxTokens,
|
|
265
|
+
reasoning: options?.reasoning,
|
|
266
|
+
cacheRetention: resolveCacheRetention(options?.cacheRetention, options?.env),
|
|
267
|
+
sessionId: options?.sessionId,
|
|
268
|
+
toolChoice: options?.toolChoice
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const nextPayload = await options?.onPayload?.(payload, model);
|
|
272
|
+
if (nextPayload !== void 0) payload = nextPayload;
|
|
273
|
+
const response = await (options?.fetch ?? globalThis.fetch)(url, {
|
|
274
|
+
method: "POST",
|
|
275
|
+
headers: providerHeadersToRecord(getIdentityHeaders(model, options?.identity), {
|
|
276
|
+
authorization: `Bearer ${apiKey}`,
|
|
277
|
+
accept: "text/event-stream",
|
|
278
|
+
"content-type": "application/json"
|
|
279
|
+
}, options?.headers),
|
|
280
|
+
body: JSON.stringify(payload),
|
|
281
|
+
signal: options?.signal
|
|
282
|
+
});
|
|
283
|
+
await options?.onResponse?.({
|
|
284
|
+
status: response.status,
|
|
285
|
+
headers: headersToRecord(response.headers)
|
|
286
|
+
}, model);
|
|
287
|
+
if (!response.ok) throw createPiMessagesResponseError(model, url, response, await response.text());
|
|
288
|
+
if (!response.body) throw new Error(`${model.provider} response has no body`);
|
|
289
|
+
for await (const piEvent of readPiMessagesEvents(response.body)) {
|
|
290
|
+
await options?.onProviderStreamEvent?.(piEvent, model);
|
|
291
|
+
const event = convertEvent(piEvent);
|
|
292
|
+
eventStream.push(event);
|
|
293
|
+
if (event.type === "done" || event.type === "error") return;
|
|
294
|
+
}
|
|
295
|
+
throw new Error(`${model.provider} stream ended without a terminal event`);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
eventStream.push(createErrorEvent(model, error, options?.signal?.aborted ?? false));
|
|
298
|
+
}
|
|
299
|
+
})();
|
|
300
|
+
return eventStream;
|
|
301
|
+
};
|
|
302
|
+
const streamSimple = (model, context, options) => {
|
|
303
|
+
const extra = options;
|
|
304
|
+
return stream(model, context, {
|
|
305
|
+
...options,
|
|
306
|
+
reasoning: options?.reasoning,
|
|
307
|
+
toolChoice: options?.toolChoice,
|
|
308
|
+
debug: extra?.debug
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
//#endregion
|
|
312
|
+
export { PiMessagesResponseError, stream, streamSimple };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { fn as piAgentDirectory, gn as nodeHost, mn as createSerialRunner } from "./serverPlugin-OOfjB8tm.js";
|
|
2
|
+
import { i as readTextIfExists } from "./platformFiles-DB3Cw1l_.js";
|
|
3
|
+
import "./platform-yhQXrrM_.js";
|
|
4
|
+
import { n as writePrivateAtomicJsonAsync } from "./atomicJson-DCIsEywH.js";
|
|
5
|
+
import "./piSettings-tdui0CZI.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
//#region ../../foundations/po-config/src/services/imageSettings/index.ts
|
|
8
|
+
const IMAGE_SETTINGS_KEY = "images";
|
|
9
|
+
const IMAGE_AUTO_RESIZE_KEY = "autoResize";
|
|
10
|
+
const IMAGE_MAX_DIMENSION_KEY = "maxDimension";
|
|
11
|
+
/** Pi's own cap, from its resize core; also the largest value worth writing. */
|
|
12
|
+
const DEFAULT_IMAGE_MAX_DIMENSION = 2e3;
|
|
13
|
+
function clampImageMaxDimension(value) {
|
|
14
|
+
const rounded = Math.round(value);
|
|
15
|
+
if (rounded < 256) return 256;
|
|
16
|
+
if (rounded > 2e3) return DEFAULT_IMAGE_MAX_DIMENSION;
|
|
17
|
+
return rounded;
|
|
18
|
+
}
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
/** Resolves the effective limits, defaulting anything absent or unusable. */
|
|
23
|
+
function parsePiImageSettings(config) {
|
|
24
|
+
const images = config[IMAGE_SETTINGS_KEY];
|
|
25
|
+
if (!isRecord(images)) return {
|
|
26
|
+
autoResize: true,
|
|
27
|
+
maxDimension: DEFAULT_IMAGE_MAX_DIMENSION
|
|
28
|
+
};
|
|
29
|
+
const autoResize = images[IMAGE_AUTO_RESIZE_KEY];
|
|
30
|
+
const maxDimension = images[IMAGE_MAX_DIMENSION_KEY];
|
|
31
|
+
return {
|
|
32
|
+
autoResize: typeof autoResize === "boolean" ? autoResize : true,
|
|
33
|
+
maxDimension: typeof maxDimension === "number" && Number.isFinite(maxDimension) ? clampImageMaxDimension(maxDimension) : DEFAULT_IMAGE_MAX_DIMENSION
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Folds a change into the `images` object of a settings document, leaving every
|
|
38
|
+
* other key of that document, and of `images` itself, as it was.
|
|
39
|
+
*/
|
|
40
|
+
function applyPiImageSettings(config, update) {
|
|
41
|
+
const existing = config[IMAGE_SETTINGS_KEY];
|
|
42
|
+
const images = isRecord(existing) ? { ...existing } : {};
|
|
43
|
+
if (update.autoResize !== void 0) images[IMAGE_AUTO_RESIZE_KEY] = update.autoResize;
|
|
44
|
+
if (update.maxDimension !== void 0) images[IMAGE_MAX_DIMENSION_KEY] = clampImageMaxDimension(update.maxDimension);
|
|
45
|
+
return {
|
|
46
|
+
...config,
|
|
47
|
+
[IMAGE_SETTINGS_KEY]: images
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region ../../foundations/po-config/src/services/piConfig/core.ts
|
|
52
|
+
const SETTINGS_FILE_NAME = "settings.json";
|
|
53
|
+
const CONFIG_DIR_NAME = ".pi";
|
|
54
|
+
/** An explicit home other than the real one is isolated from the process environment. */
|
|
55
|
+
function defaultAgentDirectory(homeDirectory) {
|
|
56
|
+
return piAgentDirectory(homeDirectory === nodeHost.homeDirectory() ? process.env : {}, homeDirectory);
|
|
57
|
+
}
|
|
58
|
+
function isObject(value) {
|
|
59
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60
|
+
}
|
|
61
|
+
function mergeConfig(base, override) {
|
|
62
|
+
const result = { ...base };
|
|
63
|
+
for (const [key, value] of Object.entries(override)) {
|
|
64
|
+
const current = result[key];
|
|
65
|
+
result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/** Parses one settings file; `undefined` text means the file is missing. */
|
|
70
|
+
function configFromText(text, filePath) {
|
|
71
|
+
if (text === void 0) return {};
|
|
72
|
+
let parsed;
|
|
73
|
+
try {
|
|
74
|
+
parsed = JSON.parse(text);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });
|
|
77
|
+
}
|
|
78
|
+
if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);
|
|
79
|
+
return parsed;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Where the image limits are read from and written to.
|
|
83
|
+
*
|
|
84
|
+
* The user layer only. Pi merges a trusted project settings.json over it, but
|
|
85
|
+
* these limits describe one machine's tolerance for image payloads rather than
|
|
86
|
+
* one repository's, and the cockpit page that writes them has no repository
|
|
87
|
+
* scope to offer. The legacy user path is still read, because a machine that
|
|
88
|
+
* has not been migrated still answers from it.
|
|
89
|
+
*/
|
|
90
|
+
function userSettingsPaths(homeDirectory) {
|
|
91
|
+
return {
|
|
92
|
+
legacy: path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),
|
|
93
|
+
canonical: path.join(defaultAgentDirectory(homeDirectory), SETTINGS_FILE_NAME)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../../foundations/po-config/src/services/piConfig/index.ts
|
|
98
|
+
/** Image settings saves in this process are queued per file, so none reads a stale document. */
|
|
99
|
+
const imageSettingsWrites = createSerialRunner();
|
|
100
|
+
async function readConfig(fs, filePath, context) {
|
|
101
|
+
return configFromText(await readTextIfExists(fs, filePath, context), filePath);
|
|
102
|
+
}
|
|
103
|
+
async function readConfigPaths(fs, paths, context) {
|
|
104
|
+
return (await Promise.all(paths.map((filePath) => readConfig(fs, filePath, context)))).reduce(mergeConfig, {});
|
|
105
|
+
}
|
|
106
|
+
async function readPiImageSettings(fs, context, homeDirectory = nodeHost.homeDirectory()) {
|
|
107
|
+
const paths = userSettingsPaths(homeDirectory);
|
|
108
|
+
return parsePiImageSettings(await readConfigPaths(fs, [paths.legacy, paths.canonical], context));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Writes the changed keys back and reports the limits that now apply.
|
|
112
|
+
*
|
|
113
|
+
* Read-modify-write on Pi's own file, so a save races a concurrent Pi settings
|
|
114
|
+
* save rather than merging with it. Pi writes only the fields its UI touched,
|
|
115
|
+
* as this does, which keeps the window to the one setting being changed on
|
|
116
|
+
* both sides at once. Saves from this process are queued.
|
|
117
|
+
*/
|
|
118
|
+
async function savePiImageSettingsAsync(fs, update, context, homeDirectory = nodeHost.homeDirectory()) {
|
|
119
|
+
const paths = userSettingsPaths(homeDirectory);
|
|
120
|
+
await imageSettingsWrites.forKey(path.resolve(paths.canonical))(async () => {
|
|
121
|
+
const current = await readConfig(fs, paths.canonical, context);
|
|
122
|
+
await writePrivateAtomicJsonAsync(fs, paths.canonical, applyPiImageSettings(current, update), context);
|
|
123
|
+
});
|
|
124
|
+
return readPiImageSettings(fs, context, homeDirectory);
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { savePiImageSettingsAsync as n, DEFAULT_IMAGE_MAX_DIMENSION as r, readPiImageSettings as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./serverPlugin-OOfjB8tm.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { En as SessionIdentityDoc } from "./serverPlugin-OOfjB8tm.js";
|
|
2
2
|
//#region ../../core/po-core/src/services/durableSession/index.ts
|
|
3
3
|
/** Stamps a new session's identity, or checks an existing one matches the requested id. */
|
|
4
4
|
async function initializeSessionIdentity(session, request, context) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as BACKGROUND_CONTEXT, bn as getOrThrow } from "./serverPlugin-OOfjB8tm.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
//#region ../../core/po-core/src/services/platformFiles/index.ts
|
|
@@ -7,12 +7,37 @@ let largestTranscriptEntryBytes = 0;
|
|
|
7
7
|
function recordTranscriptProjection(bytes) {
|
|
8
8
|
if (Number.isSafeInteger(bytes) && bytes > 0) largestTranscriptEntryBytes = Math.max(largestTranscriptEntryBytes, bytes);
|
|
9
9
|
}
|
|
10
|
+
var FileTooLargeError = class extends Error {
|
|
11
|
+
constructor(filePath, maxBytes) {
|
|
12
|
+
super(`File exceeds ${maxBytes} byte read limit: ${filePath}`);
|
|
13
|
+
this.name = "FileTooLargeError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** Bounds allocation even when a file grows between stat and read. */
|
|
17
|
+
async function readBoundedFile(fs, filePath, maxBytes, context) {
|
|
18
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError("Invalid read limit.");
|
|
19
|
+
const reader = getOrThrow(await fs.openBinaryReader(filePath, {}, context));
|
|
20
|
+
try {
|
|
21
|
+
const info = getOrThrow(await reader.info(context));
|
|
22
|
+
if (info.size > maxBytes) throw new FileTooLargeError(filePath, maxBytes);
|
|
23
|
+
const data = getOrThrow(await reader.read(0, info.size, context));
|
|
24
|
+
const after = getOrThrow(await reader.info(context));
|
|
25
|
+
if (after.size > maxBytes) throw new FileTooLargeError(filePath, maxBytes);
|
|
26
|
+
if (data.length !== info.size || after.size !== info.size || after.mtimeMs !== info.mtimeMs) throw new Error(`File changed during access: ${filePath}`);
|
|
27
|
+
return data;
|
|
28
|
+
} finally {
|
|
29
|
+
await reader.close(BACKGROUND_CONTEXT);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
10
32
|
/** File text, or undefined when the file does not exist. Every other failure throws. */
|
|
11
33
|
async function readTextIfExists(fs, filePath, context) {
|
|
12
34
|
const result = await fs.readTextFile(filePath, context);
|
|
13
35
|
if (!result.ok && result.error.code === "not_found") return void 0;
|
|
14
36
|
return getOrThrow(result);
|
|
15
37
|
}
|
|
38
|
+
async function pathExists(fs, filePath, context) {
|
|
39
|
+
return getOrThrow(await fs.exists(filePath, context));
|
|
40
|
+
}
|
|
16
41
|
/** Removes a file or directory tree; a missing path is not an error. */
|
|
17
42
|
async function removePath(fs, filePath, context) {
|
|
18
43
|
getOrThrow(await fs.remove(filePath, {
|
|
@@ -36,4 +61,4 @@ async function writeFileAtomic(fs, filePath, content, context) {
|
|
|
36
61
|
}
|
|
37
62
|
}
|
|
38
63
|
//#endregion
|
|
39
|
-
export {
|
|
64
|
+
export { recordTranscriptProjection as a, readTextIfExists as i, pathExists as n, removePath as o, readBoundedFile as r, writeFileAtomic as s, FileTooLargeError as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region ../../core/po-core/src/schemas/pluginContributions.ts
|
|
2
|
+
/** Preserve schema inference at the declaration, before heterogeneous composition. */
|
|
3
|
+
function defineTool(tool) {
|
|
4
|
+
return {
|
|
5
|
+
...tool,
|
|
6
|
+
kind: "tool"
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function defineCommand(command) {
|
|
10
|
+
return {
|
|
11
|
+
...command,
|
|
12
|
+
kind: "command"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { defineTool as n, defineCommand as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Errors } from "./value-
|
|
1
|
+
import { $ as Boolean, B as String$1, X as Literal, ft as _Object_, mt as Optional } from "./serverPlugin-OOfjB8tm.js";
|
|
2
|
+
import { t as Errors } from "./value-DyVsxCwZ.js";
|
|
3
3
|
_Object_({
|
|
4
4
|
code: String$1({ minLength: 1 }),
|
|
5
5
|
message: String$1({ minLength: 1 }),
|