@agimon-ai/po-cloudflare 0.0.2-alpha.2 → 0.0.2-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/abort-signals-2GUraIGq.js +34 -0
- package/dist/agent-DZ-OKOHn.js +6850 -0
- package/dist/anthropic-messages-5ODquUB-.js +14317 -0
- package/dist/{apiContracts-CHOiCbS_.js → apiContracts-b33nSAAI.js} +18 -81
- package/dist/{approval-BMXqnTYd.js → approval-r3NnI1VC.js} +19 -3
- package/dist/{approvalPrompt-Bg1JrEEY.js → approvalPrompt-DWoXxu3S.js} +2 -2
- package/dist/artifactFiles-DLCReI0-.js +1 -0
- package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-XeNS0L9M.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-B6ZW0nkR.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-bVR64sHO.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53-D7tZz3io.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-DdwScfiX.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-DgSxZJCV.js} +2 -2
- package/dist/assets/assets/channel-TPcVvp_3.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-D5TXC2SM.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T-BWhOSvo1.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-HkkBzLtZ.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-CBnjycLU.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-75lIIq8T.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-D8PpnXMk.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-CXRS2NIN.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-BocUqS94.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-CHf_ogYT.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-DrW1PaIv.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-CLoA7bFm.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-BmBsrj9I.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-iFE4Tl8c.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-DShE_cgv.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-B3oLvSXy.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-B14vKK7C.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-Da8elIW2.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-Du4tGtiJ.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-Cyj6i_WI.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-DFWXwO7A.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-C1wB_cf-.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-MYCOBYl6.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-BFYbKUFf.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-6siqTpv_.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-CaBr9CoB.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-DAvmuDpc.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-CJnhgCpo.js} +2 -2
- package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-BQ4W1R18.js} +2 -2
- package/dist/assets/assets/{dist-DvgCCshF.js → dist-BnzFckPF.js} +2 -2
- package/dist/assets/assets/{dist-gfbb4ygy.js → dist-CFtBpcYL.js} +2 -2
- package/dist/assets/assets/{dist-BabjcJ3j.js → dist-CIQX1z4W.js} +2 -2
- package/dist/assets/assets/{dist-XIZum9n5.js → dist-ChHYoe9_.js} +2 -2
- package/dist/assets/assets/{dist-1-mhYUBH.js → dist-DKxZO8d9.js} +2 -2
- package/dist/assets/assets/{dist-h6SOnP8-.js → dist-DL6z28wl.js} +2 -2
- package/dist/assets/assets/{dist-B3JXhDWV.js → dist-DNyn1p9Z.js} +2 -2
- package/dist/assets/assets/{dist-Izr2SB3q.js → dist-qYlLXIa8.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-AUcqDTM3.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-aA10PEHJ.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-hhYiqA-x.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-BQZqbRo5.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BuyysPYC.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-CLON1GpW.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-DbmvNwR2.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-DJVO0WlL.js} +2 -2
- package/dist/assets/assets/index-BiTVAj5E.js +155 -0
- package/dist/assets/assets/index-CBNQEGK3.css +1 -0
- package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-CAt3Nt3g.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-DTuqH-Zb.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-BnWvdonT.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-Btxtcgvl.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-q7ek9o_H.js} +2 -2
- package/dist/assets/assets/{line-BsXJZn93.js → line-B7yLilmC.js} +2 -2
- package/dist/assets/assets/{linear-BHYaD5T0.js → linear-y8aSKEli.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-B4rH50nD.js} +4 -4
- package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-DnRVHTjE.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-DT9Afs2v.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-CnqNbu4p.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-cvxdBBFq.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-etXMNsaL.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-CBN-R3_j.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-C5jjVPIH.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-CAMd_mrV.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-DIs3auoe.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-CJXr1qWy.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-DfwtykqI.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-B8beAhTs.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-BDcQE-EL.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-KJ4-QjZM.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-VjIB-Ybr.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-MfMuWq1M.js} +2 -2
- package/dist/assets/assets/{src-gihY33R9.js → src-BAxIj8GJ.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-mHwLRRCY.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-PArlYoqV.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-The09-5S.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-B2nKiNFU.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-gU23_RuI.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-CiqoMvZa.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-DpeoWpMK.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-C31iGKvM.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-CIzHhzNw.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-DIIkoezc.js} +2 -2
- package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-RFseiMZW.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-QiHL91kC.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +2 -2
- package/dist/assets/plugins/assets/base-CKKRZ7-h.css +2 -0
- package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/dist/assets/plugins/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/assets/plugins/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
- package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
- package/dist/assets/plugins/chunks/po-web-runtime-BJDT6Lbw.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -0
- package/dist/assets/plugins/slots/approval.293d9a00-BXIhaPlQ.js +2 -0
- package/dist/assets/plugins/slots/artifacts.24567664-ZzR0gbvy.js +1 -0
- package/dist/assets/plugins/slots/author.0998a880-DAbA-7rb.js +93 -0
- package/dist/assets/plugins/slots/autocompact.dd97d013-IVq4Z6qm.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.36d7400b-CpCLjRRN.js +7 -0
- package/dist/assets/plugins/slots/codemode.8eaee717-VWt9PqsU.js +10 -0
- package/dist/assets/plugins/slots/domain.5e95fc37-5PIUBqDe.js +1 -0
- package/dist/assets/plugins/slots/edit.385c9aa9-DNAjPNG5.js +7 -0
- package/dist/assets/plugins/slots/files.daf34ed8-CQaTz0i1.js +2 -0
- package/dist/assets/plugins/slots/goal.77ec9930-B8EkarBq.js +1 -0
- package/dist/assets/plugins/slots/grep.02052cdc-CIRhO2gY.js +1 -0
- package/dist/assets/plugins/slots/help.ecd4c0f9-naMF9NN1.js +3 -0
- package/dist/assets/plugins/slots/log.a86eb6d0-D5__rAZJ.js +4 -0
- package/dist/assets/plugins/slots/mcp.974af249-DPNHn9XH.js +109 -0
- package/dist/assets/plugins/slots/plan.bafb8f68-C5GEpybF.js +3 -0
- package/dist/assets/plugins/slots/profile.48851a1d-yX6tzV3x.js +1 -0
- package/dist/assets/plugins/slots/prompts.723d7748-B7zpPeoF.js +3 -0
- package/dist/assets/plugins/slots/read.46bf6536-Cw5Z5z5T.js +1 -0
- package/dist/assets/plugins/slots/runner.53e9bd76-CiQR_FPX.js +8 -0
- package/dist/assets/plugins/slots/skill.086701a4-CL6h_F-x.js +4 -0
- package/dist/assets/plugins/slots/vault.ac9935c8-DKERQYg4.js +1 -0
- package/dist/assets/plugins/slots/voice.e85ca7f9-DEgb-U9m.js +1 -0
- package/dist/assets/pwa/pwa.js +12 -12
- package/dist/assets/pwa/sw.js +4 -4
- package/dist/{atomicJson-BJfPFSYF.js → atomicJson-C_7F2zD1.js} +2 -3
- package/dist/azure-openai-config-COZUaRzM.js +55 -0
- package/dist/azure-openai-responses-Cs4k2HOd.js +183 -0
- package/dist/{backgroundWork-CeFrbRnj.js → backgroundWork-B1mPDYlf.js} +1 -1
- package/dist/browser-BWf8OMfl.js +3 -0
- package/dist/childSession-Cf2-kH4O.js +22 -0
- package/dist/classifier-shared-IhSH9hhh.js +106 -0
- package/dist/cloudflare-workers-ai-system-one-BNnc8MuH.js +52 -0
- package/dist/{codemode-DbPu0yJN.js → codemode-DQFmrosw.js} +5 -2
- package/dist/contracts-DD3f1Lpn.js +19 -0
- package/dist/diagnostics-1lYFeSJe.js +131 -0
- package/dist/{server-D3PQk1Gt.js → dist-B-vqs6tA.js} +1 -546
- package/dist/dist-Dvx5mlIR.js +50 -0
- package/dist/env-api-keys-Bow6MJe2.js +32 -0
- package/dist/error-body-CJk7jMUh.js +102 -0
- package/dist/esm-BKJy3O9-.js +1553 -0
- package/dist/exports-B0WMEXCP.js +34 -0
- package/dist/{remoteMcp-CMqZldeA.js → exports-D09VsUk-.js} +1153 -175
- package/dist/{exports-BNZz2DNU.js → exports-nV43ShA7.js} +25 -9
- package/dist/{extensionFile-CXOa5G4C.js → extensionFile-DNM4xsje.js} +26 -2
- package/dist/github-copilot-headers-D1RedfLn.js +22 -0
- package/dist/google-generative-ai-DXTILNT0.js +328 -0
- package/dist/google-shared-e4JDCTVP.js +19588 -0
- package/dist/google-vertex-a1lzvJfq.js +374 -0
- package/dist/{domains-BNjGTOPj.js → harnessState-Dwrk3lfv.js} +175 -16
- package/dist/{harnessStore-BT706Ly6.js → harnessStore-Z7yDLO45.js} +4 -5
- package/dist/hash-Dt6RIbkn.js +16 -0
- package/dist/headers-CwtEVQvr.js +17 -0
- package/dist/help-w6vVEZGL.js +101 -0
- package/dist/hubChannel-Cm-sxOvU.js +21 -0
- package/dist/hubRevisions-58pU2dW5.js +363 -0
- package/dist/identity-BgfHobJH.js +165 -0
- package/dist/index.edge-COJJ_Dv2.js +937 -0
- package/dist/index.edge-ChYa2LU4.js +14 -0
- package/dist/index.edge-ClLTmPFz.js +191 -0
- package/dist/index.edge-DyYmurS7.js +62 -0
- package/dist/index.edge-K0w5auwG.js +56 -0
- package/dist/index.edge-Xa5LLtxz.js +67 -0
- package/dist/iso-BPQViXM8.js +10 -0
- package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-CUkYUs1f.js} +193 -15
- package/dist/{majorModes-DbCfLZH3.js → majorModes-BB0PXgFn.js} +4 -14
- package/dist/majorModes-C7vtBs4D.js +1 -0
- package/dist/{mcpProjection-BsP0IEnb.js → mcpProjection-BtKzB6oK.js} +2 -2
- package/dist/migrations-5gbLIQIc.js +32 -0
- package/dist/mistral-conversations-CLwhVDjA.js +689 -0
- package/dist/modeDefinition-C3Zbrw48.js +44 -0
- package/dist/models-Chzm15vC.js +1511 -0
- package/dist/narration-CpRurWLO.js +127 -0
- package/dist/node-BT4GsJQp.js +2479 -0
- package/dist/node-DytJOfYf.js +23 -0
- package/dist/notification-kckG3leF.js +102 -0
- package/dist/openai-codex-responses-DRMONxDE.js +1210 -0
- package/dist/openai-completions-CcNhAv8l.js +984 -0
- package/dist/openai-decisions-BsFjaAGw.js +142 -0
- package/dist/openai-kPrtlgjl.js +17357 -0
- package/dist/openai-prompt-cache-Bc6qNWt0.js +8 -0
- package/dist/openai-responses-C5Gp2UOV.js +281 -0
- package/dist/openai-responses-shared-BbSi-wBR.js +661 -0
- package/dist/openrouter-cost-CvC52g3b.js +30 -0
- package/dist/openrouter-images-BoHl8g8p.js +124 -0
- package/dist/{hubChannel-BHQyzcOo.js → packageApi-t1oCjNDU.js} +4 -41
- package/dist/photon_rs_bg.wasm +0 -0
- package/dist/pi-messages-BXfrZLC7.js +312 -0
- package/dist/piConfig-DQzlbPY4.js +126 -0
- package/dist/piSettings-Cf1QofNe.js +1 -0
- package/dist/platform-BIEiM4TG.js +113 -0
- package/dist/pluginContributions-Be9EnCAW.js +16 -0
- package/dist/pluginProtocol-BqXXyI4z.js +80 -0
- package/dist/{protocol-Xpm_mCNN.js → protocol-DDL8geoS.js} +2 -2
- package/dist/provider-env-CxhHUFiF.js +38 -0
- package/dist/provider-retry-BUoezuw8.js +79 -0
- package/dist/sanitize-unicode-C3Ec8oL6.js +26 -0
- package/dist/sealedChannel-BeWNTWys.js +27 -0
- package/dist/server-AbXyhXlY.js +217 -0
- package/dist/server-B6dqQoh2.js +1518 -0
- package/dist/server-BIHo9TFu.js +505 -0
- package/dist/{server-BZh1ZXz_.js → server-BJ7DNzCp.js} +8 -19
- package/dist/server-BO-j_GbD.js +15106 -0
- package/dist/{server-D4W7EdJY.js → server-BQzAiMns.js} +16 -16
- package/dist/server-BR7SZtj7.js +3125 -0
- package/dist/{server-BE6VqEiA.js → server-BT2ORK83.js} +20 -12
- package/dist/server-BbSHYRnY.js +295 -0
- package/dist/server-BqoKlEGk.js +1806 -0
- package/dist/{server-tvgQ99rv.js → server-Busl0pQI.js} +370 -120
- package/dist/server-CIHM4jqu.js +1116 -0
- package/dist/server-CgWSSdvd.js +576 -0
- package/dist/{server-Dpgh8PDh.js → server-Co_UWKrR.js} +14 -5
- package/dist/{server-BAAL9-NA.js → server-CuEPb7u-.js} +3 -10
- package/dist/{server-Dt4y1rZD.js → server-D40q2Jpx.js} +47 -27
- package/dist/server-DCyf2Asb.js +679 -0
- package/dist/server-DH7PfLln.js +148 -0
- package/dist/server-DJ8bc89M.js +934 -0
- package/dist/server-DYdp0W9v.js +489 -0
- package/dist/server-DsdPEYGu.js +639 -0
- package/dist/server-DymH4Ucq.js +189 -0
- package/dist/server-IqECnUrb.js +834 -0
- package/dist/{server-36iuA3MI.js → server-KBgW77zh.js} +3 -3
- package/dist/server-RW_9R3R3.js +1522 -0
- package/dist/server-aUit8j6r.js +1028 -0
- package/dist/{server-DJAanjoI.js → server-gifRriZK.js} +491 -103
- package/dist/server-nkUlqnAL.js +2658 -0
- package/dist/server-oxyEbv1a.js +1256 -0
- package/dist/{server-D8ndq0wL.js → server-ub3s16Mc.js} +11 -9
- package/dist/{build-2gFaVEfG.js → serverPlugin-CELT6P0Q.js} +3946 -3
- package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-RQGvfm6E.js} +550 -760
- package/dist/simple-options-CFzI5Pd_.js +156 -0
- package/dist/streaming-json-BWTHTwz-.js +858 -0
- package/dist/system-one-shared-CiIrx29d.js +132 -0
- package/dist/{notification-D76PSL7r.js → telemetry-Csv1ZxAn.js} +1 -92
- package/dist/transform-messages-D77af7Bx.js +356 -0
- package/dist/truncate-M3KbFyVj.js +89 -0
- package/dist/{server-A-_GFpPr.js → type-ASYnCGVW.js} +10 -1031
- package/dist/typesafe-system-one-DGxeggJh.js +37 -0
- package/dist/uuid-B0QJx6Kr.js +31 -0
- package/dist/{validation-D77NZBrx.js → validation-BJxVSAwx.js} +8 -3
- package/dist/{value-Djvc2foV.js → value-_W31So3B.js} +1 -1
- package/dist/vaultSettings-Di3n5YIg.js +328 -0
- package/dist/voiceTools-RMn4HvWo.js +246 -0
- package/dist/web-DCP7ELJj.js +3 -0
- package/dist/worker.js +95288 -49863
- package/dist/workflow-B7qx0Vv9.js +79 -0
- package/package.json +37 -22
- package/wrangler.jsonc +4 -2
- package/dist/assets/assets/channel-CMrEzemr.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-CFf0S6bN.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BhGbWVf0.js +0 -1
- package/dist/assets/assets/index-Bx_K4Joy.js +0 -155
- package/dist/assets/assets/index-DZM68mTk.css +0 -1
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-q91tR8ri.js +0 -9
- package/dist/contextProjection-DVP2Vc5j.js +0 -188
- package/dist/harnessState-gmzJcPGt.js +0 -88
- package/dist/harnessStore-BiH9vSuD.js +0 -1
- package/dist/index.edge-BgSx_gRO.js +0 -45
- package/dist/majorModes-BvWNqoHt.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- package/dist/platform-B4AAgwJ0.js +0 -16
- package/dist/platformFiles-C_bXo4Ig.js +0 -39
- package/dist/server-BZaPPoQp.js +0 -592
- package/dist/server-D75MWDhB.js +0 -118
- package/dist/server-r358hzQg.js +0 -280
- package/dist/serverPlugin-BOI6c6s5.js +0 -3393
|
@@ -0,0 +1,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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ar as defineServiceContract } from "./serverPlugin-CELT6P0Q.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) {
|
|
@@ -64,44 +64,7 @@ function poApiCallerFrom(headers) {
|
|
|
64
64
|
...federation
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
* Rekey well before the counter could wrap.
|
|
70
|
-
*
|
|
71
|
-
* A repeated nonce under one AES-GCM key is catastrophic, not merely weak: it
|
|
72
|
-
* leaks the XOR of two plaintexts and the authentication subkey. The counter is
|
|
73
|
-
* 64 bits, so this bound is nowhere near it; the point is that the bound exists
|
|
74
|
-
* and is enforced rather than assumed.
|
|
75
|
-
*/
|
|
76
|
-
const MAX_MESSAGES_PER_KEY = 2 ** 32;
|
|
77
|
-
/**
|
|
78
|
-
* HKDF info strings, one per direction.
|
|
79
|
-
*
|
|
80
|
-
* Separate keys per direction, not one shared key, so a message the server sent
|
|
81
|
-
* can never be replayed back at it as though the client had sent it.
|
|
82
|
-
*/
|
|
83
|
-
const CLIENT_TO_SERVER_INFO = "po/sealed/c2s/v1";
|
|
84
|
-
const SERVER_TO_CLIENT_INFO = "po/sealed/s2c/v1";
|
|
85
|
-
function infoFor(direction) {
|
|
86
|
-
return direction === "c2s" ? CLIENT_TO_SERVER_INFO : SERVER_TO_CLIENT_INFO;
|
|
87
|
-
}
|
|
88
|
-
function isSealedEnvelope(value) {
|
|
89
|
-
if (typeof value !== "object" || value === null) return false;
|
|
90
|
-
const candidate = value;
|
|
91
|
-
return candidate.v === 1 && typeof candidate.n === "string" && typeof candidate.c === "string";
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region ../../core/po-core/src/schemas/hubChannel.ts
|
|
95
|
-
/** Compact host-wide session attention, published over the existing direct event bus. */
|
|
96
|
-
const PO_SESSION_ATTENTION_EVENT = "po.session.attention";
|
|
97
|
-
/**
|
|
98
|
-
* Provenance of a session a workflow step opened.
|
|
99
|
-
*
|
|
100
|
-
* The step's conversation belongs to the workflow that ran it and is read in
|
|
101
|
-
* that workflow's view, so the session rail leaves such sessions out.
|
|
102
|
-
*/
|
|
103
|
-
const WORKFLOW_STEP_SESSION_PROVENANCE = "workflow";
|
|
104
|
-
/** Provenance of a conversation an external MCP client opened and drives. */
|
|
105
|
-
const REMOTE_CONVERSATION_SESSION_PROVENANCE = "remote-conversation";
|
|
67
|
+
const PO_EDIT_PRESENCE_SERVICE = "po/edit-presence";
|
|
68
|
+
const PO_EDIT_PRESENCE_CONTRACT = defineServiceContract(PO_EDIT_PRESENCE_SERVICE, { scope: "workspace" });
|
|
106
69
|
//#endregion
|
|
107
|
-
export {
|
|
70
|
+
export { poApiCallerFrom as a, parsePoSocketPath as i, PO_EDIT_PRESENCE_CONTRACT as n, PO_EDIT_PRESENCE_SERVICE as r, PO_API_ROUTE_PREFIX as t };
|
|
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,126 @@
|
|
|
1
|
+
import { gn as createSerialRunner, mn as piAgentDirectory, vn as nodeHost } from "./serverPlugin-CELT6P0Q.js";
|
|
2
|
+
import { s as readTextIfExists } from "./platform-BIEiM4TG.js";
|
|
3
|
+
import { n as writePrivateAtomicJsonAsync } from "./atomicJson-C_7F2zD1.js";
|
|
4
|
+
import "./piSettings-Cf1QofNe.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
//#region ../../foundations/po-config/src/services/imageSettings/index.ts
|
|
7
|
+
const IMAGE_SETTINGS_KEY = "images";
|
|
8
|
+
const IMAGE_AUTO_RESIZE_KEY = "autoResize";
|
|
9
|
+
const IMAGE_MAX_DIMENSION_KEY = "maxDimension";
|
|
10
|
+
/** Pi's own cap, from its resize core; also the largest value worth writing. */
|
|
11
|
+
const DEFAULT_IMAGE_MAX_DIMENSION = 2e3;
|
|
12
|
+
function clampImageMaxDimension(value) {
|
|
13
|
+
const rounded = Math.round(value);
|
|
14
|
+
if (rounded < 256) return 256;
|
|
15
|
+
if (rounded > 2e3) return DEFAULT_IMAGE_MAX_DIMENSION;
|
|
16
|
+
return rounded;
|
|
17
|
+
}
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
/** Resolves the effective limits, defaulting anything absent or unusable. */
|
|
22
|
+
function parsePiImageSettings(config) {
|
|
23
|
+
const images = config[IMAGE_SETTINGS_KEY];
|
|
24
|
+
if (!isRecord(images)) return {
|
|
25
|
+
autoResize: true,
|
|
26
|
+
maxDimension: DEFAULT_IMAGE_MAX_DIMENSION
|
|
27
|
+
};
|
|
28
|
+
const autoResize = images[IMAGE_AUTO_RESIZE_KEY];
|
|
29
|
+
const maxDimension = images[IMAGE_MAX_DIMENSION_KEY];
|
|
30
|
+
return {
|
|
31
|
+
autoResize: typeof autoResize === "boolean" ? autoResize : true,
|
|
32
|
+
maxDimension: typeof maxDimension === "number" && Number.isFinite(maxDimension) ? clampImageMaxDimension(maxDimension) : DEFAULT_IMAGE_MAX_DIMENSION
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Folds a change into the `images` object of a settings document, leaving every
|
|
37
|
+
* other key of that document, and of `images` itself, as it was.
|
|
38
|
+
*/
|
|
39
|
+
function applyPiImageSettings(config, update) {
|
|
40
|
+
const existing = config[IMAGE_SETTINGS_KEY];
|
|
41
|
+
const images = isRecord(existing) ? { ...existing } : {};
|
|
42
|
+
if (update.autoResize !== void 0) images[IMAGE_AUTO_RESIZE_KEY] = update.autoResize;
|
|
43
|
+
if (update.maxDimension !== void 0) images[IMAGE_MAX_DIMENSION_KEY] = clampImageMaxDimension(update.maxDimension);
|
|
44
|
+
return {
|
|
45
|
+
...config,
|
|
46
|
+
[IMAGE_SETTINGS_KEY]: images
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region ../../foundations/po-config/src/services/piConfig/core.ts
|
|
51
|
+
const SETTINGS_FILE_NAME = "settings.json";
|
|
52
|
+
const CONFIG_DIR_NAME = ".pi";
|
|
53
|
+
/** An explicit home other than the real one is isolated from the process environment. */
|
|
54
|
+
function defaultAgentDirectory(homeDirectory) {
|
|
55
|
+
return piAgentDirectory(homeDirectory === nodeHost.homeDirectory() ? process.env : {}, homeDirectory);
|
|
56
|
+
}
|
|
57
|
+
function isObject(value) {
|
|
58
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59
|
+
}
|
|
60
|
+
function mergeConfig(base, override) {
|
|
61
|
+
const result = { ...base };
|
|
62
|
+
for (const [key, value] of Object.entries(override)) {
|
|
63
|
+
const current = result[key];
|
|
64
|
+
result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/** Parses one settings file; `undefined` text means the file is missing. */
|
|
69
|
+
function configFromText(text, filePath) {
|
|
70
|
+
if (text === void 0) return {};
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(text);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });
|
|
76
|
+
}
|
|
77
|
+
if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Where the image limits are read from and written to.
|
|
82
|
+
*
|
|
83
|
+
* The user layer only. Pi merges a trusted project settings.json over it, but
|
|
84
|
+
* these limits describe one machine's tolerance for image payloads rather than
|
|
85
|
+
* one repository's, and the cockpit page that writes them has no repository
|
|
86
|
+
* scope to offer. The legacy user path is still read, because a machine that
|
|
87
|
+
* has not been migrated still answers from it.
|
|
88
|
+
*/
|
|
89
|
+
function userSettingsPaths(homeDirectory) {
|
|
90
|
+
return {
|
|
91
|
+
legacy: path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),
|
|
92
|
+
canonical: path.join(defaultAgentDirectory(homeDirectory), SETTINGS_FILE_NAME)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../../foundations/po-config/src/services/piConfig/index.ts
|
|
97
|
+
/** Image settings saves in this process are queued per file, so none reads a stale document. */
|
|
98
|
+
const imageSettingsWrites = createSerialRunner();
|
|
99
|
+
async function readConfig(fs, filePath, context) {
|
|
100
|
+
return configFromText(await readTextIfExists(fs, filePath, context), filePath);
|
|
101
|
+
}
|
|
102
|
+
async function readConfigPaths(fs, paths, context) {
|
|
103
|
+
return (await Promise.all(paths.map((filePath) => readConfig(fs, filePath, context)))).reduce(mergeConfig, {});
|
|
104
|
+
}
|
|
105
|
+
async function readPiImageSettings(fs, context, homeDirectory = nodeHost.homeDirectory()) {
|
|
106
|
+
const paths = userSettingsPaths(homeDirectory);
|
|
107
|
+
return parsePiImageSettings(await readConfigPaths(fs, [paths.legacy, paths.canonical], context));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Writes the changed keys back and reports the limits that now apply.
|
|
111
|
+
*
|
|
112
|
+
* Read-modify-write on Pi's own file, so a save races a concurrent Pi settings
|
|
113
|
+
* save rather than merging with it. Pi writes only the fields its UI touched,
|
|
114
|
+
* as this does, which keeps the window to the one setting being changed on
|
|
115
|
+
* both sides at once. Saves from this process are queued.
|
|
116
|
+
*/
|
|
117
|
+
async function savePiImageSettingsAsync(fs, update, context, homeDirectory = nodeHost.homeDirectory()) {
|
|
118
|
+
const paths = userSettingsPaths(homeDirectory);
|
|
119
|
+
await imageSettingsWrites.forKey(path.resolve(paths.canonical))(async () => {
|
|
120
|
+
const current = await readConfig(fs, paths.canonical, context);
|
|
121
|
+
await writePrivateAtomicJsonAsync(fs, paths.canonical, applyPiImageSettings(current, update), context);
|
|
122
|
+
});
|
|
123
|
+
return readPiImageSettings(fs, context, homeDirectory);
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { savePiImageSettingsAsync as n, DEFAULT_IMAGE_MAX_DIMENSION as r, readPiImageSettings as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./serverPlugin-CELT6P0Q.js";
|